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