cpu.h revision 153666
150276Speter/*- 276726Speter * Copyright (c) 1990 The Regents of the University of California. 397049Speter * All rights reserved. 4178866Srafan * 5178866Srafan * This code is derived from software contributed to Berkeley by 662449Speter * William Jolitz. 7184989Srafan * 862449Speter * Redistribution and use in source and binary forms, with or without 950276Speter * modification, are permitted provided that the following conditions 1050276Speter * are met: 1150276Speter * 1. Redistributions of source code must retain the above copyright 1250276Speter * notice, this list of conditions and the following disclaimer. 1350276Speter * 2. Redistributions in binary form must reproduce the above copyright 1450276Speter * notice, this list of conditions and the following disclaimer in the 1550276Speter * documentation and/or other materials provided with the distribution. 1650276Speter * 4. Neither the name of the University nor the names of its contributors 1750276Speter * may be used to endorse or promote products derived from this software 1850276Speter * without specific prior written permission. 1950276Speter * 2050276Speter * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2150276Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2250276Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2350276Speter * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2450276Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25166124Srafan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26166124Srafan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27166124Srafan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2850276Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2950276Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3050276Speter * SUCH DAMAGE. 3150276Speter * 3250276Speter * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 33166124Srafan * $FreeBSD: head/sys/amd64/include/cpu.h 153666 2005-12-22 22:16:09Z jhb $ 3497049Speter */ 3597049Speter 3662449Speter#ifndef _MACHINE_CPU_H_ 3750276Speter#define _MACHINE_CPU_H_ 3850276Speter 3950276Speter/* 4050276Speter * Definitions unique to i386 cpu support. 4150276Speter */ 4250276Speter#include <machine/psl.h> 4350276Speter#include <machine/frame.h> 4450276Speter#include <machine/segments.h> 4550276Speter 4650276Speter/* 4750276Speter * definitions of cpu-dependent requirements 4850276Speter * referenced in generic code 4950276Speter */ 5050276Speter#undef COPY_SIGCODE /* don't copy sigcode above user stack in exec */ 5150276Speter 5250276Speter#define cpu_exec(p) /* nothing */ 5350276Speter#define cpu_swapin(p) /* nothing */ 5450276Speter#define cpu_getstack(td) ((td)->td_frame->tf_rsp) 5550276Speter#define cpu_setstack(td, ap) ((td)->td_frame->tf_rsp = (ap)) 5650276Speter#define cpu_spinwait() ia32_pause() 5762449Speter 5850276Speter#define TRAPF_USERMODE(framep) \ 5962449Speter (ISPL((framep)->tf_cs) == SEL_UPL) 6062449Speter#define TRAPF_PC(framep) ((framep)->tf_rip) 6162449Speter 6262449Speter/* 6362449Speter * CTL_MACHDEP definitions. 6462449Speter */ 6562449Speter#define CPU_CONSDEV 1 /* dev_t: console terminal device */ 6676726Speter#define CPU_ADJKERNTZ 2 /* int: timezone offset (seconds) */ 6776726Speter#define CPU_DISRTCSET 3 /* int: disable resettodr() call */ 6876726Speter#define CPU_WALLCLOCK 5 /* int: indicates wall CMOS clock */ 6962449Speter#define CPU_MAXID 6 /* number of valid machdep ids */ 7076726Speter 7176726Speter#ifdef _KERNEL 7276726Speterextern char btext[]; 7376726Speterextern char etext[]; 7476726Speter 75178866Srafanvoid cpu_halt(void); 76178866Srafanvoid cpu_reset(void); 7776726Spetervoid fork_trampoline(void); 7876726Spetervoid swi_vm(void *); 7976726Speter 8076726Speter/* 8162449Speter * Return contents of in-cpu fast counter as a sort of "bogo-time" 8262449Speter * for random-harvesting purposes. 8362449Speter */ 8462449Speterstatic __inline u_int64_t 8562449Speterget_cyclecount(void) 8676726Speter{ 8776726Speter 88166124Srafan return (rdtsc()); 8976726Speter} 90166124Srafan 9162449Speter#endif 92166124Srafan 9362449Speter#endif /* !_MACHINE_CPU_H_ */ 9462449Speter