Author: evb
Date: Wed Feb 3 04:14:59 2010
New Revision: 45386
URL:
http://svn.reactos.org/svn/reactos?rev=45386&view=rev
Log:
- Flesh out more code.
- Support ATAG Linux/ARMBoot architecture defined-structures. These are used by all
ARMBoot-compatible loaders (QEmu, U-boot, etc).
- Read RAMDisk, RAM, Command Line from ATAGs (use -append boot-device=RAMDISK).
- Make environment-get function read command-line.
- Allocate RAM memory structure portably.
- Validate board info on boot.
Added:
trunk/reactos/boot/armllb/inc/envir.h (with props)
Modified:
trunk/reactos/boot/armllb/envir.c
trunk/reactos/boot/armllb/hw/versatile/hwinfo.c
trunk/reactos/boot/armllb/hw/versatile/hwinit.c
trunk/reactos/boot/armllb/inc/osloader.h
trunk/reactos/boot/armllb/inc/precomp.h
trunk/reactos/boot/armllb/main.c
trunk/reactos/boot/armllb/os/loader.c
Modified: trunk/reactos/boot/armllb/envir.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/envir.c?rev=45…
==============================================================================
--- trunk/reactos/boot/armllb/envir.c [iso-8859-1] (original)
+++ trunk/reactos/boot/armllb/envir.c [iso-8859-1] Wed Feb 3 04:14:59 2010
@@ -8,12 +8,111 @@
#include "precomp.h"
+ULONG LlbEnvHwPageSize;
+ULONG LlbEnvHwMemStart;
+ULONG LlbEnvHwMemSize;
+ULONG LlbEnvRamDiskStart;
+ULONG LlbEnvRamDiskSize;
+CHAR LlbEnvCmdLine[256];
+
+VOID
+NTAPI
+LlbEnvParseArguments(IN PATAG Arguments)
+{
+ PATAG Atag;
+
+ /* Parse the ATAGs */
+ Atag = Arguments;
+ while (Atag->Hdr.Size)
+ {
+ /* Check tag type */
+ switch (Atag->Hdr.Tag)
+ {
+ case ATAG_CORE:
+
+ /* Save page size */
+ LlbEnvHwPageSize = Atag->u.Core.PageSize;
+ break;
+
+ case ATAG_MEM:
+
+ /* Save RAM start and size */
+ LlbEnvHwMemStart = Atag->u.Mem.Start;
+ LlbEnvHwMemSize = Atag->u.Mem.Size;
+ break;
+
+ case ATAG_INITRD2:
+
+ /* Save RAMDISK start and size */
+ LlbEnvRamDiskStart = Atag->u.InitRd2.Start;
+ LlbEnvRamDiskSize = Atag->u.InitRd2.Size;
+ break;
+
+ case ATAG_CMDLINE:
+
+ /* Save command line */
+ strncpy(LlbEnvCmdLine,
+ Atag->u.CmdLine.CmdLine,
+ Atag->Hdr.Size * sizeof(ULONG));
+ break;
+
+ /* Nothing left to handle */
+ case ATAG_NONE:
+ default:
+ return;
+ }
+
+ /* Next tag */
+ Atag = (PATAG)((PULONG)Atag + Atag->Hdr.Size);
+ }
+
+ /* For debugging */
+ DbgPrint("[BOOTROM] PageSize: %dKB RAM: %dMB CMDLINE: %s\n",
+ LlbEnvHwPageSize / 1024, LlbEnvHwMemSize / 1024 / 1024, LlbEnvCmdLine);
+}
+
+VOID
+NTAPI
+LlbEnvGetMemoryInformation(IN PULONG Base,
+ IN PULONG Size)
+{
+ /* Return RAM information */
+ *Base = LlbEnvHwMemStart;
+ *Size = LlbEnvHwMemSize;
+}
+
+BOOLEAN
+NTAPI
+LlbEnvGetRamDiskInformation(IN PULONG Base,
+ IN PULONG Size)
+{
+ /* Do we have a ramdisk? */
+ if (LlbEnvRamDiskSize == 0)
+ {
+ /* No */
+ *Base = 0;
+ *Size = 0;
+ return FALSE;
+ }
+
+ /* Return ramdisk information */
+ *Base = LlbEnvRamDiskStart;
+ *Size = LlbEnvRamDiskSize;
+ return TRUE;
+}
+
PCHAR
NTAPI
LlbEnvRead(IN PCHAR ValueName)
{
- /* FIXME: HACK */
- return "RAMDISK";
+ PCHAR ValueData;
+
+ /* Search for the value name */
+ ValueData = strstr(LlbEnvCmdLine, ValueName);
+ if (ValueData) ValueData += strlen(ValueName) + 1;
+
+ /* Return the data */
+ return ValueData;
}
/* EOF */
Modified: trunk/reactos/boot/armllb/hw/versatile/hwinfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/hw/versatile/h…
==============================================================================
--- trunk/reactos/boot/armllb/hw/versatile/hwinfo.c [iso-8859-1] (original)
+++ trunk/reactos/boot/armllb/hw/versatile/hwinfo.c [iso-8859-1] Wed Feb 3 04:14:59 2010
@@ -40,9 +40,6 @@
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);
}
Modified: trunk/reactos/boot/armllb/hw/versatile/hwinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/hw/versatile/h…
==============================================================================
--- trunk/reactos/boot/armllb/hw/versatile/hwinit.c [iso-8859-1] (original)
+++ trunk/reactos/boot/armllb/hw/versatile/hwinit.c [iso-8859-1] Wed Feb 3 04:14:59 2010
@@ -29,8 +29,11 @@
NTAPI
LlbHwLoadOsLoaderFromRam(VOID)
{
- /* The OS Loader should have already been loaded by QEMU at the right place */
- return (POSLOADER_INIT)0x800000;
+ ULONG Base, Dummy;
+
+ /* On versatile, the loader is loaded with the RAMDISK. Just get the address */
+ LlbEnvGetRamDiskInformation(&Base, &Dummy);
+ return (POSLOADER_INIT)Base;
}
Added: trunk/reactos/boot/armllb/inc/envir.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/inc/envir.h?re…
==============================================================================
--- trunk/reactos/boot/armllb/inc/envir.h (added)
+++ trunk/reactos/boot/armllb/inc/envir.h [iso-8859-1] Wed Feb 3 04:14:59 2010
@@ -1,0 +1,88 @@
+/*
+ * PROJECT: ReactOS Boot Loader
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: boot/armllb/inc/envir.h
+ * PURPOSE: LLB Environment Functions
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+typedef struct _ATAG_HEADER
+{
+ ULONG Size;
+ ULONG Tag;
+} ATAG_HEADER, *PATAG_HEADER;
+
+typedef struct _ATAG_CORE
+{
+ ULONG Flags;
+ ULONG PageSize;
+ ULONG RootDev;
+} ATAG_CORE, *PATAG_CORE;
+
+typedef struct _ATAG_MEM
+{
+ ULONG Size;
+ ULONG Start;
+} ATAG_MEM, *PATAG_MEM;
+
+typedef struct _ATAG_INITRD2
+{
+ ULONG Start;
+ ULONG Size;
+} ATAG_INITRD2, *PATAG_INITRD2;
+
+typedef struct _ATAG_CMDLINE
+{
+ CHAR CmdLine[ANYSIZE_ARRAY];
+} ATAG_CMDLINE, *PATAG_CMDLINE;
+
+typedef struct _ATAG
+{
+ ATAG_HEADER Hdr;
+ union
+ {
+ ATAG_CORE Core;
+ ATAG_MEM Mem;
+ ATAG_INITRD2 InitRd2;
+ ATAG_CMDLINE CmdLine;
+ } u;
+} ATAG, *PATAG;
+
+#define ATAG_NONE 0x00000000
+#define ATAG_CORE 0x54410001
+#define ATAG_MEM 0x54410002
+#define ATAG_VIDEOTEXT 0x54410003
+#define ATAG_RAMDISK 0x54410004
+#define ATAG_INITRD2 0x54420005
+#define ATAG_SERIAL 0x54410006
+#define ATAG_REVISION 0x54410007
+#define ATAG_VIDEOLFB 0x54410008
+#define ATAG_CMDLINE 0x54410009
+
+PCHAR
+NTAPI
+LlbEnvRead(
+ IN PCHAR Option
+);
+
+BOOLEAN
+NTAPI
+LlbEnvGetRamDiskInformation(
+ IN PULONG Base,
+ IN PULONG Size
+);
+
+VOID
+NTAPI
+LlbEnvGetMemoryInformation(
+ IN PULONG Base,
+ IN PULONG Size
+);
+
+VOID
+NTAPI
+LlbEnvParseArguments(
+ IN PATAG Arguments
+);
+
+/* EOF */
Propchange: trunk/reactos/boot/armllb/inc/envir.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/boot/armllb/inc/envir.h
------------------------------------------------------------------------------
svn:executable = *
Modified: trunk/reactos/boot/armllb/inc/osloader.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/inc/osloader.h…
==============================================================================
--- trunk/reactos/boot/armllb/inc/osloader.h [iso-8859-1] (original)
+++ trunk/reactos/boot/armllb/inc/osloader.h [iso-8859-1] Wed Feb 3 04:14:59 2010
@@ -97,10 +97,4 @@
IN PCHAR CommandLine
);
-PCHAR
-NTAPI
-LlbEnvRead(
- IN PCHAR Option
-);
-
/* EOF */
Modified: trunk/reactos/boot/armllb/inc/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/inc/precomp.h?…
==============================================================================
--- trunk/reactos/boot/armllb/inc/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/boot/armllb/inc/precomp.h [iso-8859-1] Wed Feb 3 04:14:59 2010
@@ -16,6 +16,7 @@
#include "serial.h"
#include "video.h"
#include "keyboard.h"
+#include "envir.h"
VOID
DbgPrint(
Modified: trunk/reactos/boot/armllb/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/main.c?rev=453…
==============================================================================
--- trunk/reactos/boot/armllb/main.c [iso-8859-1] (original)
+++ trunk/reactos/boot/armllb/main.c [iso-8859-1] Wed Feb 3 04:14:59 2010
@@ -9,8 +9,16 @@
#include "precomp.h"
VOID
-LlbStartup(VOID)
+LlbStartup(IN ULONG Reserved,
+ IN ULONG BoardInfo,
+ IN PATAG Arguments)
{
+ /* Make sure we are booting on the correct kind of machine */
+ if (BoardInfo != LlbHwGetBoardType()) while (TRUE);
+
+ /* Either QEMU or U-Boot itself should send this information */
+ LlbEnvParseArguments(Arguments);
+
/* Initialize hardware components */
LlbHwInitialize();
Modified: trunk/reactos/boot/armllb/os/loader.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/armllb/os/loader.c?re…
==============================================================================
--- trunk/reactos/boot/armllb/os/loader.c [iso-8859-1] (original)
+++ trunk/reactos/boot/armllb/os/loader.c [iso-8859-1] Wed Feb 3 04:14:59 2010
@@ -38,7 +38,6 @@
LlbSetCommandLine(IN PCHAR CommandLine)
{
/* Copy the command line in the ARM block */
- printf("Command Line %s\n", CommandLine);
strcpy(ArmBlock.CommandLine, CommandLine);
}
@@ -61,11 +60,11 @@
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);
+ DbgPrint("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;
@@ -80,10 +79,16 @@
NTAPI
LlbBuildMemoryMap(VOID)
{
+ ULONG Base, Size;
+
/* Zero out the memory map */
memset(MemoryMap, 0, sizeof(MemoryMap));
+
+ /* Query memory information */
+ LlbEnvGetMemoryInformation(&Base, &Size);
+ LlbAllocateMemoryEntry(BiosMemoryUsable, Base, Size);
- /* Call the hardware-specific function */
+ /* Call the hardware-specific function for hardware-defined regions */
LlbHwBuildMemoryMap(MemoryMap);
}