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