1 /*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * William Jolitz. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)cpu.h 8.1 (Berkeley) 06/11/93 11 */ 12 13 /* 14 * Definitions unique to i386 cpu support. 15 */ 16 #include <machine/frame.h> 17 #include <machine/segments.h> 18 19 /* 20 * definitions of cpu-dependent requirements 21 * referenced in generic code 22 */ 23 #undef COPY_SIGCODE /* don't copy sigcode above user stack in exec */ 24 25 /* 26 * function vs. inline configuration; 27 * these are defined to get generic functions 28 * rather than inline or machine-dependent implementations 29 */ 30 #define NEED_MINMAX /* need {,i,l,ul}{min,max} functions */ 31 #define NEED_FFS /* need ffs function */ 32 #define NEED_BCMP /* need bcmp function */ 33 #define NEED_STRLEN /* need strlen function */ 34 35 #define cpu_exec(p) /* nothing */ 36 #define cpu_setstack(p, ap) \ 37 (p)->p_md.md_regs[SP] = ap 38 39 /* 40 * Arguments to hardclock, softclock and gatherstats 41 * encapsulate the previous machine state in an opaque 42 * clockframe; for now, use generic intrframe. 43 */ 44 struct clockframe { 45 struct intrframe cf_if; 46 }; 47 48 #define CLKF_USERMODE(framep) (ISPL((framep)->cf_if.if_cs) == SEL_UPL) 49 #define CLKF_BASEPRI(framep) ((framep)->cf_if.if_ppl == 0) 50 #define CLKF_PC(framep) ((framep)->cf_if.if_eip) 51 52 #define resettodr() /* no todr to set */ 53 54 /* 55 * Preempt the current process if in interrupt from user mode, 56 * or after the current trap/syscall if in system mode. 57 */ 58 #define need_resched() { want_resched++; aston(); } 59 60 /* 61 * Give a profiling tick to the current process from the softclock 62 * interrupt. On tahoe, request an ast to send us through trap(), 63 * marking the proc as needing a profiling tick. 64 */ 65 #define profile_tick(p, framep) { (p)->p_flag |= SOWEUPC; aston(); } 66 67 /* 68 * Notify the current process (p) that it has a signal pending, 69 * process as soon as possible. 70 */ 71 #define signotify(p) aston() 72 73 #define aston() (astpending++) 74 75 int astpending; /* need to trap before returning to user mode */ 76 int want_resched; /* resched() was called */ 77 78 /* 79 * Kinds of processor 80 */ 81 82 #define CPU_386SX 0 83 #define CPU_386 1 84 #define CPU_486SX 2 85 #define CPU_486 3 86 #define CPU_586 4 87 88 /* 89 * CTL_MACHDEP definitions. 90 */ 91 #define CPU_CONSDEV 1 /* dev_t: console terminal device */ 92 #define CPU_MAXID 2 /* number of valid machdep ids */ 93 94 #define CTL_MACHDEP_NAMES { \ 95 { 0, 0 }, \ 96 { "console_device", CTLTYPE_STRUCT }, \ 97 } 98