///////////////////////////////////////////////////////////////////////// // $Id: crregs.h,v 1.2 2007-09-10 16:04:41 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2007 MandrakeSoft S.A. // // MandrakeSoft S.A. // 43, rue d'Aboukir // 75002 Paris - France // http://www.linux-mandrake.com/ // http://www.mandrakesoft.com/ // // 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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(AM, 18); IMPLEMENT_CRREG_ACCESSORS(WP, 16); IMPLEMENT_CRREG_ACCESSORS(CD, 29); IMPLEMENT_CRREG_ACCESSORS(NW, 30); #endif IMPLEMENT_CRREG_ACCESSORS(PG, 31); BX_CPP_INLINE Bit32u getRegister() { return val32; } BX_CPP_INLINE void setRegister(Bit32u val) { val32 = val; } }; #if BX_CPU_LEVEL >= 4 struct bx_cr4_t { Bit32u val32; // 32bit value of register #if BX_SUPPORT_VME 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); BX_CPP_INLINE Bit32u getRegister() { return val32; } BX_CPP_INLINE void setRegister(Bit32u val) { val32 = val; } }; #endif // #if BX_CPU_LEVEL >= 4 #if BX_SUPPORT_VME #define CR4_VME_ENABLED (BX_CPU_THIS_PTR cr4.get_VME()) #else #define CR4_VME_ENABLED (0) #endif #undef IMPLEMENT_CRREG_ACCESSORS #endif