xref: /csrg-svn/sys/i386/include/cpu.h (revision 63359)
141059Swilliam /*-
2*63359Sbostic  * Copyright (c) 1990, 1993
3*63359Sbostic  *	The Regents of the University of California.  All rights reserved.
440453Sbill  *
541059Swilliam  * This code is derived from software contributed to Berkeley by
641059Swilliam  * William Jolitz.
741059Swilliam  *
846006Swilliam  * %sccs.include.redist.c%
941059Swilliam  *
10*63359Sbostic  *	@(#)cpu.h	8.1 (Berkeley) 06/11/93
1140453Sbill  */
1240453Sbill 
1349244Skarels /*
1449244Skarels  * Definitions unique to i386 cpu support.
1549244Skarels  */
1656512Sbostic #include <machine/frame.h>
1756512Sbostic #include <machine/segments.h>
1849244Skarels 
1949244Skarels /*
2049244Skarels  * definitions of cpu-dependent requirements
2149244Skarels  * referenced in generic code
2249244Skarels  */
2349523Swilliam #undef	COPY_SIGCODE		/* don't copy sigcode above user stack in exec */
2449244Skarels 
2549244Skarels /*
2649244Skarels  * function vs. inline configuration;
2749244Skarels  * these are defined to get generic functions
2849244Skarels  * rather than inline or machine-dependent implementations
2949244Skarels  */
3049244Skarels #define	NEED_MINMAX		/* need {,i,l,ul}{min,max} functions */
3149523Swilliam #define	NEED_FFS		/* need ffs function */
3249523Swilliam #define	NEED_BCMP		/* need bcmp function */
3349523Swilliam #define	NEED_STRLEN		/* need strlen function */
3449244Skarels 
3549244Skarels #define	cpu_exec(p)	/* nothing */
3652379Smckusick #define cpu_setstack(p, ap) \
3752379Smckusick 	(p)->p_md.md_regs[SP] = ap
3849244Skarels 
3949244Skarels /*
4049244Skarels  * Arguments to hardclock, softclock and gatherstats
4149244Skarels  * encapsulate the previous machine state in an opaque
4249244Skarels  * clockframe; for now, use generic intrframe.
4349244Skarels  */
4463171Scgd struct clockframe {
4563171Scgd 	struct intrframe	cf_if;
4663171Scgd };
4749244Skarels 
4863171Scgd #define	CLKF_USERMODE(framep)	(ISPL((framep)->cf_if.if_cs) == SEL_UPL)
4963171Scgd #define	CLKF_BASEPRI(framep)	((framep)->cf_if.if_ppl == 0)
5063171Scgd #define	CLKF_PC(framep)		((framep)->cf_if.if_eip)
5149244Skarels 
5240453Sbill #define	resettodr()	/* no todr to set */
5340453Sbill 
5449244Skarels /*
5549244Skarels  * Preempt the current process if in interrupt from user mode,
5649244Skarels  * or after the current trap/syscall if in system mode.
5749244Skarels  */
5849244Skarels #define	need_resched()	{ want_resched++; aston(); }
5949244Skarels 
6049244Skarels /*
6149244Skarels  * Give a profiling tick to the current process from the softclock
6249244Skarels  * interrupt.  On tahoe, request an ast to send us through trap(),
6349244Skarels  * marking the proc as needing a profiling tick.
6449244Skarels  */
6549244Skarels #define	profile_tick(p, framep)	{ (p)->p_flag |= SOWEUPC; aston(); }
6649244Skarels 
6749244Skarels /*
6849244Skarels  * Notify the current process (p) that it has a signal pending,
6949244Skarels  * process as soon as possible.
7049244Skarels  */
7149244Skarels #define	signotify(p)	aston()
7249244Skarels 
7349244Skarels #define aston() (astpending++)
7449244Skarels 
7549244Skarels int	astpending;		/* need to trap before returning to user mode */
7649244Skarels int	want_resched;		/* resched() was called */
7749244Skarels 
7849244Skarels /*
7949244Skarels  * Kinds of processor
8049244Skarels  */
8149244Skarels 
8249244Skarels #define	CPU_386SX	0
8349244Skarels #define	CPU_386		1
8449244Skarels #define	CPU_486SX	2
8549244Skarels #define	CPU_486		3
8649244Skarels #define	CPU_586		4
8760205Smckusick 
8860205Smckusick /*
8960205Smckusick  * CTL_MACHDEP definitions.
9060205Smckusick  */
9160205Smckusick #define	CPU_CONSDEV		1	/* dev_t: console terminal device */
9260205Smckusick #define	CPU_MAXID		2	/* number of valid machdep ids */
9360205Smckusick 
9460205Smckusick #define CTL_MACHDEP_NAMES { \
9560205Smckusick 	{ 0, 0 }, \
9660205Smckusick 	{ "console_device", CTLTYPE_STRUCT }, \
9760205Smckusick }
98