xref: /csrg-svn/sys/i386/include/cpu.h (revision 56512)
141059Swilliam /*-
241059Swilliam  * Copyright (c) 1990 The Regents of the University of California.
341059Swilliam  * 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*56512Sbostic  *	@(#)cpu.h	5.6 (Berkeley) 10/11/92
1140453Sbill  */
1240453Sbill 
1349244Skarels /*
1449244Skarels  * Definitions unique to i386 cpu support.
1549244Skarels  */
16*56512Sbostic #include <machine/frame.h>
17*56512Sbostic #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  */
4449244Skarels typedef struct intrframe clockframe;
4549244Skarels 
4649244Skarels #define	CLKF_USERMODE(framep)	(ISPL((framep)->if_cs) == SEL_UPL)
4749244Skarels #define	CLKF_BASEPRI(framep)	((framep)->if_ppl == 0)
4849244Skarels #define	CLKF_PC(framep)		((framep)->if_eip)
4949244Skarels 
5040453Sbill #define	resettodr()	/* no todr to set */
5140453Sbill 
5249244Skarels /*
5349244Skarels  * Preempt the current process if in interrupt from user mode,
5449244Skarels  * or after the current trap/syscall if in system mode.
5549244Skarels  */
5649244Skarels #define	need_resched()	{ want_resched++; aston(); }
5749244Skarels 
5849244Skarels /*
5949244Skarels  * Give a profiling tick to the current process from the softclock
6049244Skarels  * interrupt.  On tahoe, request an ast to send us through trap(),
6149244Skarels  * marking the proc as needing a profiling tick.
6249244Skarels  */
6349244Skarels #define	profile_tick(p, framep)	{ (p)->p_flag |= SOWEUPC; aston(); }
6449244Skarels 
6549244Skarels /*
6649244Skarels  * Notify the current process (p) that it has a signal pending,
6749244Skarels  * process as soon as possible.
6849244Skarels  */
6949244Skarels #define	signotify(p)	aston()
7049244Skarels 
7149244Skarels #define aston() (astpending++)
7249244Skarels 
7349244Skarels int	astpending;		/* need to trap before returning to user mode */
7449244Skarels int	want_resched;		/* resched() was called */
7549244Skarels 
7649244Skarels /*
7749244Skarels  * Kinds of processor
7849244Skarels  */
7949244Skarels 
8049244Skarels #define	CPU_386SX	0
8149244Skarels #define	CPU_386		1
8249244Skarels #define	CPU_486SX	2
8349244Skarels #define	CPU_486		3
8449244Skarels #define	CPU_586		4
85