From e3020a50396a213352f70782904fa34546b6f2e4 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Sat, 6 Sep 2014 22:25:31 +0200 Subject: [PATCH] ARM: remove initrd handling from mmu code Let the platform mmu_map_physical_memory the initrd region, and reserve it before calling mmu_init. This removes another hardcoded address, since e.g. U-Boot gets the address from the uImage file. --- build/jam/board/beagle/BoardSetup | 3 +-- src/system/boot/arch/arm/arch_mmu.cpp | 17 ++++------------- .../boot/platform/raspberrypi_arm/start.cpp | 3 +++ src/system/boot/platform/u-boot/start.cpp | 12 ++++++++++++ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/build/jam/board/beagle/BoardSetup b/build/jam/board/beagle/BoardSetup index 27eeea7bf2..10994d19e8 100644 --- a/build/jam/board/beagle/BoardSetup +++ b/build/jam/board/beagle/BoardSetup @@ -61,8 +61,7 @@ HAIKU_BOARD_SDIMAGE_FILES = # # gcc flags for the specific cpu -local flags = -mcpu=cortex-a8 -mfpu=vfpv3 -mfloat-abi=hard - -DHAIKU_BOARD_LOADER_UIBASE=$(HAIKU_BOARD_LOADER_UIBASE) ; +local flags = -mcpu=cortex-a8 -mfpu=vfpv3 -mfloat-abi=hard ; HAIKU_ASFLAGS_$(HAIKU_PACKAGING_ARCH) += $(flags) ; HAIKU_CCFLAGS_$(HAIKU_PACKAGING_ARCH) += $(flags) ; diff --git a/src/system/boot/arch/arm/arch_mmu.cpp b/src/system/boot/arch/arm/arch_mmu.cpp index 81c75de5bc..3bd0ffd5b2 100644 --- a/src/system/boot/arch/arm/arch_mmu.cpp +++ b/src/system/boot/arch/arm/arch_mmu.cpp @@ -110,12 +110,6 @@ static struct memblock LOADER_MEMORYMAP[] = { kLoaderBaseAddress + 0x11FFFFF, ARM_MMU_L2_FLAG_C, }, - { - "RAM_initrd", // initrd - HAIKU_BOARD_LOADER_UIBASE, - HAIKU_BOARD_LOADER_UIBASE + 0x500000, - ARM_MMU_L2_FLAG_C, - }, #ifdef FB_BASE { @@ -548,8 +542,10 @@ mmu_init_for_kernel(void) TRACE(("mmu_init_for_kernel\n")); // save the memory we've physically allocated - gKernelArgs.physical_allocated_range[0].size - = sNextPhysicalAddress - gKernelArgs.physical_allocated_range[0].start; + int index = gKernelArgs.num_physical_allocated_ranges; + gKernelArgs.physical_allocated_range[index].start = SDRAM_BASE; + gKernelArgs.physical_allocated_range[index].size = sNextPhysicalAddress - SDRAM_BASE; + gKernelArgs.num_physical_allocated_ranges++; // Save the memory we've virtually allocated (for the kernel and other // stuff) @@ -619,11 +615,6 @@ mmu_init(void) gKernelArgs.physical_memory_range[0].size = highestRAMAddress - SDRAM_BASE; gKernelArgs.num_physical_memory_ranges = 1; - gKernelArgs.physical_allocated_range[0].start = SDRAM_BASE; - gKernelArgs.physical_allocated_range[0].size = 0; - gKernelArgs.num_physical_allocated_ranges = 1; - // remember the start of the allocated physical pages - init_page_directory(); // map in a kernel stack diff --git a/src/system/boot/platform/raspberrypi_arm/start.cpp b/src/system/boot/platform/raspberrypi_arm/start.cpp index 46b0e8df57..2d64bd7c44 100644 --- a/src/system/boot/platform/raspberrypi_arm/start.cpp +++ b/src/system/boot/platform/raspberrypi_arm/start.cpp @@ -134,6 +134,9 @@ _start(void) // Flick on "OK" led, use pre-mmu firmware base gpio_write(gPeripheralBase + GPIO_BASE, 16, 0); + // Reserve memory for boot archive before switching on MMU + insert_physical_allocated_range(BOOT_ARCHIVE_BASE, BOOT_ARCHIVE_SIZE); + // To debug mmu, enable serial_init above me! mmu_init(); diff --git a/src/system/boot/platform/u-boot/start.cpp b/src/system/boot/platform/u-boot/start.cpp index d2e4203704..f50c89665e 100644 --- a/src/system/boot/platform/u-boot/start.cpp +++ b/src/system/boot/platform/u-boot/start.cpp @@ -267,8 +267,20 @@ start_raw(int argc, const char **argv) dump_fdt(gFDT); } + if (args.platform.boot_tgz_size > 0) { + insert_physical_allocated_range((addr_t)args.platform.boot_tgz_data, + args.platform.boot_tgz_size); + } + mmu_init(); + // Handle our tarFS post-mmu + if (args.platform.boot_tgz_size > 0) { + args.platform.boot_tgz_data = (void*)mmu_map_physical_memory((addr_t) + args.platform.boot_tgz_data, args.platform.boot_tgz_size, + kDefaultPageFlags); + } + // wait a bit to give the user the opportunity to press a key // spin(750000);