/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 1990 The Regents of the University of California.4* All rights reserved.5*6* This code is derived from software contributed to Berkeley by7* William Jolitz.8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions and the following disclaimer.14* 2. Redistributions in binary form must reproduce the above copyright15* notice, this list of conditions and the following disclaimer in the16* documentation and/or other materials provided with the distribution.17* 3. Neither the name of the University nor the names of its contributors18* may be used to endorse or promote products derived from this software19* without specific prior written permission.20*21* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND22* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE23* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE24* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE25* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL26* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS27* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)28* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT29* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31* SUCH DAMAGE.32*/3334#ifndef _MACHINE_CPU_H_35#define _MACHINE_CPU_H_3637/*38* Definitions unique to i386 cpu support.39*/40#ifdef _KERNEL41#include <sys/systm.h> /* For cpu_ticks(). */42#endif43#include <machine/psl.h>44#include <machine/frame.h>45#include <machine/segments.h>4647#define cpu_exec(p) /* nothing */48#define cpu_swapin(p) /* nothing */49#define cpu_getstack(td) ((td)->td_frame->tf_esp)50#define cpu_setstack(td, ap) ((td)->td_frame->tf_esp = (ap))51#define cpu_spinwait() ia32_pause()5253#define TRAPF_USERMODE(framep) \54((ISPL((framep)->tf_cs) == SEL_UPL) || ((framep)->tf_eflags & PSL_VM))55#define TRAPF_PC(framep) ((framep)->tf_eip)5657#ifdef _KERNEL58/*59* Struct containing pointers to CPU management functions whose60* implementation is run time selectable. Selection can be made,61* for example, based on detection of a particular CPU variant or62* hypervisor environment.63*/64struct cpu_ops {65void (*cpu_init)(void);66void (*cpu_resume)(void);67};6869extern struct cpu_ops cpu_ops;70extern char btext[];71extern char etext[];7273void cpu_halt(void);74void cpu_lock_delay(void);75void cpu_reset(void);76void fork_trampoline(void);7778/*79* Return contents of in-cpu fast counter as a sort of "bogo-time"80* for random-harvesting purposes.81*/82static __inline uint64_t83get_cyclecount(void)84{8586return (cpu_ticks());87}8889#endif9091#endif /* !_MACHINE_CPU_H_ */929394