cpu.h revision 1.6 1 /* $NetBSD: cpu.h,v 1.6 2001/02/27 16:00:27 reinoud Exp $ */
2
3 /*
4 * Copyright (c) 1994-1996 Mark Brinicombe.
5 * Copyright (c) 1994 Brini.
6 * All rights reserved.
7 *
8 * This code is derived from software written for Brini by Mark Brinicombe
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by Brini.
21 * 4. The name of the company nor the name of the author may be used to
22 * endorse or promote products derived from this software without specific
23 * prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * RiscBSD kernel project
38 *
39 * cpu.h
40 *
41 * CPU specific symbols
42 *
43 * Created : 18/09/94
44 *
45 * Based on kate/katelib/arm6.h
46 */
47
48 #ifndef _ARM32_CPU_H_
49 #define _ARM32_CPU_H_
50
51 #if defined(_KERNEL) && !defined(_LKM)
52 #include "opt_cputypes.h"
53 #include "opt_lockdebug.h"
54 #endif
55
56 #ifndef _LOCORE
57 #include <machine/frame.h>
58 #endif /* !_LOCORE */
59 #include <machine/psl.h>
60
61 #if defined(CPU_ARM7500) && !defined(CPU_ARM7)
62 #error "option CPU_ARM7 is required with CPU_ARM7500"
63 #endif
64
65 #include <arm/armreg.h>
66
67 #ifdef CPU_ARM7500
68 #ifdef CPU_ARM6
69 #error "CPU options CPU_ARM6 and CPU_ARM7500 are not compatible"
70 #endif
71 #ifdef CPU_ARM8
72 #error "CPU options CPU_ARM8 and CPU_ARM7500 are not compatible"
73 #endif
74 #ifdef CPU_SA110
75 #error "CPU options CPU_SA110 and CPU_ARM7500 are not compatible"
76 #endif
77 #endif /* CPU_ARM7500 */
78
79 #ifdef _LOCORE
80 #define IRQdisable \
81 stmfd sp!, {r0} ; \
82 mrs r0, cpsr_all ; \
83 orr r0, r0, #(I32_bit) ; \
84 msr cpsr_all, r0 ; \
85 ldmfd sp!, {r0}
86
87 #define IRQenable \
88 stmfd sp!, {r0} ; \
89 mrs r0, cpsr_all ; \
90 bic r0, r0, #(I32_bit) ; \
91 msr cpsr_all, r0 ; \
92 ldmfd sp!, {r0}
93
94 #else
95 #define IRQdisable SetCPSR(I32_bit, I32_bit);
96 #define IRQenable SetCPSR(I32_bit, 0);
97 #endif /* _LOCORE */
98
99 /*
100 * Return TRUE/FALSE (1/0) depending on whether the frame came from USR
101 * mode or not.
102 */
103
104 #define CLKF_USERMODE(frame) ((frame->if_spsr & PSR_MODE) == PSR_USR32_MODE)
105
106 /*
107 * This needs straighening, prob is the frame does not have info on the priority
108 * a guess that needs trying is (current_spl_level == SPL0)
109 */
110
111 #define CLKF_BASEPRI(frame) ((frame->if_spsr & PSR_MODE) == PSR_USR32_MODE)
112
113 #define CLKF_PC(frame) (frame->if_pc)
114
115 /*#define CLKF_INTR(frame) (current_intr_depth > 1)*/
116
117 /* Hack to treat FPE time as interrupt time so we can measure it */
118 #define CLKF_INTR(frame) ((current_intr_depth > 1) || (frame->if_spsr & PSR_MODE) == PSR_UND32_MODE)
119
120 #define PROC_PC(p) ((p)->p_md.md_regs->tf_pc)
121
122 /*
123 * definitions of cpu-dependent requirements
124 * referenced in generic code
125 */
126
127 #ifndef _LOCORE
128 #include <sys/sched.h>
129 struct cpu_info {
130 struct schedstate_percpu ci_schedstate; /* scheduler state */
131 #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
132 u_long ci_spin_locks; /* # of spin locks held */
133 u_long ci_simple_locks; /* # of simple locks held */
134 #endif
135 };
136 #ifdef _KERNEL
137 extern struct cpu_info cpu_info_store;
138 #define curcpu() (&cpu_info_store)
139 #endif /* _KERNEL */
140 #endif /* ! _LOCORE */
141
142 /*
143 * Notify the current process (p) that it has a signal pending,
144 * process as soon as possible.
145 */
146
147 #define signotify(p) setsoftast()
148
149 #define cpu_wait(p) /* nothing */
150 #define cpu_number() 0
151
152 #if defined(_KERNEL) && !defined(_LOCORE)
153 extern int current_intr_depth;
154
155 /*
156 * Preempt the current process if in interrupt from user mode,
157 * or after the current trap/syscall if in system mode.
158 */
159 int want_resched; /* resched() was called */
160 #define need_resched(ci) (want_resched = 1, setsoftast())
161
162 /*
163 * Give a profiling tick to the current process when the user profiling
164 * buffer pages are invalid. On the i386, request an ast to send us
165 * through trap(), marking the proc as needing a profiling tick.
166 */
167 #define need_proftick(p) ((p)->p_flag |= P_OWEUPC, setsoftast())
168
169 /* locore.S */
170 void atomic_set_bit __P((u_int *address, u_int setmask));
171 void atomic_clear_bit __P((u_int *address, u_int clearmask));
172
173 /* cpuswitch.S */
174 struct pcb;
175 void savectx __P((struct pcb *pcb));
176
177 /* ast.c */
178 void userret __P((register struct proc *p));
179
180 /* machdep.h */
181 void bootsync __P((void));
182
183 /* strstr.c */
184 char *strstr __P((const char *s1, const char *s2));
185
186 /* syscall.c */
187 void child_return __P((void *));
188
189 #endif /* _KERNEL && !_LOCORE */
190
191 /*
192 * CTL_MACHDEP definitions.
193 */
194 #define CPU_DEBUG 1 /* int: misc kernel debug control */
195 #define CPU_BOOTED_DEVICE 2 /* string: device we booted from */
196 #define CPU_BOOTED_KERNEL 3 /* string: kernel we booted */
197 #define CPU_CONSDEV 4 /* struct: dev_t of our console */
198 #define CPU_MAXID 5 /* number of valid machdep ids */
199
200 #define CTL_MACHDEP_NAMES { \
201 { 0, 0 }, \
202 { "debug", CTLTYPE_INT }, \
203 { "booted_device", CTLTYPE_STRING }, \
204 { "booted_kernel", CTLTYPE_STRING }, \
205 { "console_device", CTLTYPE_STRUCT }, \
206 }
207
208 #endif /* !_ARM32_CPU_H_ */
209
210 /* End of cpu.h */
211