rename CopyData to CopyOut and implement CopyIn to copy data
from the simulator into the simulatee kern/tru64/dump_mbuf.cc: rename CopyData -> CopyOut --HG-- extra : convert_revision : e3ef27a5762dfc495dcb84a372470464c27557d2
This commit is contained in:
parent
12e8ab2b64
commit
671cff5937
3 changed files with 52 additions and 10 deletions
|
@ -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);
|
||||
|
||||
|
@ -173,6 +173,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)
|
||||
{
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue