///////////////////////////////////////////////////////////////////////// // $Id: crregs.h,v 1.27 2010-04-29 19:34:32 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (c) 2007-2009 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA B 02110-1301 USA // ///////////////////////////////////////////////////////////////////////// #ifndef BX_CRREGS #define BX_CRREGS struct bx_cr0_t { Bit32u val32; // 32bit value of register // Accessors for all cr0 bitfields. #define IMPLEMENT_CRREG_ACCESSORS(name,bitnum) \ BX_CPP_INLINE bx_bool get_##name () { \ return 1 & (val32 >> bitnum); \ } \ BX_CPP_INLINE void set_##name (Bit8u val) { \ val32 = (val32&~(1<= 4 IMPLEMENT_CRREG_ACCESSORS(ET, 4); IMPLEMENT_CRREG_ACCESSORS(NE, 5); IMPLEMENT_CRREG_ACCESSORS(WP, 16); IMPLEMENT_CRREG_ACCESSORS(AM, 18); IMPLEMENT_CRREG_ACCESSORS(NW, 29); IMPLEMENT_CRREG_ACCESSORS(CD, 30); #endif IMPLEMENT_CRREG_ACCESSORS(PG, 31); BX_CPP_INLINE Bit32u get32() { return val32; } // ET is hardwired bit in CR0 BX_CPP_INLINE void set32(Bit32u val) { val32 = val | 0x10; } }; #if BX_CPU_LEVEL >= 4 #define BX_CR4_VME_MASK (1 << 0) #define BX_CR4_PVI_MASK (1 << 1) #define BX_CR4_TSD_MASK (1 << 2) #define BX_CR4_DE_MASK (1 << 3) #define BX_CR4_PSE_MASK (1 << 4) #define BX_CR4_PAE_MASK (1 << 5) #define BX_CR4_MCE_MASK (1 << 6) #define BX_CR4_PGE_MASK (1 << 7) #define BX_CR4_PCE_MASK (1 << 8) #define BX_CR4_OSFXSR_MASK (1 << 9) #define BX_CR4_OSXMMEXCPT_MASK (1 << 10) #define BX_CR4_VMXE_MASK (1 << 13) #define BX_CR4_SMXE_MASK (1 << 14) #define BX_CR4_PCIDE_MASK (1 << 17) #define BX_CR4_OSXSAVE_MASK (1 << 18) struct bx_cr4_t { Bit32u val32; // 32bit value of register #if BX_CPU_LEVEL >= 5 IMPLEMENT_CRREG_ACCESSORS(VME, 0); IMPLEMENT_CRREG_ACCESSORS(PVI, 1); #endif IMPLEMENT_CRREG_ACCESSORS(TSD, 2); IMPLEMENT_CRREG_ACCESSORS(DE, 3); IMPLEMENT_CRREG_ACCESSORS(PSE, 4); IMPLEMENT_CRREG_ACCESSORS(PAE, 5); IMPLEMENT_CRREG_ACCESSORS(MCE, 6); IMPLEMENT_CRREG_ACCESSORS(PGE, 7); IMPLEMENT_CRREG_ACCESSORS(PCE, 8); IMPLEMENT_CRREG_ACCESSORS(OSFXSR, 9); IMPLEMENT_CRREG_ACCESSORS(OSXMMEXCPT, 10); #if BX_SUPPORT_VMX IMPLEMENT_CRREG_ACCESSORS(VMXE, 13); #endif #if BX_SUPPORT_X86_64 IMPLEMENT_CRREG_ACCESSORS(PCIDE, 17); #endif #if BX_CPU_LEVEL >= 6 IMPLEMENT_CRREG_ACCESSORS(OSXSAVE, 18); #endif BX_CPP_INLINE Bit32u get32() { return val32; } BX_CPP_INLINE void set32(Bit32u val) { val32 = val; } }; #define BX_CR4_FLUSH_TLB_MASK \ (BX_CR4_PSE_MASK | BX_CR4_PAE_MASK | BX_CR4_PGE_MASK | BX_CR4_PCIDE_MASK) #endif // #if BX_CPU_LEVEL >= 4 #if BX_SUPPORT_X86_64 struct bx_efer_t { Bit32u val32; // 32bit value of register IMPLEMENT_CRREG_ACCESSORS(SCE, 0); IMPLEMENT_CRREG_ACCESSORS(LME, 8); IMPLEMENT_CRREG_ACCESSORS(LMA, 10); IMPLEMENT_CRREG_ACCESSORS(NXE, 11); IMPLEMENT_CRREG_ACCESSORS(FFXSR, 14); BX_CPP_INLINE Bit32u get32() { return val32; } BX_CPP_INLINE void set32(Bit32u val) { val32 = val; } }; #define BX_EFER_LME_MASK (1 << 8) #define BX_EFER_LMA_MASK (1 << 10) #define BX_EFER_SUPPORTED_BITS BX_CONST64(0x00004d01) #endif #if BX_CPU_LEVEL >= 6 struct xcr0_t { Bit32u val32; // 32bit value of register #define BX_XCR0_SUPPORTED_BITS 0x3 #define BX_XCR0_FPU_BIT 0 #define BX_XCR0_FPU_MASK (1<