From 0d1618746cdc5ca8749dc62027c39ba7477b2b9a Mon Sep 17 00:00:00 2001 From: hsc Date: Mon, 22 Oct 2012 15:36:09 +0000 Subject: [PATCH] sal/bochs: move register IDs to a separate file This is necessary as a temporary fix: Currently, campaign code cannot use Fail*'s architecture abstractions at all (e.g., we cannot iterate over all existing GP registers). Until this is corrected by separating a concrete backend and architecture information (the latter being usable by a campaign), we now at least can use register IDs. git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1792 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- src/core/sal/bochs/BochsRegister.hpp | 35 +------------------ src/core/sal/bochs/BochsRegisterIDs.hpp | 45 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 src/core/sal/bochs/BochsRegisterIDs.hpp diff --git a/src/core/sal/bochs/BochsRegister.hpp b/src/core/sal/bochs/BochsRegister.hpp index ef276f8e..e71c531a 100644 --- a/src/core/sal/bochs/BochsRegister.hpp +++ b/src/core/sal/bochs/BochsRegister.hpp @@ -2,6 +2,7 @@ #define __BOCHS_REGISTER_HPP__ #include "../Register.hpp" +#include "BochsRegisterIDs.hpp" #include "bochs.h" @@ -57,40 +58,6 @@ public: : BochsRegister(id, width, link, RT_GP) { } }; -/** - * \enum GPRegisterId - * Symbolic identifier to access Bochs' general purpose register - * (within the corresponding GP set), e.g. - * \code - * // Print %eax register data: - * BochsController bc(...); - * cout << bc.getRegisterManager().getSetOfType(RT_GP) - * .getRegister(RID_EAX)->getData(); - * \endcode - */ -enum GPRegisterId { - #if BX_SUPPORT_X86_64 // 64 bit register id's: - RID_RAX = 0, RID_RCX, RID_RDX, RID_RBX, RID_RSP, RID_RBP, RID_RSI, RID_RDI, - RID_R8, RID_R9, RID_R10, RID_R11, RID_R12, RID_R13, RID_R14, RID_R15, - #else // 32 bit register id's: - RID_EAX = 0, RID_ECX, RID_EDX, RID_EBX, RID_ESP, RID_EBP, RID_ESI, RID_EDI, - #endif // common register id's (independent of the current register width): - RID_CAX = 0, RID_CCX, RID_CDX, RID_CBX, RID_CSP, RID_CBP, RID_CSI, RID_CDI, - RID_LAST_GP_ID -}; - -/** - * \enum PCRegisterId - * Symbolic identifier to access Bochs' program counter register. - */ -enum PCRegisterId { RID_PC = RID_LAST_GP_ID, RID_LAST_PC_ID }; - -/** - * \enum FlagsRegisterId - * Symbolic identifier to access Bochs' flags register. - */ -enum FlagsRegisterId { RID_FLAGS = RID_LAST_PC_ID }; - /** * \class BxPCReg * Bochs-specific implementation of the x86 program counter register. diff --git a/src/core/sal/bochs/BochsRegisterIDs.hpp b/src/core/sal/bochs/BochsRegisterIDs.hpp new file mode 100644 index 00000000..7f5eb0ac --- /dev/null +++ b/src/core/sal/bochs/BochsRegisterIDs.hpp @@ -0,0 +1,45 @@ +#ifndef __BOCHS_REGISTER_IDS_HPP__ + #define __BOCHS_REGISTER_IDS_HPP__ + +// FIXME: This should be part of an x86 architecture-specific header, outside +// the bochs/ subdirectory, and be usable from a campaign without an existing +// simulator backend. (Also, iterating over registers should be possible.) + +namespace fail { +/** + * \enum GPRegisterId + * Symbolic identifier to access Bochs' general purpose register + * (within the corresponding GP set), e.g. + * \code + * // Print %eax register data: + * BochsController bc(...); + * cout << bc.getRegisterManager().getSetOfType(RT_GP) + * .getRegister(RID_EAX)->getData(); + * \endcode + */ +enum GPRegisterId { + #if BX_SUPPORT_X86_64 // 64 bit register id's: + RID_RAX = 0, RID_RCX, RID_RDX, RID_RBX, RID_RSP, RID_RBP, RID_RSI, RID_RDI, + RID_R8, RID_R9, RID_R10, RID_R11, RID_R12, RID_R13, RID_R14, RID_R15, + #else // 32 bit register id's: + RID_EAX = 0, RID_ECX, RID_EDX, RID_EBX, RID_ESP, RID_EBP, RID_ESI, RID_EDI, + #endif // common register id's (independent of the current register width): + RID_CAX = 0, RID_CCX, RID_CDX, RID_CBX, RID_CSP, RID_CBP, RID_CSI, RID_CDI, + RID_LAST_GP_ID +}; + +/** + * \enum PCRegisterId + * Symbolic identifier to access Bochs' program counter register. + */ +enum PCRegisterId { RID_PC = RID_LAST_GP_ID, RID_LAST_PC_ID }; + +/** + * \enum FlagsRegisterId + * Symbolic identifier to access Bochs' flags register. + */ +enum FlagsRegisterId { RID_FLAGS = RID_LAST_PC_ID }; + +} + +#endif