cpufunc.h revision 199767f8919635c4928607450d9e0abb932109ce
/*-
* Copyright (c) 2003 Peter Wemm.
* Copyright (c) 1993 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
/*
* Functions to provide access to special i386 instructions.
* used in preference to this.
*/
#ifndef _MACHINE_CPUFUNC_H_
#define _MACHINE_CPUFUNC_H_
#ifndef _SYS_CDEFS_H_
#endif
struct region_descriptor;
#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
static __inline void
breakpoint(void)
{
}
{
return (result);
}
{
return (result);
}
{
return (result);
}
{
return (result);
}
static __inline void
{
}
static __inline void
{
}
static __inline void
clts(void)
{
}
static __inline void
disable_intr(void)
{
}
static __inline void
{
: "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3])
: "0" (ax));
}
static __inline void
{
: "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3])
}
static __inline void
enable_intr(void)
{
}
#ifdef _KERNEL
#define HAVE_INLINE_FFS
#define ffs(x) __builtin_ffs(x)
#define HAVE_INLINE_FFSL
static __inline int
{
}
#define HAVE_INLINE_FFSLL
static __inline int
{
}
#define HAVE_INLINE_FLS
static __inline int
{
}
#define HAVE_INLINE_FLSL
static __inline int
{
}
#define HAVE_INLINE_FLSLL
static __inline int
{
}
#endif /* _KERNEL */
static __inline void
halt(void)
{
}
{
return (data);
}
{
return (data);
}
static __inline void
{
: "d" (port)
: "memory");
}
static __inline void
{
: "d" (port)
: "memory");
}
static __inline void
{
: "d" (port)
: "memory");
}
static __inline void
invd(void)
{
}
{
return (data);
}
static __inline void
{
}
static __inline void
{
}
static __inline void
{
: "d" (port));
}
static __inline void
{
: "d" (port));
}
static __inline void
{
: "d" (port));
}
static __inline void
{
}
{
return (result);
}
static __inline void
lfence(void)
{
}
static __inline void
mfence(void)
{
}
static __inline void
ia32_pause(void)
{
}
read_rflags(void)
{
return (rf);
}
{
}
{
return (low);
}
{
}
rdtsc(void)
{
}
rdtsc32(void)
{
return (rv);
}
static __inline void
wbinvd(void)
{
}
static __inline void
{
}
static __inline void
{
}
static __inline void
{
}
rcr0(void)
{
return (data);
}
rcr2(void)
{
return (data);
}
static __inline void
{
}
rcr3(void)
{
return (data);
}
static __inline void
{
}
rcr4(void)
{
return (data);
}
{
}
static __inline void
{
}
/*
* Global TLB flush (except for thise for pages marked PG_G)
*/
static __inline void
invltlb(void)
{
}
#ifndef CR4_PGE
#endif
/*
* Perform the guaranteed invalidation of all TLB entries. This
* includes the global entries, and entries in all PCIDs, not only the
* current context. The function works both on non-PCID CPUs and CPUs
* with the PCID turned off or on. See IA-32 SDM Vol. 3a 4.10.4.1
* Operations that Invalidate TLBs and Paging-Structure Caches.
*/
static __inline void
invltlb_glob(void)
{
/*
* Although preemption at this point could be detrimental to
* performance, it would not lead to an error. PG_G is simply
* ignored if CR4.PGE is clear. Moreover, in case this block
* is re-entered, the load_cr4() either above or below will
* modify CR4.PGE flushing the TLB.
*/
}
/*
* TLB flush for an individual page (even if it has PG_G).
* Only works on 486+ CPUs (i386 does not have PG_G).
*/
static __inline void
{
}
#define INVPCID_ADDR 0
#define INVPCID_CTX 1
#define INVPCID_CTXGLOB 2
#define INVPCID_ALLCTX 3
struct invpcid_descr {
} __packed;
static __inline void
{
}
rfs(void)
{
return (sel);
}
rgs(void)
{
return (sel);
}
rss(void)
{
return (sel);
}
static __inline void
{
}
static __inline void
{
}
static __inline void
{
}
static __inline void
{
}
#ifdef _KERNEL
/* This is defined in <machine/specialreg.h> but is too painful to get to */
#ifndef MSR_FSBASE
#define MSR_FSBASE 0xc0000100
#endif
static __inline void
{
/* Preserve the fsbase value across the selector load */
}
#ifndef MSR_GSBASE
#define MSR_GSBASE 0xc0000101
#endif
static __inline void
{
/*
* Preserve the gsbase value across the selector load.
* Note that we have to disable interrupts because the gsbase
* being trashed happens to be the kernel gsbase at the time.
*/
}
#else
/* Usable by userland */
static __inline void
{
}
static __inline void
{
}
#endif
static __inline void
{
}
static __inline void
{
}
static __inline void
{
}
rdr0(void)
{
return (data);
}
static __inline void
{
}
rdr1(void)
{
return (data);
}
static __inline void
{
}
rdr2(void)
{
return (data);
}
static __inline void
{
}
rdr3(void)
{
return (data);
}
static __inline void
{
}
rdr4(void)
{
return (data);
}
static __inline void
{
}
rdr5(void)
{
return (data);
}
static __inline void
{
}
rdr6(void)
{
return (data);
}
static __inline void
{
}
rdr7(void)
{
return (data);
}
static __inline void
{
}
static __inline register_t
intr_disable(void)
{
rflags = read_rflags();
disable_intr();
return (rflags);
}
static __inline void
{
}
#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */
int breakpoint(void);
void clts(void);
void disable_intr(void);
void enable_intr(void);
void halt(void);
void ia32_pause(void);
register_t intr_disable(void);
void invd(void);
void invltlb(void);
u_long read_rflags(void);
void wbinvd(void);
#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */
void reset_dbregs(void);
#ifdef _KERNEL
#endif
#endif /* !_MACHINE_CPUFUNC_H_ */