xref: /original-bsd/sys/news3400/include/cpu.h (revision 84651319)
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.4 (Berkeley) 01/20/93
12  */
13 
14 #ifndef _CPU_H_
15 #define _CPU_H_
16 
17 #include <machine/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 #define	COPY_SIGCODE		/* copy sigcode above user stack in exec */
28 
29 #define	cpu_exec(p)	(p->p_md.md_ss_addr = 0) /* init single step */
30 #define	cpu_wait(p)	/* nothing */
31 #define cpu_setstack(p, ap) \
32 	(p)->p_md.md_regs[SP] = ap
33 
34 /*
35  * Arguments to hardclock and gatherstats encapsulate the previous
36  * machine state in an opaque clockframe.
37  */
38 struct clockframe {
39 	int	pc;	/* program counter at time of interrupt */
40 	int	sr;	/* status register at time of interrupt */
41 };
42 
43 #define	CLKF_USERMODE(framep)	((framep)->sr & MACH_SR_KU_PREV)
44 #define	CLKF_BASEPRI(framep)	\
45 	((~(framep)->sr & (MACH_INT_MASK | MACH_SR_INT_ENA_PREV)) == 0)
46 #define	CLKF_PC(framep)		((framep)->pc)
47 #define	CLKF_INTR(framep)	(0)
48 
49 /*
50  * Preempt the current process if in interrupt from user mode,
51  * or after the current trap/syscall if in system mode.
52  */
53 #define	need_resched()	{ want_resched = 1; aston(); }
54 
55 /*
56  * Give a profiling tick to the current process when the user profiling
57  * buffer pages are invalid.  On the PMAX, request an ast to send us
58  * through trap, marking the proc as needing a profiling tick.
59  */
60 #define	need_proftick(p)	{ (p)->p_flag |= SOWEUPC; aston(); }
61 
62 /*
63  * Notify the current process (p) that it has a signal pending,
64  * process as soon as possible.
65  */
66 #define	signotify(p)	aston()
67 
68 #define aston()		(astpending = 1)
69 
70 int	astpending;	/* need to trap before returning to user mode */
71 int	want_resched;	/* resched() was called */
72 
73 /*
74  * CPU identification, from PRID register.
75  */
76 union cpuprid {
77 	int	cpuprid;
78 	struct {
79 #if BYTE_ORDER == BIG_ENDIAN
80 		u_int	pad1:16;	/* reserved */
81 		u_int	cp_imp:8;	/* implementation identifier */
82 		u_int	cp_majrev:4;	/* major revision identifier */
83 		u_int	cp_minrev:4;	/* minor revision identifier */
84 #else
85 		u_int	cp_minrev:4;	/* minor revision identifier */
86 		u_int	cp_majrev:4;	/* major revision identifier */
87 		u_int	cp_imp:8;	/* implementation identifier */
88 		u_int	pad1:16;	/* reserved */
89 #endif
90 	} cpu;
91 };
92 
93 /*
94  * MIPS CPU types (cp_imp).
95  */
96 #define	MIPS_R2000	0x01
97 #define	MIPS_R3000	0x02
98 #define	MIPS_R6000	0x03
99 #define	MIPS_R4000	0x04
100 #define	MIPS_R6000A	0x06
101 
102 /*
103  * MIPS FPU types
104  */
105 #define	MIPS_R2010_FPU	0x02
106 #define	MIPS_R3010_FPU	0x03
107 #define	MIPS_R6010_FPU	0x04
108 #define	MIPS_R4000_FPU	0x05
109 
110 struct intr_tab {
111 	void	(*func)();	/* pointer to interrupt routine */
112 	int	unit;		/* logical unit number */
113 };
114 
115 #ifdef KERNEL
116 union	cpuprid cpu;
117 union	cpuprid fpu;
118 u_int	machDataCacheSize;
119 u_int	machInstCacheSize;
120 extern	struct intr_tab intr_tab[];
121 #endif
122 
123 #endif /* _CPU_H_ */
124