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