Gem5: Implemented MemoryManager
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1863 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -2,6 +2,9 @@
|
|||||||
#define __GEM5_CONTROLLER_HPP__
|
#define __GEM5_CONTROLLER_HPP__
|
||||||
|
|
||||||
#include "../SimulatorController.hpp"
|
#include "../SimulatorController.hpp"
|
||||||
|
#include "Gem5Memory.hpp"
|
||||||
|
|
||||||
|
#include "sim/system.hh"
|
||||||
|
|
||||||
namespace fail {
|
namespace fail {
|
||||||
|
|
||||||
@ -11,6 +14,13 @@ namespace fail {
|
|||||||
*/
|
*/
|
||||||
class Gem5Controller : public SimulatorController {
|
class Gem5Controller : public SimulatorController {
|
||||||
public:
|
public:
|
||||||
|
void startup()
|
||||||
|
{
|
||||||
|
SimulatorController::startup();
|
||||||
|
|
||||||
|
m_Mem = new Gem5MemoryManager(System::systemList.front());
|
||||||
|
}
|
||||||
|
|
||||||
void onBreakpoint(address_t instrPtr, address_t address_space);
|
void onBreakpoint(address_t instrPtr, address_t address_space);
|
||||||
|
|
||||||
bool save(const std::string &path);
|
bool save(const std::string &path);
|
||||||
|
|||||||
75
src/core/sal/gem5/Gem5Memory.hpp
Normal file
75
src/core/sal/gem5/Gem5Memory.hpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#ifndef __GEM5_MEMORY_HPP__
|
||||||
|
#define __GEM5_MEMORY_HPP__
|
||||||
|
|
||||||
|
#include "../Memory.hpp"
|
||||||
|
|
||||||
|
#include "sim/system.hh"
|
||||||
|
#include "mem/packet.hh"
|
||||||
|
#include "mem/physical.hh"
|
||||||
|
|
||||||
|
//class System;
|
||||||
|
|
||||||
|
namespace fail {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \class Gem5MemoryManager
|
||||||
|
* Represents a concrete implemenation of the abstract
|
||||||
|
* MemoryManager to provide access to gem5's memory pool.
|
||||||
|
*/
|
||||||
|
class Gem5MemoryManager : public MemoryManager {
|
||||||
|
public:
|
||||||
|
Gem5MemoryManager(System* system) : m_System(system), m_Mem(&system->getPhysMem()) {}
|
||||||
|
|
||||||
|
size_t getPoolSize() const { return m_Mem->totalSize(); }
|
||||||
|
host_address_t getStartAddr() const { return 0; }
|
||||||
|
|
||||||
|
byte_t getByte(guest_address_t addr)
|
||||||
|
{
|
||||||
|
Request req(addr, 1, Request::PHYSICAL, 0);
|
||||||
|
|
||||||
|
Packet pkt(&req, MemCmd::ReadReq);
|
||||||
|
byte_t data;
|
||||||
|
pkt.dataStatic(&data);
|
||||||
|
|
||||||
|
m_Mem->functionalAccess(&pkt);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void getBytes(guest_address_t addr, size_t cnt, void *dest)
|
||||||
|
{
|
||||||
|
Request req(addr, cnt, Request::PHYSICAL, 0);
|
||||||
|
|
||||||
|
Packet pkt(&req, MemCmd::ReadReq);
|
||||||
|
pkt.dataStatic(dest);
|
||||||
|
|
||||||
|
m_Mem->functionalAccess(&pkt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setByte(guest_address_t addr, byte_t data)
|
||||||
|
{
|
||||||
|
Request req(addr, 1, Request::PHYSICAL, 0);
|
||||||
|
|
||||||
|
Packet pkt(&req, MemCmd::WriteReq);
|
||||||
|
pkt.dataStatic(&data);
|
||||||
|
|
||||||
|
m_Mem->functionalAccess(&pkt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBytes(guest_address_t addr, size_t cnt, void const *src)
|
||||||
|
{
|
||||||
|
Request req(addr, cnt, Request::PHYSICAL, 0);
|
||||||
|
|
||||||
|
Packet pkt(&req, MemCmd::WriteReq);
|
||||||
|
pkt.dataStatic(src);
|
||||||
|
|
||||||
|
m_Mem->functionalAccess(&pkt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
System* m_System;
|
||||||
|
PhysicalMemory* m_Mem;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end-of-namespace: fail
|
||||||
|
|
||||||
|
#endif // __GEM5_MEMORY_HPP__
|
||||||
Reference in New Issue
Block a user