MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / ProcessCommandLine

Function ProcessCommandLine

ShellPkg/Application/Shell/Shell.c:940–1182  ·  view source on GitHub ↗

Process all Uefi Shell 2.0 command line options. see Uefi Shell 2.0 section 3.2 for full details. the command line must resemble the following: shell.efi [ShellOpt-options] [options] [file-name [file-name-options]] ShellOpt-options Options which control the initialization behavior of the shell. These options are read from the EFI global variable "ShellOpt"

Source from the content-addressed store, hash-verified

938 @retval EFI_SUCCESS The variable is initialized.
939**/
940EFI_STATUS
941ProcessCommandLine(
942 VOID
943 )
944{
945 UINTN Size;
946 UINTN LoopVar;
947 CHAR16 *CurrentArg;
948 CHAR16 *DelayValueStr;
949 UINT64 DelayValue;
950 EFI_STATUS Status;
951 EFI_UNICODE_COLLATION_PROTOCOL *UnicodeCollation;
952
953 // `file-name-options` will contain arguments to `file-name` that we don't
954 // know about. This would cause ShellCommandLineParse to error, so we parse
955 // arguments manually, ignoring those after the first thing that doesn't look
956 // like a shell option (which is assumed to be `file-name`).
957
958 Status = gBS->LocateProtocol (
959 &gEfiUnicodeCollation2ProtocolGuid,
960 NULL,
961 (VOID **) &UnicodeCollation
962 );
963 if (EFI_ERROR(Status)) {
964 Status = gBS->LocateProtocol (
965 &gEfiUnicodeCollationProtocolGuid,
966 NULL,
967 (VOID **) &UnicodeCollation
968 );
969 if (EFI_ERROR (Status)) {
970 return Status;
971 }
972 }
973
974 // Set default options
975 ShellInfoObject.ShellInitSettings.BitUnion.Bits.Startup = FALSE;
976 ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoStartup = FALSE;
977 ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut = FALSE;
978 ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn = FALSE;
979 ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoInterrupt = FALSE;
980 ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoMap = FALSE;
981 ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoVersion = FALSE;
982 ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay = FALSE;
983 ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit = FALSE;
984 ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest = FALSE;
985 ShellInfoObject.ShellInitSettings.Delay = 5;
986
987 //
988 // Start LoopVar at 0 to parse only optional arguments at Argv[0]
989 // and parse other parameters from Argv[1]. This is for use case that
990 // UEFI Shell boot option is created, and OptionalData is provided
991 // that starts with shell command-line options.
992 //
993 for (LoopVar = 0 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {
994 CurrentArg = gEfiShellParametersProtocol->Argv[LoopVar];
995 if (UnicodeCollation->StriColl (
996 UnicodeCollation,
997 L"-startup",

Callers 1

UefiMainFunction · 0.85

Calls 4

ShellPrintHiiExFunction · 0.85
StrStrFunction · 0.85
StrnCmpFunction · 0.50

Tested by

no test coverage detected