cpu.h revision 45959
1132718Skan/*- 290075Sobrien * Copyright (c) 1990 The Regents of the University of California. 3169689Skan * All rights reserved. 4169689Skan * 590075Sobrien * This code is derived from software contributed to Berkeley by 6132718Skan * William Jolitz. 790075Sobrien * 8132718Skan * Redistribution and use in source and binary forms, with or without 990075Sobrien * modification, are permitted provided that the following conditions 1090075Sobrien * are met: 1190075Sobrien * 1. Redistributions of source code must retain the above copyright 1290075Sobrien * notice, this list of conditions and the following disclaimer. 13132718Skan * 2. Redistributions in binary form must reproduce the above copyright 1490075Sobrien * notice, this list of conditions and the following disclaimer in the 1590075Sobrien * documentation and/or other materials provided with the distribution. 1690075Sobrien * 3. All advertising materials mentioning features or use of this software 1790075Sobrien * must display the following acknowledgement: 1890075Sobrien * This product includes software developed by the University of 19132718Skan * California, Berkeley and its contributors. 20169689Skan * 4. Neither the name of the University nor the names of its contributors 21169689Skan * may be used to endorse or promote products derived from this software 2290075Sobrien * without specific prior written permission. 2390075Sobrien * 24132718Skan * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25132718Skan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2690075Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27132718Skan * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28132718Skan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29132718Skan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3090075Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31132718Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32132718Skan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33132718Skan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34132718Skan * SUCH DAMAGE. 3590075Sobrien * 36132718Skan * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 37132718Skan * $Id: cpu.h,v 1.38 1999/02/02 09:08:23 bde Exp $ 3890075Sobrien */ 3990075Sobrien 40132718Skan#ifndef _MACHINE_CPU_H_ 4190075Sobrien#define _MACHINE_CPU_H_ 42132718Skan 43132718Skan/* 44132718Skan * Definitions unique to i386 cpu support. 45132718Skan */ 46169689Skan#include <machine/psl.h> 47132718Skan#include <machine/frame.h> 48132718Skan#include <machine/segments.h> 49132718Skan 50132718Skan/* 51132718Skan * definitions of cpu-dependent requirements 5290075Sobrien * referenced in generic code 53169689Skan */ 54169689Skan#undef COPY_SIGCODE /* don't copy sigcode above user stack in exec */ 55132718Skan 5690075Sobrien#define cpu_exec(p) /* nothing */ 57132718Skan#define cpu_swapin(p) /* nothing */ 58132718Skan#define cpu_setstack(p, ap) ((p)->p_md.md_regs[SP] = (ap)) 59132718Skan#define cpu_set_init_frame(p, fp) ((p)->p_md.md_regs = (fp)) 60132718Skan 61132718Skan#define CLKF_USERMODE(framep) \ 62132718Skan ((ISPL((framep)->cf_cs) == SEL_UPL) || (framep->cf_eflags & PSL_VM)) 6390075Sobrien 64132718Skan#define CLKF_INTR(framep) (intr_nesting_level >= 2) 65132718Skan#if 0 66132718Skan/* 67132718Skan * XXX splsoftclock() is very broken and barely worth fixing. It doesn't 6890075Sobrien * turn off the clock bit in imen or in the icu. (This is not a serious 69132718Skan * problem at 100 Hz but it is serious at 16000 Hz for pcaudio. softclock() 70132718Skan * can take more than 62.5 usec so clock interrupts are lost.) It doesn't 7190075Sobrien * check for pending interrupts being unmasked. clkintr() and Xintr0() 72169689Skan * assume that the ipl is high when hardclock() returns. Our SWI_AST 73132718Skan * handling is efficient enough that little is gained by calling 74169689Skan * softclock() directly. 75169689Skan */ 76132718Skan#define CLKF_BASEPRI(framep) (((framep)->cf_ppl & ~SWI_AST_MASK) == 0) 7790075Sobrien#else 78132718Skan#define CLKF_BASEPRI(framep) (0) 79132718Skan#endif 80132718Skan#define CLKF_PC(framep) ((framep)->cf_eip) 81169689Skan 82169689Skan/* 83169689Skan * Preempt the current process if in interrupt from user mode, 84169689Skan * or after the current trap/syscall if in system mode. 85169689Skan */ 86169689Skan#define need_resched() { want_resched = 1; aston(); } 87132718Skan 88132718Skan#define resched_wanted() want_resched 89132718Skan 90132718Skan/* 91132718Skan * Arrange to handle pending profiling ticks before returning to user mode. 92169689Skan * 93169689Skan * XXX this is now poorly named and implemented. It used to handle only a 94169689Skan * single tick and the P_OWEUPC flag served as a counter. Now there is a 95169689Skan * counter in the proc table and flag isn't really necessary. 96169689Skan */ 97169689Skan#define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); } 98132718Skan 99132718Skan/* 100132718Skan * Notify the current process (p) that it has a signal pending, 101132718Skan * process as soon as possible. 102132718Skan */ 103132718Skan#define signotify(p) aston() 104132718Skan 105132718Skan#define aston() setsoftast() 106169689Skan#define astoff() 107169689Skan 108132718Skan/* 109132718Skan * CTL_MACHDEP definitions. 110132718Skan */ 111132718Skan#define CPU_CONSDEV 1 /* dev_t: console terminal device */ 112132718Skan#define CPU_ADJKERNTZ 2 /* int: timezone offset (seconds) */ 113169689Skan#define CPU_DISRTCSET 3 /* int: disable resettodr() call */ 114169689Skan#define CPU_BOOTINFO 4 /* struct: bootinfo */ 115169689Skan#define CPU_WALLCLOCK 5 /* int: indicates wall CMOS clock */ 116132718Skan#define CPU_MAXID 6 /* number of valid machdep ids */ 117132718Skan 11890075Sobrien#define CTL_MACHDEP_NAMES { \ 119169689Skan { 0, 0 }, \ 120132718Skan { "console_device", CTLTYPE_STRUCT }, \ 121132718Skan { "adjkerntz", CTLTYPE_INT }, \ 12290075Sobrien { "disable_rtc_set", CTLTYPE_INT }, \ 123132718Skan { "bootinfo", CTLTYPE_STRUCT }, \ 12490075Sobrien { "wall_cmos_clock", CTLTYPE_INT }, \ 125132718Skan} 126132718Skan 127132718Skan#ifdef KERNEL 128132718Skanextern char btext[]; 129132718Skanextern char etext[]; 130132718Skanextern u_char intr_nesting_level; 131132718Skanextern int want_resched; /* resched was called */ 13290075Sobrien 133132718Skanvoid fork_trampoline __P((void)); 134132718Skanvoid fork_return __P((struct proc *, struct trapframe)); 135169689Skan#endif 136169689Skan 137169689Skan#endif /* !_MACHINE_CPU_H_ */ 138169689Skan