summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2003-10-13 19:54:11 -0700
committerSteve Reinhardt <stever@eecs.umich.edu>2003-10-13 19:54:11 -0700
commit8f1855034e925384c88736e26cdcb93135279503 (patch)
tree6b7509785cdb8967825e17a09b23ef374a97085e /arch
parent7646a5a1e09c01b99d58394d05e79435a11be0d6 (diff)
parent60a7bd950b4c3a2b9bffed92f14fdd50f566222c (diff)
downloadgem5-8f1855034e925384c88736e26cdcb93135279503.tar.xz
Merge zizzer:/bk/m5 into isabel.reinhardt.house:/z/stever/bk/m5
--HG-- extra : convert_revision : 8bfe9a5cb1f127b52e4f189eb1193f7d1c93e580
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/arguments.hh7
-rw-r--r--arch/alpha/vtophys.cc100
-rw-r--r--arch/alpha/vtophys.hh3
3 files changed, 107 insertions, 3 deletions
diff --git a/arch/alpha/arguments.hh b/arch/alpha/arguments.hh
index 69c69d0d7..9ac744e17 100644
--- a/arch/alpha/arguments.hh
+++ b/arch/alpha/arguments.hh
@@ -32,8 +32,9 @@
#include <assert.h>
#include "sim/host.hh"
-#include "targetarch/kernel.hh"
+#include "kern/tru64/kernel.hh"
#include "base/refcnt.hh"
+#include "targetarch/vtophys.hh"
class ExecContext;
@@ -129,13 +130,13 @@ class AlphaArguments
template <class T>
operator T *() {
T *buf = (T *)data->alloc(sizeof(T));
- Kernel::CopyData(xc, buf, getArg(), sizeof(T));
+ CopyData(xc, buf, getArg(), sizeof(T));
return buf;
}
operator char *() {
char *buf = data->alloc(2048);
- Kernel::CopyString(xc, buf, getArg(), 2048);
+ CopyString(xc, buf, getArg(), 2048);
return buf;
}
};
diff --git a/arch/alpha/vtophys.cc b/arch/alpha/vtophys.cc
index 5dc0013fc..a1afdb05b 100644
--- a/arch/alpha/vtophys.cc
+++ b/arch/alpha/vtophys.cc
@@ -121,3 +121,103 @@ vtomem(ExecContext *xc, Addr vaddr, size_t len)
Addr paddr = vtophys(xc, vaddr);
return xc->physmem->dma_addr(paddr, len);
}
+
+void
+CopyData(ExecContext *xc, void *dest, Addr vaddr, size_t cplen)
+{
+ Addr paddr;
+ char *dmaaddr;
+ char *dst = (char *)dest;
+ int len;
+
+ paddr = vtophys(xc, vaddr);
+ len = min((int)(ALPHA_PGBYTES - (paddr & PGOFSET)), (int)cplen);
+ dmaaddr = (char *)xc->physmem->dma_addr(paddr, len);
+ assert(dmaaddr);
+
+ memcpy(dst, dmaaddr, len);
+ if (len == cplen)
+ return;
+
+ cplen -= len;
+ dst += len;
+ vaddr += len;
+
+ while (cplen > ALPHA_PGBYTES) {
+ paddr = vtophys(xc, vaddr);
+ dmaaddr = (char *)xc->physmem->dma_addr(paddr, ALPHA_PGBYTES);
+ assert(dmaaddr);
+
+ memcpy(dst, dmaaddr, ALPHA_PGBYTES);
+ cplen -= ALPHA_PGBYTES;
+ dst += ALPHA_PGBYTES;
+ vaddr += ALPHA_PGBYTES;
+ }
+
+ if (cplen > 0) {
+ paddr = vtophys(xc, vaddr);
+ dmaaddr = (char *)xc->physmem->dma_addr(paddr, cplen);
+ assert(dmaaddr);
+
+ memcpy(dst, dmaaddr, cplen);
+ }
+}
+
+void
+CopyString(ExecContext *xc, char *dst, Addr vaddr, size_t maxlen)
+{
+ Addr paddr;
+ char *dmaaddr;
+ int len;
+
+ paddr = vtophys(xc, vaddr);
+ len = min((int)(ALPHA_PGBYTES - (paddr & PGOFSET)), (int)maxlen);
+ dmaaddr = (char *)xc->physmem->dma_addr(paddr, len);
+ assert(dmaaddr);
+
+ char *term = (char *)memchr(dmaaddr, 0, len);
+ if (term)
+ len = term - dmaaddr + 1;
+
+ memcpy(dst, dmaaddr, len);
+
+ if (term || len == maxlen)
+ return;
+
+ maxlen -= len;
+ dst += len;
+ vaddr += len;
+
+ while (maxlen > ALPHA_PGBYTES) {
+ paddr = vtophys(xc, vaddr);
+ dmaaddr = (char *)xc->physmem->dma_addr(paddr, ALPHA_PGBYTES);
+ assert(dmaaddr);
+
+ char *term = (char *)memchr(dmaaddr, 0, ALPHA_PGBYTES);
+ len = term ? (term - dmaaddr + 1) : ALPHA_PGBYTES;
+
+ memcpy(dst, dmaaddr, len);
+ if (term)
+ return;
+
+ maxlen -= ALPHA_PGBYTES;
+ dst += ALPHA_PGBYTES;
+ vaddr += ALPHA_PGBYTES;
+ }
+
+ if (maxlen > 0) {
+ paddr = vtophys(xc, vaddr);
+ dmaaddr = (char *)xc->physmem->dma_addr(paddr, maxlen);
+ assert(dmaaddr);
+
+ char *term = (char *)memchr(dmaaddr, 0, maxlen);
+ len = term ? (term - dmaaddr + 1) : maxlen;
+
+ memcpy(dst, dmaaddr, len);
+
+ maxlen -= len;
+ }
+
+ if (maxlen == 0)
+ dst[maxlen] = '\0';
+}
diff --git a/arch/alpha/vtophys.hh b/arch/alpha/vtophys.hh
index 8d121ec5b..75a589259 100644
--- a/arch/alpha/vtophys.hh
+++ b/arch/alpha/vtophys.hh
@@ -42,5 +42,8 @@ Addr vtophys(PhysicalMemory *xc, Addr vaddr);
Addr vtophys(ExecContext *xc, Addr vaddr);
uint8_t *vtomem(ExecContext *xc, Addr vaddr, size_t len);
+void CopyData(ExecContext *xc, void *dst, Addr vaddr, size_t len);
+void CopyString(ExecContext *xc, char *dst, Addr vaddr, size_t maxlen);
+
#endif // __VTOPHYS_H__