2 * PROJECT: ReactOS Boot Loader
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: boot/freeldr/cmdline.c
5 * PURPOSE: FreeLDR Command Line Parsing
6 * PROGRAMMERS: ReactOS Portable Systems Group
9 /* INCLUDES *******************************************************************/
13 /* GLOBALS ********************************************************************/
15 typedef struct tagCMDLINEINFO
17 const char *DefaultOperatingSystem
;
19 } CMDLINEINFO
, *PCMDLINEINFO
;
22 CMDLINEINFO CmdLineInfo
;
24 /* FUNCTIONS ******************************************************************/
27 CmdLineParse(IN PCHAR CmdLine
)
30 ULONG_PTR Length
, Offset
= 0;
33 CmdLineInfo
.DefaultOperatingSystem
= NULL
;
34 CmdLineInfo
.TimeOut
= -1;
37 Setting
= strstr(CmdLine
, "timeout=");
38 if (Setting
) CmdLineInfo
.TimeOut
= atoi(Setting
+
43 Setting
= strstr(CmdLine
, "defaultos=");
46 /* Check if there's more command-line parameters following */
47 Setting
+= sizeof("defaultos=") + sizeof(ANSI_NULL
);
48 End
= strstr(Setting
, " ");
50 Length
= End
- Setting
;
52 Length
= sizeof(DefaultOs
);
54 /* Copy the default OS */
55 strncpy(DefaultOs
, Setting
, Length
);
56 CmdLineInfo
.DefaultOperatingSystem
= DefaultOs
;
59 /* Get ramdisk base address */
60 Setting
= strstr(CmdLine
, "rdbase=");
61 if (Setting
) gRamDiskBase
= (PVOID
)(ULONG_PTR
)strtoull(Setting
+
67 /* Get ramdisk size */
68 Setting
= strstr(CmdLine
, "rdsize=");
69 if (Setting
) gRamDiskSize
= strtoul(Setting
+
75 /* Get ramdisk offset */
76 Setting
= strstr(CmdLine
, "rdoffset=");
77 if (Setting
) Offset
= strtoul(Setting
+
84 gRamDiskBase
= (PVOID
)((ULONG_PTR
)gRamDiskBase
+ Offset
);
88 CmdLineGetDefaultOS(VOID
)
90 return CmdLineInfo
.DefaultOperatingSystem
;
94 CmdLineGetTimeOut(VOID
)
96 return CmdLineInfo
.TimeOut
;