From 125914a3051535eede128d34cca6a3d601421fc4 Mon Sep 17 00:00:00 2001 From: adrian Date: Thu, 17 Jan 2013 13:41:23 +0000 Subject: [PATCH] BochsRegister.hpp and BochsRegisterIDs.hpp not needed anymore The includes of these headers have already been removed from the experiments. In the current code, the content of the header BochsRegister.hpp is rather simply copied to x86/Architecture.hpp. It is therefore necessary to revisit the code soon (especially the FIXME related to register IDs). Another problem is that there is no generalization of register IDs. Thus, all experiments are currently specific to a concrete architecture (which is not desired). git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@2010 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- src/core/sal/bochs/BochsController.cc | 2 - src/core/sal/bochs/BochsRegister.hpp | 203 ------------------ src/core/sal/bochs/BochsRegisterIDs.hpp | 47 ---- src/core/sal/ovp/OVPController.hpp | 2 +- src/core/sal/x86/Architecture.hpp | 6 +- .../checksum-oostubs/experiment.cc | 1 - src/experiments/cool-checksum/experiment.cc | 1 - .../ecos_kernel_test/experiment.cc | 1 - src/experiments/fault-coverage/experiment.cc | 1 - src/experiments/hsc-simple/experiment.cc | 1 - src/experiments/l4-sys/UDIS86.hpp | 1 - src/experiments/l4-sys/experiment.cc | 1 - src/experiments/nanojpeg/UDIS86.hpp | 1 - src/experiments/nanojpeg/campaign.hpp | 2 +- src/experiments/nanojpeg/udis86_helper.hpp | 2 +- src/experiments/regression-test/experiment.cc | 1 - src/experiments/vezs-example/experiment.cc | 1 - src/experiments/weather-monitor/experiment.cc | 1 - 18 files changed, 5 insertions(+), 270 deletions(-) delete mode 100644 src/core/sal/bochs/BochsRegister.hpp delete mode 100644 src/core/sal/bochs/BochsRegisterIDs.hpp diff --git a/src/core/sal/bochs/BochsController.cc b/src/core/sal/bochs/BochsController.cc index d922f638..f8b7cdb8 100644 --- a/src/core/sal/bochs/BochsController.cc +++ b/src/core/sal/bochs/BochsController.cc @@ -2,8 +2,6 @@ #include "BochsController.hpp" #include "BochsMemory.hpp" -//#include "BochsRegister.hpp" -//#include "../Register.hpp" #include "../SALInst.hpp" #include "../Listener.hpp" diff --git a/src/core/sal/bochs/BochsRegister.hpp b/src/core/sal/bochs/BochsRegister.hpp deleted file mode 100644 index 88c657d6..00000000 --- a/src/core/sal/bochs/BochsRegister.hpp +++ /dev/null @@ -1,203 +0,0 @@ -#if 0 -#ifndef __BOCHS_REGISTER_HPP__ - #define __BOCHS_REGISTER_HPP__ - -#include "../Register.hpp" -#include "BochsRegisterIDs.hpp" - -#include "bochs.h" - -#include -#include - -namespace fail { - -/** - * \class BochsRegister - * Bochs-specific implementation of x86 registers. - */ -class BochsRegister : public Register { -protected: - regdata_t* m_pData; -public: - /** - * Constructs a new register object. - * @param id the global unique id - * @param width width of the register (8, 16, 32 or 64 bit should suffice) - * @param link pointer to bochs interal register memory - * @param t type of the register - */ - BochsRegister(unsigned int id, regwidth_t width, regdata_t* link, RegisterType t) - : Register(id, t, width), m_pData(link) { } - /** - * Retrieves the data of the register. - * @return the current register data - */ - regdata_t getData() { return *m_pData; } - /** - * Sets the content of the register. - * @param data the new register data to be written - */ - void setData(regdata_t data) { *m_pData = data; } -}; - -/** - * \class BxGPReg - * Bochs-specific implementation of x86 general purpose (GP) registers. - */ -class BxGPReg : public BochsRegister { -public: - /** - * Constructs a new general purpose register. - * @param id the global unique id - * @param width width of the register (8, 16, 32 or 64 bit should - * suffice) - * @param link pointer to bochs interal register memory - */ - BxGPReg(unsigned int id, regwidth_t width, regdata_t* link) - : BochsRegister(id, width, link, RT_GP) { } -}; - -/** - * \class BxPCReg - * Bochs-specific implementation of the x86 program counter register. - */ -class BxPCReg : public BochsRegister { -public: - /** - * Constructs a new program counter register. - * @param id the global unique id - * @param width width of the register (8, 16, 32 or 64 bit should - * suffice) - * @param link pointer to bochs internal register memory - */ - BxPCReg(unsigned int id, regwidth_t width, regdata_t* link) - : BochsRegister(id, width, link, RT_PC) { } -}; - -/** - * \class BxFlagsReg - * Bochs-specific implementation of the FLAGS status register. - */ -class BxFlagsReg : public BochsRegister { -public: - /** - * Constructs a new FLAGS status register. The refenced FLAGS are - * allocated as follows: - * -------------------------------------------------- - * 31|30|29|28| 27|26|25|24| 23|22|21|20| 19|18|17|16 - * ==|==|=====| ==|==|==|==| ==|==|==|==| ==|==|==|== - * 0| 0| 0| 0| 0| 0| 0| 0| 0| 0|ID|VP| VF|AC|VM|RF - * - * 15|14|13|12| 11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0 - * ==|==|=====| ==|==|==|==| ==|==|==|==| ==|==|==|== - * 0|NT| IOPL| OF|DF|IF|TF| SF|ZF| 0|AF| 0|PF| 1|CF - * -------------------------------------------------- - * @param id the global unique id - * @param link pointer to bochs internal register memory - */ - BxFlagsReg(unsigned int id, regdata_t* link) - : BochsRegister(id, 32, link, RT_ST) { } - - /** - * Returns \c true if the corresponding flag is set, or \c false - * otherwise. - */ - bool getCarryFlag() const { return BX_CPU(0)->get_CF(); } - bool getParityFlag() const { return BX_CPU(0)->get_PF(); } - bool getZeroFlag() const { return BX_CPU(0)->get_ZF(); } - bool getSignFlag() const { return BX_CPU(0)->get_SF(); } - bool getOverflowFlag() const { return BX_CPU(0)->get_OF(); } - bool getTrapFlag() const { return BX_CPU(0)->get_TF(); } - bool getInterruptFlag() const { return BX_CPU(0)->get_IF(); } - bool getDirectionFlag() const { return BX_CPU(0)->get_DF(); } - unsigned getIOPrivilegeLevel() const { return BX_CPU(0)->get_IOPL(); } - bool getNestedTaskFlag() const { return BX_CPU(0)->get_NT(); } - bool getResumeFlag() const { return BX_CPU(0)->get_RF(); } - bool getVMFlag() const { return BX_CPU(0)->get_VM(); } - bool getAlignmentCheckFlag() const { return BX_CPU(0)->get_AC(); } - bool getVInterruptFlag() const { return BX_CPU(0)->get_VIF(); } - bool getVInterruptPendingFlag() const { return BX_CPU(0)->get_VIP(); } - bool getIdentificationFlag() const { return BX_CPU(0)->get_ID(); } - - /** - * Sets/resets various status FLAGS. - */ - void setCarryFlag(bool bit) { BX_CPU(0)->set_CF(bit); } - void setParityFlag(bool bit) { BX_CPU(0)->set_PF(bit); } - void setZeroFlag(bool bit) { BX_CPU(0)->set_ZF(bit); } - void setSignFlag(bool bit) { BX_CPU(0)->set_SF(bit); } - void setOverflowFlag(bool bit) { BX_CPU(0)->set_OF(bit); } - void setTrapFlag(bool bit) { BX_CPU(0)->set_TF(bit); } - void setInterruptFlag(bool bit) { BX_CPU(0)->set_IF(bit); } - void setDirectionFlag(bool bit) { BX_CPU(0)->set_DF(bit); } - void setIOPrivilegeLevel(unsigned lvl) { BX_CPU(0)->set_IOPL(lvl); } - void setNestedTaskFlag(bool bit) { BX_CPU(0)->set_NT(bit); } - void setResumeFlag(bool bit) { BX_CPU(0)->set_RF(bit); } - void setVMFlag(bool bit) { BX_CPU(0)->set_VM(bit); } - void setAlignmentCheckFlag(bool bit) { BX_CPU(0)->set_AC(bit); } - void setVInterruptFlag(bool bit) { BX_CPU(0)->set_VIF(bit); } - void setVInterruptPendingFlag(bool bit) { BX_CPU(0)->set_VIP(bit); } - void setIdentificationFlag(bool bit) { BX_CPU(0)->set_ID(bit); } - - /** - * Sets the content of the status register. - * @param data the new register data to be written; note that only the - * 32 lower bits are used (bits 32-63 are ignored in 64 bit mode) - */ - void setData(regdata_t data) - { - #ifdef BX_SUPPORT_X86_64 - // We are in 64 bit mode: Just assign the lower 32 bits! - (*m_pData) = ((*m_pData) & 0xFFFFFFFF00000000ULL) | (data & 0xFFFFFFFFULL); - #else - *m_pData = data; - #endif - } -}; - -/** - * \class BochsRegisterManager - * Bochs-specific implementation of the RegisterManager. - */ -class BochsRegisterManager : public RegisterManager { -public: - /** - * Returns the current instruction pointer. - * @return the current eip - */ - address_t getInstructionPointer() - { - return static_cast(getSetOfType(RT_PC)->first()->getData()); - } - /** - * Returns the top address of the stack. - * @return the starting address of the stack - */ - address_t getStackPointer() - { - #if BX_SUPPORT_X86_64 - return static_cast(getRegister(RID_RSP)->getData()); - #else - return static_cast(getRegister(RID_ESP)->getData()); - #endif - } - /** - * Retrieves the base ptr (holding the address of the - * current stack frame). - * @return the base pointer - */ - address_t getBasePointer() - { - #if BX_SUPPORT_X86_64 - return static_cast(getRegister(RID_RBP)->getData()); - #else - return static_cast(getRegister(RID_EBP)->getData()); - #endif - } -}; - -} // end-of-namespace: fail - -#endif // __BOCHS_REGISTER_HPP__ -#endif diff --git a/src/core/sal/bochs/BochsRegisterIDs.hpp b/src/core/sal/bochs/BochsRegisterIDs.hpp deleted file mode 100644 index 0296eef4..00000000 --- a/src/core/sal/bochs/BochsRegisterIDs.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#if 0 -#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 -#endif diff --git a/src/core/sal/ovp/OVPController.hpp b/src/core/sal/ovp/OVPController.hpp index 33f1ac13..36641b94 100644 --- a/src/core/sal/ovp/OVPController.hpp +++ b/src/core/sal/ovp/OVPController.hpp @@ -28,7 +28,7 @@ private: // FIXME: Perhaps this should be declared as a static member: unsigned int m_currentRegId; - // NOTE: Constants (such as GPRegisterId in sal/bochs/BochsRegister.hpp) + // NOTE: Constants (such as GPRegisterId in sal/x86/Architecture.hpp) // are much easier to read... public: /** diff --git a/src/core/sal/x86/Architecture.hpp b/src/core/sal/x86/Architecture.hpp index a9ca4813..4d2a0f1b 100644 --- a/src/core/sal/x86/Architecture.hpp +++ b/src/core/sal/x86/Architecture.hpp @@ -5,8 +5,6 @@ #include "../CPUState.hpp" #include "../SALConfig.hpp" -// TODO: Remove BochsRegister.* files ... shouldn't be required anymore... - namespace fail { /** @@ -36,8 +34,8 @@ enum GPRegisterId { RID_CAX = 0, RID_CCX, RID_CDX, RID_CBX, RID_CSP, RID_CBP, RID_CSI, RID_CDI, RID_LAST_GP_ID }; -// FIXME: RID_RSP/RID_ESP/RID_CSP is not a GP register but this definition makes -// it much easier to map the id to Bochs' internal register id. +// FIXME: RID_RSP/RID_ESP/RID_CSP are not GP registers but this definition makes +// it much easier to map the ids to Bochs' (!!!! -> FIXME!) internal register ids. /** * \enum PCRegisterId diff --git a/src/experiments/checksum-oostubs/experiment.cc b/src/experiments/checksum-oostubs/experiment.cc index 89861359..b44a0e15 100644 --- a/src/experiments/checksum-oostubs/experiment.cc +++ b/src/experiments/checksum-oostubs/experiment.cc @@ -12,7 +12,6 @@ #include "sal/SALConfig.hpp" #include "sal/SALInst.hpp" #include "sal/Memory.hpp" -#include "sal/bochs/BochsRegister.hpp" #include "sal/bochs/BochsListener.hpp" #include "sal/Listener.hpp" diff --git a/src/experiments/cool-checksum/experiment.cc b/src/experiments/cool-checksum/experiment.cc index c85325bc..64b910ad 100644 --- a/src/experiments/cool-checksum/experiment.cc +++ b/src/experiments/cool-checksum/experiment.cc @@ -7,7 +7,6 @@ #include "sal/SALConfig.hpp" #include "sal/SALInst.hpp" #include "sal/Memory.hpp" -#include "sal/bochs/BochsRegister.hpp" #include "sal/Listener.hpp" #include "config/FailConfig.hpp" diff --git a/src/experiments/ecos_kernel_test/experiment.cc b/src/experiments/ecos_kernel_test/experiment.cc index 7d6a1bdf..5e9d3105 100644 --- a/src/experiments/ecos_kernel_test/experiment.cc +++ b/src/experiments/ecos_kernel_test/experiment.cc @@ -13,7 +13,6 @@ #include "sal/SALConfig.hpp" #include "sal/SALInst.hpp" #include "sal/Memory.hpp" -#include "sal/bochs/BochsRegister.hpp" #include "sal/bochs/BochsListener.hpp" #include "sal/Listener.hpp" #include "util/ElfReader.hpp" diff --git a/src/experiments/fault-coverage/experiment.cc b/src/experiments/fault-coverage/experiment.cc index 382cd6ad..bfaaad52 100644 --- a/src/experiments/fault-coverage/experiment.cc +++ b/src/experiments/fault-coverage/experiment.cc @@ -6,7 +6,6 @@ #include "experiment.hpp" #include "sal/SALInst.hpp" -#include "sal/bochs/BochsRegister.hpp" #include "util/Logger.hpp" using namespace std; diff --git a/src/experiments/hsc-simple/experiment.cc b/src/experiments/hsc-simple/experiment.cc index 6ebdb834..8d2766b3 100644 --- a/src/experiments/hsc-simple/experiment.cc +++ b/src/experiments/hsc-simple/experiment.cc @@ -3,7 +3,6 @@ #include "experiment.hpp" #include "sal/SALInst.hpp" -#include "sal/bochs/BochsRegister.hpp" #include "sal/Listener.hpp" #include "util/Logger.hpp" #include "config/FailConfig.hpp" diff --git a/src/experiments/l4-sys/UDIS86.hpp b/src/experiments/l4-sys/UDIS86.hpp index 674af421..8a8483de 100644 --- a/src/experiments/l4-sys/UDIS86.hpp +++ b/src/experiments/l4-sys/UDIS86.hpp @@ -3,7 +3,6 @@ #include #include "sal/bochs/BochsController.hpp" -#include "sal/bochs/BochsRegister.hpp" /** * \class Udis86 diff --git a/src/experiments/l4-sys/experiment.cc b/src/experiments/l4-sys/experiment.cc index 64c4b4eb..c704c4da 100644 --- a/src/experiments/l4-sys/experiment.cc +++ b/src/experiments/l4-sys/experiment.cc @@ -17,7 +17,6 @@ #include "sal/SALConfig.hpp" #include "sal/SALInst.hpp" #include "sal/Memory.hpp" -#include "sal/bochs/BochsRegister.hpp" #include "sal/Listener.hpp" #include "config/FailConfig.hpp" diff --git a/src/experiments/nanojpeg/UDIS86.hpp b/src/experiments/nanojpeg/UDIS86.hpp index e4f2e4dc..4025680e 100644 --- a/src/experiments/nanojpeg/UDIS86.hpp +++ b/src/experiments/nanojpeg/UDIS86.hpp @@ -3,7 +3,6 @@ #include #include "sal/bochs/BochsController.hpp" -#include "sal/bochs/BochsRegister.hpp" /** * \class Udis86 diff --git a/src/experiments/nanojpeg/campaign.hpp b/src/experiments/nanojpeg/campaign.hpp index a643c688..73648c9a 100644 --- a/src/experiments/nanojpeg/campaign.hpp +++ b/src/experiments/nanojpeg/campaign.hpp @@ -8,7 +8,7 @@ #include "cpn/Campaign.hpp" #include "comm/ExperimentData.hpp" #include "util/Logger.hpp" -#include "sal/bochs/BochsRegisterIDs.hpp" +#include "sal/x86/Architecture.hpp" #include "nanojpeg.pb.h" class NanoJPEGExperimentData : public fail::ExperimentData { diff --git a/src/experiments/nanojpeg/udis86_helper.hpp b/src/experiments/nanojpeg/udis86_helper.hpp index e0cd8d55..54b64ec0 100644 --- a/src/experiments/nanojpeg/udis86_helper.hpp +++ b/src/experiments/nanojpeg/udis86_helper.hpp @@ -7,7 +7,7 @@ #include #include -#include "sal/bochs/BochsRegisterIDs.hpp" +#include "sal/x86/Architecture.hpp" class Udis86Helper { public: diff --git a/src/experiments/regression-test/experiment.cc b/src/experiments/regression-test/experiment.cc index 746347a6..2907218d 100644 --- a/src/experiments/regression-test/experiment.cc +++ b/src/experiments/regression-test/experiment.cc @@ -8,7 +8,6 @@ #include "sal/Listener.hpp" #include "sal/Memory.hpp" #include "config/FailConfig.hpp" -#include "sal/bochs/BochsRegister.hpp" #include "../plugins/tracing/TracingPlugin.hpp" #include "../plugins/serialoutput/SerialOutput.hpp" diff --git a/src/experiments/vezs-example/experiment.cc b/src/experiments/vezs-example/experiment.cc index a6164baf..164a893d 100644 --- a/src/experiments/vezs-example/experiment.cc +++ b/src/experiments/vezs-example/experiment.cc @@ -14,7 +14,6 @@ #include "sal/Memory.hpp" #include "sal/Listener.hpp" -#include "sal/bochs/BochsRegister.hpp" #include "sal/bochs/BochsListener.hpp" using namespace std; diff --git a/src/experiments/weather-monitor/experiment.cc b/src/experiments/weather-monitor/experiment.cc index d55e70b7..72b17ffc 100644 --- a/src/experiments/weather-monitor/experiment.cc +++ b/src/experiments/weather-monitor/experiment.cc @@ -13,7 +13,6 @@ #include "sal/SALConfig.hpp" #include "sal/SALInst.hpp" #include "sal/Memory.hpp" -#include "sal/bochs/BochsRegister.hpp" #include "sal/bochs/BochsListener.hpp" #include "sal/Listener.hpp"