- More fixes
authorevb <evb@svn.reactos.org>
Tue, 2 Feb 2010 00:14:14 +0000 (00:14 +0000)
committerevb <evb@svn.reactos.org>
Tue, 2 Feb 2010 00:14:14 +0000 (00:14 +0000)
- Plugin support for booting FreeLDR when used as initrd on QEMU command-line.

svn path=/trunk/; revision=45377

reactos/boot/armllb/hw/serial.c
reactos/boot/armllb/hw/versatile/hwinfo.c
reactos/boot/armllb/hw/versatile/hwinit.c
reactos/boot/armllb/inc/hw.h
reactos/boot/armllb/inc/osloader.h
reactos/boot/armllb/main.c
reactos/boot/armllb/os/loader.c

index e5507b6..7bb09cf 100755 (executable)
@@ -13,7 +13,7 @@ NTAPI
 LlbSerialPutChar(IN CHAR c)
 {
     /* Properly support new-lines */
//   if (c == '\n') LlbSerialPutChar('\r');
+    if (c == '\n') LlbSerialPutChar('\r');
  
     /* Wait for ready */
     while (!LlbHwUartTxReady());
index c7eb76b..3390b59 100755 (executable)
@@ -19,7 +19,7 @@ ULONG
 NTAPI
 LlbHwGetPClk(VOID)
 {
-    return 0x24000000;
+    return 24000000;
 }
 
 ULONG
@@ -36,4 +36,26 @@ LlbHwGetSerialUart(VOID)
     return 0;
 }     
 
+VOID
+NTAPI
+LlbHwBuildMemoryMap(IN PBIOS_MEMORY_MAP MemoryMap)
+{
+    /* For now, hard-code 128MB of RAM starting at 0x00000000 */
+    LlbAllocateMemoryEntry(BiosMemoryUsable, 0x00000000, 128 * 1024 * 1024);
+    
+    /* Mark MMIO space as reserved */
+    LlbAllocateMemoryEntry(BiosMemoryReserved, 0x10000000, 128 * 1024 * 1024);
+}
+
+//
+// hwenv.c? or environment.c? or both?
+//
+PCHAR
+NTAPI
+LlbHwEnvRead(IN PCHAR Option)
+{
+    /* HACKFIX */
+    return "RAMDISK";
+}
+
 /* EOF */
index c420e4c..d1cc822 100755 (executable)
@@ -19,4 +19,16 @@ LlbHwInitialize(VOID)
     LlbHwVersaUartInitialize();
 }
 
+//
+// Should go to hwdev.c
+//
+POSLOADER_INIT
+NTAPI
+LlbHwLoadOsLoaderFromRam(VOID)
+{
+    /* The OS Loader should have already been loaded by QEMU at the right place */
+    return (POSLOADER_INIT)0x800000;
+}
+
+
 /* EOF */
index f4e24c2..4dcd5d6 100755 (executable)
@@ -80,6 +80,24 @@ LlbHwUartTxReady(
     VOID
 );
 
+VOID
+NTAPI
+LlbHwBuildMemoryMap(
+    IN PBIOS_MEMORY_MAP MemoryMap
+);
+
+POSLOADER_INIT
+NTAPI
+LlbHwLoadOsLoaderFromRam(
+    VOID
+);
+
+PCHAR
+NTAPI
+LlbHwEnvRead(
+    IN PCHAR Option
+);
+
 #ifdef _VERSATILE_
 #include "versa.h"
 #elif _OMAP3_
index 0e38e37..9d4a2ac 100644 (file)
@@ -10,7 +10,7 @@
 // OS Loader Main Routine
 // 
 typedef
-VOID (*OSLOADER_INIT)(
+VOID (*POSLOADER_INIT)(
     IN PVOID BoardInit
 );
 
@@ -54,4 +54,42 @@ typedef struct _ARM_BOARD_CONFIGURATION_BLOCK
     CHAR CommandLine[256];
 } ARM_BOARD_CONFIGURATION_BLOCK, *PARM_BOARD_CONFIGURATION_BLOCK;
 
+VOID
+NTAPI
+LlbAllocateMemoryEntry(
+    IN BIOS_MEMORY_TYPE Type,
+    IN ULONG BaseAddress,
+    IN ULONG Length
+);
+
+VOID
+NTAPI
+LlbSetCommandLine(
+    IN PCHAR CommandLine
+);
+
+VOID
+NTAPI
+LlbBuildArmBlock(
+    VOID
+);
+
+VOID
+NTAPI
+LlbBuildMemoryMap(
+    VOID
+);
+
+VOID
+NTAPI
+LlbLoadOsLoader(
+    VOID
+);
+
+VOID
+NTAPI
+LlbBoot(
+    IN PCHAR CommandLine
+);
+
 /* EOF */
index c936f44..b76bc93 100755 (executable)
@@ -19,6 +19,9 @@ LlbStartup(VOID)
 
     /* Print header */
     printf("ReactOS ARM Low-Level Boot Loader [" __DATE__ " "__TIME__ "]\n");
+    
+    /* Boot the OS Loader */
+    LlbBoot("");
     while (TRUE);
 }
 
index b595219..1470e8f 100755 (executable)
 
 BIOS_MEMORY_MAP MemoryMap[32];
 ARM_BOARD_CONFIGURATION_BLOCK ArmBlock;
-
+POSLOADER_INIT LoaderInit;
+    
 VOID
 NTAPI
-AllocateMemoryEntry(IN BIOS_MEMORY_TYPE Type,
-                    IN ULONG BaseAddress,
-                    IN ULONG Length)
+LlbAllocateMemoryEntry(IN BIOS_MEMORY_TYPE Type,
+                      IN ULONG BaseAddress,
+                      IN ULONG Length)
 {
     PBIOS_MEMORY_MAP Entry;
     
@@ -37,6 +38,7 @@ NTAPI
 LlbSetCommandLine(IN PCHAR CommandLine)
 {
     /* Copy the command line in the ARM block */
+    printf("Command Line %s\n", CommandLine);
     strcpy(ArmBlock.CommandLine, CommandLine);
 }
 
@@ -58,8 +60,76 @@ LlbBuildArmBlock(VOID)
     ArmBlock.TimerRegisterBase = LlbHwGetTmr0Base();
     ArmBlock.UartRegisterBase = LlbHwGetUartBase(LlbHwGetSerialUart());
     
+    /* Debug */
+    printf("Machine Identifier: %lx\nPCLK: %d\nTIMER 0: %p\nSERIAL UART: %p\n",
+            ArmBlock.BoardType,
+            ArmBlock.ClockRate,
+            ArmBlock.TimerRegisterBase,
+            ArmBlock.UartRegisterBase);
+    
     /* Now load the memory map */
     ArmBlock.MemoryMap = MemoryMap;
 }
 
+VOID
+NTAPI
+LlbBuildMemoryMap(VOID)
+{
+    /* Zero out the memory map */
+    memset(MemoryMap, 0, sizeof(MemoryMap));
+
+    /* Call the hardware-specific function */
+    LlbHwBuildMemoryMap(MemoryMap);
+}
+
+VOID
+NTAPI
+LlbLoadOsLoader(VOID)
+{
+    PCHAR BootDevice;
+    
+    /* Read the current boot device */
+    BootDevice = LlbHwEnvRead("boot-device");
+    printf("Loading OS Loader from: %s...\n", BootDevice);
+    if (!strcmp(BootDevice, "NAND"))
+    {
+        // todo
+    }
+    else if (!strcmp(BootDevice, "RAMDISK"))
+    {
+        /* Call the hardware-specific function */
+        LoaderInit = LlbHwLoadOsLoaderFromRam();
+    }
+    else if (!strcmp(BootDevice, "MMC") ||
+             !strcmp(BootDevice, "SD"))
+    {
+        //todo
+    }
+    else if (!strcmp(BootDevice, "HDD"))
+    {
+        //todo
+    }
+    printf("OS Loader loaded at 0x%p...JUMP!\n", LoaderInit);
+}
+
+VOID
+NTAPI
+LlbBoot(IN PCHAR CommandLine)
+{
+    /* Setup the ARM block */
+    LlbBuildArmBlock();
+    
+    /* Build the memory map */
+    LlbBuildMemoryMap();
+    
+    /* Set the command-line */
+    LlbSetCommandLine(CommandLine);
+    
+    /* Load the OS loader */
+    LlbLoadOsLoader();
+    
+    /* Jump to the OS Loader (FreeLDR in this case) */
+    LoaderInit(&ArmBlock);
+}
+
 /* EOF */