1 /* $NetBSD: cpu.h,v 1.57 2004/01/04 11:33:29 jdolecek Exp $ */ 2 3 /* 4 * Copyright (c) 1982, 1990 The Regents of the University of California. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * the Systems Programming Group of the University of Utah Computer 9 * Science Department. 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. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * from: Utah $Hdr: cpu.h 1.16 91/03/25$ 36 * 37 * @(#)cpu.h 7.7 (Berkeley) 6/27/91 38 */ 39 /* 40 * Copyright (c) 1988 University of Utah. 41 * 42 * This code is derived from software contributed to Berkeley by 43 * the Systems Programming Group of the University of Utah Computer 44 * Science Department. 45 * 46 * Redistribution and use in source and binary forms, with or without 47 * modification, are permitted provided that the following conditions 48 * are met: 49 * 1. Redistributions of source code must retain the above copyright 50 * notice, this list of conditions and the following disclaimer. 51 * 2. Redistributions in binary form must reproduce the above copyright 52 * notice, this list of conditions and the following disclaimer in the 53 * documentation and/or other materials provided with the distribution. 54 * 3. All advertising materials mentioning features or use of this software 55 * must display the following acknowledgement: 56 * This product includes software developed by the University of 57 * California, Berkeley and its contributors. 58 * 4. Neither the name of the University nor the names of its contributors 59 * may be used to endorse or promote products derived from this software 60 * without specific prior written permission. 61 * 62 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 63 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 64 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 65 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 66 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 72 * SUCH DAMAGE. 73 * 74 * from: Utah $Hdr: cpu.h 1.16 91/03/25$ 75 * 76 * @(#)cpu.h 7.7 (Berkeley) 6/27/91 77 */ 78 #ifndef _MACHINE_CPU_H_ 79 #define _MACHINE_CPU_H_ 80 81 /* 82 * Exported definitions unique to amiga/68k cpu support. 83 */ 84 85 #if defined(_KERNEL_OPT) 86 #include "opt_lockdebug.h" 87 #endif 88 89 /* 90 * Get common m68k CPU definitions. 91 */ 92 #include <m68k/cpu.h> 93 #define M68K_MMU_MOTOROLA 94 95 #include <sys/sched.h> 96 struct cpu_info { 97 struct schedstate_percpu ci_schedstate; /* scheduler state */ 98 #if defined(DIAGNOSTIC) || defined(LOCKDEBUG) 99 u_long ci_spin_locks; /* # of spin locks held */ 100 u_long ci_simple_locks; /* # of simple locks held */ 101 #endif 102 }; 103 104 #ifdef _KERNEL 105 extern struct cpu_info cpu_info_store; 106 107 #define curcpu() (&cpu_info_store) 108 109 /* 110 * definitions of cpu-dependent requirements 111 * referenced in generic code 112 */ 113 #define cpu_swapin(p) /* nothing */ 114 #define cpu_swapout(p) /* nothing */ 115 #define cpu_number() 0 116 117 void cpu_proc_fork(struct proc *, struct proc *); 118 119 120 extern volatile unsigned int interrupt_depth; 121 /* 122 * Arguments to hardclock and gatherstats encapsulate the previous 123 * machine state in an opaque clockframe. One the hp300, we use 124 * what the hardware pushes on an interrupt (frame format 0). 125 */ 126 struct clockframe { 127 u_short sr; /* sr at time of interrupt */ 128 u_long pc; /* pc at time of interrupt */ 129 u_short vo; /* vector offset (4-word frame) */ 130 }; 131 132 #define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0) 133 /*#define CLKF_BASEPRI(framep) (((framep)->sr & PSL_IPL) == 0)*/ 134 #define CLKF_BASEPRI(framep) (0) 135 #define CLKF_PC(framep) ((framep)->pc) 136 #define CLKF_INTR(framep) (interrupt_depth > 1) 137 138 139 /* 140 * Preempt the current process if in interrupt from user mode, 141 * or after the current trap/syscall if in system mode. 142 */ 143 extern int want_resched; /* resched() was called */ 144 #define need_resched(ci) {want_resched = 1; setsoftast();} 145 146 /* 147 * Give a profiling tick to the current process from the softclock 148 * interrupt. On hp300, request an ast to send us through trap(), 149 * marking the proc as needing a profiling tick. 150 */ 151 #define profile_tick(p, framep) ((p)->p_flag |= P_OWEUPC, setsoftast()) 152 #define need_proftick(p) ((p)->p_flag |= P_OWEUPC, setsoftast()) 153 154 /* 155 * Notify the current process (p) that it has a signal pending, 156 * process as soon as possible. 157 */ 158 #define signotify(p) setsoftast() 159 160 extern int astpending; /* need trap before returning to user mode */ 161 #define setsoftast() (astpending = 1) 162 163 #endif /* _KERNEL */ 164 165 /* include support for software interrupts */ 166 #include <machine/mtpr.h> 167 168 /* 169 * The rest of this should probably be moved to ../amiga/amigacpu.h, 170 * although some of it could probably be put into generic 68k headers. 171 */ 172 173 /* values for machineid (happen to be AFF_* settings of AttnFlags) */ 174 #define AMIGA_68020 (1L<<1) 175 #define AMIGA_68030 (1L<<2) 176 #define AMIGA_68040 (1L<<3) 177 #define AMIGA_68881 (1L<<4) 178 #define AMIGA_68882 (1L<<5) 179 #define AMIGA_FPU40 (1L<<6) 180 #define AMIGA_68060 (1L<<7) 181 182 #ifdef _KERNEL 183 extern int machineid; 184 #endif 185 186 /* 187 * CTL_MACHDEP definitions. 188 */ 189 #define CPU_CONSDEV 1 /* dev_t: console terminal device */ 190 #define CPU_MAXID 2 /* number of valid machdep ids */ 191 192 #define CTL_MACHDEP_NAMES { \ 193 { 0, 0 }, \ 194 { "console_device", CTLTYPE_STRUCT }, \ 195 } 196 197 #ifdef _KERNEL 198 /* 199 * Prototypes from amiga_init.c 200 */ 201 void *alloc_z2mem __P((long)); 202 203 /* 204 * Prototypes from autoconf.c 205 */ 206 int is_a1200 __P((void)); 207 int is_a3000 __P((void)); 208 int is_a4000 __P((void)); 209 #ifdef DRACO 210 #define is_draco() ((machineid >> 24) == 0x7d ? (machineid >> 16) & 0xff : 0) 211 #endif 212 213 /* 214 * Prototypes from clock.c 215 */ 216 u_long clkread __P((void)); 217 218 #ifdef DRACO 219 /* 220 * Prototypes from kbd.c 221 */ 222 void drkbdintr __P((void)); 223 224 /* 225 * Prototypes from drsc.c 226 */ 227 void drsc_handler __P((void)); 228 #endif 229 230 /* 231 * Prototypes from locore.s 232 */ 233 struct fpframe; 234 struct user; 235 struct pcb; 236 237 void clearseg __P((vm_offset_t)); 238 void doboot __P((void)) __attribute__((__noreturn__)); 239 void loadustp __P((int)); 240 #ifdef FPCOPROC 241 void m68881_save __P((struct fpframe *)); 242 void m68881_restore __P((struct fpframe *)); 243 #endif 244 void physcopyseg __P((vm_offset_t, vm_offset_t)); 245 u_int probeva __P((u_int, u_int)); 246 void proc_trampoline __P((void)); 247 void savectx __P((struct pcb *)); 248 void switch_exit __P((struct lwp *)); 249 void switch_lwp_exit __P((struct lwp *)); 250 251 /* 252 * Prototypes from machdep.c 253 */ 254 int badaddr __P((caddr_t)); 255 int badbaddr __P((caddr_t)); 256 void bootsync __P((void)); 257 void dumpconf __P((void)); 258 259 /* 260 * Prototypes from sys_machdep.c: 261 */ 262 int cachectl1 __P((unsigned long, vaddr_t, size_t, struct proc *)); 263 int dma_cachectl __P((caddr_t, int)); 264 265 /* 266 * Prototypes from vm_machdep.c 267 */ 268 int kvtop __P((caddr_t)); 269 void physaccess __P((caddr_t, caddr_t, int, int)); 270 void physunaccess __P((caddr_t, int)); 271 void setredzone __P((u_int *, caddr_t)); 272 273 /* 274 * Prototypes from pmap.c: 275 */ 276 void pmap_bootstrap __P((vm_offset_t, vm_offset_t)); 277 278 #endif /* _KERNEL */ 279 280 #endif /* !_MACHINE_CPU_H_ */ 281