}
void
-FSTranslatingPortProxy::writeBlob(Addr addr, uint8_t *p, int size) const
+FSTranslatingPortProxy::writeBlob(Addr addr, const uint8_t *p, int size) const
{
Addr paddr;
for (ChunkGenerator gen(addr, size, TheISA::PageBytes); !gen.done();
}
void
-CopyIn(ThreadContext *tc, Addr dest, void *source, size_t cplen)
+CopyIn(ThreadContext *tc, Addr dest, const void *source, size_t cplen)
{
uint8_t *src = (uint8_t *)source;
tc->getVirtProxy().writeBlob(dest, src, cplen);
}
void
-CopyStringIn(ThreadContext *tc, char *src, Addr vaddr)
+CopyStringIn(ThreadContext *tc, const char *src, Addr vaddr)
{
FSTranslatingPortProxy &vp = tc->getVirtProxy();
for (ChunkGenerator gen(vaddr, strlen(src), TheISA::PageBytes); !gen.done();
/** Version of writeBlob that translates virt->phys and deals
* with page boundries. */
- virtual void writeBlob(Addr addr, uint8_t *p, int size) const;
+ virtual void writeBlob(Addr addr, const uint8_t *p, int size) const;
/**
* Fill size bytes starting at addr with byte value val.
};
void CopyOut(ThreadContext *tc, void *dest, Addr src, size_t cplen);
-void CopyIn(ThreadContext *tc, Addr dest, void *source, size_t cplen);
+void CopyIn(ThreadContext *tc, Addr dest, const void *source, size_t cplen);
void CopyStringOut(ThreadContext *tc, char *dst, Addr vaddr, size_t maxlen);
-void CopyStringIn(ThreadContext *tc, char *src, Addr vaddr);
+void CopyStringIn(ThreadContext *tc, const char *src, Addr vaddr);
#endif //__MEM_FS_PORT_PROXY_HH__
flags.set(STATIC_DATA);
}
+ /**
+ * Set the data pointer to the following value that should not be
+ * freed. This version of the function allows the pointer passed
+ * to us to be const. To avoid issues down the line we cast the
+ * constness away, the alternative would be to keep both a const
+ * and non-const data pointer and cleverly choose between
+ * them. Note that this is only allowed for static data.
+ */
+ template <typename T>
+ void
+ dataStaticConst(const T *p)
+ {
+ assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA));
+ data = const_cast<PacketDataPtr>(p);
+ flags.set(STATIC_DATA);
+ }
+
/**
* Set the data pointer to a value that should have delete []
* called on it.
#include "mem/port_proxy.hh"
void
-PortProxy::blobHelper(Addr addr, uint8_t *p, int size, MemCmd cmd) const
+PortProxy::readBlob(Addr addr, uint8_t *p, int size) const
{
Request req;
- for (ChunkGenerator gen(addr, size, _cacheLineSize);
- !gen.done(); gen.next()) {
+ for (ChunkGenerator gen(addr, size, _cacheLineSize); !gen.done();
+ gen.next()) {
req.setPhys(gen.addr(), gen.size(), 0, Request::funcMasterId);
- Packet pkt(&req, cmd);
+ Packet pkt(&req, MemCmd::ReadReq);
pkt.dataStatic(p);
_port.sendFunctional(&pkt);
p += gen.size();
}
}
+void
+PortProxy::writeBlob(Addr addr, const uint8_t *p, int size) const
+{
+ Request req;
+
+ for (ChunkGenerator gen(addr, size, _cacheLineSize); !gen.done();
+ gen.next()) {
+ req.setPhys(gen.addr(), gen.size(), 0, Request::funcMasterId);
+ Packet pkt(&req, MemCmd::WriteReq);
+ pkt.dataStaticConst(p);
+ _port.sendFunctional(&pkt);
+ p += gen.size();
+ }
+}
+
void
PortProxy::memsetBlob(Addr addr, uint8_t v, int size) const
{
uint8_t *buf = new uint8_t[size];
std::memset(buf, v, size);
- blobHelper(addr, buf, size, MemCmd::WriteReq);
+ PortProxy::writeBlob(addr, buf, size);
delete [] buf;
}
/** Granularity of any transactions issued through this proxy. */
const unsigned int _cacheLineSize;
- void blobHelper(Addr addr, uint8_t *p, int size, MemCmd cmd) const;
-
public:
PortProxy(MasterPort &port, unsigned int cacheLineSize) :
_port(port), _cacheLineSize(cacheLineSize) { }
/**
* Read size bytes memory at address and store in p.
*/
- virtual void readBlob(Addr addr, uint8_t* p, int size) const
- { blobHelper(addr, p, size, MemCmd::ReadReq); }
+ virtual void readBlob(Addr addr, uint8_t* p, int size) const;
/**
* Write size bytes from p to address.
*/
- virtual void writeBlob(Addr addr, uint8_t* p, int size) const
- { blobHelper(addr, p, size, MemCmd::WriteReq); }
+ virtual void writeBlob(Addr addr, const uint8_t* p, int size) const;
/**
* Fill size bytes starting at addr with byte value val.
bool
-SETranslatingPortProxy::tryWriteBlob(Addr addr, uint8_t *p, int size) const
+SETranslatingPortProxy::tryWriteBlob(Addr addr, const uint8_t *p,
+ int size) const
{
int prevSize = 0;
void
-SETranslatingPortProxy::writeBlob(Addr addr, uint8_t *p, int size) const
+SETranslatingPortProxy::writeBlob(Addr addr, const uint8_t *p, int size) const
{
if (!tryWriteBlob(addr, p, size))
fatal("writeBlob(0x%x, ...) failed", addr);
virtual ~SETranslatingPortProxy();
bool tryReadBlob(Addr addr, uint8_t *p, int size) const;
- bool tryWriteBlob(Addr addr, uint8_t *p, int size) const;
+ bool tryWriteBlob(Addr addr, const 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) const;
- virtual void writeBlob(Addr addr, uint8_t *p, int size) const;
+ virtual void writeBlob(Addr addr, const uint8_t *p, int size) const;
virtual void memsetBlob(Addr addr, uint8_t val, int size) const;
void writeString(Addr addr, const char *str) const;