cpu.h revision 719
1252190Srpaulo/*- 2252190Srpaulo * Copyright (c) 1990 The Regents of the University of California. 3252190Srpaulo * All rights reserved. 4252190Srpaulo * 5252190Srpaulo * This code is derived from software contributed to Berkeley by 6252190Srpaulo * William Jolitz. 7252190Srpaulo * 8252190Srpaulo * Redistribution and use in source and binary forms, with or without 9252190Srpaulo * modification, are permitted provided that the following conditions 10252190Srpaulo * are met: 11252190Srpaulo * 1. Redistributions of source code must retain the above copyright 12252190Srpaulo * notice, this list of conditions and the following disclaimer. 13252190Srpaulo * 2. Redistributions in binary form must reproduce the above copyright 14252190Srpaulo * notice, this list of conditions and the following disclaimer in the 15252190Srpaulo * documentation and/or other materials provided with the distribution. 16252190Srpaulo * 3. All advertising materials mentioning features or use of this software 17252190Srpaulo * must display the following acknowledgement: 18252190Srpaulo * This product includes software developed by the University of 19252190Srpaulo * California, Berkeley and its contributors. 20252190Srpaulo * 4. Neither the name of the University nor the names of its contributors 21252190Srpaulo * may be used to endorse or promote products derived from this software 22252190Srpaulo * without specific prior written permission. 23252190Srpaulo * 24252190Srpaulo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25252190Srpaulo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26252190Srpaulo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27252190Srpaulo * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28252190Srpaulo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29252190Srpaulo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30252190Srpaulo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31252190Srpaulo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32252190Srpaulo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33252190Srpaulo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34252190Srpaulo * SUCH DAMAGE. 35252190Srpaulo * 36252190Srpaulo * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 37252190Srpaulo * $Id: cpu.h,v 1.3 1993/10/08 20:50:57 rgrimes Exp $ 38252190Srpaulo */ 39252190Srpaulo 40252190Srpaulo#ifndef _MACHINE_CPU_H_ 41252190Srpaulo#define _MACHINE_CPU_H_ 1 42252190Srpaulo 43252190Srpaulo/* 44252190Srpaulo * Definitions unique to i386 cpu support. 45252190Srpaulo */ 46252190Srpaulo#include "machine/frame.h" 47252190Srpaulo#include "machine/segments.h" 48252190Srpaulo 49252190Srpaulo/* 50252190Srpaulo * definitions of cpu-dependent requirements 51252190Srpaulo * referenced in generic code 52252190Srpaulo */ 53252190Srpaulo#undef COPY_SIGCODE /* don't copy sigcode above user stack in exec */ 54252190Srpaulo 55252190Srpaulo#define cpu_exec(p) /* nothing */ 56252190Srpaulo 57252190Srpaulo/* 58252190Srpaulo * Arguments to hardclock, softclock and gatherstats 59252190Srpaulo * encapsulate the previous machine state in an opaque 60252190Srpaulo * clockframe; for now, use generic intrframe. 61252190Srpaulo */ 62252190Srpaulotypedef struct intrframe clockframe; 63252190Srpaulo 64252190Srpaulo#define CLKF_USERMODE(framep) (ISPL((framep)->if_cs) == SEL_UPL) 65252190Srpaulo#define CLKF_BASEPRI(framep) ((framep)->if_ppl == 0) 66252190Srpaulo#define CLKF_PC(framep) ((framep)->if_eip) 67252190Srpaulo 68252190Srpaulo/* 69252190Srpaulo * Preempt the current process if in interrupt from user mode, 70252190Srpaulo * or after the current trap/syscall if in system mode. 71252190Srpaulo */ 72252190Srpaulo#define need_resched() { want_resched++; aston(); } 73252190Srpaulo 74252190Srpaulo/* 75252190Srpaulo * Give a profiling tick to the current process from the softclock 76252190Srpaulo * interrupt. On tahoe, request an ast to send us through trap(), 77252190Srpaulo * marking the proc as needing a profiling tick. 78252190Srpaulo */ 79252190Srpaulo#define profile_tick(p, framep) { (p)->p_flag |= SOWEUPC; aston(); } 80252190Srpaulo 81252190Srpaulo/* 82252190Srpaulo * Notify the current process (p) that it has a signal pending, 83252190Srpaulo * process as soon as possible. 84252190Srpaulo */ 85252190Srpaulo#define signotify(p) aston() 86252190Srpaulo 87252190Srpaulo#define aston() (astpending++) 88252190Srpaulo 89252190Srpaulo/* 90252190Srpaulo * pull in #defines for kinds of processors 91252190Srpaulo */ 92252190Srpaulo#include "machine/cputypes.h" 93252190Srpaulo 94252190Srpaulostruct cpu_nameclass { 95252190Srpaulo char *cpu_name; 96252190Srpaulo int cpu_class; 97252190Srpaulo}; 98252190Srpaulo 99252190Srpaulo#ifdef KERNEL 100252190Srpauloextern int astpending; /* want a trap before returning to user mode */ 101252190Srpauloextern int want_resched; /* resched was called */ 102252190Srpaulo 103252190Srpauloextern int cpu; 104252190Srpauloextern int cpu_class; 105252190Srpauloextern struct cpu_nameclass i386_cpus[]; 106252190Srpaulo#endif 107252190Srpaulo#endif /* _MACHINE_CPU_H_ */ 108252190Srpaulo