From 35753cd075d182927b6be7a28c84ff5b2d244807 Mon Sep 17 00:00:00 2001 From: adrian Date: Wed, 5 Dec 2012 12:27:17 +0000 Subject: [PATCH] coding style++, some TODOs added. git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1967 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- src/core/sal/CPU.hpp | 13 +++++-------- src/core/sal/CPUState.hpp | 10 ++++------ src/core/sal/ConcreteCPU.hpp | 2 +- src/core/sal/arm/arch.cc | 6 ++---- src/core/sal/arm/arch.hpp | 16 ++++++---------- src/core/sal/gem5/Gem5ArmCPU.cc | 2 ++ src/core/sal/gem5/Gem5ArmCPU.hpp | 6 +++--- 7 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/core/sal/CPU.hpp b/src/core/sal/CPU.hpp index 4731b7e2..83456b2f 100644 --- a/src/core/sal/CPU.hpp +++ b/src/core/sal/CPU.hpp @@ -1,5 +1,5 @@ #ifndef __CPU_HPP__ - #define __CPU_HPP__ + #define __CPU_HPP__ #include #include @@ -17,8 +17,7 @@ namespace fail { * directly derived from this are especially meant to be usable in campaigns, so they shouldn't * contain any backend specific code. */ -class CPUArchitecture -{ +class CPUArchitecture { public: /** * Retrieves the total number of registers over all homogeneous sets. @@ -54,14 +53,12 @@ public: * Returns the set with register type \a t. The set can be used to * loop over all registers of type \a t. * @param t the type to check for - * @return a pointer to the retrieved register set (if found), NULL - * otherwise + * @return a pointer to the retrieved register set (if found), \c NULL otherwise */ UniformRegisterSet* getRegisterSetOfType(RegisterType t) const; - protected: - std::vector< Register* > m_Registers; - std::vector< UniformRegisterSet* > m_RegisterSubsets; + std::vector m_Registers; + std::vector m_RegisterSubsets; }; } // end-of-namespace: fail diff --git a/src/core/sal/CPUState.hpp b/src/core/sal/CPUState.hpp index aef7bb47..e40b3c56 100644 --- a/src/core/sal/CPUState.hpp +++ b/src/core/sal/CPUState.hpp @@ -1,5 +1,5 @@ #ifndef __CPU_STATE_HPP__ - #define __CPU_STATE_HPP__ + #define __CPU_STATE_HPP__ #include #include @@ -11,11 +11,10 @@ namespace fail { /** * \class CPUArchitecture * This is the base class for the CPU state without any architecture specific additions. It contains - * pure virtual functions for e.g. register acces and have to be overridden in the backend + * pure virtual functions for e.g. register access and have to be overridden in the backend * implementation. */ -class CPUState -{ +class CPUState { public: /** * Gets the content of the passed Register. @@ -57,7 +56,6 @@ public: * @return \c true if sucessfully removed, \c false otherwise (not found) */ bool removeSuppressedInterrupt(unsigned interruptNum); - protected: std::vector m_SuppressedInterrupts; }; @@ -67,4 +65,4 @@ extern int interrupt_to_fire; } // end-of-namespace: fail -#endif +#endif // __CPU_STATE_HPP__ diff --git a/src/core/sal/ConcreteCPU.hpp b/src/core/sal/ConcreteCPU.hpp index 82232e30..5396b64f 100644 --- a/src/core/sal/ConcreteCPU.hpp +++ b/src/core/sal/ConcreteCPU.hpp @@ -1,5 +1,5 @@ #ifndef __CONCRETE_CPU_HPP__ - #define __CONCRETE_CPU_HPP__ + #define __CONCRETE_CPU_HPP__ #if defined BUILD_BOCHS #include "bochs/BochsCPU.hpp" diff --git a/src/core/sal/arm/arch.cc b/src/core/sal/arm/arch.cc index a228f140..95fa7e5a 100644 --- a/src/core/sal/arm/arch.cc +++ b/src/core/sal/arm/arch.cc @@ -12,8 +12,7 @@ void ArmArchitecture::fillRegisterList() { // TODO: Add missing registers // 16x 32-Bit GP Registers - for (int i=0; i<16; i++) - { + for (int i = 0; i < 16; i++) { Register *reg = new Register(i, RT_GP, 32); addRegister(reg); } @@ -22,8 +21,7 @@ void ArmArchitecture::fillRegisterList() ArmArchitecture::~ArmArchitecture() { std::vector< Register* >::iterator it = m_Registers.begin(); - while(it != m_Registers.end()) - { + while (it != m_Registers.end()) { delete *it; it = m_Registers.erase(it); } diff --git a/src/core/sal/arm/arch.hpp b/src/core/sal/arm/arch.hpp index 37c82b27..384f2f3f 100644 --- a/src/core/sal/arm/arch.hpp +++ b/src/core/sal/arm/arch.hpp @@ -1,5 +1,5 @@ #ifndef __ARM_ARCH_HPP__ - #define __ARM_ARCH_HPP__ + #define __ARM_ARCH_HPP__ #include "../CPU.hpp" #include "../CPUState.hpp" @@ -7,21 +7,18 @@ namespace fail { /** * \class ArmArchitecture - * This class adds ARM specific functionality to the base architecture. This can be used for every - * simulator backend that runs on ARM. + * This class adds ARM specific functionality to the base architecture. + * This can be used for every simulator backend that runs on ARM. */ -class ArmArchitecture : public CPUArchitecture -{ +class ArmArchitecture : public CPUArchitecture { public: ArmArchitecture(); ~ArmArchitecture(); - private: void fillRegisterList(); }; -class ArmCPUState : public CPUState -{ +class ArmCPUState : public CPUState { public: virtual regdata_t getRegisterContent(Register* reg) = 0; @@ -34,8 +31,7 @@ public: virtual address_t getLinkRegister() = 0; }; -enum GPRegIndex -{ +enum GPRegIndex { RI_R0, RI_R1, RI_R2, diff --git a/src/core/sal/gem5/Gem5ArmCPU.cc b/src/core/sal/gem5/Gem5ArmCPU.cc index 6a153c66..1b2ccabc 100644 --- a/src/core/sal/gem5/Gem5ArmCPU.cc +++ b/src/core/sal/gem5/Gem5ArmCPU.cc @@ -19,6 +19,7 @@ regdata_t Gem5ArmCPU::getRegisterContent(Register* reg) } // This shouldn't be reached if a valid register is passed + // TODO: assertion? return 0; } @@ -39,6 +40,7 @@ void Gem5ArmCPU::setRegisterContent(Register* reg, regdata_t value) case RT_IP: return setRegisterContent(getRegister(RI_IP), value); } + // TODO: assertion? } address_t Gem5ArmCPU::getInstructionPointer() diff --git a/src/core/sal/gem5/Gem5ArmCPU.hpp b/src/core/sal/gem5/Gem5ArmCPU.hpp index b52556fd..3abef361 100644 --- a/src/core/sal/gem5/Gem5ArmCPU.hpp +++ b/src/core/sal/gem5/Gem5ArmCPU.hpp @@ -1,5 +1,5 @@ #ifndef __GEM5_ARM_CPU_HPP__ - #define __GEM5_ARM_CPU_HPP__ + #define __GEM5_ARM_CPU_HPP__ #include "../arm/arch.hpp" @@ -7,9 +7,9 @@ namespace fail { -class Gem5ArmCPU : public ArmArchitecture, public ArmCPUState -{ +class Gem5ArmCPU : public ArmArchitecture, public ArmCPUState { public: + // TODO: comments Gem5ArmCPU(unsigned int id, System* system) : m_Id(id), m_System(system) {} regdata_t getRegisterContent(Register* reg); void setRegisterContent(Register* reg, regdata_t value);