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