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