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