X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=boot%2Ffreeldr%2Ffreeldr%2Fcmdline.c;h=001c9467fc836425bd91b1b3a8a918660b7f5f9c;hp=d75c63d8db7debcc12e3eb8a04f872e0a88820b2;hb=8d94b2a68ddaf93c3dfcbded456053b6e209430b;hpb=87f326521707b050e5a974d58625927850b21210 diff --git a/boot/freeldr/freeldr/cmdline.c b/boot/freeldr/freeldr/cmdline.c index d75c63d8db7..001c9467fc8 100644 --- a/boot/freeldr/freeldr/cmdline.c +++ b/boot/freeldr/freeldr/cmdline.c @@ -1,7 +1,7 @@ /* * PROJECT: ReactOS Boot Loader * LICENSE: BSD - See COPYING.ARM in the top level directory - * FILE: boot/freeldr/cmdline.c + * FILE: boot/freeldr/freeldr/cmdline.c * PURPOSE: FreeLDR Command Line Parsing * PROGRAMMERS: ReactOS Portable Systems Group */ @@ -12,54 +12,88 @@ /* GLOBALS ********************************************************************/ +typedef struct tagCMDLINEINFO +{ + PCCH DebugString; + PCCH DefaultOperatingSystem; + LONG TimeOut; +} CMDLINEINFO, *PCMDLINEINFO; + +CCHAR DebugString[256]; CCHAR DefaultOs[256]; CMDLINEINFO CmdLineInfo; /* FUNCTIONS ******************************************************************/ VOID -CmdLineParse(IN PCHAR CmdLine) +CmdLineParse(IN PCCH CmdLine) { PCHAR End, Setting; ULONG_PTR Length, Offset = 0; - // - // Set defaults - // + /* Set defaults */ + CmdLineInfo.DebugString = NULL; CmdLineInfo.DefaultOperatingSystem = NULL; CmdLineInfo.TimeOut = -1; - // - // Get timeout - // + /* + * Get debug string, in the following format: + * "debug=option1=XXX;option2=YYY;..." + * and translate it into the format: + * "OPTION1=XXX OPTION2=YYY ..." + */ + Setting = strstr(CmdLine, "debug="); + if (Setting) + { + /* Check if there are more command-line parameters following */ + Setting += sizeof("debug=") + sizeof(ANSI_NULL); + End = strstr(Setting, " "); + if (End) + Length = End - Setting; + else + Length = sizeof(DebugString); + + /* Copy the debug string and upcase it */ + strncpy(DebugString, Setting, Length); + DebugString[Length - 1] = ANSI_NULL; + _strupr(DebugString); + + /* Replace all separators ';' by spaces */ + Setting = DebugString; + while (*Setting) + { + if (*Setting == ';') *Setting = ' '; + Setting++; + } + + CmdLineInfo.DebugString = DebugString; + } + + /* Get timeout */ Setting = strstr(CmdLine, "timeout="); if (Setting) CmdLineInfo.TimeOut = atoi(Setting + sizeof("timeout=") + sizeof(ANSI_NULL)); - // - // Get default OS - // + /* Get default OS */ Setting = strstr(CmdLine, "defaultos="); if (Setting) { - // - // Check if there's more command-line parameters following - // + /* Check if there are more command-line parameters following */ Setting += sizeof("defaultos=") + sizeof(ANSI_NULL); End = strstr(Setting, " "); - if (End) Length = End - Setting; else Length = sizeof(DefaultOs); + if (End) + Length = End - Setting; + else + Length = sizeof(DefaultOs); - // - // Copy the default OS - // + /* Copy the default OS */ strncpy(DefaultOs, Setting, Length); + DefaultOs[Length - 1] = ANSI_NULL; CmdLineInfo.DefaultOperatingSystem = DefaultOs; } - // - // Get ramdisk base address - // + /* Get ramdisk base address */ Setting = strstr(CmdLine, "rdbase="); if (Setting) gRamDiskBase = (PVOID)(ULONG_PTR)strtoull(Setting + sizeof("rdbase=") - @@ -67,9 +101,7 @@ CmdLineParse(IN PCHAR CmdLine) NULL, 0); - // - // Get ramdisk size - // + /* Get ramdisk size */ Setting = strstr(CmdLine, "rdsize="); if (Setting) gRamDiskSize = strtoul(Setting + sizeof("rdsize=") - @@ -77,9 +109,7 @@ CmdLineParse(IN PCHAR CmdLine) NULL, 0); - // - // Get ramdisk offset - // + /* Get ramdisk offset */ Setting = strstr(CmdLine, "rdoffset="); if (Setting) Offset = strtoul(Setting + sizeof("rdoffset=") - @@ -87,12 +117,16 @@ CmdLineParse(IN PCHAR CmdLine) NULL, 0); - // - // Fix it up - // + /* Fix it up */ gRamDiskBase = (PVOID)((ULONG_PTR)gRamDiskBase + Offset); } +PCCH +CmdLineGetDebugString(VOID) +{ + return CmdLineInfo.DebugString; +} + PCCH CmdLineGetDefaultOS(VOID) {