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