From 466a1c65ee6a14c307696b7691a5c269b8f2011d Mon Sep 17 00:00:00 2001 From: evb Date: Thu, 4 Feb 2010 19:52:13 +0000 Subject: [PATCH] - Define memory map structure for Versatile board/QEMU and send to OS Loader. - Many hack removed. - Better efficency use of memory layout. - Region at 0x800000 now available for FreeLDR use to load kernel files. - Implement simple ArmDiskNormalizeSystemPath so boot is allowed to happen. - Use better stack address as defined in memory map. - Now FreeLDR loads all files correctly from disk and is ready to jump to kernel. ARMv5 paging code must be rewritten before that can happen. svn path=/trunk/; revision=45424 --- reactos/boot/armllb/boot.s | 2 +- reactos/boot/armllb/envir.c | 8 +++ reactos/boot/armllb/hw/versatile/hwinfo.c | 57 ++++++++++++++++++- reactos/boot/armllb/hw/versatile/hwinit.c | 11 ++-- reactos/boot/armllb/os/loader.c | 13 ----- reactos/boot/freeldr/freeldr/arcemul/mm.c | 4 +- .../boot/freeldr/freeldr/arch/arm/loader.c | 4 ++ .../boot/freeldr/freeldr/arch/arm/macharm.c | 4 +- reactos/boot/freeldr/freeldr/freeldr.rbuild | 2 +- 9 files changed, 75 insertions(+), 30 deletions(-) diff --git a/reactos/boot/armllb/boot.s b/reactos/boot/armllb/boot.s index 6b0f35bcd5c..505ae843cac 100644 --- a/reactos/boot/armllb/boot.s +++ b/reactos/boot/armllb/boot.s @@ -31,7 +31,7 @@ ENTRY_END _start L_BootStackEnd: - .long 0x2000000 + .long 0x00010000 L_LlbStartup: .long LlbStartup diff --git a/reactos/boot/armllb/envir.c b/reactos/boot/armllb/envir.c index 514776f87cb..31ec2a56f82 100644 --- a/reactos/boot/armllb/envir.c +++ b/reactos/boot/armllb/envir.c @@ -47,6 +47,14 @@ LlbEnvParseArguments(IN PATAG Arguments) /* Save RAMDISK start and size */ LlbEnvRamDiskStart = Atag->u.InitRd2.Start; LlbEnvRamDiskSize = Atag->u.InitRd2.Size; + + /* Make sure it's 16MB-aligned */ + LlbEnvRamDiskSize = (LlbEnvRamDiskSize + (16 * 1024 * 1024) - 1) + &~ ((16 * 1024 * 1024) - 1); + + /* The RAMDISK actually starts 16MB later */ + LlbEnvRamDiskStart += 16 * 1024 * 1024; + LlbEnvRamDiskSize -= 16 * 1024 * 1024; break; case ATAG_CMDLINE: diff --git a/reactos/boot/armllb/hw/versatile/hwinfo.c b/reactos/boot/armllb/hw/versatile/hwinfo.c index 667898f17af..e59e8d41fcc 100755 --- a/reactos/boot/armllb/hw/versatile/hwinfo.c +++ b/reactos/boot/armllb/hw/versatile/hwinfo.c @@ -37,14 +37,65 @@ NTAPI LlbHwGetSerialUart(VOID) { return 0; -} +} + +// +// Versatile Memory Map +// +// 0x00000000 - 0x000000FF ARM Vectors [ 1 KB] +// 0x00000100 - 0x000001FF ATAG Structures [ 1 KB] +// 0x00000200 - 0x0000FFFF ARM STACK [ 62 KB] +// 0x00010000 - 0x0001FFFF ARM LLB [ 64 KB] +// 0x00020000 - 0x0009FFFF ARM OS LOADER [512 KB] +// 0x000A0000 - 0x007FFFFF OS LOADER FREE/UNUSED [7.3 MB] +// 0x00800000 - 0x017FFFFF KERNEL, HAL, INITIAL DRIVER LOAD ADDR [ 16 MB] +// 0x01800000 - 0x037FFFFF RAM DISK [ 32 MB] +// 0x03800000 - 0x07FFFFFF FREE RAM [ 72 MB] +// 0x08000000 - 0x0FFFFFFF FREE RAM IF 256MB DEVICE [128 MB] +// 0x10000000 - 0x1FFFFFFF MMIO DEVICES [256 MB] +BIOS_MEMORY_MAP LlbHwVersaMemoryMap[] = +{ + {0x00000000, 0x00000100, BiosMemoryReserved, 0}, + {0x00000100, 0x00000100, BiosMemoryBootStrap, 0}, + {0x00000200, 0x0000FE00, BiosMemoryBootStrap, 0}, + {0x00010000, 0x00010000, BiosMemoryBootStrap, 0}, + {0x00020000, 0x00080000, BiosMemoryBootLoader, 0}, + {0x00080000, 0x01000000, BiosMemoryUsable, 0}, + {0x01800000, 0x02000000, BiosMemoryReserved, 0}, + {0x10000000, 0x10000000, BiosMemoryReserved, 0}, + {0, 0, 0, 0} +}; VOID NTAPI LlbHwBuildMemoryMap(IN PBIOS_MEMORY_MAP MemoryMap) { - /* Mark MMIO space as reserved */ - LlbAllocateMemoryEntry(BiosMemoryReserved, 0x10000000, 128 * 1024 * 1024); + PBIOS_MEMORY_MAP MapEntry; + ULONG Base, Size, FsBase, FsSize; + + /* Parse hardware memory map */ + MapEntry = LlbHwVersaMemoryMap; + while (MapEntry->Length) + { + /* Add this entry */ + LlbAllocateMemoryEntry(MapEntry->Type, MapEntry->BaseAddress, MapEntry->Length); + + /* Move to the next one */ + MapEntry++; + } + + /* Query memory and RAMDISK information */ + LlbEnvGetMemoryInformation(&Base, &Size); + LlbEnvGetRamDiskInformation(&FsBase, &FsSize); + + /* Add-in the size of the ramdisk */ + Base = FsBase + FsSize; + + /* Subtract size of ramdisk and anything else before it */ + Size -= Base; + + /* Allocate an entry for it */ + LlbAllocateMemoryEntry(BiosMemoryUsable, Base, Size); } ULONG diff --git a/reactos/boot/armllb/hw/versatile/hwinit.c b/reactos/boot/armllb/hw/versatile/hwinit.c index e46d95677ee..20e38512dce 100755 --- a/reactos/boot/armllb/hw/versatile/hwinit.c +++ b/reactos/boot/armllb/hw/versatile/hwinit.c @@ -33,14 +33,11 @@ LlbHwLoadOsLoaderFromRam(VOID) PCHAR Offset; CHAR CommandLine[64]; - /* On versatile, the NAND image is loaded as the RAMDISK */ - LlbEnvGetRamDiskInformation(&Base, &Size); + /* On versatile we load the RAMDISK with initrd */ + LlbEnvGetRamDiskInformation(&RootFs, &Size); - /* The LLB is first, which we already have, so skip it */ - Base += 0x10000; // 64 KB (see nandflash) - - /* The OS loader is next, followed by the root file system */ - RootFs = Base + 0x80000; // 512 KB (see nandflash) + /* The OS Loader is at 0x20000, always */ + Base = 0x20000; /* Read image offset */ Offset = LlbEnvRead("rdoffset"); diff --git a/reactos/boot/armllb/os/loader.c b/reactos/boot/armllb/os/loader.c index d7f7e90e147..7d0e9fcf995 100755 --- a/reactos/boot/armllb/os/loader.c +++ b/reactos/boot/armllb/os/loader.c @@ -93,21 +93,8 @@ VOID NTAPI LlbBuildMemoryMap(VOID) { - ULONG Base, Size; - /* Zero out the memory map */ memset(MemoryMap, 0, sizeof(MemoryMap)); - - /* Query memory information */ - LlbEnvGetMemoryInformation(&Base, &Size); - - /* Don't use memory that the RAMDISK is using */ - /* HACK HACK */ - Base += 32 * 1024 * 1024; - Size -= 32 * 1024 * 1024; - - /* Allocate an entry for it */ - LlbAllocateMemoryEntry(BiosMemoryUsable, Base, Size); /* Call the hardware-specific function for hardware-defined regions */ LlbHwBuildMemoryMap(MemoryMap); diff --git a/reactos/boot/freeldr/freeldr/arcemul/mm.c b/reactos/boot/freeldr/freeldr/arcemul/mm.c index 03ddbaf71e2..57a654e0b20 100644 --- a/reactos/boot/freeldr/freeldr/arcemul/mm.c +++ b/reactos/boot/freeldr/freeldr/arcemul/mm.c @@ -32,9 +32,7 @@ static const MEMORY_DESCRIPTOR_INT MemoryDescriptors[] = { { MemoryFirmwarePermanent, 0xA0, 0x60 }, 6, }, // ROM / Video { { MemorySpecialMemory, 0xFFF, 1 }, 7, }, // unusable memory #elif __arm__ // This needs to be done per-platform specific way - { { MemoryLoadedProgram, 0x80000, 32 }, 0, }, // X-Loader + OmapLdr - { { MemoryLoadedProgram, 0x81000, 128 }, 1, }, // FreeLDR - { { MemoryFirmwareTemporary, 0x80500, 4096 }, 2, }, // Video Buffer + #endif }; MEMORY_DESCRIPTOR* diff --git a/reactos/boot/freeldr/freeldr/arch/arm/loader.c b/reactos/boot/freeldr/freeldr/arch/arm/loader.c index 987386e9c33..ee7402df88f 100644 --- a/reactos/boot/freeldr/freeldr/arch/arm/loader.c +++ b/reactos/boot/freeldr/freeldr/arch/arm/loader.c @@ -1036,6 +1036,9 @@ ArmPrepareForReactOS(IN BOOLEAN Setup) PULONG Buffer; PWCHAR ArmModuleName; + TuiPrintf("About to prepare for kernel boot\n"); + while (TRUE); + // // Allocate the ARM Shared Heap // @@ -1607,6 +1610,7 @@ FrLdrStartup(IN ULONG Magic) // // Initialize the page directory // + TuiPrintf("About to jump into kernel\n"); while (TRUE); ArmSetupPageDirectory(); diff --git a/reactos/boot/freeldr/freeldr/arch/arm/macharm.c b/reactos/boot/freeldr/freeldr/arch/arm/macharm.c index 006a2998040..f8979bba771 100644 --- a/reactos/boot/freeldr/freeldr/arch/arm/macharm.c +++ b/reactos/boot/freeldr/freeldr/arch/arm/macharm.c @@ -73,8 +73,8 @@ BOOLEAN ArmDiskNormalizeSystemPath(IN OUT PCHAR SystemPath, IN unsigned Size) { - TuiPrintf("Called: %s\n", SystemPath); - while (TRUE); + /* Only RAMDISK supported for now */ + if (!strstr(SystemPath, "ramdisk(0)")) return FALSE; return TRUE; } diff --git a/reactos/boot/freeldr/freeldr/freeldr.rbuild b/reactos/boot/freeldr/freeldr/freeldr.rbuild index f6fc7c2179a..dc83aaa9878 100644 --- a/reactos/boot/freeldr/freeldr/freeldr.rbuild +++ b/reactos/boot/freeldr/freeldr/freeldr.rbuild @@ -38,7 +38,7 @@ -Wl,--image-base=0x80FFF000 - -Wl,--image-base=0x0080F000 + -Wl,--image-base=0x0001F000