Merge zizzer.eecs.umich.edu:/m5/Bitkeeper/m5

into zizzer.eecs.umich.edu:/.automount/ziff/z/binkertn/research/m5/memory

--HG--
extra : convert_revision : 99f5289f4143fb09c84694a51b3394d6699d927a
This commit is contained in:
Nathan Binkert 2004-02-13 15:44:46 -05:00
commit 8c89212fa3
2 changed files with 19 additions and 11 deletions

View file

@ -96,25 +96,32 @@ vtophys(ExecContext *xc, Addr vaddr)
{ {
Addr ptbr = xc->regs.ipr[AlphaISA::IPR_PALtemp20]; Addr ptbr = xc->regs.ipr[AlphaISA::IPR_PALtemp20];
Addr paddr = 0; Addr paddr = 0;
if (vaddr < ALPHA_K0SEG_BASE) { if (PC_PAL(vaddr)) {
DPRINTF(VtoPhys, "vtophys: invalid vaddr %#x", vaddr); paddr = vaddr & ~ULL(1);
} else if (vaddr < ALPHA_K1SEG_BASE) { } else if (!ptbr) {
paddr = vaddr;
} else {
if (vaddr >= ALPHA_K0SEG_BASE && vaddr <= ALPHA_K0SEG_END) {
paddr = ALPHA_K0SEG_TO_PHYS(vaddr); paddr = ALPHA_K0SEG_TO_PHYS(vaddr);
} else { } else {
if (!ptbr)
panic("vtophys: ptbr is not set on virtual lookup");
Addr pte = kernel_pte_lookup(xc->physmem, ptbr, vaddr); Addr pte = kernel_pte_lookup(xc->physmem, ptbr, vaddr);
uint64_t entry = xc->physmem->phys_read_qword(pte); uint64_t entry = xc->physmem->phys_read_qword(pte);
if (pte && entry_valid(entry)) if (pte && entry_valid(entry))
paddr = PMAP_PTE_PA(entry) | (vaddr & PGOFSET); paddr = PMAP_PTE_PA(entry) | (vaddr & PGOFSET);
} }
}
DPRINTF(VtoPhys, "vtophys(%#x) -> %#x\n", vaddr, paddr); DPRINTF(VtoPhys, "vtophys(%#x) -> %#x\n", vaddr, paddr);
return paddr; return paddr;
} }
uint8_t *
ptomem(ExecContext *xc, Addr paddr, size_t len)
{
return xc->physmem->dma_addr(paddr, len);
}
uint8_t * uint8_t *
vtomem(ExecContext *xc, Addr vaddr, size_t len) vtomem(ExecContext *xc, Addr vaddr, size_t len)
{ {

View file

@ -42,6 +42,7 @@ Addr kernel_pte_lookup(PhysicalMemory *pmem, Addr ptbr, Addr vaddr);
Addr vtophys(PhysicalMemory *xc, Addr vaddr); Addr vtophys(PhysicalMemory *xc, Addr vaddr);
Addr vtophys(ExecContext *xc, Addr vaddr); Addr vtophys(ExecContext *xc, Addr vaddr);
uint8_t *vtomem(ExecContext *xc, Addr vaddr, size_t len); 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 CopyData(ExecContext *xc, void *dst, Addr vaddr, size_t len);
void CopyString(ExecContext *xc, char *dst, Addr vaddr, size_t maxlen); void CopyString(ExecContext *xc, char *dst, Addr vaddr, size_t maxlen);