153972Sfujita /* 253972Sfujita * Copyright (c) 1988 University of Utah. 353972Sfujita * Copyright (c) 1992 OMRON Corporation. 453972Sfujita * Copyright (c) 1982, 1990, 1992 The Regents of the University of California. 553972Sfujita * All rights reserved. 653972Sfujita * 753972Sfujita * This code is derived from software contributed to Berkeley by 853972Sfujita * the Systems Programming Group of the University of Utah Computer 953972Sfujita * Science Department. 1053972Sfujita * 1153972Sfujita * %sccs.include.redist.c% 1253972Sfujita * 1353972Sfujita * from: Utah $Hdr: cpu.h 1.16 91/03/25$ 14*57394Sakito * from: hp300/include/cpu.h 7.13 (Berkeley) 12/27/92 1553972Sfujita * 16*57394Sakito * @(#)cpu.h 7.3 (Berkeley) 01/02/93 1753972Sfujita */ 1853972Sfujita 1953972Sfujita /* 20*57394Sakito * Exported definitions unique to luna/68k cpu support, 21*57394Sakito * taken from hp300/68k. 2253972Sfujita */ 2353972Sfujita 2453972Sfujita /* 2553972Sfujita * definitions of cpu-dependent requirements 2653972Sfujita * referenced in generic code 2753972Sfujita */ 2853972Sfujita #define COPY_SIGCODE /* copy sigcode above user stack in exec */ 2953972Sfujita 3053972Sfujita #define cpu_exec(p) /* nothing */ 3153972Sfujita #define cpu_wait(p) /* nothing */ 3253972Sfujita #define cpu_setstack(p, ap) \ 3353972Sfujita (p)->p_md.md_regs[SP] = ap 3453972Sfujita 3553972Sfujita /* 3655583Sfujita * Arguments to hardclock and gatherstats encapsulate the previous 3755583Sfujita * machine state in an opaque clockframe. One the 68k, we use 3855583Sfujita * what the hardware pushes on an interrupt (but we pad the sr to a 3955583Sfujita * longword boundary). 4053972Sfujita */ 4155583Sfujita struct clockframe { 4255583Sfujita u_short sr; /* sr at time of interrupt */ 4355583Sfujita u_long pc; /* pc at time of interrupt */ 4455583Sfujita u_short vo; /* vector offset (4-word frame) */ 4555583Sfujita }; 4653972Sfujita 4755583Sfujita #define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0) 4855583Sfujita #define CLKF_BASEPRI(framep) (((framep)->sr & PSL_IPL) == 0) 4953972Sfujita #define CLKF_PC(framep) ((framep)->pc) 5055583Sfujita #if 0 5155583Sfujita /* We would like to do it this way... */ 5255583Sfujita #define CLKF_INTR(framep) (((framep)->sr & PSL_M) == 0) 5355583Sfujita #else 5455583Sfujita /* but until we start using PSL_M, we have to do this instead */ 5555583Sfujita #define CLKF_INTR(framep) (0) /* XXX */ 5655583Sfujita #endif 5753972Sfujita 5853972Sfujita 5953972Sfujita /* 6053972Sfujita * Preempt the current process if in interrupt from user mode, 6153972Sfujita * or after the current trap/syscall if in system mode. 6253972Sfujita */ 6353972Sfujita #define need_resched() { want_resched++; aston(); } 6453972Sfujita 6553972Sfujita /* 6655583Sfujita * Give a profiling tick to the current process when the user profiling 6755583Sfujita * buffer pages are invalid. On the 68k, request an ast to send us 6855583Sfujita * through trap, marking the proc as needing a profiling tick. 6953972Sfujita */ 7055583Sfujita #define need_proftick(p) { (p)->p_flag |= SOWEUPC; aston(); } 7153972Sfujita 7253972Sfujita /* 7353972Sfujita * Notify the current process (p) that it has a signal pending, 7453972Sfujita * process as soon as possible. 7553972Sfujita */ 7653972Sfujita #define signotify(p) aston() 7753972Sfujita 7853972Sfujita #define aston() (astpending++) 7953972Sfujita 8053972Sfujita int astpending; /* need to trap before returning to user mode */ 8153972Sfujita int want_resched; /* resched() was called */ 8253972Sfujita 8353972Sfujita 8453972Sfujita /* 8553972Sfujita * simulated software interrupt register 8653972Sfujita */ 8753972Sfujita extern unsigned char ssir; 8853972Sfujita 8953972Sfujita #define SIR_NET 0x1 9053972Sfujita #define SIR_CLOCK 0x2 9153972Sfujita 9253972Sfujita #define siroff(x) ssir &= ~(x) 9353972Sfujita #define setsoftnet() ssir |= SIR_NET 9453972Sfujita #define setsoftclock() ssir |= SIR_CLOCK 9553972Sfujita 9653972Sfujita /* values for mmutype (assigned for quick testing) */ 9753972Sfujita #define MMU_68040 -2 /* 68040 on-chip MMU */ 9853972Sfujita #define MMU_68030 -1 /* 68030 on-chip subset of 68851 */ 9953972Sfujita 10053972Sfujita /* values for cpuspeed (not really related to clock speed due to caches) */ 10153972Sfujita #define MHZ_8 1 10253972Sfujita #define MHZ_16 2 10353972Sfujita #define MHZ_25 3 10453972Sfujita #define MHZ_33 4 10553972Sfujita #define MHZ_50 6 10653972Sfujita 10753972Sfujita /* 10853972Sfujita * 68851 and 68030 MMU 10953972Sfujita */ 11053972Sfujita #define PMMU_LVLMASK 0x0007 11153972Sfujita #define PMMU_INV 0x0400 11253972Sfujita #define PMMU_WP 0x0800 11353972Sfujita #define PMMU_ALV 0x1000 11453972Sfujita #define PMMU_SO 0x2000 11553972Sfujita #define PMMU_LV 0x4000 11653972Sfujita #define PMMU_BE 0x8000 11753972Sfujita #define PMMU_FAULT (PMMU_WP|PMMU_INV) 11853972Sfujita 11953972Sfujita /* 12053972Sfujita * 68040 MMU 12153972Sfujita */ 12253972Sfujita #define MMU4_RES 0x001 12353972Sfujita #define MMU4_TTR 0x002 12453972Sfujita #define MMU4_WP 0x004 12553972Sfujita #define MMU4_MOD 0x010 12653972Sfujita #define MMU4_CMMASK 0x060 12753972Sfujita #define MMU4_SUP 0x080 12853972Sfujita #define MMU4_U0 0x100 12953972Sfujita #define MMU4_U1 0x200 13053972Sfujita #define MMU4_GLB 0x400 13153972Sfujita #define MMU4_BE 0x800 13253972Sfujita 13353972Sfujita /* 680X0 function codes */ 13453972Sfujita #define FC_USERD 1 /* user data space */ 13553972Sfujita #define FC_USERP 2 /* user program space */ 13653972Sfujita #define FC_PURGE 3 /* HPMMU: clear TLB entries */ 13753972Sfujita #define FC_SUPERD 5 /* supervisor data space */ 13853972Sfujita #define FC_SUPERP 6 /* supervisor program space */ 13953972Sfujita #define FC_CPU 7 /* CPU space */ 14053972Sfujita 14153972Sfujita /* fields in the 68020 cache control register */ 14253972Sfujita #define IC_ENABLE 0x0001 /* enable instruction cache */ 14353972Sfujita #define IC_FREEZE 0x0002 /* freeze instruction cache */ 14453972Sfujita #define IC_CE 0x0004 /* clear instruction cache entry */ 14553972Sfujita #define IC_CLR 0x0008 /* clear entire instruction cache */ 14653972Sfujita 14753972Sfujita /* additional fields in the 68030 cache control register */ 14853972Sfujita #define IC_BE 0x0010 /* instruction burst enable */ 14953972Sfujita #define DC_ENABLE 0x0100 /* data cache enable */ 15053972Sfujita #define DC_FREEZE 0x0200 /* data cache freeze */ 15153972Sfujita #define DC_CE 0x0400 /* clear data cache entry */ 15253972Sfujita #define DC_CLR 0x0800 /* clear entire data cache */ 15353972Sfujita #define DC_BE 0x1000 /* data burst enable */ 15453972Sfujita #define DC_WA 0x2000 /* write allocate */ 15553972Sfujita 15653972Sfujita #define CACHE_ON (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE) 15753972Sfujita #define CACHE_OFF (DC_CLR|IC_CLR) 15853972Sfujita #define CACHE_CLR (CACHE_ON) 15953972Sfujita #define IC_CLEAR (DC_WA|DC_BE|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE) 16053972Sfujita #define DC_CLEAR (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_ENABLE) 16153972Sfujita 16253972Sfujita /* 68040 cache control register */ 16353972Sfujita #define IC4_ENABLE 0x8000 /* instruction cache enable bit */ 16453972Sfujita #define DC4_ENABLE 0x80000000 /* data cache enable bit */ 16553972Sfujita 16653972Sfujita #define CACHE4_ON (IC4_ENABLE|DC4_ENABLE) 16753972Sfujita #define CACHE4_OFF (0) 168