We now support ArmDiskGetBootVolume for ramdisk only, later revisions will support...
authorReactOS Portable Systems Group <ros-arm-bringup@svn.reactos.org>
Wed, 6 Feb 2008 18:27:53 +0000 (18:27 +0000)
committerReactOS Portable Systems Group <ros-arm-bringup@svn.reactos.org>
Wed, 6 Feb 2008 18:27:53 +0000 (18:27 +0000)
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.

svn path=/trunk/; revision=32164

reactos/boot/freeldr/freeldr/arch/arm/stubs.c
reactos/boot/freeldr/freeldr/cmdline.c
reactos/boot/freeldr/freeldr/disk/ramdisk.c
reactos/boot/freeldr/freeldr/freeldr.c
reactos/boot/freeldr/freeldr/include/ramdisk.h

index 37aa9da..c2f64a1 100644 (file)
@@ -30,8 +30,16 @@ ArmDiskGetBootVolume(IN PULONG DriveNumber,
                      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 @@ MachInit(IN PCCH CommandLine)
     // We can now print to the console
     //
     TuiPrintf("%s for ARM\n", GetFreeLoaderVersionString());
+    TuiPrintf("Bootargs: %s\n", CommandLine);
 }
index 6f0dd6d..9a5e459 100644 (file)
-/* $Id$
- *
- *  FreeLoader
- *  Copyright (C) 1998-2003  Brian Palmer  <brianp@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)
-{
-  while ('\0' != *s && isspace(*s))
-    {
-      s++;
-    }
+CCHAR DefaultOs[256];
+CMDLINEINFO CmdLineInfo;
 
-  return s;
-}
+/* FUNCTIONS ******************************************************************/
 
-void
-CmdLineParse(char *CmdLine)
+VOID
+CmdLineParse(IN PCHAR CmdLine)
 {
-  char *s;
-  char *Name;
-  char *Value;
-  char *End;
+    PCHAR End, Setting;
+    ULONG Length;
 
-  CmdLineInfo.DefaultOperatingSystem = NULL;
-  CmdLineInfo.TimeOut = -1;
+    //
+    // 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));
 
-  if (NULL == CmdLine)
+    //
+    // Get default OS
+    //
+    Setting = strstr(CmdLine, "defaultos=");
+    if (Setting)
     {
-      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);
-            }
-        }
+        //
+        // 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;
     }
+    
+    //
+    // 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);
 }
 
-const char *
-CmdLineGetDefaultOS(void)
+PCCH
+CmdLineGetDefaultOS(VOID)
 {
-  return CmdLineInfo.DefaultOperatingSystem;
+    return CmdLineInfo.DefaultOperatingSystem;
 }
 
 LONG
-CmdLineGetTimeOut(void)
+CmdLineGetTimeOut(VOID)
 {
-  return CmdLineInfo.TimeOut;
+    return CmdLineInfo.TimeOut;
 }
-
-/* EOF */
-
index fa1fcd2..3dddb5a 100644 (file)
@@ -163,18 +163,3 @@ RamDiskSwitchFromBios(VOID)
         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);
-}
index 2af6cc1..278e31a 100644 (file)
@@ -26,8 +26,6 @@ VOID BootMain(LPSTR CmdLine)
 
        MachInit(CmdLine);
 
-       RamDiskInit(CmdLine);
-
        DebugInit();
 
        DbgPrint((DPRINT_WARNING, "BootMain() called.\n"));
index 12d1b35..d1e69aa 100644 (file)
 //
 // Ramdisk Routines
 //
-VOID
-NTAPI
-RamDiskInit(
-    IN PCHAR CmdLine
-);
-
 VOID
 NTAPI
 RamDiskSwitchFromBios(
@@ -30,4 +24,7 @@ RamDiskCheckForVirtualFile(
     VOID
 );
 
+extern PVOID gRamDiskBase;
+extern ULONG gRamDiskSize;
+
 #endif