cpu.h revision 3488
1107207Snectar/*-
2102644Snectar * Copyright (c) 1990 The Regents of the University of California.
355682Smarkm * All rights reserved.
4102644Snectar *
578527Sassar * This code is derived from software contributed to Berkeley by
655682Smarkm * William Jolitz.
755682Smarkm *
855682Smarkm * Redistribution and use in source and binary forms, with or without
955682Smarkm * modification, are permitted provided that the following conditions
1055682Smarkm * are met:
1155682Smarkm * 1. Redistributions of source code must retain the above copyright
1255682Smarkm *    notice, this list of conditions and the following disclaimer.
1355682Smarkm * 2. Redistributions in binary form must reproduce the above copyright
1455682Smarkm *    notice, this list of conditions and the following disclaimer in the
1590926Snectar *    documentation and/or other materials provided with the distribution.
1690926Snectar * 3. All advertising materials mentioning features or use of this software
1790926Snectar *    must display the following acknowledgement:
1890926Snectar *	This product includes software developed by the University of
19102644Snectar *	California, Berkeley and its contributors.
2090926Snectar * 4. Neither the name of the University nor the names of its contributors
21120945Snectar *    may be used to endorse or promote products derived from this software
2255682Smarkm *    without specific prior written permission.
2355682Smarkm *
2455682Smarkm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2555682Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2655682Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2755682Smarkm * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2855682Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2955682Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3055682Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3155682Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3255682Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3355682Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3455682Smarkm * SUCH DAMAGE.
3555682Smarkm *
3655682Smarkm *	from: @(#)cpu.h	5.4 (Berkeley) 5/9/91
3755682Smarkm *	$Id: cpu.h,v 1.12 1994/10/08 22:21:32 phk Exp $
3855682Smarkm */
3955682Smarkm
4055682Smarkm#ifndef _MACHINE_CPU_H_
4155682Smarkm#define	_MACHINE_CPU_H_
4255682Smarkm
4355682Smarkm/*
4455682Smarkm * Definitions unique to i386 cpu support.
4555682Smarkm */
4655682Smarkm#include <machine/frame.h>
4755682Smarkm#include <machine/segments.h>
4855682Smarkm
4955682Smarkm/*
5055682Smarkm * definitions of cpu-dependent requirements
5155682Smarkm * referenced in generic code
52102644Snectar */
5355682Smarkm#undef	COPY_SIGCODE		/* don't copy sigcode above user stack in exec */
5472445Sassar
5555682Smarkm#define	cpu_exec(p)	/* nothing */
56102644Snectar#define cpu_swapin(p)	/* nothing */
57102644Snectar#define cpu_setstack(p, ap)		(p)->p_md.md_regs = ap
5855682Smarkm#define cpu_set_init_frame(p, fp)	(p)->p_md.md_regs = fp
5990926Snectar
6055682Smarkm#define	CLKF_USERMODE(framep)	(ISPL((framep)->cf_cs) == SEL_UPL)
6155682Smarkm#define CLKF_INTR(framep)	(0)
6255682Smarkm#define	CLKF_BASEPRI(framep)	(((framep)->cf_ppl & ~SWI_AST_MASK) == 0)
6355682Smarkm#define	CLKF_PC(framep)		((framep)->cf_eip)
6455682Smarkm
6555682Smarkm/*
6655682Smarkm * Preempt the current process if in interrupt from user mode,
6755682Smarkm * or after the current trap/syscall if in system mode.
6855682Smarkm */
69102644Snectar#define	need_resched()	{ want_resched = 1; aston(); }
70102644Snectar
71102644Snectar/*
72102644Snectar * Give a profiling tick to the current process from the softclock
7355682Smarkm * interrupt.  On tahoe, request an ast to send us through trap(),
7472445Sassar * marking the proc as needing a profiling tick.
7572445Sassar */
7655682Smarkm#define	need_proftick(p)	{ (p)->p_flag |= P_OWEUPC; aston(); }
7755682Smarkm
7855682Smarkm/*
7955682Smarkm * Notify the current process (p) that it has a signal pending,
8055682Smarkm * process as soon as possible.
8190926Snectar */
8272445Sassar#define	signotify(p)	aston()
8355682Smarkm
8472445Sassar#define aston()	setsoftast()
8590926Snectar#define astoff()
8672445Sassar
8772445Sassar/*
8872445Sassar * pull in #defines for kinds of processors
89102644Snectar */
9055682Smarkm#include <machine/cputypes.h>
9155682Smarkm
9272445Sassarstruct cpu_nameclass {
9355682Smarkm	char *cpu_name;
9490926Snectar	int  cpu_class;
9590926Snectar};
9655682Smarkm
97102644Snectar/*
98102644Snectar * CTL_MACHDEP definitions.
99102644Snectar */
10055682Smarkm#define CPU_CONSDEV		1	/* dev_t: console terminal device */
10155682Smarkm#define	CPU_ADJKERNTZ		2	/* int:	timezone offset	for resettodr()	*/
10255682Smarkm#define	CPU_DISRTCSET		3	/* int:	disable	resettodr() call */
10390926Snectar#define	CPU_MAXID		4	/* number of valid machdep ids */
10490926Snectar
10590926Snectar#define CTL_MACHDEP_NAMES { \
10690926Snectar	{ 0, 0 }, \
10772445Sassar	{ "console_device", CTLTYPE_STRUCT }, \
10890926Snectar	{ "adjkerntz", CTLTYPE_INT }, \
10972445Sassar	{ "disable_rtc_set", CTLTYPE_INT }, \
11090926Snectar}
11155682Smarkm
11255682Smarkm#ifdef KERNEL
11355682Smarkmextern int want_resched;	/* resched was called */
11455682Smarkm
11555682Smarkmextern int cpu;
11655682Smarkmextern int cpu_class;
117120945Snectarextern struct cpu_nameclass i386_cpus[];
11855682Smarkmint	cpu_fork __P((struct proc *, struct proc *));
11955682Smarkmint	npxdna __P((void));
12055682Smarkmvoid	npxexit __P((struct proc *p));
12172445Sassarvoid	resettodr __P((void));
12255682Smarkm#endif
12355682Smarkm
124102644Snectar#endif /* !_MACHINE_CPU_H_ */
12555682Smarkm