Author: ros-arm-bringup
Date: Wed Feb 6 21:27:53 2008
New Revision: 32164
URL:
http://svn.reactos.org/svn/reactos?rev=32164&view=rev
Log:
We now support ArmDiskGetBootVolume for ramdisk only, later revisions will support NAND
boot as well.
The ramdisk parameter parsing had several bugs which were fixed, including support for hex
parameters and using proper return values from strstr.
We also rewrote command line parsing to be much simpler. It was very broken, modifying the
memory contents of the command line -- this wouldn't work on systems where the command
line is stored in ROM unless a copy is first made. It also broke ram disk parameters by
modifying whitespaces to NULL chars for purposes of reading its own parameters, but did
not put the whitespace back, terminating the command line early.
Finally, we now have an integrated ramdisk parameter parsing with the new command line
code.
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c
trunk/reactos/boot/freeldr/freeldr/cmdline.c
trunk/reactos/boot/freeldr/freeldr/disk/ramdisk.c
trunk/reactos/boot/freeldr/freeldr/freeldr.c
trunk/reactos/boot/freeldr/freeldr/include/ramdisk.h
Modified: trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/arm/stubs.c Wed Feb 6 21:27:53 2008
@@ -30,8 +30,16 @@
IN PULONGLONG SectorCount,
OUT PINT FsType)
{
- while (TRUE);
- return FALSE;
+ //
+ // We only support RAM disk for now -- add support for NAND later
+ //
+ ASSERT(gRamDiskBase);
+ ASSERT(gRamDiskSize);
+ *DriveNumber = 0x49;
+ *StartSector = 0;
+ *SectorCount = gRamDiskSize * 512;
+ *FsType = FS_FAT;
+ return TRUE;
}
VOID
@@ -183,4 +191,5 @@
// We can now print to the console
//
TuiPrintf("%s for ARM\n", GetFreeLoaderVersionString());
+ TuiPrintf("Bootargs: %s\n", CommandLine);
}
Modified: trunk/reactos/boot/freeldr/freeldr/cmdline.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/cmdli…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/cmdline.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/cmdline.c Wed Feb 6 21:27:53 2008
@@ -1,120 +1,91 @@
-/* $Id$
- *
- * FreeLoader
- * Copyright (C) 1998-2003 Brian Palmer <brianp(a)sginet.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+/*
+ * PROJECT: ReactOS Boot Loader
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: boot/freeldr/cmdline.c
+ * PURPOSE: FreeLDR Command Line Parsing
+ * PROGRAMMERS: ReactOS Portable Systems Group
*/
+
+/* INCLUDES *******************************************************************/
#include <freeldr.h>
-static CMDLINEINFO CmdLineInfo;
+/* GLOBALS ********************************************************************/
-static char *
-SkipWhitespace(char *s)
+CCHAR DefaultOs[256];
+CMDLINEINFO CmdLineInfo;
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+CmdLineParse(IN PCHAR CmdLine)
{
- while ('\0' != *s && isspace(*s))
+ PCHAR End, Setting;
+ ULONG Length;
+
+ //
+ // Set defaults
+ //
+ CmdLineInfo.DefaultOperatingSystem = NULL;
+ CmdLineInfo.TimeOut = -1;
+
+ //
+ // Get timeout
+ //
+ Setting = strstr(CmdLine, "timeout=");
+ if (Setting) CmdLineInfo.TimeOut = atoi(Setting +
+ sizeof("timeout=") +
+ sizeof(ANSI_NULL));
+
+ //
+ // Get default OS
+ //
+ Setting = strstr(CmdLine, "defaultos=");
+ if (Setting)
{
- s++;
+ //
+ // Check if there's more command-line parameters following
+ //
+ Setting += sizeof("defaultos=") + sizeof(ANSI_NULL);
+ End = strstr(Setting, " ");
+ if (End) Length = End - Setting; else Length = sizeof(DefaultOs);
+
+ //
+ // Copy the default OS
+ //
+ strncpy(DefaultOs, Setting, Length);
+ CmdLineInfo.DefaultOperatingSystem = DefaultOs;
}
-
- return s;
+
+ //
+ // Get ramdisk base address
+ //
+ Setting = strstr(CmdLine, "rdbase=");
+ if (Setting) gRamDiskBase = (PVOID)strtoul(Setting +
+ sizeof("rdbase=") -
+ sizeof(ANSI_NULL),
+ NULL,
+ 0);
+
+ //
+ // Get ramdisk size
+ //
+ Setting = strstr(CmdLine, "rdsize=");
+ if (Setting) gRamDiskSize = strtoul(Setting +
+ sizeof("rdsize=") -
+ sizeof(ANSI_NULL),
+ NULL,
+ 0);
}
-void
-CmdLineParse(char *CmdLine)
+PCCH
+CmdLineGetDefaultOS(VOID)
{
- char *s;
- char *Name;
- char *Value;
- char *End;
-
- CmdLineInfo.DefaultOperatingSystem = NULL;
- CmdLineInfo.TimeOut = -1;
-
- if (NULL == CmdLine)
- {
- return;
- }
-
- /* Skip over "kernel name" */
- s = CmdLine;
- while ('\0' != *s && ! isspace(*s))
- {
- s++;
- }
- s = SkipWhitespace(s);
-
- while ('\0' != *s)
- {
- Name = s;
- while (! isspace(*s) && '=' != *s && '\0' != *s)
- {
- s++;
- }
- End = s;
- s = SkipWhitespace(s);
- if ('=' == *s)
- {
- s++;
- *End = '\0';
- s = SkipWhitespace(s);
- if ('"' == *s)
- {
- s++;
- Value = s;
- while ('"' != *s && '\0' != *s)
- {
- s++;
- }
- }
- else
- {
- Value = s;
- while (! isspace(*s) && '\0' != *s)
- {
- s++;
- }
- }
- if ('\0' != *s)
- {
- *s++ = '\0';
- }
- if (0 == _stricmp(Name, "defaultos"))
- {
- CmdLineInfo.DefaultOperatingSystem = Value;
- }
- else if (0 == _stricmp(Name, "timeout"))
- {
- CmdLineInfo.TimeOut = atoi(Value);
- }
- }
- }
-}
-
-const char *
-CmdLineGetDefaultOS(void)
-{
- return CmdLineInfo.DefaultOperatingSystem;
+ return CmdLineInfo.DefaultOperatingSystem;
}
LONG
-CmdLineGetTimeOut(void)
+CmdLineGetTimeOut(VOID)
{
- return CmdLineInfo.TimeOut;
+ return CmdLineInfo.TimeOut;
}
-
-/* EOF */
-
Modified: trunk/reactos/boot/freeldr/freeldr/disk/ramdisk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/disk/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/disk/ramdisk.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/disk/ramdisk.c Wed Feb 6 21:27:53 2008
@@ -163,18 +163,3 @@
gCacheEnabled = FALSE;
}
}
-
-VOID
-NTAPI
-RamDiskInit(IN PCHAR CmdLine)
-{
- PCHAR Setting;
-
- //
- // Get RAM disk parameters
- //
- Setting = strstr(CmdLine, "rdbase=");
- if (Setting) gRamDiskBase = (PVOID)atoi(Setting);
- Setting = strstr(CmdLine, "rdsize=");
- if (Setting) gRamDiskSize = atoi(Setting);
-}
Modified: trunk/reactos/boot/freeldr/freeldr/freeldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freel…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/freeldr.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/freeldr.c Wed Feb 6 21:27:53 2008
@@ -26,8 +26,6 @@
MachInit(CmdLine);
- RamDiskInit(CmdLine);
-
DebugInit();
DbgPrint((DPRINT_WARNING, "BootMain() called.\n"));
Modified: trunk/reactos/boot/freeldr/freeldr/include/ramdisk.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/ramdisk.h (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/ramdisk.h Wed Feb 6 21:27:53 2008
@@ -14,12 +14,6 @@
//
VOID
NTAPI
-RamDiskInit(
- IN PCHAR CmdLine
-);
-
-VOID
-NTAPI
RamDiskSwitchFromBios(
VOID
);
@@ -30,4 +24,7 @@
VOID
);
+extern PVOID gRamDiskBase;
+extern ULONG gRamDiskSize;
+
#endif