Index: sys/arm/allwinner/allwinner_machdep.c =================================================================== --- sys/arm/allwinner/allwinner_machdep.c +++ sys/arm/allwinner/allwinner_machdep.c @@ -39,12 +39,12 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -98,7 +98,7 @@ allwinner_lastaddr(platform_t plat) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } /* @@ -115,7 +115,7 @@ allwinner_devmap_init(platform_t plat) { - arm_devmap_add_entry(0x01C00000, 0x00400000); /* 4MB */ + devmap_add_entry(0x01C00000, 0x00400000); /* 4MB */ return (0); } Index: sys/arm/altera/socfpga/socfpga_machdep.c =================================================================== --- sys/arm/altera/socfpga/socfpga_machdep.c +++ sys/arm/altera/socfpga/socfpga_machdep.c @@ -38,12 +38,12 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -51,7 +51,7 @@ platform_lastaddr(void) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } void @@ -77,7 +77,7 @@ { /* UART */ - arm_devmap_add_entry(0xffc00000, 0x100000); + devmap_add_entry(0xffc00000, 0x100000); /* * USB OTG @@ -87,16 +87,16 @@ * It might be caused due to some power save options being turned * on or something else. */ - arm_devmap_add_entry(0xffb00000, 0x100000); + devmap_add_entry(0xffb00000, 0x100000); /* dwmmc */ - arm_devmap_add_entry(0xff700000, 0x100000); + devmap_add_entry(0xff700000, 0x100000); /* scu */ - arm_devmap_add_entry(0xfff00000, 0x100000); + devmap_add_entry(0xfff00000, 0x100000); /* FPGA memory window, 256MB */ - arm_devmap_add_entry(0xd0000000, 0x10000000); + devmap_add_entry(0xd0000000, 0x10000000); return (0); } Index: sys/arm/amlogic/aml8726/aml8726_machdep.c =================================================================== --- sys/arm/amlogic/aml8726/aml8726_machdep.c +++ sys/arm/amlogic/aml8726/aml8726_machdep.c @@ -35,13 +35,13 @@ #include #include #include +#include #include #include #include #include -#include #include #include #include @@ -85,7 +85,7 @@ platform_lastaddr(void) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } void @@ -108,7 +108,7 @@ * and platform_gpio_init during which printf can't be used. */ aml8726_aobus_kva_base = - (vm_offset_t)arm_devmap_ptov(0xc8100000, 0x100000); + (vm_offset_t)devmap_ptov(0xc8100000, 0x100000); /* * The hardware mux used by clkmsr is unique to the SoC (though @@ -154,14 +154,14 @@ platform_devmap_init(void) { - arm_devmap_add_entry(0xc1100000, 0x200000); /* cbus */ - arm_devmap_add_entry(0xc4200000, 0x100000); /* pl310 */ - arm_devmap_add_entry(0xc4300000, 0x100000); /* periph */ - arm_devmap_add_entry(0xc8000000, 0x100000); /* apbbus */ - arm_devmap_add_entry(0xc8100000, 0x100000); /* aobus */ - arm_devmap_add_entry(0xc9000000, 0x800000); /* ahbbus */ - arm_devmap_add_entry(0xd9000000, 0x100000); /* ahb */ - arm_devmap_add_entry(0xda000000, 0x100000); /* secbus */ + devmap_add_entry(0xc1100000, 0x200000); /* cbus */ + devmap_add_entry(0xc4200000, 0x100000); /* pl310 */ + devmap_add_entry(0xc4300000, 0x100000); /* periph */ + devmap_add_entry(0xc8000000, 0x100000); /* apbbus */ + devmap_add_entry(0xc8100000, 0x100000); /* aobus */ + devmap_add_entry(0xc9000000, 0x800000); /* ahbbus */ + devmap_add_entry(0xd9000000, 0x100000); /* ahb */ + devmap_add_entry(0xda000000, 0x100000); /* secbus */ return (0); } Index: sys/arm/annapurna/alpine/alpine_machdep.c =================================================================== --- sys/arm/annapurna/alpine/alpine_machdep.c +++ sys/arm/annapurna/alpine/alpine_machdep.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -42,7 +43,6 @@ #include #include /* For trapframe_t, used in */ #include -#include #include #include @@ -128,7 +128,7 @@ platform_devmap_init(void) { alpine_get_devmap_base(&al_devmap_pa, &al_devmap_size); - arm_devmap_add_entry(al_devmap_pa, al_devmap_size); + devmap_add_entry(al_devmap_pa, al_devmap_size); return (0); } Index: sys/arm/arm/bus_space_generic.c =================================================================== --- sys/arm/arm/bus_space_generic.c +++ sys/arm/arm/bus_space_generic.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -51,7 +52,6 @@ #include #include -#include void generic_bs_unimplemented(void) Index: sys/arm/arm/devmap.c =================================================================== --- sys/arm/arm/devmap.c +++ sys/arm/arm/devmap.c @@ -1,333 +0,0 @@ -/*- - * Copyright (c) 2013 Ian Lepore - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -/* - * Routines for mapping device memory. - * - * This is used on both arm and arm64. - */ - -#include "opt_ddb.h" - -#include -#include -#include -#include -#include -#ifdef __arm__ -#include -#endif -#include -#include -#include - -static const struct arm_devmap_entry *devmap_table; -static boolean_t devmap_bootstrap_done = false; - -#if defined(__aarch64__) -#define MAX_VADDR VM_MAX_KERNEL_ADDRESS -#elif defined(__arm__) -#define MAX_VADDR ARM_VECTORS_HIGH -#endif - -/* - * The allocated-kva (akva) devmap table and metadata. Platforms can call - * arm_devmap_add_entry() to add static device mappings to this table using - * automatically allocated virtual addresses carved out of the top of kva space. - * Allocation begins immediately below the ARM_VECTORS_HIGH address. - */ -#define AKVA_DEVMAP_MAX_ENTRIES 32 -static struct arm_devmap_entry akva_devmap_entries[AKVA_DEVMAP_MAX_ENTRIES]; -static u_int akva_devmap_idx; -static vm_offset_t akva_devmap_vaddr = MAX_VADDR; - -#ifdef __aarch64__ -extern int early_boot; -#endif - -/* - * Print the contents of the static mapping table using the provided printf-like - * output function (which will be either printf or db_printf). - */ -static void -devmap_dump_table(int (*prfunc)(const char *, ...)) -{ - const struct arm_devmap_entry *pd; - - if (devmap_table == NULL || devmap_table[0].pd_size == 0) { - prfunc("No static device mappings.\n"); - return; - } - - prfunc("Static device mappings:\n"); - for (pd = devmap_table; pd->pd_size != 0; ++pd) { - prfunc(" 0x%08x - 0x%08x mapped at VA 0x%08x\n", - pd->pd_pa, pd->pd_pa + pd->pd_size - 1, pd->pd_va); - } -} - -/* - * Print the contents of the static mapping table. Used for bootverbose. - */ -void -arm_devmap_print_table() -{ - devmap_dump_table(printf); -} - -/* - * Return the "last" kva address used by the registered devmap table. It's - * actually the lowest address used by the static mappings, i.e., the address of - * the first unusable byte of KVA. - */ -vm_offset_t -arm_devmap_lastaddr() -{ - const struct arm_devmap_entry *pd; - vm_offset_t lowaddr; - - if (akva_devmap_idx > 0) - return (akva_devmap_vaddr); - - lowaddr = MAX_VADDR; - for (pd = devmap_table; pd != NULL && pd->pd_size != 0; ++pd) { - if (lowaddr > pd->pd_va) - lowaddr = pd->pd_va; - } - - return (lowaddr); -} - -/* - * Add an entry to the internal "akva" static devmap table using the given - * physical address and size and a virtual address allocated from the top of - * kva. This automatically registers the akva table on the first call, so all a - * platform has to do is call this routine to install as many mappings as it - * needs and when initarm() calls arm_devmap_bootstrap() it will pick up all the - * entries in the akva table automatically. - */ -void -arm_devmap_add_entry(vm_paddr_t pa, vm_size_t sz) -{ - struct arm_devmap_entry *m; - - if (devmap_bootstrap_done) - panic("arm_devmap_add_entry() after arm_devmap_bootstrap()"); - - if (akva_devmap_idx == (AKVA_DEVMAP_MAX_ENTRIES - 1)) - panic("AKVA_DEVMAP_MAX_ENTRIES is too small"); - - if (akva_devmap_idx == 0) - arm_devmap_register_table(akva_devmap_entries); - - /* - * Allocate virtual address space from the top of kva downwards. If the - * range being mapped is aligned and sized to 1MB boundaries then also - * align the virtual address to the next-lower 1MB boundary so that we - * end up with a nice efficient section mapping. - */ -#ifdef __arm__ - if ((pa & 0x000fffff) == 0 && (sz & 0x000fffff) == 0) { - akva_devmap_vaddr = trunc_1mpage(akva_devmap_vaddr - sz); - } else -#endif - { - akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - sz); - } - m = &akva_devmap_entries[akva_devmap_idx++]; - m->pd_va = akva_devmap_vaddr; - m->pd_pa = pa; - m->pd_size = sz; -} - -/* - * Register the given table as the one to use in arm_devmap_bootstrap(). - */ -void -arm_devmap_register_table(const struct arm_devmap_entry *table) -{ - - devmap_table = table; -} - -/* - * Map all of the static regions in the devmap table, and remember the devmap - * table so the mapdev, ptov, and vtop functions can do lookups later. - * - * If a non-NULL table pointer is given it is used unconditionally, otherwise - * the previously-registered table is used. This smooths transition from legacy - * code that fills in a local table then calls this function passing that table, - * and newer code that uses arm_devmap_register_table() in platform-specific - * code, then lets the common initarm() call this function with a NULL pointer. - */ -void -arm_devmap_bootstrap(vm_offset_t l1pt, const struct arm_devmap_entry *table) -{ - const struct arm_devmap_entry *pd; - - devmap_bootstrap_done = true; - - /* - * If given a table pointer, use it. Otherwise, if a table was - * previously registered, use it. Otherwise, no work to do. - */ - if (table != NULL) - devmap_table = table; - else if (devmap_table == NULL) - return; - - for (pd = devmap_table; pd->pd_size != 0; ++pd) { -#if defined(__arm__) -#if __ARM_ARCH >= 6 - pmap_preboot_map_attr(pd->pd_pa, pd->pd_va, pd->pd_size, - VM_PROT_READ | VM_PROT_WRITE, VM_MEMATTR_DEVICE); -#else - pmap_map_chunk(l1pt, pd->pd_va, pd->pd_pa, pd->pd_size, - VM_PROT_READ | VM_PROT_WRITE, PTE_DEVICE); -#endif -#elif defined(__aarch64__) - pmap_kenter_device(pd->pd_va, pd->pd_size, pd->pd_pa); -#endif - } -} - -/* - * Look up the given physical address in the static mapping data and return the - * corresponding virtual address, or NULL if not found. - */ -void * -arm_devmap_ptov(vm_paddr_t pa, vm_size_t size) -{ - const struct arm_devmap_entry *pd; - - if (devmap_table == NULL) - return (NULL); - - for (pd = devmap_table; pd->pd_size != 0; ++pd) { - if (pa >= pd->pd_pa && pa + size <= pd->pd_pa + pd->pd_size) - return ((void *)(pd->pd_va + (pa - pd->pd_pa))); - } - - return (NULL); -} - -/* - * Look up the given virtual address in the static mapping data and return the - * corresponding physical address, or DEVMAP_PADDR_NOTFOUND if not found. - */ -vm_paddr_t -arm_devmap_vtop(void * vpva, vm_size_t size) -{ - const struct arm_devmap_entry *pd; - vm_offset_t va; - - if (devmap_table == NULL) - return (DEVMAP_PADDR_NOTFOUND); - - va = (vm_offset_t)vpva; - for (pd = devmap_table; pd->pd_size != 0; ++pd) { - if (va >= pd->pd_va && va + size <= pd->pd_va + pd->pd_size) - return ((vm_paddr_t)(pd->pd_pa + (va - pd->pd_va))); - } - - return (DEVMAP_PADDR_NOTFOUND); -} - -/* - * Map a set of physical memory pages into the kernel virtual address space. - * Return a pointer to where it is mapped. - * - * This uses a pre-established static mapping if one exists for the requested - * range, otherwise it allocates kva space and maps the physical pages into it. - * - * This routine is intended to be used for mapping device memory, NOT real - * memory; the mapping type is inherently VM_MEMATTR_DEVICE in - * pmap_kenter_device(). - */ -void * -pmap_mapdev(vm_offset_t pa, vm_size_t size) -{ - vm_offset_t va, offset; - void * rva; - - /* First look in the static mapping table. */ - if ((rva = arm_devmap_ptov(pa, size)) != NULL) - return (rva); - - offset = pa & PAGE_MASK; - pa = trunc_page(pa); - size = round_page(size + offset); - -#ifdef __aarch64__ - if (early_boot) { - akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - size); - va = akva_devmap_vaddr; - KASSERT(va >= VM_MAX_KERNEL_ADDRESS - L2_SIZE, - ("Too many early devmap mappings")); - } else -#endif - va = kva_alloc(size); - if (!va) - panic("pmap_mapdev: Couldn't alloc kernel virtual memory"); - - pmap_kenter_device(va, size, pa); - - return ((void *)(va + offset)); -} - -/* - * Unmap device memory and free the kva space. - */ -void -pmap_unmapdev(vm_offset_t va, vm_size_t size) -{ - vm_offset_t offset; - - /* Nothing to do if we find the mapping in the static table. */ - if (arm_devmap_vtop((void*)va, size) != DEVMAP_PADDR_NOTFOUND) - return; - - offset = va & PAGE_MASK; - va = trunc_page(va); - size = round_page(size + offset); - - pmap_kremove_device(va, size); - kva_free(va, size); -} - -#ifdef DDB -#include - -DB_SHOW_COMMAND(devmap, db_show_devmap) -{ - devmap_dump_table(db_printf); -} - -#endif /* DDB */ - Index: sys/arm/arm/machdep.c =================================================================== --- sys/arm/arm/machdep.c +++ sys/arm/arm/machdep.c @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -100,7 +101,6 @@ #include #include #include -#include #include #include #include @@ -455,7 +455,7 @@ (uintmax_t)arm32_ptob(vm_cnt.v_free_count) / mbyte); if (bootverbose) { arm_physmem_print_tables(); - arm_devmap_print_table(); + devmap_print_table(); } bufinit(); @@ -1692,7 +1692,7 @@ /* Establish static device mappings. */ err_devmap = platform_devmap_init(); - arm_devmap_bootstrap(l1pagetable, NULL); + devmap_bootstrap(l1pagetable, NULL); vm_max_kernel_address = platform_lastaddr(); cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2)) | DOMAIN_CLIENT); @@ -1913,7 +1913,7 @@ /* Establish static device mappings. */ err_devmap = platform_devmap_init(); - arm_devmap_bootstrap(0, NULL); + devmap_bootstrap(0, NULL); vm_max_kernel_address = platform_lastaddr(); /* Index: sys/arm/at91/at91.c =================================================================== --- sys/arm/at91/at91.c +++ sys/arm/at91/at91.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -45,7 +46,6 @@ #include #define _ARM32_BUS_DMA_PRIVATE #include -#include #include #include Index: sys/arm/at91/at91_common.c =================================================================== --- sys/arm/at91/at91_common.c +++ sys/arm/at91/at91_common.c @@ -30,10 +30,10 @@ #include #include #include +#include #include -#include #include #include #include @@ -47,7 +47,7 @@ #include -extern const struct arm_devmap_entry at91_devmap[]; +extern const struct devmap_entry at91_devmap[]; struct fdt_fixup_entry fdt_fixup_table[] = { { NULL, NULL } @@ -91,7 +91,7 @@ platform_lastaddr(void) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } void @@ -106,9 +106,9 @@ platform_devmap_init(void) { -// arm_devmap_add_entry(0xfff00000, 0x00100000); /* 1MB - uart, aic and timers*/ +// devmap_add_entry(0xfff00000, 0x00100000); /* 1MB - uart, aic and timers*/ - arm_devmap_register_table(at91_devmap); + devmap_register_table(at91_devmap); return (0); } Index: sys/arm/at91/at91_machdep.c =================================================================== --- sys/arm/at91/at91_machdep.c +++ sys/arm/at91/at91_machdep.c @@ -71,6 +71,7 @@ #include #include #include +#include #include #include #include @@ -81,7 +82,6 @@ #include #include #include -#include #include #include #include @@ -117,7 +117,7 @@ struct pv_addr kernel_pt_table[NUM_KERNEL_PTS]; /* Static device mappings. */ -const struct arm_devmap_entry at91_devmap[] = { +const struct devmap_entry at91_devmap[] = { /* * Map the critical on-board devices. The interrupt vector at * 0xffff0000 makes it impossible to map them PA == VA, so we map all @@ -552,7 +552,7 @@ VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE); } - arm_devmap_bootstrap(l1pagetable, at91_devmap); + devmap_bootstrap(l1pagetable, at91_devmap); cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2)) | DOMAIN_CLIENT); cpu_setttb(kernel_l1pt.pv_pa); cpu_tlb_flushID(); Index: sys/arm/broadcom/bcm2835/bcm2835_machdep.c =================================================================== --- sys/arm/broadcom/bcm2835/bcm2835_machdep.c +++ sys/arm/broadcom/bcm2835/bcm2835_machdep.c @@ -46,12 +46,12 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -66,7 +66,7 @@ bcm2835_lastaddr(platform_t plat) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } static void @@ -98,7 +98,7 @@ bcm2835_devmap_init(platform_t plat) { - arm_devmap_add_entry(0x20000000, 0x01000000); + devmap_add_entry(0x20000000, 0x01000000); return (0); } #endif @@ -108,7 +108,7 @@ bcm2836_devmap_init(platform_t plat) { - arm_devmap_add_entry(0x3f000000, 0x01000000); + devmap_add_entry(0x3f000000, 0x01000000); return (0); } #endif Index: sys/arm/cavium/cns11xx/econa_machdep.c =================================================================== --- sys/arm/cavium/cns11xx/econa_machdep.c +++ sys/arm/cavium/cns11xx/econa_machdep.c @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -71,7 +72,6 @@ #include #include #include -#include #include #include #include @@ -105,7 +105,7 @@ struct pv_addr kernelstack; /* Static device mappings. */ -static const struct arm_devmap_entry econa_devmap[] = { +static const struct devmap_entry econa_devmap[] = { { /* * This maps DDR SDRAM @@ -263,7 +263,7 @@ VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE); } - arm_devmap_bootstrap(l1pagetable, econa_devmap); + devmap_bootstrap(l1pagetable, econa_devmap); cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT); cpu_setttb(kernel_l1pt.pv_pa); cpu_tlb_flushID(); Index: sys/arm/freescale/fsl_ocotp.c =================================================================== --- sys/arm/freescale/fsl_ocotp.c +++ sys/arm/freescale/fsl_ocotp.c @@ -59,7 +59,7 @@ #include #include #include -#include +#include static uint32_t *ocotp_regs; static vm_size_t ocotp_size; Index: sys/arm/freescale/imx/imx51_machdep.c =================================================================== --- sys/arm/freescale/imx/imx51_machdep.c +++ sys/arm/freescale/imx/imx51_machdep.c @@ -33,11 +33,11 @@ #include #include #include +#include #include #include -#include #include #include @@ -49,7 +49,7 @@ imx51_lastaddr(platform_t plat) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } static int @@ -74,9 +74,9 @@ imx51_devmap_init(platform_t plat) { - arm_devmap_add_entry(0x70000000, 0x00100000); - arm_devmap_add_entry(0x73f00000, 0x00100000); - arm_devmap_add_entry(0x83f00000, 0x00100000); + devmap_add_entry(0x70000000, 0x00100000); + devmap_add_entry(0x73f00000, 0x00100000); + devmap_add_entry(0x83f00000, 0x00100000); return (0); } Index: sys/arm/freescale/imx/imx53_machdep.c =================================================================== --- sys/arm/freescale/imx/imx53_machdep.c +++ sys/arm/freescale/imx/imx53_machdep.c @@ -33,11 +33,11 @@ #include #include #include +#include #include #include -#include #include #include @@ -49,7 +49,7 @@ imx53_lastaddr(platform_t plat) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } static int @@ -74,9 +74,9 @@ imx53_devmap_init(platform_t plat) { - arm_devmap_add_entry(0x50000000, 0x00100000); - arm_devmap_add_entry(0x53f00000, 0x00100000); - arm_devmap_add_entry(0x63f00000, 0x00100000); + devmap_add_entry(0x50000000, 0x00100000); + devmap_add_entry(0x53f00000, 0x00100000); + devmap_add_entry(0x63f00000, 0x00100000); return (0); } Index: sys/arm/freescale/imx/imx6_machdep.c =================================================================== --- sys/arm/freescale/imx/imx6_machdep.c +++ sys/arm/freescale/imx/imx6_machdep.c @@ -33,11 +33,11 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -166,7 +166,7 @@ imx6_lastaddr(platform_t plat) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } static int @@ -220,9 +220,9 @@ const uint32_t IMX6_AIPS2_PHYS = 0x02100000; const uint32_t IMX6_AIPS2_SIZE = 0x00100000; - arm_devmap_add_entry(IMX6_ARMMP_PHYS, IMX6_ARMMP_SIZE); - arm_devmap_add_entry(IMX6_AIPS1_PHYS, IMX6_AIPS1_SIZE); - arm_devmap_add_entry(IMX6_AIPS2_PHYS, IMX6_AIPS2_SIZE); + devmap_add_entry(IMX6_ARMMP_PHYS, IMX6_ARMMP_SIZE); + devmap_add_entry(IMX6_AIPS1_PHYS, IMX6_AIPS1_SIZE); + devmap_add_entry(IMX6_AIPS2_PHYS, IMX6_AIPS2_SIZE); return (0); } @@ -287,7 +287,7 @@ IMX6_ANALOG_DIGPROG_SOCTYPE_SHIFT; /*printf("digprog = 0x%08x\n", digprog);*/ if (hwsoc == HWSOC_MX6DL) { - pcr = arm_devmap_ptov(SCU_CONFIG_PHYSADDR, 4); + pcr = devmap_ptov(SCU_CONFIG_PHYSADDR, 4); if (pcr != NULL) { /*printf("scu config = 0x%08x\n", *pcr);*/ if ((*pcr & 0x03) == 0) { Index: sys/arm/freescale/imx/imx_machdep.c =================================================================== --- sys/arm/freescale/imx/imx_machdep.c +++ sys/arm/freescale/imx/imx_machdep.c @@ -33,13 +33,13 @@ #include #include #include +#include #include #include #include #include -#include #include #include @@ -85,7 +85,7 @@ * control register. The reset happens on the next cycle of the wdog * 32KHz clock, so hang out in a spin loop until the reset takes effect. */ - if ((pcr = arm_devmap_ptov(wdcr_physaddr, sizeof(*pcr))) == NULL) { + if ((pcr = devmap_ptov(wdcr_physaddr, sizeof(*pcr))) == NULL) { printf("cpu_reset() can't find its control register... locking up now."); } else { *pcr &= ~WDOG_CR_SRS; @@ -99,7 +99,7 @@ { volatile uint16_t * psr; - if ((psr = arm_devmap_ptov(wdsr_phys, sizeof(*psr))) == NULL) + if ((psr = devmap_ptov(wdsr_phys, sizeof(*psr))) == NULL) return; last_reset_status = *psr; if (last_reset_status & WDOG_RSR_SFTW) { Index: sys/arm/freescale/vybrid/vf_machdep.c =================================================================== --- sys/arm/freescale/vybrid/vf_machdep.c +++ sys/arm/freescale/vybrid/vf_machdep.c @@ -34,12 +34,12 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -49,7 +49,7 @@ platform_lastaddr(void) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } void @@ -74,7 +74,7 @@ platform_devmap_init(void) { - arm_devmap_add_entry(0x40000000, 0x100000); + devmap_add_entry(0x40000000, 0x100000); return (0); } Index: sys/arm/include/devmap.h =================================================================== --- sys/arm/include/devmap.h +++ sys/arm/include/devmap.h @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 2013 Ian Lepore - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_DEVMAP_H_ -#define _MACHINE_DEVMAP_H_ - -/* - * This structure is used by MD code to describe static mappings of devices - * which are established as part of bringing up the MMU early in the boot. - */ -struct arm_devmap_entry { - vm_offset_t pd_va; /* virtual address */ - vm_paddr_t pd_pa; /* physical address */ - vm_size_t pd_size; /* size of region */ -}; - -/* - * Return the lowest KVA address used in any entry in the registered devmap - * table. This works with whatever table is registered, including the internal - * table used by arm_devmap_add_entry() if that routine was used. Platforms can - * implement platform_lastaddr() by calling this if static device mappings are - * their only use of high KVA space. - */ -vm_offset_t arm_devmap_lastaddr(void); - -/* - * Automatically allocate KVA (from the top of the address space downwards) and - * make static device mapping entries in an internal table. The internal table - * is automatically registered on the first call to this. - */ -void arm_devmap_add_entry(vm_paddr_t pa, vm_size_t sz); - -/* - * Register a platform-local table to be bootstrapped by the generic - * initarm() in arm/machdep.c. This is used by newer code that allocates and - * fills in its own local table but does not have its own initarm() routine. - */ -void arm_devmap_register_table(const struct arm_devmap_entry * _table); - -/* - * Establish mappings for all the entries in the table. This is called - * automatically from the common initarm() in arm/machdep.c, and also from the - * custom initarm() routines in older code. If the table pointer is NULL, this - * will use the table installed previously by arm_devmap_register_table(). - */ -void arm_devmap_bootstrap(vm_offset_t _l1pt, - const struct arm_devmap_entry *_table); - -/* - * Translate between virtual and physical addresses within a region that is - * static-mapped by the devmap code. If the given address range isn't - * static-mapped, then ptov returns NULL and vtop returns DEVMAP_PADDR_NOTFOUND. - * The latter implies that you can't vtop just the last byte of physical address - * space. This is not as limiting as it might sound, because even if a device - * occupies the end of the physical address space, you're only prevented from - * doing vtop for that single byte. If you vtop a size bigger than 1 it works. - */ -#define DEVMAP_PADDR_NOTFOUND ((vm_paddr_t)(-1)) - -void * arm_devmap_ptov(vm_paddr_t _pa, vm_size_t _sz); -vm_paddr_t arm_devmap_vtop(void * _va, vm_size_t _sz); - -/* Print the static mapping table; used for bootverbose output. */ -void arm_devmap_print_table(void); - -#endif Index: sys/arm/include/vmparam.h =================================================================== --- sys/arm/include/vmparam.h +++ sys/arm/include/vmparam.h @@ -172,4 +172,6 @@ #define SFBUF #define SFBUF_MAP +#define DEVMAP_MAX_VADDR ARM_VECTORS_HIGH + #endif /* _MACHINE_VMPARAM_H_ */ Index: sys/arm/lpc/lpc_machdep.c =================================================================== --- sys/arm/lpc/lpc_machdep.c +++ sys/arm/lpc/lpc_machdep.c @@ -45,13 +45,13 @@ #include #include #include +#include #include #include #include #include -#include #include #include @@ -64,7 +64,7 @@ platform_lastaddr(void) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } void @@ -90,13 +90,13 @@ /* * Add a single static device mapping. * The values used were taken from the ranges property of the SoC node in the - * dts file when this code was converted to arm_devmap_add_entry(). + * dts file when this code was converted to devmap_add_entry(). */ int platform_devmap_init(void) { - arm_devmap_add_entry(LPC_DEV_PHYS_BASE, LPC_DEV_SIZE); + devmap_add_entry(LPC_DEV_PHYS_BASE, LPC_DEV_SIZE); return (0); } Index: sys/arm/mv/mv_common.c =================================================================== --- sys/arm/mv/mv_common.c +++ sys/arm/mv/mv_common.c @@ -381,7 +381,7 @@ * Notice: system identifiers are available in the registers range of * PCIE controller, so using this function is only allowed (and * possible) after the internal registers range has been mapped in via - * arm_devmap_bootstrap(). + * devmap_bootstrap(). */ *dev = bus_space_read_4(fdtbus_bs_tag, MV_PCIE_BASE, 0) >> 16; *rev = bus_space_read_4(fdtbus_bs_tag, MV_PCIE_BASE, 8) & 0xff; Index: sys/arm/mv/mv_localbus.c =================================================================== --- sys/arm/mv/mv_localbus.c +++ sys/arm/mv/mv_localbus.c @@ -36,10 +36,10 @@ #include #include #include +#include #include -#include #include #include @@ -384,7 +384,7 @@ } int -fdt_localbus_devmap(phandle_t dt_node, struct arm_devmap_entry *fdt_devmap, +fdt_localbus_devmap(phandle_t dt_node, struct devmap_entry *fdt_devmap, int banks_max_num, int *banks_added) { pcell_t ranges[MV_LOCALBUS_MAX_BANKS * MV_LOCALBUS_MAX_BANK_CELLS]; Index: sys/arm/mv/mv_machdep.c =================================================================== --- sys/arm/mv/mv_machdep.c +++ sys/arm/mv/mv_machdep.c @@ -45,12 +45,12 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -270,12 +270,12 @@ } #define FDT_DEVMAP_MAX (MV_WIN_CPU_MAX + 2) -static struct arm_devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = { +static struct devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = { { 0, 0, 0, } }; static int -platform_sram_devmap(struct arm_devmap_entry *map) +platform_sram_devmap(struct devmap_entry *map) { #if !defined(SOC_MV_ARMADAXP) phandle_t child, root; @@ -318,10 +318,10 @@ * real implementation of this function in arm/mv/mv_pci.c overrides the weak * alias defined here. */ -int mv_default_fdt_pci_devmap(phandle_t node, struct arm_devmap_entry *devmap, +int mv_default_fdt_pci_devmap(phandle_t node, struct devmap_entry *devmap, vm_offset_t io_va, vm_offset_t mem_va); int -mv_default_fdt_pci_devmap(phandle_t node, struct arm_devmap_entry *devmap, +mv_default_fdt_pci_devmap(phandle_t node, struct devmap_entry *devmap, vm_offset_t io_va, vm_offset_t mem_va) { @@ -345,7 +345,7 @@ int i, num_mapped; i = 0; - arm_devmap_register_table(&fdt_devmap[0]); + devmap_register_table(&fdt_devmap[0]); #ifdef SOC_MV_ARMADAXP vm_paddr_t cur_immr_pa; Index: sys/arm/mv/mv_pci.c =================================================================== --- sys/arm/mv/mv_pci.c +++ sys/arm/mv/mv_pci.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -70,7 +71,6 @@ #include "ofw_bus_if.h" #include "pcib_if.h" -#include #include #include @@ -221,7 +221,7 @@ } int -mv_pci_devmap(phandle_t node, struct arm_devmap_entry *devmap, vm_offset_t io_va, +mv_pci_devmap(phandle_t node, struct devmap_entry *devmap, vm_offset_t io_va, vm_offset_t mem_va) { struct mv_pci_range io_space, mem_space; Index: sys/arm/mv/mvvar.h =================================================================== --- sys/arm/mv/mvvar.h +++ sys/arm/mv/mvvar.h @@ -135,10 +135,10 @@ int mv_msi_data(int irq, uint64_t *addr, uint32_t *data); -struct arm_devmap_entry; +struct devmap_entry; -int mv_pci_devmap(phandle_t, struct arm_devmap_entry *, vm_offset_t, +int mv_pci_devmap(phandle_t, struct devmap_entry *, vm_offset_t, vm_offset_t); -int fdt_localbus_devmap(phandle_t, struct arm_devmap_entry *, int, int *); +int fdt_localbus_devmap(phandle_t, struct devmap_entry *, int, int *); #endif /* _MVVAR_H_ */ Index: sys/arm/mv/orion/db88f5xxx.c =================================================================== --- sys/arm/mv/orion/db88f5xxx.c +++ sys/arm/mv/orion/db88f5xxx.c @@ -73,7 +73,7 @@ int platform_pci_get_irq(u_int bus, u_int slot, u_int func, u_int pin); /* Static device mappings. */ -const struct arm_devmap_entry db88f5xxx_devmap[] = { +const struct devmap_entry db88f5xxx_devmap[] = { /* * Map the on-board devices VA == PA so that we can access them * with the MMU on or off. Index: sys/arm/nvidia/tegra124/tegra124_machdep.c =================================================================== --- sys/arm/nvidia/tegra124/tegra124_machdep.c +++ sys/arm/nvidia/tegra124/tegra124_machdep.c @@ -34,11 +34,11 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -84,7 +84,7 @@ tegra124_lastaddr(platform_t plat) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } static int @@ -108,7 +108,7 @@ tegra124_devmap_init(platform_t plat) { - arm_devmap_add_entry(0x70000000, 0x01000000); + devmap_add_entry(0x70000000, 0x01000000); return (0); } Index: sys/arm/nvidia/tegra_pcie.c =================================================================== --- sys/arm/nvidia/tegra_pcie.c +++ sys/arm/nvidia/tegra_pcie.c @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -60,7 +61,6 @@ #include #include -#include #include #include @@ -1688,4 +1688,4 @@ devclass_t pcib_devclass; -DRIVER_MODULE(pcib, simplebus, tegra_pcib_driver, pcib_devclass, 0, 0); \ No newline at end of file +DRIVER_MODULE(pcib, simplebus, tegra_pcib_driver, pcib_devclass, 0, 0); Index: sys/arm/qemu/virt_machdep.c =================================================================== --- sys/arm/qemu/virt_machdep.c +++ sys/arm/qemu/virt_machdep.c @@ -33,11 +33,11 @@ #define _ARM32_BUS_DMA_PRIVATE #include #include +#include #include #include -#include #include #include @@ -70,7 +70,7 @@ virt_lastaddr(platform_t plat) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } /* @@ -80,7 +80,7 @@ virt_devmap_init(platform_t plat) { - arm_devmap_add_entry(0x09000000, 0x100000); /* Uart */ + devmap_add_entry(0x09000000, 0x100000); /* Uart */ return (0); } Index: sys/arm/rockchip/rk30xx_machdep.c =================================================================== --- sys/arm/rockchip/rk30xx_machdep.c +++ sys/arm/rockchip/rk30xx_machdep.c @@ -38,13 +38,13 @@ #include #include #include +#include #include #include #include #include -#include #include #include @@ -56,7 +56,7 @@ platform_lastaddr(void) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } void @@ -86,8 +86,8 @@ platform_devmap_init(void) { - arm_devmap_add_entry(0x10000000, 0x00200000); - arm_devmap_add_entry(0x20000000, 0x00100000); + devmap_add_entry(0x10000000, 0x00200000); + devmap_add_entry(0x20000000, 0x00100000); return (0); } Index: sys/arm/samsung/exynos/exynos5_machdep.c =================================================================== --- sys/arm/samsung/exynos/exynos5_machdep.c +++ sys/arm/samsung/exynos/exynos5_machdep.c @@ -34,12 +34,12 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -47,7 +47,7 @@ platform_lastaddr(void) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } void @@ -73,13 +73,13 @@ { /* CHIP ID */ - arm_devmap_add_entry(0x10000000, 0x100000); + devmap_add_entry(0x10000000, 0x100000); /* UART */ - arm_devmap_add_entry(0x12C00000, 0x100000); + devmap_add_entry(0x12C00000, 0x100000); /* DWMMC */ - arm_devmap_add_entry(0x12200000, 0x100000); + devmap_add_entry(0x12200000, 0x100000); return (0); } Index: sys/arm/ti/ti_machdep.c =================================================================== --- sys/arm/ti/ti_machdep.c +++ sys/arm/ti/ti_machdep.c @@ -44,12 +44,12 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -63,7 +63,7 @@ ti_lastaddr(platform_t plat) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } /* @@ -74,8 +74,8 @@ static int ti_omap4_devmap_init(platform_t plat) { - arm_devmap_add_entry(0x48000000, 0x01000000); /*16mb L4_PER devices */ - arm_devmap_add_entry(0x4A000000, 0x01000000); /*16mb L4_CFG devices */ + devmap_add_entry(0x48000000, 0x01000000); /*16mb L4_PER devices */ + devmap_add_entry(0x4A000000, 0x01000000); /*16mb L4_CFG devices */ return (0); } #endif @@ -85,13 +85,13 @@ ti_am335x_devmap_init(platform_t plat) { - arm_devmap_add_entry(0x44C00000, 0x00400000); /* 4mb L4_WKUP devices*/ - arm_devmap_add_entry(0x47400000, 0x00100000); /* 1mb USB */ - arm_devmap_add_entry(0x47800000, 0x00100000); /* 1mb mmchs2 */ - arm_devmap_add_entry(0x48000000, 0x01000000); /*16mb L4_PER devices */ - arm_devmap_add_entry(0x49000000, 0x00100000); /* 1mb edma3 */ - arm_devmap_add_entry(0x49800000, 0x00300000); /* 3mb edma3 */ - arm_devmap_add_entry(0x4A000000, 0x01000000); /*16mb L4_FAST devices*/ + devmap_add_entry(0x44C00000, 0x00400000); /* 4mb L4_WKUP devices*/ + devmap_add_entry(0x47400000, 0x00100000); /* 1mb USB */ + devmap_add_entry(0x47800000, 0x00100000); /* 1mb mmchs2 */ + devmap_add_entry(0x48000000, 0x01000000); /*16mb L4_PER devices */ + devmap_add_entry(0x49000000, 0x00100000); /* 1mb edma3 */ + devmap_add_entry(0x49800000, 0x00300000); /* 3mb edma3 */ + devmap_add_entry(0x4A000000, 0x01000000); /*16mb L4_FAST devices*/ return (0); } #endif Index: sys/arm/versatile/versatile_machdep.c =================================================================== --- sys/arm/versatile/versatile_machdep.c +++ sys/arm/versatile/versatile_machdep.c @@ -43,12 +43,12 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -81,7 +81,7 @@ } #define FDT_DEVMAP_MAX (2) /* FIXME */ -static struct arm_devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = { +static struct devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = { { 0, 0, 0, }, { 0, 0, 0, } }; @@ -98,7 +98,7 @@ fdt_devmap[i].pd_pa = 0x10100000; fdt_devmap[i].pd_size = 0x01000000; /* 1 MB */ - arm_devmap_register_table(&fdt_devmap[0]); + devmap_register_table(&fdt_devmap[0]); return (0); } Index: sys/arm/xilinx/zy7_machdep.c =================================================================== --- sys/arm/xilinx/zy7_machdep.c +++ sys/arm/xilinx/zy7_machdep.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,6 @@ #include #include -#include #include #include @@ -59,7 +59,7 @@ platform_lastaddr(void) { - return (arm_devmap_lastaddr()); + return (devmap_lastaddr()); } void @@ -87,8 +87,8 @@ platform_devmap_init(void) { - arm_devmap_add_entry(ZYNQ7_PSIO_HWBASE, ZYNQ7_PSIO_SIZE); - arm_devmap_add_entry(ZYNQ7_PSCTL_HWBASE, ZYNQ7_PSCTL_SIZE); + devmap_add_entry(ZYNQ7_PSIO_HWBASE, ZYNQ7_PSIO_SIZE); + devmap_add_entry(ZYNQ7_PSCTL_HWBASE, ZYNQ7_PSCTL_SIZE); return (0); } Index: sys/arm/xscale/i8134x/crb_machdep.c =================================================================== --- sys/arm/xscale/i8134x/crb_machdep.c +++ sys/arm/xscale/i8134x/crb_machdep.c @@ -72,6 +72,7 @@ #include #include #include +#include #include #include @@ -80,7 +81,6 @@ #include #include #include -#include #include #include #include @@ -120,7 +120,7 @@ struct pv_addr kernelstack; /* Static device mappings. */ -static const struct arm_devmap_entry iq81342_devmap[] = { +static const struct devmap_entry iq81342_devmap[] = { { IOP34X_VADDR, IOP34X_HWADDR, @@ -249,7 +249,7 @@ /* Map the vector page. */ pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); - arm_devmap_bootstrap(l1pagetable, iq81342_devmap); + devmap_bootstrap(l1pagetable, iq81342_devmap); /* * Give the XScale global cache clean code an appropriately * sized chunk of unmapped VA space starting at 0xff000000 Index: sys/arm/xscale/ixp425/avila_machdep.c =================================================================== --- sys/arm/xscale/ixp425/avila_machdep.c +++ sys/arm/xscale/ixp425/avila_machdep.c @@ -72,6 +72,7 @@ #include #include #include +#include #include #include #include @@ -81,7 +82,6 @@ #include #include #include -#include #include #include #include @@ -117,7 +117,7 @@ struct pv_addr minidataclean; /* Static device mappings. */ -static const struct arm_devmap_entry ixp425_devmap[] = { +static const struct devmap_entry ixp425_devmap[] = { /* Physical/Virtual address for I/O space */ { IXP425_IO_VBASE, IXP425_IO_HWBASE, IXP425_IO_SIZE, }, @@ -144,7 +144,7 @@ }; /* Static device mappings. */ -static const struct arm_devmap_entry ixp435_devmap[] = { +static const struct devmap_entry ixp435_devmap[] = { /* Physical/Virtual address for I/O space */ { IXP425_IO_VBASE, IXP425_IO_HWBASE, IXP425_IO_SIZE, }, @@ -326,9 +326,9 @@ pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); if (cpu_is_ixp43x()) - arm_devmap_bootstrap(l1pagetable, ixp435_devmap); + devmap_bootstrap(l1pagetable, ixp435_devmap); else - arm_devmap_bootstrap(l1pagetable, ixp425_devmap); + devmap_bootstrap(l1pagetable, ixp425_devmap); /* * Give the XScale global cache clean code an appropriately * sized chunk of unmapped VA space starting at 0xff000000 Index: sys/arm/xscale/pxa/pxa_machdep.c =================================================================== --- sys/arm/xscale/pxa/pxa_machdep.c +++ sys/arm/xscale/pxa/pxa_machdep.c @@ -73,6 +73,7 @@ #include #include #include +#include #include #include @@ -81,7 +82,6 @@ #include #include #include -#include #include #include #include @@ -120,7 +120,7 @@ uint32_t *, uint32_t *); /* Static device mappings. */ -static const struct arm_devmap_entry pxa_devmap[] = { +static const struct devmap_entry pxa_devmap[] = { /* * Map the on-board devices up into the KVA region so we don't muck * up user-space. @@ -254,7 +254,7 @@ /* Map the vector page. */ pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE); - arm_devmap_bootstrap(l1pagetable, pxa_devmap); + devmap_bootstrap(l1pagetable, pxa_devmap); /* * Give the XScale global cache clean code an appropriately Index: sys/arm64/arm64/machdep.c =================================================================== --- sys/arm64/arm64/machdep.c +++ sys/arm64/arm64/machdep.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -70,7 +71,6 @@ #include #include #include -#include #include #include #include @@ -912,7 +912,7 @@ pmap_bootstrap(abp->kern_l0pt, abp->kern_l1pt, KERNBASE - abp->kern_delta, lastaddr - KERNBASE); - arm_devmap_bootstrap(0, NULL); + devmap_bootstrap(0, NULL); cninit(); Index: sys/arm64/include/devmap.h =================================================================== --- sys/arm64/include/devmap.h +++ sys/arm64/include/devmap.h @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 2013 Ian Lepore - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_DEVMAP_H_ -#define _MACHINE_DEVMAP_H_ - -/* - * This structure is used by MD code to describe static mappings of devices - * which are established as part of bringing up the MMU early in the boot. - */ -struct arm_devmap_entry { - vm_offset_t pd_va; /* virtual address */ - vm_paddr_t pd_pa; /* physical address */ - vm_size_t pd_size; /* size of region */ -}; - -/* - * Return the lowest KVA address used in any entry in the registered devmap - * table. This works with whatever table is registered, including the internal - * table used by arm_devmap_add_entry() if that routine was used. Platforms can - * implement initarm_lastaddr() by calling this if static device mappings are - * their only use of high KVA space. - */ -vm_offset_t arm_devmap_lastaddr(void); - -/* - * Automatically allocate KVA (from the top of the address space downwards) and - * make static device mapping entries in an internal table. The internal table - * is automatically registered on the first call to this. - */ -void arm_devmap_add_entry(vm_paddr_t pa, vm_size_t sz); - -/* - * Register a platform-local table to be bootstrapped by the generic - * initarm() in arm/machdep.c. This is used by newer code that allocates and - * fills in its own local table but does not have its own initarm() routine. - */ -void arm_devmap_register_table(const struct arm_devmap_entry * _table); - -/* - * Establish mappings for all the entries in the table. This is called - * automatically from the common initarm() in arm/machdep.c, and also from the - * custom initarm() routines in older code. If the table pointer is NULL, this - * will use the table installed previously by arm_devmap_register_table(). - */ -void arm_devmap_bootstrap(vm_offset_t _l1pt, - const struct arm_devmap_entry *_table); - -/* - * Translate between virtual and physical addresses within a region that is - * static-mapped by the devmap code. If the given address range isn't - * static-mapped, then ptov returns NULL and vtop returns DEVMAP_PADDR_NOTFOUND. - * The latter implies that you can't vtop just the last byte of physical address - * space. This is not as limiting as it might sound, because even if a device - * occupies the end of the physical address space, you're only prevented from - * doing vtop for that single byte. If you vtop a size bigger than 1 it works. - */ -#define DEVMAP_PADDR_NOTFOUND ((vm_paddr_t)(-1)) - -void * arm_devmap_ptov(vm_paddr_t _pa, vm_size_t _sz); -vm_paddr_t arm_devmap_vtop(void * _va, vm_size_t _sz); - -/* Print the static mapping table; used for bootverbose output. */ -void arm_devmap_print_table(void); - -#endif Index: sys/arm64/include/vmparam.h =================================================================== --- sys/arm64/include/vmparam.h +++ sys/arm64/include/vmparam.h @@ -247,4 +247,6 @@ #define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ +#define DEVMAP_MAX_VADDR VM_MAX_KERNEL_ADDRESS + #endif /* !_MACHINE_VMPARAM_H_ */ Index: sys/conf/files.arm =================================================================== --- sys/conf/files.arm +++ sys/conf/files.arm @@ -29,7 +29,6 @@ arm/arm/db_interface.c optional ddb arm/arm/db_trace.c optional ddb arm/arm/debug_monitor.c optional ddb armv6 -arm/arm/devmap.c standard arm/arm/disassem.c optional ddb arm/arm/dump_machdep.c standard arm/arm/elf_machdep.c standard @@ -117,6 +116,7 @@ clean "font.h ${SC_DFLT_FONT}-8x14 ${SC_DFLT_FONT}-8x16 ${SC_DFLT_FONT}-8x8" kern/pic_if.m optional intrng kern/subr_busdma_bufalloc.c standard +kern/subr_devmap.c standard kern/subr_sfbuf.c standard libkern/arm/aeabi_unwind.c standard libkern/arm/divsi3.S standard Index: sys/conf/files.arm64 =================================================================== --- sys/conf/files.arm64 +++ sys/conf/files.arm64 @@ -1,5 +1,4 @@ # $FreeBSD$ -arm/arm/devmap.c standard arm/arm/generic_timer.c standard arm/arm/pmu.c standard arm64/acpica/acpi_machdep.c optional acpi @@ -84,6 +83,7 @@ dev/vnic/thunder_mdio.c optional vnic dev/vnic/lmac_if.m optional vnic kern/kern_clocksource.c standard +kern/subr_devmap.c standard libkern/bcmp.c standard libkern/ffs.c standard libkern/ffsl.c standard Index: sys/conf/files.riscv =================================================================== --- sys/conf/files.riscv +++ sys/conf/files.riscv @@ -3,6 +3,7 @@ crypto/des/des_enc.c optional crypto | ipsec | netsmb dev/ofw/ofw_cpu.c optional fdt kern/kern_clocksource.c standard +kern/subr_devmap.c standard kern/subr_dummy_vdso_tc.c standard libkern/bcmp.c standard libkern/ffs.c standard @@ -26,7 +27,6 @@ riscv/riscv/db_disasm.c optional ddb riscv/riscv/db_interface.c optional ddb riscv/riscv/db_trace.c optional ddb -riscv/riscv/devmap.c standard riscv/riscv/dump_machdep.c standard riscv/riscv/elf_machdep.c standard riscv/riscv/intr_machdep.c standard Index: sys/kern/subr_devmap.c =================================================================== --- sys/kern/subr_devmap.c +++ sys/kern/subr_devmap.c @@ -30,42 +30,35 @@ /* * Routines for mapping device memory. * - * This is used on both arm and arm64. + * This is used on arm, arm64 and riscv. */ #include "opt_ddb.h" #include #include +#include #include #include #include #ifdef __arm__ #include #endif -#include -#include #include -static const struct arm_devmap_entry *devmap_table; +static const struct devmap_entry *devmap_table; static boolean_t devmap_bootstrap_done = false; -#if defined(__aarch64__) -#define MAX_VADDR VM_MAX_KERNEL_ADDRESS -#elif defined(__arm__) -#define MAX_VADDR ARM_VECTORS_HIGH -#endif - /* * The allocated-kva (akva) devmap table and metadata. Platforms can call - * arm_devmap_add_entry() to add static device mappings to this table using + * devmap_add_entry() to add static device mappings to this table using * automatically allocated virtual addresses carved out of the top of kva space. * Allocation begins immediately below the ARM_VECTORS_HIGH address. */ #define AKVA_DEVMAP_MAX_ENTRIES 32 -static struct arm_devmap_entry akva_devmap_entries[AKVA_DEVMAP_MAX_ENTRIES]; +static struct devmap_entry akva_devmap_entries[AKVA_DEVMAP_MAX_ENTRIES]; static u_int akva_devmap_idx; -static vm_offset_t akva_devmap_vaddr = MAX_VADDR; +static vm_offset_t akva_devmap_vaddr = DEVMAP_MAX_VADDR; #ifdef __aarch64__ extern int early_boot; @@ -78,7 +71,7 @@ static void devmap_dump_table(int (*prfunc)(const char *, ...)) { - const struct arm_devmap_entry *pd; + const struct devmap_entry *pd; if (devmap_table == NULL || devmap_table[0].pd_size == 0) { prfunc("No static device mappings.\n"); @@ -96,7 +89,7 @@ * Print the contents of the static mapping table. Used for bootverbose. */ void -arm_devmap_print_table() +devmap_print_table() { devmap_dump_table(printf); } @@ -107,15 +100,15 @@ * the first unusable byte of KVA. */ vm_offset_t -arm_devmap_lastaddr() +devmap_lastaddr() { - const struct arm_devmap_entry *pd; + const struct devmap_entry *pd; vm_offset_t lowaddr; if (akva_devmap_idx > 0) return (akva_devmap_vaddr); - lowaddr = MAX_VADDR; + lowaddr = DEVMAP_MAX_VADDR; for (pd = devmap_table; pd != NULL && pd->pd_size != 0; ++pd) { if (lowaddr > pd->pd_va) lowaddr = pd->pd_va; @@ -129,22 +122,22 @@ * physical address and size and a virtual address allocated from the top of * kva. This automatically registers the akva table on the first call, so all a * platform has to do is call this routine to install as many mappings as it - * needs and when initarm() calls arm_devmap_bootstrap() it will pick up all the + * needs and when initarm() calls devmap_bootstrap() it will pick up all the * entries in the akva table automatically. */ void -arm_devmap_add_entry(vm_paddr_t pa, vm_size_t sz) +devmap_add_entry(vm_paddr_t pa, vm_size_t sz) { - struct arm_devmap_entry *m; + struct devmap_entry *m; if (devmap_bootstrap_done) - panic("arm_devmap_add_entry() after arm_devmap_bootstrap()"); + panic("devmap_add_entry() after devmap_bootstrap()"); if (akva_devmap_idx == (AKVA_DEVMAP_MAX_ENTRIES - 1)) panic("AKVA_DEVMAP_MAX_ENTRIES is too small"); if (akva_devmap_idx == 0) - arm_devmap_register_table(akva_devmap_entries); + devmap_register_table(akva_devmap_entries); /* * Allocate virtual address space from the top of kva downwards. If the @@ -167,10 +160,10 @@ } /* - * Register the given table as the one to use in arm_devmap_bootstrap(). + * Register the given table as the one to use in devmap_bootstrap(). */ void -arm_devmap_register_table(const struct arm_devmap_entry *table) +devmap_register_table(const struct devmap_entry *table) { devmap_table = table; @@ -183,13 +176,13 @@ * If a non-NULL table pointer is given it is used unconditionally, otherwise * the previously-registered table is used. This smooths transition from legacy * code that fills in a local table then calls this function passing that table, - * and newer code that uses arm_devmap_register_table() in platform-specific + * and newer code that uses devmap_register_table() in platform-specific * code, then lets the common initarm() call this function with a NULL pointer. */ void -arm_devmap_bootstrap(vm_offset_t l1pt, const struct arm_devmap_entry *table) +devmap_bootstrap(vm_offset_t l1pt, const struct devmap_entry *table) { - const struct arm_devmap_entry *pd; + const struct devmap_entry *pd; devmap_bootstrap_done = true; @@ -222,9 +215,9 @@ * corresponding virtual address, or NULL if not found. */ void * -arm_devmap_ptov(vm_paddr_t pa, vm_size_t size) +devmap_ptov(vm_paddr_t pa, vm_size_t size) { - const struct arm_devmap_entry *pd; + const struct devmap_entry *pd; if (devmap_table == NULL) return (NULL); @@ -242,9 +235,9 @@ * corresponding physical address, or DEVMAP_PADDR_NOTFOUND if not found. */ vm_paddr_t -arm_devmap_vtop(void * vpva, vm_size_t size) +devmap_vtop(void * vpva, vm_size_t size) { - const struct arm_devmap_entry *pd; + const struct devmap_entry *pd; vm_offset_t va; if (devmap_table == NULL) @@ -277,7 +270,7 @@ void * rva; /* First look in the static mapping table. */ - if ((rva = arm_devmap_ptov(pa, size)) != NULL) + if ((rva = devmap_ptov(pa, size)) != NULL) return (rva); offset = pa & PAGE_MASK; @@ -310,7 +303,7 @@ vm_offset_t offset; /* Nothing to do if we find the mapping in the static table. */ - if (arm_devmap_vtop((void*)va, size) != DEVMAP_PADDR_NOTFOUND) + if (devmap_vtop((void*)va, size) != DEVMAP_PADDR_NOTFOUND) return; offset = va & PAGE_MASK; Index: sys/riscv/include/vmparam.h =================================================================== --- sys/riscv/include/vmparam.h +++ sys/riscv/include/vmparam.h @@ -239,4 +239,6 @@ #define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ +#define DEVMAP_MAX_VADDR VM_MAX_KERNEL_ADDRESS + #endif /* !_MACHINE_VMPARAM_H_ */ Index: sys/riscv/riscv/devmap.c =================================================================== --- sys/riscv/riscv/devmap.c +++ sys/riscv/riscv/devmap.c @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 2015 Ruslan Bukin - * All rights reserved. - * - * Portions of this software were developed by SRI International and the - * University of Cambridge Computer Laboratory under DARPA/AFRL contract - * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. - * - * Portions of this software were developed by the University of Cambridge - * Computer Laboratory as part of the CTSRD Project, with support from the - * UK Higher Education Innovation Fund (HEIF). - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -/* RISC-V doesn't provide memory-mapped devices yet */ - -#include "opt_ddb.h" - -#include -#include -#include -#include -#include -#include -#include - -void * -pmap_mapdev(vm_offset_t pa, vm_size_t size) -{ - - return (NULL); -} - -void -pmap_unmapdev(vm_offset_t va, vm_size_t size) -{ - -} Index: sys/sys/devmap.h =================================================================== --- sys/sys/devmap.h +++ sys/sys/devmap.h @@ -26,14 +26,18 @@ * $FreeBSD$ */ -#ifndef _MACHINE_DEVMAP_H_ -#define _MACHINE_DEVMAP_H_ +#ifndef _SYS_DEVMAP_H_ +#define _SYS_DEVMAP_H_ + +#ifndef _KERNEL +#error "no user-servicable parts inside" +#endif /* * This structure is used by MD code to describe static mappings of devices * which are established as part of bringing up the MMU early in the boot. */ -struct arm_devmap_entry { +struct devmap_entry { vm_offset_t pd_va; /* virtual address */ vm_paddr_t pd_pa; /* physical address */ vm_size_t pd_size; /* size of region */ @@ -42,34 +46,34 @@ /* * Return the lowest KVA address used in any entry in the registered devmap * table. This works with whatever table is registered, including the internal - * table used by arm_devmap_add_entry() if that routine was used. Platforms can + * table used by devmap_add_entry() if that routine was used. Platforms can * implement platform_lastaddr() by calling this if static device mappings are * their only use of high KVA space. */ -vm_offset_t arm_devmap_lastaddr(void); +vm_offset_t devmap_lastaddr(void); /* * Automatically allocate KVA (from the top of the address space downwards) and * make static device mapping entries in an internal table. The internal table * is automatically registered on the first call to this. */ -void arm_devmap_add_entry(vm_paddr_t pa, vm_size_t sz); +void devmap_add_entry(vm_paddr_t pa, vm_size_t sz); /* * Register a platform-local table to be bootstrapped by the generic * initarm() in arm/machdep.c. This is used by newer code that allocates and * fills in its own local table but does not have its own initarm() routine. */ -void arm_devmap_register_table(const struct arm_devmap_entry * _table); +void devmap_register_table(const struct devmap_entry * _table); /* * Establish mappings for all the entries in the table. This is called * automatically from the common initarm() in arm/machdep.c, and also from the * custom initarm() routines in older code. If the table pointer is NULL, this - * will use the table installed previously by arm_devmap_register_table(). + * will use the table installed previously by devmap_register_table(). */ -void arm_devmap_bootstrap(vm_offset_t _l1pt, - const struct arm_devmap_entry *_table); +void devmap_bootstrap(vm_offset_t _l1pt, + const struct devmap_entry *_table); /* * Translate between virtual and physical addresses within a region that is @@ -82,10 +86,10 @@ */ #define DEVMAP_PADDR_NOTFOUND ((vm_paddr_t)(-1)) -void * arm_devmap_ptov(vm_paddr_t _pa, vm_size_t _sz); -vm_paddr_t arm_devmap_vtop(void * _va, vm_size_t _sz); +void * devmap_ptov(vm_paddr_t _pa, vm_size_t _sz); +vm_paddr_t devmap_vtop(void * _va, vm_size_t _sz); /* Print the static mapping table; used for bootverbose output. */ -void arm_devmap_print_table(void); +void devmap_print_table(void); -#endif +#endif /* !_SYS_DEVMAP_H_ */