1 /* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1992 OMRON Corporation. 4 * Copyright (c) 1982, 1990, 1992, 1993 5 * The Regents of the University of California. 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 * %sccs.include.redist.c% 12 * 13 * from: Utah $Hdr: cpu.h 1.16 91/03/25$ 14 * from: hp300/include/cpu.h 8.2 (Berkeley) 9/23/93 15 * 16 * @(#)cpu.h 8.6 (Berkeley) 05/17/95 17 */ 18 19 /* 20 * Exported definitions unique to luna/68k cpu support, 21 * taken from hp300/68k. 22 */ 23 24 /* 25 * definitions of cpu-dependent requirements 26 * referenced in generic code 27 */ 28 #define COPY_SIGCODE /* copy sigcode above user stack in exec */ 29 30 #define cpu_exec(p) /* nothing */ 31 #define cpu_swapin(p) /* nothing */ 32 #define cpu_wait(p) /* nothing */ 33 #define cpu_setstack(p, ap) (p)->p_md.md_regs[SP] = ap 34 #define cpu_set_init_frame(p, fp) (p)->p_md.md_regs = fp 35 #define BACKTRACE(p) /* not implemented */ 36 37 /* 38 * Arguments to hardclock and gatherstats encapsulate the previous 39 * machine state in an opaque clockframe. One the 68k, we use 40 * what the hardware pushes on an interrupt (but we pad the sr to a 41 * longword boundary). 42 */ 43 struct clockframe { 44 u_short sr; /* sr at time of interrupt */ 45 u_long pc; /* pc at time of interrupt */ 46 u_short vo; /* vector offset (4-word frame) */ 47 }; 48 49 #define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0) 50 #define CLKF_BASEPRI(framep) (((framep)->sr & PSL_IPL) == 0) 51 #define CLKF_PC(framep) ((framep)->pc) 52 #if 0 53 /* We would like to do it this way... */ 54 #define CLKF_INTR(framep) (((framep)->sr & PSL_M) == 0) 55 #else 56 /* but until we start using PSL_M, we have to do this instead */ 57 #define CLKF_INTR(framep) (0) /* XXX */ 58 #endif 59 60 61 /* 62 * Preempt the current process if in interrupt from user mode, 63 * or after the current trap/syscall if in system mode. 64 */ 65 #define need_resched() { want_resched++; aston(); } 66 67 /* 68 * Give a profiling tick to the current process when the user profiling 69 * buffer pages are invalid. On the 68k, request an ast to send us 70 * through trap, marking the proc as needing a profiling tick. 71 */ 72 #define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); } 73 74 /* 75 * Notify the current process (p) that it has a signal pending, 76 * process as soon as possible. 77 */ 78 #define signotify(p) aston() 79 80 #define aston() (astpending++) 81 82 int astpending; /* need to trap before returning to user mode */ 83 int want_resched; /* resched() was called */ 84 85 86 /* 87 * simulated software interrupt register 88 */ 89 extern unsigned char ssir; 90 91 #define SIR_NET 0x1 92 #define SIR_CLOCK 0x2 93 94 #define siroff(x) ssir &= ~(x) 95 #define setsoftnet() ssir |= SIR_NET 96 #define setsoftclock() ssir |= SIR_CLOCK 97 98 /* 99 * CTL_MACHDEP definitions. 100 */ 101 #define CPU_CONSDEV 1 /* dev_t: console terminal device */ 102 #define CPU_MAXID 2 /* number of valid machdep ids */ 103 104 #define CTL_MACHDEP_NAMES { \ 105 { 0, 0 }, \ 106 { "console_device", CTLTYPE_STRUCT }, \ 107 } 108 109 #ifdef KERNEL 110 extern int mmutype, machineid; 111 #endif 112 113 /* values for machineid */ 114 #define LUNA_I 1 /* 20Mhz 68030 */ 115 #define LUNA_II 2 /* 25Mhz 68040 */ 116 117 /* values for mmutype (assigned for quick testing) */ 118 #define MMU_68040 -2 /* 68040 on-chip MMU */ 119 #define MMU_68030 -1 /* 68030 on-chip subset of 68851 */ 120 121 /* values for cpuspeed (not really related to clock speed due to caches) */ 122 #define MHZ_8 1 123 #define MHZ_16 2 124 #define MHZ_25 3 125 #define MHZ_33 4 126 #define MHZ_50 6 127 128 /* 129 * 68851 and 68030 MMU 130 */ 131 #define PMMU_LVLMASK 0x0007 132 #define PMMU_INV 0x0400 133 #define PMMU_WP 0x0800 134 #define PMMU_ALV 0x1000 135 #define PMMU_SO 0x2000 136 #define PMMU_LV 0x4000 137 #define PMMU_BE 0x8000 138 #define PMMU_FAULT (PMMU_WP|PMMU_INV) 139 140 /* 141 * 68040 MMU 142 */ 143 #define MMU4_RES 0x001 144 #define MMU4_TTR 0x002 145 #define MMU4_WP 0x004 146 #define MMU4_MOD 0x010 147 #define MMU4_CMMASK 0x060 148 #define MMU4_SUP 0x080 149 #define MMU4_U0 0x100 150 #define MMU4_U1 0x200 151 #define MMU4_GLB 0x400 152 #define MMU4_BE 0x800 153 154 /* 680X0 function codes */ 155 #define FC_USERD 1 /* user data space */ 156 #define FC_USERP 2 /* user program space */ 157 #define FC_PURGE 3 /* HPMMU: clear TLB entries */ 158 #define FC_SUPERD 5 /* supervisor data space */ 159 #define FC_SUPERP 6 /* supervisor program space */ 160 #define FC_CPU 7 /* CPU space */ 161 162 /* fields in the 68020 cache control register */ 163 #define IC_ENABLE 0x0001 /* enable instruction cache */ 164 #define IC_FREEZE 0x0002 /* freeze instruction cache */ 165 #define IC_CE 0x0004 /* clear instruction cache entry */ 166 #define IC_CLR 0x0008 /* clear entire instruction cache */ 167 168 /* additional fields in the 68030 cache control register */ 169 #define IC_BE 0x0010 /* instruction burst enable */ 170 #define DC_ENABLE 0x0100 /* data cache enable */ 171 #define DC_FREEZE 0x0200 /* data cache freeze */ 172 #define DC_CE 0x0400 /* clear data cache entry */ 173 #define DC_CLR 0x0800 /* clear entire data cache */ 174 #define DC_BE 0x1000 /* data burst enable */ 175 #define DC_WA 0x2000 /* write allocate */ 176 177 #define CACHE_ON (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE) 178 #define CACHE_OFF (DC_CLR|IC_CLR) 179 #define CACHE_CLR (CACHE_ON) 180 #define IC_CLEAR (DC_WA|DC_BE|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE) 181 #define DC_CLEAR (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_ENABLE) 182 183 /* 68040 cache control register */ 184 #define IC4_ENABLE 0x8000 /* instruction cache enable bit */ 185 #define DC4_ENABLE 0x80000000 /* data cache enable bit */ 186 187 #define CACHE4_ON (IC4_ENABLE|DC4_ENABLE) 188 #define CACHE4_OFF (0) 189