Annotation of prex-old/sys/arch/arm/cats/platform.h, Revision 1.3
1.1 nbrk 1: /*
2: * Copyright (c) 2007, Kohsuke Ohtani
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms, with or without
6: * modification, are permitted provided that the following conditions
7: * are met:
8: * 1. Redistributions of source code must retain the above copyright
9: * notice, this list of conditions and the following disclaimer.
10: * 2. Redistributions in binary form must reproduce the above copyright
11: * notice, this list of conditions and the following disclaimer in the
12: * documentation and/or other materials provided with the distribution.
13: * 3. Neither the name of the author nor the names of any co-contributors
14: * may be used to endorse or promote products derived from this software
15: * without specific prior written permission.
16: *
17: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27: * SUCH DAMAGE.
28: */
29:
1.2 nbrk 30: #ifndef _CATS_PLATFORM_H
31: #define _CATS_PLATFORM_H
1.1 nbrk 32:
33: /*
34: * Memory location
35: */
36:
37: #define PAGE_OFFSET 0x00000000
38:
1.3 ! nbrk 39: #define KERNEL_BASE 0x00100000
! 40: #define KERNEL_MAX 0x00400000
! 41: #define USER_BASE 0x00400000
! 42: #define USER_MAX 0x02000000
1.2 nbrk 43:
1.3 ! nbrk 44: #define BOOT_INFO_SIZE 0x00000800
! 45: #define BOOT_INFO (0x00100000 - BOOT_INFO_SIZE)
! 46: #define BOOT_STACK 0x00002800
! 47: #define INT_STACK 0x00004800
! 48: #define SYS_STACK 0x00008800
1.1 nbrk 49:
50: #ifndef __ASSEMBLY__
51:
52: /*
53: * Page mapping
54: */
55: #define phys_to_virt(p_addr) (void *)((u_long)(p_addr) + PAGE_OFFSET)
56: #define virt_to_phys(v_addr) (void *)((u_long)(v_addr) - PAGE_OFFSET)
57:
58: /*
59: * Kernel/User Locations
60: */
61: #define kern_area(addr) \
62: (((u_long)(addr) >= KERNEL_BASE) && ((u_long)(addr) < KERNEL_MAX))
63: #define user_area(addr) \
64: (((u_long)(addr) >= USER_BASE) && ((u_long)(addr) < USER_MAX))
65:
66: /*
67: * Interrupt
68: */
69: #define NIRQS 14 /* number of interrupt vectors */
70:
71: static __inline void
72: interrupt_enable(void)
73: {
74: #ifndef __lint__
75: u_long val;
76:
77: __asm__ __volatile__(
78: "mrs %0, cpsr\n\t"
79: "bic %0, %0, #0xc0\n\t" /* Enable IRQ & FIQ */
80: "msr cpsr_c, %0\n\t"
81: :"=&r" (val)
82: :
83: : "memory");
84: #endif
85: }
86:
87: static __inline void
88: interrupt_disable(void)
89: {
90: #ifndef __lint__
91: u_long val;
92:
93: __asm__ __volatile__(
94: "mrs %0, cpsr\n\t"
95: "orr %0, %0, #0xc0\n\t" /* Disable IRQ & FIQ */
96: "msr cpsr_c, %0\n\t"
97: :"=&r" (val)
98: :
99: : "memory");
100: #endif
101: }
102:
103: static __inline void
104: interrupt_save(int *sts)
105: {
106: u_long val;
107:
108: __asm__ __volatile__(
109: "mrs %0, cpsr\n\t"
110: :"=&r" (val)
111: :
112: :"memory");
113: *sts = (int)val;
114: }
115:
116: static __inline void
117: interrupt_restore(int sts)
118: {
119:
120: __asm__ __volatile__(
121: "msr cpsr_c, %0\n\t"
122: :
123: :"r" (sts)
124: :"memory");
125: }
126:
127: extern void interrupt_mask(int);
128: extern void interrupt_unmask(int, int);
129: extern void interrupt_setup(int, int);
130: extern void interrupt_init(void);
131:
132: /* Interrupt mode for interrupt_setup() */
133: #define IMODE_EDGE 0 /* edge trigger */
134: #define IMODE_LEVEL 1 /* level trigger */
135:
136: extern void clock_init(void);
137:
138: extern void diag_init(void);
139:
140: #ifdef CONFIG_DIAG_VBA
141: static __inline void
142: diag_print(char *buf)
143: {
144:
145: __asm__ __volatile__(
146: "mov r0, %0\n\t"
147: "swi 0xff0000\n\t" /* VBA emulator call */
148: :
149: :"r" (buf)
150: :"r0");
151: }
152:
153: #else
154: extern void diag_print(char *);
155: #endif
156:
157: static __inline void
158: machine_idle(void)
159: {
160:
161: __asm__ __volatile__(
162: "swi 0x20000\n\t" /* GBA BIOS call */
163: :::"r0", "r1", "r2", "r3");
164: }
165:
166: static __inline void
167: machine_reset(void)
168: {
169:
170: __asm__ __volatile__(
171: "swi 0\n\t" /* GBA BIOS call */
172: :::"r0", "r1", "r2", "r3");
173: }
174:
175: extern void machine_init(void);
176:
177: #endif /* !__ASSEMBLY__ */
1.2 nbrk 178: #endif /* !_CATS_PLATFORM_H */
CVSweb