cpu.h revision 2819
152942Sbrian/*-
252942Sbrian * Copyright (c) 1990 The Regents of the University of California.
352942Sbrian * All rights reserved.
452942Sbrian *
552942Sbrian * This code is derived from software contributed to Berkeley by
652942Sbrian * William Jolitz.
752942Sbrian *
852942Sbrian * Redistribution and use in source and binary forms, with or without
952942Sbrian * modification, are permitted provided that the following conditions
1052942Sbrian * are met:
1152942Sbrian * 1. Redistributions of source code must retain the above copyright
1252942Sbrian *    notice, this list of conditions and the following disclaimer.
1352942Sbrian * 2. Redistributions in binary form must reproduce the above copyright
1452942Sbrian *    notice, this list of conditions and the following disclaimer in the
1552942Sbrian *    documentation and/or other materials provided with the distribution.
1652942Sbrian * 3. All advertising materials mentioning features or use of this software
1752942Sbrian *    must display the following acknowledgement:
1852942Sbrian *	This product includes software developed by the University of
1952942Sbrian *	California, Berkeley and its contributors.
2052942Sbrian * 4. Neither the name of the University nor the names of its contributors
2152942Sbrian *    may be used to endorse or promote products derived from this software
2252942Sbrian *    without specific prior written permission.
2352942Sbrian *
2452942Sbrian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2552942Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2652942Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2752942Sbrian * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2852942Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2952942Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3052942Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3152942Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3252942Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3352942Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3452942Sbrian * SUCH DAMAGE.
3552942Sbrian *
3652942Sbrian *	from: @(#)cpu.h	5.4 (Berkeley) 5/9/91
3752942Sbrian *	$Id: cpu.h,v 1.7 1994/08/13 03:49:48 wollman Exp $
3852942Sbrian */
3952942Sbrian
4052942Sbrian#ifndef _MACHINE_CPU_H_
4152942Sbrian#define _MACHINE_CPU_H_ 1
4252942Sbrian
4352942Sbrian/*
4452942Sbrian * Definitions unique to i386 cpu support.
4552942Sbrian */
4652942Sbrian#include <machine/frame.h>
4752942Sbrian#include <machine/segments.h>
4852942Sbrian#include <machine/spl.h>
4952942Sbrian
5052942Sbrian/*
5152942Sbrian * definitions of cpu-dependent requirements
5253241Sbrian * referenced in generic code
5352942Sbrian */
5452942Sbrian#undef	COPY_SIGCODE		/* don't copy sigcode above user stack in exec */
5552942Sbrian
5652942Sbrian#define	cpu_exec(p)	/* nothing */
5752942Sbrian#define cpu_swapin(p)	/* nothing */
5852942Sbrian#define cpu_setstack(p, ap)		(p)->p_md.md_regs = ap
5952942Sbrian#define cpu_set_init_frame(p, fp)	(p)->p_md.md_regs = fp
6052942Sbrian
6152942Sbrian#define	CLKF_USERMODE(framep)	(ISPL((framep)->cf_cs) == SEL_UPL)
6252942Sbrian#define CLKF_INTR(framep)	(0)
6352942Sbrian#define	CLKF_BASEPRI(framep)	(((framep)->cf_ppl & ~SWI_AST_MASK) == 0)
6452942Sbrian#define	CLKF_PC(framep)		((framep)->cf_eip)
6552942Sbrian
6652942Sbrian#define resettodr()	/* no todr to set */
6752942Sbrian
6852942Sbrian/*
6952942Sbrian * Preempt the current process if in interrupt from user mode,
7052942Sbrian * or after the current trap/syscall if in system mode.
7152942Sbrian */
7252942Sbrian#define	need_resched()	{ want_resched = 1; aston(); }
7352942Sbrian
7452942Sbrian/*
7552942Sbrian * Give a profiling tick to the current process from the softclock
7652942Sbrian * interrupt.  On tahoe, request an ast to send us through trap(),
7752942Sbrian * marking the proc as needing a profiling tick.
7852942Sbrian */
7952942Sbrian#define	need_proftick(p)	{ (p)->p_flag |= P_OWEUPC; aston(); }
8052942Sbrian
8152942Sbrian/*
8252942Sbrian * Notify the current process (p) that it has a signal pending,
8352942Sbrian * process as soon as possible.
8452942Sbrian */
8552942Sbrian#define	signotify(p)	aston()
8652942Sbrian
8752942Sbrian#define aston()	setsoftast()
8852942Sbrian#define astoff()
8952942Sbrian
9052942Sbrian/*
9152942Sbrian * pull in #defines for kinds of processors
9252942Sbrian */
9352942Sbrian#include "machine/cputypes.h"
9452942Sbrian
9552942Sbrianstruct cpu_nameclass {
9652942Sbrian	char *cpu_name;
9752942Sbrian	int  cpu_class;
9852942Sbrian};
9952942Sbrian
10052942Sbrian/*
10152942Sbrian * CTL_MACHDEP definitions.
10252942Sbrian */
10352942Sbrian#define CPU_CONSDEV		1	/* dev_t: console terminal device */
10452942Sbrian#define	CPU_ADJKERNTZ		2	/* int:	timezone offset	for resettodr()	*/
10552942Sbrian#define	CPU_MAXID		3	/* number of valid machdep ids */
10652942Sbrian
10752942Sbrian#define CTL_MACHDEP_NAMES { \
10852942Sbrian	{ 0, 0 }, \
10952942Sbrian	{ "console_device", CTLTYPE_STRUCT }, \
11052942Sbrian	{ "adjkerntz", CTLTYPE_INT }, \
11152942Sbrian}
11252942Sbrian
11352942Sbrian#ifdef KERNEL
11452942Sbrianextern int want_resched;	/* resched was called */
11552942Sbrian
11652942Sbrianextern int cpu;
11752942Sbrianextern int cpu_class;
11852942Sbrianextern struct cpu_nameclass i386_cpus[];
11952942Sbrian#endif
12052942Sbrian#endif /* _MACHINE_CPU_H_ */
12152942Sbrian