1*53972Sfujita /* 2*53972Sfujita * Copyright (c) 1988 University of Utah. 3*53972Sfujita * Copyright (c) 1992 OMRON Corporation. 4*53972Sfujita * Copyright (c) 1982, 1990, 1992 The Regents of the University of California. 5*53972Sfujita * All rights reserved. 6*53972Sfujita * 7*53972Sfujita * This code is derived from software contributed to Berkeley by 8*53972Sfujita * the Systems Programming Group of the University of Utah Computer 9*53972Sfujita * Science Department. 10*53972Sfujita * 11*53972Sfujita * %sccs.include.redist.c% 12*53972Sfujita * 13*53972Sfujita * from: Utah $Hdr: cpu.h 1.16 91/03/25$ 14*53972Sfujita * OMRON: $Id: cpu.h,v 1.2 92/06/14 06:27:54 moti Exp $ 15*53972Sfujita * 16*53972Sfujita * @(#)cpu.h 7.1 (Berkeley) 06/15/92 17*53972Sfujita */ 18*53972Sfujita 19*53972Sfujita /* 20*53972Sfujita * Exported definitions unique to luna/68k cpu support, taken from: 21*53972Sfujita * hp300/68k. 22*53972Sfujita */ 23*53972Sfujita 24*53972Sfujita /* 25*53972Sfujita * definitions of cpu-dependent requirements 26*53972Sfujita * referenced in generic code 27*53972Sfujita */ 28*53972Sfujita #define COPY_SIGCODE /* copy sigcode above user stack in exec */ 29*53972Sfujita 30*53972Sfujita /* 31*53972Sfujita * function vs. inline configuration; 32*53972Sfujita * these are defined to get generic functions 33*53972Sfujita * rather than inline or machine-dependent implementations 34*53972Sfujita */ 35*53972Sfujita #define NEED_MINMAX /* need {,i,l,ul}{min,max} functions */ 36*53972Sfujita #undef NEED_FFS /* don't need ffs function */ 37*53972Sfujita #undef NEED_BCMP /* don't need bcmp function */ 38*53972Sfujita #undef NEED_STRLEN /* don't need strlen function */ 39*53972Sfujita 40*53972Sfujita #define cpu_exec(p) /* nothing */ 41*53972Sfujita #define cpu_wait(p) /* nothing */ 42*53972Sfujita #define cpu_setstack(p, ap) \ 43*53972Sfujita (p)->p_md.md_regs[SP] = ap 44*53972Sfujita 45*53972Sfujita /* 46*53972Sfujita * Arguments to hardclock, softclock and gatherstats 47*53972Sfujita * encapsulate the previous machine state in an opaque 48*53972Sfujita * clockframe; for 68k, use just what the hardware 49*53972Sfujita * leaves on the stack. 50*53972Sfujita */ 51*53972Sfujita typedef struct intrframe { 52*53972Sfujita char *pc; 53*53972Sfujita int ps; 54*53972Sfujita } clockframe; 55*53972Sfujita 56*53972Sfujita #define CLKF_USERMODE(framep) (((framep)->ps & PSL_S) == 0) 57*53972Sfujita #define CLKF_BASEPRI(framep) (((framep)->ps & PSL_IPL7) == 0) 58*53972Sfujita #define CLKF_PC(framep) ((framep)->pc) 59*53972Sfujita 60*53972Sfujita 61*53972Sfujita /* 62*53972Sfujita * Preempt the current process if in interrupt from user mode, 63*53972Sfujita * or after the current trap/syscall if in system mode. 64*53972Sfujita */ 65*53972Sfujita #define need_resched() { want_resched++; aston(); } 66*53972Sfujita 67*53972Sfujita /* 68*53972Sfujita * Give a profiling tick to the current process from the softclock 69*53972Sfujita * interrupt. On 68k, request an ast to send us through trap(), 70*53972Sfujita * marking the proc as needing a profiling tick. 71*53972Sfujita */ 72*53972Sfujita #define profile_tick(p, framep) { (p)->p_flag |= SOWEUPC; aston(); } 73*53972Sfujita 74*53972Sfujita /* 75*53972Sfujita * Notify the current process (p) that it has a signal pending, 76*53972Sfujita * process as soon as possible. 77*53972Sfujita */ 78*53972Sfujita #define signotify(p) aston() 79*53972Sfujita 80*53972Sfujita #define aston() (astpending++) 81*53972Sfujita 82*53972Sfujita int astpending; /* need to trap before returning to user mode */ 83*53972Sfujita int want_resched; /* resched() was called */ 84*53972Sfujita 85*53972Sfujita 86*53972Sfujita /* 87*53972Sfujita * simulated software interrupt register 88*53972Sfujita */ 89*53972Sfujita extern unsigned char ssir; 90*53972Sfujita 91*53972Sfujita #define SIR_NET 0x1 92*53972Sfujita #define SIR_CLOCK 0x2 93*53972Sfujita 94*53972Sfujita #define siroff(x) ssir &= ~(x) 95*53972Sfujita #define setsoftnet() ssir |= SIR_NET 96*53972Sfujita #define setsoftclock() ssir |= SIR_CLOCK 97*53972Sfujita 98*53972Sfujita /* values for mmutype (assigned for quick testing) */ 99*53972Sfujita #define MMU_68040 -2 /* 68040 on-chip MMU */ 100*53972Sfujita #define MMU_68030 -1 /* 68030 on-chip subset of 68851 */ 101*53972Sfujita 102*53972Sfujita /* values for cpuspeed (not really related to clock speed due to caches) */ 103*53972Sfujita #define MHZ_8 1 104*53972Sfujita #define MHZ_16 2 105*53972Sfujita #define MHZ_25 3 106*53972Sfujita #define MHZ_33 4 107*53972Sfujita #define MHZ_50 6 108*53972Sfujita 109*53972Sfujita /* 110*53972Sfujita * 68851 and 68030 MMU 111*53972Sfujita */ 112*53972Sfujita #define PMMU_LVLMASK 0x0007 113*53972Sfujita #define PMMU_INV 0x0400 114*53972Sfujita #define PMMU_WP 0x0800 115*53972Sfujita #define PMMU_ALV 0x1000 116*53972Sfujita #define PMMU_SO 0x2000 117*53972Sfujita #define PMMU_LV 0x4000 118*53972Sfujita #define PMMU_BE 0x8000 119*53972Sfujita #define PMMU_FAULT (PMMU_WP|PMMU_INV) 120*53972Sfujita 121*53972Sfujita /* 122*53972Sfujita * 68040 MMU 123*53972Sfujita */ 124*53972Sfujita #define MMU4_RES 0x001 125*53972Sfujita #define MMU4_TTR 0x002 126*53972Sfujita #define MMU4_WP 0x004 127*53972Sfujita #define MMU4_MOD 0x010 128*53972Sfujita #define MMU4_CMMASK 0x060 129*53972Sfujita #define MMU4_SUP 0x080 130*53972Sfujita #define MMU4_U0 0x100 131*53972Sfujita #define MMU4_U1 0x200 132*53972Sfujita #define MMU4_GLB 0x400 133*53972Sfujita #define MMU4_BE 0x800 134*53972Sfujita 135*53972Sfujita /* 680X0 function codes */ 136*53972Sfujita #define FC_USERD 1 /* user data space */ 137*53972Sfujita #define FC_USERP 2 /* user program space */ 138*53972Sfujita #define FC_PURGE 3 /* HPMMU: clear TLB entries */ 139*53972Sfujita #define FC_SUPERD 5 /* supervisor data space */ 140*53972Sfujita #define FC_SUPERP 6 /* supervisor program space */ 141*53972Sfujita #define FC_CPU 7 /* CPU space */ 142*53972Sfujita 143*53972Sfujita /* fields in the 68020 cache control register */ 144*53972Sfujita #define IC_ENABLE 0x0001 /* enable instruction cache */ 145*53972Sfujita #define IC_FREEZE 0x0002 /* freeze instruction cache */ 146*53972Sfujita #define IC_CE 0x0004 /* clear instruction cache entry */ 147*53972Sfujita #define IC_CLR 0x0008 /* clear entire instruction cache */ 148*53972Sfujita 149*53972Sfujita /* additional fields in the 68030 cache control register */ 150*53972Sfujita #define IC_BE 0x0010 /* instruction burst enable */ 151*53972Sfujita #define DC_ENABLE 0x0100 /* data cache enable */ 152*53972Sfujita #define DC_FREEZE 0x0200 /* data cache freeze */ 153*53972Sfujita #define DC_CE 0x0400 /* clear data cache entry */ 154*53972Sfujita #define DC_CLR 0x0800 /* clear entire data cache */ 155*53972Sfujita #define DC_BE 0x1000 /* data burst enable */ 156*53972Sfujita #define DC_WA 0x2000 /* write allocate */ 157*53972Sfujita 158*53972Sfujita #define CACHE_ON (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE) 159*53972Sfujita #define CACHE_OFF (DC_CLR|IC_CLR) 160*53972Sfujita #define CACHE_CLR (CACHE_ON) 161*53972Sfujita #define IC_CLEAR (DC_WA|DC_BE|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE) 162*53972Sfujita #define DC_CLEAR (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_ENABLE) 163*53972Sfujita 164*53972Sfujita /* 68040 cache control register */ 165*53972Sfujita #define IC4_ENABLE 0x8000 /* instruction cache enable bit */ 166*53972Sfujita #define DC4_ENABLE 0x80000000 /* data cache enable bit */ 167*53972Sfujita 168*53972Sfujita #define CACHE4_ON (IC4_ENABLE|DC4_ENABLE) 169*53972Sfujita #define CACHE4_OFF (0) 170