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*65082Smckusick * @(#)cpu.h 8.3 (Berkeley) 12/10/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 47*65082Smckusick #define cpu_exec(p) /* nothing */ 48*65082Smckusick #define cpu_wait(p) /* nothing */ 4955118Storek #define cpu_setstack(p, ap) ((p)->p_md.md_tf->tf_out[6] = (ap) - 64) 5055118Storek 5155118Storek /* 52*65082Smckusick * See syscall() for an explanation of the following. Note that the 53*65082Smckusick * locore bootstrap code follows the syscall stack protocol. The 54*65082Smckusick * framep argument is unused. 55*65082Smckusick */ 56*65082Smckusick #define cpu_set_init_frame(p, fp) \ 57*65082Smckusick (p)->p_md.md_tf = (struct trapframe *) \ 58*65082Smckusick ((caddr_t)(p)->p_addr + UPAGES * NBPG - sizeof(struct trapframe)) 59*65082Smckusick 60*65082Smckusick /* 6155118Storek * Arguments to hardclock, softclock and gatherstats encapsulate the 6255118Storek * previous machine state in an opaque clockframe. The ipl is here 6355118Storek * as well for strayintr (see locore.s:interrupt and intr.c:strayintr). 6455118Storek * Note that CLKF_INTR is valid only if CLKF_USERMODE is false. 6555118Storek */ 6655118Storek struct clockframe { 6755118Storek u_int psr; /* psr before interrupt, excluding PSR_ET */ 6855118Storek u_int pc; /* pc at interrupt */ 6955118Storek u_int npc; /* npc at interrupt */ 7055118Storek u_int ipl; /* actual interrupt priority level */ 7155118Storek u_int fp; /* %fp at interrupt */ 7255118Storek }; 7355118Storek 7455118Storek extern int eintstack[]; 7555118Storek 7655118Storek #define CLKF_USERMODE(framep) (((framep)->psr & PSR_PS) == 0) 7755118Storek #define CLKF_BASEPRI(framep) (((framep)->psr & PSR_PIL) == 0) 7855118Storek #define CLKF_PC(framep) ((framep)->pc) 7955118Storek #define CLKF_INTR(framep) ((framep)->fp < (u_int)eintstack) 8055118Storek 8155118Storek /* 8255118Storek * Software interrupt request `register'. 8355118Storek */ 8455118Storek union sir { 8555118Storek int sir_any; 8655118Storek char sir_which[4]; 8755118Storek } sir; 8855118Storek 8955118Storek #define SIR_NET 0 9055118Storek #define SIR_CLOCK 1 9155118Storek 9255118Storek #define setsoftint() ienab_bis(IE_L1) 9355118Storek #define setsoftnet() (sir.sir_which[SIR_NET] = 1, setsoftint()) 9455118Storek #define setsoftclock() (sir.sir_which[SIR_CLOCK] = 1, setsoftint()) 9555118Storek 9655118Storek int want_ast; 9755118Storek 9855118Storek /* 9955118Storek * Preempt the current process if in interrupt from user mode, 10055118Storek * or after the current trap/syscall if in system mode. 10155118Storek */ 10255118Storek int want_resched; /* resched() was called */ 10355118Storek #define need_resched() (want_resched = 1, want_ast = 1) 10455118Storek 10555118Storek /* 10655118Storek * Give a profiling tick to the current process when the user profiling 10755118Storek * buffer pages are invalid. On the sparc, request an ast to send us 10855118Storek * through trap(), marking the proc as needing a profiling tick. 10955118Storek */ 11064633Sbostic #define need_proftick(p) ((p)->p_flag |= P_OWEUPC, want_ast = 1) 11155118Storek 11255118Storek /* 11355118Storek * Notify the current process (p) that it has a signal pending, 11455118Storek * process as soon as possible. 11555118Storek */ 11655118Storek #define signotify(p) (want_ast = 1) 11755118Storek 11855118Storek /* 11955118Storek * Only one process may own the FPU state. 12055118Storek * 12155118Storek * XXX this must be per-cpu (eventually) 12255118Storek */ 12355118Storek struct proc *fpproc; /* FPU owner */ 12455118Storek int foundfpu; /* true => we have an FPU */ 12555118Storek 12655118Storek /* 12755118Storek * Interrupt handler chains. Interrupt handlers should return 0 for 12855118Storek * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a 12955118Storek * handler into the list. The handler is called with its (single) 13055118Storek * argument, or with a pointer to a clockframe if ih_arg is NULL. 13155118Storek */ 13255118Storek struct intrhand { 13355118Storek int (*ih_fun) __P((void *)); 13455118Storek void *ih_arg; 13555118Storek struct intrhand *ih_next; 13655118Storek } *intrhand[15]; 13755118Storek 13855118Storek void intr_establish __P((int level, struct intrhand *)); 13955118Storek 14055118Storek /* 14155118Storek * intr_fasttrap() is a lot like intr_establish, but is used for ``fast'' 14255118Storek * interrupt vectors (vectors that are not shared and are handled in the 14355118Storek * trap window). Such functions must be written in assembly. 14455118Storek */ 14555118Storek void intr_fasttrap __P((int level, void (*vec)(void))); 14655118Storek 14760355Storek #endif /* KERNEL */ 14860355Storek #endif /* _CPU_H_ */ 149