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