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