MEM: Make all the port proxy members const

This is a trivial patch that merely makes all the member functions of
the port proxies const. There is no good reason why they should not
be, and this change only serves to make it explicit that they are not
modified through their use.
This commit is contained in:
Andreas Hansson 2012-02-29 04:47:51 -05:00
parent 88abdc0fad
commit e5ac647fc9
6 changed files with 40 additions and 40 deletions

View file

@ -68,7 +68,7 @@ FSTranslatingPortProxy::~FSTranslatingPortProxy()
}
void
FSTranslatingPortProxy::readBlob(Addr addr, uint8_t *p, int size)
FSTranslatingPortProxy::readBlob(Addr addr, uint8_t *p, int size) const
{
Addr paddr;
for (ChunkGenerator gen(addr, size, TheISA::PageBytes); !gen.done();
@ -85,7 +85,7 @@ FSTranslatingPortProxy::readBlob(Addr addr, uint8_t *p, int size)
}
void
FSTranslatingPortProxy::writeBlob(Addr addr, uint8_t *p, int size)
FSTranslatingPortProxy::writeBlob(Addr addr, uint8_t *p, int size) const
{
Addr paddr;
for (ChunkGenerator gen(addr, size, TheISA::PageBytes); !gen.done();
@ -102,7 +102,7 @@ FSTranslatingPortProxy::writeBlob(Addr addr, uint8_t *p, int size)
}
void
FSTranslatingPortProxy::memsetBlob(Addr address, uint8_t v, int size)
FSTranslatingPortProxy::memsetBlob(Addr address, uint8_t v, int size) const
{
Addr paddr;
for (ChunkGenerator gen(address, size, TheISA::PageBytes); !gen.done();

View file

@ -84,16 +84,16 @@ class FSTranslatingPortProxy : public PortProxy
/** Version of readblob that translates virt->phys and deals
* with page boundries. */
virtual void readBlob(Addr addr, uint8_t *p, int size);
virtual void readBlob(Addr addr, uint8_t *p, int size) const;
/** Version of writeBlob that translates virt->phys and deals
* with page boundries. */
virtual void writeBlob(Addr addr, uint8_t *p, int size);
virtual void writeBlob(Addr addr, uint8_t *p, int size) const;
/**
* Fill size bytes starting at addr with byte value val.
*/
virtual void memsetBlob(Addr address, uint8_t v, int size);
virtual void memsetBlob(Addr address, uint8_t v, int size) const;
};
void CopyOut(ThreadContext *tc, void *dest, Addr src, size_t cplen);

View file

@ -41,7 +41,7 @@
#include "mem/port_proxy.hh"
void
PortProxy::blobHelper(Addr addr, uint8_t *p, int size, MemCmd cmd)
PortProxy::blobHelper(Addr addr, uint8_t *p, int size, MemCmd cmd) const
{
Request req;
@ -56,7 +56,7 @@ PortProxy::blobHelper(Addr addr, uint8_t *p, int size, MemCmd cmd)
}
void
PortProxy::memsetBlob(Addr addr, uint8_t v, int size)
PortProxy::memsetBlob(Addr addr, uint8_t v, int size) const
{
// quick and dirty...
uint8_t *buf = new uint8_t[size];

View file

@ -88,7 +88,7 @@ class PortProxy
/** The actual physical port used by this proxy. */
Port &_port;
void blobHelper(Addr addr, uint8_t *p, int size, MemCmd cmd);
void blobHelper(Addr addr, uint8_t *p, int size, MemCmd cmd) const;
public:
PortProxy(Port &port) : _port(port) { }
@ -97,31 +97,31 @@ class PortProxy
/**
* Read size bytes memory at address and store in p.
*/
virtual void readBlob(Addr addr, uint8_t* p, int size)
virtual void readBlob(Addr addr, uint8_t* p, int size) const
{ blobHelper(addr, p, size, MemCmd::ReadReq); }
/**
* Write size bytes from p to address.
*/
virtual void writeBlob(Addr addr, uint8_t* p, int size)
virtual void writeBlob(Addr addr, uint8_t* p, int size) const
{ blobHelper(addr, p, size, MemCmd::WriteReq); }
/**
* Fill size bytes starting at addr with byte value val.
*/
virtual void memsetBlob(Addr addr, uint8_t v, int size);
virtual void memsetBlob(Addr addr, uint8_t v, int size) const;
/**
* Read sizeof(T) bytes from address and return as object T.
*/
template <typename T>
T read(Addr address);
T read(Addr address) const;
/**
* Write object T to address. Writes sizeof(T) bytes.
*/
template <typename T>
void write(Addr address, T data);
void write(Addr address, T data) const;
#if THE_ISA != NO_ISA
/**
@ -129,21 +129,21 @@ class PortProxy
* Performs Guest to Host endianness transform.
*/
template <typename T>
T readGtoH(Addr address);
T readGtoH(Addr address) const;
/**
* Write object T to address. Writes sizeof(T) bytes.
* Performs Host to Guest endianness transform.
*/
template <typename T>
void writeHtoG(Addr address, T data);
void writeHtoG(Addr address, T data) const;
#endif
};
template <typename T>
T
PortProxy::read(Addr address)
PortProxy::read(Addr address) const
{
T data;
readBlob(address, (uint8_t*)&data, sizeof(T));
@ -152,7 +152,7 @@ PortProxy::read(Addr address)
template <typename T>
void
PortProxy::write(Addr address, T data)
PortProxy::write(Addr address, T data) const
{
writeBlob(address, (uint8_t*)&data, sizeof(T));
}
@ -160,7 +160,7 @@ PortProxy::write(Addr address, T data)
#if THE_ISA != NO_ISA
template <typename T>
T
PortProxy::readGtoH(Addr address)
PortProxy::readGtoH(Addr address) const
{
T data;
readBlob(address, (uint8_t*)&data, sizeof(T));
@ -169,7 +169,7 @@ PortProxy::readGtoH(Addr address)
template <typename T>
void
PortProxy::writeHtoG(Addr address, T data)
PortProxy::writeHtoG(Addr address, T data) const
{
data = TheISA::htog(data);
writeBlob(address, (uint8_t*)&data, sizeof(T));

View file

@ -63,7 +63,7 @@ SETranslatingPortProxy::~SETranslatingPortProxy()
{ }
bool
SETranslatingPortProxy::tryReadBlob(Addr addr, uint8_t *p, int size)
SETranslatingPortProxy::tryReadBlob(Addr addr, uint8_t *p, int size) const
{
int prevSize = 0;
@ -81,7 +81,7 @@ SETranslatingPortProxy::tryReadBlob(Addr addr, uint8_t *p, int size)
}
void
SETranslatingPortProxy::readBlob(Addr addr, uint8_t *p, int size)
SETranslatingPortProxy::readBlob(Addr addr, uint8_t *p, int size) const
{
if (!tryReadBlob(addr, p, size))
fatal("readBlob(0x%x, ...) failed", addr);
@ -89,7 +89,7 @@ SETranslatingPortProxy::readBlob(Addr addr, uint8_t *p, int size)
bool
SETranslatingPortProxy::tryWriteBlob(Addr addr, uint8_t *p, int size)
SETranslatingPortProxy::tryWriteBlob(Addr addr, uint8_t *p, int size) const
{
int prevSize = 0;
@ -120,14 +120,14 @@ SETranslatingPortProxy::tryWriteBlob(Addr addr, uint8_t *p, int size)
void
SETranslatingPortProxy::writeBlob(Addr addr, uint8_t *p, int size)
SETranslatingPortProxy::writeBlob(Addr addr, uint8_t *p, int size) const
{
if (!tryWriteBlob(addr, p, size))
fatal("writeBlob(0x%x, ...) failed", addr);
}
bool
SETranslatingPortProxy::tryMemsetBlob(Addr addr, uint8_t val, int size)
SETranslatingPortProxy::tryMemsetBlob(Addr addr, uint8_t val, int size) const
{
for (ChunkGenerator gen(addr, size, VMPageSize); !gen.done(); gen.next()) {
Addr paddr;
@ -149,7 +149,7 @@ SETranslatingPortProxy::tryMemsetBlob(Addr addr, uint8_t val, int size)
}
void
SETranslatingPortProxy::memsetBlob(Addr addr, uint8_t val, int size)
SETranslatingPortProxy::memsetBlob(Addr addr, uint8_t val, int size) const
{
if (!tryMemsetBlob(addr, val, size))
fatal("memsetBlob(0x%x, ...) failed", addr);
@ -157,7 +157,7 @@ SETranslatingPortProxy::memsetBlob(Addr addr, uint8_t val, int size)
bool
SETranslatingPortProxy::tryWriteString(Addr addr, const char *str)
SETranslatingPortProxy::tryWriteString(Addr addr, const char *str) const
{
uint8_t c;
@ -177,14 +177,14 @@ SETranslatingPortProxy::tryWriteString(Addr addr, const char *str)
}
void
SETranslatingPortProxy::writeString(Addr addr, const char *str)
SETranslatingPortProxy::writeString(Addr addr, const char *str) const
{
if (!tryWriteString(addr, str))
fatal("writeString(0x%x, ...) failed", addr);
}
bool
SETranslatingPortProxy::tryReadString(std::string &str, Addr addr)
SETranslatingPortProxy::tryReadString(std::string &str, Addr addr) const
{
uint8_t c;
@ -204,7 +204,7 @@ SETranslatingPortProxy::tryReadString(std::string &str, Addr addr)
}
void
SETranslatingPortProxy::readString(std::string &str, Addr addr)
SETranslatingPortProxy::readString(std::string &str, Addr addr) const
{
if (!tryReadString(str, addr))
fatal("readString(0x%x, ...) failed", addr);

View file

@ -83,18 +83,18 @@ class SETranslatingPortProxy : public PortProxy
SETranslatingPortProxy(Port& port, Process* p, AllocType alloc);
virtual ~SETranslatingPortProxy();
bool tryReadBlob(Addr addr, uint8_t *p, int size);
bool tryWriteBlob(Addr addr, uint8_t *p, int size);
bool tryMemsetBlob(Addr addr, uint8_t val, int size);
bool tryWriteString(Addr addr, const char *str);
bool tryReadString(std::string &str, Addr addr);
bool tryReadBlob(Addr addr, uint8_t *p, int size) const;
bool tryWriteBlob(Addr addr, uint8_t *p, int size) const;
bool tryMemsetBlob(Addr addr, uint8_t val, int size) const;
bool tryWriteString(Addr addr, const char *str) const;
bool tryReadString(std::string &str, Addr addr) const;
virtual void readBlob(Addr addr, uint8_t *p, int size);
virtual void writeBlob(Addr addr, uint8_t *p, int size);
virtual void memsetBlob(Addr addr, uint8_t val, int size);
virtual void readBlob(Addr addr, uint8_t *p, int size) const;
virtual void writeBlob(Addr addr, uint8_t *p, int size) const;
virtual void memsetBlob(Addr addr, uint8_t val, int size) const;
void writeString(Addr addr, const char *str);
void readString(std::string &str, Addr addr);
void writeString(Addr addr, const char *str) const;
void readString(std::string &str, Addr addr) const;
};
#endif // __MEM_SE_TRANSLATING_PORT_PROXY_HH__