}
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);
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);
}
}
+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)
{
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__
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;
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;
if (!m.m_next)
break;
- CopyData(xc, &m, m.m_next, sizeof(m));
+ CopyOut(xc, &m, m.m_next, sizeof(m));
}
}