/*-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#include <machine/psl.h>41#include <machine/frame.h>42#include <machine/segments.h>4344#define cpu_exec(p) /* nothing */45#define cpu_swapin(p) /* nothing */46#define cpu_getstack(td) ((td)->td_frame->tf_rsp)47#define cpu_setstack(td, ap) ((td)->td_frame->tf_rsp = (ap))48#define cpu_spinwait() ia32_pause()4950#define TRAPF_USERMODE(framep) \51(ISPL((framep)->tf_cs) == SEL_UPL)52#define TRAPF_PC(framep) ((framep)->tf_rip)5354#ifdef _KERNEL55/*56* Struct containing pointers to CPU management functions whose57* implementation is run time selectable. Selection can be made,58* for example, based on detection of a particular CPU variant or59* hypervisor environment.60*/61struct cpu_ops {62void (*cpu_init)(void);63void (*cpu_resume)(void);64};6566extern struct cpu_ops cpu_ops;67extern char brwsection[];68extern char btext[];69extern char _end[];70extern char etext[];7172/* Suspend and resume hook for VMM. */73extern void (*vmm_suspend_p)(void);74extern void (*vmm_resume_p)(void);7576void cpu_halt(void);77void cpu_lock_delay(void);78void cpu_reset(void);79void fork_trampoline(void);8081/*82* Return contents of in-cpu fast counter as a sort of "bogo-time"83* for random-harvesting purposes.84*/85static __inline u_int64_t86get_cyclecount(void)87{8889return (rdtsc());90}9192#define MEMSET_EARLY_FUNC memset_std93#define MEMCPY_EARLY_FUNC memcpy_std94#define MEMMOVE_EARLY_FUNC memmove_std9596#endif9798#endif /* !_MACHINE_CPU_H_ */99100101