Hi, instead of messing w/bs_tags, use the fact pmap_kernel()->pm_refs is going to be 0 until pmap_bootstrap() has ran. tmp_bs_tag was unused, and bootstrap_bs_map doesn't need/use the void *t-arg when being ran indirectly via armv7_bs_map().
the whole existence of bootstrap_bs_map is another story, and the comment in /* Now, map the FDT area. */ is somewhat an stupid excuse, it's already mapped before initarm() w/VA=PA, and could well be _init()&_get_size()'d & memcpy'ed somewhere in reach within bootstrap KVA, guess diff might follow for that, too, if anyone has time for these simplifications. the diff got tested/booted on cubie2, and i don't see how the result could differ on any other SoC. -Artturi diff --git a/sys/arch/arm/armv7/armv7_space.c b/sys/arch/arm/armv7/armv7_space.c index c7e9b686b8f..08aa551e014 100644 --- a/sys/arch/arm/armv7/armv7_space.c +++ b/sys/arch/arm/armv7/armv7_space.c @@ -170,7 +170,12 @@ armv7_bs_map(void *t, uint64_t bpa, bus_size_t size, { u_long startpa, endpa, pa; vaddr_t va; - int pmap_flags = PMAP_DEVICE; + int pmap_flags; + extern int bootstrap_bs_map(uint64_t, bus_size_t, int, + bus_space_handle_t *); + + if (pmap_kernel()->pm_refs == 0) + return bootstrap_bs_map(bpa, size, flags, bshp); startpa = trunc_page(bpa); endpa = round_page(bpa + size); @@ -183,8 +188,7 @@ armv7_bs_map(void *t, uint64_t bpa, bus_size_t size, *bshp = (bus_space_handle_t)(va + (bpa - startpa)); - if (flags & BUS_SPACE_MAP_CACHEABLE) - pmap_flags = 0; + pmap_flags = (flags & BUS_SPACE_MAP_CACHEABLE) ? 0 : PMAP_DEVICE; for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) pmap_kenter_pa(va, pa | pmap_flags, PROT_READ | PROT_WRITE); diff --git a/sys/arch/armv7/armv7/armv7_machdep.c b/sys/arch/armv7/armv7/armv7_machdep.c index aa1c549b29b..f33f7dff818 100644 --- a/sys/arch/armv7/armv7/armv7_machdep.c +++ b/sys/arch/armv7/armv7/armv7_machdep.c @@ -199,8 +199,7 @@ int safepri = 0; /* Prototypes */ char bootargs[MAX_BOOT_STRING]; -int bootstrap_bs_map(void *, uint64_t, bus_size_t, int, - bus_space_handle_t *); +int bootstrap_bs_map(uint64_t, bus_size_t, int, bus_space_handle_t *); void process_kernel_args(char *); void consinit(void); @@ -311,8 +310,8 @@ read_ttb(void) static vaddr_t section_free = 0xfd000000; /* XXX - huh */ int -bootstrap_bs_map(void *t, uint64_t bpa, bus_size_t size, - int flags, bus_space_handle_t *bshp) +bootstrap_bs_map(uint64_t bpa, bus_size_t size, int flags, + bus_space_handle_t *bshp) { u_long startpa, pa, endpa; vaddr_t va; @@ -384,11 +383,6 @@ initarm(void *arg0, void *arg1, void *arg2, paddr_t loadaddr) void *node; extern uint32_t esym; /* &_end if no symbols are loaded */ - /* early bus_space_map support */ - struct bus_space tmp_bs_tag; - int (*map_func_save)(void *, uint64_t, bus_size_t, int, - bus_space_handle_t *); - if (arg0) esym = (uint32_t)arg0; @@ -407,19 +401,6 @@ initarm(void *arg0, void *arg1, void *arg2, paddr_t loadaddr) panic("cpu not recognized!"); /* - * Temporarily replace bus_space_map() functions so that - * console devices can get mapped. - * - * Note that this relies upon the fact that both regular - * and a4x bus_space tags use the same map function. - */ - tmp_bs_tag = armv7_bs_tag; - map_func_save = armv7_bs_tag.bs_map; - armv7_bs_tag.bs_map = bootstrap_bs_map; - armv7_a4x_bs_tag.bs_map = bootstrap_bs_map; - tmp_bs_tag.bs_map = bootstrap_bs_map; - - /* * Now, map the FDT area. * * As we don't know the size of a possible FDT, map the size of a @@ -429,7 +410,7 @@ initarm(void *arg0, void *arg1, void *arg2, paddr_t loadaddr) * XXX: There's (currently) no way to unmap a bootstrap mapping, so * we might lose a bit of the bootstrap address space. */ - bootstrap_bs_map(NULL, (bus_addr_t)arg2, L1_S_SIZE, 0, + bootstrap_bs_map((bus_addr_t)arg2, L1_S_SIZE, 0, (bus_space_handle_t *)&config); if (!fdt_init(config) || fdt_get_size(config) == 0) @@ -772,12 +753,6 @@ initarm(void *arg0, void *arg1, void *arg2, paddr_t loadaddr) vector_page_setprot(PROT_READ | PROT_EXEC); - /* - * Restore proper bus_space operation, now that pmap is initialized. - */ - armv7_bs_tag.bs_map = map_func_save; - armv7_a4x_bs_tag.bs_map = map_func_save; - #ifdef DDB db_machine_init();