21 DataTypeHexNumber = 0,
25 DataTypeDevicePath = 4,
54 for (Pos = String; *Pos != L
'\0'; ++Pos) {
75 if ((Data[0] == L
'0') && ((Data[1] == L
'x') || (Data[1] == L
'X'))) {
77 return DataTypeHexNumber;
79 return DataTypeUnKnow;
81 }
else if (Data[0] == L
'H') {
83 return DataTypeHexArray;
85 return DataTypeUnKnow;
87 }
else if (Data[0] == L
'S') {
89 }
else if (Data[0] == L
'L') {
90 return DataTypeUnicode;
91 }
else if ((Data[0] == L
'P') || (
StrnCmp (Data, L
"--", 2) == 0)) {
92 return DataTypeDevicePath;
96 return DataTypeHexArray;
138 if ((Data ==
NULL) || (BufferSize ==
NULL)) {
139 return EFI_INVALID_PARAMETER;
143 if (DataType == DataTypeHexNumber) {
148 HexNumberLen =
StrLen (Data + 2);
149 if ((HexNumberLen >= 1) && (HexNumberLen <= 2)) {
151 }
else if ((HexNumberLen >= 3) && (HexNumberLen <= 4)) {
153 }
else if ((HexNumberLen >= 5) && (HexNumberLen <= 8)) {
155 }
else if ((HexNumberLen >= 9) && (HexNumberLen <= 16)) {
159 if ((Buffer !=
NULL) && (*BufferSize >= Size)) {
160 CopyMem (Buffer, (VOID *)&HexNumber, Size);
162 Status = EFI_BUFFER_TOO_SMALL;
166 }
else if (DataType == DataTypeHexArray) {
175 if ((Buffer !=
NULL) && (*BufferSize >= Size)) {
178 Status = EFI_BUFFER_TOO_SMALL;
182 }
else if (DataType == DataTypeAscii) {
191 if (AsciiBuffer ==
NULL) {
192 Status = EFI_OUT_OF_RESOURCES;
197 if ((Buffer !=
NULL) && (*BufferSize >= Size)) {
198 CopyMem (Buffer, AsciiBuffer, Size);
200 Status = EFI_BUFFER_TOO_SMALL;
206 SHELL_FREE_NON_NULL (AsciiBuffer);
207 }
else if (DataType == DataTypeUnicode) {
215 Size =
StrSize (Data) -
sizeof (CHAR16);
216 if ((Buffer !=
NULL) && (*BufferSize >= Size)) {
219 Status = EFI_BUFFER_TOO_SMALL;
223 }
else if (DataType == DataTypeDevicePath) {
226 }
else if (
StrnCmp (Data, L
"--", 2) == 0) {
231 if (DevPath ==
NULL) {
233 Status = EFI_INVALID_PARAMETER;
236 if ((Buffer !=
NULL) && (*BufferSize >= Size)) {
237 CopyMem (Buffer, DevPath, Size);
239 Status = EFI_BUFFER_TOO_SMALL;
245 SHELL_FREE_NON_NULL (DevPath);
247 Status = EFI_INVALID_PARAMETER;
271 CONST CHAR16 *TempData;
283 return EFI_INVALID_PARAMETER;
288 if (TempData ==
NULL) {
289 ASSERT (TempData !=
NULL);
290 return EFI_INVALID_PARAMETER;
293 if (TempData[0] != L
'=') {
295 return EFI_INVALID_PARAMETER;
298 TempData = TempData + 1;
301 if (EFI_ERROR (Status)) {
302 if (Status == EFI_BUFFER_TOO_SMALL) {
308 if (Status == EFI_INVALID_PARAMETER) {
310 }
else if (Status == EFI_NOT_FOUND) {
319 *BufferSize = TotalSize;
322 if (*Buffer ==
NULL) {
323 Status = EFI_OUT_OF_RESOURCES;
325 BufferWalker = *Buffer;
328 TempData = TempData + 1;
332 if (!EFI_ERROR (Status)) {
333 BufferWalker = BufferWalker + Size;
334 TotalSize = TotalSize - Size;
358 RETURN_STATUS RStatus;
360 CHAR16 *ProblemParam;
362 CONST CHAR16 *VariableName;
364 CONST CHAR16 *StringGuid;
389 if (EFI_ERROR (Status)) {
390 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam !=
NULL)) {
407 if (VariableName ==
NULL) {
413 CopyGuid (&Guid, &gEfiGlobalVariableGuid);
416 if (StringGuid !=
NULL) {
424 if (
RETURN_ERROR (RStatus) || (StringGuid[GUID_STRING_LENGTH] != L
'\0')) {
434 Status =
gRT->GetVariable ((CHAR16 *)VariableName, &Guid, &Attributes, &Size, Buffer);
435 if (Status == EFI_BUFFER_TOO_SMALL) {
437 if (Buffer ==
NULL) {
443 Status =
gRT->GetVariable ((CHAR16 *)VariableName, &Guid, &Attributes, &Size, Buffer);
446 if (!EFI_ERROR (Status) && (Buffer !=
NULL)) {
448 for (LoopVar = 0; LoopVar < Size; LoopVar++) {
449 ShellPrintEx (-1, -1, L
"%02x ", ((UINT8 *)Buffer)[LoopVar]);
461 Status =
gRT->GetVariable ((CHAR16 *)VariableName, &Guid, &Attributes, &Size, Buffer);
462 if (Status == EFI_BUFFER_TOO_SMALL) {
464 if (Buffer ==
NULL) {
470 Status =
gRT->GetVariable ((CHAR16 *)VariableName, &Guid, &Attributes, &Size, Buffer);
473 if (EFI_ERROR (Status) || (Buffer ==
NULL)) {
479 Attributes |= EFI_VARIABLE_BOOTSERVICE_ACCESS;
483 Attributes |= EFI_VARIABLE_RUNTIME_ACCESS |
484 EFI_VARIABLE_BOOTSERVICE_ACCESS;
492 SHELL_FREE_NON_NULL (Buffer);
496 if (!EFI_ERROR (Status)) {
497 Status =
gRT->SetVariable ((CHAR16 *)VariableName, &Guid, Attributes, Size, Buffer);
500 if (EFI_ERROR (Status)) {
512 if (Buffer !=
NULL) {
516 return (ShellStatus);
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
INTN EFIAPI StrnCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString, IN UINTN Length)
RETURN_STATUS EFIAPI StrToGuid(IN CONST CHAR16 *String, OUT GUID *Guid)
RETURN_STATUS EFIAPI StrHexToBytes(IN CONST CHAR16 *String, IN UINTN Length, OUT UINT8 *Buffer, IN UINTN MaxBufferSize)
RETURN_STATUS EFIAPI StrHexToUint64S(IN CONST CHAR16 *String, OUT CHAR16 **EndPointer OPTIONAL, OUT UINT64 *Data)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI ConvertTextToDevicePath(IN CONST CHAR16 *TextDevicePath)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
UINTN EFIAPI AsciiSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString,...)
EFI_RUNTIME_SERVICES * gRT
#define RETURN_ERROR(StatusCode)
#define ASSERT_EFI_ERROR(StatusParameter)
@ SHELL_INVALID_PARAMETER
DATA_TYPE TestDataType(IN CONST CHAR16 *Data)
EFI_STATUS ParseParameterData(IN CONST CHAR16 *Data, OUT VOID *Buffer, IN OUT UINTN *BufferSize)
SHELL_STATUS EFIAPI ShellCommandRunSetVar(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS GetVariableDataFromParameter(IN CONST LIST_ENTRY *Package, OUT UINT8 **Buffer, OUT UINTN *BufferSize)
BOOLEAN IsStringOfHexNibbles(IN CONST CHAR16 *String)
EFI_STATUS EFIAPI CommandInit(VOID)
BOOLEAN EFIAPI ShellIsHexaDecimalDigitCharacter(IN CHAR16 Char)
CONST CHAR16 *EFIAPI ShellCommandLineGetValue(IN CONST LIST_ENTRY *CheckPackage, IN CHAR16 *KeyString)
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
@ TypeValue
A flag that has some data following it with a space (IE "-a 1").
@ TypeFlag
A flag that is present or not present only (IE "-a").
EFI_STATUS EFIAPI ShellCommandLineCheckDuplicate(IN CONST LIST_ENTRY *CheckPackage, OUT CHAR16 **Param)
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellInitialize(VOID)
EFI_STATUS EFIAPI ShellPrintEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR16 *Format,...)
CONST CHAR16 *EFIAPI ShellCommandLineGetRawValue(IN CONST LIST_ENTRY *CONST CheckPackage, IN UINTN Position)
UINTN EFIAPI ShellCommandLineGetCount(IN CONST LIST_ENTRY *CheckPackage)
#define EFI_VARIABLE_NON_VOLATILE