153972Sfujita /* 253972Sfujita * Copyright (c) 1988 University of Utah. 353972Sfujita * Copyright (c) 1992 OMRON Corporation. 463194Sbostic * Copyright (c) 1982, 1990, 1992, 1993 563194Sbostic * The Regents of the University of California. 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$ 1465040Sakito * from: hp300/include/cpu.h 8.2 (Berkeley) 9/23/93 1553972Sfujita * 16*69532Smckusick * @(#)cpu.h 8.6 (Berkeley) 05/17/95 1753972Sfujita */ 1853972Sfujita 1953972Sfujita /* 2057394Sakito * Exported definitions unique to luna/68k cpu support, 2157394Sakito * 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 3065070Smckusick #define cpu_exec(p) /* nothing */ 3165499Smckusick #define cpu_swapin(p) /* nothing */ 3265070Smckusick #define cpu_wait(p) /* nothing */ 3365070Smckusick #define cpu_setstack(p, ap) (p)->p_md.md_regs[SP] = ap 3465070Smckusick #define cpu_set_init_frame(p, fp) (p)->p_md.md_regs = fp 35*69532Smckusick #define BACKTRACE(p) /* not implemented */ 3653972Sfujita 3753972Sfujita /* 3855583Sfujita * Arguments to hardclock and gatherstats encapsulate the previous 3955583Sfujita * machine state in an opaque clockframe. One the 68k, we use 4055583Sfujita * what the hardware pushes on an interrupt (but we pad the sr to a 4155583Sfujita * longword boundary). 4253972Sfujita */ 4355583Sfujita struct clockframe { 4455583Sfujita u_short sr; /* sr at time of interrupt */ 4555583Sfujita u_long pc; /* pc at time of interrupt */ 4655583Sfujita u_short vo; /* vector offset (4-word frame) */ 4755583Sfujita }; 4853972Sfujita 4955583Sfujita #define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0) 5055583Sfujita #define CLKF_BASEPRI(framep) (((framep)->sr & PSL_IPL) == 0) 5153972Sfujita #define CLKF_PC(framep) ((framep)->pc) 5255583Sfujita #if 0 5355583Sfujita /* We would like to do it this way... */ 5455583Sfujita #define CLKF_INTR(framep) (((framep)->sr & PSL_M) == 0) 5555583Sfujita #else 5655583Sfujita /* but until we start using PSL_M, we have to do this instead */ 5755583Sfujita #define CLKF_INTR(framep) (0) /* XXX */ 5855583Sfujita #endif 5953972Sfujita 6053972Sfujita 6153972Sfujita /* 6253972Sfujita * Preempt the current process if in interrupt from user mode, 6353972Sfujita * or after the current trap/syscall if in system mode. 6453972Sfujita */ 6553972Sfujita #define need_resched() { want_resched++; aston(); } 6653972Sfujita 6753972Sfujita /* 6855583Sfujita * Give a profiling tick to the current process when the user profiling 6955583Sfujita * buffer pages are invalid. On the 68k, request an ast to send us 7055583Sfujita * through trap, marking the proc as needing a profiling tick. 7153972Sfujita */ 7264632Sbostic #define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); } 7353972Sfujita 7453972Sfujita /* 7553972Sfujita * Notify the current process (p) that it has a signal pending, 7653972Sfujita * process as soon as possible. 7753972Sfujita */ 7853972Sfujita #define signotify(p) aston() 7953972Sfujita 8053972Sfujita #define aston() (astpending++) 8153972Sfujita 8253972Sfujita int astpending; /* need to trap before returning to user mode */ 8353972Sfujita int want_resched; /* resched() was called */ 8453972Sfujita 8553972Sfujita 8653972Sfujita /* 8753972Sfujita * simulated software interrupt register 8853972Sfujita */ 8953972Sfujita extern unsigned char ssir; 9053972Sfujita 9153972Sfujita #define SIR_NET 0x1 9253972Sfujita #define SIR_CLOCK 0x2 9353972Sfujita 9453972Sfujita #define siroff(x) ssir &= ~(x) 9553972Sfujita #define setsoftnet() ssir |= SIR_NET 9653972Sfujita #define setsoftclock() ssir |= SIR_CLOCK 9753972Sfujita 9860362Sakito /* 9960362Sakito * CTL_MACHDEP definitions. 10060362Sakito */ 10160362Sakito #define CPU_CONSDEV 1 /* dev_t: console terminal device */ 10260362Sakito #define CPU_MAXID 2 /* number of valid machdep ids */ 10360362Sakito 10460362Sakito #define CTL_MACHDEP_NAMES { \ 10560362Sakito { 0, 0 }, \ 10660362Sakito { "console_device", CTLTYPE_STRUCT }, \ 10760362Sakito } 10860362Sakito 10959943Sakito #ifdef KERNEL 11059943Sakito extern int mmutype, machineid; 11159943Sakito #endif 11259943Sakito 11359943Sakito /* values for machineid */ 11459943Sakito #define LUNA_I 1 /* 20Mhz 68030 */ 11559943Sakito #define LUNA_II 2 /* 25Mhz 68040 */ 11659943Sakito 11753972Sfujita /* values for mmutype (assigned for quick testing) */ 11853972Sfujita #define MMU_68040 -2 /* 68040 on-chip MMU */ 11953972Sfujita #define MMU_68030 -1 /* 68030 on-chip subset of 68851 */ 12053972Sfujita 12153972Sfujita /* values for cpuspeed (not really related to clock speed due to caches) */ 12253972Sfujita #define MHZ_8 1 12353972Sfujita #define MHZ_16 2 12453972Sfujita #define MHZ_25 3 12553972Sfujita #define MHZ_33 4 12653972Sfujita #define MHZ_50 6 12753972Sfujita 12853972Sfujita /* 12953972Sfujita * 68851 and 68030 MMU 13053972Sfujita */ 13153972Sfujita #define PMMU_LVLMASK 0x0007 13253972Sfujita #define PMMU_INV 0x0400 13353972Sfujita #define PMMU_WP 0x0800 13453972Sfujita #define PMMU_ALV 0x1000 13553972Sfujita #define PMMU_SO 0x2000 13653972Sfujita #define PMMU_LV 0x4000 13753972Sfujita #define PMMU_BE 0x8000 13853972Sfujita #define PMMU_FAULT (PMMU_WP|PMMU_INV) 13953972Sfujita 14053972Sfujita /* 14153972Sfujita * 68040 MMU 14253972Sfujita */ 14353972Sfujita #define MMU4_RES 0x001 14453972Sfujita #define MMU4_TTR 0x002 14553972Sfujita #define MMU4_WP 0x004 14653972Sfujita #define MMU4_MOD 0x010 14753972Sfujita #define MMU4_CMMASK 0x060 14853972Sfujita #define MMU4_SUP 0x080 14953972Sfujita #define MMU4_U0 0x100 15053972Sfujita #define MMU4_U1 0x200 15153972Sfujita #define MMU4_GLB 0x400 15253972Sfujita #define MMU4_BE 0x800 15353972Sfujita 15453972Sfujita /* 680X0 function codes */ 15553972Sfujita #define FC_USERD 1 /* user data space */ 15653972Sfujita #define FC_USERP 2 /* user program space */ 15753972Sfujita #define FC_PURGE 3 /* HPMMU: clear TLB entries */ 15853972Sfujita #define FC_SUPERD 5 /* supervisor data space */ 15953972Sfujita #define FC_SUPERP 6 /* supervisor program space */ 16053972Sfujita #define FC_CPU 7 /* CPU space */ 16153972Sfujita 16253972Sfujita /* fields in the 68020 cache control register */ 16353972Sfujita #define IC_ENABLE 0x0001 /* enable instruction cache */ 16453972Sfujita #define IC_FREEZE 0x0002 /* freeze instruction cache */ 16553972Sfujita #define IC_CE 0x0004 /* clear instruction cache entry */ 16653972Sfujita #define IC_CLR 0x0008 /* clear entire instruction cache */ 16753972Sfujita 16853972Sfujita /* additional fields in the 68030 cache control register */ 16953972Sfujita #define IC_BE 0x0010 /* instruction burst enable */ 17053972Sfujita #define DC_ENABLE 0x0100 /* data cache enable */ 17153972Sfujita #define DC_FREEZE 0x0200 /* data cache freeze */ 17253972Sfujita #define DC_CE 0x0400 /* clear data cache entry */ 17353972Sfujita #define DC_CLR 0x0800 /* clear entire data cache */ 17453972Sfujita #define DC_BE 0x1000 /* data burst enable */ 17553972Sfujita #define DC_WA 0x2000 /* write allocate */ 17653972Sfujita 17753972Sfujita #define CACHE_ON (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE) 17853972Sfujita #define CACHE_OFF (DC_CLR|IC_CLR) 17953972Sfujita #define CACHE_CLR (CACHE_ON) 18053972Sfujita #define IC_CLEAR (DC_WA|DC_BE|DC_ENABLE|IC_BE|IC_CLR|IC_ENABLE) 18153972Sfujita #define DC_CLEAR (DC_WA|DC_BE|DC_CLR|DC_ENABLE|IC_BE|IC_ENABLE) 18253972Sfujita 18353972Sfujita /* 68040 cache control register */ 18453972Sfujita #define IC4_ENABLE 0x8000 /* instruction cache enable bit */ 18553972Sfujita #define DC4_ENABLE 0x80000000 /* data cache enable bit */ 18653972Sfujita 18753972Sfujita #define CACHE4_ON (IC4_ENABLE|DC4_ENABLE) 18853972Sfujita #define CACHE4_OFF (0) 189