xref: /original-bsd/sys/pmax/include/cpu.h (revision 10042f30)
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.3 (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 #define cpu_setstack(p, ap) \
41 	(p)->p_md.md_regs[SP] = ap
42 
43 /*
44  * Arguments to hardclock, softclock and gatherstats
45  * encapsulate the previous machine state in an opaque
46  * clockframe;
47  */
48 typedef struct intrframe {
49 	int	pc;
50 	int	ps;
51 } clockframe;
52 
53 #define	CLKF_USERMODE(framep)	((framep)->ps & MACH_SR_KU_PREV)
54 #define	CLKF_BASEPRI(framep)	\
55 	(((framep)->ps & (MACH_INT_MASK | MACH_SR_INT_ENA_PREV)) == \
56 	(MACH_INT_MASK | MACH_SR_INT_ENA_PREV))
57 #define	CLKF_PC(framep)		((framep)->pc)
58 
59 /*
60  * Preempt the current process if in interrupt from user mode,
61  * or after the current trap/syscall if in system mode.
62  */
63 #define	need_resched()	{ want_resched = 1; aston(); }
64 
65 /*
66  * Give a profiling tick to the current process from the softclock
67  * interrupt.
68  */
69 #define	profile_tick(p, framep) \
70 	addupc((framep)->pc, &p->p_stats->p_prof, 1);
71 
72 /*
73  * Notify the current process (p) that it has a signal pending,
74  * process as soon as possible.
75  */
76 #define	signotify(p)	aston()
77 
78 #define aston()		(astpending = 1)
79 
80 int	astpending;	/* need to trap before returning to user mode */
81 int	want_resched;	/* resched() was called */
82 
83 /*
84  * CPU identification, from PRID register.
85  */
86 union cpuprid {
87 	int	cpuprid;
88 	struct {
89 #if BYTE_ORDER == BIG_ENDIAN
90 		u_int	pad1:16;	/* reserved */
91 		u_int	cp_imp:8;	/* implementation identifier */
92 		u_int	cp_majrev:4;	/* major revision identifier */
93 		u_int	cp_minrev:4;	/* minor revision identifier */
94 #else
95 		u_int	cp_minrev:4;	/* minor revision identifier */
96 		u_int	cp_majrev:4;	/* major revision identifier */
97 		u_int	cp_imp:8;	/* implementation identifier */
98 		u_int	pad1:16;	/* reserved */
99 #endif
100 	} cpu;
101 };
102 
103 /*
104  * MIPS CPU types (cp_imp).
105  */
106 #define	MIPS_R2000	0x02
107 #define	MIPS_R3000	0x03
108 #define	MIPS_R4000	0x04
109 
110 /*
111  * MIPS FPU types
112  */
113 #define	MIPS_R2010	0x03
114 #define	MIPS_R3010	0x04
115 #define	MIPS_R4010	0x05
116 
117 struct intr_tab {
118 	void	(*func)();	/* pointer to interrupt routine */
119 	int	unit;		/* logical unit number */
120 };
121 
122 #ifdef KERNEL
123 union	cpuprid cpu;
124 union	cpuprid fpu;
125 u_int	machDataCacheSize;
126 u_int	machInstCacheSize;
127 extern	struct intr_tab intr_tab[];
128 #endif
129 
130 /*
131  * Enable realtime clock (always enabled).
132  */
133 #define	enablertclock()
134 
135 #endif /* _CPU_H_ */
136