cpu.h revision 137784
117680Spst/*- 217680Spst * Copyright (c) 1990 The Regents of the University of California. 317680Spst * All rights reserved. 417680Spst * 517680Spst * This code is derived from software contributed to Berkeley by 617680Spst * William Jolitz. 717680Spst * 817680Spst * Redistribution and use in source and binary forms, with or without 917680Spst * modification, are permitted provided that the following conditions 1017680Spst * are met: 1117680Spst * 1. Redistributions of source code must retain the above copyright 1217680Spst * notice, this list of conditions and the following disclaimer. 1317680Spst * 2. Redistributions in binary form must reproduce the above copyright 1417680Spst * notice, this list of conditions and the following disclaimer in the 1517680Spst * documentation and/or other materials provided with the distribution. 1617680Spst * 4. Neither the name of the University nor the names of its contributors 1717680Spst * may be used to endorse or promote products derived from this software 1817680Spst * without specific prior written permission. 1917680Spst * 2017680Spst * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21214478Srpaulo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2217680Spst * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2317680Spst * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2417680Spst * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2517680Spst * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2617680Spst * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2717680Spst * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2817680Spst * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2917680Spst * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3017680Spst * SUCH DAMAGE. 3117680Spst * 3217680Spst * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 3317680Spst * $FreeBSD: head/sys/i386/include/cpu.h 137784 2004-11-16 20:42:32Z jhb $ 3417680Spst */ 3517680Spst 3617680Spst#ifndef _MACHINE_CPU_H_ 3717680Spst#define _MACHINE_CPU_H_ 3817680Spst 3917680Spst/* 4017680Spst * Definitions unique to i386 cpu support. 4117680Spst */ 4217680Spst#include <machine/psl.h> 4317680Spst#include <machine/frame.h> 4417680Spst#include <machine/segments.h> 4517680Spst 4617680Spst/* 4717680Spst * definitions of cpu-dependent requirements 4817680Spst * referenced in generic code 4917680Spst */ 5017680Spst#undef COPY_SIGCODE /* don't copy sigcode above user stack in exec */ 5117680Spst 5217680Spst#define cpu_exec(p) /* nothing */ 5317680Spst#define cpu_swapin(p) /* nothing */ 5417680Spst#define cpu_getstack(td) ((td)->td_frame->tf_esp) 5517680Spst#define cpu_setstack(td, ap) ((td)->td_frame->tf_esp = (ap)) 5617680Spst#define cpu_spinwait() ia32_pause() 5717680Spst 5817680Spst#define TRAPF_USERMODE(framep) \ 5917680Spst ((ISPL((framep)->tf_cs) == SEL_UPL) || ((framep)->tf_eflags & PSL_VM)) 6017680Spst#define TRAPF_PC(framep) ((framep)->tf_eip) 6117680Spst 6217680Spst#define CLKF_USERMODE(framep) \ 6317680Spst ((ISPL((framep)->cf_cs) == SEL_UPL) || ((framep)->cf_eflags & PSL_VM)) 6417680Spst#define CLKF_PC(framep) ((framep)->cf_eip) 6517680Spst 6617680Spst/* 6717680Spst * CTL_MACHDEP definitions. 6817680Spst */ 6917680Spst#define CPU_CONSDEV 1 /* dev_t: console terminal device */ 7017680Spst#define CPU_ADJKERNTZ 2 /* int: timezone offset (seconds) */ 7117680Spst#define CPU_DISRTCSET 3 /* int: disable resettodr() call */ 7217680Spst#define CPU_BOOTINFO 4 /* struct: bootinfo */ 7317680Spst#define CPU_WALLCLOCK 5 /* int: indicates wall CMOS clock */ 7417680Spst#define CPU_MAXID 6 /* number of valid machdep ids */ 7517680Spst 7617680Spst#define CTL_MACHDEP_NAMES { \ 7717680Spst { 0, 0 }, \ 7817680Spst { "console_device", CTLTYPE_STRUCT }, \ 7917680Spst { "adjkerntz", CTLTYPE_INT }, \ 8017680Spst { "disable_rtc_set", CTLTYPE_INT }, \ 8117680Spst { "bootinfo", CTLTYPE_STRUCT }, \ 8217680Spst { "wall_cmos_clock", CTLTYPE_INT }, \ 8317680Spst} 8417680Spst 8517680Spst#ifdef _KERNEL 8617680Spstextern char btext[]; 8717680Spstextern char etext[]; 8817680Spstextern u_int tsc_present; 8917680Spst 9017680Spstvoid cpu_halt(void); 9117680Spstvoid cpu_reset(void); 9217680Spstvoid fork_trampoline(void); 9317680Spstvoid swi_vm(void *); 9417680Spst 9517680Spst/* 9617680Spst * Return contents of in-cpu fast counter as a sort of "bogo-time" 9717680Spst * for random-harvesting purposes. 9817680Spst */ 9917680Spststatic __inline u_int64_t 10017680Spstget_cyclecount(void) 10117680Spst{ 10217680Spst#if defined(I486_CPU) || defined(KLD_MODULE) 10317680Spst struct bintime bt; 10417680Spst 10517680Spst if (!tsc_present) { 10617680Spst binuptime(&bt); 10717680Spst return (bt.frac ^ bt.sec); 10817680Spst } 10917680Spst#endif 11017680Spst return (rdtsc()); 11117680Spst} 11217680Spst 11317680Spst#endif 11417680Spst 11517680Spst#endif /* !_MACHINE_CPU_H_ */ 11617680Spst