cpu.h revision 255331
1170754Sdelphij/*- 2170754Sdelphij * Copyright (c) 1990 The Regents of the University of California. 3170754Sdelphij * All rights reserved. 4170754Sdelphij * 5170754Sdelphij * This code is derived from software contributed to Berkeley by 6170754Sdelphij * William Jolitz. 7170754Sdelphij * 8170754Sdelphij * Redistribution and use in source and binary forms, with or without 9170754Sdelphij * modification, are permitted provided that the following conditions 10170754Sdelphij * are met: 11170754Sdelphij * 1. Redistributions of source code must retain the above copyright 12170754Sdelphij * notice, this list of conditions and the following disclaimer. 13170754Sdelphij * 2. Redistributions in binary form must reproduce the above copyright 14170754Sdelphij * notice, this list of conditions and the following disclaimer in the 15170754Sdelphij * documentation and/or other materials provided with the distribution. 16170754Sdelphij * 4. Neither the name of the University nor the names of its contributors 17170754Sdelphij * may be used to endorse or promote products derived from this software 18170754Sdelphij * without specific prior written permission. 19170754Sdelphij * 20170754Sdelphij * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21170754Sdelphij * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22170754Sdelphij * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23170754Sdelphij * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24170754Sdelphij * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25170754Sdelphij * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26170754Sdelphij * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27170754Sdelphij * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28170754Sdelphij * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29170754Sdelphij * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30170754Sdelphij * SUCH DAMAGE. 31170754Sdelphij * 32170754Sdelphij * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 33170754Sdelphij * $FreeBSD: head/sys/amd64/include/cpu.h 255331 2013-09-06 22:17:02Z gibbs $ 34170754Sdelphij */ 35170754Sdelphij 36170754Sdelphij#ifndef _MACHINE_CPU_H_ 37170754Sdelphij#define _MACHINE_CPU_H_ 38170754Sdelphij 39170754Sdelphij/* 40170754Sdelphij * Definitions unique to i386 cpu support. 41170754Sdelphij */ 42170754Sdelphij#include <machine/psl.h> 43170754Sdelphij#include <machine/frame.h> 44170754Sdelphij#include <machine/segments.h> 45170754Sdelphij 46170754Sdelphij#define cpu_exec(p) /* nothing */ 47170754Sdelphij#define cpu_swapin(p) /* nothing */ 48170754Sdelphij#define cpu_getstack(td) ((td)->td_frame->tf_rsp) 49170754Sdelphij#define cpu_setstack(td, ap) ((td)->td_frame->tf_rsp = (ap)) 50170754Sdelphij#define cpu_spinwait() ia32_pause() 51170754Sdelphij 52170754Sdelphij#define TRAPF_USERMODE(framep) \ 53170754Sdelphij (ISPL((framep)->tf_cs) == SEL_UPL) 54170754Sdelphij#define TRAPF_PC(framep) ((framep)->tf_rip) 55170754Sdelphij 56170754Sdelphij#ifdef _KERNEL 57170754Sdelphij/* 58170754Sdelphij * Struct containing pointers to CPU management functions whose 59170754Sdelphij * implementation is run time selectable. Selection can be made, 60170754Sdelphij * for example, based on detection of a particular CPU variant or 61170754Sdelphij * hypervisor environment. 62170754Sdelphij */ 63170754Sdelphijstruct cpu_ops { 64170754Sdelphij void (*ipi_vectored)(u_int, int); 65170754Sdelphij}; 66170754Sdelphij 67170754Sdelphijextern struct cpu_ops cpu_ops; 68170754Sdelphijextern char btext[]; 69170754Sdelphijextern char etext[]; 70170754Sdelphij 71170754Sdelphijvoid cpu_halt(void); 72170754Sdelphijvoid cpu_reset(void); 73170754Sdelphijvoid fork_trampoline(void); 74170754Sdelphijvoid swi_vm(void *); 75170754Sdelphij 76170754Sdelphij/* 77170754Sdelphij * Return contents of in-cpu fast counter as a sort of "bogo-time" 78170754Sdelphij * for random-harvesting purposes. 79170754Sdelphij */ 80170754Sdelphijstatic __inline u_int64_t 81170754Sdelphijget_cyclecount(void) 82170754Sdelphij{ 83170754Sdelphij 84170754Sdelphij return (rdtsc()); 85170754Sdelphij} 86170754Sdelphij 87170754Sdelphij#endif 88170754Sdelphij 89170754Sdelphij#endif /* !_MACHINE_CPU_H_ */ 90170754Sdelphij