cpu.h revision 43524
11590Srgrimes/*-
21590Srgrimes * Copyright (c) 1990 The Regents of the University of California.
31590Srgrimes * All rights reserved.
41590Srgrimes *
51590Srgrimes * This code is derived from software contributed to Berkeley by
61590Srgrimes * William Jolitz.
71590Srgrimes *
81590Srgrimes * Redistribution and use in source and binary forms, with or without
91590Srgrimes * modification, are permitted provided that the following conditions
101590Srgrimes * are met:
111590Srgrimes * 1. Redistributions of source code must retain the above copyright
121590Srgrimes *    notice, this list of conditions and the following disclaimer.
131590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
141590Srgrimes *    notice, this list of conditions and the following disclaimer in the
151590Srgrimes *    documentation and/or other materials provided with the distribution.
161590Srgrimes * 3. All advertising materials mentioning features or use of this software
171590Srgrimes *    must display the following acknowledgement:
181590Srgrimes *	This product includes software developed by the University of
191590Srgrimes *	California, Berkeley and its contributors.
201590Srgrimes * 4. Neither the name of the University nor the names of its contributors
211590Srgrimes *    may be used to endorse or promote products derived from this software
221590Srgrimes *    without specific prior written permission.
231590Srgrimes *
241590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271590Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2950477Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31132277Stjr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341590Srgrimes * SUCH DAMAGE.
351590Srgrimes *
361590Srgrimes *	from: @(#)cpu.h	5.4 (Berkeley) 5/9/91
371590Srgrimes *	$Id: cpu.h,v 1.37 1999/01/29 08:36:43 dillon Exp $
3827623Scharnier */
391590Srgrimes
401590Srgrimes#ifndef _MACHINE_CPU_H_
411590Srgrimes#define	_MACHINE_CPU_H_
4272432Sru
431590Srgrimes/*
4479755Sdd * Definitions unique to i386 cpu support.
4527623Scharnier */
461590Srgrimes#include <machine/psl.h>
471590Srgrimes#include <machine/frame.h>
481590Srgrimes#include <machine/segments.h>
491590Srgrimes
501590Srgrimes/*
511590Srgrimes * definitions of cpu-dependent requirements
5227623Scharnier * referenced in generic code
531590Srgrimes */
541590Srgrimes#undef	COPY_SIGCODE		/* don't copy sigcode above user stack in exec */
551590Srgrimes
561590Srgrimes#define	cpu_exec(p)	/* nothing */
571590Srgrimes#define cpu_swapin(p)	/* nothing */
581590Srgrimes#define cpu_setstack(p, ap)		((p)->p_md.md_regs[SP] = (ap))
591590Srgrimes#define cpu_set_init_frame(p, fp)	((p)->p_md.md_regs = (fp))
601590Srgrimes
611590Srgrimes#define	CLKF_USERMODE(framep) \
621590Srgrimes	((ISPL((framep)->cf_cs) == SEL_UPL) || (framep->cf_eflags & PSL_VM))
631590Srgrimes
64116112Scharnier#define CLKF_INTR(framep)	(intr_nesting_level >= 2)
65116112Scharnier#if 0
661590Srgrimes/*
67131491Sru * XXX splsoftclock() is very broken and barely worth fixing.  It doesn't
681590Srgrimes * turn off the clock bit in imen or in the icu.  (This is not a serious
691590Srgrimes * problem at 100 Hz but it is serious at 16000 Hz for pcaudio.  softclock()
701590Srgrimes * can take more than 62.5 usec so clock interrupts are lost.)  It doesn't
711590Srgrimes * check for pending interrupts being unmasked.  clkintr() and Xintr0()
72131491Sru * assume that the ipl is high when hardclock() returns.  Our SWI_AST
731590Srgrimes * handling is efficient enough that little is gained by calling
741590Srgrimes * softclock() directly.
751590Srgrimes */
761590Srgrimes#define	CLKF_BASEPRI(framep)	(((framep)->cf_ppl & ~SWI_AST_MASK) == 0)
771590Srgrimes#else
781590Srgrimes#define	CLKF_BASEPRI(framep)	(0)
79132396Stjr#endif
801590Srgrimes#define	CLKF_PC(framep)		((framep)->cf_eip)
81132396Stjr
82132396Stjr/*
83132396Stjr * Preempt the current process if in interrupt from user mode,
84132396Stjr * or after the current trap/syscall if in system mode.
8527623Scharnier */
86132396Stjr#define	need_resched()	{ want_resched = 1; aston(); }
87132396Stjr
88132396Stjr#define	resched_wanted()	want_resched
891590Srgrimes
901590Srgrimes/*
911590Srgrimes * Arrange to handle pending profiling ticks before returning to user mode.
921590Srgrimes *
931590Srgrimes * XXX this is now poorly named and implemented.  It used to handle only a
94140368Sru * single tick and the P_OWEUPC flag served as a counter.  Now there is a
95132396Stjr * counter in the proc table and flag isn't really necessary.
96132396Stjr */
97132396Stjr#define	need_proftick(p)	{ (p)->p_flag |= P_OWEUPC; aston(); }
98132396Stjr
991590Srgrimes/*
1001590Srgrimes * Notify the current process (p) that it has a signal pending,
1011590Srgrimes * process as soon as possible.
1021590Srgrimes */
1031590Srgrimes#define	signotify(p)	aston()
1041590Srgrimes
1051590Srgrimes#define aston()	setsoftast()
106132397Stjr#define astoff()
107132397Stjr
108132397Stjr/*
1091590Srgrimes * CTL_MACHDEP definitions.
11095124Scharnier */
11195124Scharnier#define CPU_CONSDEV		1	/* dev_t: console terminal device */
11295124Scharnier#define	CPU_ADJKERNTZ		2	/* int:	timezone offset	(seconds) */
11317787Smpp#define	CPU_DISRTCSET		3	/* int: disable resettodr() call */
114132277Stjr#define CPU_BOOTINFO		4	/* struct: bootinfo */
115132396Stjr#define	CPU_WALLCLOCK		5	/* int:	indicates wall CMOS clock */
116132396Stjr#define	CPU_MAXID		6	/* number of valid machdep ids */
117132393Stjr
118132393Stjr#define CTL_MACHDEP_NAMES { \
119132393Stjr	{ 0, 0 }, \
120132393Stjr	{ "console_device", CTLTYPE_STRUCT }, \
121	{ "adjkerntz", CTLTYPE_INT }, \
122	{ "disable_rtc_set", CTLTYPE_INT }, \
123	{ "bootinfo", CTLTYPE_STRUCT }, \
124	{ "wall_cmos_clock", CTLTYPE_INT }, \
125}
126
127#ifdef KERNEL
128extern char	btext[];
129extern char	etext[];
130extern u_char	intr_nesting_level;
131extern int	want_resched;	/* resched was called */
132
133void	fork_trampoline __P((void));
134void	fork_return __P((struct proc *, struct trapframe));
135void	cpu_set_fork_handler __P((struct proc *, void (*pc)(const void *), const void *));
136#endif
137
138#endif /* !_MACHINE_CPU_H_ */
139