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.

svn path=/trunk/; revision=32164
This commit is contained in:
ReactOS Portable Systems Group 2008-02-06 18:27:53 +00:00
parent bd50edb2a5
commit f20598a976
5 changed files with 90 additions and 130 deletions

View 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);
}

View file

@ -1,120 +1,91 @@
/* $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)
CCHAR DefaultOs[256];
CMDLINEINFO CmdLineInfo;
/* FUNCTIONS ******************************************************************/
VOID
CmdLineParse(IN PCHAR CmdLine)
{
while ('\0' != *s && isspace(*s))
{
s++;
}
PCHAR End, Setting;
ULONG Length;
return s;
//
// 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)
{
//
// 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);
}
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 */

View 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);
}

View file

@ -26,8 +26,6 @@ VOID BootMain(LPSTR CmdLine)
MachInit(CmdLine);
RamDiskInit(CmdLine);
DebugInit();
DbgPrint((DPRINT_WARNING, "BootMain() called.\n"));

View file

@ -12,12 +12,6 @@
//
// Ramdisk Routines
//
VOID
NTAPI
RamDiskInit(
IN PCHAR CmdLine
);
VOID
NTAPI
RamDiskSwitchFromBios(
@ -30,4 +24,7 @@ RamDiskCheckForVirtualFile(
VOID
);
extern PVOID gRamDiskBase;
extern ULONG gRamDiskSize;
#endif