Author: mcayland Date: Sun Jan 2 01:06:53 2011 New Revision: 1006 URL: http://tracker.coreboot.org/trac/openbios/changeset/1006
Log: Introduce ofmem_arch_io_translation_mode() to allow an OFMEM arch to specify different MMU modes for I/O memory mapped regions.
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 Tested-by: Blue Swirl blauwirbel@gmail.com Reviewed-by: Blue Swirl blauwirbel@gmail.com
Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c trunk/openbios-devel/arch/sparc32/lib.c trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c trunk/openbios-devel/drivers/iommu.c trunk/openbios-devel/include/libopenbios/ofmem.h
Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/ofmem.c Sun Jan 2 01:06:47 2011 (r1005) +++ trunk/openbios-devel/arch/ppc/qemu/ofmem.c Sun Jan 2 01:06:53 2011 (r1006) @@ -239,6 +239,10 @@ 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 */
Modified: trunk/openbios-devel/arch/sparc32/lib.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/lib.c Sun Jan 2 01:06:47 2011 (r1005) +++ trunk/openbios-devel/arch/sparc32/lib.c Sun Jan 2 01:06:53 2011 (r1006) @@ -208,15 +208,7 @@ 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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
Modified: trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sun Jan 2 01:06:47 2011 (r1005) +++ trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sun Jan 2 01:06:53 2011 (r1006) @@ -123,6 +123,11 @@ return SRMMU_REF | SRMMU_CACHE | SRMMU_PRIV; }
+ucell ofmem_arch_io_translation_mode( phys_addr_t phys ) +{ + return SRMMU_REF | SRMMU_PRIV; +} + /************************************************************************/ /* init / cleanup */ /************************************************************************/
Modified: trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sun Jan 2 01:06:47 2011 (r1005) +++ trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sun Jan 2 01:06:53 2011 (r1006) @@ -120,8 +120,11 @@ 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 */
Modified: trunk/openbios-devel/drivers/iommu.c ============================================================================== --- trunk/openbios-devel/drivers/iommu.c Sun Jan 2 01:06:47 2011 (r1005) +++ trunk/openbios-devel/drivers/iommu.c Sun Jan 2 01:06:53 2011 (r1006) @@ -68,7 +68,7 @@ */ 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.
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h ============================================================================== --- trunk/openbios-devel/include/libopenbios/ofmem.h Sun Jan 2 01:06:47 2011 (r1005) +++ trunk/openbios-devel/include/libopenbios/ofmem.h Sun Jan 2 01:06:53 2011 (r1006) @@ -69,6 +69,7 @@ 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);