summaryrefslogtreecommitdiff
path: root/arch/alpha/vtophys.cc
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2003-10-13 16:09:33 -0400
committerNathan Binkert <binkertn@umich.edu>2003-10-13 16:09:33 -0400
commit60a7bd950b4c3a2b9bffed92f14fdd50f566222c (patch)
tree720c4032298c08e94a9fcd4b7aafc98dd947f626 /arch/alpha/vtophys.cc
parentb177f696ff10473d6421af90d740254d523c5f7e (diff)
downloadgem5-60a7bd950b4c3a2b9bffed92f14fdd50f566222c.tar.xz
CopyData and CopyString moved from kernel.cc to vtophys.cc
kernel.cc and kernel.hh moved to kern/tru64 --HG-- extra : convert_revision : 1b9123af03960b602a2d52dfa7b714280f9995aa
Diffstat (limited to 'arch/alpha/vtophys.cc')
-rw-r--r--arch/alpha/vtophys.cc100
1 files changed, 100 insertions, 0 deletions
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';
+}