cpu.h revision 1.45.4.8 1 1.45.4.8 thorpej /* $NetBSD: cpu.h,v 1.45.4.8 2003/01/03 17:25:04 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.5 nathanw #define CPU_BOOTED_DEVICE 2 /* string: device booted from */
55 1.45.4.5 nathanw #define CPU_BOOT_ARGS 3 /* string: args booted with */
56 1.45.4.7 thorpej #define CPU_ARCH 4 /* integer: cpu architecture version */
57 1.45.4.7 thorpej #define CPU_MAXID 5 /* number of valid machdep ids */
58 1.45.4.2 pk
59 1.45.4.2 pk #define CTL_MACHDEP_NAMES { \
60 1.45.4.2 pk { 0, 0 }, \
61 1.45.4.2 pk { "booted_kernel", CTLTYPE_STRING }, \
62 1.45.4.5 nathanw { "booted_device", CTLTYPE_STRING }, \
63 1.45.4.5 nathanw { "boot_args", CTLTYPE_STRING }, \
64 1.45.4.7 thorpej { "cpu_arch", CTLTYPE_INT }, \
65 1.45.4.2 pk }
66 1.45.4.2 pk
67 1.45.4.2 pk #ifdef _KERNEL
68 1.45.4.2 pk /*
69 1.45.4.2 pk * Exported definitions unique to SPARC cpu support.
70 1.45.4.2 pk */
71 1.45.4.2 pk
72 1.45.4.4 nathanw #if !defined(_LKM) && defined(_KERNEL_OPT)
73 1.45.4.2 pk #include "opt_multiprocessor.h"
74 1.45.4.2 pk #include "opt_lockdebug.h"
75 1.45.4.4 nathanw #include "opt_sparc_arch.h"
76 1.45.4.2 pk #endif
77 1.45.4.2 pk
78 1.45.4.2 pk #include <machine/intr.h>
79 1.45.4.7 thorpej #include <machine/psl.h>
80 1.45.4.2 pk #include <sparc/sparc/cpuvar.h>
81 1.45.4.2 pk #include <sparc/sparc/intreg.h>
82 1.45.4.2 pk
83 1.45.4.2 pk /*
84 1.45.4.2 pk * definitions of cpu-dependent requirements
85 1.45.4.2 pk * referenced in generic code
86 1.45.4.2 pk */
87 1.45.4.2 pk #define curcpu() (cpuinfo.ci_self)
88 1.45.4.6 nathanw #define curlwp (curcpu()->ci_curlwp)
89 1.45.4.2 pk #define CPU_IS_PRIMARY(ci) ((ci)->master)
90 1.45.4.2 pk
91 1.45.4.3 thorpej #define cpu_swapin(p) /* nothing */
92 1.45.4.3 thorpej #define cpu_swapout(p) /* nothing */
93 1.45.4.3 thorpej #define cpu_wait(p) /* nothing */
94 1.45.4.3 thorpej #define cpu_number() (cpuinfo.ci_cpuid)
95 1.45.4.3 thorpej #define cpu_proc_fork(p1, p2) /* nothing */
96 1.45.4.2 pk
97 1.45.4.2 pk #if defined(MULTIPROCESSOR)
98 1.45.4.2 pk void cpu_boot_secondary_processors __P((void));
99 1.45.4.2 pk #endif
100 1.45.4.2 pk
101 1.45.4.2 pk /*
102 1.45.4.2 pk * Arguments to hardclock, softclock and gatherstats encapsulate the
103 1.45.4.2 pk * previous machine state in an opaque clockframe. The ipl is here
104 1.45.4.2 pk * as well for strayintr (see locore.s:interrupt and intr.c:strayintr).
105 1.45.4.2 pk * Note that CLKF_INTR is valid only if CLKF_USERMODE is false.
106 1.45.4.2 pk */
107 1.45.4.2 pk struct clockframe {
108 1.45.4.2 pk u_int psr; /* psr before interrupt, excluding PSR_ET */
109 1.45.4.2 pk u_int pc; /* pc at interrupt */
110 1.45.4.2 pk u_int npc; /* npc at interrupt */
111 1.45.4.2 pk u_int ipl; /* actual interrupt priority level */
112 1.45.4.2 pk u_int fp; /* %fp at interrupt */
113 1.45.4.2 pk };
114 1.45.4.2 pk typedef struct clockframe clockframe;
115 1.45.4.2 pk
116 1.45.4.2 pk extern int eintstack[];
117 1.45.4.2 pk
118 1.45.4.2 pk #define CLKF_USERMODE(framep) (((framep)->psr & PSR_PS) == 0)
119 1.45.4.2 pk #define CLKF_BASEPRI(framep) (((framep)->psr & PSR_PIL) == 0)
120 1.45.4.2 pk #define CLKF_PC(framep) ((framep)->pc)
121 1.45.4.2 pk #if defined(MULTIPROCESSOR)
122 1.45.4.2 pk #define CLKF_INTR(framep) \
123 1.45.4.2 pk ((framep)->fp > (u_int)cpuinfo.eintstack - INT_STACK_SIZE && \
124 1.45.4.2 pk (framep)->fp < (u_int)cpuinfo.eintstack)
125 1.45.4.2 pk #else
126 1.45.4.2 pk #define CLKF_INTR(framep) ((framep)->fp < (u_int)eintstack)
127 1.45.4.2 pk #endif
128 1.45.4.2 pk
129 1.45.4.2 pk void softintr_init __P((void));
130 1.45.4.2 pk void *softnet_cookie;
131 1.45.4.2 pk
132 1.45.4.2 pk #define setsoftnet() softintr_schedule(softnet_cookie);
133 1.45.4.2 pk
134 1.45.4.2 pk extern int want_ast;
135 1.45.4.2 pk
136 1.45.4.2 pk /*
137 1.45.4.2 pk * Preempt the current process if in interrupt from user mode,
138 1.45.4.2 pk * or after the current trap/syscall if in system mode.
139 1.45.4.2 pk */
140 1.45.4.2 pk extern int want_resched; /* resched() was called */
141 1.45.4.2 pk #define need_resched(ci) (want_resched = 1, want_ast = 1)
142 1.45.4.2 pk
143 1.45.4.2 pk /*
144 1.45.4.2 pk * Give a profiling tick to the current process when the user profiling
145 1.45.4.2 pk * buffer pages are invalid. On the sparc, request an ast to send us
146 1.45.4.2 pk * through trap(), marking the proc as needing a profiling tick.
147 1.45.4.2 pk */
148 1.45.4.2 pk #define need_proftick(p) ((p)->p_flag |= P_OWEUPC, want_ast = 1)
149 1.45.4.2 pk
150 1.45.4.2 pk /*
151 1.45.4.2 pk * Notify the current process (p) that it has a signal pending,
152 1.45.4.2 pk * process as soon as possible.
153 1.45.4.2 pk */
154 1.45.4.2 pk #define signotify(p) (want_ast = 1)
155 1.45.4.2 pk
156 1.45.4.7 thorpej /* CPU architecture version */
157 1.45.4.7 thorpej extern int cpu_arch;
158 1.45.4.7 thorpej
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 * Interrupt handler chains. Interrupt handlers should return 0 for
164 1.45.4.2 pk * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a
165 1.45.4.2 pk * handler into the list. The handler is called with its (single)
166 1.45.4.2 pk * argument, or with a pointer to a clockframe if ih_arg is NULL.
167 1.45.4.2 pk */
168 1.45.4.2 pk extern struct intrhand {
169 1.45.4.7 thorpej int (*ih_fun)(void *);
170 1.45.4.2 pk void *ih_arg;
171 1.45.4.2 pk struct intrhand *ih_next;
172 1.45.4.7 thorpej int ih_classipl;
173 1.45.4.2 pk } *intrhand[15];
174 1.45.4.2 pk
175 1.45.4.7 thorpej void intr_establish(int level, int classipl, struct intrhand *,
176 1.45.4.7 thorpej void (*fastvec)(void));
177 1.45.4.7 thorpej void intr_disestablish(int level, struct intrhand *);
178 1.45.4.2 pk
179 1.45.4.7 thorpej void intr_lock_kernel(void);
180 1.45.4.7 thorpej void intr_unlock_kernel(void);
181 1.45.4.2 pk
182 1.45.4.2 pk /* disksubr.c */
183 1.45.4.2 pk struct dkbad;
184 1.45.4.7 thorpej int isbad(struct dkbad *bt, int, int, int);
185 1.45.4.2 pk /* machdep.c */
186 1.45.4.7 thorpej int ldcontrolb(caddr_t);
187 1.45.4.7 thorpej void dumpconf(void);
188 1.45.4.7 thorpej caddr_t reserve_dumppages(caddr_t);
189 1.45.4.2 pk /* clock.c */
190 1.45.4.2 pk struct timeval;
191 1.45.4.7 thorpej void lo_microtime(struct timeval *);
192 1.45.4.2 pk /* locore.s */
193 1.45.4.2 pk struct fpstate;
194 1.45.4.7 thorpej void savefpstate(struct fpstate *);
195 1.45.4.7 thorpej void loadfpstate(struct fpstate *);
196 1.45.4.7 thorpej int probeget(caddr_t, int);
197 1.45.4.7 thorpej void write_all_windows(void);
198 1.45.4.7 thorpej void write_user_windows(void);
199 1.45.4.7 thorpej void proc_trampoline(void);
200 1.45.4.7 thorpej void switchexit(struct lwp *);
201 1.45.4.7 thorpej void switchlwpexit(struct lwp *);
202 1.45.4.2 pk struct pcb;
203 1.45.4.7 thorpej void snapshot(struct pcb *);
204 1.45.4.7 thorpej struct frame *getfp(void);
205 1.45.4.7 thorpej int xldcontrolb(caddr_t, struct pcb *);
206 1.45.4.7 thorpej void copywords(const void *, void *, size_t);
207 1.45.4.7 thorpej void qcopy(const void *, void *, size_t);
208 1.45.4.7 thorpej void qzero(void *, size_t);
209 1.45.4.2 pk /* trap.c */
210 1.45.4.7 thorpej void kill_user_windows(struct lwp *);
211 1.45.4.7 thorpej int rwindow_save(struct lwp *);
212 1.45.4.2 pk /* cons.c */
213 1.45.4.7 thorpej int cnrom(void);
214 1.45.4.2 pk /* zs.c */
215 1.45.4.7 thorpej void zsconsole(struct tty *, int, int, void (**)(struct tty *, int));
216 1.45.4.2 pk #ifdef KGDB
217 1.45.4.7 thorpej void zs_kgdb_init(void);
218 1.45.4.2 pk #endif
219 1.45.4.2 pk /* fb.c */
220 1.45.4.7 thorpej void fb_unblank(void);
221 1.45.4.2 pk /* cache.c */
222 1.45.4.7 thorpej void cache_flush(caddr_t, u_int);
223 1.45.4.2 pk /* kgdb_stub.c */
224 1.45.4.2 pk #ifdef KGDB
225 1.45.4.7 thorpej void kgdb_attach(int (*)(void *), void (*)(void *, int), void *);
226 1.45.4.7 thorpej void kgdb_connect(int);
227 1.45.4.7 thorpej void kgdb_panic(void);
228 1.45.4.2 pk #endif
229 1.45.4.2 pk /* emul.c */
230 1.45.4.2 pk struct trapframe;
231 1.45.4.7 thorpej int fixalign(struct lwp *, struct trapframe *);
232 1.45.4.7 thorpej int emulinstr(int, struct trapframe *);
233 1.45.4.2 pk /* cpu.c */
234 1.45.4.7 thorpej void mp_pause_cpus(void);
235 1.45.4.7 thorpej void mp_resume_cpus(void);
236 1.45.4.7 thorpej void mp_halt_cpus(void);
237 1.45.4.4 nathanw /* msiiep.c */
238 1.45.4.7 thorpej void msiiep_swap_endian(int);
239 1.45.4.2 pk
240 1.45.4.2 pk /*
241 1.45.4.2 pk *
242 1.45.4.2 pk * The SPARC has a Trap Base Register (TBR) which holds the upper 20 bits
243 1.45.4.2 pk * of the trap vector table. The next eight bits are supplied by the
244 1.45.4.2 pk * hardware when the trap occurs, and the bottom four bits are always
245 1.45.4.2 pk * zero (so that we can shove up to 16 bytes of executable code---exactly
246 1.45.4.2 pk * four instructions---into each trap vector).
247 1.45.4.2 pk *
248 1.45.4.2 pk * The hardware allocates half the trap vectors to hardware and half to
249 1.45.4.2 pk * software.
250 1.45.4.2 pk *
251 1.45.4.2 pk * Traps have priorities assigned (lower number => higher priority).
252 1.45.4.2 pk */
253 1.45.4.2 pk
254 1.45.4.2 pk struct trapvec {
255 1.45.4.2 pk int tv_instr[4]; /* the four instructions */
256 1.45.4.2 pk };
257 1.45.4.2 pk extern struct trapvec *trapbase; /* the 256 vectors */
258 1.45.4.2 pk
259 1.45.4.2 pk extern void wzero __P((void *, u_int));
260 1.45.4.2 pk extern void wcopy __P((const void *, void *, u_int));
261 1.45.4.2 pk
262 1.45.4.2 pk #endif /* _KERNEL */
263 1.45.4.2 pk #endif /* _CPU_H_ */
264