cpu.h revision 1.23 1 1.23 thorpej /* $NetBSD: cpu.h,v 1.23 2000/05/26 21:20:27 thorpej Exp $ */
2 1.1 oki
3 1.1 oki /*
4 1.1 oki * Copyright (c) 1988 University of Utah.
5 1.1 oki * Copyright (c) 1982, 1990, 1993
6 1.1 oki * The Regents of the University of California. All rights reserved.
7 1.1 oki *
8 1.1 oki * This code is derived from software contributed to Berkeley by
9 1.1 oki * the Systems Programming Group of the University of Utah Computer
10 1.1 oki * Science Department.
11 1.1 oki *
12 1.1 oki * Redistribution and use in source and binary forms, with or without
13 1.1 oki * modification, are permitted provided that the following conditions
14 1.1 oki * are met:
15 1.1 oki * 1. Redistributions of source code must retain the above copyright
16 1.1 oki * notice, this list of conditions and the following disclaimer.
17 1.1 oki * 2. Redistributions in binary form must reproduce the above copyright
18 1.1 oki * notice, this list of conditions and the following disclaimer in the
19 1.1 oki * documentation and/or other materials provided with the distribution.
20 1.1 oki * 3. All advertising materials mentioning features or use of this software
21 1.1 oki * must display the following acknowledgement:
22 1.1 oki * This product includes software developed by the University of
23 1.1 oki * California, Berkeley and its contributors.
24 1.1 oki * 4. Neither the name of the University nor the names of its contributors
25 1.1 oki * may be used to endorse or promote products derived from this software
26 1.1 oki * without specific prior written permission.
27 1.1 oki *
28 1.1 oki * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 1.1 oki * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 1.1 oki * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 1.1 oki * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 1.1 oki * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 1.1 oki * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 1.1 oki * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 1.1 oki * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 1.1 oki * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 1.1 oki * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 1.1 oki * SUCH DAMAGE.
39 1.1 oki *
40 1.1 oki * from: Utah $Hdr: cpu.h 1.16 91/03/25$
41 1.1 oki *
42 1.1 oki * @(#)cpu.h 8.4 (Berkeley) 1/5/94
43 1.1 oki */
44 1.1 oki
45 1.1 oki #ifndef _X68K_CPU_H_
46 1.1 oki #define _X68K_CPU_H_
47 1.1 oki
48 1.1 oki /*
49 1.1 oki * Exported definitions unique to x68k/68k cpu support.
50 1.1 oki */
51 1.21 minoura
52 1.22 minoura #if defined(_KERNEL) && !defined(_LKM)
53 1.21 minoura #include "opt_m680x0.h"
54 1.23 thorpej #include "opt_lockdebug.h"
55 1.21 minoura #endif
56 1.1 oki
57 1.1 oki /*
58 1.3 thorpej * Get common m68k CPU definitions.
59 1.3 thorpej */
60 1.3 thorpej #include <m68k/cpu.h>
61 1.20 minoura #include <m68k/cacheops.h>
62 1.3 thorpej #define M68K_MMU_MOTOROLA
63 1.3 thorpej
64 1.3 thorpej /*
65 1.13 minoura * Get interrupt glue.
66 1.13 minoura */
67 1.13 minoura #include <machine/intr.h>
68 1.13 minoura
69 1.23 thorpej #include <sys/sched.h>
70 1.23 thorpej struct cpu_info {
71 1.23 thorpej struct schedstate_percpu ci_schedstate; /* scheduler state */
72 1.23 thorpej #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
73 1.23 thorpej u_long ci_spin_locks; /* # of spin locks held */
74 1.23 thorpej u_long ci_simple_locks; /* # of simple locks held */
75 1.23 thorpej #endif
76 1.23 thorpej };
77 1.23 thorpej
78 1.23 thorpej #ifdef _KERNEL
79 1.23 thorpej extern struct cpu_info cpu_info_store;
80 1.23 thorpej
81 1.23 thorpej #define curcpu() (&cpu_info_store)
82 1.23 thorpej
83 1.13 minoura /*
84 1.1 oki * definitions of cpu-dependent requirements
85 1.1 oki * referenced in generic code
86 1.1 oki */
87 1.1 oki #define cpu_swapin(p) /* nothing */
88 1.1 oki #define cpu_wait(p) /* nothing */
89 1.1 oki #define cpu_swapout(p) /* nothing */
90 1.19 thorpej #define cpu_number() 0
91 1.1 oki
92 1.1 oki /*
93 1.1 oki * Arguments to hardclock and gatherstats encapsulate the previous
94 1.1 oki * machine state in an opaque clockframe. One the x68k, we use
95 1.1 oki * what the hardware pushes on an interrupt (frame format 0).
96 1.1 oki */
97 1.1 oki struct clockframe {
98 1.1 oki u_short sr; /* sr at time of interrupt */
99 1.1 oki u_long pc; /* pc at time of interrupt */
100 1.1 oki u_short vo; /* vector offset (4-word frame) */
101 1.1 oki };
102 1.1 oki
103 1.1 oki #define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0)
104 1.1 oki #define CLKF_BASEPRI(framep) (((framep)->sr & PSL_IPL) == 0)
105 1.1 oki #define CLKF_PC(framep) ((framep)->pc)
106 1.1 oki #if 0
107 1.1 oki /* We would like to do it this way... */
108 1.1 oki #define CLKF_INTR(framep) (((framep)->sr & PSL_M) == 0)
109 1.1 oki #else
110 1.1 oki /* but until we start using PSL_M, we have to do this instead */
111 1.1 oki #define CLKF_INTR(framep) (0) /* XXX */
112 1.1 oki #endif
113 1.1 oki
114 1.1 oki
115 1.1 oki /*
116 1.1 oki * Preempt the current process if in interrupt from user mode,
117 1.1 oki * or after the current trap/syscall if in system mode.
118 1.1 oki */
119 1.8 scottr extern int want_resched; /* resched() was called */
120 1.1 oki #define need_resched() { want_resched++; aston(); }
121 1.1 oki
122 1.1 oki /*
123 1.1 oki * Give a profiling tick to the current process when the user profiling
124 1.1 oki * buffer pages are invalid. On the x68k, request an ast to send us
125 1.1 oki * through trap, marking the proc as needing a profiling tick.
126 1.1 oki */
127 1.1 oki #define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); }
128 1.1 oki
129 1.1 oki /*
130 1.1 oki * Notify the current process (p) that it has a signal pending,
131 1.1 oki * process as soon as possible.
132 1.1 oki */
133 1.1 oki #define signotify(p) aston()
134 1.1 oki
135 1.8 scottr extern int astpending; /* need to trap before returning to user mode */
136 1.1 oki #define aston() (astpending++)
137 1.23 thorpej
138 1.23 thorpej #endif /* _KERNEL */
139 1.1 oki
140 1.1 oki /*
141 1.1 oki * CTL_MACHDEP definitions.
142 1.1 oki */
143 1.1 oki #define CPU_CONSDEV 1 /* dev_t: console terminal device */
144 1.1 oki #define CPU_MAXID 2 /* number of valid machdep ids */
145 1.1 oki
146 1.1 oki #define CTL_MACHDEP_NAMES { \
147 1.1 oki { 0, 0 }, \
148 1.1 oki { "console_device", CTLTYPE_STRUCT }, \
149 1.1 oki }
150 1.1 oki
151 1.1 oki /*
152 1.13 minoura * The rest of this should probably be moved to <machine/x68kcpu.h>
153 1.1 oki * although some of it could probably be put into generic 68k headers.
154 1.1 oki */
155 1.1 oki
156 1.1 oki #ifdef _KERNEL
157 1.3 thorpej extern int machineid;
158 1.1 oki extern char *intiolimit;
159 1.2 oki
160 1.6 oki /* autoconf.c functions */
161 1.6 oki void config_console __P((void));
162 1.4 oki
163 1.6 oki /* fpu.c functions */
164 1.4 oki int fpu_probe __P((void));
165 1.2 oki
166 1.6 oki /* machdep.c functions */
167 1.2 oki void dumpconf __P((void));
168 1.2 oki void dumpsys __P((void));
169 1.2 oki
170 1.6 oki /* locore.s functions */
171 1.2 oki struct pcb;
172 1.2 oki struct fpframe;
173 1.17 minoura int suline __P((caddr_t, caddr_t));
174 1.2 oki void savectx __P((struct pcb *));
175 1.2 oki void switch_exit __P((struct proc *));
176 1.2 oki void proc_trampoline __P((void));
177 1.2 oki void loadustp __P((int));
178 1.2 oki void m68881_save __P((struct fpframe *));
179 1.2 oki void m68881_restore __P((struct fpframe *));
180 1.17 minoura
181 1.17 minoura /* machdep.c functions */
182 1.17 minoura int badaddr __P((caddr_t));
183 1.17 minoura int badbaddr __P((caddr_t));
184 1.2 oki
185 1.6 oki /* sys_machdep.c functions */
186 1.15 is int cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *));
187 1.2 oki int dma_cachectl __P((caddr_t, int));
188 1.2 oki
189 1.6 oki /* vm_machdep.c functions */
190 1.6 oki void physaccess __P((caddr_t, caddr_t, int, int));
191 1.6 oki void physunaccess __P((caddr_t, int));
192 1.2 oki int kvtop __P((caddr_t));
193 1.12 thorpej
194 1.12 thorpej /* trap.c functions */
195 1.12 thorpej void child_return __P((void *));
196 1.2 oki
197 1.1 oki #endif
198 1.1 oki
199 1.1 oki /* physical memory sections */
200 1.1 oki #define INTIOBASE (0x00C00000)
201 1.1 oki #define INTIOTOP (0x01000000)
202 1.1 oki
203 1.1 oki /*
204 1.1 oki * Internal IO space:
205 1.1 oki *
206 1.1 oki * Ranges from 0xC00000 to 0x1000000 (IIOMAPSIZE).
207 1.1 oki *
208 1.1 oki * Internal IO space is mapped in the kernel from ``IODEVbase'' to
209 1.1 oki * ``intiolimit'' (defined in locore.s). Since it is always mapped,
210 1.1 oki * conversion between physical and kernel virtual addresses is easy.
211 1.1 oki */
212 1.1 oki #define IIOPOFF(pa) ((int)(pa)-INTIOBASE)
213 1.1 oki #define IIOMAPSIZE btoc(INTIOTOP-INTIOBASE) /* 4mb */
214 1.1 oki
215 1.1 oki #endif /* _X68K_CPU_H_ */
216