xref: /csrg-svn/sys/news3400/include/cpu.h (revision 57181)
153899Smckusick /*
253899Smckusick  * Copyright (c) 1992 Regents of the University of California.
353899Smckusick  * All rights reserved.
453899Smckusick  *
553899Smckusick  * This code is derived from software contributed to Berkeley by
653899Smckusick  * Ralph Campbell and Kazumasa Utashiro of Software Research
753899Smckusick  * Associates, Inc.
853899Smckusick  *
953899Smckusick  * %sccs.include.redist.c%
1053899Smckusick  *
11*57181Sutashiro  *	@(#)cpu.h	7.3 (Berkeley) 12/17/92
1253899Smckusick  */
1353899Smckusick 
1453899Smckusick #ifndef _CPU_H_
1553899Smckusick #define _CPU_H_
1653899Smckusick 
17*57181Sutashiro #include <machine/machConst.h>
1853899Smckusick 
1953899Smckusick /*
2053899Smckusick  * Exported definitions unique to pmax/mips cpu support.
2153899Smckusick  */
2253899Smckusick 
2353899Smckusick /*
2453899Smckusick  * definitions of cpu-dependent requirements
2553899Smckusick  * referenced in generic code
2653899Smckusick  */
2753899Smckusick #undef	COPY_SIGCODE		/* copy sigcode above user stack in exec */
2853899Smckusick 
2953899Smckusick #define	cpu_exec(p)	(p->p_md.md_ss_addr = 0) /* init single step */
3053899Smckusick #define	cpu_wait(p)	/* nothing */
3153899Smckusick #define cpu_setstack(p, ap) \
3253899Smckusick 	(p)->p_md.md_regs[SP] = ap
3353899Smckusick 
3453899Smckusick /*
3555765Sbostic  * Arguments to hardclock and gatherstats encapsulate the previous
3655765Sbostic  * machine state in an opaque clockframe.
3753899Smckusick  */
3855765Sbostic struct clockframe {
3955765Sbostic 	int	pc;	/* program counter at time of interrupt */
4055765Sbostic 	int	sr;	/* status register at time of interrupt */
4155765Sbostic };
4253899Smckusick 
4355765Sbostic #define	CLKF_USERMODE(framep)	((framep)->sr & MACH_SR_KU_PREV)
4453899Smckusick #define	CLKF_BASEPRI(framep)	\
4555765Sbostic 	((~(framep)->sr & (MACH_INT_MASK | MACH_SR_INT_ENA_PREV)) == 0)
4653899Smckusick #define	CLKF_PC(framep)		((framep)->pc)
4755765Sbostic #define	CLKF_INTR(framep)	(0)
4853899Smckusick 
4953899Smckusick /*
5053899Smckusick  * Preempt the current process if in interrupt from user mode,
5153899Smckusick  * or after the current trap/syscall if in system mode.
5253899Smckusick  */
5353899Smckusick #define	need_resched()	{ want_resched = 1; aston(); }
5453899Smckusick 
5553899Smckusick /*
5655765Sbostic  * Give a profiling tick to the current process when the user profiling
5755765Sbostic  * buffer pages are invalid.  On the PMAX, request an ast to send us
5855765Sbostic  * through trap, marking the proc as needing a profiling tick.
5953899Smckusick  */
6055765Sbostic #define	need_proftick(p)	{ (p)->p_flag |= SOWEUPC; aston(); }
6153899Smckusick 
6253899Smckusick /*
6353899Smckusick  * Notify the current process (p) that it has a signal pending,
6453899Smckusick  * process as soon as possible.
6553899Smckusick  */
6653899Smckusick #define	signotify(p)	aston()
6753899Smckusick 
6853899Smckusick #define aston()		(astpending = 1)
6953899Smckusick 
7053899Smckusick int	astpending;	/* need to trap before returning to user mode */
7153899Smckusick int	want_resched;	/* resched() was called */
7253899Smckusick 
7353899Smckusick /*
7453899Smckusick  * CPU identification, from PRID register.
7553899Smckusick  */
7653899Smckusick union cpuprid {
7753899Smckusick 	int	cpuprid;
7853899Smckusick 	struct {
7953899Smckusick #if BYTE_ORDER == BIG_ENDIAN
8053899Smckusick 		u_int	pad1:16;	/* reserved */
8153899Smckusick 		u_int	cp_imp:8;	/* implementation identifier */
8253899Smckusick 		u_int	cp_majrev:4;	/* major revision identifier */
8353899Smckusick 		u_int	cp_minrev:4;	/* minor revision identifier */
8453899Smckusick #else
8553899Smckusick 		u_int	cp_minrev:4;	/* minor revision identifier */
8653899Smckusick 		u_int	cp_majrev:4;	/* major revision identifier */
8753899Smckusick 		u_int	cp_imp:8;	/* implementation identifier */
8853899Smckusick 		u_int	pad1:16;	/* reserved */
8953899Smckusick #endif
9053899Smckusick 	} cpu;
9153899Smckusick };
9253899Smckusick 
9353899Smckusick /*
9453899Smckusick  * MIPS CPU types (cp_imp).
9553899Smckusick  */
9653899Smckusick #define	MIPS_R2000	0x01
9753899Smckusick #define	MIPS_R3000	0x02
9853899Smckusick #define	MIPS_R6000	0x03
9953899Smckusick #define	MIPS_R4000	0x04
10053899Smckusick #define	MIPS_R6000A	0x06
10153899Smckusick 
10253899Smckusick /*
10353899Smckusick  * MIPS FPU types
10453899Smckusick  */
10553899Smckusick #define	MIPS_R2010_FPU	0x02
10653899Smckusick #define	MIPS_R3010_FPU	0x03
10753899Smckusick #define	MIPS_R6010_FPU	0x04
10853899Smckusick #define	MIPS_R4000_FPU	0x05
10953899Smckusick 
11053899Smckusick struct intr_tab {
11153899Smckusick 	void	(*func)();	/* pointer to interrupt routine */
11253899Smckusick 	int	unit;		/* logical unit number */
11353899Smckusick };
11453899Smckusick 
11553899Smckusick #ifdef KERNEL
11653899Smckusick union	cpuprid cpu;
11753899Smckusick union	cpuprid fpu;
11853899Smckusick u_int	machDataCacheSize;
11953899Smckusick u_int	machInstCacheSize;
12053899Smckusick extern	struct intr_tab intr_tab[];
12153899Smckusick #endif
12253899Smckusick 
12353899Smckusick #endif /* _CPU_H_ */
124