cpu.h revision 1.2.8.3 1 1.2.8.3 nathanw /* $NetBSD: cpu.h,v 1.2.8.3 2002/11/11 22:05:44 nathanw Exp $ */
2 1.2.8.2 thorpej
3 1.2.8.2 thorpej /*
4 1.2.8.2 thorpej * Copyright (c) 1994 Gordon W. Ross
5 1.2.8.2 thorpej * Copyright (c) 1993 Adam Glass
6 1.2.8.2 thorpej * Copyright (c) 1988 University of Utah.
7 1.2.8.2 thorpej * Copyright (c) 1982, 1990 The Regents of the University of California.
8 1.2.8.2 thorpej * All rights reserved.
9 1.2.8.2 thorpej *
10 1.2.8.2 thorpej * This code is derived from software contributed to Berkeley by
11 1.2.8.2 thorpej * the Systems Programming Group of the University of Utah Computer
12 1.2.8.2 thorpej * Science Department.
13 1.2.8.2 thorpej *
14 1.2.8.2 thorpej * Redistribution and use in source and binary forms, with or without
15 1.2.8.2 thorpej * modification, are permitted provided that the following conditions
16 1.2.8.2 thorpej * are met:
17 1.2.8.2 thorpej * 1. Redistributions of source code must retain the above copyright
18 1.2.8.2 thorpej * notice, this list of conditions and the following disclaimer.
19 1.2.8.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
20 1.2.8.2 thorpej * notice, this list of conditions and the following disclaimer in the
21 1.2.8.2 thorpej * documentation and/or other materials provided with the distribution.
22 1.2.8.2 thorpej * 3. All advertising materials mentioning features or use of this software
23 1.2.8.2 thorpej * must display the following acknowledgement:
24 1.2.8.2 thorpej * This product includes software developed by the University of
25 1.2.8.2 thorpej * California, Berkeley and its contributors.
26 1.2.8.2 thorpej * 4. Neither the name of the University nor the names of its contributors
27 1.2.8.2 thorpej * may be used to endorse or promote products derived from this software
28 1.2.8.2 thorpej * without specific prior written permission.
29 1.2.8.2 thorpej *
30 1.2.8.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
31 1.2.8.2 thorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 1.2.8.2 thorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 1.2.8.2 thorpej * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
34 1.2.8.2 thorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 1.2.8.2 thorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 1.2.8.2 thorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 1.2.8.2 thorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 1.2.8.2 thorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 1.2.8.2 thorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 1.2.8.2 thorpej * SUCH DAMAGE.
41 1.2.8.2 thorpej *
42 1.2.8.2 thorpej * from: Utah Hdr: cpu.h 1.16 91/03/25
43 1.2.8.2 thorpej * from: @(#)cpu.h 7.7 (Berkeley) 6/27/91
44 1.2.8.2 thorpej * cpu.h,v 1.2 1993/05/22 07:58:17 cgd Exp
45 1.2.8.2 thorpej */
46 1.2.8.2 thorpej
47 1.2.8.2 thorpej #ifndef _CPU_H_
48 1.2.8.2 thorpej #define _CPU_H_
49 1.2.8.2 thorpej
50 1.2.8.2 thorpej #if defined(_KERNEL_OPT)
51 1.2.8.2 thorpej #include "opt_lockdebug.h"
52 1.2.8.2 thorpej #endif
53 1.2.8.2 thorpej
54 1.2.8.2 thorpej #include <m68k/m68k.h>
55 1.2.8.2 thorpej
56 1.2.8.2 thorpej #ifdef _KERNEL
57 1.2.8.2 thorpej
58 1.2.8.2 thorpej /*
59 1.2.8.2 thorpej * External definitions unique to sun68k cpu support.
60 1.2.8.2 thorpej * These are the "public" declarations - those needed in
61 1.2.8.2 thorpej * machine-independent source code. The "private" ones
62 1.2.8.2 thorpej * are in machdep.h (used only inside sys/arch/sun{2,3,68k}).
63 1.2.8.2 thorpej *
64 1.2.8.2 thorpej * Note that the name of this file is NOT meant to imply
65 1.2.8.2 thorpej * that it has anything to do with Motorola CPU stuff.
66 1.2.8.2 thorpej * The name "cpu" is historical, and used in the common
67 1.2.8.2 thorpej * code to identify machine-dependent functions, etc.
68 1.2.8.2 thorpej */
69 1.2.8.2 thorpej
70 1.2.8.2 thorpej #include <sys/sched.h>
71 1.2.8.2 thorpej struct cpu_info {
72 1.2.8.2 thorpej struct schedstate_percpu ci_schedstate; /* scheduler state */
73 1.2.8.2 thorpej #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
74 1.2.8.2 thorpej u_long ci_spin_locks; /* # of spin locks held */
75 1.2.8.2 thorpej u_long ci_simple_locks; /* # of simple locks held */
76 1.2.8.2 thorpej #endif
77 1.2.8.2 thorpej };
78 1.2.8.2 thorpej
79 1.2.8.2 thorpej extern struct cpu_info cpu_info_store;
80 1.2.8.2 thorpej
81 1.2.8.2 thorpej #define curcpu() (&cpu_info_store)
82 1.2.8.2 thorpej
83 1.2.8.2 thorpej /*
84 1.2.8.2 thorpej * definitions of cpu-dependent requirements
85 1.2.8.2 thorpej * referenced in generic code
86 1.2.8.2 thorpej */
87 1.2.8.2 thorpej #define cpu_number() 0
88 1.2.8.3 nathanw #define cpu_wait(p) /* nothing */
89 1.2.8.2 thorpej #define cpu_proc_fork(p1, p2) /* nothing */
90 1.2.8.3 nathanw #define cpu_swapin(p) /* nothing */
91 1.2.8.3 nathanw #define cpu_swapout(p) /* nothing */
92 1.2.8.2 thorpej
93 1.2.8.2 thorpej /*
94 1.2.8.2 thorpej * Arguments to hardclock and gatherstats encapsulate the previous
95 1.2.8.2 thorpej * machine state in an opaque clockframe. On the sun68k, we use
96 1.2.8.2 thorpej * what the locore.s glue puts on the stack before calling C-code.
97 1.2.8.2 thorpej */
98 1.2.8.2 thorpej struct clockframe {
99 1.2.8.2 thorpej u_int cf_regs[4]; /* d0,d1,a0,a1 */
100 1.2.8.2 thorpej u_short cf_sr; /* sr at time of interrupt */
101 1.2.8.2 thorpej u_long cf_pc; /* pc at time of interrupt */
102 1.2.8.2 thorpej u_short cf_vo; /* vector offset (4-word frame) */
103 1.2.8.2 thorpej } __attribute__((packed));
104 1.2.8.2 thorpej
105 1.2.8.2 thorpej #define CLKF_USERMODE(framep) (((framep)->cf_sr & PSL_S) == 0)
106 1.2.8.2 thorpej #define CLKF_BASEPRI(framep) (((framep)->cf_sr & PSL_IPL) == 0)
107 1.2.8.2 thorpej #define CLKF_PC(framep) ((framep)->cf_pc)
108 1.2.8.2 thorpej #if 0
109 1.2.8.2 thorpej /* We would like to do it this way... */
110 1.2.8.2 thorpej #define CLKF_INTR(framep) (((framep)->cf_sr & PSL_M) == 0)
111 1.2.8.2 thorpej #else
112 1.2.8.2 thorpej /* but until we start using PSL_M, we have to do this instead */
113 1.2.8.2 thorpej #define CLKF_INTR(framep) (0) /* XXX */
114 1.2.8.2 thorpej #endif
115 1.2.8.2 thorpej
116 1.2.8.2 thorpej extern int astpending; /* need to trap before returning to user mode */
117 1.2.8.2 thorpej #define aston() (astpending = 1)
118 1.2.8.2 thorpej
119 1.2.8.2 thorpej /*
120 1.2.8.2 thorpej * Preempt the current process if in interrupt from user mode,
121 1.2.8.2 thorpej * or after the current trap/syscall if in system mode.
122 1.2.8.2 thorpej */
123 1.2.8.2 thorpej extern int want_resched; /* resched() was called */
124 1.2.8.2 thorpej #define need_resched(ci) { want_resched = 1; aston(); }
125 1.2.8.2 thorpej
126 1.2.8.2 thorpej /*
127 1.2.8.2 thorpej * Give a profiling tick to the current process when the user profiling
128 1.2.8.2 thorpej * buffer pages are invalid. On the sun68k, request an ast to send us
129 1.2.8.2 thorpej * through trap, marking the proc as needing a profiling tick.
130 1.2.8.2 thorpej */
131 1.2.8.2 thorpej #define need_proftick(p) ((p)->p_flag |= P_OWEUPC, aston())
132 1.2.8.2 thorpej
133 1.2.8.2 thorpej /*
134 1.2.8.2 thorpej * Notify the current process (p) that it has a signal pending,
135 1.2.8.2 thorpej * process as soon as possible.
136 1.2.8.2 thorpej */
137 1.2.8.2 thorpej #define signotify(p) aston()
138 1.2.8.2 thorpej
139 1.2.8.2 thorpej #include <machine/intr.h>
140 1.2.8.2 thorpej extern void *softnet_cookie;
141 1.2.8.2 thorpej #define setsoftnet() softintr_schedule(softnet_cookie)
142 1.2.8.2 thorpej
143 1.2.8.2 thorpej /*
144 1.2.8.2 thorpej * For some reason the sparc has this prototype in its machine/cpu.h,
145 1.2.8.2 thorpej * so for now we do the same.
146 1.2.8.2 thorpej */
147 1.2.8.2 thorpej void fb_unblank __P((void));
148 1.2.8.2 thorpej
149 1.2.8.2 thorpej int cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *));
150 1.2.8.2 thorpej
151 1.2.8.2 thorpej /*
152 1.2.8.2 thorpej * This is needed by sun68k/isr.c. It's here for lack of a
153 1.2.8.2 thorpej * better place.
154 1.2.8.2 thorpej */
155 1.2.8.2 thorpej void netintr __P((void));
156 1.2.8.2 thorpej
157 1.2.8.3 nathanw /*
158 1.2.8.3 nathanw * more stuff here for lack of a better place.
159 1.2.8.3 nathanw */
160 1.2.8.3 nathanw struct pcb;
161 1.2.8.3 nathanw void proc_trampoline __P((void));
162 1.2.8.3 nathanw void savectx __P((struct pcb *));
163 1.2.8.3 nathanw void switch_exit __P((struct lwp *));
164 1.2.8.3 nathanw void switch_lwp_exit __P((struct lwp *));
165 1.2.8.3 nathanw
166 1.2.8.3 nathanw #define M68K_VAC
167 1.2.8.3 nathanw
168 1.2.8.2 thorpej #endif /* _KERNEL */
169 1.2.8.2 thorpej
170 1.2.8.2 thorpej #include <m68k/sysctl.h>
171 1.2.8.2 thorpej #endif /* _CPU_H_ */
172