coding-style++, gem5 code doc added
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@2083 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -161,6 +161,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual Register* first() { return getRegister(0); }
|
virtual Register* first() { return getRegister(0); }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end-of-namespace: fail
|
} // end-of-namespace: fail
|
||||||
|
|
||||||
#endif // __REGISTER_HPP__
|
#endif // __REGISTER_HPP__
|
||||||
|
|||||||
@ -21,7 +21,8 @@ private:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \enum GPRegIndex
|
* \enum GPRegIndex
|
||||||
* TODO.
|
* Defines the general purpose (GP) register identifier for the ARM
|
||||||
|
* plattform. Some of them are just aliases.
|
||||||
*/
|
*/
|
||||||
enum GPRegIndex {
|
enum GPRegIndex {
|
||||||
RI_R0,
|
RI_R0,
|
||||||
|
|||||||
@ -6,6 +6,11 @@
|
|||||||
|
|
||||||
namespace fail {
|
namespace fail {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \class ArmCPUState
|
||||||
|
* This class represents the current state of a ARM based CPU. A final CPU class
|
||||||
|
* need to implement \c ArmCPUState and \c ArmArchitecture.
|
||||||
|
*/
|
||||||
class ArmCPUState : public CPUState {
|
class ArmCPUState : public CPUState {
|
||||||
public:
|
public:
|
||||||
virtual regdata_t getRegisterContent(Register* reg) = 0;
|
virtual regdata_t getRegisterContent(Register* reg) = 0;
|
||||||
|
|||||||
@ -9,15 +9,11 @@ regdata_t Gem5ArmCPU::getRegisterContent(Register* reg)
|
|||||||
if (reg->getIndex() == 15) {
|
if (reg->getIndex() == 15) {
|
||||||
return m_System->getThreadContext(m_Id)->pcState().pc();
|
return m_System->getThreadContext(m_Id)->pcState().pc();
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_System->getThreadContext(m_Id)->readIntReg(reg->getIndex());
|
return m_System->getThreadContext(m_Id)->readIntReg(reg->getIndex());
|
||||||
|
|
||||||
case RT_FP:
|
case RT_FP:
|
||||||
return m_System->getThreadContext(m_Id)->readFloatReg(reg->getIndex());
|
return m_System->getThreadContext(m_Id)->readFloatReg(reg->getIndex());
|
||||||
|
|
||||||
case RT_ST:
|
case RT_ST:
|
||||||
return m_System->getThreadContext(m_Id)->readMiscReg(reg->getIndex());
|
return m_System->getThreadContext(m_Id)->readMiscReg(reg->getIndex());
|
||||||
|
|
||||||
case RT_IP:
|
case RT_IP:
|
||||||
return m_System->getThreadContext(m_Id)->pcState().pc();
|
return m_System->getThreadContext(m_Id)->pcState().pc();
|
||||||
}
|
}
|
||||||
@ -32,15 +28,12 @@ void Gem5ArmCPU::setRegisterContent(Register* reg, regdata_t value)
|
|||||||
switch (reg->getType()) {
|
switch (reg->getType()) {
|
||||||
case RT_GP:
|
case RT_GP:
|
||||||
m_System->getThreadContext(m_Id)->setIntReg(reg->getIndex(), value);
|
m_System->getThreadContext(m_Id)->setIntReg(reg->getIndex(), value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RT_FP:
|
case RT_FP:
|
||||||
m_System->getThreadContext(m_Id)->setFloatReg(reg->getIndex(), value);
|
m_System->getThreadContext(m_Id)->setFloatReg(reg->getIndex(), value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RT_ST:
|
case RT_ST:
|
||||||
return m_System->getThreadContext(m_Id)->setMiscReg(reg->getIndex(), value);
|
return m_System->getThreadContext(m_Id)->setMiscReg(reg->getIndex(), value);
|
||||||
|
|
||||||
case RT_IP:
|
case RT_IP:
|
||||||
return setRegisterContent(getRegister(RI_IP), value);
|
return setRegisterContent(getRegister(RI_IP), value);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,24 +8,66 @@
|
|||||||
|
|
||||||
namespace fail {
|
namespace fail {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \class Gem5ArmCPU
|
||||||
|
*
|
||||||
|
* \c Gem5ArmCPU is the concrete CPU implementation for the gem5 ARM simulator. It
|
||||||
|
* implements the CPU interfaces \c ArmArchitecture and \c ArmCPUState.
|
||||||
|
* \c ArmArchitecture refers to architectural information (e.g. register \a count)
|
||||||
|
* while \c ArmCPUState encapsulates the CPU state (e.g. register \a content).
|
||||||
|
*/
|
||||||
class Gem5ArmCPU : public ArmArchitecture, public ArmCPUState {
|
class Gem5ArmCPU : public ArmArchitecture, public ArmCPUState {
|
||||||
public:
|
public:
|
||||||
// TODO: comments
|
/**
|
||||||
|
* Creates a new gem5 CPU for ARM based targets.
|
||||||
|
* @param id the unique ID of the CPU to be created (the first CPU0 has ID 0)
|
||||||
|
* @param system the gem5 system object
|
||||||
|
*/
|
||||||
Gem5ArmCPU(unsigned int id, System* system) : m_Id(id), m_System(system) { }
|
Gem5ArmCPU(unsigned int id, System* system) : m_Id(id), m_System(system) { }
|
||||||
|
/**
|
||||||
|
* Retrieves the register content from the current gem5 CPU.
|
||||||
|
* @param reg the destination register whose content should be retrieved
|
||||||
|
* @return the content of register \c reg
|
||||||
|
*/
|
||||||
regdata_t getRegisterContent(Register* reg);
|
regdata_t getRegisterContent(Register* reg);
|
||||||
|
/**
|
||||||
|
* Sets the register content for the \a current gem5 CPU.
|
||||||
|
* @param reg the (initialized) register object whose content should be set
|
||||||
|
* @param value the new content of the register \c reg
|
||||||
|
*/
|
||||||
void setRegisterContent(Register* reg, regdata_t value);
|
void setRegisterContent(Register* reg, regdata_t value);
|
||||||
|
/**
|
||||||
|
* Retrieves the current instruction pointer (IP aka program counter, PC for short)
|
||||||
|
* for the current CPU \c this.
|
||||||
|
* @return the current instruction ptr address
|
||||||
|
*/
|
||||||
|
|
||||||
address_t getInstructionPointer();
|
address_t getInstructionPointer();
|
||||||
address_t getStackPointer();
|
address_t getStackPointer();
|
||||||
address_t getLinkRegister();
|
address_t getLinkRegister();
|
||||||
|
|
||||||
unsigned int getId() { return m_Id; }
|
unsigned int getId() { return m_Id; }
|
||||||
|
/**
|
||||||
|
* Retrieves the current stack pointer for the current CPU \c this.
|
||||||
|
* @return the current stack ptr address
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Retrieves the link register (return address when a function returns) for
|
||||||
|
* the current CPU \c this. See
|
||||||
|
* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0211h/ch02s08s01.html
|
||||||
|
* for further information.
|
||||||
|
* @return the current link register address
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Returns the ID of the current CPU.
|
||||||
|
* @return the unique ID of \c this CPU object
|
||||||
|
*/
|
||||||
private:
|
private:
|
||||||
unsigned int m_Id;
|
unsigned int m_Id; //!< the unique ID of this CPU
|
||||||
System* m_System;
|
System* m_System; //!< the gem5 system object
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Gem5ArmCPU ConcreteCPU;
|
typedef Gem5ArmCPU ConcreteCPU; //!< the concrete CPU type for ARM + gem5
|
||||||
|
|
||||||
} // end-of-namespace: fail
|
} // end-of-namespace: fail
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user