cpu.h revision 1.37 1 /* $NetBSD: cpu.h,v 1.37 2000/02/29 22:19:54 thorpej Exp $ */
2
3 /*-
4 * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 /*
41 * Copyright (c) 1988 University of Utah.
42 * Copyright (c) 1982, 1990, 1993
43 * The Regents of the University of California. All rights reserved.
44 *
45 * This code is derived from software contributed to Berkeley by
46 * the Systems Programming Group of the University of Utah Computer
47 * Science Department.
48 *
49 * Redistribution and use in source and binary forms, with or without
50 * modification, are permitted provided that the following conditions
51 * are met:
52 * 1. Redistributions of source code must retain the above copyright
53 * notice, this list of conditions and the following disclaimer.
54 * 2. Redistributions in binary form must reproduce the above copyright
55 * notice, this list of conditions and the following disclaimer in the
56 * documentation and/or other materials provided with the distribution.
57 * 3. All advertising materials mentioning features or use of this software
58 * must display the following acknowledgement:
59 * This product includes software developed by the University of
60 * California, Berkeley and its contributors.
61 * 4. Neither the name of the University nor the names of its contributors
62 * may be used to endorse or promote products derived from this software
63 * without specific prior written permission.
64 *
65 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
66 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
67 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
68 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
69 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
70 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
71 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
72 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
73 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
74 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
75 * SUCH DAMAGE.
76 *
77 * from: Utah $Hdr: cpu.h 1.16 91/03/25$
78 *
79 * @(#)cpu.h 8.4 (Berkeley) 1/5/94
80 */
81
82 #ifndef _ALPHA_CPU_H_
83 #define _ALPHA_CPU_H_
84
85 #if defined(_KERNEL) && !defined(_LKM)
86 #include "opt_multiprocessor.h"
87 #endif
88
89 /*
90 * Exported definitions unique to Alpha cpu support.
91 */
92
93 #include <machine/alpha_cpu.h>
94
95 #ifdef _KERNEL
96 #include <machine/frame.h>
97
98 /*
99 * Machine check information.
100 */
101 struct mchkinfo {
102 __volatile int mc_expected; /* machine check is expected */
103 __volatile int mc_received; /* machine check was received */
104 };
105
106 #if defined(MULTIPROCESSOR)
107
108 #include <sys/lock.h> /* will also get LOCKDEBUG */
109
110 struct cpu_info {
111 /*
112 * Public members.
113 */
114 struct proc *ci_curproc; /* current owner of the processor */
115 struct simplelock ci_slock; /* lock on this data structure */
116 cpuid_t ci_cpuid; /* our CPU ID */
117 #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
118 u_long ci_spin_locks; /* # of spin locks held */
119 u_long ci_simple_locks; /* # of simple locks held */
120 #endif
121
122 /*
123 * Private members.
124 */
125 struct proc *ci_fpcurproc; /* current owner of the FPU */
126 paddr_t ci_curpcb; /* PA of current HW PCB */
127 struct pcb *ci_idle_pcb; /* our idle PCB */
128 paddr_t ci_idle_pcb_paddr; /* PA of idle PCB */
129 u_long ci_flags; /* flags; see below */
130 u_long ci_ipis; /* interprocessor interrupts pending */
131 struct device *ci_dev; /* pointer to our device */
132 struct mchkinfo ci_mcinfo; /* machine check info */
133 };
134
135 #define CPUF_PRIMARY 0x01 /* CPU is primary CPU */
136 #define CPUF_PRESENT 0x02 /* CPU is present */
137 #define CPUF_RUNNING 0x04 /* CPU is running */
138
139 extern u_long cpus_running;
140 extern struct cpu_info cpu_info[];
141
142 #define curcpu() ((struct cpu_info *)alpha_pal_rdval())
143
144 #define fpcurproc curcpu()->ci_fpcurproc
145 #define curpcb curcpu()->ci_curpcb
146
147 #define cpu_mchkinfo() (&curcpu()->ci_mcinfo)
148
149 void cpu_boot_secondary_processors __P((void));
150 #else
151 extern struct proc *fpcurproc; /* current owner of FPU */
152 extern paddr_t curpcb; /* PA of current HW context */
153 extern struct mchkinfo mchkinfo_store; /* mchkifo for single-cpu configs */
154
155 #define cpu_mchkinfo() (&mchkinfo_store)
156 #endif /* MULTIPROCESSOR */
157
158 /*
159 * definitions of cpu-dependent requirements
160 * referenced in generic code
161 */
162 #define cpu_wait(p) /* nothing */
163 #define cpu_number() alpha_pal_whami()
164
165 /*
166 * Arguments to hardclock and gatherstats encapsulate the previous
167 * machine state in an opaque clockframe. One the Alpha, we use
168 * what we push on an interrupt (a trapframe).
169 */
170 struct clockframe {
171 struct trapframe cf_tf;
172 };
173 #define CLKF_USERMODE(framep) \
174 (((framep)->cf_tf.tf_regs[FRAME_PS] & ALPHA_PSL_USERMODE) != 0)
175 #define CLKF_BASEPRI(framep) \
176 (((framep)->cf_tf.tf_regs[FRAME_PS] & ALPHA_PSL_IPL_MASK) == 0)
177 #define CLKF_PC(framep) ((framep)->cf_tf.tf_regs[FRAME_PC])
178 /*
179 * XXX No way to accurately tell if we were in interrupt mode before taking
180 * clock interrupt.
181 */
182 #define CLKF_INTR(framep) (0)
183
184 /*
185 * Preempt the current process if in interrupt from user mode,
186 * or after the current trap/syscall if in system mode.
187 */
188 #define need_resched() { want_resched = 1; aston(); }
189
190 /*
191 * Give a profiling tick to the current process when the user profiling
192 * buffer pages are invalid. On the hp300, request an ast to send us
193 * through trap, marking the proc as needing a profiling tick.
194 */
195 #define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); }
196
197 /*
198 * Notify the current process (p) that it has a signal pending,
199 * process as soon as possible.
200 */
201 #define signotify(p) aston()
202
203 #define aston() (astpending = 1)
204
205 u_int64_t astpending; /* need to trap before returning to user mode */
206 u_int64_t want_resched; /* resched() was called */
207 #endif /* _KERNEL */
208
209 /*
210 * CTL_MACHDEP definitions.
211 */
212 #define CPU_CONSDEV 1 /* dev_t: console terminal device */
213 #define CPU_ROOT_DEVICE 2 /* string: root device name */
214 #define CPU_UNALIGNED_PRINT 3 /* int: print unaligned accesses */
215 #define CPU_UNALIGNED_FIX 4 /* int: fix unaligned accesses */
216 #define CPU_UNALIGNED_SIGBUS 5 /* int: SIGBUS unaligned accesses */
217 #define CPU_BOOTED_KERNEL 6 /* string: booted kernel name */
218 #define CPU_MAXID 7 /* 6 valid machdep IDs */
219
220 #define CTL_MACHDEP_NAMES { \
221 { 0, 0 }, \
222 { "console_device", CTLTYPE_STRUCT }, \
223 { "root_device", CTLTYPE_STRING }, \
224 { "unaligned_print", CTLTYPE_INT }, \
225 { "unaligned_fix", CTLTYPE_INT }, \
226 { "unaligned_sigbus", CTLTYPE_INT }, \
227 { "booted_kernel", CTLTYPE_STRING }, \
228 }
229
230 #ifdef _KERNEL
231
232 struct pcb;
233 struct proc;
234 struct reg;
235 struct rpb;
236 struct trapframe;
237
238 int badaddr __P((void *, size_t));
239
240 #endif /* _KERNEL */
241 #endif /* _ALPHA_CPU_H_ */
242