asm-amd64-x86.h revision 141a285580775ead77d73bb52a63701a5591dc6d
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/** @file
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * IPRT - AMD64 and x86 Specific Assembly Functions.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/*
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Copyright (C) 2006-2010 Oracle Corporation
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * available from http://www.virtualbox.org. This file is free software;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * you can redistribute it and/or modify it under the terms of the GNU
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * General Public License (GPL) as published by the Free Software
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * The contents of this file may alternatively be used under the terms
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * of the Common Development and Distribution License Version 1.0
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * VirtualBox OSE distribution, in which case the provisions of the
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * CDDL are applicable instead of those of the GPL.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * You may elect to license modified versions of this file under the
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * terms and conditions of either the GPL or the CDDL or both.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#ifndef ___iprt_asm_amd64_x86_h
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#define ___iprt_asm_amd64_x86_h
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync#include <iprt/types.h>
141a285580775ead77d73bb52a63701a5591dc6dvboxsync#if !defined(RT_ARCH_AMD64) && !defined(RT_ARCH_X86)
141a285580775ead77d73bb52a63701a5591dc6dvboxsync# error "Not on AMD64 or x86"
141a285580775ead77d73bb52a63701a5591dc6dvboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync#if defined(_MSC_VER) && RT_INLINE_ASM_USES_INTRIN
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# include <intrin.h>
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /* Emit the intrinsics at all optimization levels. */
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(_ReadWriteBarrier)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__cpuid)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(_enable)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(_disable)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__rdtsc)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__readmsr)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__writemsr)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__outbyte)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__outbytestring)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__outword)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__outwordstring)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__outdword)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__outdwordstring)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__inbyte)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__inbytestring)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__inword)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__inwordstring)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__indword)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__indwordstring)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__invlpg)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__wbinvd)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__readcr0)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__readcr2)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__readcr3)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__readcr4)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__writecr0)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__writecr3)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__writecr4)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__readdr)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__writedr)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# ifdef RT_ARCH_AMD64
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__readcr8)
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# pragma intrinsic(__writecr8)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/** @defgroup grp_rt_asm_amd64_x86 AMD64 and x86 Specific ASM Routines
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @ingroup grp_rt_asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/** @todo find a more proper place for this structure? */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#pragma pack(1)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/** IDTR */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsynctypedef struct RTIDTR
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Size of the IDT. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint16_t cbIdt;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Address of the IDT. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uintptr_t pIdt;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync} RTIDTR, *PRTIDTR;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#pragma pack()
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#pragma pack(1)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/** GDTR */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsynctypedef struct RTGDTR
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Size of the GDT. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint16_t cbGdt;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Address of the GDT. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uintptr_t pGdt;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync} RTGDTR, *PRTGDTR;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#pragma pack()
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Gets the content of the IDTR CPU register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pIdtr Where to store the IDTR contents.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMGetIDTR(PRTIDTR pIdtr);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMGetIDTR(PRTIDTR pIdtr)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("sidt %0" : "=m" (*pIdtr));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [pIdtr]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync sidt [rax]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [pIdtr]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync sidt [eax]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Sets the content of the IDTR CPU register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pIdtr Where to load the IDTR contents from
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMSetIDTR(const RTIDTR *pIdtr);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMSetIDTR(const RTIDTR *pIdtr)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("lidt %0" : : "m" (*pIdtr));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [pIdtr]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync lidt [rax]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [pIdtr]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync lidt [eax]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Gets the content of the GDTR CPU register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pGdtr Where to store the GDTR contents.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMGetGDTR(PRTGDTR pGdtr);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMGetGDTR(PRTGDTR pGdtr)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("sgdt %0" : "=m" (*pGdtr));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [pGdtr]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync sgdt [rax]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [pGdtr]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync sgdt [eax]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get the cs register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns cs.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTSEL) ASMGetCS(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTSEL) ASMGetCS(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTSEL SelCS;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movw %%cs, %0\n\t" : "=r" (SelCS));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ax, cs
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [SelCS], ax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return SelCS;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get the DS register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns DS.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTSEL) ASMGetDS(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTSEL) ASMGetDS(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTSEL SelDS;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movw %%ds, %0\n\t" : "=r" (SelDS));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ax, ds
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [SelDS], ax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return SelDS;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get the ES register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns ES.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTSEL) ASMGetES(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTSEL) ASMGetES(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTSEL SelES;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movw %%es, %0\n\t" : "=r" (SelES));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ax, es
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [SelES], ax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return SelES;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get the FS register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns FS.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTSEL) ASMGetFS(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTSEL) ASMGetFS(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTSEL SelFS;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movw %%fs, %0\n\t" : "=r" (SelFS));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ax, fs
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [SelFS], ax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return SelFS;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get the GS register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns GS.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTSEL) ASMGetGS(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTSEL) ASMGetGS(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTSEL SelGS;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movw %%gs, %0\n\t" : "=r" (SelGS));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ax, gs
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [SelGS], ax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return SelGS;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get the SS register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns SS.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTSEL) ASMGetSS(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTSEL) ASMGetSS(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTSEL SelSS;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movw %%ss, %0\n\t" : "=r" (SelSS));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ax, ss
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [SelSS], ax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return SelSS;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get the TR register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns TR.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTSEL) ASMGetTR(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTSEL) ASMGetTR(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTSEL SelTR;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("str %w0\n\t" : "=r" (SelTR));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync str ax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [SelTR], ax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return SelTR;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get the [RE]FLAGS register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns [RE]FLAGS.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetFlags(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetFlags(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uFlags;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("pushfq\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "popq %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=r" (uFlags));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("pushfl\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "popl %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=r" (uFlags));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pushfq
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pop [uFlags]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pushfd
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pop [uFlags]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uFlags;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Set the [RE]FLAGS register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uFlags The new [RE]FLAGS value.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMSetFlags(RTCCUINTREG uFlags);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMSetFlags(RTCCUINTREG uFlags)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("pushq %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "popfq\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : : "g" (uFlags));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("pushl %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "popfl\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : : "g" (uFlags));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync push [uFlags]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync popfq
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync push [uFlags]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync popfd
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Gets the content of the CPU timestamp counter register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns TSC.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(uint64_t) ASMReadTSC(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint64_t) ASMReadTSC(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTUINT64U u;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("rdtsc\n\t" : "=a" (u.s.Lo), "=d" (u.s.Hi));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync u.u = __rdtsc();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync rdtsc
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [u.s.Lo], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [u.s.Hi], edx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return u.u;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Performs the cpuid instruction returning all registers.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uOperator CPUID operation (eax).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pvEAX Where to store eax.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pvEBX Where to store ebx.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pvECX Where to store ecx.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pvEDX Where to store edx.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @remark We're using void pointers to ease the use of special bitfield structures and such.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMCpuId(uint32_t uOperator, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMCpuId(uint32_t uOperator, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uRAX, uRBX, uRCX, uRDX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("cpuid\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (uRAX),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=b" (uRBX),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=c" (uRCX),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=d" (uRDX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (uOperator));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEAX = (uint32_t)uRAX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEBX = (uint32_t)uRBX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvECX = (uint32_t)uRCX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEDX = (uint32_t)uRDX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("xchgl %%ebx, %1\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "cpuid\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "xchgl %%ebx, %1\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (*(uint32_t *)pvEAX),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=r" (*(uint32_t *)pvEBX),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=c" (*(uint32_t *)pvECX),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=d" (*(uint32_t *)pvEDX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (uOperator));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync int aInfo[4];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __cpuid(aInfo, uOperator);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEAX = aInfo[0];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEBX = aInfo[1];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvECX = aInfo[2];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEDX = aInfo[3];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t uEAX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t uEBX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t uECX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t uEDX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync push ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uOperator]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync cpuid
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uEAX], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uEBX], ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uECX], ecx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uEDX], edx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pop ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEAX = uEAX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEBX = uEBX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvECX = uECX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEDX = uEDX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Performs the cpuid instruction returning all registers.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Some subfunctions of cpuid take ECX as additional parameter (currently known for EAX=4)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uOperator CPUID operation (eax).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uIdxECX ecx index
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pvEAX Where to store eax.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pvEBX Where to store ebx.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pvECX Where to store ecx.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pvEDX Where to store edx.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @remark We're using void pointers to ease the use of special bitfield structures and such.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMCpuId_Idx_ECX(uint32_t uOperator, uint32_t uIdxECX, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMCpuId_Idx_ECX(uint32_t uOperator, uint32_t uIdxECX, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uRAX, uRBX, uRCX, uRDX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("cpuid\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (uRAX),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=b" (uRBX),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=c" (uRCX),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=d" (uRDX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (uOperator),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "2" (uIdxECX));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEAX = (uint32_t)uRAX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEBX = (uint32_t)uRBX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvECX = (uint32_t)uRCX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEDX = (uint32_t)uRDX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("xchgl %%ebx, %1\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "cpuid\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "xchgl %%ebx, %1\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (*(uint32_t *)pvEAX),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=r" (*(uint32_t *)pvEBX),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=c" (*(uint32_t *)pvECX),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=d" (*(uint32_t *)pvEDX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (uOperator),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "2" (uIdxECX));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync int aInfo[4];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /* ??? another intrinsic ??? */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __cpuid(aInfo, uOperator);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEAX = aInfo[0];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEBX = aInfo[1];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvECX = aInfo[2];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEDX = aInfo[3];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t uEAX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t uEBX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t uECX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t uEDX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync push ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uOperator]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, [uIdxECX]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync cpuid
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uEAX], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uEBX], ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uECX], ecx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uEDX], edx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pop ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEAX = uEAX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEBX = uEBX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvECX = uECX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *(uint32_t *)pvEDX = uEDX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Performs the cpuid instruction returning ecx and edx.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uOperator CPUID operation (eax).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pvECX Where to store ecx.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pvEDX Where to store edx.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @remark We're using void pointers to ease the use of special bitfield structures and such.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMCpuId_ECX_EDX(uint32_t uOperator, void *pvECX, void *pvEDX);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMCpuId_ECX_EDX(uint32_t uOperator, void *pvECX, void *pvEDX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t uEBX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync ASMCpuId(uOperator, &uOperator, &uEBX, pvECX, pvEDX);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Performs the cpuid instruction returning edx.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uOperator CPUID operation (eax).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns EDX after cpuid operation.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(uint32_t) ASMCpuId_EDX(uint32_t uOperator);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint32_t) ASMCpuId_EDX(uint32_t uOperator)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG xDX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uSpill;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("cpuid"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (uSpill),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=d" (xDX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (uOperator)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "rbx", "rcx");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif (defined(PIC) || defined(__PIC__)) && defined(__i386__)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("push %%ebx\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "cpuid\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "pop %%ebx\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (uOperator),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=d" (xDX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (uOperator)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "ecx");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("cpuid"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (uOperator),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=d" (xDX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (uOperator)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "ebx", "ecx");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync int aInfo[4];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __cpuid(aInfo, uOperator);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xDX = aInfo[3];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync push ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uOperator]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync cpuid
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [xDX], edx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pop ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return (uint32_t)xDX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Performs the cpuid instruction returning ecx.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uOperator CPUID operation (eax).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns ECX after cpuid operation.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(uint32_t) ASMCpuId_ECX(uint32_t uOperator);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint32_t) ASMCpuId_ECX(uint32_t uOperator)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG xCX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uSpill;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("cpuid"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (uSpill),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=c" (xCX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (uOperator)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "rbx", "rdx");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif (defined(PIC) || defined(__PIC__)) && defined(__i386__)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("push %%ebx\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "cpuid\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "pop %%ebx\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (uOperator),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=c" (xCX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (uOperator)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "edx");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("cpuid"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (uOperator),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=c" (xCX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (uOperator)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "ebx", "edx");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync int aInfo[4];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __cpuid(aInfo, uOperator);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xCX = aInfo[2];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync push ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uOperator]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync cpuid
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [xCX], ecx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pop ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return (uint32_t)xCX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Checks if the current CPU supports CPUID.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns true if CPUID is supported.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(bool) ASMHasCpuId(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return true; /* ASSUME that all amd64 compatible CPUs have cpuid. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else /* !RT_ARCH_AMD64 */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync bool fRet = false;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t u1;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t u2;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("pushf\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "pop %1\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "mov %1, %2\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "xorl $0x200000, %1\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "push %1\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "popf\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "pushf\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "pop %1\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "cmpl %1, %2\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "setne %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "push %2\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "popf\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=m" (fRet), "=r" (u1), "=r" (u2));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pushfd
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pop eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ebx, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xor eax, 0200000h
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync push eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync popfd
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pushfd
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pop eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync cmp eax, ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync setne fRet
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync push ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync popfd
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return fRet;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif /* !RT_ARCH_AMD64 */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Gets the APIC ID of the current CPU.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns the APIC ID.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(uint8_t) ASMGetApicId(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint8_t) ASMGetApicId(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG xBX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uSpill;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("cpuid"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (uSpill),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=b" (xBX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (1)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "rcx", "rdx");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif (defined(PIC) || defined(__PIC__)) && defined(__i386__)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uSpill;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("mov %%ebx,%1\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "cpuid\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "xchgl %%ebx,%1\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (uSpill),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=r" (xBX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (1)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "ecx", "edx");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uSpill;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ ("cpuid"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (uSpill),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=b" (xBX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "0" (1)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "ecx", "edx");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync int aInfo[4];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __cpuid(aInfo, 1);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xBX = aInfo[1];
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync push ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, 1
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync cpuid
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [xBX], ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pop ebx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return (uint8_t)(xBX >> 24);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Tests if it a genuine Intel CPU based on the ASMCpuId(0) output.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns true/false.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uEBX EBX return from ASMCpuId(0)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uECX ECX return from ASMCpuId(0)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uEDX EDX return from ASMCpuId(0)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(bool) ASMIsIntelCpuEx(uint32_t uEBX, uint32_t uECX, uint32_t uEDX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uEBX == UINT32_C(0x756e6547)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync && uECX == UINT32_C(0x6c65746e)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync && uEDX == UINT32_C(0x49656e69);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Tests if this is a genuine Intel CPU.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns true/false.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @remarks ASSUMES that cpuid is supported by the CPU.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(bool) ASMIsIntelCpu(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t uEAX, uEBX, uECX, uEDX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync ASMCpuId(0, &uEAX, &uEBX, &uECX, &uEDX);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return ASMIsIntelCpuEx(uEBX, uECX, uEDX);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Tests if it a authentic AMD CPU based on the ASMCpuId(0) output.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns true/false.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uEBX EBX return from ASMCpuId(0)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uECX ECX return from ASMCpuId(0)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uEDX EDX return from ASMCpuId(0)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(bool) ASMIsAmdCpuEx(uint32_t uEBX, uint32_t uECX, uint32_t uEDX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uEBX == UINT32_C(0x68747541)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync && uECX == UINT32_C(0x444d4163)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync && uEDX == UINT32_C(0x69746e65);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Tests if this is an authentic AMD CPU.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns true/false.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @remarks ASSUMES that cpuid is supported by the CPU.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(bool) ASMIsAmdCpu(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t uEAX, uEBX, uECX, uEDX;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync ASMCpuId(0, &uEAX, &uEBX, &uECX, &uEDX);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return ASMIsAmdCpuEx(uEBX, uECX, uEDX);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Extracts the CPU family from ASMCpuId(1) or ASMCpuId(0x80000001)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns Family.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uEAX EAX return from ASMCpuId(1) or ASMCpuId(0x80000001).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint32_t) ASMGetCpuFamily(uint32_t uEAX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return ((uEAX >> 8) & 0xf) == 0xf
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync ? ((uEAX >> 20) & 0x7f) + 0xf
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : ((uEAX >> 8) & 0xf);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Extracts the CPU model from ASMCpuId(1) or ASMCpuId(0x80000001), Intel variant.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns Model.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uEAX EAX from ASMCpuId(1) or ASMCpuId(0x80000001).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint32_t) ASMGetCpuModelIntel(uint32_t uEAX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return ((uEAX >> 8) & 0xf) == 0xf || (((uEAX >> 8) & 0xf) == 0x6) /* family! */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync ? ((uEAX >> 4) & 0xf) | ((uEAX >> 12) & 0xf0)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : ((uEAX >> 4) & 0xf);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Extracts the CPU model from ASMCpuId(1) or ASMCpuId(0x80000001), AMD variant.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns Model.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uEAX EAX from ASMCpuId(1) or ASMCpuId(0x80000001).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint32_t) ASMGetCpuModelAMD(uint32_t uEAX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return ((uEAX >> 8) & 0xf) == 0xf
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync ? ((uEAX >> 4) & 0xf) | ((uEAX >> 12) & 0xf0)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : ((uEAX >> 4) & 0xf);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Extracts the CPU model from ASMCpuId(1) or ASMCpuId(0x80000001)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns Model.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uEAX EAX from ASMCpuId(1) or ASMCpuId(0x80000001).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param fIntel Whether it's an intel CPU. Use ASMIsIntelCpuEx() or ASMIsIntelCpu().
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint32_t) ASMGetCpuModel(uint32_t uEAX, bool fIntel)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return ((uEAX >> 8) & 0xf) == 0xf || (((uEAX >> 8) & 0xf) == 0x6 && fIntel) /* family! */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync ? ((uEAX >> 4) & 0xf) | ((uEAX >> 12) & 0xf0)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : ((uEAX >> 4) & 0xf);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Extracts the CPU stepping from ASMCpuId(1) or ASMCpuId(0x80000001)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns Model.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uEAX EAX from ASMCpuId(1) or ASMCpuId(0x80000001).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint32_t) ASMGetCpuStepping(uint32_t uEAX)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uEAX & 0xf;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get cr0.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns cr0.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetCR0(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetCR0(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uCR0;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uCR0 = __readcr0();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%cr0, %0\t\n" : "=r" (uCR0));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %%cr0, %0\t\n" : "=r" (uCR0));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, cr0
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uCR0], rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, cr0
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uCR0], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uCR0;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Sets the CR0 register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uCR0 The new CR0 value.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMSetCR0(RTCCUINTREG uCR0);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMSetCR0(RTCCUINTREG uCR0)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __writecr0(uCR0);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %0, %%cr0\n\t" :: "r" (uCR0));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %0, %%cr0\n\t" :: "r" (uCR0));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [uCR0]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov cr0, rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uCR0]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov cr0, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get cr2.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns cr2.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetCR2(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetCR2(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uCR2;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uCR2 = __readcr2();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%cr2, %0\t\n" : "=r" (uCR2));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %%cr2, %0\t\n" : "=r" (uCR2));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, cr2
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uCR2], rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, cr2
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uCR2], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uCR2;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Sets the CR2 register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uCR2 The new CR0 value.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMSetCR2(RTCCUINTREG uCR2);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMSetCR2(RTCCUINTREG uCR2)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %0, %%cr2\n\t" :: "r" (uCR2));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %0, %%cr2\n\t" :: "r" (uCR2));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [uCR2]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov cr2, rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uCR2]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov cr2, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get cr3.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns cr3.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetCR3(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetCR3(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uCR3;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uCR3 = __readcr3();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%cr3, %0\t\n" : "=r" (uCR3));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %%cr3, %0\t\n" : "=r" (uCR3));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, cr3
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uCR3], rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, cr3
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uCR3], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uCR3;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Sets the CR3 register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uCR3 New CR3 value.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMSetCR3(RTCCUINTREG uCR3);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMSetCR3(RTCCUINTREG uCR3)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __writecr3(uCR3);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %0, %%cr3\n\t" : : "r" (uCR3));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %0, %%cr3\n\t" : : "r" (uCR3));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [uCR3]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov cr3, rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uCR3]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov cr3, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Reloads the CR3 register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMReloadCR3(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMReloadCR3(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __writecr3(__readcr3());
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG u;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%cr3, %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "movq %0, %%cr3\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=r" (u));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %%cr3, %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "movl %0, %%cr3\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=r" (u));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, cr3
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov cr3, rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, cr3
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov cr3, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get cr4.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns cr4.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetCR4(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetCR4(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uCR4;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uCR4 = __readcr4();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%cr4, %0\t\n" : "=r" (uCR4));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %%cr4, %0\t\n" : "=r" (uCR4));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, cr4
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uCR4], rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync push eax /* just in case */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /*mov eax, cr4*/
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0x0f
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0x20
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0xe0
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uCR4], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pop eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uCR4;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Sets the CR4 register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uCR4 New CR4 value.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMSetCR4(RTCCUINTREG uCR4);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMSetCR4(RTCCUINTREG uCR4)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __writecr4(uCR4);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %0, %%cr4\n\t" : : "r" (uCR4));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %0, %%cr4\n\t" : : "r" (uCR4));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [uCR4]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov cr4, rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uCR4]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0x0F
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0x22
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0xE0 /* mov cr4, eax */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Get cr8.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns cr8.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @remark The lock prefix hack for access from non-64-bit modes is NOT used and 0 is returned.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetCR8(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetCR8(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uCR8;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uCR8 = __readcr8();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%cr8, %0\t\n" : "=r" (uCR8));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, cr8
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uCR8], rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uCR8;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else /* !RT_ARCH_AMD64 */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return 0;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif /* !RT_ARCH_AMD64 */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Enables interrupts (EFLAGS.IF).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMIntEnable(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMIntEnable(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm("sti\n");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _enable();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm sti
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Disables interrupts (!EFLAGS.IF).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMIntDisable(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMIntDisable(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm("cli\n");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _disable();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm cli
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Disables interrupts and returns previous xFLAGS.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMIntDisableFlags(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMIntDisableFlags(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG xFlags;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("pushfq\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "cli\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "popq %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=r" (xFlags));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("pushfl\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "cli\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "popl %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=r" (xFlags));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN && !defined(RT_ARCH_X86)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xFlags = ASMGetFlags();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _disable();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pushfd
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync cli
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync pop [xFlags]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return xFlags;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Are interrupts enabled?
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns true / false.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMIntAreEnabled(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uFlags = ASMGetFlags();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uFlags & 0x200 /* X86_EFL_IF */ ? true : false;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Halts the CPU until interrupted.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMHalt(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMHalt(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("hlt\n\t");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync hlt
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Reads a machine specific register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns Register content.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uRegister Register to read.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(uint64_t) ASMRdMsr(uint32_t uRegister);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint64_t) ASMRdMsr(uint32_t uRegister)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTUINT64U u;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("rdmsr\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (u.s.Lo),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "=d" (u.s.Hi)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "c" (uRegister));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync u.u = __readmsr(uRegister);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, [uRegister]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync rdmsr
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [u.s.Lo], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [u.s.Hi], edx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return u.u;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Writes a machine specific register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns Register content.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uRegister Register to write to.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param u64Val Value to write.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMWrMsr(uint32_t uRegister, uint64_t u64Val);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMWrMsr(uint32_t uRegister, uint64_t u64Val)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTUINT64U u;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync u.u = u64Val;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("wrmsr\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync ::"a" (u.s.Lo),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "d" (u.s.Hi),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "c" (uRegister));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __writemsr(uRegister, u.u);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, [uRegister]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov edx, [u.s.Hi]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [u.s.Lo]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync wrmsr
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Reads low part of a machine specific register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns Register content.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uRegister Register to read.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(uint32_t) ASMRdMsr_Low(uint32_t uRegister);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint32_t) ASMRdMsr_Low(uint32_t uRegister)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t u32;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("rdmsr\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (u32)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "c" (uRegister)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "edx");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync u32 = (uint32_t)__readmsr(uRegister);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, [uRegister]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync rdmsr
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [u32], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return u32;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Reads high part of a machine specific register.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns Register content.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uRegister Register to read.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(uint32_t) ASMRdMsr_High(uint32_t uRegister);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint32_t) ASMRdMsr_High(uint32_t uRegister)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t u32;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("rdmsr\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=d" (u32)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "c" (uRegister)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "eax");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync u32 = (uint32_t)(__readmsr(uRegister) >> 32);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, [uRegister]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync rdmsr
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [u32], edx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return u32;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Gets dr0.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns dr0.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetDR0(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetDR0(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uDR0;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uDR0 = __readdr(0);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%dr0, %0\n\t" : "=r" (uDR0));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %%dr0, %0\n\t" : "=r" (uDR0));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, dr0
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR0], rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, dr0
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR0], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uDR0;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Gets dr1.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns dr1.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetDR1(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetDR1(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uDR1;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uDR1 = __readdr(1);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%dr1, %0\n\t" : "=r" (uDR1));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %%dr1, %0\n\t" : "=r" (uDR1));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, dr1
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR1], rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, dr1
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR1], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uDR1;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Gets dr2.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns dr2.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetDR2(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetDR2(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uDR2;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uDR2 = __readdr(2);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%dr2, %0\n\t" : "=r" (uDR2));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %%dr2, %0\n\t" : "=r" (uDR2));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, dr2
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR2], rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, dr2
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR2], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uDR2;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Gets dr3.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns dr3.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetDR3(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetDR3(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uDR3;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uDR3 = __readdr(3);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%dr3, %0\n\t" : "=r" (uDR3));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %%dr3, %0\n\t" : "=r" (uDR3));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, dr3
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR3], rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, dr3
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR3], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uDR3;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Gets dr6.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns dr6.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetDR6(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetDR6(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uDR6;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uDR6 = __readdr(6);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%dr6, %0\n\t" : "=r" (uDR6));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %%dr6, %0\n\t" : "=r" (uDR6));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, dr6
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR6], rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, dr6
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR6], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uDR6;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Reads and clears DR6.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns DR6.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetAndClearDR6(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetAndClearDR6(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uDR6;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uDR6 = __readdr(6);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __writedr(6, 0xffff0ff0U); /* 31-16 and 4-11 are 1's, 12 and 63-31 are zero. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uNewValue = 0xffff0ff0U;/* 31-16 and 4-11 are 1's, 12 and 63-31 are zero. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%dr6, %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "movq %1, %%dr6\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=r" (uDR6)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "r" (uNewValue));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %%dr6, %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "movl %1, %%dr6\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=r" (uDR6)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "r" (uNewValue));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, dr6
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR6], rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rcx, rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, 0ffff0ff0h; /* 31-16 and 4-11 are 1's, 12 and 63-31 are zero. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr6, rcx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, dr6
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR6], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, 0ffff0ff0h; /* 31-16 and 4-11 are 1's, 12 is zero. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr6, ecx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uDR6;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Gets dr7.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns dr7.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(RTCCUINTREG) ASMGetDR7(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(RTCCUINTREG) ASMGetDR7(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync RTCCUINTREG uDR7;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uDR7 = __readdr(7);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %%dr7, %0\n\t" : "=r" (uDR7));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %%dr7, %0\n\t" : "=r" (uDR7));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, dr7
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR7], rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, dr7
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [uDR7], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return uDR7;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Sets dr0.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uDRVal Debug register value to write
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMSetDR0(RTCCUINTREG uDRVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMSetDR0(RTCCUINTREG uDRVal)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __writedr(0, uDRVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %0, %%dr0\n\t" : : "r" (uDRVal));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %0, %%dr0\n\t" : : "r" (uDRVal));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [uDRVal]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr0, rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uDRVal]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr0, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Sets dr1.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uDRVal Debug register value to write
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMSetDR1(RTCCUINTREG uDRVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMSetDR1(RTCCUINTREG uDRVal)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __writedr(1, uDRVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %0, %%dr1\n\t" : : "r" (uDRVal));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %0, %%dr1\n\t" : : "r" (uDRVal));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [uDRVal]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr1, rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uDRVal]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr1, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Sets dr2.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uDRVal Debug register value to write
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMSetDR2(RTCCUINTREG uDRVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMSetDR2(RTCCUINTREG uDRVal)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __writedr(2, uDRVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %0, %%dr2\n\t" : : "r" (uDRVal));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %0, %%dr2\n\t" : : "r" (uDRVal));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [uDRVal]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr2, rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uDRVal]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr2, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Sets dr3.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uDRVal Debug register value to write
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMSetDR3(RTCCUINTREG uDRVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMSetDR3(RTCCUINTREG uDRVal)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __writedr(3, uDRVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %0, %%dr3\n\t" : : "r" (uDRVal));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %0, %%dr3\n\t" : : "r" (uDRVal));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [uDRVal]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr3, rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uDRVal]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr3, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Sets dr6.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uDRVal Debug register value to write
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMSetDR6(RTCCUINTREG uDRVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMSetDR6(RTCCUINTREG uDRVal)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __writedr(6, uDRVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %0, %%dr6\n\t" : : "r" (uDRVal));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %0, %%dr6\n\t" : : "r" (uDRVal));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [uDRVal]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr6, rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uDRVal]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr6, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Sets dr7.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param uDRVal Debug register value to write
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMSetDR7(RTCCUINTREG uDRVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMSetDR7(RTCCUINTREG uDRVal)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __writedr(7, uDRVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movq %0, %%dr7\n\t" : : "r" (uDRVal));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("movl %0, %%dr7\n\t" : : "r" (uDRVal));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [uDRVal]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr7, rax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [uDRVal]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dr7, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Writes a 8-bit unsigned integer to an I/O port, ordered.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param Port I/O port to write to.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param u8 8-bit integer to write.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMOutU8(RTIOPORT Port, uint8_t u8);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMOutU8(RTIOPORT Port, uint8_t u8)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("outb %b1, %w0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync :: "Nd" (Port),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "a" (u8));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __outbyte(Port, u8);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dx, [Port]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov al, [u8]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync out dx, al
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Reads a 8-bit unsigned integer from an I/O port, ordered.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns 8-bit integer.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param Port I/O port to read from.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(uint8_t) ASMInU8(RTIOPORT Port);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint8_t) ASMInU8(RTIOPORT Port)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint8_t u8;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("inb %w1, %b0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (u8)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "Nd" (Port));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync u8 = __inbyte(Port);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dx, [Port]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync in al, dx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [u8], al
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return u8;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Writes a 16-bit unsigned integer to an I/O port, ordered.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param Port I/O port to write to.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param u16 16-bit integer to write.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMOutU16(RTIOPORT Port, uint16_t u16);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMOutU16(RTIOPORT Port, uint16_t u16)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("outw %w1, %w0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync :: "Nd" (Port),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "a" (u16));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __outword(Port, u16);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dx, [Port]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ax, [u16]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync out dx, ax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Reads a 16-bit unsigned integer from an I/O port, ordered.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns 16-bit integer.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param Port I/O port to read from.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(uint16_t) ASMInU16(RTIOPORT Port);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint16_t) ASMInU16(RTIOPORT Port)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint16_t u16;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("inw %w1, %w0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (u16)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "Nd" (Port));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync u16 = __inword(Port);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dx, [Port]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync in ax, dx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [u16], ax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return u16;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Writes a 32-bit unsigned integer to an I/O port, ordered.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param Port I/O port to write to.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param u32 32-bit integer to write.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMOutU32(RTIOPORT Port, uint32_t u32);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMOutU32(RTIOPORT Port, uint32_t u32)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("outl %1, %w0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync :: "Nd" (Port),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "a" (u32));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __outdword(Port, u32);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dx, [Port]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [u32]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync out dx, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Reads a 32-bit unsigned integer from an I/O port, ordered.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @returns 32-bit integer.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param Port I/O port to read from.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(uint32_t) ASMInU32(RTIOPORT Port);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(uint32_t) ASMInU32(RTIOPORT Port)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t u32;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("inl %w1, %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "=a" (u32)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "Nd" (Port));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync u32 = __indword(Port);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dx, [Port]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync in eax, dx
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov [u32], eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return u32;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Writes a string of 8-bit unsigned integer items to an I/O port, ordered.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param Port I/O port to write to.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pau8 Pointer to the string buffer.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param c The number of items to write.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMOutStrU8(RTIOPORT Port, uint8_t const *pau8, size_t c);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMOutStrU8(RTIOPORT Port, uint8_t const *pau8, size_t c)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("rep; outsb\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "+S" (pau8),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "+c" (c)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "d" (Port));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __outbytestring(Port, (unsigned char *)pau8, (unsigned long)c);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dx, [Port]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, [c]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [pau8]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xchg esi, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync rep outsb
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xchg esi, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Reads a string of 8-bit unsigned integer items from an I/O port, ordered.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param Port I/O port to read from.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pau8 Pointer to the string buffer (output).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param c The number of items to read.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMInStrU8(RTIOPORT Port, uint8_t *pau8, size_t c);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMInStrU8(RTIOPORT Port, uint8_t *pau8, size_t c)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("rep; insb\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "+D" (pau8),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "+c" (c)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "d" (Port));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __inbytestring(Port, pau8, (unsigned long)c);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dx, [Port]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, [c]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [pau8]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xchg edi, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync rep insb
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xchg edi, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Writes a string of 16-bit unsigned integer items to an I/O port, ordered.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param Port I/O port to write to.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pau16 Pointer to the string buffer.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param c The number of items to write.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMOutStrU16(RTIOPORT Port, uint16_t const *pau16, size_t c);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMOutStrU16(RTIOPORT Port, uint16_t const *pau16, size_t c)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("rep; outsw\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "+S" (pau16),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "+c" (c)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "d" (Port));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __outwordstring(Port, (unsigned short *)pau16, (unsigned long)c);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dx, [Port]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, [c]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [pau16]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xchg esi, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync rep outsw
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xchg esi, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Reads a string of 16-bit unsigned integer items from an I/O port, ordered.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param Port I/O port to read from.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pau16 Pointer to the string buffer (output).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param c The number of items to read.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMInStrU16(RTIOPORT Port, uint16_t *pau16, size_t c);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMInStrU16(RTIOPORT Port, uint16_t *pau16, size_t c)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("rep; insw\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "+D" (pau16),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "+c" (c)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "d" (Port));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __inwordstring(Port, pau16, (unsigned long)c);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dx, [Port]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, [c]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [pau16]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xchg edi, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync rep insw
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xchg edi, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Writes a string of 32-bit unsigned integer items to an I/O port, ordered.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param Port I/O port to write to.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pau32 Pointer to the string buffer.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param c The number of items to write.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMOutStrU32(RTIOPORT Port, uint32_t const *pau32, size_t c);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMOutStrU32(RTIOPORT Port, uint32_t const *pau32, size_t c)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("rep; outsl\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "+S" (pau32),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "+c" (c)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "d" (Port));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __outdwordstring(Port, (unsigned long *)pau32, (unsigned long)c);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dx, [Port]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, [c]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [pau32]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xchg esi, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync rep outsd
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xchg esi, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Reads a string of 32-bit unsigned integer items from an I/O port, ordered.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param Port I/O port to read from.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pau32 Pointer to the string buffer (output).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param c The number of items to read.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMInStrU32(RTIOPORT Port, uint32_t *pau32, size_t c);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMInStrU32(RTIOPORT Port, uint32_t *pau32, size_t c)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("rep; insl\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "+D" (pau32),
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync "+c" (c)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : "d" (Port));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __indwordstring(Port, (unsigned long *)pau32, (unsigned long)c);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov dx, [Port]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov ecx, [c]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [pau32]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xchg edi, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync rep insd
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync xchg edi, eax
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Invalidate page.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync *
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param pv Address of the page to invalidate.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMInvalidatePage(void *pv);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMInvalidatePage(void *pv)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __invlpg(pv);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("invlpg %0\n\t"
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync : : "m" (*(uint8_t *)pv));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# ifdef RT_ARCH_AMD64
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov rax, [pv]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync invlpg [rax]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mov eax, [pv]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync invlpg [eax]
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Write back the internal caches and invalidate them.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMWriteBackAndInvalidateCaches(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMWriteBackAndInvalidateCaches(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __wbinvd();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# elif RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("wbinvd");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync wbinvd
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Invalidate internal and (perhaps) external caches without first
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * flushing dirty cache lines. Use with extreme care.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_EXTERNAL
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLASM(void) ASMInvalidateInternalCaches(void);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMInvalidateInternalCaches(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__("invd");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync invd
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync# endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Memory load/store fence, waits for any pending writes and reads to complete.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Requires the X86_CPUID_FEATURE_EDX_SSE2 CPUID bit set.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMMemoryFenceSSE2(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__ (".byte 0x0f,0xae,0xf0\n\t");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _mm_mfence();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0x0f
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0xae
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0xf0
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Memory store fence, waits for any writes to complete.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Requires the X86_CPUID_FEATURE_EDX_SSE CPUID bit set.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMWriteFenceSSE(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__ (".byte 0x0f,0xae,0xf8\n\t");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _mm_sfence();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0x0f
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0xae
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0xf8
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/**
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Memory load fence, waits for any pending reads to complete.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Requires the X86_CPUID_FEATURE_EDX_SSE2 CPUID bit set.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsyncDECLINLINE(void) ASMReadFenceSSE2(void)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync{
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if RT_INLINE_ASM_GNU_STYLE
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm__ __volatile__ (".byte 0x0f,0xae,0xe8\n\t");
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#elif RT_INLINE_ASM_USES_INTRIN
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _mm_lfence();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#else
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync __asm
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync {
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0x0f
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0xae
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync _emit 0xe8
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync}
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/** @} */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#endif
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync