155118Storek /* 263320Sbostic * Copyright (c) 1992, 1993 363320Sbostic * The Regents of the University of California. All rights reserved. 455118Storek * 555118Storek * This software was developed by the Computer Systems Engineering group 655118Storek * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 755118Storek * contributed to Berkeley. 855118Storek * 955501Sbostic * All advertising materials mentioning features or use of this software 1055501Sbostic * must display the following acknowledgement: 1155501Sbostic * This product includes software developed by the University of 1259199Storek * California, Lawrence Berkeley Laboratory. 1355501Sbostic * 1455118Storek * %sccs.include.redist.c% 1555118Storek * 16*64633Sbostic * @(#)cpu.h 8.2 (Berkeley) 09/23/93 1755118Storek * 1860355Storek * from: $Header: cpu.h,v 1.12 93/05/25 10:36:34 torek Exp $ (LBL) 1955118Storek */ 2055118Storek 2155118Storek #ifndef _CPU_H_ 2255118Storek #define _CPU_H_ 2355118Storek 2460355Storek /* 2560355Storek * CTL_MACHDEP definitinos. 2660355Storek */ 2760355Storek #define CPU_MAXID 1 /* no valid machdep ids */ 2855118Storek 2960355Storek #define CTL_MACHDEP_NAMES { \ 3060355Storek { 0, 0 }, \ 3160355Storek } 3260355Storek 3360355Storek #ifdef KERNEL 3455118Storek /* 3555118Storek * Exported definitions unique to SPARC cpu support. 3655118Storek */ 3755118Storek 3860355Storek #include <machine/psl.h> 3960355Storek #include <sparc/sparc/intreg.h> 4060355Storek 4155118Storek /* 4255118Storek * definitions of cpu-dependent requirements 4355118Storek * referenced in generic code 4455118Storek */ 4555118Storek #define COPY_SIGCODE /* copy sigcode above user stack in exec */ 4655118Storek 4755118Storek #define cpu_exec(p) /* nothing */ 4855118Storek #define cpu_wait(p) /* nothing */ 4955118Storek #define cpu_setstack(p, ap) ((p)->p_md.md_tf->tf_out[6] = (ap) - 64) 5055118Storek 5155118Storek /* 5255118Storek * Arguments to hardclock, softclock and gatherstats encapsulate the 5355118Storek * previous machine state in an opaque clockframe. The ipl is here 5455118Storek * as well for strayintr (see locore.s:interrupt and intr.c:strayintr). 5555118Storek * Note that CLKF_INTR is valid only if CLKF_USERMODE is false. 5655118Storek */ 5755118Storek struct clockframe { 5855118Storek u_int psr; /* psr before interrupt, excluding PSR_ET */ 5955118Storek u_int pc; /* pc at interrupt */ 6055118Storek u_int npc; /* npc at interrupt */ 6155118Storek u_int ipl; /* actual interrupt priority level */ 6255118Storek u_int fp; /* %fp at interrupt */ 6355118Storek }; 6455118Storek 6555118Storek extern int eintstack[]; 6655118Storek 6755118Storek #define CLKF_USERMODE(framep) (((framep)->psr & PSR_PS) == 0) 6855118Storek #define CLKF_BASEPRI(framep) (((framep)->psr & PSR_PIL) == 0) 6955118Storek #define CLKF_PC(framep) ((framep)->pc) 7055118Storek #define CLKF_INTR(framep) ((framep)->fp < (u_int)eintstack) 7155118Storek 7255118Storek /* 7355118Storek * Software interrupt request `register'. 7455118Storek */ 7555118Storek union sir { 7655118Storek int sir_any; 7755118Storek char sir_which[4]; 7855118Storek } sir; 7955118Storek 8055118Storek #define SIR_NET 0 8155118Storek #define SIR_CLOCK 1 8255118Storek 8355118Storek #define setsoftint() ienab_bis(IE_L1) 8455118Storek #define setsoftnet() (sir.sir_which[SIR_NET] = 1, setsoftint()) 8555118Storek #define setsoftclock() (sir.sir_which[SIR_CLOCK] = 1, setsoftint()) 8655118Storek 8755118Storek int want_ast; 8855118Storek 8955118Storek /* 9055118Storek * Preempt the current process if in interrupt from user mode, 9155118Storek * or after the current trap/syscall if in system mode. 9255118Storek */ 9355118Storek int want_resched; /* resched() was called */ 9455118Storek #define need_resched() (want_resched = 1, want_ast = 1) 9555118Storek 9655118Storek /* 9755118Storek * Give a profiling tick to the current process when the user profiling 9855118Storek * buffer pages are invalid. On the sparc, request an ast to send us 9955118Storek * through trap(), marking the proc as needing a profiling tick. 10055118Storek */ 101*64633Sbostic #define need_proftick(p) ((p)->p_flag |= P_OWEUPC, want_ast = 1) 10255118Storek 10355118Storek /* 10455118Storek * Notify the current process (p) that it has a signal pending, 10555118Storek * process as soon as possible. 10655118Storek */ 10755118Storek #define signotify(p) (want_ast = 1) 10855118Storek 10955118Storek /* 11055118Storek * Only one process may own the FPU state. 11155118Storek * 11255118Storek * XXX this must be per-cpu (eventually) 11355118Storek */ 11455118Storek struct proc *fpproc; /* FPU owner */ 11555118Storek int foundfpu; /* true => we have an FPU */ 11655118Storek 11755118Storek /* 11855118Storek * Interrupt handler chains. Interrupt handlers should return 0 for 11955118Storek * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a 12055118Storek * handler into the list. The handler is called with its (single) 12155118Storek * argument, or with a pointer to a clockframe if ih_arg is NULL. 12255118Storek */ 12355118Storek struct intrhand { 12455118Storek int (*ih_fun) __P((void *)); 12555118Storek void *ih_arg; 12655118Storek struct intrhand *ih_next; 12755118Storek } *intrhand[15]; 12855118Storek 12955118Storek void intr_establish __P((int level, struct intrhand *)); 13055118Storek 13155118Storek /* 13255118Storek * intr_fasttrap() is a lot like intr_establish, but is used for ``fast'' 13355118Storek * interrupt vectors (vectors that are not shared and are handled in the 13455118Storek * trap window). Such functions must be written in assembly. 13555118Storek */ 13655118Storek void intr_fasttrap __P((int level, void (*vec)(void))); 13755118Storek 13860355Storek #endif /* KERNEL */ 13960355Storek #endif /* _CPU_H_ */ 140