xref: /csrg-svn/sys/news3400/include/cpu.h (revision 53899)
1*53899Smckusick /*
2*53899Smckusick  * Copyright (c) 1992 Regents of the University of California.
3*53899Smckusick  * All rights reserved.
4*53899Smckusick  *
5*53899Smckusick  * This code is derived from software contributed to Berkeley by
6*53899Smckusick  * Ralph Campbell and Kazumasa Utashiro of Software Research
7*53899Smckusick  * Associates, Inc.
8*53899Smckusick  *
9*53899Smckusick  * %sccs.include.redist.c%
10*53899Smckusick  *
11*53899Smckusick  *	@(#)cpu.h	7.1 (Berkeley) 06/04/92
12*53899Smckusick  */
13*53899Smckusick 
14*53899Smckusick #ifndef _CPU_H_
15*53899Smckusick #define _CPU_H_
16*53899Smckusick 
17*53899Smckusick #include "machConst.h"
18*53899Smckusick 
19*53899Smckusick /*
20*53899Smckusick  * Exported definitions unique to pmax/mips cpu support.
21*53899Smckusick  */
22*53899Smckusick 
23*53899Smckusick /*
24*53899Smckusick  * definitions of cpu-dependent requirements
25*53899Smckusick  * referenced in generic code
26*53899Smckusick  */
27*53899Smckusick #undef	COPY_SIGCODE		/* copy sigcode above user stack in exec */
28*53899Smckusick 
29*53899Smckusick /*
30*53899Smckusick  * function vs. inline configuration;
31*53899Smckusick  * these are defined to get generic functions
32*53899Smckusick  * rather than inline or machine-dependent implementations
33*53899Smckusick  */
34*53899Smckusick #define	NEED_MINMAX		/* need {,i,l,ul}{min,max} functions */
35*53899Smckusick #define	NEED_FFS		/* don't need ffs function */
36*53899Smckusick #undef	NEED_BCMP		/* don't need bcmp function */
37*53899Smckusick #undef	NEED_STRLEN		/* don't need strlen function */
38*53899Smckusick 
39*53899Smckusick #define	cpu_exec(p)	(p->p_md.md_ss_addr = 0) /* init single step */
40*53899Smckusick #define	cpu_wait(p)	/* nothing */
41*53899Smckusick #define cpu_setstack(p, ap) \
42*53899Smckusick 	(p)->p_md.md_regs[SP] = ap
43*53899Smckusick 
44*53899Smckusick /*
45*53899Smckusick  * Arguments to hardclock, softclock and gatherstats
46*53899Smckusick  * encapsulate the previous machine state in an opaque
47*53899Smckusick  * clockframe;
48*53899Smckusick  */
49*53899Smckusick typedef struct intrframe {
50*53899Smckusick 	int	pc;
51*53899Smckusick 	int	ps;
52*53899Smckusick } clockframe;
53*53899Smckusick 
54*53899Smckusick #define	CLKF_USERMODE(framep)	((framep)->ps & MACH_SR_KU_PREV)
55*53899Smckusick #define	CLKF_BASEPRI(framep)	\
56*53899Smckusick 	(((framep)->ps & (MACH_INT_MASK | MACH_SR_INT_ENA_PREV)) == \
57*53899Smckusick 	(MACH_INT_MASK | MACH_SR_INT_ENA_PREV))
58*53899Smckusick #define	CLKF_PC(framep)		((framep)->pc)
59*53899Smckusick 
60*53899Smckusick /*
61*53899Smckusick  * Preempt the current process if in interrupt from user mode,
62*53899Smckusick  * or after the current trap/syscall if in system mode.
63*53899Smckusick  */
64*53899Smckusick #define	need_resched()	{ want_resched = 1; aston(); }
65*53899Smckusick 
66*53899Smckusick /*
67*53899Smckusick  * Give a profiling tick to the current process from the softclock
68*53899Smckusick  * interrupt.
69*53899Smckusick  */
70*53899Smckusick #define	profile_tick(p, framep) \
71*53899Smckusick 	addupc((framep)->pc, &p->p_stats->p_prof, 1);
72*53899Smckusick 
73*53899Smckusick /*
74*53899Smckusick  * Notify the current process (p) that it has a signal pending,
75*53899Smckusick  * process as soon as possible.
76*53899Smckusick  */
77*53899Smckusick #define	signotify(p)	aston()
78*53899Smckusick 
79*53899Smckusick #define aston()		(astpending = 1)
80*53899Smckusick 
81*53899Smckusick int	astpending;	/* need to trap before returning to user mode */
82*53899Smckusick int	want_resched;	/* resched() was called */
83*53899Smckusick 
84*53899Smckusick /*
85*53899Smckusick  * CPU identification, from PRID register.
86*53899Smckusick  */
87*53899Smckusick union cpuprid {
88*53899Smckusick 	int	cpuprid;
89*53899Smckusick 	struct {
90*53899Smckusick #if BYTE_ORDER == BIG_ENDIAN
91*53899Smckusick 		u_int	pad1:16;	/* reserved */
92*53899Smckusick 		u_int	cp_imp:8;	/* implementation identifier */
93*53899Smckusick 		u_int	cp_majrev:4;	/* major revision identifier */
94*53899Smckusick 		u_int	cp_minrev:4;	/* minor revision identifier */
95*53899Smckusick #else
96*53899Smckusick 		u_int	cp_minrev:4;	/* minor revision identifier */
97*53899Smckusick 		u_int	cp_majrev:4;	/* major revision identifier */
98*53899Smckusick 		u_int	cp_imp:8;	/* implementation identifier */
99*53899Smckusick 		u_int	pad1:16;	/* reserved */
100*53899Smckusick #endif
101*53899Smckusick 	} cpu;
102*53899Smckusick };
103*53899Smckusick 
104*53899Smckusick /*
105*53899Smckusick  * MIPS CPU types (cp_imp).
106*53899Smckusick  */
107*53899Smckusick #define	MIPS_R2000	0x01
108*53899Smckusick #define	MIPS_R3000	0x02
109*53899Smckusick #define	MIPS_R6000	0x03
110*53899Smckusick #define	MIPS_R4000	0x04
111*53899Smckusick #define	MIPS_R6000A	0x06
112*53899Smckusick 
113*53899Smckusick /*
114*53899Smckusick  * MIPS FPU types
115*53899Smckusick  */
116*53899Smckusick #define	MIPS_R2010_FPU	0x02
117*53899Smckusick #define	MIPS_R3010_FPU	0x03
118*53899Smckusick #define	MIPS_R6010_FPU	0x04
119*53899Smckusick #define	MIPS_R4000_FPU	0x05
120*53899Smckusick 
121*53899Smckusick struct intr_tab {
122*53899Smckusick 	void	(*func)();	/* pointer to interrupt routine */
123*53899Smckusick 	int	unit;		/* logical unit number */
124*53899Smckusick };
125*53899Smckusick 
126*53899Smckusick #ifdef KERNEL
127*53899Smckusick union	cpuprid cpu;
128*53899Smckusick union	cpuprid fpu;
129*53899Smckusick u_int	machDataCacheSize;
130*53899Smckusick u_int	machInstCacheSize;
131*53899Smckusick extern	struct intr_tab intr_tab[];
132*53899Smckusick #endif
133*53899Smckusick 
134*53899Smckusick #endif /* _CPU_H_ */
135