1 /* 2 * Copyright (c) 1992 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This software was developed by the Computer Systems Engineering group 6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7 * contributed to Berkeley. 8 * 9 * %sccs.include.redist.c% 10 * 11 * @(#)cpu.h 7.1 (Berkeley) 07/13/92 12 * 13 * from: $Header: cpu.h,v 1.10 92/07/09 03:10:54 torek Exp $ (LBL) 14 */ 15 16 #ifndef _CPU_H_ 17 #define _CPU_H_ 18 19 #include "machine/psl.h" 20 #include "../sparc/intreg.h" 21 22 /* 23 * Exported definitions unique to SPARC cpu support. 24 */ 25 26 /* 27 * definitions of cpu-dependent requirements 28 * referenced in generic code 29 */ 30 #define COPY_SIGCODE /* copy sigcode above user stack in exec */ 31 32 /* 33 * function vs. inline configuration; 34 * these are defined to get generic functions 35 * rather than inline or machine-dependent implementations 36 */ 37 #define NEED_MINMAX /* need {,i,l,ul}{min,max} functions */ 38 #undef NEED_FFS /* don't need ffs function */ 39 #define NEED_BCMP /* need bcmp function */ 40 #define NEED_STRLEN /* need strlen function */ 41 42 #define cpu_exec(p) /* nothing */ 43 #define cpu_wait(p) /* nothing */ 44 #define cpu_setstack(p, ap) ((p)->p_md.md_tf->tf_out[6] = (ap) - 64) 45 46 /* 47 * Arguments to hardclock, softclock and gatherstats encapsulate the 48 * previous machine state in an opaque clockframe. The ipl is here 49 * as well for strayintr (see locore.s:interrupt and intr.c:strayintr). 50 * Note that CLKF_INTR is valid only if CLKF_USERMODE is false. 51 */ 52 struct clockframe { 53 u_int psr; /* psr before interrupt, excluding PSR_ET */ 54 u_int pc; /* pc at interrupt */ 55 u_int npc; /* npc at interrupt */ 56 u_int ipl; /* actual interrupt priority level */ 57 u_int fp; /* %fp at interrupt */ 58 }; 59 60 extern int eintstack[]; 61 62 #define CLKF_USERMODE(framep) (((framep)->psr & PSR_PS) == 0) 63 #define CLKF_BASEPRI(framep) (((framep)->psr & PSR_PIL) == 0) 64 #define CLKF_PC(framep) ((framep)->pc) 65 #define CLKF_INTR(framep) ((framep)->fp < (u_int)eintstack) 66 67 /* 68 * Software interrupt request `register'. 69 */ 70 union sir { 71 int sir_any; 72 char sir_which[4]; 73 } sir; 74 75 #define SIR_NET 0 76 #define SIR_CLOCK 1 77 78 #define setsoftint() ienab_bis(IE_L1) 79 #define setsoftnet() (sir.sir_which[SIR_NET] = 1, setsoftint()) 80 #define setsoftclock() (sir.sir_which[SIR_CLOCK] = 1, setsoftint()) 81 82 int want_ast; 83 84 /* 85 * Preempt the current process if in interrupt from user mode, 86 * or after the current trap/syscall if in system mode. 87 */ 88 int want_resched; /* resched() was called */ 89 #define need_resched() (want_resched = 1, want_ast = 1) 90 91 /* 92 * Give a profiling tick to the current process when the user profiling 93 * buffer pages are invalid. On the sparc, request an ast to send us 94 * through trap(), marking the proc as needing a profiling tick. 95 */ 96 #define need_proftick(p) ((p)->p_flag |= SOWEUPC, want_ast = 1) 97 98 /* 99 * Notify the current process (p) that it has a signal pending, 100 * process as soon as possible. 101 */ 102 #define signotify(p) (want_ast = 1) 103 104 /* 105 * Only one process may own the FPU state. 106 * 107 * XXX this must be per-cpu (eventually) 108 */ 109 struct proc *fpproc; /* FPU owner */ 110 int foundfpu; /* true => we have an FPU */ 111 112 /* 113 * Interrupt handler chains. Interrupt handlers should return 0 for 114 * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a 115 * handler into the list. The handler is called with its (single) 116 * argument, or with a pointer to a clockframe if ih_arg is NULL. 117 */ 118 struct intrhand { 119 int (*ih_fun) __P((void *)); 120 void *ih_arg; 121 struct intrhand *ih_next; 122 } *intrhand[15]; 123 124 void intr_establish __P((int level, struct intrhand *)); 125 126 /* 127 * intr_fasttrap() is a lot like intr_establish, but is used for ``fast'' 128 * interrupt vectors (vectors that are not shared and are handled in the 129 * trap window). Such functions must be written in assembly. 130 */ 131 void intr_fasttrap __P((int level, void (*vec)(void))); 132 133 #endif _CPU_H_ 134