xref: /csrg-svn/sys/pmax/include/cpu.h (revision 52757)
152131Smckusick /*
252131Smckusick  * Copyright (c) 1992 Regents of the University of California.
352131Smckusick  * All rights reserved.
452131Smckusick  *
552131Smckusick  * This code is derived from software contributed to Berkeley by
652131Smckusick  * Ralph Campbell.
752131Smckusick  *
852131Smckusick  * %sccs.include.redist.c%
952131Smckusick  *
10*52757Sralph  *	@(#)cpu.h	7.3 (Berkeley) 02/29/92
1152131Smckusick  */
1252131Smckusick 
1352131Smckusick #ifndef _CPU_H_
1452131Smckusick #define _CPU_H_
1552131Smckusick 
1652131Smckusick #include "machConst.h"
1752131Smckusick 
1852131Smckusick /*
1952131Smckusick  * Exported definitions unique to pmax/mips cpu support.
2052131Smckusick  */
2152131Smckusick 
2252131Smckusick /*
2352131Smckusick  * definitions of cpu-dependent requirements
2452131Smckusick  * referenced in generic code
2552131Smckusick  */
2652131Smckusick #undef	COPY_SIGCODE		/* copy sigcode above user stack in exec */
2752131Smckusick 
2852131Smckusick /*
2952131Smckusick  * function vs. inline configuration;
3052131Smckusick  * these are defined to get generic functions
3152131Smckusick  * rather than inline or machine-dependent implementations
3252131Smckusick  */
3352131Smckusick #define	NEED_MINMAX		/* need {,i,l,ul}{min,max} functions */
3452131Smckusick #undef	NEED_FFS		/* don't need ffs function */
3552131Smckusick #undef	NEED_BCMP		/* don't need bcmp function */
3652131Smckusick #undef	NEED_STRLEN		/* don't need strlen function */
3752131Smckusick 
3852744Sralph #define	cpu_exec(p)	(p->p_md.md_ss_addr = 0) /* init single step */
3952131Smckusick #define	cpu_wait(p)	/* nothing */
40*52757Sralph #define cpu_setstack(p, ap) \
41*52757Sralph 	(p)->p_md.md_regs[SP] = ap
4252131Smckusick 
4352131Smckusick /*
4452131Smckusick  * Arguments to hardclock, softclock and gatherstats
4552131Smckusick  * encapsulate the previous machine state in an opaque
4652131Smckusick  * clockframe;
4752131Smckusick  */
4852131Smckusick typedef struct intrframe {
4952131Smckusick 	int	pc;
5052131Smckusick 	int	ps;
5152131Smckusick } clockframe;
5252131Smckusick 
5352131Smckusick #define	CLKF_USERMODE(framep)	((framep)->ps & MACH_SR_KU_PREV)
5452131Smckusick #define	CLKF_BASEPRI(framep)	\
5552131Smckusick 	(((framep)->ps & (MACH_INT_MASK | MACH_SR_INT_ENA_PREV)) == \
5652131Smckusick 	(MACH_INT_MASK | MACH_SR_INT_ENA_PREV))
5752131Smckusick #define	CLKF_PC(framep)		((framep)->pc)
5852131Smckusick 
5952131Smckusick /*
6052131Smckusick  * Preempt the current process if in interrupt from user mode,
6152131Smckusick  * or after the current trap/syscall if in system mode.
6252131Smckusick  */
6352131Smckusick #define	need_resched()	{ want_resched = 1; aston(); }
6452131Smckusick 
6552131Smckusick /*
6652131Smckusick  * Give a profiling tick to the current process from the softclock
6752131Smckusick  * interrupt.
6852131Smckusick  */
6952131Smckusick #define	profile_tick(p, framep) \
7052131Smckusick 	addupc((framep)->pc, &p->p_stats->p_prof, 1);
7152131Smckusick 
7252131Smckusick /*
7352131Smckusick  * Notify the current process (p) that it has a signal pending,
7452131Smckusick  * process as soon as possible.
7552131Smckusick  */
7652131Smckusick #define	signotify(p)	aston()
7752131Smckusick 
7852131Smckusick #define aston()		(astpending = 1)
7952131Smckusick 
8052131Smckusick int	astpending;	/* need to trap before returning to user mode */
8152131Smckusick int	want_resched;	/* resched() was called */
8252131Smckusick 
8352131Smckusick /*
8452131Smckusick  * CPU identification, from PRID register.
8552131Smckusick  */
8652131Smckusick union cpuprid {
8752131Smckusick 	int	cpuprid;
8852131Smckusick 	struct {
8952131Smckusick #if BYTE_ORDER == BIG_ENDIAN
9052131Smckusick 		u_int	pad1:16;	/* reserved */
9152131Smckusick 		u_int	cp_imp:8;	/* implementation identifier */
9252131Smckusick 		u_int	cp_majrev:4;	/* major revision identifier */
9352131Smckusick 		u_int	cp_minrev:4;	/* minor revision identifier */
9452131Smckusick #else
9552131Smckusick 		u_int	cp_minrev:4;	/* minor revision identifier */
9652131Smckusick 		u_int	cp_majrev:4;	/* major revision identifier */
9752131Smckusick 		u_int	cp_imp:8;	/* implementation identifier */
9852131Smckusick 		u_int	pad1:16;	/* reserved */
9952131Smckusick #endif
10052131Smckusick 	} cpu;
10152131Smckusick };
10252131Smckusick 
10352131Smckusick /*
10452131Smckusick  * MIPS CPU types (cp_imp).
10552131Smckusick  */
10652744Sralph #define	MIPS_R2000	0x02
10752744Sralph #define	MIPS_R3000	0x03
10852744Sralph #define	MIPS_R4000	0x04
10952131Smckusick 
11052131Smckusick /*
11152131Smckusick  * MIPS FPU types
11252131Smckusick  */
11352744Sralph #define	MIPS_R2010	0x03
11452744Sralph #define	MIPS_R3010	0x04
11552744Sralph #define	MIPS_R4010	0x05
11652131Smckusick 
11752744Sralph struct intr_tab {
11852744Sralph 	void	(*func)();	/* pointer to interrupt routine */
11952744Sralph 	int	unit;		/* logical unit number */
12052744Sralph };
12152744Sralph 
12252131Smckusick #ifdef KERNEL
12352131Smckusick union	cpuprid cpu;
12452131Smckusick union	cpuprid fpu;
12552131Smckusick u_int	machDataCacheSize;
12652131Smckusick u_int	machInstCacheSize;
12752744Sralph extern	struct intr_tab intr_tab[];
12852131Smckusick #endif
12952131Smckusick 
13052131Smckusick /*
13152131Smckusick  * Enable realtime clock (always enabled).
13252131Smckusick  */
13352131Smckusick #define	enablertclock()
13452131Smckusick 
13552131Smckusick #endif /* _CPU_H_ */
136