/*
- * Copyright (c) 2011 ARM Limited
+ * Copyright (c) 2011,2013 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* Port object definitions.
*/
+#include "arch/vtophys.hh"
#include "base/chunk_generator.hh"
#include "cpu/base.hh"
#include "cpu/thread_context.hh"
#include "mem/fs_translating_port_proxy.hh"
+#include "sim/system.hh"
using namespace TheISA;
FSTranslatingPortProxy::FSTranslatingPortProxy(ThreadContext *tc)
- : PortProxy(*(tc->getCpuPtr()->getPort("dcache_port"))), _tc(tc)
+ : PortProxy(tc->getCpuPtr()->getDataPort(),
+ tc->getSystemPtr()->cacheLineSize()), _tc(tc)
{
}
-FSTranslatingPortProxy::FSTranslatingPortProxy(Port &port)
- : PortProxy(port), _tc(NULL)
+FSTranslatingPortProxy::FSTranslatingPortProxy(MasterPort &port,
+ unsigned int cacheLineSize)
+ : PortProxy(port, cacheLineSize), _tc(NULL)
{
}
}
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();
}
void
-FSTranslatingPortProxy::writeBlob(Addr addr, uint8_t *p, int size)
+FSTranslatingPortProxy::writeBlob(Addr addr, const uint8_t *p, int size) const
{
Addr paddr;
for (ChunkGenerator gen(addr, size, TheISA::PageBytes); !gen.done();
}
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();
CopyOut(ThreadContext *tc, void *dest, Addr src, size_t cplen)
{
uint8_t *dst = (uint8_t *)dest;
- FSTranslatingPortProxy* vp = tc->getVirtProxy();
-
- vp->readBlob(src, dst, cplen);
+ tc->getVirtProxy().readBlob(src, dst, cplen);
}
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;
- FSTranslatingPortProxy* vp = tc->getVirtProxy();
-
- vp->writeBlob(dest, src, cplen);
+ tc->getVirtProxy().writeBlob(dest, src, cplen);
}
void
CopyStringOut(ThreadContext *tc, char *dst, Addr vaddr, size_t maxlen)
{
- int len = 0;
char *start = dst;
- FSTranslatingPortProxy* vp = tc->getVirtProxy();
-
- do {
- vp->readBlob(vaddr++, (uint8_t*)dst++, 1);
- } while (len < maxlen && start[len++] != 0 );
+ FSTranslatingPortProxy &vp = tc->getVirtProxy();
+
+ bool foundNull = false;
+ while ((dst - start + 1) < maxlen && !foundNull) {
+ vp.readBlob(vaddr++, (uint8_t*)dst, 1);
+ if (*dst == '\0')
+ foundNull = true;
+ dst++;
+ }
- dst[len] = 0;
+ if (!foundNull)
+ *dst = '\0';
}
void
-CopyStringIn(ThreadContext *tc, char *src, Addr vaddr)
+CopyStringIn(ThreadContext *tc, const char *src, Addr vaddr)
{
- FSTranslatingPortProxy* vp = tc->getVirtProxy();
+ FSTranslatingPortProxy &vp = tc->getVirtProxy();
for (ChunkGenerator gen(vaddr, strlen(src), TheISA::PageBytes); !gen.done();
- gen.next())
+ gen.next())
{
- vp->writeBlob(gen.addr(), (uint8_t*)src, gen.size());
+ vp.writeBlob(gen.addr(), (uint8_t*)src, gen.size());
src += gen.size();
}
}