cpu.h revision 43387
11638Srgrimes/*- 21638Srgrimes * Copyright (c) 1990 The Regents of the University of California. 31638Srgrimes * All rights reserved. 41638Srgrimes * 51638Srgrimes * This code is derived from software contributed to Berkeley by 61638Srgrimes * William Jolitz. 71638Srgrimes * 81638Srgrimes * Redistribution and use in source and binary forms, with or without 91638Srgrimes * modification, are permitted provided that the following conditions 101638Srgrimes * are met: 111638Srgrimes * 1. Redistributions of source code must retain the above copyright 12263142Seadler * notice, this list of conditions and the following disclaimer. 131638Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141638Srgrimes * notice, this list of conditions and the following disclaimer in the 151638Srgrimes * documentation and/or other materials provided with the distribution. 161638Srgrimes * 3. All advertising materials mentioning features or use of this software 171638Srgrimes * must display the following acknowledgement: 181638Srgrimes * This product includes software developed by the University of 191638Srgrimes * California, Berkeley and its contributors. 201638Srgrimes * 4. Neither the name of the University nor the names of its contributors 211638Srgrimes * may be used to endorse or promote products derived from this software 221638Srgrimes * without specific prior written permission. 231638Srgrimes * 241638Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 251638Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 261638Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 271638Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 281638Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2969280Sru * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 301638Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 311638Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 321638Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 331638Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 341638Srgrimes * SUCH DAMAGE. 351638Srgrimes * 361638Srgrimes * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 371638Srgrimes * $Id: cpu.h,v 1.36 1998/08/31 08:41:40 kato Exp $ 381638Srgrimes */ 391638Srgrimes 401638Srgrimes#ifndef _MACHINE_CPU_H_ 411638Srgrimes#define _MACHINE_CPU_H_ 421638Srgrimes 431638Srgrimes/* 441638Srgrimes * Definitions unique to i386 cpu support. 451638Srgrimes */ 461638Srgrimes#include <machine/psl.h> 471638Srgrimes#include <machine/frame.h> 481638Srgrimes#include <machine/segments.h> 491638Srgrimes 5069280Sru/* 5169280Sru * definitions of cpu-dependent requirements 521638Srgrimes * referenced in generic code 531638Srgrimes */ 541638Srgrimes#undef COPY_SIGCODE /* don't copy sigcode above user stack in exec */ 551638Srgrimes 561638Srgrimes#define cpu_exec(p) /* nothing */ 571638Srgrimes#define cpu_swapin(p) /* nothing */ 581638Srgrimes#define cpu_setstack(p, ap) ((p)->p_md.md_regs[SP] = (ap)) 591638Srgrimes#define cpu_set_init_frame(p, fp) ((p)->p_md.md_regs = (fp)) 601638Srgrimes 611638Srgrimes#define CLKF_USERMODE(framep) \ 621638Srgrimes ((ISPL((framep)->cf_cs) == SEL_UPL) || (framep->cf_eflags & PSL_VM)) 631638Srgrimes 641638Srgrimes#define CLKF_INTR(framep) (intr_nesting_level >= 2) 651638Srgrimes#if 0 661638Srgrimes/* 671638Srgrimes * XXX splsoftclock() is very broken and barely worth fixing. It doesn't 681638Srgrimes * turn off the clock bit in imen or in the icu. (This is not a serious 691638Srgrimes * problem at 100 Hz but it is serious at 16000 Hz for pcaudio. softclock() 701638Srgrimes * can take more than 62.5 usec so clock interrupts are lost.) It doesn't 711638Srgrimes * check for pending interrupts being unmasked. clkintr() and Xintr0() 721638Srgrimes * assume that the ipl is high when hardclock() returns. Our SWI_AST 731638Srgrimes * handling is efficient enough that little is gained by calling 741638Srgrimes * softclock() directly. 751638Srgrimes */ 761638Srgrimes#define CLKF_BASEPRI(framep) (((framep)->cf_ppl & ~SWI_AST_MASK) == 0) 771638Srgrimes#else 781638Srgrimes#define CLKF_BASEPRI(framep) (0) 791638Srgrimes#endif 801638Srgrimes#define CLKF_PC(framep) ((framep)->cf_eip) 811638Srgrimes 821638Srgrimes/* 831638Srgrimes * Preempt the current process if in interrupt from user mode, 841638Srgrimes * or after the current trap/syscall if in system mode. 851638Srgrimes */ 861638Srgrimes#define need_resched() { want_resched = 1; aston(); } 871638Srgrimes 881638Srgrimes/* 891638Srgrimes * Arrange to handle pending profiling ticks before returning to user mode. 901638Srgrimes * 911638Srgrimes * XXX this is now poorly named and implemented. It used to handle only a 921638Srgrimes * single tick and the P_OWEUPC flag served as a counter. Now there is a 931638Srgrimes * counter in the proc table and flag isn't really necessary. 941638Srgrimes */ 951638Srgrimes#define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); } 961638Srgrimes 971638Srgrimes/* 981638Srgrimes * Notify the current process (p) that it has a signal pending, 991638Srgrimes * process as soon as possible. 1001638Srgrimes */ 1011638Srgrimes#define signotify(p) aston() 1021638Srgrimes 1031638Srgrimes#define aston() setsoftast() 1041638Srgrimes#define astoff() 1051638Srgrimes 1061638Srgrimes/* 1071638Srgrimes * CTL_MACHDEP definitions. 1081638Srgrimes */ 1091638Srgrimes#define CPU_CONSDEV 1 /* dev_t: console terminal device */ 1101638Srgrimes#define CPU_ADJKERNTZ 2 /* int: timezone offset (seconds) */ 1111638Srgrimes#define CPU_DISRTCSET 3 /* int: disable resettodr() call */ 1121638Srgrimes#define CPU_BOOTINFO 4 /* struct: bootinfo */ 1131638Srgrimes#define CPU_WALLCLOCK 5 /* int: indicates wall CMOS clock */ 1141638Srgrimes#define CPU_MAXID 6 /* number of valid machdep ids */ 1151638Srgrimes 1161638Srgrimes#define CTL_MACHDEP_NAMES { \ 1171638Srgrimes { 0, 0 }, \ 1181638Srgrimes { "console_device", CTLTYPE_STRUCT }, \ 1191638Srgrimes { "adjkerntz", CTLTYPE_INT }, \ 1201638Srgrimes { "disable_rtc_set", CTLTYPE_INT }, \ 1211638Srgrimes { "bootinfo", CTLTYPE_STRUCT }, \ 1221638Srgrimes { "wall_cmos_clock", CTLTYPE_INT }, \ 1231638Srgrimes} 1241638Srgrimes 1251638Srgrimes#ifdef KERNEL 1261638Srgrimesextern char btext[]; 1271638Srgrimesextern char etext[]; 1281638Srgrimesextern u_char intr_nesting_level; 1291638Srgrimesextern int want_resched; /* resched was called */ 130 131void fork_trampoline __P((void)); 132void fork_return __P((struct proc *, struct trapframe)); 133void cpu_set_fork_handler __P((struct proc *, void (*pc)(const void *), const void *)); 134#endif 135 136#endif /* !_MACHINE_CPU_H_ */ 137