cpu.h revision 1.45.4.3 1 1.45.4.3 thorpej /* $NetBSD: cpu.h,v 1.45.4.3 2001/12/08 08:22:43 thorpej Exp $ */
2 1.45.4.2 pk
3 1.45.4.2 pk /*
4 1.45.4.2 pk * Copyright (c) 1992, 1993
5 1.45.4.2 pk * The Regents of the University of California. All rights reserved.
6 1.45.4.2 pk *
7 1.45.4.2 pk * This software was developed by the Computer Systems Engineering group
8 1.45.4.2 pk * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 1.45.4.2 pk * contributed to Berkeley.
10 1.45.4.2 pk *
11 1.45.4.2 pk * All advertising materials mentioning features or use of this software
12 1.45.4.2 pk * must display the following acknowledgement:
13 1.45.4.2 pk * This product includes software developed by the University of
14 1.45.4.2 pk * California, Lawrence Berkeley Laboratory.
15 1.45.4.2 pk *
16 1.45.4.2 pk * Redistribution and use in source and binary forms, with or without
17 1.45.4.2 pk * modification, are permitted provided that the following conditions
18 1.45.4.2 pk * are met:
19 1.45.4.2 pk * 1. Redistributions of source code must retain the above copyright
20 1.45.4.2 pk * notice, this list of conditions and the following disclaimer.
21 1.45.4.2 pk * 2. Redistributions in binary form must reproduce the above copyright
22 1.45.4.2 pk * notice, this list of conditions and the following disclaimer in the
23 1.45.4.2 pk * documentation and/or other materials provided with the distribution.
24 1.45.4.2 pk * 3. All advertising materials mentioning features or use of this software
25 1.45.4.2 pk * must display the following acknowledgement:
26 1.45.4.2 pk * This product includes software developed by the University of
27 1.45.4.2 pk * California, Berkeley and its contributors.
28 1.45.4.2 pk * 4. Neither the name of the University nor the names of its contributors
29 1.45.4.2 pk * may be used to endorse or promote products derived from this software
30 1.45.4.2 pk * without specific prior written permission.
31 1.45.4.2 pk *
32 1.45.4.2 pk * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33 1.45.4.2 pk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 1.45.4.2 pk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 1.45.4.2 pk * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36 1.45.4.2 pk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 1.45.4.2 pk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 1.45.4.2 pk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 1.45.4.2 pk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 1.45.4.2 pk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 1.45.4.2 pk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 1.45.4.2 pk * SUCH DAMAGE.
43 1.45.4.2 pk *
44 1.45.4.2 pk * @(#)cpu.h 8.4 (Berkeley) 1/5/94
45 1.45.4.2 pk */
46 1.45.4.2 pk
47 1.45.4.2 pk #ifndef _CPU_H_
48 1.45.4.2 pk #define _CPU_H_
49 1.45.4.2 pk
50 1.45.4.2 pk /*
51 1.45.4.2 pk * CTL_MACHDEP definitions.
52 1.45.4.2 pk */
53 1.45.4.2 pk #define CPU_BOOTED_KERNEL 1 /* string: booted kernel name */
54 1.45.4.2 pk #define CPU_MAXID 2 /* number of valid machdep ids */
55 1.45.4.2 pk
56 1.45.4.2 pk #define CTL_MACHDEP_NAMES { \
57 1.45.4.2 pk { 0, 0 }, \
58 1.45.4.2 pk { "booted_kernel", CTLTYPE_STRING }, \
59 1.45.4.2 pk }
60 1.45.4.2 pk
61 1.45.4.2 pk #ifdef _KERNEL
62 1.45.4.2 pk /*
63 1.45.4.2 pk * Exported definitions unique to SPARC cpu support.
64 1.45.4.2 pk */
65 1.45.4.2 pk
66 1.45.4.2 pk #if !defined(_LKM)
67 1.45.4.2 pk #include "opt_multiprocessor.h"
68 1.45.4.2 pk #include "opt_lockdebug.h"
69 1.45.4.2 pk #endif
70 1.45.4.2 pk
71 1.45.4.2 pk #include <machine/psl.h>
72 1.45.4.2 pk #include <machine/intr.h>
73 1.45.4.2 pk #include <sparc/sparc/cpuvar.h>
74 1.45.4.2 pk #include <sparc/sparc/intreg.h>
75 1.45.4.2 pk
76 1.45.4.2 pk /*
77 1.45.4.2 pk * definitions of cpu-dependent requirements
78 1.45.4.2 pk * referenced in generic code
79 1.45.4.2 pk */
80 1.45.4.2 pk #define curcpu() (cpuinfo.ci_self)
81 1.45.4.2 pk #define curproc (curcpu()->ci_curproc)
82 1.45.4.2 pk #define CPU_IS_PRIMARY(ci) ((ci)->master)
83 1.45.4.2 pk
84 1.45.4.3 thorpej #define cpu_swapin(p) /* nothing */
85 1.45.4.3 thorpej #define cpu_swapout(p) /* nothing */
86 1.45.4.3 thorpej #define cpu_wait(p) /* nothing */
87 1.45.4.3 thorpej #define cpu_number() (cpuinfo.ci_cpuid)
88 1.45.4.3 thorpej #define cpu_proc_fork(p1, p2) /* nothing */
89 1.45.4.2 pk
90 1.45.4.2 pk #if defined(MULTIPROCESSOR)
91 1.45.4.2 pk void cpu_boot_secondary_processors __P((void));
92 1.45.4.2 pk #endif
93 1.45.4.2 pk
94 1.45.4.2 pk /*
95 1.45.4.2 pk * Arguments to hardclock, softclock and gatherstats encapsulate the
96 1.45.4.2 pk * previous machine state in an opaque clockframe. The ipl is here
97 1.45.4.2 pk * as well for strayintr (see locore.s:interrupt and intr.c:strayintr).
98 1.45.4.2 pk * Note that CLKF_INTR is valid only if CLKF_USERMODE is false.
99 1.45.4.2 pk */
100 1.45.4.2 pk struct clockframe {
101 1.45.4.2 pk u_int psr; /* psr before interrupt, excluding PSR_ET */
102 1.45.4.2 pk u_int pc; /* pc at interrupt */
103 1.45.4.2 pk u_int npc; /* npc at interrupt */
104 1.45.4.2 pk u_int ipl; /* actual interrupt priority level */
105 1.45.4.2 pk u_int fp; /* %fp at interrupt */
106 1.45.4.2 pk };
107 1.45.4.2 pk typedef struct clockframe clockframe;
108 1.45.4.2 pk
109 1.45.4.2 pk extern int eintstack[];
110 1.45.4.2 pk
111 1.45.4.2 pk #define CLKF_USERMODE(framep) (((framep)->psr & PSR_PS) == 0)
112 1.45.4.2 pk #define CLKF_BASEPRI(framep) (((framep)->psr & PSR_PIL) == 0)
113 1.45.4.2 pk #define CLKF_PC(framep) ((framep)->pc)
114 1.45.4.2 pk #if defined(MULTIPROCESSOR)
115 1.45.4.2 pk #define CLKF_INTR(framep) \
116 1.45.4.2 pk ((framep)->fp > (u_int)cpuinfo.eintstack - INT_STACK_SIZE && \
117 1.45.4.2 pk (framep)->fp < (u_int)cpuinfo.eintstack)
118 1.45.4.2 pk #else
119 1.45.4.2 pk #define CLKF_INTR(framep) ((framep)->fp < (u_int)eintstack)
120 1.45.4.2 pk #endif
121 1.45.4.2 pk
122 1.45.4.2 pk #if defined(SUN4M)
123 1.45.4.2 pk extern void raise __P((int, int));
124 1.45.4.2 pk #if !(defined(SUN4) || defined(SUN4C))
125 1.45.4.2 pk #define setsoftint() raise(0,1)
126 1.45.4.2 pk #else /* both defined */
127 1.45.4.2 pk #define setsoftint() (cputyp == CPU_SUN4M ? raise(0,1) : ienab_bis(IE_L1))
128 1.45.4.2 pk #endif /* !4,!4c */
129 1.45.4.2 pk #else /* 4m not defined */
130 1.45.4.2 pk #define setsoftint() ienab_bis(IE_L1)
131 1.45.4.2 pk #endif /* SUN4M */
132 1.45.4.2 pk
133 1.45.4.2 pk void softintr_init __P((void));
134 1.45.4.2 pk void *softnet_cookie;
135 1.45.4.2 pk
136 1.45.4.2 pk #define setsoftnet() softintr_schedule(softnet_cookie);
137 1.45.4.2 pk
138 1.45.4.2 pk extern int want_ast;
139 1.45.4.2 pk
140 1.45.4.2 pk /*
141 1.45.4.2 pk * Preempt the current process if in interrupt from user mode,
142 1.45.4.2 pk * or after the current trap/syscall if in system mode.
143 1.45.4.2 pk */
144 1.45.4.2 pk extern int want_resched; /* resched() was called */
145 1.45.4.2 pk #define need_resched(ci) (want_resched = 1, want_ast = 1)
146 1.45.4.2 pk
147 1.45.4.2 pk /*
148 1.45.4.2 pk * Give a profiling tick to the current process when the user profiling
149 1.45.4.2 pk * buffer pages are invalid. On the sparc, request an ast to send us
150 1.45.4.2 pk * through trap(), marking the proc as needing a profiling tick.
151 1.45.4.2 pk */
152 1.45.4.2 pk #define need_proftick(p) ((p)->p_flag |= P_OWEUPC, want_ast = 1)
153 1.45.4.2 pk
154 1.45.4.2 pk /*
155 1.45.4.2 pk * Notify the current process (p) that it has a signal pending,
156 1.45.4.2 pk * process as soon as possible.
157 1.45.4.2 pk */
158 1.45.4.2 pk #define signotify(p) (want_ast = 1)
159 1.45.4.2 pk
160 1.45.4.2 pk /* Number of CPUs in the system */
161 1.45.4.2 pk extern int ncpu;
162 1.45.4.2 pk
163 1.45.4.2 pk /*
164 1.45.4.2 pk * Only one process may own the FPU state.
165 1.45.4.2 pk *
166 1.45.4.2 pk * XXX this must be per-cpu (eventually)
167 1.45.4.2 pk */
168 1.45.4.2 pk extern struct lwp *fpproc; /* FPU owner */
169 1.45.4.2 pk extern int foundfpu; /* true => we have an FPU */
170 1.45.4.2 pk
171 1.45.4.2 pk /*
172 1.45.4.2 pk * Interrupt handler chains. Interrupt handlers should return 0 for
173 1.45.4.2 pk * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a
174 1.45.4.2 pk * handler into the list. The handler is called with its (single)
175 1.45.4.2 pk * argument, or with a pointer to a clockframe if ih_arg is NULL.
176 1.45.4.2 pk */
177 1.45.4.2 pk extern struct intrhand {
178 1.45.4.2 pk int (*ih_fun) __P((void *));
179 1.45.4.2 pk void *ih_arg;
180 1.45.4.2 pk struct intrhand *ih_next;
181 1.45.4.2 pk } *intrhand[15];
182 1.45.4.2 pk
183 1.45.4.2 pk void intr_establish __P((int level, struct intrhand *));
184 1.45.4.2 pk void intr_disestablish __P((int level, struct intrhand *));
185 1.45.4.2 pk
186 1.45.4.2 pk /*
187 1.45.4.2 pk * intr_fasttrap() is a lot like intr_establish, but is used for ``fast''
188 1.45.4.2 pk * interrupt vectors (vectors that are not shared and are handled in the
189 1.45.4.2 pk * trap window). Such functions must be written in assembly.
190 1.45.4.2 pk */
191 1.45.4.2 pk void intr_fasttrap __P((int level, void (*vec)(void)));
192 1.45.4.2 pk
193 1.45.4.2 pk void intr_lock_kernel __P((void));
194 1.45.4.2 pk void intr_unlock_kernel __P((void));
195 1.45.4.2 pk
196 1.45.4.2 pk /* disksubr.c */
197 1.45.4.2 pk struct dkbad;
198 1.45.4.2 pk int isbad __P((struct dkbad *bt, int, int, int));
199 1.45.4.2 pk /* machdep.c */
200 1.45.4.2 pk int ldcontrolb __P((caddr_t));
201 1.45.4.2 pk void dumpconf __P((void));
202 1.45.4.2 pk caddr_t reserve_dumppages __P((caddr_t));
203 1.45.4.2 pk /* clock.c */
204 1.45.4.2 pk struct timeval;
205 1.45.4.2 pk void lo_microtime __P((struct timeval *));
206 1.45.4.2 pk int statintr __P((void *));
207 1.45.4.2 pk int clockintr __P((void *));/* level 10 (clock) interrupt code */
208 1.45.4.2 pk int statintr __P((void *)); /* level 14 (statclock) interrupt code */
209 1.45.4.2 pk /* locore.s */
210 1.45.4.2 pk struct fpstate;
211 1.45.4.2 pk void savefpstate __P((struct fpstate *));
212 1.45.4.2 pk void loadfpstate __P((struct fpstate *));
213 1.45.4.2 pk int probeget __P((caddr_t, int));
214 1.45.4.2 pk void write_all_windows __P((void));
215 1.45.4.2 pk void write_user_windows __P((void));
216 1.45.4.2 pk void proc_trampoline __P((void));
217 1.45.4.2 pk void switchexit __P((struct lwp *));
218 1.45.4.2 pk void switchlwpexit __P((struct lwp *));
219 1.45.4.2 pk struct pcb;
220 1.45.4.2 pk void snapshot __P((struct pcb *));
221 1.45.4.2 pk struct frame *getfp __P((void));
222 1.45.4.2 pk int xldcontrolb __P((caddr_t, struct pcb *));
223 1.45.4.2 pk void copywords __P((const void *, void *, size_t));
224 1.45.4.2 pk void qcopy __P((const void *, void *, size_t));
225 1.45.4.2 pk void qzero __P((void *, size_t));
226 1.45.4.2 pk /* trap.c */
227 1.45.4.2 pk void kill_user_windows __P((struct lwp *));
228 1.45.4.2 pk int rwindow_save __P((struct lwp *));
229 1.45.4.2 pk /* amd7930intr.s */
230 1.45.4.2 pk void amd7930_trap __P((void));
231 1.45.4.2 pk /* cons.c */
232 1.45.4.2 pk int cnrom __P((void));
233 1.45.4.2 pk /* zs.c */
234 1.45.4.2 pk void zsconsole __P((struct tty *, int, int, void (**)(struct tty *, int)));
235 1.45.4.2 pk #ifdef KGDB
236 1.45.4.2 pk void zs_kgdb_init __P((void));
237 1.45.4.2 pk #endif
238 1.45.4.2 pk /* fb.c */
239 1.45.4.2 pk void fb_unblank __P((void));
240 1.45.4.2 pk /* cache.c */
241 1.45.4.2 pk void cache_flush __P((caddr_t, u_int));
242 1.45.4.2 pk /* kgdb_stub.c */
243 1.45.4.2 pk #ifdef KGDB
244 1.45.4.2 pk void kgdb_attach __P((int (*)(void *), void (*)(void *, int), void *));
245 1.45.4.2 pk void kgdb_connect __P((int));
246 1.45.4.2 pk void kgdb_panic __P((void));
247 1.45.4.2 pk #endif
248 1.45.4.2 pk /* emul.c */
249 1.45.4.2 pk struct trapframe;
250 1.45.4.2 pk int fixalign __P((struct lwp *, struct trapframe *));
251 1.45.4.2 pk int emulinstr __P((int, struct trapframe *));
252 1.45.4.2 pk /* cpu.c */
253 1.45.4.2 pk void mp_pause_cpus __P((void));
254 1.45.4.2 pk void mp_resume_cpus __P((void));
255 1.45.4.2 pk void mp_halt_cpus __P((void));
256 1.45.4.2 pk
257 1.45.4.2 pk /*
258 1.45.4.2 pk *
259 1.45.4.2 pk * The SPARC has a Trap Base Register (TBR) which holds the upper 20 bits
260 1.45.4.2 pk * of the trap vector table. The next eight bits are supplied by the
261 1.45.4.2 pk * hardware when the trap occurs, and the bottom four bits are always
262 1.45.4.2 pk * zero (so that we can shove up to 16 bytes of executable code---exactly
263 1.45.4.2 pk * four instructions---into each trap vector).
264 1.45.4.2 pk *
265 1.45.4.2 pk * The hardware allocates half the trap vectors to hardware and half to
266 1.45.4.2 pk * software.
267 1.45.4.2 pk *
268 1.45.4.2 pk * Traps have priorities assigned (lower number => higher priority).
269 1.45.4.2 pk */
270 1.45.4.2 pk
271 1.45.4.2 pk struct trapvec {
272 1.45.4.2 pk int tv_instr[4]; /* the four instructions */
273 1.45.4.2 pk };
274 1.45.4.2 pk extern struct trapvec *trapbase; /* the 256 vectors */
275 1.45.4.2 pk
276 1.45.4.2 pk extern void wzero __P((void *, u_int));
277 1.45.4.2 pk extern void wcopy __P((const void *, void *, u_int));
278 1.45.4.2 pk
279 1.45.4.2 pk #endif /* _KERNEL */
280 1.45.4.2 pk #endif /* _CPU_H_ */
281