summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2004-02-13 15:36:21 -0500
committerNathan Binkert <binkertn@umich.edu>2004-02-13 15:36:21 -0500
commit8232c9743df13416810316476500d0e13681677e (patch)
tree02d295d452f3fe51c86338d71465fef2eb0959f7
parent5e82f8d84c4d8a8ec4ce914f02328a068ea2cacc (diff)
downloadgem5-8232c9743df13416810316476500d0e13681677e.tar.xz
fix up vtophys a bit
arch/alpha/vtophys.cc: fix up vtophys to deal with translations if there is no ptbr, and to deal with PAL addresses add ptomem which is just a wrapper for dma_addr arch/alpha/vtophys.hh: add ptomem which is a wrapper for dma_addr with the same usage as vtomem --HG-- extra : convert_revision : 1ae22073d400e87b708a4a7ef501124227fc6c39
-rw-r--r--arch/alpha/vtophys.cc29
-rw-r--r--arch/alpha/vtophys.hh1
2 files changed, 19 insertions, 11 deletions
diff --git a/arch/alpha/vtophys.cc b/arch/alpha/vtophys.cc
index a1afdb05b..5e14b06d3 100644
--- a/arch/alpha/vtophys.cc
+++ b/arch/alpha/vtophys.cc
@@ -96,18 +96,19 @@ vtophys(ExecContext *xc, Addr vaddr)
{
Addr ptbr = xc->regs.ipr[AlphaISA::IPR_PALtemp20];
Addr paddr = 0;
- if (vaddr < ALPHA_K0SEG_BASE) {
- DPRINTF(VtoPhys, "vtophys: invalid vaddr %#x", vaddr);
- } else if (vaddr < ALPHA_K1SEG_BASE) {
- paddr = ALPHA_K0SEG_TO_PHYS(vaddr);
+ if (PC_PAL(vaddr)) {
+ paddr = vaddr & ~ULL(1);
+ } else if (!ptbr) {
+ paddr = vaddr;
} else {
- if (!ptbr)
- panic("vtophys: ptbr is not set on virtual lookup");
-
- Addr pte = kernel_pte_lookup(xc->physmem, ptbr, vaddr);
- uint64_t entry = xc->physmem->phys_read_qword(pte);
- if (pte && entry_valid(entry))
- paddr = PMAP_PTE_PA(entry) | (vaddr & PGOFSET);
+ if (vaddr >= ALPHA_K0SEG_BASE && vaddr <= ALPHA_K0SEG_END) {
+ paddr = ALPHA_K0SEG_TO_PHYS(vaddr);
+ } else {
+ Addr pte = kernel_pte_lookup(xc->physmem, ptbr, vaddr);
+ uint64_t entry = xc->physmem->phys_read_qword(pte);
+ if (pte && entry_valid(entry))
+ paddr = PMAP_PTE_PA(entry) | (vaddr & PGOFSET);
+ }
}
DPRINTF(VtoPhys, "vtophys(%#x) -> %#x\n", vaddr, paddr);
@@ -116,6 +117,12 @@ vtophys(ExecContext *xc, Addr vaddr)
}
uint8_t *
+ptomem(ExecContext *xc, Addr paddr, size_t len)
+{
+ return xc->physmem->dma_addr(paddr, len);
+}
+
+uint8_t *
vtomem(ExecContext *xc, Addr vaddr, size_t len)
{
Addr paddr = vtophys(xc, vaddr);
diff --git a/arch/alpha/vtophys.hh b/arch/alpha/vtophys.hh
index 47ee538a6..f5696e9c8 100644
--- a/arch/alpha/vtophys.hh
+++ b/arch/alpha/vtophys.hh
@@ -42,6 +42,7 @@ Addr kernel_pte_lookup(PhysicalMemory *pmem, Addr ptbr, Addr vaddr);
Addr vtophys(PhysicalMemory *xc, Addr vaddr);
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 CopyString(ExecContext *xc, char *dst, Addr vaddr, size_t maxlen);