xref: /csrg-svn/sys/news3400/include/cpu.h (revision 65500)
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*65500Smckusick  *	@(#)cpu.h	7.6 (Berkeley) 01/05/94
1253899Smckusick  */
1353899Smckusick 
1453899Smckusick #ifndef _CPU_H_
1553899Smckusick #define _CPU_H_
1653899Smckusick 
1757181Sutashiro #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  */
2757604Sutashiro #define	COPY_SIGCODE		/* copy sigcode above user stack in exec */
2853899Smckusick 
2965074Smckusick #define	cpu_exec(p)		(p->p_md.md_ss_addr = 0) /* init single step */
30*65500Smckusick #define	cpu_swapin(p)		/* nothing */
3165074Smckusick #define	cpu_wait(p)		/* nothing */
3265074Smckusick #define cpu_setstack(p, ap)	(p)->p_md.md_regs[SP] = ap
3365074Smckusick #define cpu_set_init_frame(p, fp) (p)->p_md.md_regs = fp
3453899Smckusick 
3553899Smckusick /*
3655765Sbostic  * Arguments to hardclock and gatherstats encapsulate the previous
3755765Sbostic  * machine state in an opaque clockframe.
3853899Smckusick  */
3955765Sbostic struct clockframe {
4055765Sbostic 	int	pc;	/* program counter at time of interrupt */
4155765Sbostic 	int	sr;	/* status register at time of interrupt */
4255765Sbostic };
4353899Smckusick 
4455765Sbostic #define	CLKF_USERMODE(framep)	((framep)->sr & MACH_SR_KU_PREV)
4553899Smckusick #define	CLKF_BASEPRI(framep)	\
4655765Sbostic 	((~(framep)->sr & (MACH_INT_MASK | MACH_SR_INT_ENA_PREV)) == 0)
4753899Smckusick #define	CLKF_PC(framep)		((framep)->pc)
4855765Sbostic #define	CLKF_INTR(framep)	(0)
4953899Smckusick 
5053899Smckusick /*
5153899Smckusick  * Preempt the current process if in interrupt from user mode,
5253899Smckusick  * or after the current trap/syscall if in system mode.
5353899Smckusick  */
5453899Smckusick #define	need_resched()	{ want_resched = 1; aston(); }
5553899Smckusick 
5653899Smckusick /*
5755765Sbostic  * Give a profiling tick to the current process when the user profiling
5855765Sbostic  * buffer pages are invalid.  On the PMAX, request an ast to send us
5955765Sbostic  * through trap, marking the proc as needing a profiling tick.
6053899Smckusick  */
6155765Sbostic #define	need_proftick(p)	{ (p)->p_flag |= SOWEUPC; aston(); }
6253899Smckusick 
6353899Smckusick /*
6453899Smckusick  * Notify the current process (p) that it has a signal pending,
6553899Smckusick  * process as soon as possible.
6653899Smckusick  */
6753899Smckusick #define	signotify(p)	aston()
6853899Smckusick 
6953899Smckusick #define aston()		(astpending = 1)
7053899Smckusick 
7153899Smckusick int	astpending;	/* need to trap before returning to user mode */
7253899Smckusick int	want_resched;	/* resched() was called */
7353899Smckusick 
7453899Smckusick /*
7553899Smckusick  * CPU identification, from PRID register.
7653899Smckusick  */
7753899Smckusick union cpuprid {
7853899Smckusick 	int	cpuprid;
7953899Smckusick 	struct {
8053899Smckusick #if BYTE_ORDER == BIG_ENDIAN
8153899Smckusick 		u_int	pad1:16;	/* reserved */
8253899Smckusick 		u_int	cp_imp:8;	/* implementation identifier */
8353899Smckusick 		u_int	cp_majrev:4;	/* major revision identifier */
8453899Smckusick 		u_int	cp_minrev:4;	/* minor revision identifier */
8553899Smckusick #else
8653899Smckusick 		u_int	cp_minrev:4;	/* minor revision identifier */
8753899Smckusick 		u_int	cp_majrev:4;	/* major revision identifier */
8853899Smckusick 		u_int	cp_imp:8;	/* implementation identifier */
8953899Smckusick 		u_int	pad1:16;	/* reserved */
9053899Smckusick #endif
9153899Smckusick 	} cpu;
9253899Smckusick };
9353899Smckusick 
9453899Smckusick /*
9553899Smckusick  * MIPS CPU types (cp_imp).
9653899Smckusick  */
9753899Smckusick #define	MIPS_R2000	0x01
9853899Smckusick #define	MIPS_R3000	0x02
9953899Smckusick #define	MIPS_R6000	0x03
10053899Smckusick #define	MIPS_R4000	0x04
10153899Smckusick #define	MIPS_R6000A	0x06
10253899Smckusick 
10353899Smckusick /*
10453899Smckusick  * MIPS FPU types
10553899Smckusick  */
10653899Smckusick #define	MIPS_R2010_FPU	0x02
10753899Smckusick #define	MIPS_R3010_FPU	0x03
10853899Smckusick #define	MIPS_R6010_FPU	0x04
10953899Smckusick #define	MIPS_R4000_FPU	0x05
11053899Smckusick 
11153899Smckusick struct intr_tab {
11253899Smckusick 	void	(*func)();	/* pointer to interrupt routine */
11353899Smckusick 	int	unit;		/* logical unit number */
11453899Smckusick };
11553899Smckusick 
11653899Smckusick #ifdef KERNEL
11753899Smckusick union	cpuprid cpu;
11853899Smckusick union	cpuprid fpu;
11953899Smckusick u_int	machDataCacheSize;
12053899Smckusick u_int	machInstCacheSize;
12153899Smckusick extern	struct intr_tab intr_tab[];
12253899Smckusick #endif
12353899Smckusick 
12453899Smckusick #endif /* _CPU_H_ */
125