summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/alpha/vtophys.cc53
-rw-r--r--arch/alpha/vtophys.hh3
-rw-r--r--kern/tru64/dump_mbuf.cc6
3 files changed, 52 insertions, 10 deletions
diff --git a/arch/alpha/vtophys.cc b/arch/alpha/vtophys.cc
index 7a38b296b..f4b2c7ed3 100644
--- a/arch/alpha/vtophys.cc
+++ b/arch/alpha/vtophys.cc
@@ -133,14 +133,14 @@ vtomem(ExecContext *xc, Addr vaddr, size_t len)
}
void
-CopyData(ExecContext *xc, void *dest, Addr vaddr, size_t cplen)
+CopyOut(ExecContext *xc, void *dest, Addr src, size_t cplen)
{
Addr paddr;
char *dmaaddr;
char *dst = (char *)dest;
int len;
- paddr = vtophys(xc, vaddr);
+ paddr = vtophys(xc, src);
len = min((int)(ALPHA_PGBYTES - (paddr & PGOFSET)), (int)cplen);
dmaaddr = (char *)xc->physmem->dma_addr(paddr, len);
assert(dmaaddr);
@@ -151,21 +151,21 @@ CopyData(ExecContext *xc, void *dest, Addr vaddr, size_t cplen)
cplen -= len;
dst += len;
- vaddr += len;
+ src += len;
while (cplen > ALPHA_PGBYTES) {
- paddr = vtophys(xc, vaddr);
+ paddr = vtophys(xc, src);
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;
+ src += ALPHA_PGBYTES;
}
if (cplen > 0) {
- paddr = vtophys(xc, vaddr);
+ paddr = vtophys(xc, src);
dmaaddr = (char *)xc->physmem->dma_addr(paddr, cplen);
assert(dmaaddr);
@@ -174,6 +174,47 @@ CopyData(ExecContext *xc, void *dest, Addr vaddr, size_t cplen)
}
void
+CopyIn(ExecContext *xc, Addr dest, void *source, size_t cplen)
+{
+ Addr paddr;
+ char *dmaaddr;
+ char *src = (char *)source;
+ int len;
+
+ paddr = vtophys(xc, dest);
+ len = min((int)(ALPHA_PGBYTES - (paddr & PGOFSET)), (int)cplen);
+ dmaaddr = (char *)xc->physmem->dma_addr(paddr, len);
+ assert(dmaaddr);
+
+ memcpy(dmaaddr, src, len);
+ if (len == cplen)
+ return;
+
+ cplen -= len;
+ src += len;
+ dest += len;
+
+ while (cplen > ALPHA_PGBYTES) {
+ paddr = vtophys(xc, dest);
+ dmaaddr = (char *)xc->physmem->dma_addr(paddr, ALPHA_PGBYTES);
+ assert(dmaaddr);
+
+ memcpy(dmaaddr, src, ALPHA_PGBYTES);
+ cplen -= ALPHA_PGBYTES;
+ src += ALPHA_PGBYTES;
+ dest += ALPHA_PGBYTES;
+ }
+
+ if (cplen > 0) {
+ paddr = vtophys(xc, dest);
+ dmaaddr = (char *)xc->physmem->dma_addr(paddr, cplen);
+ assert(dmaaddr);
+
+ memcpy(dmaaddr, src, cplen);
+ }
+}
+
+void
CopyString(ExecContext *xc, char *dst, Addr vaddr, size_t maxlen)
{
Addr paddr;
diff --git a/arch/alpha/vtophys.hh b/arch/alpha/vtophys.hh
index 497a53f0d..7c22e3371 100644
--- a/arch/alpha/vtophys.hh
+++ b/arch/alpha/vtophys.hh
@@ -44,7 +44,8 @@ Addr vtophys(ExecContext *xc, Addr vaddr);
uint8_t *vtomem(ExecContext *xc, Addr vaddr, size_t len);
uint8_t *ptomem(ExecContext *xc, Addr paddr, size_t len);
-void CopyData(ExecContext *xc, void *dst, Addr vaddr, size_t len);
+void CopyOut(ExecContext *xc, void *dst, Addr src, size_t len);
+void CopyIn(ExecContext *xc, Addr dst, void *src, size_t len);
void CopyString(ExecContext *xc, char *dst, Addr vaddr, size_t maxlen);
#endif // __VTOPHYS_H__
diff --git a/kern/tru64/dump_mbuf.cc b/kern/tru64/dump_mbuf.cc
index 42a2d719c..9121e823d 100644
--- a/kern/tru64/dump_mbuf.cc
+++ b/kern/tru64/dump_mbuf.cc
@@ -46,7 +46,7 @@ DumpMbuf(AlphaArguments args)
Addr addr = (Addr)args;
struct mbuf m;
- CopyData(xc, &m, addr, sizeof(m));
+ CopyOut(xc, &m, addr, sizeof(m));
int count = m.m_pkthdr.len;
@@ -57,7 +57,7 @@ DumpMbuf(AlphaArguments args)
ccprintf(DebugOut(), "m=%#lx, m->m_data=%#lx, m->m_len=%d\n",
addr, m.m_data, m.m_len);
char *buffer = new char[m.m_len];
- CopyData(xc, buffer, m.m_data, m.m_len);
+ CopyOut(xc, buffer, m.m_data, m.m_len);
Trace::rawDump((uint8_t *)buffer, m.m_len);
delete [] buffer;
@@ -65,7 +65,7 @@ DumpMbuf(AlphaArguments args)
if (!m.m_next)
break;
- CopyData(xc, &m, m.m_next, sizeof(m));
+ CopyOut(xc, &m, m.m_next, sizeof(m));
}
}