locore.h revision 1.1 1 1.1 matt /* cpu.h,v 1.45.4.7 2008/01/28 18:20:39 matt Exp */
2 1.1 matt
3 1.1 matt /*
4 1.1 matt * Copyright (c) 1994-1996 Mark Brinicombe.
5 1.1 matt * Copyright (c) 1994 Brini.
6 1.1 matt * All rights reserved.
7 1.1 matt *
8 1.1 matt * This code is derived from software written for Brini by Mark Brinicombe
9 1.1 matt *
10 1.1 matt * Redistribution and use in source and binary forms, with or without
11 1.1 matt * modification, are permitted provided that the following conditions
12 1.1 matt * are met:
13 1.1 matt * 1. Redistributions of source code must retain the above copyright
14 1.1 matt * notice, this list of conditions and the following disclaimer.
15 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 matt * notice, this list of conditions and the following disclaimer in the
17 1.1 matt * documentation and/or other materials provided with the distribution.
18 1.1 matt * 3. All advertising materials mentioning features or use of this software
19 1.1 matt * must display the following acknowledgement:
20 1.1 matt * This product includes software developed by Brini.
21 1.1 matt * 4. The name of the company nor the name of the author may be used to
22 1.1 matt * endorse or promote products derived from this software without specific
23 1.1 matt * prior written permission.
24 1.1 matt *
25 1.1 matt * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 1.1 matt * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 1.1 matt * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 1.1 matt * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 1.1 matt * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 1.1 matt * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 1.1 matt * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.1 matt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.1 matt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.1 matt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.1 matt * SUCH DAMAGE.
36 1.1 matt *
37 1.1 matt * RiscBSD kernel project
38 1.1 matt *
39 1.1 matt * cpu.h
40 1.1 matt *
41 1.1 matt * CPU specific symbols
42 1.1 matt *
43 1.1 matt * Created : 18/09/94
44 1.1 matt *
45 1.1 matt * Based on kate/katelib/arm6.h
46 1.1 matt */
47 1.1 matt
48 1.1 matt #ifndef _ARM_LOCORE_H_
49 1.1 matt #define _ARM_LOCORE_H_
50 1.1 matt
51 1.1 matt #include <arm/cpuconf.h>
52 1.1 matt #include <arm/armreg.h>
53 1.1 matt
54 1.1 matt #include <machine/frame.h>
55 1.1 matt
56 1.1 matt #ifndef _LOCORE
57 1.1 matt /* 1 == use cpu_sleep(), 0 == don't */
58 1.1 matt extern int cpu_do_powersave;
59 1.1 matt extern int cpu_fpu_present;
60 1.1 matt #endif
61 1.1 matt
62 1.1 matt #ifdef _LOCORE
63 1.1 matt
64 1.1 matt #if defined(_ARM_ARCH_6)
65 1.1 matt #define IRQdisable cpsid i
66 1.1 matt #define IRQenable cpsie i
67 1.1 matt #elif defined(__PROG32)
68 1.1 matt #define IRQdisable \
69 1.1 matt stmfd sp!, {r0} ; \
70 1.1 matt mrs r0, cpsr ; \
71 1.1 matt orr r0, r0, #(I32_bit) ; \
72 1.1 matt msr cpsr_c, r0 ; \
73 1.1 matt ldmfd sp!, {r0}
74 1.1 matt
75 1.1 matt #define IRQenable \
76 1.1 matt stmfd sp!, {r0} ; \
77 1.1 matt mrs r0, cpsr ; \
78 1.1 matt bic r0, r0, #(I32_bit) ; \
79 1.1 matt msr cpsr_c, r0 ; \
80 1.1 matt ldmfd sp!, {r0}
81 1.1 matt #else
82 1.1 matt /* Not yet used in 26-bit code */
83 1.1 matt #endif
84 1.1 matt
85 1.1 matt #if defined (TPIDRPRW_IS_CURCPU)
86 1.1 matt #define GET_CURCPU(rX) mrc p15, 0, rX, c13, c0, 4
87 1.1 matt #define GET_CURLWP(rX) GET_CURCPU(rX); ldr rX, [rX, #CI_CURLWP]
88 1.1 matt #elif defined (TPIDRPRW_IS_CURLWP)
89 1.1 matt #define GET_CURLWP(rX) mrc p15, 0, rX, c13, c0, 4
90 1.1 matt #define GET_CURCPU(rX) GET_CURLWP(rX); ldr rX, [rX, #L_CPU]
91 1.1 matt #elif !defined(MULTIPROCESSOR)
92 1.1 matt #define GET_CURCPU(rX) ldr rX, =_C_LABEL(cpu_info_store)
93 1.1 matt #define GET_CURLWP(rX) GET_CURCPU(rX); ldr rX, [rX, #CI_CURLWP]
94 1.1 matt #endif
95 1.1 matt #define GET_CURPCB(rX) GET_CURLWP(rX); ldr rX, [rX, #L_PCB]
96 1.1 matt
97 1.1 matt #else /* !_LOCORE */
98 1.1 matt
99 1.1 matt #ifdef __PROG32
100 1.1 matt #define IRQdisable __set_cpsr_c(I32_bit, I32_bit);
101 1.1 matt #define IRQenable __set_cpsr_c(I32_bit, 0);
102 1.1 matt #else
103 1.1 matt #define IRQdisable set_r15(R15_IRQ_DISABLE, R15_IRQ_DISABLE);
104 1.1 matt #define IRQenable set_r15(R15_IRQ_DISABLE, 0);
105 1.1 matt #endif
106 1.1 matt
107 1.1 matt #endif /* !_LOCORE */
108 1.1 matt
109 1.1 matt #ifndef _LOCORE
110 1.1 matt
111 1.1 matt /*
112 1.1 matt * Validate a PC or PSR for a user process. Used by various system calls
113 1.1 matt * that take a context passed by the user and restore it.
114 1.1 matt */
115 1.1 matt
116 1.1 matt #ifdef __PROG32
117 1.1 matt #define VALID_R15_PSR(r15,psr) \
118 1.1 matt (((psr) & PSR_MODE) == PSR_USR32_MODE && \
119 1.1 matt ((psr) & (I32_bit | F32_bit)) == 0)
120 1.1 matt #else
121 1.1 matt #define VALID_R15_PSR(r15,psr) \
122 1.1 matt (((r15) & R15_MODE) == R15_MODE_USR && \
123 1.1 matt ((r15) & (R15_IRQ_DISABLE | R15_FIQ_DISABLE)) == 0)
124 1.1 matt #endif
125 1.1 matt
126 1.1 matt
127 1.1 matt
128 1.1 matt /* The address of the vector page. */
129 1.1 matt extern vaddr_t vector_page;
130 1.1 matt #ifdef __PROG32
131 1.1 matt void arm32_vector_init(vaddr_t, int);
132 1.1 matt
133 1.1 matt #define ARM_VEC_RESET (1 << 0)
134 1.1 matt #define ARM_VEC_UNDEFINED (1 << 1)
135 1.1 matt #define ARM_VEC_SWI (1 << 2)
136 1.1 matt #define ARM_VEC_PREFETCH_ABORT (1 << 3)
137 1.1 matt #define ARM_VEC_DATA_ABORT (1 << 4)
138 1.1 matt #define ARM_VEC_ADDRESS_EXCEPTION (1 << 5)
139 1.1 matt #define ARM_VEC_IRQ (1 << 6)
140 1.1 matt #define ARM_VEC_FIQ (1 << 7)
141 1.1 matt
142 1.1 matt #define ARM_NVEC 8
143 1.1 matt #define ARM_VEC_ALL 0xffffffff
144 1.1 matt #endif /* __PROG32 */
145 1.1 matt
146 1.1 matt #ifndef acorn26
147 1.1 matt /*
148 1.1 matt * cpu device glue (belongs in cpuvar.h)
149 1.1 matt */
150 1.1 matt void cpu_attach(device_t, cpuid_t);
151 1.1 matt #endif
152 1.1 matt
153 1.1 matt /*
154 1.1 matt * Random cruft
155 1.1 matt */
156 1.1 matt
157 1.1 matt struct lwp;
158 1.1 matt
159 1.1 matt /* locore.S */
160 1.1 matt void atomic_set_bit(u_int *, u_int);
161 1.1 matt void atomic_clear_bit(u_int *, u_int);
162 1.1 matt
163 1.1 matt /* cpuswitch.S */
164 1.1 matt struct pcb;
165 1.1 matt void savectx(struct pcb *);
166 1.1 matt
167 1.1 matt /* ast.c */
168 1.1 matt void userret(struct lwp *);
169 1.1 matt
170 1.1 matt /* *_machdep.c */
171 1.1 matt void bootsync(void);
172 1.1 matt
173 1.1 matt /* fault.c */
174 1.1 matt int badaddr_read(void *, size_t, void *);
175 1.1 matt
176 1.1 matt /* syscall.c */
177 1.1 matt void swi_handler(trapframe_t *);
178 1.1 matt
179 1.1 matt /* arm_machdep.c */
180 1.1 matt void ucas_ras_check(trapframe_t *);
181 1.1 matt
182 1.1 matt /* vfp_init.c */
183 1.1 matt void vfp_attach(void);
184 1.1 matt void vfp_discardcontext(void);
185 1.1 matt void vfp_savecontext(void);
186 1.1 matt void vfp_kernel_acquire(void);
187 1.1 matt void vfp_kernel_release(void);
188 1.1 matt extern const pcu_ops_t arm_vfp_ops;
189 1.1 matt
190 1.1 matt #endif /* !_LOCORE */
191 1.1 matt
192 1.1 matt #endif /* !_ARM_LOCORE_H_ */
193