cpu.h revision 1.45.4.2 1 1.45.4.2 pk /* $NetBSD: cpu.h,v 1.45.4.2 2001/11/20 16:20:50 pk 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.2 pk #define cpu_swapin(p) /* nothing */
85 1.45.4.2 pk #define cpu_swapout(p) /* nothing */
86 1.45.4.2 pk #define cpu_wait(p) /* nothing */
87 1.45.4.2 pk #define cpu_number() (cpuinfo.ci_cpuid)
88 1.45.4.2 pk
89 1.45.4.2 pk #if defined(MULTIPROCESSOR)
90 1.45.4.2 pk void cpu_boot_secondary_processors __P((void));
91 1.45.4.2 pk #endif
92 1.45.4.2 pk
93 1.45.4.2 pk /*
94 1.45.4.2 pk * Arguments to hardclock, softclock and gatherstats encapsulate the
95 1.45.4.2 pk * previous machine state in an opaque clockframe. The ipl is here
96 1.45.4.2 pk * as well for strayintr (see locore.s:interrupt and intr.c:strayintr).
97 1.45.4.2 pk * Note that CLKF_INTR is valid only if CLKF_USERMODE is false.
98 1.45.4.2 pk */
99 1.45.4.2 pk struct clockframe {
100 1.45.4.2 pk u_int psr; /* psr before interrupt, excluding PSR_ET */
101 1.45.4.2 pk u_int pc; /* pc at interrupt */
102 1.45.4.2 pk u_int npc; /* npc at interrupt */
103 1.45.4.2 pk u_int ipl; /* actual interrupt priority level */
104 1.45.4.2 pk u_int fp; /* %fp at interrupt */
105 1.45.4.2 pk };
106 1.45.4.2 pk typedef struct clockframe clockframe;
107 1.45.4.2 pk
108 1.45.4.2 pk extern int eintstack[];
109 1.45.4.2 pk
110 1.45.4.2 pk #define CLKF_USERMODE(framep) (((framep)->psr & PSR_PS) == 0)
111 1.45.4.2 pk #define CLKF_BASEPRI(framep) (((framep)->psr & PSR_PIL) == 0)
112 1.45.4.2 pk #define CLKF_PC(framep) ((framep)->pc)
113 1.45.4.2 pk #if defined(MULTIPROCESSOR)
114 1.45.4.2 pk #define CLKF_INTR(framep) \
115 1.45.4.2 pk ((framep)->fp > (u_int)cpuinfo.eintstack - INT_STACK_SIZE && \
116 1.45.4.2 pk (framep)->fp < (u_int)cpuinfo.eintstack)
117 1.45.4.2 pk #else
118 1.45.4.2 pk #define CLKF_INTR(framep) ((framep)->fp < (u_int)eintstack)
119 1.45.4.2 pk #endif
120 1.45.4.2 pk
121 1.45.4.2 pk #if defined(SUN4M)
122 1.45.4.2 pk extern void raise __P((int, int));
123 1.45.4.2 pk #if !(defined(SUN4) || defined(SUN4C))
124 1.45.4.2 pk #define setsoftint() raise(0,1)
125 1.45.4.2 pk #else /* both defined */
126 1.45.4.2 pk #define setsoftint() (cputyp == CPU_SUN4M ? raise(0,1) : ienab_bis(IE_L1))
127 1.45.4.2 pk #endif /* !4,!4c */
128 1.45.4.2 pk #else /* 4m not defined */
129 1.45.4.2 pk #define setsoftint() ienab_bis(IE_L1)
130 1.45.4.2 pk #endif /* SUN4M */
131 1.45.4.2 pk
132 1.45.4.2 pk void softintr_init __P((void));
133 1.45.4.2 pk void *softnet_cookie;
134 1.45.4.2 pk
135 1.45.4.2 pk #define setsoftnet() softintr_schedule(softnet_cookie);
136 1.45.4.2 pk
137 1.45.4.2 pk extern int want_ast;
138 1.45.4.2 pk
139 1.45.4.2 pk /*
140 1.45.4.2 pk * Preempt the current process if in interrupt from user mode,
141 1.45.4.2 pk * or after the current trap/syscall if in system mode.
142 1.45.4.2 pk */
143 1.45.4.2 pk extern int want_resched; /* resched() was called */
144 1.45.4.2 pk #define need_resched(ci) (want_resched = 1, want_ast = 1)
145 1.45.4.2 pk
146 1.45.4.2 pk /*
147 1.45.4.2 pk * Give a profiling tick to the current process when the user profiling
148 1.45.4.2 pk * buffer pages are invalid. On the sparc, request an ast to send us
149 1.45.4.2 pk * through trap(), marking the proc as needing a profiling tick.
150 1.45.4.2 pk */
151 1.45.4.2 pk #define need_proftick(p) ((p)->p_flag |= P_OWEUPC, want_ast = 1)
152 1.45.4.2 pk
153 1.45.4.2 pk /*
154 1.45.4.2 pk * Notify the current process (p) that it has a signal pending,
155 1.45.4.2 pk * process as soon as possible.
156 1.45.4.2 pk */
157 1.45.4.2 pk #define signotify(p) (want_ast = 1)
158 1.45.4.2 pk
159 1.45.4.2 pk /* Number of CPUs in the system */
160 1.45.4.2 pk extern int ncpu;
161 1.45.4.2 pk
162 1.45.4.2 pk /*
163 1.45.4.2 pk * Only one process may own the FPU state.
164 1.45.4.2 pk *
165 1.45.4.2 pk * XXX this must be per-cpu (eventually)
166 1.45.4.2 pk */
167 1.45.4.2 pk extern struct lwp *fpproc; /* FPU owner */
168 1.45.4.2 pk extern int foundfpu; /* true => we have an FPU */
169 1.45.4.2 pk
170 1.45.4.2 pk /*
171 1.45.4.2 pk * Interrupt handler chains. Interrupt handlers should return 0 for
172 1.45.4.2 pk * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a
173 1.45.4.2 pk * handler into the list. The handler is called with its (single)
174 1.45.4.2 pk * argument, or with a pointer to a clockframe if ih_arg is NULL.
175 1.45.4.2 pk */
176 1.45.4.2 pk extern struct intrhand {
177 1.45.4.2 pk int (*ih_fun) __P((void *));
178 1.45.4.2 pk void *ih_arg;
179 1.45.4.2 pk struct intrhand *ih_next;
180 1.45.4.2 pk } *intrhand[15];
181 1.45.4.2 pk
182 1.45.4.2 pk void intr_establish __P((int level, struct intrhand *));
183 1.45.4.2 pk void intr_disestablish __P((int level, struct intrhand *));
184 1.45.4.2 pk
185 1.45.4.2 pk /*
186 1.45.4.2 pk * intr_fasttrap() is a lot like intr_establish, but is used for ``fast''
187 1.45.4.2 pk * interrupt vectors (vectors that are not shared and are handled in the
188 1.45.4.2 pk * trap window). Such functions must be written in assembly.
189 1.45.4.2 pk */
190 1.45.4.2 pk void intr_fasttrap __P((int level, void (*vec)(void)));
191 1.45.4.2 pk
192 1.45.4.2 pk void intr_lock_kernel __P((void));
193 1.45.4.2 pk void intr_unlock_kernel __P((void));
194 1.45.4.2 pk
195 1.45.4.2 pk /* disksubr.c */
196 1.45.4.2 pk struct dkbad;
197 1.45.4.2 pk int isbad __P((struct dkbad *bt, int, int, int));
198 1.45.4.2 pk /* machdep.c */
199 1.45.4.2 pk int ldcontrolb __P((caddr_t));
200 1.45.4.2 pk void dumpconf __P((void));
201 1.45.4.2 pk caddr_t reserve_dumppages __P((caddr_t));
202 1.45.4.2 pk /* clock.c */
203 1.45.4.2 pk struct timeval;
204 1.45.4.2 pk void lo_microtime __P((struct timeval *));
205 1.45.4.2 pk int statintr __P((void *));
206 1.45.4.2 pk int clockintr __P((void *));/* level 10 (clock) interrupt code */
207 1.45.4.2 pk int statintr __P((void *)); /* level 14 (statclock) interrupt code */
208 1.45.4.2 pk /* locore.s */
209 1.45.4.2 pk struct fpstate;
210 1.45.4.2 pk void savefpstate __P((struct fpstate *));
211 1.45.4.2 pk void loadfpstate __P((struct fpstate *));
212 1.45.4.2 pk int probeget __P((caddr_t, int));
213 1.45.4.2 pk void write_all_windows __P((void));
214 1.45.4.2 pk void write_user_windows __P((void));
215 1.45.4.2 pk void proc_trampoline __P((void));
216 1.45.4.2 pk void switchexit __P((struct lwp *));
217 1.45.4.2 pk void switchlwpexit __P((struct lwp *));
218 1.45.4.2 pk struct pcb;
219 1.45.4.2 pk void snapshot __P((struct pcb *));
220 1.45.4.2 pk struct frame *getfp __P((void));
221 1.45.4.2 pk int xldcontrolb __P((caddr_t, struct pcb *));
222 1.45.4.2 pk void copywords __P((const void *, void *, size_t));
223 1.45.4.2 pk void qcopy __P((const void *, void *, size_t));
224 1.45.4.2 pk void qzero __P((void *, size_t));
225 1.45.4.2 pk /* trap.c */
226 1.45.4.2 pk void kill_user_windows __P((struct lwp *));
227 1.45.4.2 pk int rwindow_save __P((struct lwp *));
228 1.45.4.2 pk /* amd7930intr.s */
229 1.45.4.2 pk void amd7930_trap __P((void));
230 1.45.4.2 pk /* cons.c */
231 1.45.4.2 pk int cnrom __P((void));
232 1.45.4.2 pk /* zs.c */
233 1.45.4.2 pk void zsconsole __P((struct tty *, int, int, void (**)(struct tty *, int)));
234 1.45.4.2 pk #ifdef KGDB
235 1.45.4.2 pk void zs_kgdb_init __P((void));
236 1.45.4.2 pk #endif
237 1.45.4.2 pk /* fb.c */
238 1.45.4.2 pk void fb_unblank __P((void));
239 1.45.4.2 pk /* cache.c */
240 1.45.4.2 pk void cache_flush __P((caddr_t, u_int));
241 1.45.4.2 pk /* kgdb_stub.c */
242 1.45.4.2 pk #ifdef KGDB
243 1.45.4.2 pk void kgdb_attach __P((int (*)(void *), void (*)(void *, int), void *));
244 1.45.4.2 pk void kgdb_connect __P((int));
245 1.45.4.2 pk void kgdb_panic __P((void));
246 1.45.4.2 pk #endif
247 1.45.4.2 pk /* emul.c */
248 1.45.4.2 pk struct trapframe;
249 1.45.4.2 pk int fixalign __P((struct lwp *, struct trapframe *));
250 1.45.4.2 pk int emulinstr __P((int, struct trapframe *));
251 1.45.4.2 pk /* cpu.c */
252 1.45.4.2 pk void mp_pause_cpus __P((void));
253 1.45.4.2 pk void mp_resume_cpus __P((void));
254 1.45.4.2 pk void mp_halt_cpus __P((void));
255 1.45.4.2 pk
256 1.45.4.2 pk /*
257 1.45.4.2 pk *
258 1.45.4.2 pk * The SPARC has a Trap Base Register (TBR) which holds the upper 20 bits
259 1.45.4.2 pk * of the trap vector table. The next eight bits are supplied by the
260 1.45.4.2 pk * hardware when the trap occurs, and the bottom four bits are always
261 1.45.4.2 pk * zero (so that we can shove up to 16 bytes of executable code---exactly
262 1.45.4.2 pk * four instructions---into each trap vector).
263 1.45.4.2 pk *
264 1.45.4.2 pk * The hardware allocates half the trap vectors to hardware and half to
265 1.45.4.2 pk * software.
266 1.45.4.2 pk *
267 1.45.4.2 pk * Traps have priorities assigned (lower number => higher priority).
268 1.45.4.2 pk */
269 1.45.4.2 pk
270 1.45.4.2 pk struct trapvec {
271 1.45.4.2 pk int tv_instr[4]; /* the four instructions */
272 1.45.4.2 pk };
273 1.45.4.2 pk extern struct trapvec *trapbase; /* the 256 vectors */
274 1.45.4.2 pk
275 1.45.4.2 pk extern void wzero __P((void *, u_int));
276 1.45.4.2 pk extern void wcopy __P((const void *, void *, u_int));
277 1.45.4.2 pk
278 1.45.4.2 pk #endif /* _KERNEL */
279 1.45.4.2 pk #endif /* _CPU_H_ */
280