Once this is in place, we can switch SPARC32's map_pages() over to use the MMU mode directly to bring it in line with the existing OFMEM API.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk --- openbios-devel/arch/ppc/qemu/ofmem.c | 4 ++++ openbios-devel/arch/sparc32/lib.c | 22 +++++++--------------- openbios-devel/arch/sparc32/ofmem_sparc32.c | 5 +++++ openbios-devel/arch/sparc64/ofmem_sparc64.c | 7 +++++-- openbios-devel/drivers/iommu.c | 2 +- openbios-devel/include/libopenbios/ofmem.h | 1 + 6 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/openbios-devel/arch/ppc/qemu/ofmem.c b/openbios-devel/arch/ppc/qemu/ofmem.c index c0143a4..80fad75 100644 --- a/openbios-devel/arch/ppc/qemu/ofmem.c +++ b/openbios-devel/arch/ppc/qemu/ofmem.c @@ -239,6 +239,10 @@ ucell ofmem_arch_default_translation_mode(phys_addr_t phys) return 0x6a; /* WIm GxPp, I/O */ }
+ucell ofmem_arch_io_translation_mode(phys_addr_t phys) +{ + return 0x6a; /* WIm GxPp, I/O */ +}
/************************************************************************/ /* page fault handler */ diff --git a/openbios-devel/arch/sparc32/lib.c b/openbios-devel/arch/sparc32/lib.c index d5faab3..6847b36 100644 --- a/openbios-devel/arch/sparc32/lib.c +++ b/openbios-devel/arch/sparc32/lib.c @@ -208,15 +208,7 @@ map_pages(phys_addr_t phys, unsigned long virt, pa = find_pte(virt, 1);
pte = SRMMU_ET_PTE | ((phys & PAGE_MASK) >> 4); - - if (mode) { /* I/O */ - pte |= SRMMU_REF; - /* SRMMU cannot make Supervisor-only, but not exectutable */ - pte |= SRMMU_PRIV; - } else { /* memory */ - pte |= SRMMU_REF | SRMMU_CACHE; - pte |= SRMMU_PRIV; /* Supervisor only access */ - } + pte |= mode;
*(uint32_t *)pa = pte;
@@ -244,7 +236,7 @@ map_io(uint64_t pa, int size) if (va == 0) return NULL;
- map_pages(pa, va, npages * PAGE_SIZE, 1); + map_pages(pa, va, npages * PAGE_SIZE, ofmem_arch_io_translation_mode(pa)); return (void *)(va + off); }
@@ -304,7 +296,7 @@ ob_map_pages(void) pa <<= 32; pa |= POP() & 0xffffffff;
- map_pages(pa, va, size, 0); + map_pages(pa, va, size, ofmem_arch_default_translation_mode(pa)); DPRINTF("map-page: va 0x%lx pa 0x%llx size 0x%x\n", va, pa, size); }
@@ -362,7 +354,7 @@ char *obp_dumb_mmap(char *va, int which_io, unsigned int pa, { uint64_t mpa = ((uint64_t)which_io << 32) | (uint64_t)pa;
- map_pages(mpa, (unsigned long)va, size, 0); + map_pages(mpa, (unsigned long)va, size, ofmem_arch_default_translation_mode(mpa)); return va; }
@@ -402,7 +394,7 @@ char *obp_dumb_memalloc(char *va, unsigned int size) DPRINTF("obp_dumb_memalloc req null -> 0x%p\n", va); }
- map_pages(totavail[0].num_bytes, (unsigned long)va, size, 0); + map_pages(totavail[0].num_bytes, (unsigned long)va, size, ofmem_arch_default_translation_mode(totavail[0].num_bytes));
update_memory_properties();
@@ -496,10 +488,10 @@ init_mmu_swift(void) va = (unsigned long)&_start; size = (unsigned long)&_end - (unsigned long)&_start; pa = va2pa(va); - map_pages(pa, va, size, 0); + map_pages(pa, va, size, ofmem_arch_default_translation_mode(pa));
// 1:1 mapping for RAM - map_pages(0, 0, LOWMEMSZ, 0); + map_pages(0, 0, LOWMEMSZ, ofmem_arch_default_translation_mode(0));
/* * Flush cache diff --git a/openbios-devel/arch/sparc32/ofmem_sparc32.c b/openbios-devel/arch/sparc32/ofmem_sparc32.c index 030d62d..bd6f69b 100644 --- a/openbios-devel/arch/sparc32/ofmem_sparc32.c +++ b/openbios-devel/arch/sparc32/ofmem_sparc32.c @@ -123,6 +123,11 @@ ucell ofmem_arch_default_translation_mode( phys_addr_t phys ) return SRMMU_REF | SRMMU_CACHE | SRMMU_PRIV; }
+ucell ofmem_arch_io_translation_mode( phys_addr_t phys ) +{ + return SRMMU_REF | SRMMU_PRIV; +} + /************************************************************************/ /* init / cleanup */ /************************************************************************/ diff --git a/openbios-devel/arch/sparc64/ofmem_sparc64.c b/openbios-devel/arch/sparc64/ofmem_sparc64.c index 0ec8632..6a4fb5e 100644 --- a/openbios-devel/arch/sparc64/ofmem_sparc64.c +++ b/openbios-devel/arch/sparc64/ofmem_sparc64.c @@ -120,8 +120,11 @@ ucell ofmem_arch_default_translation_mode( phys_addr_t phys ) return SPITFIRE_TTE_CP | SPITFIRE_TTE_CV | SPITFIRE_TTE_WRITABLE; }
- - +ucell ofmem_arch_io_translation_mode( phys_addr_t phys ) +{ + /* Writable, not privileged and not locked */ + return SPITFIRE_TTE_CV | SPITFIRE_TTE_WRITABLE; +}
/************************************************************************/ /* init / cleanup */ diff --git a/openbios-devel/drivers/iommu.c b/openbios-devel/drivers/iommu.c index bf3c887..6af5b33 100644 --- a/openbios-devel/drivers/iommu.c +++ b/openbios-devel/drivers/iommu.c @@ -68,7 +68,7 @@ dvma_alloc(int size, unsigned int *pphys) */ mva = (unsigned int) va; mpa = (unsigned int) pa; - map_pages(mpa, mva, npages * PAGE_SIZE, 1); + map_pages(mpa, mva, npages * PAGE_SIZE, ofmem_arch_io_translation_mode(mpa));
/* * Map into IOMMU page table. diff --git a/openbios-devel/include/libopenbios/ofmem.h b/openbios-devel/include/libopenbios/ofmem.h index 2766a95..e350dec 100644 --- a/openbios-devel/include/libopenbios/ofmem.h +++ b/openbios-devel/include/libopenbios/ofmem.h @@ -69,6 +69,7 @@ extern int ofmem_arch_encode_physaddr(ucell *p, phys_addr_t value); extern int ofmem_arch_get_translation_entry_size(void); extern void ofmem_arch_create_translation_entry(ucell *transentry, translation_t *t); extern ucell ofmem_arch_default_translation_mode( phys_addr_t phys ); +extern ucell ofmem_arch_io_translation_mode( phys_addr_t phys ); extern void ofmem_arch_early_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell mode); extern void ofmem_arch_unmap_pages(ucell virt, ucell size);