From 3737ac2bc3c2e6589d88be97345d641ea2006933 Mon Sep 17 00:00:00 2001 From: jcarsey Date: Fri, 25 Mar 2011 21:22:20 +0000 Subject: [PATCH] comp - add comments and add input verification bcfg - updated for bugs. compress - rename for coding standards. add comments. dblk - add comments, input verification, and a header line dmem - add comments, add input verification, add system table info dmpstore - add comments eficompress - add comments and add input verification efidecompress - add comments and add input verification loadpcirom - add comments and more output messages memmap - add more output to exceed the spec. mm - move functions, add comments, add input verification. mode - add comment pci - add input verification. SerMode - add comments and add input verification setsize - add comments and add input verification setvar - add comments and add input verification smbiosview - add input verification. clarify error messages. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11438 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/UefiShellDebug1CommandsLib/Bcfg.c | 331 ++- .../Library/UefiShellDebug1CommandsLib/Comp.c | 59 +- .../UefiShellDebug1CommandsLib/Compress.c | 1907 +++++++---------- .../UefiShellDebug1CommandsLib/Compress.h | 4 +- .../Library/UefiShellDebug1CommandsLib/Dblk.c | 103 +- .../Library/UefiShellDebug1CommandsLib/Dmem.c | 112 +- .../UefiShellDebug1CommandsLib/DmpStore.c | 64 +- .../UefiShellDebug1CommandsLib/EfiCompress.c | 101 +- .../EfiDecompress.c | 137 +- .../UefiShellDebug1CommandsLib/LoadPciRom.c | 101 +- .../UefiShellDebug1CommandsLib/MemMap.c | 85 +- .../Library/UefiShellDebug1CommandsLib/Mm.c | 334 +-- .../Library/UefiShellDebug1CommandsLib/Mode.c | 8 +- .../Library/UefiShellDebug1CommandsLib/Pci.c | 54 +- .../UefiShellDebug1CommandsLib/SerMode.c | 41 +- .../UefiShellDebug1CommandsLib/SetSize.c | 31 +- .../UefiShellDebug1CommandsLib/SetVar.c | 55 +- .../SmbiosView/SmbiosView.c | 18 +- .../SmbiosView/SmbiosViewStrings.uni | Bin 93274 -> 93274 bytes .../UefiShellDebug1CommandsLib.c | 484 ++++- .../UefiShellDebug1CommandsLib.h | 141 +- .../UefiShellDebug1CommandsLib.inf | 52 +- .../UefiShellDebug1CommandsLib.uni | Bin 59882 -> 150442 bytes 23 files changed, 2464 insertions(+), 1758 deletions(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c index 4c2eb3c1a8..73e8c57637 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c @@ -1,7 +1,7 @@ /** @file - Main file for bcfg shell install1 function. + Main file for bcfg shell Debug1 function. - Copyright (c) 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -19,20 +19,20 @@ #include typedef enum { - BCFG_TARGET_BOOT_ORDER = 0, - BCFG_TARGET_DRIVER_ORDER = 1, - BCFG_TARGET_MAX = 2 + BcfgTargetBootOrder = 0, + BcfgTargetDriverOrder = 1, + BcfgTargetMax = 2 } BCFG_OPERATION_TARGET; typedef enum { - BCFG_TYPE_DUMP = 0, - BCFG_TYPE_ADD = 1, - BCFG_TYPE_ADDP = 2, - BCFG_TYPE_ADDH = 3, - BCFG_TYPE_RM = 4, - BCFG_TYPE_MV = 5, - BCFG_TYPE_OPT = 6, - BCFG_TYPE_MAX = 7 + BcfgTypeDump = 0, + BcfgTypeAdd = 1, + BcfgTypeAddp = 2, + BcfgTypeAddh = 3, + BcfgTypeRm = 4, + BcfgTypeMv = 5, + BcfgTypeOpt = 6, + BcfgTypeMax = 7 } BCFG_OPERATION_TYPE; typedef struct { @@ -47,9 +47,25 @@ typedef struct { CONST CHAR16 *OptData; } BGFG_OPERATION; +/** + Function to add a option. + + @param[in] Position The position to add Target at. + @param[in] File The file to make the target. + @param[in] Desc The description text. + @param[in] CurrentOrder The pointer to the current order of items. + @param[in] OrderCount The number if items in CurrentOrder. + @param[in] Target The info on the option to add. + @param[in] UseHandle TRUE to use HandleNumber, FALSE to use File and Desc. + @param[in] UsePath TRUE to convert to devicepath. + @param[in] HandleNumber The handle number to add. + + @retval SHELL_SUCCESS The operation was successful. + @retval SHELL_INVALID_PARAMETER A parameter was invalid. +**/ SHELL_STATUS EFIAPI -BcfgAdd ( +BcfgAddDebug1( IN UINTN Position, IN CONST CHAR16 *File, IN CONST CHAR16 *Desc, @@ -62,10 +78,14 @@ BcfgAdd ( ) { EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *DevicePath, *FilePath, *FileNode, *DevPath; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_DEVICE_PATH_PROTOCOL *FilePath; + EFI_DEVICE_PATH_PROTOCOL *FileNode; + EFI_DEVICE_PATH_PROTOCOL *DevPath; CHAR16 *Str; - CONST CHAR16 *p; - UINT8 *p8; + CONST CHAR16 *StringWalker; + UINT8 *TempByteBuffer; + UINT8 *TempByteStart; EFI_SHELL_FILE_INFO *Arg; EFI_SHELL_FILE_INFO *FileList; CHAR16 OptionStr[40]; @@ -80,15 +100,21 @@ BcfgAdd ( UINTN ChildControllerHandleCount; SHELL_STATUS ShellStatus; UINT16 *NewOrder; + UINT64 Intermediate; if (!UseHandle) { - ASSERT(File != NULL); - ASSERT(Desc != NULL); + if (File == NULL || Desc == NULL) { + return (SHELL_INVALID_PARAMETER); + } } else { - ASSERT(HandleNumber != 0); + if (HandleNumber == 0) { + return (SHELL_INVALID_PARAMETER); + } } - ASSERT(Position <= (OrderCount+1)); + if (Position > OrderCount) { + Position = OrderCount; + } Str = NULL; FilePath = NULL; @@ -98,13 +124,10 @@ BcfgAdd ( ShellStatus = SHELL_SUCCESS; TargetLocation = 0xFFFF; -// if (Position > 0) { -// Position--; -// } - if (UseHandle) { - CurHandle = ConvertHandleIndexToHandle(StrHexToUintn(File)); - if (CurHandle == NULL) { + Status = ShellConvertStringToUint64(File, &Intermediate, TRUE, FALSE); + CurHandle = ConvertHandleIndexToHandle((UINTN)Intermediate); + if (CurHandle == NULL || EFI_ERROR(Status)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, File); ShellStatus = SHELL_INVALID_PARAMETER; } else { @@ -136,7 +159,7 @@ BcfgAdd ( (VOID**)&FilePath); } if (EFI_ERROR (Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_HANDLE), gShellDebug1HiiHandle, StrHexToUintn(File)); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_HANDLE), gShellDebug1HiiHandle, Intermediate); ShellStatus = SHELL_INVALID_PARAMETER; } } @@ -146,10 +169,16 @@ BcfgAdd ( // ShellOpenFileMetaArg ((CHAR16*)File, EFI_FILE_MODE_READ, &FileList); - // - // If filename expanded to multiple names, fail - // - if (FileList == NULL || FileList->Link.ForwardLink != FileList->Link.BackLink) { + if (FileList == NULL) { + // + // If filename matched nothing fail + // + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, File); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if (FileList->Link.ForwardLink != FileList->Link.BackLink) { + // + // If filename expanded to multiple names, fail + // ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE), gShellDebug1HiiHandle, File); ShellStatus = SHELL_INVALID_PARAMETER; } else { @@ -166,7 +195,7 @@ BcfgAdd ( // get the device path // DevicePath = mEfiShellProtocol->GetDevicePathFromFilePath(Arg->FullName); - if (DevicePath != NULL) { + if (DevicePath == NULL) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE_DP), gShellDebug1HiiHandle, Arg->FullName); ShellStatus = SHELL_UNSUPPORTED; } else { @@ -187,8 +216,8 @@ BcfgAdd ( // // append the file // - for(p=Arg->FullName; *p != CHAR_NULL && *p != ':'; p++); - FileNode = FileDevicePath(NULL, p+1); + for(StringWalker=Arg->FullName; *StringWalker != CHAR_NULL && *StringWalker != ':'; StringWalker++); + FileNode = FileDevicePath(NULL, StringWalker+1); FilePath = AppendDevicePath(DevicePath, FileNode); FreePool(FileNode); } else { @@ -207,7 +236,7 @@ BcfgAdd ( // Find a free target ,a brute force implementation // Found = FALSE; - for (TargetLocation=1; TargetLocation < 0xFFFF; TargetLocation++) { + for (TargetLocation=0; TargetLocation < 0xFFFF; TargetLocation++) { Found = TRUE; for (Index=0; Index < OrderCount; Index++) { if (CurrentOrder[Index] == TargetLocation) { @@ -235,32 +264,33 @@ BcfgAdd ( DescSize = StrSize(Desc); FilePathSize = GetDevicePathSize (FilePath); - p8 = AllocatePool(sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize); - *((UINT32 *) p8) = LOAD_OPTION_ACTIVE; // Attributes - p8 += sizeof (UINT32); + TempByteBuffer = AllocateZeroPool(sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize); + TempByteStart = TempByteBuffer; + *((UINT32 *) TempByteBuffer) = LOAD_OPTION_ACTIVE; // Attributes + TempByteBuffer += sizeof (UINT32); - *((UINT16 *) p8) = (UINT16)FilePathSize; // FilePathListLength - p8 += sizeof (UINT16); + *((UINT16 *) TempByteBuffer) = (UINT16)FilePathSize; // FilePathListLength + TempByteBuffer += sizeof (UINT16); - CopyMem (p8, Desc, DescSize); - p8 += DescSize; - CopyMem (p8, FilePath, FilePathSize); + CopyMem (TempByteBuffer, Desc, DescSize); + TempByteBuffer += DescSize; + CopyMem (TempByteBuffer, FilePath, FilePathSize); - UnicodeSPrint (OptionStr, sizeof(OptionStr), L"%s%04x", Target == BCFG_TARGET_BOOT_ORDER?L"Boot":L"Driver", TargetLocation); + UnicodeSPrint (OptionStr, sizeof(OptionStr), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", TargetLocation); Status = gRT->SetVariable ( OptionStr, &gEfiGlobalVariableGuid, EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize, - p8 + TempByteStart ); - FreePool(p8); + FreePool(TempByteStart); if (EFI_ERROR(Status)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellDebug1HiiHandle, OptionStr, Status); } else { - NewOrder = AllocatePool((OrderCount+1)*sizeof(NewOrder[0])); + NewOrder = AllocateZeroPool((OrderCount+1)*sizeof(NewOrder[0])); ASSERT(NewOrder != NULL); CopyMem(NewOrder, CurrentOrder, (OrderCount)*sizeof(NewOrder[0])); @@ -273,7 +303,7 @@ BcfgAdd ( NewOrder[Position] = (UINT16) TargetLocation; Status = gRT->SetVariable ( - Target == BCFG_TARGET_BOOT_ORDER?L"BootOrder":L"DriverOrder", + Target == BcfgTargetBootOrder?L"BootOrder":L"DriverOrder", &gEfiGlobalVariableGuid, EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, (OrderCount+1) * sizeof(UINT16), @@ -283,7 +313,7 @@ BcfgAdd ( FreePool(NewOrder); if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BCFG_TARGET_BOOT_ORDER?L"BootOrder":L"DriverOrder", Status); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BcfgTargetBootOrder?L"BootOrder":L"DriverOrder", Status); ShellStatus = SHELL_INVALID_PARAMETER; } else { Print (L"bcfg: Add %s as %x\n", OptionStr, Position); @@ -317,9 +347,20 @@ BcfgAdd ( return (ShellStatus); } +/** + Funciton to remove an item. + + @param[in] Target The target item to move. + @param[in] CurrentOrder The pointer to the current order of items. + @param[in] OrderCount The number if items in CurrentOrder. + @param[in] Location The current location of the Target. + + @retval SHELL_SUCCESS The operation was successful. + @retval SHELL_INVALID_PARAMETER A parameter was invalid. +**/ SHELL_STATUS EFIAPI -BcfgRemove( +BcfgRemoveDebug1( IN CONST BCFG_OPERATION_TARGET Target, IN CONST UINT16 *CurrentOrder, IN CONST UINTN OrderCount, @@ -332,7 +373,7 @@ BcfgRemove( UINTN LoopVar; UINTN NewCount; - UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Target == BCFG_TARGET_BOOT_ORDER?L"Boot":L"Driver", Location); + UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", Location); Status = gRT->SetVariable( VariableName, (EFI_GUID*)&gEfiGlobalVariableGuid, @@ -343,7 +384,7 @@ BcfgRemove( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, VariableName, Status); return (SHELL_INVALID_PARAMETER); } - NewOrder = AllocatePool(OrderCount*sizeof(CurrentOrder[0])); + NewOrder = AllocateZeroPool(OrderCount*sizeof(CurrentOrder[0])); NewCount = OrderCount; CopyMem(NewOrder, CurrentOrder, OrderCount*sizeof(CurrentOrder[0])); for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++){ @@ -353,7 +394,7 @@ BcfgRemove( } } Status = gRT->SetVariable( - Target == BCFG_TARGET_BOOT_ORDER?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", + Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", (EFI_GUID*)&gEfiGlobalVariableGuid, EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, NewCount*sizeof(NewOrder[0]), @@ -361,15 +402,27 @@ BcfgRemove( FreePool(NewOrder); if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BCFG_TARGET_BOOT_ORDER?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", Status); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", Status); return (SHELL_INVALID_PARAMETER); } return (SHELL_SUCCESS); } +/** + Funciton to move a item to another location. + + @param[in] Target The target item to move. + @param[in] CurrentOrder The pointer to the current order of items. + @param[in] OrderCount The number if items in CurrentOrder. + @param[in] OldLocation The current location of the Target. + @param[in] NewLocation The desired location of the Target. + + @retval SHELL_SUCCESS The operation was successful. + @retval SHELL_INVALID_PARAMETER A parameter was invalid. +**/ SHELL_STATUS EFIAPI -BcfgMove( +BcfgMoveDebug1( IN CONST BCFG_OPERATION_TARGET Target, IN CONST UINT16 *CurrentOrder, IN CONST UINTN OrderCount, @@ -381,7 +434,7 @@ BcfgMove( EFI_STATUS Status; UINT16 Temp; - NewOrder = AllocatePool(OrderCount*sizeof(CurrentOrder[0])); + NewOrder = AllocateZeroPool(OrderCount*sizeof(CurrentOrder[0])); ASSERT(NewOrder != NULL); Temp = CurrentOrder[OldLocation]; @@ -392,7 +445,7 @@ BcfgMove( Status = gRT->SetVariable( - Target == BCFG_TARGET_BOOT_ORDER?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", + Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", (EFI_GUID*)&gEfiGlobalVariableGuid, EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, OrderCount*sizeof(CurrentOrder[0]), @@ -401,7 +454,7 @@ BcfgMove( FreePool(NewOrder); if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BCFG_TARGET_BOOT_ORDER?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", Status); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", Status); return (SHELL_INVALID_PARAMETER); } return (SHELL_SUCCESS); @@ -409,9 +462,32 @@ BcfgMove( SHELL_STATUS EFIAPI -BcfgDisplayDump( +BcfgAddOptDebug1( + IN CONST CHAR16 *OptData, + IN CONST BCFG_OPERATION_TARGET Target + ) +{ + ASSERT(OptData != NULL); + return SHELL_SUCCESS; +} + +/** + Function to dump the Bcfg information. + + @param[in] Op The operation. + @param[in] OrderCount How many to dump. + @param[in] CurrentOrder The pointer to the current order of items. + @param[in] VerboseOutput TRUE for extra output. FALSE otherwise. + + @retval SHELL_SUCCESS The dump was successful. + @retval SHELL_INVALID_PARAMETER A parameter was invalid. +**/ +SHELL_STATUS +EFIAPI +BcfgDisplayDumpDebug1( IN CONST CHAR16 *Op, - IN CONST UINTN OrderCount, + IN CONST UINTN OrderCount, + IN CONST UINT16 *CurrentOrder, IN CONST BOOLEAN VerboseOutput ) { @@ -424,10 +500,15 @@ BcfgDisplayDump( CHAR16 *DevPathString; VOID *DevPath; + if (OrderCount == 0) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_BCFG_NONE), gShellDebug1HiiHandle); + return (SHELL_SUCCESS); + } + for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++) { Buffer = NULL; BufferSize = 0; - UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Op, LoopVar); + UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Op, CurrentOrder[LoopVar]); Status = gRT->GetVariable( VariableName, @@ -436,7 +517,7 @@ BcfgDisplayDump( &BufferSize, Buffer); if (Status == EFI_BUFFER_TOO_SMALL) { - Buffer = AllocatePool(BufferSize); + Buffer = AllocateZeroPool(BufferSize); Status = gRT->GetVariable( VariableName, (EFI_GUID*)&gEfiGlobalVariableGuid, @@ -450,7 +531,7 @@ BcfgDisplayDump( return (SHELL_INVALID_PARAMETER); } - DevPath = AllocatePool(*(UINT16*)(Buffer+4)); + DevPath = AllocateZeroPool(*(UINT16*)(Buffer+4)); CopyMem(DevPath, Buffer+6+StrSize((CHAR16*)(Buffer+6)), *(UINT16*)(Buffer+4)); DevPathString = gDevPathToText->ConvertDevicePathToText(DevPath, TRUE, FALSE); ShellPrintHiiEx( @@ -459,6 +540,7 @@ BcfgDisplayDump( NULL, STRING_TOKEN(STR_BCFG_LOAD_OPTIONS), gShellDebug1HiiHandle, + LoopVar, VariableName, (CHAR16*)(Buffer+6), DevPathString, @@ -492,15 +574,20 @@ BcfgDisplayDump( return (SHELL_SUCCESS); } +/** + Function to initialize the BCFG operation structure. + + @param[in] Struct The stuct to initialize. +**/ VOID EFIAPI -InitBcfgStruct( +InitBcfgStructDebug1( IN BGFG_OPERATION *Struct ) { ASSERT(Struct != NULL); - Struct->Target = BCFG_TARGET_MAX; - Struct->Type = BCFG_TYPE_MAX; + Struct->Target = BcfgTargetMax; + Struct->Type = BcfgTypeMax; Struct->Number1 = 0; Struct->Number2 = 0; Struct->HandleIndex = 0; @@ -538,13 +625,14 @@ ShellCommandRunBcfg ( CONST CHAR16 *CurrentParam; BGFG_OPERATION CurrentOperation; UINTN Length; + UINT64 Intermediate; Length = 0; ProblemParam = NULL; Package = NULL; ShellStatus = SHELL_SUCCESS; - InitBcfgStruct(&CurrentOperation); + InitBcfgStructDebug1(&CurrentOperation); // // initialize the shell lib (we must be in non-auto-init...) @@ -568,44 +656,51 @@ ShellCommandRunBcfg ( ASSERT(FALSE); } } else { + // + // Read in if we are doing -OPT + // + if (ShellCommandLineGetFlag(Package, L"-opt")) { + CurrentOperation.OptData = ShellCommandLineGetValue(Package, L"-opt"); + if (CurrentOperation.OptData == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, L"-opt"); + ShellStatus = SHELL_INVALID_PARAMETER; + } + CurrentOperation.Type = BcfgTypeOpt; + } + // // small block to read the target of the operation // - if (ShellCommandLineGetCount(Package) < 3) { + if ((ShellCommandLineGetCount(Package) < 3 && CurrentOperation.Type != BcfgTypeOpt) || + (ShellCommandLineGetCount(Package) < 2 && CurrentOperation.Type == BcfgTypeOpt) + ){ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)ShellCommandLineGetRawValue(Package, 1), L"driver") == 0) { - CurrentOperation.Target = BCFG_TARGET_DRIVER_ORDER; + CurrentOperation.Target = BcfgTargetDriverOrder; } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)ShellCommandLineGetRawValue(Package, 1), L"boot") == 0) { - CurrentOperation.Target = BCFG_TARGET_BOOT_ORDER; + CurrentOperation.Target = BcfgTargetBootOrder; } else { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_DRIVER_BOOT), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; } - // - // Read in if we are doing -OPT - // - if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BCFG_TARGET_MAX && ShellCommandLineGetFlag(Package, L"-opt")) { - CurrentOperation.OptData = ShellCommandLineGetValue(Package, L"-opt"); - CurrentOperation.Type = BCFG_TYPE_OPT; - } // // Read in the boot or driver order environment variable (not needed for opt) // - if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BCFG_TARGET_MAX && CurrentOperation.Type != BCFG_TYPE_OPT) { + if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax && CurrentOperation.Type != BcfgTypeOpt) { Length = 0; Status = gRT->GetVariable( - CurrentOperation.Target == BCFG_TARGET_BOOT_ORDER?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", + CurrentOperation.Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, CurrentOperation.Order); if (Status == EFI_BUFFER_TOO_SMALL) { - CurrentOperation.Order = AllocatePool(Length+(4*sizeof(CurrentOperation.Order[0]))); + CurrentOperation.Order = AllocateZeroPool(Length+(4*sizeof(CurrentOperation.Order[0]))); Status = gRT->GetVariable( - CurrentOperation.Target == BCFG_TARGET_BOOT_ORDER?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", + CurrentOperation.Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, @@ -616,11 +711,11 @@ ShellCommandRunBcfg ( // // large block to read the type of operation and verify parameter types for the info. // - if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BCFG_TARGET_MAX) { + if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax) { for (ParamNumber = 2 ; ParamNumber < ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS; ParamNumber++) { CurrentParam = ShellCommandLineGetRawValue(Package, ParamNumber); if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"dump") == 0) { - CurrentOperation.Type = BCFG_TYPE_DUMP; + CurrentOperation.Type = BcfgTypeDump; } else if (ShellCommandLineGetFlag(Package, L"-v")) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"-v (without dump)"); ShellStatus = SHELL_INVALID_PARAMETER; @@ -629,13 +724,14 @@ ShellCommandRunBcfg ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; } - CurrentOperation.Type = BCFG_TYPE_ADD; + CurrentOperation.Type = BcfgTypeAdd; CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); ShellStatus = SHELL_INVALID_PARAMETER; } else { - CurrentOperation.Number1 = (UINT16)StrHexToUintn(CurrentParam); + Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE); + CurrentOperation.Number1 = (UINT16)Intermediate; ASSERT(CurrentOperation.FileName == NULL); CurrentOperation.FileName = StrnCatGrow(&CurrentOperation.FileName , NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0); ASSERT(CurrentOperation.Description == NULL); @@ -646,13 +742,14 @@ ShellCommandRunBcfg ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; } - CurrentOperation.Type = BCFG_TYPE_ADDP; + CurrentOperation.Type = BcfgTypeAddp; CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); ShellStatus = SHELL_INVALID_PARAMETER; } else { - CurrentOperation.Number1 = (UINT16)StrHexToUintn(CurrentParam); + Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE); + CurrentOperation.Number1 = (UINT16)Intermediate; ASSERT(CurrentOperation.FileName == NULL); CurrentOperation.FileName = StrnCatGrow(&CurrentOperation.FileName , NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0); ASSERT(CurrentOperation.Description == NULL); @@ -663,19 +760,21 @@ ShellCommandRunBcfg ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; } - CurrentOperation.Type = BCFG_TYPE_ADDH; + CurrentOperation.Type = BcfgTypeAddh; CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); ShellStatus = SHELL_INVALID_PARAMETER; } else { - CurrentOperation.Number1 = (UINT16)StrHexToUintn(CurrentParam); + Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE); + CurrentOperation.Number1 = (UINT16)Intermediate; CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); ShellStatus = SHELL_INVALID_PARAMETER; } else { - CurrentOperation.HandleIndex = (UINT16)StrHexToUintn(CurrentParam); + Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE); + CurrentOperation.HandleIndex = (UINT16)Intermediate; ASSERT(CurrentOperation.Description == NULL); CurrentOperation.Description = StrnCatGrow(&CurrentOperation.Description, NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0); } @@ -685,13 +784,14 @@ ShellCommandRunBcfg ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; } - CurrentOperation.Type = BCFG_TYPE_RM; + CurrentOperation.Type = BcfgTypeRm; CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); ShellStatus = SHELL_INVALID_PARAMETER; } else { - CurrentOperation.Number1 = (UINT16)StrHexToUintn(CurrentParam); + Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE); + CurrentOperation.Number1 = (UINT16)Intermediate; if (CurrentOperation.Number1 > (Length / sizeof(CurrentOperation.Order[0]))){ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_NUMB_RANGE), gShellDebug1HiiHandle, Length / sizeof(CurrentOperation.Order[0])); ShellStatus = SHELL_INVALID_PARAMETER; @@ -702,13 +802,14 @@ ShellCommandRunBcfg ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; } - CurrentOperation.Type = BCFG_TYPE_MV; + CurrentOperation.Type = BcfgTypeMv; CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber); if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); ShellStatus = SHELL_INVALID_PARAMETER; } else { - CurrentOperation.Number1 = (UINT16)StrHexToUintn(CurrentParam); + Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE); + CurrentOperation.Number1 = (UINT16)Intermediate; if (CurrentOperation.Number1 > (Length / sizeof(CurrentOperation.Order[0]))){ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_NUMB_RANGE), gShellDebug1HiiHandle, Length / sizeof(CurrentOperation.Order[0])); ShellStatus = SHELL_INVALID_PARAMETER; @@ -718,7 +819,8 @@ ShellCommandRunBcfg ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam); ShellStatus = SHELL_INVALID_PARAMETER; } else { - CurrentOperation.Number2 = (UINT16)StrHexToUintn(CurrentParam); + Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE); + CurrentOperation.Number2 = (UINT16)Intermediate; } if (CurrentOperation.Number2 == CurrentOperation.Number1 ||CurrentOperation.Number1 > (Length / sizeof(CurrentOperation.Order[0])) @@ -734,47 +836,52 @@ ShellCommandRunBcfg ( } } } - if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BCFG_TARGET_MAX && CurrentOperation.Type < BCFG_TYPE_MAX) { + if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax && CurrentOperation.Type < BcfgTypeMax) { // // we have all the info. Do the work // switch (CurrentOperation.Type) { - case BCFG_TYPE_DUMP: - ShellStatus = BcfgDisplayDump( - CurrentOperation.Target == BCFG_TARGET_BOOT_ORDER?L"Boot":L"Driver", + case BcfgTypeDump: + ShellStatus = BcfgDisplayDumpDebug1( + CurrentOperation.Target == BcfgTargetBootOrder?L"Boot":L"Driver", Length / sizeof(CurrentOperation.Order[0]), + CurrentOperation.Order, ShellCommandLineGetFlag(Package, L"-v")); break; - case BCFG_TYPE_MV: - ShellStatus = BcfgMove( + case BcfgTypeMv: + ShellStatus = BcfgMoveDebug1( CurrentOperation.Target, CurrentOperation.Order, Length / sizeof(CurrentOperation.Order[0]), CurrentOperation.Number1, CurrentOperation.Number2); break; - case BCFG_TYPE_RM: - ShellStatus = BcfgRemove( + case BcfgTypeRm: + ShellStatus = BcfgRemoveDebug1( CurrentOperation.Target, CurrentOperation.Order, Length / sizeof(CurrentOperation.Order[0]), CurrentOperation.Number1); break; - case BCFG_TYPE_ADD: - case BCFG_TYPE_ADDP: - case BCFG_TYPE_ADDH: - ShellStatus = BcfgAdd( + case BcfgTypeAdd: + case BcfgTypeAddp: + case BcfgTypeAddh: + ShellStatus = BcfgAddDebug1( CurrentOperation.Number1, CurrentOperation.FileName, CurrentOperation.Description, CurrentOperation.Order, - Length, + Length / sizeof(CurrentOperation.Order[0]), CurrentOperation.Target, - (BOOLEAN)(CurrentOperation.Type == BCFG_TYPE_ADDH), - (BOOLEAN)(CurrentOperation.Type == BCFG_TYPE_ADDP), + (BOOLEAN)(CurrentOperation.Type == BcfgTypeAddh), + (BOOLEAN)(CurrentOperation.Type == BcfgTypeAddp), CurrentOperation.HandleIndex); break; - case BCFG_TYPE_OPT: + case BcfgTypeOpt: + ShellStatus = BcfgAddOptDebug1( + CurrentOperation.OptData, + CurrentOperation.Target); + break; default: ASSERT(FALSE); } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c index c6933e6095..b59ef31682 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c @@ -1,7 +1,7 @@ /** @file Main file for Comp shell Debug1 function. - Copyright (c) 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -14,6 +14,12 @@ #include "UefiShellDebug1CommandsLib.h" +/** + Function for 'comp' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ SHELL_STATUS EFIAPI ShellCommandRunComp ( @@ -83,24 +89,26 @@ ShellCommandRunComp ( ShellStatus = SHELL_INVALID_PARAMETER; } else { FileName1 = ShellFindFilePath(ShellCommandLineGetRawValue(Package, 1)); - FileName2 = ShellFindFilePath(ShellCommandLineGetRawValue(Package, 2)); - Status = ShellOpenFileByName(FileName1, &FileHandle1, EFI_FILE_MODE_READ, 0); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1), Status); + if (FileName1 == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1)); ShellStatus = SHELL_NOT_FOUND; + } else { + Status = ShellOpenFileByName(FileName1, &FileHandle1, EFI_FILE_MODE_READ, 0); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1), Status); + ShellStatus = SHELL_NOT_FOUND; + } } - Status = ShellOpenFileByName(FileName2, &FileHandle2, EFI_FILE_MODE_READ, 0); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status); + FileName2 = ShellFindFilePath(ShellCommandLineGetRawValue(Package, 2)); + if (FileName2 == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2)); ShellStatus = SHELL_NOT_FOUND; - } - if (FileHandleIsDirectory(FileHandle1) == EFI_SUCCESS){ - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, FileName1); - ShellStatus = SHELL_INVALID_PARAMETER; - } - if (FileHandleIsDirectory(FileHandle2) == EFI_SUCCESS){ - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, FileName2); - ShellStatus = SHELL_INVALID_PARAMETER; + } else { + Status = ShellOpenFileByName(FileName2, &FileHandle2, EFI_FILE_MODE_READ, 0); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status); + ShellStatus = SHELL_NOT_FOUND; + } } if (ShellStatus == SHELL_SUCCESS) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_HEADER), gShellDebug1HiiHandle, FileName1, FileName2); @@ -228,22 +236,19 @@ ShellCommandRunComp ( ShellStatus = SHELL_NOT_EQUAL; } } - } - if (ErrorCount == 0) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_PASS), gShellDebug1HiiHandle); - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_FAIL), gShellDebug1HiiHandle); + if (ErrorCount == 0) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_PASS), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_FAIL), gShellDebug1HiiHandle); + } } } ShellCommandLineFreeVarList (Package); } - if (FileName1 != NULL) { - FreePool(FileName1); - } - if (FileName2 != NULL) { - FreePool(FileName2); - } + SHELL_FREE_NON_NULL(FileName1); + SHELL_FREE_NON_NULL(FileName2); + if (FileHandle1 != NULL) { gEfiShellProtocol->CloseFile(FileHandle1); } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c index 9e880e6d6b..870335b9a1 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c @@ -7,7 +7,7 @@ This sequence is further divided into Blocks and Huffman codings are applied to each Block. - Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -39,9 +39,9 @@ typedef INT16 NODE; #define CODE_BIT 16 #define NIL 0 #define MAX_HASH_VAL (3 * WNDSIZ + (WNDSIZ / 512 + 1) * UINT8_MAX) -#define HASH(p, c) ((p) + ((c) << (WNDBIT - 9)) + WNDSIZ * 2) +#define HASH(LoopVar7, LoopVar5) ((LoopVar7) + ((LoopVar5) << (WNDBIT - 9)) + WNDSIZ * 2) #define CRCPOLY 0xA001 -#define UPDATE_CRC(c) mCrc = mCrcTable[(mCrc ^ (c)) & 0xFF] ^ (mCrc >> UINT8_BIT) +#define UPDATE_CRC(LoopVar5) mCrc = mCrcTable[(mCrc ^ (LoopVar5)) & 0xFF] ^ (mCrc >> UINT8_BIT) // // C: the Char&Len Set; P: the Position Set; T: the exTra Set @@ -72,287 +72,85 @@ PutDword( IN UINT32 Data ); -EFI_STATUS -EFIAPI -AllocateMemory ( - VOID - ); - -VOID -EFIAPI -FreeMemory ( - VOID - ); - -VOID -EFIAPI -InitSlide ( - VOID - ); - -NODE -EFIAPI -Child ( - IN NODE q, - IN UINT8 c - ); - -VOID -EFIAPI -MakeChild ( - IN NODE q, - IN UINT8 c, - IN NODE r - ); - -VOID -EFIAPI -Split ( - IN NODE Old - ); - -VOID -EFIAPI -InsertNode ( - VOID - ); - -VOID -EFIAPI -DeleteNode ( - VOID - ); - -VOID -EFIAPI -GetNextMatch ( - VOID - ); - -EFI_STATUS -EFIAPI -Encode ( - VOID - ); - -VOID -EFIAPI -CountTFreq ( - VOID - ); - -VOID -EFIAPI -WritePTLen ( - IN INT32 n, - IN INT32 nbit, - IN INT32 Special - ); - -VOID -EFIAPI -WriteCLen ( - VOID - ); - -VOID -EFIAPI -EncodeC ( - IN INT32 c - ); - -VOID -EFIAPI -EncodeP ( - IN UINT32 p - ); - -VOID -EFIAPI -SendBlock ( - VOID - ); - -VOID -EFIAPI -CompressOutput ( - IN UINT32 c, - IN UINT32 p - ); - -VOID -EFIAPI -HufEncodeStart ( - VOID - ); - -VOID -EFIAPI -HufEncodeEnd ( - VOID - ); - -VOID -EFIAPI -MakeCrcTable ( - VOID - ); - -VOID -EFIAPI -PutBits ( - IN INT32 n, - IN UINT32 x - ); - -INT32 -EFIAPI -FreadCrc ( - OUT UINT8 *p, - IN INT32 n - ); - -VOID -EFIAPI -InitPutBits ( - VOID - ); - -VOID -EFIAPI -CountLen ( - IN INT32 i - ); - -VOID -EFIAPI -MakeLen ( - IN INT32 Root - ); - -VOID -EFIAPI -DownHeap ( - IN INT32 i - ); - -VOID -EFIAPI -MakeCode ( - IN INT32 n, - IN UINT8 Len[ ], - OUT UINT16 Code[ ] - ); - -INT32 -EFIAPI -MakeTree ( - IN INT32 NParm, - IN UINT16 FreqParm[ ], - OUT UINT8 LenParm[ ], - OUT UINT16 CodeParm[ ] - ); - // // Global Variables // -STATIC UINT8 *mSrc, *mDst, *mSrcUpperLimit, *mDstUpperLimit; - -STATIC UINT8 *mLevel, *mText, *mChildCount, *mBuf, mCLen[NC], mPTLen[NPT], *mLen; +STATIC UINT8 *mSrc; +STATIC UINT8 *mDst; +STATIC UINT8 *mSrcUpperLimit; +STATIC UINT8 *mDstUpperLimit; + +STATIC UINT8 *mLevel; +STATIC UINT8 *mText; +STATIC UINT8 *mChildCount; +STATIC UINT8 *mBuf; +STATIC UINT8 mCLen[NC]; +STATIC UINT8 mPTLen[NPT]; +STATIC UINT8 *mLen; STATIC INT16 mHeap[NC + 1]; -STATIC INT32 mRemainder, mMatchLen, mBitCount, mHeapSize, mN; -STATIC UINT32 mBufSiz = 0, mOutputPos, mOutputMask, mSubBitBuf, mCrc; -STATIC UINT32 mCompSize, mOrigSize; - -STATIC UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1], - mCrcTable[UINT8_MAX + 1], mCFreq[2 * NC - 1], mCTable[4096], mCCode[NC], - mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1]; +STATIC INT32 mRemainder; +STATIC INT32 mMatchLen; +STATIC INT32 mBitCount; +STATIC INT32 mHeapSize; +STATIC INT32 mTempInt32; +STATIC UINT32 mBufSiz = 0; +STATIC UINT32 mOutputPos; +STATIC UINT32 mOutputMask; +STATIC UINT32 mSubBitBuf; +STATIC UINT32 mCrc; +STATIC UINT32 mCompSize; +STATIC UINT32 mOrigSize; + +STATIC UINT16 *mFreq; +STATIC UINT16 *mSortPtr; +STATIC UINT16 mLenCnt[17]; +STATIC UINT16 mLeft[2 * NC - 1]; +STATIC UINT16 mRight[2 * NC - 1]; +STATIC UINT16 mCrcTable[UINT8_MAX + 1]; +STATIC UINT16 mCFreq[2 * NC - 1]; +STATIC UINT16 mCTable[4096]; +STATIC UINT16 mCCode[NC]; +STATIC UINT16 mPFreq[2 * NP - 1]; +STATIC UINT16 mPTCode[NPT]; +STATIC UINT16 mTFreq[2 * NT - 1]; + +STATIC NODE mPos; +STATIC NODE mMatchPos; +STATIC NODE mAvail; +STATIC NODE *mPosition; +STATIC NODE *mParent; +STATIC NODE *mPrev; +STATIC NODE *mNext = NULL; +INT32 mHuffmanDepth = 0; -STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL; - -// -// functions -// /** - The compression routine. - - @param[in] SrcBuffer The buffer containing the source data. - @param[in] SrcSizae Number of bytes in SrcBuffer. - @param[in] DstBuffer The buffer to put the compressed image in. - @param[in,out] DstSize On input the size (in bytes) of DstBuffer, on - return the number of bytes placed in DstBuffer. + Make a CRC table. - @retval EFI_SUCCESS The compression was sucessful. - @retval EFI_BUFFER_TOO_SMALL The buffer was too small. DstSize is required. **/ -EFI_STATUS +VOID EFIAPI -Compress ( - IN VOID *SrcBuffer, - IN UINT64 SrcSize, - IN VOID *DstBuffer, - IN OUT UINT64 *DstSize +MakeCrcTable ( + VOID ) { - EFI_STATUS Status; - - // - // Initializations - // - mBufSiz = 0; - mBuf = NULL; - mText = NULL; - mLevel = NULL; - mChildCount = NULL; - mPosition = NULL; - mParent = NULL; - mPrev = NULL; - mNext = NULL; - - mSrc = SrcBuffer; - mSrcUpperLimit = mSrc + SrcSize; - mDst = DstBuffer; - mDstUpperLimit = mDst +*DstSize; - - PutDword (0L); - PutDword (0L); + UINT32 LoopVar1; - MakeCrcTable (); + UINT32 LoopVar2; - mOrigSize = mCompSize = 0; - mCrc = INIT_CRC; + UINT32 LoopVar4; - // - // Compress it - // - Status = Encode (); - if (EFI_ERROR (Status)) { - return EFI_OUT_OF_RESOURCES; - } - // - // Null terminate the compressed data - // - if (mDst < mDstUpperLimit) { - *mDst++ = 0; - } - // - // Fill in compressed size and original size - // - mDst = DstBuffer; - PutDword (mCompSize + 1); - PutDword (mOrigSize); + for (LoopVar1 = 0; LoopVar1 <= UINT8_MAX; LoopVar1++) { + LoopVar4 = LoopVar1; + for (LoopVar2 = 0; LoopVar2 < UINT8_BIT; LoopVar2++) { + if ((LoopVar4 & 1) != 0) { + LoopVar4 = (LoopVar4 >> 1) ^ CRCPOLY; + } else { + LoopVar4 >>= 1; + } + } - // - // Return - // - if (mCompSize + 1 + 8 > *DstSize) { - *DstSize = mCompSize + 1 + 8; - return EFI_BUFFER_TOO_SMALL; - } else { - *DstSize = mCompSize + 1 + 8; - return EFI_SUCCESS; + mCrcTable[LoopVar1] = (UINT16) LoopVar4; } - } /** @@ -383,45 +181,35 @@ PutDword ( } } +/** + Allocate memory spaces for data structures used in compression process. + + @retval EFI_SUCCESS Memory was allocated successfully. + @retval EFI_OUT_OF_RESOURCES A memory allocation failed. +**/ EFI_STATUS EFIAPI AllocateMemory ( VOID ) -/*++ - -Routine Description: - - Allocate memory spaces for data structures used in compression process - -Arguments: - - None - -Returns: - - EFI_SUCCESS - Memory is allocated successfully - EFI_OUT_OF_RESOURCES - Allocation fails - -**/ { mText = AllocateZeroPool (WNDSIZ * 2 + MAXMATCH); - mLevel = AllocatePool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mLevel)); - mChildCount = AllocatePool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mChildCount)); - mPosition = AllocatePool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mPosition)); - mParent = AllocatePool (WNDSIZ * 2 * sizeof (*mParent)); - mPrev = AllocatePool (WNDSIZ * 2 * sizeof (*mPrev)); - mNext = AllocatePool ((MAX_HASH_VAL + 1) * sizeof (*mNext)); + mLevel = AllocateZeroPool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mLevel)); + mChildCount = AllocateZeroPool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mChildCount)); + mPosition = AllocateZeroPool ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mPosition)); + mParent = AllocateZeroPool (WNDSIZ * 2 * sizeof (*mParent)); + mPrev = AllocateZeroPool (WNDSIZ * 2 * sizeof (*mPrev)); + mNext = AllocateZeroPool ((MAX_HASH_VAL + 1) * sizeof (*mNext)); mBufSiz = BLKSIZ; - mBuf = AllocatePool (mBufSiz); + mBuf = AllocateZeroPool (mBufSiz); while (mBuf == NULL) { mBufSiz = (mBufSiz / 10U) * 9U; if (mBufSiz < 4 * 1024U) { return EFI_OUT_OF_RESOURCES; } - mBuf = AllocatePool (mBufSiz); + mBuf = AllocateZeroPool (mBufSiz); } mBuf[0] = 0; @@ -429,22 +217,15 @@ Returns: return EFI_SUCCESS; } -VOID +/** + Called when compression is completed to free memory previously allocated. + +**/ +VOID EFIAPI FreeMemory ( VOID ) -/*++ - -Routine Description: - - Called when compression is completed to free memory previously allocated. - -Arguments: (VOID) - -Returns: (VOID) - -**/ { SHELL_FREE_NON_NULL (mText); SHELL_FREE_NON_NULL (mLevel); @@ -456,24 +237,17 @@ Returns: (VOID) SHELL_FREE_NON_NULL (mBuf); } +/** + Initialize String Info Log data structures + +**/ VOID EFIAPI InitSlide ( VOID ) -/*++ - -Routine Description: - - Initialize String Info Log data structures - -Arguments: (VOID) - -Returns: (VOID) - -**/ { - NODE i; + NODE LoopVar1; SetMem (mLevel + WNDSIZ, (UINT8_MAX + 1) * sizeof (UINT8), 1); SetMem (mPosition + WNDSIZ, (UINT8_MAX + 1) * sizeof (NODE), 0); @@ -481,117 +255,95 @@ Returns: (VOID) SetMem (mParent + WNDSIZ, WNDSIZ * sizeof (NODE), 0); mAvail = 1; - for (i = 1; i < WNDSIZ - 1; i++) { - mNext[i] = (NODE) (i + 1); + for (LoopVar1 = 1; LoopVar1 < WNDSIZ - 1; LoopVar1++) { + mNext[LoopVar1] = (NODE) (LoopVar1 + 1); } mNext[WNDSIZ - 1] = NIL; SetMem (mNext + WNDSIZ * 2, (MAX_HASH_VAL - WNDSIZ * 2 + 1) * sizeof (NODE), 0); } -NODE -EFIAPI -Child ( - IN NODE q, - IN UINT8 c - ) -/*++ - -Routine Description: - +/** Find child node given the parent node and the edge character -Arguments: - - q - the parent node - c - the edge character - -Returns: + @param[in] LoopVar6 The parent node. + @param[in] LoopVar5 The edge character. - The child node (NIL if not found) + @return The child node. + @retval NIL(Zero) No child could be found. **/ +NODE +EFIAPI +Child ( + IN NODE LoopVar6, + IN UINT8 LoopVar5 + ) { - NODE r; + NODE LoopVar4; - r = mNext[HASH (q, c)]; - mParent[NIL] = q; /* sentinel */ - while (mParent[r] != q) { - r = mNext[r]; + LoopVar4 = mNext[HASH (LoopVar6, LoopVar5)]; + mParent[NIL] = LoopVar6; /* sentinel */ + while (mParent[LoopVar4] != LoopVar6) { + LoopVar4 = mNext[LoopVar4]; } - return r; + return LoopVar4; } +/** + Create a new child for a given parent node. + + @param[in] LoopVar6 The parent node. + @param[in] LoopVar5 The edge character. + @param[in] LoopVar4 The child node. +**/ VOID EFIAPI MakeChild ( - IN NODE q, - IN UINT8 c, - IN NODE r + IN NODE LoopVar6, + IN UINT8 LoopVar5, + IN NODE LoopVar4 ) -/*++ - -Routine Description: - - Create a new child for a given parent node. - -Arguments: - - q - the parent node - c - the edge character - r - the child node - -Returns: (VOID) - -**/ { - NODE h; - - NODE t; - - h = (NODE) HASH (q, c); - t = mNext[h]; - mNext[h] = r; - mNext[r] = t; - mPrev[t] = r; - mPrev[r] = h; - mParent[r] = q; - mChildCount[q]++; + NODE LoopVar12; + + NODE LoopVar10; + + LoopVar12 = (NODE) HASH (LoopVar6, LoopVar5); + LoopVar10 = mNext[LoopVar12]; + mNext[LoopVar12] = LoopVar4; + mNext[LoopVar4] = LoopVar10; + mPrev[LoopVar10] = LoopVar4; + mPrev[LoopVar4] = LoopVar12; + mParent[LoopVar4] = LoopVar6; + mChildCount[LoopVar6]++; } +/** + Split a node. + + @param[in] Old The node to split. +**/ VOID EFIAPI Split ( - NODE Old + IN NODE Old ) -/*++ - -Routine Description: - - Split a node. - -Arguments: - - Old - the node to split - -Returns: (VOID) - -**/ { NODE New; - NODE t; + NODE LoopVar10; New = mAvail; mAvail = mNext[New]; mChildCount[New] = 0; - t = mPrev[Old]; - mPrev[New] = t; - mNext[t] = New; - t = mNext[Old]; - mNext[New] = t; - mPrev[t] = New; + LoopVar10 = mPrev[Old]; + mPrev[New] = LoopVar10; + mNext[LoopVar10] = New; + LoopVar10 = mNext[Old]; + mNext[New] = LoopVar10; + mPrev[LoopVar10] = New; mParent[New] = mParent[Old]; mLevel[New] = (UINT8) mMatchLen; mPosition[New] = mPos; @@ -599,33 +351,26 @@ Returns: (VOID) MakeChild (New, mText[mPos + mMatchLen], mPos); } +/** + Insert string info for current position into the String Info Log. + +**/ VOID EFIAPI InsertNode ( VOID ) -/*++ - -Routine Description: - - Insert string info for current position into the String Info Log - -Arguments: (VOID) - -Returns: (VOID) - -**/ { - NODE q; + NODE LoopVar6; - NODE r; + NODE LoopVar4; - NODE j; + NODE LoopVar2; - NODE t; - UINT8 c; - UINT8 *t1; - UINT8 *t2; + NODE LoopVar10; + UINT8 LoopVar5; + UINT8 *TempString3; + UINT8 *TempString2; if (mMatchLen >= 4) { // @@ -636,36 +381,36 @@ Returns: (VOID) // in DeleteNode() later. // mMatchLen--; - r = (NODE) ((mMatchPos + 1) | WNDSIZ); - q = mParent[r]; - while (q == NIL) { - r = mNext[r]; - q = mParent[r]; + LoopVar4 = (NODE) ((mMatchPos + 1) | WNDSIZ); + LoopVar6 = mParent[LoopVar4]; + while (LoopVar6 == NIL) { + LoopVar4 = mNext[LoopVar4]; + LoopVar6 = mParent[LoopVar4]; } - while (mLevel[q] >= mMatchLen) { - r = q; - q = mParent[q]; + while (mLevel[LoopVar6] >= mMatchLen) { + LoopVar4 = LoopVar6; + LoopVar6 = mParent[LoopVar6]; } - t = q; - while (mPosition[t] < 0) { - mPosition[t] = mPos; - t = mParent[t]; + LoopVar10 = LoopVar6; + while (mPosition[LoopVar10] < 0) { + mPosition[LoopVar10] = mPos; + LoopVar10 = mParent[LoopVar10]; } - if (t < WNDSIZ) { - mPosition[t] = (NODE) (mPos | PERC_FLAG); + if (LoopVar10 < WNDSIZ) { + mPosition[LoopVar10] = (NODE) (mPos | PERC_FLAG); } } else { // // Locate the target tree // - q = (NODE) (mText[mPos] + WNDSIZ); - c = mText[mPos + 1]; - r = Child (q, c); - if (r == NIL) { - MakeChild (q, c, mPos); + LoopVar6 = (NODE) (mText[mPos] + WNDSIZ); + LoopVar5 = mText[mPos + 1]; + LoopVar4 = Child (LoopVar6, LoopVar5); + if (LoopVar4 == NIL) { + MakeChild (LoopVar6, LoopVar5, mPos); mMatchLen = 1; return ; } @@ -678,191 +423,211 @@ Returns: (VOID) // Node split or creation is involved. // for (;;) { - if (r >= WNDSIZ) { - j = MAXMATCH; - mMatchPos = r; + if (LoopVar4 >= WNDSIZ) { + LoopVar2 = MAXMATCH; + mMatchPos = LoopVar4; } else { - j = mLevel[r]; - mMatchPos = (NODE) (mPosition[r] & ~PERC_FLAG); + LoopVar2 = mLevel[LoopVar4]; + mMatchPos = (NODE) (mPosition[LoopVar4] & ~PERC_FLAG); } if (mMatchPos >= mPos) { mMatchPos -= WNDSIZ; } - t1 = &mText[mPos + mMatchLen]; - t2 = &mText[mMatchPos + mMatchLen]; - while (mMatchLen < j) { - if (*t1 != *t2) { - Split (r); + TempString3 = &mText[mPos + mMatchLen]; + TempString2 = &mText[mMatchPos + mMatchLen]; + while (mMatchLen < LoopVar2) { + if (*TempString3 != *TempString2) { + Split (LoopVar4); return ; } mMatchLen++; - t1++; - t2++; + TempString3++; + TempString2++; } if (mMatchLen >= MAXMATCH) { break; } - mPosition[r] = mPos; - q = r; - r = Child (q, *t1); - if (r == NIL) { - MakeChild (q, *t1, mPos); + mPosition[LoopVar4] = mPos; + LoopVar6 = LoopVar4; + LoopVar4 = Child (LoopVar6, *TempString3); + if (LoopVar4 == NIL) { + MakeChild (LoopVar6, *TempString3, mPos); return ; } mMatchLen++; } - t = mPrev[r]; - mPrev[mPos] = t; - mNext[t] = mPos; - t = mNext[r]; - mNext[mPos] = t; - mPrev[t] = mPos; - mParent[mPos] = q; - mParent[r] = NIL; + LoopVar10 = mPrev[LoopVar4]; + mPrev[mPos] = LoopVar10; + mNext[LoopVar10] = mPos; + LoopVar10 = mNext[LoopVar4]; + mNext[mPos] = LoopVar10; + mPrev[LoopVar10] = mPos; + mParent[mPos] = LoopVar6; + mParent[LoopVar4] = NIL; // // Special usage of 'next' // - mNext[r] = mPos; + mNext[LoopVar4] = mPos; } +/** + Delete outdated string info. (The Usage of PERC_FLAG + ensures a clean deletion). + +**/ VOID EFIAPI DeleteNode ( VOID ) -/*++ - -Routine Description: - - Delete outdated string info. (The Usage of PERC_FLAG - ensures a clean deletion) - -Arguments: (VOID) - -Returns: (VOID) - -**/ { - NODE q; + NODE LoopVar6; - NODE r; + NODE LoopVar4; - NODE s; + NODE LoopVar11; - NODE t; + NODE LoopVar10; - NODE u; + NODE LoopVar9; if (mParent[mPos] == NIL) { return ; } - r = mPrev[mPos]; - s = mNext[mPos]; - mNext[r] = s; - mPrev[s] = r; - r = mParent[mPos]; + LoopVar4 = mPrev[mPos]; + LoopVar11 = mNext[mPos]; + mNext[LoopVar4] = LoopVar11; + mPrev[LoopVar11] = LoopVar4; + LoopVar4 = mParent[mPos]; mParent[mPos] = NIL; - if (r >= WNDSIZ) { + if (LoopVar4 >= WNDSIZ) { return ; } - mChildCount[r]--; - if (mChildCount[r] > 1) { + mChildCount[LoopVar4]--; + if (mChildCount[LoopVar4] > 1) { return ; } - t = (NODE) (mPosition[r] & ~PERC_FLAG); - if (t >= mPos) { - t -= WNDSIZ; + LoopVar10 = (NODE) (mPosition[LoopVar4] & ~PERC_FLAG); + if (LoopVar10 >= mPos) { + LoopVar10 -= WNDSIZ; } - s = t; - q = mParent[r]; - u = mPosition[q]; - while ((u & PERC_FLAG) != 0){ - u &= ~PERC_FLAG; - if (u >= mPos) { - u -= WNDSIZ; + LoopVar11 = LoopVar10; + LoopVar6 = mParent[LoopVar4]; + LoopVar9 = mPosition[LoopVar6]; + while ((LoopVar9 & PERC_FLAG) != 0){ + LoopVar9 &= ~PERC_FLAG; + if (LoopVar9 >= mPos) { + LoopVar9 -= WNDSIZ; } - if (u > s) { - s = u; + if (LoopVar9 > LoopVar11) { + LoopVar11 = LoopVar9; } - mPosition[q] = (NODE) (s | WNDSIZ); - q = mParent[q]; - u = mPosition[q]; + mPosition[LoopVar6] = (NODE) (LoopVar11 | WNDSIZ); + LoopVar6 = mParent[LoopVar6]; + LoopVar9 = mPosition[LoopVar6]; } - if (q < WNDSIZ) { - if (u >= mPos) { - u -= WNDSIZ; + if (LoopVar6 < WNDSIZ) { + if (LoopVar9 >= mPos) { + LoopVar9 -= WNDSIZ; } - if (u > s) { - s = u; + if (LoopVar9 > LoopVar11) { + LoopVar11 = LoopVar9; } - mPosition[q] = (NODE) (s | WNDSIZ | PERC_FLAG); + mPosition[LoopVar6] = (NODE) (LoopVar11 | WNDSIZ | PERC_FLAG); } - s = Child (r, mText[t + mLevel[r]]); - t = mPrev[s]; - u = mNext[s]; - mNext[t] = u; - mPrev[u] = t; - t = mPrev[r]; - mNext[t] = s; - mPrev[s] = t; - t = mNext[r]; - mPrev[t] = s; - mNext[s] = t; - mParent[s] = mParent[r]; - mParent[r] = NIL; - mNext[r] = mAvail; - mAvail = r; + LoopVar11 = Child (LoopVar4, mText[LoopVar10 + mLevel[LoopVar4]]); + LoopVar10 = mPrev[LoopVar11]; + LoopVar9 = mNext[LoopVar11]; + mNext[LoopVar10] = LoopVar9; + mPrev[LoopVar9] = LoopVar10; + LoopVar10 = mPrev[LoopVar4]; + mNext[LoopVar10] = LoopVar11; + mPrev[LoopVar11] = LoopVar10; + LoopVar10 = mNext[LoopVar4]; + mPrev[LoopVar10] = LoopVar11; + mNext[LoopVar11] = LoopVar10; + mParent[LoopVar11] = mParent[LoopVar4]; + mParent[LoopVar4] = NIL; + mNext[LoopVar4] = mAvail; + mAvail = LoopVar4; } -VOID +/** + Read in source data + + @param[out] LoopVar7 The buffer to hold the data. + @param[in] LoopVar8 The number of bytes to read. + + @return The number of bytes actually read. +**/ +INT32 EFIAPI -GetNextMatch ( - VOID +FreadCrc ( + OUT UINT8 *LoopVar7, + IN INT32 LoopVar8 ) -/*++ +{ + INT32 LoopVar1; -Routine Description: + for (LoopVar1 = 0; mSrc < mSrcUpperLimit && LoopVar1 < LoopVar8; LoopVar1++) { + *LoopVar7++ = *mSrc++; + } - Advance the current position (read in new data if needed). - Delete outdated string info. Find a match string for current position. + LoopVar8 = LoopVar1; + + LoopVar7 -= LoopVar8; + mOrigSize += LoopVar8; + LoopVar1--; + while (LoopVar1 >= 0) { + UPDATE_CRC (*LoopVar7++); + LoopVar1--; + } -Arguments: (VOID) + return LoopVar8; +} -Returns: (VOID) +/** + Advance the current position (read in new data if needed). + Delete outdated string info. Find a match string for current position. **/ +VOID +EFIAPI +GetNextMatch ( + VOID + ) { - INT32 n; + INT32 LoopVar8; VOID *Temp; mRemainder--; mPos++; if (mPos == WNDSIZ * 2) { - Temp = AllocatePool (WNDSIZ + MAXMATCH); + Temp = AllocateZeroPool (WNDSIZ + MAXMATCH); CopyMem (Temp, &mText[WNDSIZ], WNDSIZ + MAXMATCH); CopyMem (&mText[0], Temp, WNDSIZ + MAXMATCH); FreePool (Temp); - n = FreadCrc (&mText[WNDSIZ + MAXMATCH], WNDSIZ); - mRemainder += n; + LoopVar8 = FreadCrc (&mText[WNDSIZ + MAXMATCH], WNDSIZ); + mRemainder += LoopVar8; mPos = WNDSIZ; } @@ -870,318 +635,483 @@ Returns: (VOID) InsertNode (); } -EFI_STATUS +/** + Send entry LoopVar1 down the queue. + + @param[in] LoopVar1 The index of the item to move. +**/ +VOID EFIAPI -Encode ( - VOID +DownHeap ( + IN INT32 i ) -/*++ +{ + INT32 LoopVar1; -Routine Description: + INT32 LoopVar2; - The main controlling routine for compression process. + // + // priority queue: send i-th entry down heap + // + LoopVar2 = mHeap[i]; + LoopVar1 = 2 * i; + while (LoopVar1 <= mHeapSize) { + if (LoopVar1 < mHeapSize && mFreq[mHeap[LoopVar1]] > mFreq[mHeap[LoopVar1 + 1]]) { + LoopVar1++; + } + + if (mFreq[LoopVar2] <= mFreq[mHeap[LoopVar1]]) { + break; + } -Arguments: (VOID) + mHeap[i] = mHeap[LoopVar1]; + i = LoopVar1; + LoopVar1 = 2 * i; + } -Returns: + mHeap[i] = (INT16) LoopVar2; +} - EFI_SUCCESS - The compression is successful - EFI_OUT_0F_RESOURCES - Not enough memory for compression process +/** + Count the number of each code length for a Huffman tree. + @param[in] LoopVar1 The top node. **/ +VOID +EFIAPI +CountLen ( + IN INT32 LoopVar1 + ) { - EFI_STATUS Status; - INT32 LastMatchLen; - NODE LastMatchPos; - - Status = AllocateMemory (); - if (EFI_ERROR (Status)) { - FreeMemory (); - return Status; + if (LoopVar1 < mTempInt32) { + mLenCnt[(mHuffmanDepth < 16) ? mHuffmanDepth : 16]++; + } else { + mHuffmanDepth++; + CountLen (mLeft[LoopVar1]); + CountLen (mRight[LoopVar1]); + mHuffmanDepth--; } +} - InitSlide (); +/** + Create code length array for a Huffman tree. - HufEncodeStart (); + @param[in] Root The root of the tree. +**/ +VOID +EFIAPI +MakeLen ( + IN INT32 Root + ) +{ + INT32 LoopVar1; - mRemainder = FreadCrc (&mText[WNDSIZ], WNDSIZ + MAXMATCH); + INT32 LoopVar2; + UINT32 Cum; - mMatchLen = 0; - mPos = WNDSIZ; - InsertNode (); - if (mMatchLen > mRemainder) { - mMatchLen = mRemainder; + for (LoopVar1 = 0; LoopVar1 <= 16; LoopVar1++) { + mLenCnt[LoopVar1] = 0; } - while (mRemainder > 0) { - LastMatchLen = mMatchLen; - LastMatchPos = mMatchPos; - GetNextMatch (); - if (mMatchLen > mRemainder) { - mMatchLen = mRemainder; - } - - if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) { - // - // Not enough benefits are gained by outputting a pointer, - // so just output the original character - // - CompressOutput(mText[mPos - 1], 0); - } else { - // - // Outputting a pointer is beneficial enough, do it. - // + CountLen (Root); - CompressOutput(LastMatchLen + (UINT8_MAX + 1 - THRESHOLD), - (mPos - LastMatchPos - 2) & (WNDSIZ - 1)); - LastMatchLen--; - while (LastMatchLen > 0) { - GetNextMatch (); - LastMatchLen--; - } + // + // Adjust the length count array so that + // no code will be generated longer than its designated length + // + Cum = 0; + for (LoopVar1 = 16; LoopVar1 > 0; LoopVar1--) { + Cum += mLenCnt[LoopVar1] << (16 - LoopVar1); + } - if (mMatchLen > mRemainder) { - mMatchLen = mRemainder; + while (Cum != (1U << 16)) { + mLenCnt[16]--; + for (LoopVar1 = 15; LoopVar1 > 0; LoopVar1--) { + if (mLenCnt[LoopVar1] != 0) { + mLenCnt[LoopVar1]--; + mLenCnt[LoopVar1 + 1] += 2; + break; } } + + Cum--; } - HufEncodeEnd (); - FreeMemory (); - return EFI_SUCCESS; + for (LoopVar1 = 16; LoopVar1 > 0; LoopVar1--) { + LoopVar2 = mLenCnt[LoopVar1]; + LoopVar2--; + while (LoopVar2 >= 0) { + mLen[*mSortPtr++] = (UINT8) LoopVar1; + LoopVar2--; + } + } } +/** + Assign code to each symbol based on the code length array. + + @param[in] LoopVar8 The number of symbols. + @param[in] Len The code length array. + @param[out] Code The stores codes for each symbol. +**/ VOID EFIAPI -CountTFreq ( - VOID +MakeCode ( + IN INT32 LoopVar8, + IN UINT8 Len[ ], + OUT UINT16 Code[ ] ) -/*++ - -Routine Description: +{ + INT32 LoopVar1; + UINT16 Start[18]; - Count the frequencies for the Extra Set + Start[1] = 0; + for (LoopVar1 = 1; LoopVar1 <= 16; LoopVar1++) { + Start[LoopVar1 + 1] = (UINT16) ((Start[LoopVar1] + mLenCnt[LoopVar1]) << 1); + } -Arguments: (VOID) + for (LoopVar1 = 0; LoopVar1 < LoopVar8; LoopVar1++) { + Code[LoopVar1] = Start[Len[LoopVar1]]++; + } +} + +/** + Generates Huffman codes given a frequency distribution of symbols. -Returns: (VOID) + @param[in] NParm The number of symbols. + @param[in] FreqParm The frequency of each symbol. + @param[out] LenParm The code length for each symbol. + @param[out] CodeParm The code for each symbol. + @return The root of the Huffman tree. **/ +INT32 +EFIAPI +MakeTree ( + IN INT32 NParm, + IN UINT16 FreqParm[ ], + OUT UINT8 LenParm[ ], + OUT UINT16 CodeParm[ ] + ) { - INT32 i; + INT32 LoopVar1; - INT32 k; + INT32 LoopVar2; - INT32 n; + INT32 LoopVar3; - INT32 Count; + INT32 Avail; - for (i = 0; i < NT; i++) { - mTFreq[i] = 0; + // + // make tree, calculate len[], return root + // + mTempInt32 = NParm; + mFreq = FreqParm; + mLen = LenParm; + Avail = mTempInt32; + mHeapSize = 0; + mHeap[1] = 0; + for (LoopVar1 = 0; LoopVar1 < mTempInt32; LoopVar1++) { + mLen[LoopVar1] = 0; + if ((mFreq[LoopVar1]) != 0) { + mHeapSize++; + mHeap[mHeapSize] = (INT16) LoopVar1; + } } - n = NC; - while (n > 0 && mCLen[n - 1] == 0) { - n--; + if (mHeapSize < 2) { + CodeParm[mHeap[1]] = 0; + return mHeap[1]; } - i = 0; - while (i < n) { - k = mCLen[i++]; - if (k == 0) { - Count = 1; - while (i < n && mCLen[i] == 0) { - i++; - Count++; - } + for (LoopVar1 = mHeapSize / 2; LoopVar1 >= 1; LoopVar1--) { + // + // make priority queue + // + DownHeap (LoopVar1); + } - if (Count <= 2) { - mTFreq[0] = (UINT16) (mTFreq[0] + Count); - } else if (Count <= 18) { - mTFreq[1]++; - } else if (Count == 19) { - mTFreq[0]++; - mTFreq[1]++; - } else { - mTFreq[2]++; - } - } else { - ASSERT((k+2)<(2 * NT - 1)); - mTFreq[k + 2]++; + mSortPtr = CodeParm; + do { + LoopVar1 = mHeap[1]; + if (LoopVar1 < mTempInt32) { + *mSortPtr++ = (UINT16) LoopVar1; } - } -} - -VOID -EFIAPI -WritePTLen ( - IN INT32 n, - IN INT32 nbit, - IN INT32 Special - ) -/*++ -Routine Description: + mHeap[1] = mHeap[mHeapSize--]; + DownHeap (1); + LoopVar2 = mHeap[1]; + if (LoopVar2 < mTempInt32) { + *mSortPtr++ = (UINT16) LoopVar2; + } - Outputs the code length array for the Extra Set or the Position Set. + LoopVar3 = Avail++; + mFreq[LoopVar3] = (UINT16) (mFreq[LoopVar1] + mFreq[LoopVar2]); + mHeap[1] = (INT16) LoopVar3; + DownHeap (1); + mLeft[LoopVar3] = (UINT16) LoopVar1; + mRight[LoopVar3] = (UINT16) LoopVar2; + } while (mHeapSize > 1); -Arguments: + mSortPtr = CodeParm; + MakeLen (LoopVar3); + MakeCode (NParm, LenParm, CodeParm); - n - the number of symbols - nbit - the number of bits needed to represent 'n' - Special - the special symbol that needs to be take care of + // + // return root + // + return LoopVar3; +} -Returns: (VOID) +/** + Outputs rightmost LoopVar8 bits of x + @param[in] LoopVar8 The rightmost LoopVar8 bits of the data is used. + @param[in] x The data. **/ +VOID +EFIAPI +PutBits ( + IN INT32 LoopVar8, + IN UINT32 x + ) { - INT32 i; + UINT8 Temp; - INT32 k; + if (LoopVar8 < mBitCount) { + mSubBitBuf |= x << (mBitCount -= LoopVar8); + } else { - while (n > 0 && mPTLen[n - 1] == 0) { - n--; - } + Temp = (UINT8)(mSubBitBuf | (x >> (LoopVar8 -= mBitCount))); + if (mDst < mDstUpperLimit) { + *mDst++ = Temp; + } + mCompSize++; - PutBits (nbit, n); - i = 0; - while (i < n) { - k = mPTLen[i++]; - if (k <= 6) { - PutBits (3, k); + if (LoopVar8 < UINT8_BIT) { + mSubBitBuf = x << (mBitCount = UINT8_BIT - LoopVar8); } else { - PutBits (k - 3, (1U << (k - 3)) - 2); - } - if (i == Special) { - while (i < 6 && mPTLen[i] == 0) { - i++; + Temp = (UINT8)(x >> (LoopVar8 - UINT8_BIT)); + if (mDst < mDstUpperLimit) { + *mDst++ = Temp; } + mCompSize++; - PutBits (2, (i - 3) & 3); + mSubBitBuf = x << (mBitCount = 2 * UINT8_BIT - LoopVar8); } } } +/** + Encode a signed 32 bit number. + + @param[in] LoopVar5 The number to encode. +**/ VOID EFIAPI -WriteCLen ( - VOID +EncodeC ( + IN INT32 LoopVar5 ) -/*++ +{ + PutBits (mCLen[LoopVar5], mCCode[LoopVar5]); +} -Routine Description: +/** + Encode a unsigned 32 bit number. - Outputs the code length array for Char&Length Set + @param[in] LoopVar7 The number to encode. +**/ +VOID +EFIAPI +EncodeP ( + IN UINT32 LoopVar7 + ) +{ + UINT32 LoopVar5; -Arguments: (VOID) + UINT32 LoopVar6; -Returns: (VOID) + LoopVar5 = 0; + LoopVar6 = LoopVar7; + while (LoopVar6 != 0) { + LoopVar6 >>= 1; + LoopVar5++; + } + + PutBits (mPTLen[LoopVar5], mPTCode[LoopVar5]); + if (LoopVar5 > 1) { + PutBits(LoopVar5 - 1, LoopVar7 & (0xFFFFU >> (17 - LoopVar5))); + } +} + +/** + Count the frequencies for the Extra Set. **/ +VOID +EFIAPI +CountTFreq ( + VOID + ) { - INT32 i; + INT32 LoopVar1; - INT32 k; + INT32 LoopVar3; - INT32 n; + INT32 LoopVar8; INT32 Count; - n = NC; - while (n > 0 && mCLen[n - 1] == 0) { - n--; + for (LoopVar1 = 0; LoopVar1 < NT; LoopVar1++) { + mTFreq[LoopVar1] = 0; } - PutBits (CBIT, n); - i = 0; - while (i < n) { - k = mCLen[i++]; - if (k == 0) { + LoopVar8 = NC; + while (LoopVar8 > 0 && mCLen[LoopVar8 - 1] == 0) { + LoopVar8--; + } + + LoopVar1 = 0; + while (LoopVar1 < LoopVar8) { + LoopVar3 = mCLen[LoopVar1++]; + if (LoopVar3 == 0) { Count = 1; - while (i < n && mCLen[i] == 0) { - i++; + while (LoopVar1 < LoopVar8 && mCLen[LoopVar1] == 0) { + LoopVar1++; Count++; } if (Count <= 2) { - for (k = 0; k < Count; k++) { - PutBits (mPTLen[0], mPTCode[0]); - } + mTFreq[0] = (UINT16) (mTFreq[0] + Count); } else if (Count <= 18) { - PutBits (mPTLen[1], mPTCode[1]); - PutBits (4, Count - 3); + mTFreq[1]++; } else if (Count == 19) { - PutBits (mPTLen[0], mPTCode[0]); - PutBits (mPTLen[1], mPTCode[1]); - PutBits (4, 15); + mTFreq[0]++; + mTFreq[1]++; } else { - PutBits (mPTLen[2], mPTCode[2]); - PutBits (CBIT, Count - 20); + mTFreq[2]++; } } else { - ASSERT((k+2)>= 1; - c++; + while (LoopVar8 > 0 && mPTLen[LoopVar8 - 1] == 0) { + LoopVar8--; } - PutBits (mPTLen[c], mPTCode[c]); - if (c > 1) { - PutBits(c - 1, p & (0xFFFFU >> (17 - c))); + PutBits (nbit, LoopVar8); + LoopVar1 = 0; + while (LoopVar1 < LoopVar8) { + LoopVar3 = mPTLen[LoopVar1++]; + if (LoopVar3 <= 6) { + PutBits (3, LoopVar3); + } else { + PutBits (LoopVar3 - 3, (1U << (LoopVar3 - 3)) - 2); + } + + if (LoopVar1 == Special) { + while (LoopVar1 < 6 && mPTLen[LoopVar1] == 0) { + LoopVar1++; + } + + PutBits (2, (LoopVar1 - 3) & 3); + } } } +/** + Outputs the code length array for Char&Length Set + +**/ VOID EFIAPI -SendBlock ( +WriteCLen ( VOID ) -/*++ +{ + INT32 LoopVar1; -Routine Description: + INT32 LoopVar3; - Huffman code the block and output it. + INT32 LoopVar8; -Arguments: + INT32 Count; - None + LoopVar8 = NC; + while (LoopVar8 > 0 && mCLen[LoopVar8 - 1] == 0) { + LoopVar8--; + } -Returns: + PutBits (CBIT, LoopVar8); + LoopVar1 = 0; + while (LoopVar1 < LoopVar8) { + LoopVar3 = mCLen[LoopVar1++]; + if (LoopVar3 == 0) { + Count = 1; + while (LoopVar1 < LoopVar8 && mCLen[LoopVar1] == 0) { + LoopVar1++; + Count++; + } + + if (Count <= 2) { + for (LoopVar3 = 0; LoopVar3 < Count; LoopVar3++) { + PutBits (mPTLen[0], mPTCode[0]); + } + } else if (Count <= 18) { + PutBits (mPTLen[1], mPTCode[1]); + PutBits (4, Count - 3); + } else if (Count == 19) { + PutBits (mPTLen[0], mPTCode[0]); + PutBits (mPTLen[1], mPTCode[1]); + PutBits (4, 15); + } else { + PutBits (mPTLen[2], mPTCode[2]); + PutBits (CBIT, Count - 20); + } + } else { + ASSERT((LoopVar3+2)= (1U << UINT8_BIT)) { + mBuf[mOutputPos++] = (UINT8) LoopVar5; + mCFreq[LoopVar5]++; + if (LoopVar5 >= (1U << UINT8_BIT)) { mBuf[CPos] = (UINT8)(mBuf[CPos]|mOutputMask); - mBuf[mOutputPos++] = (UINT8)(p >> UINT8_BIT); - mBuf[mOutputPos++] = (UINT8) p; - c = 0; - while (p!=0) { - p >>= 1; - c++; + mBuf[mOutputPos++] = (UINT8)(LoopVar7 >> UINT8_BIT); + mBuf[mOutputPos++] = (UINT8) LoopVar7; + LoopVar5 = 0; + while (LoopVar7!=0) { + LoopVar7 >>= 1; + LoopVar5++; } - mPFreq[c]++; + mPFreq[LoopVar5]++; } } -VOID -EFIAPI -HufEncodeStart ( - VOID - ) -{ - SetMem (mCFreq, NC * sizeof (UINT16), 0); - SetMem (mPFreq, NP * sizeof (UINT16), 0); - - mOutputPos = mOutputMask = 0; - InitPutBits (); - return ; -} +/** + End the huffman encoding. +**/ VOID EFIAPI HufEncodeEnd ( @@ -1317,395 +1249,160 @@ HufEncodeEnd ( // Flush remaining bits // PutBits (UINT8_BIT - 1, 0); - - return ; } -VOID +/** + The main controlling routine for compression process. + + @retval EFI_SUCCESS The compression is successful. + @retval EFI_OUT_0F_RESOURCES Not enough memory for compression process. +**/ +EFI_STATUS EFIAPI -MakeCrcTable ( +Encode ( VOID ) { - UINT32 i; - - UINT32 j; - - UINT32 r; - - for (i = 0; i <= UINT8_MAX; i++) { - r = i; - for (j = 0; j < UINT8_BIT; j++) { - if ((r & 1) != 0) { - r = (r >> 1) ^ CRCPOLY; - } else { - r >>= 1; - } - } + EFI_STATUS Status; + INT32 LastMatchLen; + NODE LastMatchPos; - mCrcTable[i] = (UINT16) r; + Status = AllocateMemory (); + if (EFI_ERROR (Status)) { + FreeMemory (); + return Status; } -} -VOID -EFIAPI -PutBits ( - IN INT32 n, - IN UINT32 x - ) -/*++ - -Routine Description: - - Outputs rightmost n bits of x - -Arguments: - - n - the rightmost n bits of the data is used - x - the data - -Returns: + InitSlide (); - None + HufEncodeStart (); -**/ -{ - UINT8 Temp; + mRemainder = FreadCrc (&mText[WNDSIZ], WNDSIZ + MAXMATCH); - if (n < mBitCount) { - mSubBitBuf |= x << (mBitCount -= n); - } else { + mMatchLen = 0; + mPos = WNDSIZ; + InsertNode (); + if (mMatchLen > mRemainder) { + mMatchLen = mRemainder; + } - Temp = (UINT8)(mSubBitBuf | (x >> (n -= mBitCount))); - if (mDst < mDstUpperLimit) { - *mDst++ = Temp; + while (mRemainder > 0) { + LastMatchLen = mMatchLen; + LastMatchPos = mMatchPos; + GetNextMatch (); + if (mMatchLen > mRemainder) { + mMatchLen = mRemainder; } - mCompSize++; - if (n < UINT8_BIT) { - mSubBitBuf = x << (mBitCount = UINT8_BIT - n); + if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) { + // + // Not enough benefits are gained by outputting a pointer, + // so just output the original character + // + CompressOutput(mText[mPos - 1], 0); } else { + // + // Outputting a pointer is beneficial enough, do it. + // - Temp = (UINT8)(x >> (n - UINT8_BIT)); - if (mDst < mDstUpperLimit) { - *mDst++ = Temp; + CompressOutput(LastMatchLen + (UINT8_MAX + 1 - THRESHOLD), + (mPos - LastMatchPos - 2) & (WNDSIZ - 1)); + LastMatchLen--; + while (LastMatchLen > 0) { + GetNextMatch (); + LastMatchLen--; } - mCompSize++; - mSubBitBuf = x << (mBitCount = 2 * UINT8_BIT - n); + if (mMatchLen > mRemainder) { + mMatchLen = mRemainder; + } } } -} -INT32 -EFIAPI -FreadCrc ( - OUT UINT8 *p, - IN INT32 n - ) -/*++ - -Routine Description: - - Read in source data - -Arguments: - - p - the buffer to hold the data - n - number of bytes to read - -Returns: - - number of bytes actually read - -**/ -{ - INT32 i; - - for (i = 0; mSrc < mSrcUpperLimit && i < n; i++) { - *p++ = *mSrc++; - } - - n = i; - - p -= n; - mOrigSize += n; - i--; - while (i >= 0) { - UPDATE_CRC (*p++); - i--; - } - - return n; -} - -VOID -EFIAPI -InitPutBits ( - VOID - ) -{ - mBitCount = UINT8_BIT; - mSubBitBuf = 0; + HufEncodeEnd (); + FreeMemory (); + return EFI_SUCCESS; } -VOID -EFIAPI -CountLen ( - IN INT32 i - ) -/*++ - -Routine Description: - - Count the number of each code length for a Huffman tree. - -Arguments: - - i - the top node +/** + The compression routine. -Returns: (VOID) + @param[in] SrcBuffer The buffer containing the source data. + @param[in] SrcSize The number of bytes in SrcBuffer. + @param[in] DstBuffer The buffer to put the compressed image in. + @param[in,out] DstSize On input the size (in bytes) of DstBuffer, on + return the number of bytes placed in DstBuffer. + @retval EFI_SUCCESS The compression was sucessful. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. DstSize is required. **/ -{ - STATIC INT32 Depth = 0; - - if (i < mN) { - mLenCnt[(Depth < 16) ? Depth : 16]++; - } else { - Depth++; - CountLen (mLeft[i]); - CountLen (mRight[i]); - Depth--; - } -} - -VOID +EFI_STATUS EFIAPI -MakeLen ( - IN INT32 Root +Compress ( + IN VOID *SrcBuffer, + IN UINT64 SrcSize, + IN VOID *DstBuffer, + IN OUT UINT64 *DstSize ) -/*++ - -Routine Description: - - Create code length array for a Huffman tree - -Arguments: - - Root - the root of the tree - -Returns: - - None - -**/ { - INT32 i; - - INT32 k; - UINT32 Cum; - - for (i = 0; i <= 16; i++) { - mLenCnt[i] = 0; - } - - CountLen (Root); + EFI_STATUS Status; // - // Adjust the length count array so that - // no code will be generated longer than its designated length + // Initializations // - Cum = 0; - for (i = 16; i > 0; i--) { - Cum += mLenCnt[i] << (16 - i); - } - - while (Cum != (1U << 16)) { - mLenCnt[16]--; - for (i = 15; i > 0; i--) { - if (mLenCnt[i] != 0) { - mLenCnt[i]--; - mLenCnt[i + 1] += 2; - break; - } - } + mBufSiz = 0; + mBuf = NULL; + mText = NULL; + mLevel = NULL; + mChildCount = NULL; + mPosition = NULL; + mParent = NULL; + mPrev = NULL; + mNext = NULL; - Cum--; - } + mSrc = SrcBuffer; + mSrcUpperLimit = mSrc + SrcSize; + mDst = DstBuffer; + mDstUpperLimit = mDst +*DstSize; - for (i = 16; i > 0; i--) { - k = mLenCnt[i]; - k--; - while (k >= 0) { - mLen[*mSortPtr++] = (UINT8) i; - k--; - } - } -} + PutDword (0L); + PutDword (0L); -VOID -EFIAPI -DownHeap ( - IN INT32 i - ) -{ - INT32 j; + MakeCrcTable (); - INT32 k; + mOrigSize = mCompSize = 0; + mCrc = INIT_CRC; // - // priority queue: send i-th entry down heap + // Compress it // - k = mHeap[i]; - j = 2 * i; - while (j <= mHeapSize) { - if (j < mHeapSize && mFreq[mHeap[j]] > mFreq[mHeap[j + 1]]) { - j++; - } - - if (mFreq[k] <= mFreq[mHeap[j]]) { - break; - } - - mHeap[i] = mHeap[j]; - i = j; - j = 2 * i; - } - - mHeap[i] = (INT16) k; -} - -VOID -EFIAPI -MakeCode ( - IN INT32 n, - IN UINT8 Len[ ], - OUT UINT16 Code[ ] - ) -/*++ - -Routine Description: - - Assign code to each symbol based on the code length array - -Arguments: - - n - number of symbols - Len - the code length array - Code - stores codes for each symbol - -Returns: - - None - -**/ -{ - INT32 i; - UINT16 Start[18]; - - Start[1] = 0; - for (i = 1; i <= 16; i++) { - Start[i + 1] = (UINT16) ((Start[i] + mLenCnt[i]) << 1); - } - - for (i = 0; i < n; i++) { - Code[i] = Start[Len[i]]++; + Status = Encode (); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; } -} - -INT32 -EFIAPI -MakeTree ( - IN INT32 NParm, - IN UINT16 FreqParm[ ], - OUT UINT8 LenParm[ ], - OUT UINT16 CodeParm[ ] - ) -/*++ - -Routine Description: - - Generates Huffman codes given a frequency distribution of symbols - -Arguments: - - NParm - number of symbols - FreqParm - frequency of each symbol - LenParm - code length for each symbol - CodeParm - code for each symbol - -Returns: - - Root of the Huffman tree. - -**/ -{ - INT32 i; - - INT32 j; - - INT32 k; - - INT32 Avail; - // - // make tree, calculate len[], return root + // Null terminate the compressed data // - mN = NParm; - mFreq = FreqParm; - mLen = LenParm; - Avail = mN; - mHeapSize = 0; - mHeap[1] = 0; - for (i = 0; i < mN; i++) { - mLen[i] = 0; - if ((mFreq[i]) != 0) { - mHeapSize++; - mHeap[mHeapSize] = (INT16) i; - } - } - - if (mHeapSize < 2) { - CodeParm[mHeap[1]] = 0; - return mHeap[1]; - } - - for (i = mHeapSize / 2; i >= 1; i--) { - // - // make priority queue - // - DownHeap (i); + if (mDst < mDstUpperLimit) { + *mDst++ = 0; } - - mSortPtr = CodeParm; - do { - i = mHeap[1]; - if (i < mN) { - *mSortPtr++ = (UINT16) i; - } - - mHeap[1] = mHeap[mHeapSize--]; - DownHeap (1); - j = mHeap[1]; - if (j < mN) { - *mSortPtr++ = (UINT16) j; - } - - k = Avail++; - mFreq[k] = (UINT16) (mFreq[i] + mFreq[j]); - mHeap[1] = (INT16) k; - DownHeap (1); - mLeft[k] = (UINT16) i; - mRight[k] = (UINT16) j; - } while (mHeapSize > 1); - - mSortPtr = CodeParm; - MakeLen (k); - MakeCode (NParm, LenParm, CodeParm); + // + // Fill in compressed size and original size + // + mDst = DstBuffer; + PutDword (mCompSize + 1); + PutDword (mOrigSize); // - // return root + // Return // - return k; + if (mCompSize + 1 + 8 > *DstSize) { + *DstSize = mCompSize + 1 + 8; + return EFI_BUFFER_TOO_SMALL; + } else { + *DstSize = mCompSize + 1 + 8; + return EFI_SUCCESS; + } + } + diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h index 29f0a53fe3..64e339cf97 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h @@ -1,7 +1,7 @@ /** @file Header file for compression routine. - Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -19,7 +19,7 @@ The compression routine. @param[in] SrcBuffer The buffer containing the source data. - @param[in] SrcSizae Number of bytes in SrcBuffer. + @param[in] SrcSize Number of bytes in SrcBuffer. @param[in] DstBuffer The buffer to put the compressed image in. @param[in,out] DstSize On input the size (in bytes) of DstBuffer, on return the number of bytes placed in DstBuffer. diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c index 96da304483..4e49d2120b 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c @@ -1,7 +1,7 @@ /** @file Main file for Dblk shell Debug1 function. - Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -15,6 +15,15 @@ #include "UefiShellDebug1CommandsLib.h" #include +/** + Display blocks to the screen. + + @param[in] DevPath The device path to get the blocks from. + @param[in] Lba The Lba number to start from. + @param[in] BlockCount How many blocks to display. + + @retval SHELL_SUCCESS The display was successful. +**/ SHELL_STATUS EFIAPI DisplayTheBlocks( @@ -24,7 +33,6 @@ DisplayTheBlocks( ) { EFI_BLOCK_IO_PROTOCOL *BlockIo; - EFI_DEVICE_PATH_PROTOCOL *Copy; EFI_HANDLE BlockIoHandle; EFI_STATUS Status; SHELL_STATUS ShellStatus; @@ -32,23 +40,38 @@ DisplayTheBlocks( UINTN BufferSize; ShellStatus = SHELL_SUCCESS; - Copy = (EFI_DEVICE_PATH_PROTOCOL *)DevPath; - Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &Copy, &BlockIoHandle); - ASSERT_EFI_ERROR(Status); + Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &((EFI_DEVICE_PATH_PROTOCOL *)DevPath), &BlockIoHandle); + if (EFI_ERROR(Status)) { + return (SHELL_NOT_FOUND); + } Status = gBS->OpenProtocol(BlockIoHandle, &gEfiBlockIoProtocolGuid, (VOID**)&BlockIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - ASSERT_EFI_ERROR(Status); + if (EFI_ERROR(Status)) { + return (SHELL_NOT_FOUND); + } BufferSize = BlockIo->Media->BlockSize * BlockCount; if (BufferSize > 0) { - Buffer = AllocatePool(BufferSize); + Buffer = AllocateZeroPool(BufferSize); } else { + ShellPrintEx(-1,-1,L" BlockSize: 0x%08x, BlockCount: 0x%08x\r\n", BlockIo->Media->BlockSize, BlockCount); Buffer = NULL; } Status = BlockIo->ReadBlocks(BlockIo, BlockIo->Media->MediaId, Lba, BufferSize, Buffer); if (!EFI_ERROR(Status) && Buffer != NULL) { + ShellPrintHiiEx( + -1, + -1, + NULL, + STRING_TOKEN (STR_DBLK_HEADER), + gShellDebug1HiiHandle, + Lba, + BufferSize, + BlockIo + ); + DumpHex(2,0,BufferSize,Buffer); } else { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_READ_FAIL), gShellDebug1HiiHandle, L"BlockIo", Status); @@ -63,6 +86,12 @@ DisplayTheBlocks( return (ShellStatus); } +/** + Function for 'dblk' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ SHELL_STATUS EFIAPI ShellCommandRunDblk ( @@ -70,15 +99,16 @@ ShellCommandRunDblk ( IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; - LIST_ENTRY *Package; - CHAR16 *ProblemParam; - SHELL_STATUS ShellStatus; - CONST CHAR16 *BlockName; - CONST CHAR16 *LbaString; - CONST CHAR16 *BlockCountString; - UINT64 Lba; - UINT8 BlockCount; + EFI_STATUS Status; + LIST_ENTRY *Package; + CHAR16 *ProblemParam; + SHELL_STATUS ShellStatus; + CONST CHAR16 *BlockName; + CONST CHAR16 *LbaString; + CONST CHAR16 *BlockCountString; + UINT64 Lba; + UINT64 BlockCount; + EFI_DEVICE_PATH_PROTOCOL *DevPath; ShellStatus = SHELL_SUCCESS; Status = EFI_SUCCESS; @@ -122,26 +152,45 @@ ShellCommandRunDblk ( if (LbaString == NULL) { Lba = 0; } else { - Lba = (UINT64)StrHexToUintn(LbaString); + if (!ShellIsHexOrDecimalNumber(LbaString, TRUE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, LbaString); + ShellStatus = SHELL_INVALID_PARAMETER; + } + ShellConvertStringToUint64(LbaString, &Lba, TRUE, FALSE); } if (BlockCountString == NULL) { BlockCount = 1; } else { - BlockCount = (UINT8)StrHexToUintn(BlockCountString); + if (!ShellIsHexOrDecimalNumber(BlockCountString, TRUE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, BlockCountString); + ShellStatus = SHELL_INVALID_PARAMETER; + } + ShellConvertStringToUint64(BlockCountString, &BlockCount, TRUE, FALSE); if (BlockCount > 0x10) { BlockCount = 0x10; + } else if (BlockCount == 0) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, BlockCountString); + ShellStatus = SHELL_INVALID_PARAMETER; } } - - // - // do the work if we have a valid block identifier - // - if (mEfiShellProtocol->GetDevicePathFromMap(BlockName) == NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, BlockName); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - ShellStatus = DisplayTheBlocks(mEfiShellProtocol->GetDevicePathFromMap(BlockName), Lba, BlockCount); + + if (ShellStatus == SHELL_SUCCESS) { + // + // do the work if we have a valid block identifier + // + if (mEfiShellProtocol->GetDevicePathFromMap(BlockName) == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, BlockName); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + DevPath = (EFI_DEVICE_PATH_PROTOCOL*)mEfiShellProtocol->GetDevicePathFromMap(BlockName); + if (gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &DevPath, NULL) == EFI_NOT_FOUND) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MAP_PROTOCOL), gShellDebug1HiiHandle, BlockName, L"BlockIo"); + ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ShellStatus = DisplayTheBlocks(mEfiShellProtocol->GetDevicePathFromMap(BlockName), Lba, (UINT8)BlockCount); + } + } } } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c index b8ab9c69e6..0229450528 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c @@ -1,7 +1,7 @@ /** @file Main file for Dmem shell Debug1 function. - Copyright (c) 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -14,8 +14,22 @@ #include "UefiShellDebug1CommandsLib.h" #include +#include +#include +#include +#include +/** + Make a printable character. + + If Char is printable then return it, otherwise return a question mark. + + @param[in] Char The character to make printable. + + @return A printable character representing Char. +**/ CHAR16 +EFIAPI MakePrintable( IN CONST CHAR16 Char ) @@ -26,6 +40,12 @@ MakePrintable( return (Char); } +/** + Display some Memory-Mapped-IO memory. + + @param[in] Address The starting address to display. + @param[in] Size The length of memory to display. +**/ SHELL_STATUS EFIAPI DisplayMmioMemory( @@ -66,6 +86,12 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = { {NULL, TypeMax} }; +/** + Function for 'dmem' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ SHELL_STATUS EFIAPI ShellCommandRunDmem ( @@ -78,8 +104,14 @@ ShellCommandRunDmem ( CHAR16 *ProblemParam; SHELL_STATUS ShellStatus; VOID *Address; - UINTN Size; + UINT64 Size; CONST CHAR16 *Temp1; + UINT64 AcpiTableAddress; + UINT64 Acpi20TableAddress; + UINT64 SalTableAddress; + UINT64 SmbiosTableAddress; + UINT64 MpsTableAddress; + UINTN TableWalker; ShellStatus = SHELL_SUCCESS; Status = EFI_SUCCESS; @@ -108,26 +140,27 @@ ShellCommandRunDmem ( ASSERT(FALSE); } } else { - Temp1 = ShellCommandLineGetRawValue(Package, 1); - if (Temp1 == NULL) { - Address = gST; - Size = 512; + if (ShellCommandLineGetCount(Package) > 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; } else { - if (!ShellIsHexOrDecimalNumber(Temp1, TRUE, FALSE)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp1); - ShellStatus = SHELL_INVALID_PARAMETER; - } else { - Address = (VOID*)StrHexToUintn(Temp1); - } - Temp1 = ShellCommandLineGetRawValue(Package, 2); + Temp1 = ShellCommandLineGetRawValue(Package, 1); if (Temp1 == NULL) { + Address = gST; Size = 512; } else { - if (!ShellIsHexOrDecimalNumber(Temp1, FALSE, FALSE)) { + if (!ShellIsHexOrDecimalNumber(Temp1, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp1, (UINT64*)&Address, TRUE, FALSE))) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp1); ShellStatus = SHELL_INVALID_PARAMETER; + } + Temp1 = ShellCommandLineGetRawValue(Package, 2); + if (Temp1 == NULL) { + Size = 512; } else { - Size = ShellStrToUintn(Temp1); + if (!ShellIsHexOrDecimalNumber(Temp1, FALSE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp1, &Size, TRUE, FALSE))) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp1); + ShellStatus = SHELL_INVALID_PARAMETER; + } } } } @@ -135,9 +168,54 @@ ShellCommandRunDmem ( if (ShellStatus == SHELL_SUCCESS) { if (!ShellCommandLineGetFlag(Package, L"-mmio")) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMEM_HEADER_ROW), gShellDebug1HiiHandle, (UINT64)Address, Size); - DumpHex(2,0,Size,Address); + DumpHex(2,0,(UINTN)Size,Address); + if (Address == (VOID*)gST) { + Acpi20TableAddress = 0; + AcpiTableAddress = 0; + SalTableAddress = 0; + SmbiosTableAddress = 0; + MpsTableAddress = 0; + for (TableWalker = 0 ; TableWalker < gST->NumberOfTableEntries ; TableWalker++) { + if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiAcpi20TableGuid)) { + Acpi20TableAddress = (UINT64)gST->ConfigurationTable[TableWalker].VendorTable; + continue; + } + if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiAcpi10TableGuid)) { + AcpiTableAddress = (UINT64)gST->ConfigurationTable[TableWalker].VendorTable; + continue; + } + if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiSalSystemTableGuid)) { + SalTableAddress = (UINT64)gST->ConfigurationTable[TableWalker].VendorTable; + continue; + } + if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiSmbiosTableGuid)) { + SmbiosTableAddress = (UINT64)gST->ConfigurationTable[TableWalker].VendorTable; + continue; + } + if (CompareGuid(&gST->ConfigurationTable[TableWalker].VendorGuid, &gEfiMpsTableGuid)) { + MpsTableAddress = (UINT64)gST->ConfigurationTable[TableWalker].VendorTable; + continue; + } + } + + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMEM_SYSTEM_TABLE), gShellDebug1HiiHandle, + (UINT64)Address, + gST->Hdr.HeaderSize, + gST->Hdr.Revision, + (UINT64)gST->ConIn, + (UINT64)gST->ConOut, + (UINT64)gST->StdErr, + (UINT64)gST->RuntimeServices, + (UINT64)gST->BootServices, + SalTableAddress, + AcpiTableAddress, + Acpi20TableAddress, + MpsTableAddress, + SmbiosTableAddress + ); + } } else { - ShellStatus = DisplayMmioMemory(Address, Size); + ShellStatus = DisplayMmioMemory(Address, (UINTN)Size); } } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c index 0a586591be..60ced4ee73 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c @@ -1,7 +1,7 @@ /** @file Main file for DmpStore shell Debug1 function. - Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -25,6 +25,19 @@ STATIC CHAR16 *AttrType[] = { L"NV+RT+BS", // 111 }; +/** + Function to display or delete variables. + + @param[in] VariableName The variable name of the EFI variable (or NULL). + @param[in] Guid The GUID of the variable set (or NULL). + @param[in] Delete TRUE to delete, FALSE otherwise. + + @retval SHELL_SUCCESS The operation was successful. + @retval SHELL_OUT_OF_RESOURCES A memorty allocation failed. + @retval SHELL_ABORTED The abort message was received. + @retval SHELL_DEVICE_ERROR UEFI Variable Services returned an error. + @retval SHELL_NOT_FOUND the Name/Guid pair could not be found. +**/ SHELL_STATUS EFIAPI ProcessVariables ( @@ -44,21 +57,26 @@ ProcessVariables ( UINTN DataSize; UINT32 Atts; SHELL_STATUS ShellStatus; + BOOLEAN Found; + + Status = gRT->QueryVariableInfo(EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS|EFI_VARIABLE_NON_VOLATILE, &MaxStorSize, &RemStorSize, &MaxVarSize); + if (EFI_ERROR(Status)) { + return (SHELL_DEVICE_ERROR); + } + Found = FALSE; ShellStatus = SHELL_SUCCESS; Size = PcdGet16(PcdShellFileOperationSize); - FoundVarName = AllocatePool(Size); + FoundVarName = AllocateZeroPool(Size); if (FoundVarName == NULL) { return (SHELL_OUT_OF_RESOURCES); } FoundVarName[0] = CHAR_NULL; - Status = gRT->QueryVariableInfo(EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS|EFI_VARIABLE_NON_VOLATILE, &MaxStorSize, &RemStorSize, &MaxVarSize); - ASSERT_EFI_ERROR(Status); DataSize = (UINTN)MaxVarSize; - DataBuffer = AllocatePool(DataSize); + DataBuffer = AllocateZeroPool(DataSize); if (DataBuffer == NULL) { FreePool(FoundVarName); return (SHELL_OUT_OF_RESOURCES); @@ -98,6 +116,7 @@ ProcessVariables ( // // do the print or delete // + Found = TRUE; if (!Delete) { ShellPrintHiiEx( -1, @@ -135,8 +154,19 @@ ProcessVariables ( if (DataBuffer != NULL) { FreePool(DataBuffer); } - - return (SHELL_UNSUPPORTED); + if (!Found) { + if (VariableName != NULL && Guid == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N), gShellDebug1HiiHandle, VariableName); + } else if (VariableName != NULL && Guid != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_GN), gShellDebug1HiiHandle, Guid, VariableName); + } else if (VariableName == NULL && Guid == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND), gShellDebug1HiiHandle); + } else if (VariableName == NULL && Guid != NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G), gShellDebug1HiiHandle, Guid); + } + return (SHELL_NOT_FOUND); + } + return (SHELL_SUCCESS); } STATIC CONST SHELL_PARAM_ITEM ParamList[] = { @@ -148,6 +178,12 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = { {NULL, TypeMax} }; +/** + Function for 'dmpstore' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ SHELL_STATUS EFIAPI ShellCommandRunDmpStore ( @@ -177,10 +213,7 @@ ShellCommandRunDmpStore ( ASSERT(FALSE); } } else { - if (ShellCommandLineGetCount(Package) < 1) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); - ShellStatus = SHELL_INVALID_PARAMETER; - } else if (ShellCommandLineGetCount(Package) > 2) { + if (ShellCommandLineGetCount(Package) > 2) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; } else if (ShellCommandLineGetFlag(Package, L"-all") && ShellCommandLineGetFlag(Package, L"-guid")) { @@ -195,14 +228,14 @@ ShellCommandRunDmpStore ( if (Temp != NULL) { Status = ConvertStringToGuid(Temp, &GuidData); if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"-guid"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); ShellStatus = SHELL_INVALID_PARAMETER; } Guid = &GuidData; } else { Guid = &gEfiGlobalVariableGuid; } - VariableName = ShellCommandLineGetRawValue(Package, 2); + VariableName = ShellCommandLineGetRawValue(Package, 1); } else { VariableName = NULL; Guid = NULL; @@ -210,9 +243,8 @@ ShellCommandRunDmpStore ( if (ShellStatus == SHELL_SUCCESS) { if (ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-l")) { ///@todo fix this after Jordan makes lib... - ShellPrintEx(-1, -1, L"Not implemeneted yet (ASSERT follows).\r\n"); - ShellStatus = SHELL_INVALID_PARAMETER; - ASSERT(FALSE); + ShellPrintEx(-1, -1, L"Not implemeneted yet.\r\n"); + ShellStatus = SHELL_UNSUPPORTED; } else { ShellStatus = ProcessVariables (VariableName, Guid, ShellCommandLineGetFlag(Package, L"-d")); } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c index 8d5aabdafc..3f27d1ae0d 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c @@ -1,7 +1,7 @@ /** @file Main file for EfiCompress shell Debug1 function. - Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -15,6 +15,12 @@ #include "UefiShellDebug1CommandsLib.h" #include "Compress.h" +/** + Function for 'compress' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ SHELL_STATUS EFIAPI ShellCommandRunEfiCompress ( @@ -76,65 +82,68 @@ ShellCommandRunEfiCompress ( } else { InFileName = ShellFindFilePath(ShellCommandLineGetRawValue(Package, 1)); OutFileName = ShellCommandLineGetRawValue(Package, 2); - Status = ShellOpenFileByName(InFileName, &InShellFileHandle, EFI_FILE_MODE_READ, 0); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1), Status); - ShellStatus = SHELL_NOT_FOUND; - } - Status = ShellOpenFileByName(OutFileName, &OutShellFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status); + if (InFileName == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1)); ShellStatus = SHELL_NOT_FOUND; - } - if (FileHandleIsDirectory(InShellFileHandle) == EFI_SUCCESS){ - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, InFileName); - ShellStatus = SHELL_INVALID_PARAMETER; - } - if (FileHandleIsDirectory(OutShellFileHandle) == EFI_SUCCESS){ - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, OutFileName); - ShellStatus = SHELL_INVALID_PARAMETER; - } - Status = gEfiShellProtocol->GetFileSize(InShellFileHandle, &InSize); - ASSERT_EFI_ERROR(Status); - InBuffer = AllocateZeroPool((UINTN)InSize); - ASSERT(InBuffer != NULL); - Status = gEfiShellProtocol->ReadFile(InShellFileHandle, &((UINTN)InSize), InBuffer); - ASSERT_EFI_ERROR(Status); - Status = Compress(InBuffer, InSize, OutBuffer, &OutSize); - if (Status == EFI_BUFFER_TOO_SMALL) { - OutBuffer = AllocateZeroPool((UINTN)OutSize); - ASSERT(OutBuffer != NULL); - Status = Compress(InBuffer, InSize, OutBuffer, &OutSize); - } - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_COMPRESS_FAIL), gShellDebug1HiiHandle, Status); - ShellStatus = SHELL_DEVICE_ERROR; } else { - Status = gEfiShellProtocol->WriteFile(OutShellFileHandle, &((UINTN)OutSize), OutBuffer); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, OutFileName, Status); - ShellStatus = SHELL_DEVICE_ERROR; + if (ShellIsDirectory(InFileName) == EFI_SUCCESS){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, InFileName); + ShellStatus = SHELL_INVALID_PARAMETER; + } + if (ShellIsDirectory(OutFileName) == EFI_SUCCESS){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, OutFileName); + ShellStatus = SHELL_INVALID_PARAMETER; + } + if (ShellStatus == SHELL_SUCCESS) { + Status = ShellOpenFileByName(InFileName, &InShellFileHandle, EFI_FILE_MODE_READ, 0); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1), Status); + ShellStatus = SHELL_NOT_FOUND; + } + Status = ShellOpenFileByName(OutFileName, &OutShellFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status); + ShellStatus = SHELL_NOT_FOUND; + } + } + if (ShellStatus == SHELL_SUCCESS) { + Status = gEfiShellProtocol->GetFileSize(InShellFileHandle, &InSize); + ASSERT_EFI_ERROR(Status); + InBuffer = AllocateZeroPool((UINTN)InSize); + ASSERT(InBuffer != NULL); + Status = gEfiShellProtocol->ReadFile(InShellFileHandle, &((UINTN)InSize), InBuffer); + ASSERT_EFI_ERROR(Status); + Status = Compress(InBuffer, InSize, OutBuffer, &OutSize); + if (Status == EFI_BUFFER_TOO_SMALL) { + OutBuffer = AllocateZeroPool((UINTN)OutSize); + ASSERT(OutBuffer != NULL); + Status = Compress(InBuffer, InSize, OutBuffer, &OutSize); + } + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_COMPRESS_FAIL), gShellDebug1HiiHandle, Status); + ShellStatus = SHELL_DEVICE_ERROR; + } else { + Status = gEfiShellProtocol->WriteFile(OutShellFileHandle, &((UINTN)OutSize), OutBuffer); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, OutFileName, Status); + ShellStatus = SHELL_DEVICE_ERROR; + } + } } } } ShellCommandLineFreeVarList (Package); } - if (InFileName != NULL) { - FreePool(InFileName); - } if (InShellFileHandle != NULL) { gEfiShellProtocol->CloseFile(InShellFileHandle); } if (OutShellFileHandle != NULL) { gEfiShellProtocol->CloseFile(OutShellFileHandle); } - if (InBuffer != NULL) { - FreePool(InBuffer); - } - if (OutBuffer != NULL) { - FreePool(OutBuffer); - } + SHELL_FREE_NON_NULL(InFileName); + SHELL_FREE_NON_NULL(InBuffer); + SHELL_FREE_NON_NULL(OutBuffer); return (ShellStatus); } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c index 3d01515f05..4b4671b455 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c @@ -16,6 +16,12 @@ #include +/** + Function for 'decompress' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ SHELL_STATUS EFIAPI ShellCommandRunEfiDecompress ( @@ -27,8 +33,8 @@ ShellCommandRunEfiDecompress ( LIST_ENTRY *Package; CHAR16 *ProblemParam; SHELL_STATUS ShellStatus; - SHELL_FILE_HANDLE InFileHandle; - SHELL_FILE_HANDLE OutFileHandle; + SHELL_FILE_HANDLE InFileHandle; + SHELL_FILE_HANDLE OutFileHandle; UINT32 OutSize; UINTN OutSizeTemp; VOID *OutBuffer; @@ -36,7 +42,7 @@ ShellCommandRunEfiDecompress ( VOID *InBuffer; CHAR16 *InFileName; CONST CHAR16 *OutFileName; - UINT64 temp; + UINT64 Temp64Bit; UINT32 ScratchSize; VOID *ScratchBuffer; EFI_DECOMPRESS_PROTOCOL *Decompress; @@ -83,81 +89,84 @@ ShellCommandRunEfiDecompress ( } else { InFileName = ShellFindFilePath(ShellCommandLineGetRawValue(Package, 1)); OutFileName = ShellCommandLineGetRawValue(Package, 2); - Status = ShellOpenFileByName(InFileName, &InFileHandle, EFI_FILE_MODE_READ, 0); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1), Status); - ShellStatus = SHELL_NOT_FOUND; - } - Status = ShellOpenFileByName(OutFileName, &OutFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status); + if (InFileName == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1)); ShellStatus = SHELL_NOT_FOUND; - } - if (FileHandleIsDirectory(InFileHandle) == EFI_SUCCESS){ - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, InFileName); - ShellStatus = SHELL_INVALID_PARAMETER; - } - if (FileHandleIsDirectory(OutFileHandle) == EFI_SUCCESS){ - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, OutFileName); - ShellStatus = SHELL_INVALID_PARAMETER; - } - Status = FileHandleGetSize(InFileHandle, &temp); - ASSERT(temp <= (UINT32)(-1)); - InSize = (UINTN)temp; - ASSERT_EFI_ERROR(Status); - InBuffer = AllocatePool(InSize); - ASSERT(InBuffer != NULL); - Status = gEfiShellProtocol->ReadFile(InFileHandle, &InSize, InBuffer); - ASSERT_EFI_ERROR(Status); - - Status = gBS->LocateProtocol(&gEfiDecompressProtocolGuid, NULL, (VOID**)&Decompress); - ASSERT_EFI_ERROR(Status); - - Status = Decompress->GetInfo(Decompress, InBuffer, (UINT32)InSize, &OutSize, &ScratchSize); - ASSERT_EFI_ERROR(Status); - - OutBuffer = AllocatePool(OutSize); - ScratchBuffer = AllocatePool(ScratchSize); - ASSERT(OutBuffer != NULL); - ASSERT(ScratchBuffer != NULL); - - Status = Decompress->Decompress(Decompress, InBuffer, (UINT32)InSize, OutBuffer, OutSize, ScratchBuffer, ScratchSize); - ASSERT_EFI_ERROR(Status); - - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_FAIL), gShellDebug1HiiHandle, Status); - ShellStatus = SHELL_DEVICE_ERROR; } else { - OutSizeTemp = OutSize; - Status = gEfiShellProtocol->WriteFile(OutFileHandle, &OutSizeTemp, OutBuffer); - OutSize = (UINT32)OutSizeTemp; - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, OutFileName, Status); - ShellStatus = SHELL_DEVICE_ERROR; + if (ShellIsDirectory(InFileName) == EFI_SUCCESS){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, InFileName); + ShellStatus = SHELL_INVALID_PARAMETER; + } + if (ShellIsDirectory(OutFileName) == EFI_SUCCESS){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, OutFileName); + ShellStatus = SHELL_INVALID_PARAMETER; + } + if (ShellStatus == SHELL_SUCCESS) { + Status = ShellOpenFileByName(InFileName, &InFileHandle, EFI_FILE_MODE_READ, 0); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1), Status); + ShellStatus = SHELL_NOT_FOUND; + } + Status = ShellOpenFileByName(OutFileName, &OutFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status); + ShellStatus = SHELL_NOT_FOUND; + } + } + + if (ShellStatus == SHELL_SUCCESS) { + Status = FileHandleGetSize(InFileHandle, &Temp64Bit); + ASSERT(Temp64Bit <= (UINT32)(-1)); + InSize = (UINTN)Temp64Bit; + ASSERT_EFI_ERROR(Status); + InBuffer = AllocateZeroPool(InSize); + ASSERT(InBuffer != NULL); + Status = gEfiShellProtocol->ReadFile(InFileHandle, &InSize, InBuffer); + ASSERT_EFI_ERROR(Status); + + Status = gBS->LocateProtocol(&gEfiDecompressProtocolGuid, NULL, (VOID**)&Decompress); + ASSERT_EFI_ERROR(Status); + + Status = Decompress->GetInfo(Decompress, InBuffer, (UINT32)InSize, &OutSize, &ScratchSize); + ASSERT_EFI_ERROR(Status); + + OutBuffer = AllocateZeroPool(OutSize); + ScratchBuffer = AllocateZeroPool(ScratchSize); + ASSERT(OutBuffer != NULL); + ASSERT(ScratchBuffer != NULL); + + Status = Decompress->Decompress(Decompress, InBuffer, (UINT32)InSize, OutBuffer, OutSize, ScratchBuffer, ScratchSize); + ASSERT_EFI_ERROR(Status); + + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_DECOMPRESS_FAIL), gShellDebug1HiiHandle, Status); + ShellStatus = SHELL_DEVICE_ERROR; + } else { + OutSizeTemp = OutSize; + Status = gEfiShellProtocol->WriteFile(OutFileHandle, &OutSizeTemp, OutBuffer); + OutSize = (UINT32)OutSizeTemp; + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_WRITE_FAIL), gShellDebug1HiiHandle, OutFileName, Status); + ShellStatus = SHELL_DEVICE_ERROR; + } + } } } } ShellCommandLineFreeVarList (Package); } - if (InFileName != NULL) { - FreePool(InFileName); - } if (InFileHandle != NULL) { gEfiShellProtocol->CloseFile(InFileHandle); } if (OutFileHandle != NULL) { gEfiShellProtocol->CloseFile(OutFileHandle); } - if (InBuffer != NULL) { - FreePool(InBuffer); - } - if (OutBuffer != NULL) { - FreePool(OutBuffer); - } - if (ScratchBuffer != NULL) { - FreePool(ScratchBuffer); - } + + SHELL_FREE_NON_NULL(InFileName); + SHELL_FREE_NON_NULL(InBuffer); + SHELL_FREE_NON_NULL(OutBuffer); + SHELL_FREE_NON_NULL(ScratchBuffer); return (ShellStatus); } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c index 0084f87ca1..8f10158000 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c @@ -1,7 +1,7 @@ /** @file Main file for LoadPciRom shell Debug1 function. - Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -18,19 +18,31 @@ #include #include +/** + Connects all available drives and controllers. + + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The abort mechanism was received. +**/ EFI_STATUS EFIAPI LoadPciRomConnectAllDriversToAllControllers ( VOID ); -EFI_STATUS -EFIAPI -InitializeLoadPciRom ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); +/** + Command entry point. + @param[in] RomBar The Rom Base address. + @param[in] RomSize The Rom size. + @param[in] FileName The file name. + + @retval EFI_SUCCESS The command completed successfully. + @retval EFI_INVALID_PARAMETER Command usage error. + @retval EFI_UNSUPPORTED Protocols unsupported. + @retval EFI_OUT_OF_RESOURCES Out of memory. + @retval Other value Unknown error. +**/ EFI_STATUS EFIAPI LoadEfiDriversFromRomImage ( @@ -44,6 +56,12 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = { {NULL, TypeMax} }; +/** + Function for 'loadpcirom' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ SHELL_STATUS EFIAPI ShellCommandRunLoadPciRom ( @@ -83,11 +101,11 @@ ShellCommandRunLoadPciRom ( ASSERT(FALSE); } } else { - if (ShellCommandLineGetCount(Package) < 1) { + if (ShellCommandLineGetCount(Package) < 2) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; } else { - if (!ShellCommandLineGetFlag(Package, L"-nc")) { + if (ShellCommandLineGetFlag(Package, L"-nc")) { Connect = FALSE; } else { Connect = TRUE; @@ -103,15 +121,12 @@ ShellCommandRunLoadPciRom ( ){ Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList); if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, Param, Status); ShellStatus = SHELL_ACCESS_DENIED; break; } } - if (FileList == NULL || IsListEmpty(&FileList->Link)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle); - } else if (ShellStatus == SHELL_SUCCESS) { - - + if (ShellStatus == SHELL_SUCCESS && FileList != NULL) { // // loop through the list and make sure we are not aborting... // @@ -130,7 +145,7 @@ ShellCommandRunLoadPciRom ( continue; } SourceSize = (UINTN) Node->Info->FileSize; - File1Buffer = AllocatePool (SourceSize); + File1Buffer = AllocateZeroPool (SourceSize); ASSERT(File1Buffer != NULL); Status = gEfiShellProtocol->ReadFile(Node->Handle, &SourceSize, File1Buffer); if (EFI_ERROR(Status)) { @@ -147,6 +162,9 @@ ShellCommandRunLoadPciRom ( } FreePool(File1Buffer); } + } else if (ShellStatus == SHELL_SUCCESS) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle); + ShellStatus = SHELL_NOT_FOUND; } if (FileList != NULL && !IsListEmpty(&FileList->Link)) { Status = ShellCloseFileMetaArg(&FileList); @@ -162,31 +180,27 @@ ShellCommandRunLoadPciRom ( return (ShellStatus); } +/** + Command entry point. + + @param[in] RomBar The Rom Base address. + @param[in] RomSize The Rom size. + @param[in] FileName The file name. + + @retval EFI_SUCCESS The command completed successfully. + @retval EFI_INVALID_PARAMETER Command usage error. + @retval EFI_UNSUPPORTED Protocols unsupported. + @retval EFI_OUT_OF_RESOURCES Out of memory. + @retval Other value Unknown error. +**/ EFI_STATUS +EFIAPI LoadEfiDriversFromRomImage ( VOID *RomBar, UINTN RomSize, CONST CHAR16 *FileName ) -/*++ - -Routine Description: - Command entry point. -Arguments: - - RomBar - Rom - RomSize - Rom size - FileName - The file name - -Returns: - EFI_SUCCESS - The command completed successfully - EFI_INVALID_PARAMETER - Command usage error - EFI_UNSUPPORTED - Protocols unsupported - EFI_OUT_OF_RESOURCES - Out of memory - Other value - Unknown error - -**/ { EFI_PCI_EXPANSION_ROM_HEADER *EfiRomHeader; PCI_DATA_STRUCTURE *Pcir; @@ -196,7 +210,7 @@ Returns: UINT16 ImageOffset; EFI_HANDLE ImageHandle; EFI_STATUS Status; - EFI_STATUS retStatus; + EFI_STATUS ReturnStatus; CHAR16 RomFileName[280]; EFI_DEVICE_PATH_PROTOCOL *FilePath; BOOLEAN SkipImage; @@ -209,7 +223,7 @@ Returns: EFI_DECOMPRESS_PROTOCOL *Decompress; ImageIndex = 0; - retStatus = EFI_NOT_FOUND; + ReturnStatus = EFI_NOT_FOUND; RomBarOffset = (UINTN) RomBar; do { @@ -219,7 +233,7 @@ Returns: if (EfiRomHeader->Signature != 0xaa55) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_CORRUPT), gShellDebug1HiiHandle, FileName, ImageIndex); // PrintToken (STRING_TOKEN (STR_LOADPCIROM_IMAGE_CORRUPT), HiiHandle, ImageIndex); - return retStatus; + return ReturnStatus; } Pcir = (PCI_DATA_STRUCTURE *) (UINTN) (RomBarOffset + EfiRomHeader->PcirOffset); @@ -262,9 +276,9 @@ Returns: &ScratchSize ); if (!EFI_ERROR (Status)) { - DecompressedImageBuffer = AllocatePool (DestinationSize); + DecompressedImageBuffer = AllocateZeroPool (DestinationSize); if (ImageBuffer != NULL) { - Scratch = AllocatePool (ScratchSize); + Scratch = AllocateZeroPool (ScratchSize); if (Scratch != NULL) { Status = Decompress->Decompress ( Decompress, @@ -312,7 +326,7 @@ Returns: ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_START_FAIL), gShellDebug1HiiHandle, FileName, ImageIndex, Status); // PrintToken (STRING_TOKEN (STR_LOADPCIROM_START_IMAGE), HiiHandle, ImageIndex, Status); } else { - retStatus = Status; + ReturnStatus = Status; } } } @@ -328,10 +342,17 @@ Returns: ImageIndex++; } while (((Pcir->Indicator & 0x80) == 0x00) && ((RomBarOffset - (UINTN) RomBar) < RomSize)); - return retStatus; + return ReturnStatus; } +/** + Connects all available drives and controllers. + + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The abort mechanism was received. +**/ EFI_STATUS +EFIAPI LoadPciRomConnectAllDriversToAllControllers ( VOID ) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c index 653c7f2d9e..59900d3256 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/MemMap.c @@ -1,7 +1,7 @@ /** @file Main file for Mode shell Debug1 function. - Copyright (c) 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
This program and the acModeanying materials are licensed and made available under the terms and conditions of the BSD License which acModeanies this distribution. The full text of the license may be found at @@ -12,23 +12,29 @@ **/ -STATIC CONST CHAR16 strNameEfiReservedMemoryType[] = L"Reserved"; -STATIC CONST CHAR16 strNameEfiLoaderCode[] = L"LoadCode"; -STATIC CONST CHAR16 strNameEfiLoaderData[] = L"LoadData"; -STATIC CONST CHAR16 strNameEfiBootServicesCode[] = L"BSCode"; -STATIC CONST CHAR16 strNameEfiBootServicesData[] = L"BSData"; -STATIC CONST CHAR16 strNameEfiRuntimeServicesCode[] = L"RTCode"; -STATIC CONST CHAR16 strNameEfiRuntimeServicesData[] = L"RTData"; -STATIC CONST CHAR16 strNameEfiConventionalMemory[] = L"Conv"; -STATIC CONST CHAR16 strNameEfiUnusableMemory[] = L"Unusable"; -STATIC CONST CHAR16 strNameEfiACPIReclaimMemory[] = L"ACPIRec"; -STATIC CONST CHAR16 strNameEfiACPIMemoryNVS[] = L"ACPI_NVS"; -STATIC CONST CHAR16 strNameEfiMemoryMappedIO[] = L"MMIO"; -STATIC CONST CHAR16 strNameEfiMemoryMappedIOPortSpace[] = L"MMIOPort"; -STATIC CONST CHAR16 strNameEfiPalCode[] = L"PalCode"; +STATIC CONST CHAR16 NameEfiReservedMemoryType[] = L"Reserved"; +STATIC CONST CHAR16 NameEfiLoaderCode[] = L"LoaderCode"; +STATIC CONST CHAR16 NameEfiLoaderData[] = L"LoaderData"; +STATIC CONST CHAR16 NameEfiBootServicesCode[] = L"BS_Code"; +STATIC CONST CHAR16 NameEfiBootServicesData[] = L"BS_Data"; +STATIC CONST CHAR16 NameEfiRuntimeServicesCode[] = L"RT_Code"; +STATIC CONST CHAR16 NameEfiRuntimeServicesData[] = L"RT_Data"; +STATIC CONST CHAR16 NameEfiConventionalMemory[] = L"Available"; +STATIC CONST CHAR16 NameEfiUnusableMemory[] = L"Unusable"; +STATIC CONST CHAR16 NameEfiACPIReclaimMemory[] = L"ACPIRec"; +STATIC CONST CHAR16 NameEfiACPIMemoryNVS[] = L"ACPI_NVS"; +STATIC CONST CHAR16 NameEfiMemoryMappedIO[] = L"MMIO"; +STATIC CONST CHAR16 NameEfiMemoryMappedIOPortSpace[] = L"MMIOPort"; +STATIC CONST CHAR16 NameEfiPalCode[] = L"PalCode"; #include "UefiShellDebug1CommandsLib.h" +/** + Function for 'memmap' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ SHELL_STATUS EFIAPI ShellCommandRunMemMap ( @@ -64,8 +70,17 @@ ShellCommandRunMemMap ( UINT64 RTCodePagesSize; UINT64 AvailPagesSize; UINT64 TotalPagesSize; + UINT64 AcpiReclaimPages; + UINT64 AcpiNvsPages; + UINT64 MmioSpacePages; + UINT64 AcpiReclaimPagesSize; + UINT64 AcpiNvsPagesSize; + UINT64 MmioSpacePagesSize; BOOLEAN Sfo; + AcpiReclaimPages = 0; + AcpiNvsPages = 0; + MmioSpacePages = 0; TotalPages = 0; ReservedPages = 0; LoadCodePages = 0; @@ -109,7 +124,7 @@ ShellCommandRunMemMap ( Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version); if (Status == EFI_BUFFER_TOO_SMALL){ Size += SIZE_1KB; - Buffer = AllocatePool(Size); + Buffer = AllocateZeroPool(Size); Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version); } if (EFI_ERROR(Status)) { @@ -123,67 +138,70 @@ ShellCommandRunMemMap ( switch (((EFI_MEMORY_DESCRIPTOR*)Walker)->Type) { // replaced ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages) with 0000 case EfiReservedMemoryType: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiReservedMemoryType, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiReservedMemoryType, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); ReservedPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiLoaderCode: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiLoaderCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiLoaderCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); LoadCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiLoaderData: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiLoaderData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiLoaderData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); LoadDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiBootServicesCode: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiBootServicesCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiBootServicesCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); BSCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiBootServicesData: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiBootServicesData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiBootServicesData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); BSDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiRuntimeServicesCode: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiRuntimeServicesCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiRuntimeServicesCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); RTCodePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiRuntimeServicesData: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiRuntimeServicesData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiRuntimeServicesData, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); RTDataPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiConventionalMemory: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiConventionalMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiConventionalMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); AvailPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiUnusableMemory: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiUnusableMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiUnusableMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiACPIReclaimMemory: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiACPIReclaimMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiACPIReclaimMemory, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + AcpiReclaimPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiACPIMemoryNVS: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiACPIMemoryNVS, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiACPIMemoryNVS, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + AcpiNvsPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiMemoryMappedIO: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiMemoryMappedIO, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiMemoryMappedIO, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; + MmioSpacePages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiMemoryMappedIOPortSpace: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiMemoryMappedIOPortSpace, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiMemoryMappedIOPortSpace, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; case EfiPalCode: - ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, strNameEfiPalCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages), ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); + ShellPrintHiiEx(-1, -1, NULL, (EFI_STRING_ID)(!Sfo?STRING_TOKEN (STR_MEMMAP_LIST_ITEM):STRING_TOKEN (STR_MEMMAP_LIST_ITEM_SFO)), gShellDebug1HiiHandle, NameEfiPalCode, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart, ((EFI_MEMORY_DESCRIPTOR*)Walker)->PhysicalStart+MultU64x64(SIZE_4KB,((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages)-1, ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages, ((EFI_MEMORY_DESCRIPTOR*)Walker)->Attribute); TotalPages += ((EFI_MEMORY_DESCRIPTOR*)Walker)->NumberOfPages; break; default: @@ -202,6 +220,9 @@ ShellCommandRunMemMap ( RTCodePagesSize = MultU64x64(SIZE_4KB,RTCodePages); AvailPagesSize = MultU64x64(SIZE_4KB,AvailPages); TotalPagesSize = MultU64x64(SIZE_4KB,TotalPages); + AcpiReclaimPagesSize = MultU64x64(SIZE_4KB,AcpiReclaimPages); + AcpiNvsPagesSize = MultU64x64(SIZE_4KB,AcpiNvsPages); + MmioSpacePagesSize = MultU64x64(SIZE_4KB,MmioSpacePages); if (!Sfo) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_LIST_SUMM), gShellDebug1HiiHandle, ReservedPages, ReservedPagesSize, @@ -209,7 +230,11 @@ ShellCommandRunMemMap ( LoadDataPages, LoadDataPagesSize, BSCodePages, BSCodePagesSize, BSDataPages, BSDataPagesSize, + RTCodePages, RTCodePagesSize, RTDataPages, RTDataPagesSize, + AcpiReclaimPages, AcpiReclaimPagesSize, + AcpiNvsPages, AcpiNvsPagesSize, + MmioSpacePages, MmioSpacePagesSize, AvailPages, AvailPagesSize, DivU64x32(MultU64x64(SIZE_4KB,TotalPages), SIZE_1MB), TotalPagesSize ); diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c index a9be4950c8..ad1e9d09b4 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c @@ -1,7 +1,7 @@ /** @file Main file for Mm shell Debug1 function. - Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -25,22 +25,69 @@ typedef enum { EfiPciEConfig } EFI_ACCESS_TYPE; -EFI_STATUS -EFIAPI -DumpIoModify ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); +STATIC CONST SHELL_PARAM_ITEM ParamList[] = { + {L"-mmio", TypeFlag}, + {L"-mem", TypeFlag}, + {L"-io", TypeFlag}, + {L"-pci", TypeFlag}, + {L"-pcie", TypeFlag}, + {L"-n", TypeFlag}, + {L"-w", TypeValue}, + {NULL, TypeMax} + }; + +STATIC CONST UINT64 MaxNum[9] = { 0xff, 0xffff, 0xffffffff, 0xffffffffffffffff }; + +/** + Read some data into a buffer from memory. + @param[in] Width The width of each read. + @param[in] Addresss The memory location to start reading at. + @param[in] Size The size of Buffer in Width sized units. + @param[out] Buffer The buffer to read into. +**/ VOID EFIAPI ReadMem ( IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, IN UINT64 Address, IN UINTN Size, - IN VOID *Buffer - ); + OUT VOID *Buffer + ) +{ + // + // This function is defective. This ASSERT prevents the defect from affecting anything. + // + ASSERT(Size == 1); + do { + if (Width == EfiPciWidthUint8) { + *(UINT8 *) Buffer = *(UINT8 *) (UINTN) Address; + Address -= 1; + } else if (Width == EfiPciWidthUint16) { + *(UINT16 *) Buffer = *(UINT16 *) (UINTN) Address; + Address -= 2; + } else if (Width == EfiPciWidthUint32) { + *(UINT32 *) Buffer = *(UINT32 *) (UINTN) Address; + Address -= 4; + } else if (Width == EfiPciWidthUint64) { + *(UINT64 *) Buffer = *(UINT64 *) (UINTN) Address; + Address -= 8; + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_READ_ERROR), gShellDebug1HiiHandle); + break; + } + Size--; + } while (Size > 0); +} + +/** + Write some data to memory. + @param[in] Width The width of each write. + @param[in] Addresss The memory location to start writing at. + @param[in] Size The size of Buffer in Width sized units. + @param[in] Buffer The buffer to write from. +**/ VOID EFIAPI WriteMem ( @@ -48,27 +95,84 @@ WriteMem ( IN UINT64 Address, IN UINTN Size, IN VOID *Buffer - ); + ) +{ + // + // This function is defective. This ASSERT prevents the defect from affecting anything. + // + ASSERT(Size == 1); + do { + if (Width == EfiPciWidthUint8) { + *(UINT8 *) (UINTN) Address = *(UINT8 *) Buffer; + Address += 1; + } else if (Width == EfiPciWidthUint16) { + *(UINT16 *) (UINTN) Address = *(UINT16 *) Buffer; + Address += 2; + } else if (Width == EfiPciWidthUint32) { + *(UINT32 *) (UINTN) Address = *(UINT32 *) Buffer; + Address += 4; + } else if (Width == EfiPciWidthUint64) { + *(UINT64 *) (UINTN) Address = *(UINT64 *) Buffer; + Address += 8; + } else { + ASSERT (FALSE); + } + // + // + // + Size--; + } while (Size > 0); +} +/** + Convert a string to it's hex data. + + @param[in] str The pointer to the string of hex data. + @param[out] data The pointer to the buffer to fill. Valid upon a TRUE return. + + @retval TRUE The conversion was successful. + @retval FALSE The conversion failed. +**/ BOOLEAN EFIAPI GetHex ( IN UINT16 *str, OUT UINT64 *data - ); + ) +{ + UINTN TempUint; + CHAR16 TempChar; + BOOLEAN Find; -STATIC CONST SHELL_PARAM_ITEM ParamList[] = { - {L"-mmio", TypeFlag}, - {L"-mem", TypeFlag}, - {L"-io", TypeFlag}, - {L"-pci", TypeFlag}, - {L"-pcie", TypeFlag}, - {L"-n", TypeFlag}, - {L"-w", TypeValue}, - {NULL, TypeMax} - }; + Find = FALSE; + // + // convert hex digits + // + TempUint = 0; + TempChar = *(str++); + while (TempChar != CHAR_NULL) { + if (TempChar >= 'a' && TempChar <= 'f') { + TempChar -= 'a' - 'A'; + } -STATIC CONST UINT64 MaxNum[9] = { 0xff, 0xffff, 0xffffffff, 0xffffffffffffffff }; + if (TempChar == ' ') { + break; + } + + if ((TempChar >= '0' && TempChar <= '9') || (TempChar >= 'A' && TempChar <= 'F')) { + TempUint = TempUint << 4 | TempChar - (TempChar >= 'A' ? 'A' - 10 : '0'); + + Find = TRUE; + } else { + return FALSE; + } + + TempChar = *(str++); + } + + *data = TempUint; + return Find; +} /** Get the PCI-E Address from a PCI address format 0x0000ssbbddffrrr @@ -157,7 +261,7 @@ ShellCommandRunMm ( ASSERT(FALSE); } } else { - if (ShellCommandLineGetCount(Package) < 1) { + if (ShellCommandLineGetCount(Package) < 2) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; goto Done; @@ -165,15 +269,49 @@ ShellCommandRunMm ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; goto Done; + } else if (ShellCommandLineGetFlag(Package, L"-w") && ShellCommandLineGetValue(Package, L"-w") == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"-w"); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; } else { if (ShellCommandLineGetFlag(Package, L"-mmio")) { AccessType = EFIMemoryMappedIo; + if (ShellCommandLineGetFlag(Package, L"-mem") + ||ShellCommandLineGetFlag(Package, L"-io") + ||ShellCommandLineGetFlag(Package, L"-pci") + ||ShellCommandLineGetFlag(Package, L"-pcie") + ){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } } else if (ShellCommandLineGetFlag(Package, L"-mem")) { AccessType = EfiMemory; + if (ShellCommandLineGetFlag(Package, L"-io") + ||ShellCommandLineGetFlag(Package, L"-pci") + ||ShellCommandLineGetFlag(Package, L"-pcie") + ){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } } else if (ShellCommandLineGetFlag(Package, L"-io")) { AccessType = EfiIo; + if (ShellCommandLineGetFlag(Package, L"-pci") + ||ShellCommandLineGetFlag(Package, L"-pcie") + ){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } } else if (ShellCommandLineGetFlag(Package, L"-pci")) { AccessType = EfiPciConfig; + if (ShellCommandLineGetFlag(Package, L"-pcie") + ){ + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } } else if (ShellCommandLineGetFlag(Package, L"-pcie")) { AccessType = EfiPciEConfig; } @@ -185,7 +323,7 @@ ShellCommandRunMm ( Temp = ShellCommandLineGetValue(Package, L"-w"); if (Temp != NULL) { - ItemValue = StrDecimalToUintn (Temp); + ItemValue = ShellStrToUintn (Temp); switch (ItemValue) { case 1: @@ -209,20 +347,26 @@ ShellCommandRunMm ( break; default: - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"-w"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, L"-w"); ShellStatus = SHELL_INVALID_PARAMETER; goto Done; } } Temp = ShellCommandLineGetRawValue(Package, 1); - if (Temp != NULL) { - Address = StrHexToUint64(Temp); + if (!ShellIsHexOrDecimalNumber(Temp, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp, (UINT64*)&Address, TRUE, FALSE))) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; } Temp = ShellCommandLineGetRawValue(Package, 2); if (Temp != NULL) { - Value = StrHexToUint64(Temp); + if (!ShellIsHexOrDecimalNumber(Temp, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp, &Value, TRUE, FALSE))) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } switch (Size) { case 1: if (Value > 0xFF) { @@ -304,7 +448,6 @@ ShellCommandRunMm ( } } if (IoDev == NULL) { - // TODO add token ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_SEGMENT_NOT_FOUND), gShellDebug1HiiHandle, SegmentNumber); ShellStatus = SHELL_INVALID_PARAMETER; goto Done; @@ -357,10 +500,10 @@ ShellCommandRunMm ( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCI), gShellDebug1HiiHandle); IoDev->Pci.Read (IoDev, Width, Address, 1, &Buffer); } else if (AccessType == EfiPciEConfig) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCIE), gShellDebug1HiiHandle); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCIE), gShellDebug1HiiHandle); IoDev->Pci.Read (IoDev, Width, PciEAddress, 1, &Buffer); } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MEM), gShellDebug1HiiHandle); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MEM), gShellDebug1HiiHandle); ReadMem (Width, Address, 1, &Buffer); } @@ -387,68 +530,59 @@ ShellCommandRunMm ( do { if (AccessType == EfiIo && Address + Size > 0x10000) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS_RANGE2), gShellDebug1HiiHandle); - // PrintToken (STRING_TOKEN (STR_IOMOD_IO_ADDRESS_2), HiiHandle, L"mm"); break; } Buffer = 0; if (AccessType == EFIMemoryMappedIo) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MMIO), gShellDebug1HiiHandle); - // PrintToken (STRING_TOKEN (STR_IOMOD_HMMIO), HiiHandle); IoDev->Mem.Read (IoDev, Width, Address, 1, &Buffer); } else if (AccessType == EfiIo) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_IO), gShellDebug1HiiHandle); - // PrintToken (STRING_TOKEN (STR_IOMOD_HIO), HiiHandle); IoDev->Io.Read (IoDev, Width, Address, 1, &Buffer); } else if (AccessType == EfiPciConfig) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCI), gShellDebug1HiiHandle); - // PrintToken (STRING_TOKEN (STR_IOMOD_HPCI), HiiHandle); IoDev->Pci.Read (IoDev, Width, Address, 1, &Buffer); } else if (AccessType == EfiPciEConfig) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCIE), gShellDebug1HiiHandle); - // PrintToken (STRING_TOKEN (STR_IOMOD_HPCIE), HiiHandle); IoDev->Pci.Read (IoDev, Width, PciEAddress, 1, &Buffer); } else { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MEM), gShellDebug1HiiHandle); - // PrintToken (STRING_TOKEN (STR_IOMOD_HMEM), HiiHandle); ReadMem (Width, Address, 1, &Buffer); } ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS), gShellDebug1HiiHandle, Address); - // PrintToken (STRING_TOKEN (STR_IOMOD_ADDRESS), HiiHandle, Address); if (Size == 1) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF2), gShellDebug1HiiHandle, Buffer); - // PrintToken (STRING_TOKEN (STR_IOMOD_BUFFER_2), HiiHandle, Buffer); } else if (Size == 2) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF4), gShellDebug1HiiHandle, Buffer); - // PrintToken (STRING_TOKEN (STR_IOMOD_BUFFER_4), HiiHandle, Buffer); } else if (Size == 4) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF8), gShellDebug1HiiHandle, Buffer); - // PrintToken (STRING_TOKEN (STR_IOMOD_BUFFER_8), HiiHandle, Buffer); } else if (Size == 8) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF16), gShellDebug1HiiHandle, Buffer); - // PrintToken (STRING_TOKEN (STR_IOMOD_BUFFER_16), HiiHandle, Buffer); } + ShellPrintEx(-1, -1, L" > "); // // wait user input to modify // if (InputStr != NULL) { FreePool(InputStr); + InputStr = NULL; } ShellPromptForResponse(ShellPromptResponseTypeFreeform, NULL, (VOID**)&InputStr); // // skip space characters // - for (Index = 0; InputStr[Index] == ' '; Index++); + for (Index = 0; InputStr != NULL && InputStr[Index] == ' '; Index++); // // parse input string // - if (InputStr[Index] == '.' || InputStr[Index] == 'q' || InputStr[Index] == 'Q') { + if (InputStr != NULL && (InputStr[Index] == '.' || InputStr[Index] == 'q' || InputStr[Index] == 'Q')) { Complete = TRUE; - } else if (InputStr[Index] == CHAR_NULL) { + } else if (InputStr == NULL || InputStr[Index] == CHAR_NULL) { // // Continue to next address // @@ -466,8 +600,8 @@ ShellCommandRunMm ( } } else { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ERROR), gShellDebug1HiiHandle); - // PrintToken (STRING_TOKEN (STR_IOMOD_ERROR), HiiHandle); continue; + // PrintToken (STRING_TOKEN (STR_IOMOD_ERROR), HiiHandle); } Address += Size; @@ -492,111 +626,3 @@ Done: } return ShellStatus; } - - -VOID -EFIAPI -ReadMem ( - IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Size, - IN VOID *Buffer - ) -{ - do { - if (Width == EfiPciWidthUint8) { - *(UINT8 *) Buffer = *(UINT8 *) (UINTN) Address; - Address -= 1; - } else if (Width == EfiPciWidthUint16) { - *(UINT16 *) Buffer = *(UINT16 *) (UINTN) Address; - Address -= 2; - } else if (Width == EfiPciWidthUint32) { - *(UINT32 *) Buffer = *(UINT32 *) (UINTN) Address; - Address -= 4; - } else if (Width == EfiPciWidthUint64) { - *(UINT64 *) Buffer = *(UINT64 *) (UINTN) Address; - Address -= 8; - } else { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_READ_ERROR), gShellDebug1HiiHandle); -// PrintToken (STRING_TOKEN (STR_IOMOD_READ_MEM_ERROR), HiiHandle); - break; - } - // - // - // - Size--; - } while (Size > 0); -} - -VOID -EFIAPI -WriteMem ( - IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Size, - IN VOID *Buffer - ) -{ - do { - if (Width == EfiPciWidthUint8) { - *(UINT8 *) (UINTN) Address = *(UINT8 *) Buffer; - Address += 1; - } else if (Width == EfiPciWidthUint16) { - *(UINT16 *) (UINTN) Address = *(UINT16 *) Buffer; - Address += 2; - } else if (Width == EfiPciWidthUint32) { - *(UINT32 *) (UINTN) Address = *(UINT32 *) Buffer; - Address += 4; - } else if (Width == EfiPciWidthUint64) { - *(UINT64 *) (UINTN) Address = *(UINT64 *) Buffer; - Address += 8; - } else { - ASSERT (FALSE); - } - // - // - // - Size--; - } while (Size > 0); -} - -BOOLEAN -EFIAPI -GetHex ( - IN UINT16 *str, - OUT UINT64 *data - ) -{ - UINTN u; - CHAR16 c; - BOOLEAN Find; - - Find = FALSE; - // - // convert hex digits - // - u = 0; - c = *(str++); - while (c != CHAR_NULL) { - if (c >= 'a' && c <= 'f') { - c -= 'a' - 'A'; - } - - if (c == ' ') { - break; - } - - if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) { - u = u << 4 | c - (c >= 'A' ? 'A' - 10 : '0'); - - Find = TRUE; - } else { - return FALSE; - } - - c = *(str++); - } - - *data = u; - return Find; -} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c index 53ba0b6cd4..d2b67d5760 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mode.c @@ -1,7 +1,7 @@ /** @file Main file for Mode shell Debug1 function. - Copyright (c) 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
This program and the acModeanying materials are licensed and made available under the terms and conditions of the BSD License which acModeanies this distribution. The full text of the license may be found at @@ -14,6 +14,12 @@ #include "UefiShellDebug1CommandsLib.h" +/** + Function for 'mode' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ SHELL_STATUS EFIAPI ShellCommandRunMode ( diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c index 56d5f7fd6f..d3a33e207c 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c @@ -1,7 +1,7 @@ /** @file Main file for Pci shell Debug1 function. - Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -1938,14 +1938,29 @@ ShellCommandRunPci ( } } else { + if (ShellCommandLineGetCount(Package) == 2) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + if (ShellCommandLineGetCount(Package) > 4) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + if (ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetValue(Package, L"-s") == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"-s"); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } // // Get all instances of PciRootBridgeIo. Allocate space for 1 EFI_HANDLE and // call LibLocateHandle(), if EFI_BUFFER_TOO_SMALL is returned, allocate enough // space for handles and call it again. // HandleBufSize = sizeof (EFI_HANDLE); - HandleBuf = (EFI_HANDLE *) AllocatePool (HandleBufSize); + HandleBuf = (EFI_HANDLE *) AllocateZeroPool (HandleBufSize); if (HandleBuf == NULL) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle); ShellStatus = SHELL_OUT_OF_RESOURCES; @@ -1987,7 +2002,7 @@ ShellCommandRunPci ( // // Argument Count == 1(no other argument): enumerate all pci functions // - if (ShellCommandLineGetCount(Package) == 0) { + if (ShellCommandLineGetCount(Package) == 1) { gST->ConOut->QueryMode ( gST->ConOut, gST->ConOut->Mode->Mode, @@ -2134,20 +2149,6 @@ ShellCommandRunPci ( goto Done; } - if (ShellCommandLineGetCount(Package) == 1) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); - ShellStatus = SHELL_INVALID_PARAMETER; - goto Done; - } - // - // Arg count >= 3, dump binary of specified function, interpret if necessary - // - if (ShellCommandLineGetCount(Package) > 3) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); - ShellStatus = SHELL_INVALID_PARAMETER; - goto Done; - } - ExplainData = FALSE; Segment = 0; Bus = 0; @@ -2159,7 +2160,7 @@ ShellCommandRunPci ( Temp = ShellCommandLineGetValue(Package, L"-s"); if (Temp != NULL) { - Segment = (UINT16) StrHexToUintn (Temp); + Segment = (UINT16) ShellStrToUintn (Temp); } // @@ -2168,7 +2169,7 @@ ShellCommandRunPci ( // Temp = ShellCommandLineGetRawValue(Package, 1); if (Temp != NULL) { - Bus = (UINT16)StrHexToUintn(Temp); + Bus = (UINT16)ShellStrToUintn(Temp); if (Bus > MAX_BUS_NUMBER) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); ShellStatus = SHELL_INVALID_PARAMETER; @@ -2177,7 +2178,7 @@ ShellCommandRunPci ( } Temp = ShellCommandLineGetRawValue(Package, 2); if (Temp != NULL) { - Device = (UINT16) StrHexToUintn(Temp); + Device = (UINT16) ShellStrToUintn(Temp); if (Device > MAX_DEVICE_NUMBER){ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); ShellStatus = SHELL_INVALID_PARAMETER; @@ -2187,7 +2188,7 @@ ShellCommandRunPci ( Temp = ShellCommandLineGetRawValue(Package, 3); if (Temp != NULL) { - Func = (UINT16) StrHexToUintn(Temp); + Func = (UINT16) ShellStrToUintn(Temp); if (Func > MAX_FUNCTION_NUMBER){ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp); ShellStatus = SHELL_INVALID_PARAMETER; @@ -2469,21 +2470,22 @@ Returns: // if a bus typed one is found and its bus range covers bus, this handle // is the handle we are looking for. // - if ((*Descriptors)->Desc == ACPI_END_TAG_DESCRIPTOR) { - *IsEnd = TRUE; - } while ((*Descriptors)->Desc != ACPI_END_TAG_DESCRIPTOR) { if ((*Descriptors)->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) { *MinBus = (UINT16) (*Descriptors)->AddrRangeMin; *MaxBus = (UINT16) (*Descriptors)->AddrRangeMax; (*Descriptors)++; - break; + return (EFI_SUCCESS); } (*Descriptors)++; } + if ((*Descriptors)->Desc == ACPI_END_TAG_DESCRIPTOR) { + *IsEnd = TRUE; + } + return EFI_SUCCESS; } @@ -4496,7 +4498,7 @@ PciExplainPciExpress ( ExtendRegSize = 0x1000 - 0x100; - ExRegBuffer = (UINT8 *) AllocatePool (ExtendRegSize); + ExRegBuffer = (UINT8 *) AllocateZeroPool (ExtendRegSize); // // PciRootBridgeIo protocol should support pci express extend space IO diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c index 52612283a2..e464d57fe4 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SerMode.c @@ -1,7 +1,7 @@ /** @file Main file for SerMode shell Debug1 function. - Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -16,9 +16,20 @@ #include #include +/** + Display information about a serial device by it's handle. + + If HandleValid is FALSE, do all devices. + + @param[in] HandleIdx The handle index for the device. + @param[in] HandleValid TRUE if HandleIdx is valid. + + @retval SHELL_INVALID_PARAMETER A parameter was invalid. + @retval SHELL_SUCCESS The operation was successful. +**/ SHELL_STATUS EFIAPI -iDisplaySettings ( +DisplaySettings ( IN UINTN HandleIdx, IN BOOLEAN HandleValid ) @@ -147,6 +158,12 @@ iDisplaySettings ( return ShellStatus; } +/** + Function for 'sermode' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ SHELL_STATUS EFIAPI ShellCommandRunSerMode ( @@ -169,6 +186,7 @@ ShellCommandRunSerMode ( LIST_ENTRY *Package; CHAR16 *ProblemParam; CONST CHAR16 *Temp; + UINT64 Intermediate; ShellStatus = SHELL_SUCCESS; HandleIdx = 0; @@ -188,28 +206,29 @@ ShellCommandRunSerMode ( ASSERT(FALSE); } } else { - if (ShellCommandLineGetCount(Package) < 5 && ShellCommandLineGetCount(Package) > 1) { + if (ShellCommandLineGetCount(Package) < 6 && ShellCommandLineGetCount(Package) > 2) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; - } else if (ShellCommandLineGetCount(Package) > 5) { + } else if (ShellCommandLineGetCount(Package) > 6) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; } else { Temp = ShellCommandLineGetRawValue(Package, 1); if (Temp != NULL) { - HandleIdx = StrHexToUintn(Temp); + Status = ShellConvertStringToUint64(Temp, &Intermediate, TRUE, FALSE); + HandleIdx = (UINTN)Intermediate; Temp = ShellCommandLineGetRawValue(Package, 2); if (Temp == NULL) { - ShellStatus = iDisplaySettings (HandleIdx, TRUE); + ShellStatus = DisplaySettings (HandleIdx, TRUE); goto Done; } } else { - ShellStatus = iDisplaySettings (0, FALSE); + ShellStatus = DisplaySettings (0, FALSE); goto Done; } Temp = ShellCommandLineGetRawValue(Package, 2); if (Temp != NULL) { - BaudRate = StrHexToUintn(Temp); + BaudRate = ShellStrToUintn(Temp); } else { ASSERT(FALSE); BaudRate = 0; @@ -252,7 +271,7 @@ ShellCommandRunSerMode ( } Temp = ShellCommandLineGetRawValue(Package, 4); if (Temp != NULL) { - DataBits = StrHexToUintn(Temp); + DataBits = ShellStrToUintn(Temp); } else { // // make sure this is some number not in the list below. @@ -270,7 +289,7 @@ ShellCommandRunSerMode ( goto Done; } Temp = ShellCommandLineGetRawValue(Package, 5); - Value = StrHexToUintn(Temp); + Value = ShellStrToUintn(Temp); switch (Value) { case 0: StopBits = DefaultStopBits; @@ -328,7 +347,7 @@ ShellCommandRunSerMode ( } } - if (Index == NoHandles) { + if (ShellStatus == SHELL_SUCCESS && Index == NoHandles) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SERMODE_BAD_HANDLE), gShellDebug1HiiHandle, HandleIdx); ShellStatus = SHELL_INVALID_PARAMETER; } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetSize.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetSize.c index 30a382fb04..24200320fc 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetSize.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetSize.c @@ -1,7 +1,7 @@ /** @file Main file for SetSize shell Debug1 function. - Copyright (c) 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -14,6 +14,12 @@ #include "UefiShellDebug1CommandsLib.h" +/** + Function for 'setsize' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ SHELL_STATUS EFIAPI ShellCommandRunSetSize ( @@ -55,20 +61,31 @@ ShellCommandRunSetSize ( ASSERT(FALSE); } } else { - Temp1 = ShellCommandLineGetRawValue(Package, 1); - if (Temp1 == NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SIZE_NOT_SPEC), gShellDebug1HiiHandle); + if (ShellCommandLineGetCount(Package) < 3) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; NewSize = 0; } else { - NewSize = ShellStrToUintn(Temp1); + Temp1 = ShellCommandLineGetRawValue(Package, 1); + if (!ShellIsHexOrDecimalNumber(Temp1, FALSE, FALSE)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SIZE_NOT_SPEC), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; + NewSize = 0; + } else { + NewSize = ShellStrToUintn(Temp1); + } } for (LoopVar = 2 ; LoopVar < ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS ; LoopVar++) { - Status = ShellOpenFileByName(ShellCommandLineGetRawValue(Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0); + Status = ShellOpenFileByName(ShellCommandLineGetRawValue(Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0); + if (EFI_ERROR(Status)) { + Status = ShellOpenFileByName(ShellCommandLineGetRawValue(Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0); + } if (EFI_ERROR(Status) && LoopVar == 2) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; } else if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, LoopVar), Status); + ShellStatus = SHELL_INVALID_PARAMETER; break; } else { Status = FileHandleSetSize(FileHandle, NewSize); @@ -78,6 +95,8 @@ ShellCommandRunSetSize ( } else if (EFI_ERROR(Status)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_SIZE_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, LoopVar), Status); ShellStatus = SHELL_INVALID_PARAMETER; + } else { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_SIZE_DONE), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, LoopVar)); } ShellCloseFile(&FileHandle); } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c index f8c6dd2e30..324db922e6 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c @@ -1,7 +1,7 @@ /** @file Main file for SetVar shell Debug1 function. - Copyright (c) 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -22,6 +22,12 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = { {NULL, TypeMax} }; +/** + Function for 'setvar' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ SHELL_STATUS EFIAPI ShellCommandRunSetVar ( @@ -38,6 +44,7 @@ ShellCommandRunSetVar ( EFI_GUID Guid; CONST CHAR16 *StringGuid; UINT32 Attributes; + UINT32 Attributes2; VOID *Buffer; UINTN Size; UINTN LoopVar; @@ -88,7 +95,8 @@ ShellCommandRunSetVar ( StringGuid = ShellCommandLineGetValue(Package, L"-guid"); Status = ConvertStringToGuid(StringGuid, &Guid); if (EFI_ERROR(Status)) { - ShellStatus = SHELL_NOT_FOUND; + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, StringGuid); + ShellStatus = SHELL_INVALID_PARAMETER; } } if (Data == NULL) { @@ -97,7 +105,7 @@ ShellCommandRunSetVar ( // Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer); if (Status == EFI_BUFFER_TOO_SMALL) { - Buffer = AllocatePool(Size); + Buffer = AllocateZeroPool(Size); Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer); } if (!EFI_ERROR(Status)&& Buffer != NULL) { @@ -138,22 +146,36 @@ ShellCommandRunSetVar ( Attributes |= EFI_VARIABLE_NON_VOLATILE; } if (ShellIsHexOrDecimalNumber(Data, TRUE, FALSE)) { - // - // arbitrary buffer - // - Buffer = AllocateZeroPool((StrLen(Data) / 2)); - for (LoopVar = 0 ; LoopVar < (StrLen(Data) / 2) ; LoopVar++) { - ((UINT8*)Buffer)[LoopVar] = (UINT8)(HexCharToUintn(Data[LoopVar*2]) * 16); - ((UINT8*)Buffer)[LoopVar] = (UINT8)(((UINT8*)Buffer)[LoopVar] + HexCharToUintn(Data[LoopVar*2+1])); - } - Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, StrLen(Data) / 2, Buffer); - if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, &Guid, VariableName, Status); - ShellStatus = SHELL_ACCESS_DENIED; + if (StrLen(Data) % 2 != 0) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, Data); + ShellStatus = SHELL_INVALID_PARAMETER; } else { - ASSERT(ShellStatus == SHELL_SUCCESS); + // + // arbitrary buffer + // + Buffer = AllocateZeroPool((StrLen(Data) / 2)); + for (LoopVar = 0 ; LoopVar < (StrLen(Data) / 2) ; LoopVar++) { + ((UINT8*)Buffer)[LoopVar] = (UINT8)(HexCharToUintn(Data[LoopVar*2]) * 16); + ((UINT8*)Buffer)[LoopVar] = (UINT8)(((UINT8*)Buffer)[LoopVar] + HexCharToUintn(Data[LoopVar*2+1])); + } + Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, StrLen(Data) / 2, Buffer); + if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, &Guid, VariableName, Status); + ShellStatus = SHELL_ACCESS_DENIED; + } else { + ASSERT(ShellStatus == SHELL_SUCCESS); + } } } else if (StrnCmp(Data, L"\"", 1) == 0) { + Size = 0; + Attributes2 = 0; + Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes2, &Size, Buffer); + if (Status == EFI_BUFFER_TOO_SMALL) { + Buffer = AllocateZeroPool(Size); + Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes2, &Size, Buffer); + FreePool(Buffer); + Attributes = Attributes2; + } // // ascii text // @@ -162,6 +184,7 @@ ShellCommandRunSetVar ( AsciiSPrint(Buffer, StrSize(Data) / 2, "%s", Data); ((CHAR8*)Buffer)[AsciiStrLen(Buffer)-1] = CHAR_NULL; + Status = gRT->SetVariable((CHAR16*)VariableName, &Guid, Attributes, AsciiStrSize(Buffer)-sizeof(CHAR8), Buffer); if (EFI_ERROR(Status)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_SET), gShellDebug1HiiHandle, &Guid, VariableName, Status); diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c index b9ff013d60..a45a721df3 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c @@ -1,7 +1,7 @@ /** @file Tools of clarify the content of the smbios table. - Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -52,7 +52,7 @@ ShellCommandRunSmbiosView ( Package = NULL; ShellStatus = SHELL_SUCCESS; - Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE); + Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); if (EFI_ERROR(Status)) { if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); @@ -65,11 +65,21 @@ ShellCommandRunSmbiosView ( if (ShellCommandLineGetCount(Package) > 1) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); ShellStatus = SHELL_INVALID_PARAMETER; + } else if ( + (ShellCommandLineGetFlag(Package, L"-t") && ShellCommandLineGetFlag(Package, L"-h")) || + (ShellCommandLineGetFlag(Package, L"-t") && ShellCommandLineGetFlag(Package, L"-s")) || + (ShellCommandLineGetFlag(Package, L"-t") && ShellCommandLineGetFlag(Package, L"-a")) || + (ShellCommandLineGetFlag(Package, L"-h") && ShellCommandLineGetFlag(Package, L"-s")) || + (ShellCommandLineGetFlag(Package, L"-h") && ShellCommandLineGetFlag(Package, L"-a")) || + (ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetFlag(Package, L"-a")) + ) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellStatus = SHELL_INVALID_PARAMETER; } else { // // Init Lib - // + Status = LibSmbiosInit (); if (EFI_ERROR (Status)) { ShellStatus = SHELL_NOT_FOUND; @@ -370,7 +380,7 @@ InitSmbiosTableStatistics ( mStatisticsTable = NULL; } - mStatisticsTable = (STRUCTURE_STATISTICS *) AllocatePool (SMBiosTable->NumberOfSmbiosStructures * sizeof (STRUCTURE_STATISTICS)); + mStatisticsTable = (STRUCTURE_STATISTICS *) AllocateZeroPool (SMBiosTable->NumberOfSmbiosStructures * sizeof (STRUCTURE_STATISTICS)); if (mStatisticsTable == NULL) { ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OUT_OF_MEM), gShellDebug1HiiHandle); diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosViewStrings.uni index b9d2aea3ce8cdd3772fc76dd5450b9c1118843b0..c63001a90e2980fffd55c71f6abfeb692af30e20 100644 GIT binary patch delta 75 zcmcb0gZ0)8)(Jk0h8ulXKawtG$YV%kNMgugNM%r9C}GG4k~u&!ks)RB*GI~XdXp!b YxlgWp+`?PHPy`f*sLb8W|HQik0K(iDsQ>@~ delta 67 zcmcb0gZ0)8)(Jk01{-}>KbkD|SV3NaA&nuCA(J78A(bJ8L4l!!As}ah@WiVF00wauiU0rr diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c index 094e429fed..226dd90397 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c @@ -1,7 +1,7 @@ /** @file Main file for NULL named library for debug1 profile shell command functions. - Copyright (c) 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -21,6 +21,12 @@ CONST EFI_GUID gShellDebug1HiiGuid = \ 0x25f200aa, 0xd3cb, 0x470a, { 0xbf, 0x51, 0xe7, 0xd1, 0x62, 0xd2, 0x2e, 0x6f } \ }; +/** + Gets the debug file name. This will be used if HII is not working. + + @retval NULL No file is available. + @return The NULL-terminated filename to get help from. +**/ CONST CHAR16* EFIAPI ShellCommandGetManFileNameDebug1 ( @@ -64,21 +70,23 @@ UefiShellDebug1CommandsLibConstructor ( // // install our shell command handlers that are always installed // - ShellCommandRegisterCommandName(L"SetSize", ShellCommandRunSetSize , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETSIZE) ); + ShellCommandRegisterCommandName(L"setsize", ShellCommandRunSetSize , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETSIZE) ); ShellCommandRegisterCommandName(L"comp", ShellCommandRunComp , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_COMP) ); ShellCommandRegisterCommandName(L"mode", ShellCommandRunMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MODE) ); ShellCommandRegisterCommandName(L"memmap", ShellCommandRunMemMap , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MEMMAP) ); ShellCommandRegisterCommandName(L"eficompress", ShellCommandRunEfiCompress , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EFICOMPRESS) ); ShellCommandRegisterCommandName(L"efidecompress", ShellCommandRunEfiDecompress , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EFIDCOMPRESS) ); ShellCommandRegisterCommandName(L"dmem", ShellCommandRunDmem , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DMEM) ); - ShellCommandRegisterCommandName(L"LoadPciRom", ShellCommandRunLoadPciRom , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_LOAD_PCI_ROM) ); + ShellCommandRegisterCommandName(L"loadpcirom", ShellCommandRunLoadPciRom , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_LOAD_PCI_ROM) ); ShellCommandRegisterCommandName(L"mm", ShellCommandRunMm , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_MM) ); - ShellCommandRegisterCommandName(L"SetVar", ShellCommandRunSetVar , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETVAR) ); - ShellCommandRegisterCommandName(L"SerMode", ShellCommandRunSerMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SERMODE) ); - ShellCommandRegisterCommandName(L"Pci", ShellCommandRunPci , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_PCI) ); + ShellCommandRegisterCommandName(L"setvar", ShellCommandRunSetVar , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SETVAR) ); + ShellCommandRegisterCommandName(L"sermode", ShellCommandRunSerMode , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SERMODE) ); + ShellCommandRegisterCommandName(L"pci", ShellCommandRunPci , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_PCI) ); ShellCommandRegisterCommandName(L"smbiosview", ShellCommandRunSmbiosView , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_SMBIOSVIEW) ); ShellCommandRegisterCommandName(L"dmpstore", ShellCommandRunDmpStore , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DMPSTORE) ); ShellCommandRegisterCommandName(L"dblk", ShellCommandRunDblk , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_DBLK) ); + ShellCommandRegisterCommandName(L"edit", ShellCommandRunEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EDIT) ); + ShellCommandRegisterCommandName(L"hexedit", ShellCommandRunHexEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_HEXEDIT) ); // // check install profile bit of the profiles mask is set @@ -87,10 +95,8 @@ UefiShellDebug1CommandsLibConstructor ( ShellCommandRegisterCommandName(L"bcfg", ShellCommandRunBcfg , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_BCFG) ); } -/* - ShellCommandRegisterCommandName(L"hexedit", ShellCommandRunHexEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_HEXEDIT ); - ShellCommandRegisterCommandName(L"edit", ShellCommandRunEdit , ShellCommandGetManFileNameDebug1, 0, L"Debug1", TRUE, gShellDebug1HiiHandle, STRING_TOKEN(STR_GET_HELP_EDIT) ); -*/ + + ShellCommandRegisterAlias(L"dmem", L"mem"); @@ -99,6 +105,9 @@ UefiShellDebug1CommandsLibConstructor ( /** Destructor for the library. free any resources. + + @param ImageHandle The image handle of the process. + @param SystemTable The EFI System Table pointer. **/ EFI_STATUS EFIAPI @@ -132,6 +141,14 @@ STATIC CONST CHAR8 Hex[] = { 'F' }; +/** + Dump some hexadecimal data to the screen. + + @param[in] Indent How many spaces to indent the output. + @param[in] Offset The offset of the printing. + @param[in] DataSize The size in bytes of UserData. + @param[in] UserData The data to print out. +**/ VOID EFIAPI DumpHex ( @@ -147,12 +164,10 @@ DumpHex ( CHAR8 Str[20]; - UINT8 c; + UINT8 TempByte; UINTN Size; UINTN Index; - ASSERT (UserData != NULL); - Data = UserData; while (DataSize != 0) { Size = 16; @@ -161,11 +176,11 @@ DumpHex ( } for (Index = 0; Index < Size; Index += 1) { - c = Data[Index]; - Val[Index * 3 + 0] = Hex[c >> 4]; - Val[Index * 3 + 1] = Hex[c & 0xF]; + TempByte = Data[Index]; + Val[Index * 3 + 0] = Hex[TempByte >> 4]; + Val[Index * 3 + 1] = Hex[TempByte & 0xF]; Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' '); - Str[Index] = (CHAR8) ((c < ' ' || c > 'z') ? '.' : c); + Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte); } Val[Index * 3] = 0; @@ -213,7 +228,7 @@ CharToUpper ( EFI System Table based on the provided GUID. @param[in] TableGuid A pointer to the table's GUID type. - @param[out] Table On exit, a pointer to a system configuration table. + @param[in,out] Table On exit, a pointer to a system configuration table. @retval EFI_SUCCESS A configuration table matching TableGuid was found. @retval EFI_NOT_FOUND A configuration table matching TableGuid was not found. @@ -229,7 +244,7 @@ GetSystemConfigurationTable ( ASSERT (Table != NULL); for (Index = 0; Index < gST->NumberOfTableEntries; Index++) { - if (CompareGuid (TableGuid, &(gST->ConfigurationTable[Index].VendorGuid)) == 0) { + if (CompareGuid (TableGuid, &(gST->ConfigurationTable[Index].VendorGuid))) { *Table = gST->ConfigurationTable[Index].VendorTable; return EFI_SUCCESS; } @@ -264,6 +279,15 @@ HexCharToUintn ( return (UINTN) (10 + CharToUpper (Char) - L'A'); } +/** + Convert a string representation of a guid to a Guid value. + + @param[in] StringGuid The pointer to the string of a guid. + @param[in,out] Guid The pointer to the GUID structure to populate. + + @retval EFI_INVALID_PARAMETER A parameter was invalid. + @retval EFI_SUCCESS The conversion was successful. +**/ EFI_STATUS EFIAPI ConvertStringToGuid ( @@ -271,39 +295,399 @@ ConvertStringToGuid ( IN OUT EFI_GUID *Guid ) { - if (StrLen(StringGuid) != 35) { + CHAR16 *TempCopy; + CHAR16 *TempSpot; + CHAR16 *Walker; + UINT64 TempVal; + EFI_STATUS Status; + + if (StringGuid == NULL) { + return (EFI_INVALID_PARAMETER); + } else if (StrLen(StringGuid) != 36) { return (EFI_INVALID_PARAMETER); + } + TempCopy = NULL; + TempCopy = StrnCatGrow(&TempCopy, NULL, StringGuid, 0); + Walker = TempCopy; + TempSpot = StrStr(Walker, L"-"); + *TempSpot = CHAR_NULL; + Status = ShellConvertStringToUint64(Walker, &TempVal, TRUE, FALSE); + if (EFI_ERROR(Status)) { + FreePool(TempCopy); + return (Status); + } + Guid->Data1 = (UINT32)TempVal; + Walker += 9; + TempSpot = StrStr(Walker, L"-"); + *TempSpot = CHAR_NULL; + Status = ShellConvertStringToUint64(Walker, &TempVal, TRUE, FALSE); + if (EFI_ERROR(Status)) { + FreePool(TempCopy); + return (Status); + } + Guid->Data2 = (UINT16)TempVal; + Walker += 5; + TempSpot = StrStr(Walker, L"-"); + *TempSpot = CHAR_NULL; + Status = ShellConvertStringToUint64(Walker, &TempVal, TRUE, FALSE); + if (EFI_ERROR(Status)) { + FreePool(TempCopy); + return (Status); + } + Guid->Data3 = (UINT16)TempVal; + Walker += 5; + Guid->Data4[0] = (UINT8)(HexCharToUintn(Walker[0]) * 16); + Guid->Data4[0] = (UINT8)(Guid->Data4[0]+ (UINT8)HexCharToUintn(Walker[1])); + Walker += 2; + Guid->Data4[1] = (UINT8)(HexCharToUintn(Walker[0]) * 16); + Guid->Data4[1] = (UINT8)(Guid->Data4[1] + (UINT8)HexCharToUintn(Walker[1])); + Walker += 3; + Guid->Data4[2] = (UINT8)(HexCharToUintn(Walker[0]) * 16); + Guid->Data4[2] = (UINT8)(Guid->Data4[2] + (UINT8)HexCharToUintn(Walker[1])); + Walker += 2; + Guid->Data4[3] = (UINT8)(HexCharToUintn(Walker[0]) * 16); + Guid->Data4[3] = (UINT8)(Guid->Data4[3] + (UINT8)HexCharToUintn(Walker[1])); + Walker += 2; + Guid->Data4[4] = (UINT8)(HexCharToUintn(Walker[0]) * 16); + Guid->Data4[4] = (UINT8)(Guid->Data4[4] + (UINT8)HexCharToUintn(Walker[1])); + Walker += 2; + Guid->Data4[5] = (UINT8)(HexCharToUintn(Walker[0]) * 16); + Guid->Data4[5] = (UINT8)(Guid->Data4[5] + (UINT8)HexCharToUintn(Walker[1])); + Walker += 2; + Guid->Data4[6] = (UINT8)(HexCharToUintn(Walker[0]) * 16); + Guid->Data4[6] = (UINT8)(Guid->Data4[6] + (UINT8)HexCharToUintn(Walker[1])); + Walker += 2; + Guid->Data4[7] = (UINT8)(HexCharToUintn(Walker[0]) * 16); + Guid->Data4[7] = (UINT8)(Guid->Data4[7] + (UINT8)HexCharToUintn(Walker[1])); + FreePool(TempCopy); + return (EFI_SUCCESS); +} + +CHAR16 TempBufferCatSPrint[1000]; +/** + Appends a formatted Unicode string to a Null-terminated Unicode string + + This function appends a formatted Unicode string to the Null-terminated + Unicode string specified by String. String is optional and may be NULL. + Storage for the formatted Unicode string returned is allocated using + AllocateZeroPool(). The pointer to the appended string is returned. The caller + is responsible for freeing the returned string. + + If String is not NULL and not aligned on a 16-bit boundary, then ASSERT(). + If Format is NULL, then ASSERT(). + If Format is not aligned on a 16-bit boundary, then ASSERT(). + + @param String A null-terminated Unicode string. + @param FormatString A null-terminated Unicode format string. + @param ... The variable argument list whose contents are accessed based + on the format string specified by Format. + + @retval NULL There was not enough available memory. + @return Null terminated Unicode string is that is the formatted + string appended to String. + @sa CatVSPrint +**/ +CHAR16* +EFIAPI +CatSPrint ( + IN CONST CHAR16 *String OPTIONAL, + IN CONST CHAR16 *FormatString, + ... + ) +{ + VA_LIST Marker; + UINTN StringLength; + if (String != NULL) { + StrCpy(TempBufferCatSPrint, String); + } else { + *TempBufferCatSPrint = CHAR_NULL; + } + VA_START (Marker, FormatString); + StringLength = StrLen(TempBufferCatSPrint); + + UnicodeVSPrint(TempBufferCatSPrint+StrLen(TempBufferCatSPrint), 1000-StringLength, FormatString, Marker); + return (AllocateCopyPool(StrSize(TempBufferCatSPrint), TempBufferCatSPrint)); +} + +/** + Clear the line at the specified Row. + + @param[in] Row The row number to be cleared ( start from 1 ) + @param[in] LastCol The last printable column. + @param[in] LastRow The last printable row. +**/ +VOID +EFIAPI +EditorClearLine ( + IN UINTN Row, + IN UINTN LastCol, + IN UINTN LastRow + ) +{ + CHAR16 Line[200]; + + if (Row == 0) { + Row = 1; + } + + // + // prepare a blank line + // + SetMem16(Line, LastCol*sizeof(CHAR16), L' '); + + if (Row == LastRow) { + // + // if CHAR_NULL is still at position 80, it will cause first line error + // + Line[LastCol - 1] = CHAR_NULL; } else { - Guid->Data1 = (UINT32)StrHexToUintn(StringGuid); - StringGuid += 9; - Guid->Data2 = (UINT16)StrHexToUintn(StringGuid); - StringGuid += 5; - Guid->Data3 = (UINT16)StrHexToUintn(StringGuid); - StringGuid += 5; - Guid->Data4[0] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); - Guid->Data4[0] = (UINT8)(Guid->Data4[0]+ (UINT8)HexCharToUintn(StringGuid[1])); - StringGuid += 2; - Guid->Data4[1] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); - Guid->Data4[1] = (UINT8)(Guid->Data4[1] + (UINT8)HexCharToUintn(StringGuid[1])); - StringGuid += 2; - Guid->Data4[2] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); - Guid->Data4[2] = (UINT8)(Guid->Data4[2] + (UINT8)HexCharToUintn(StringGuid[1])); - StringGuid += 2; - Guid->Data4[3] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); - Guid->Data4[3] = (UINT8)(Guid->Data4[3] + (UINT8)HexCharToUintn(StringGuid[1])); - StringGuid += 2; - Guid->Data4[4] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); - Guid->Data4[4] = (UINT8)(Guid->Data4[4] + (UINT8)HexCharToUintn(StringGuid[1])); - StringGuid += 2; - Guid->Data4[5] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); - Guid->Data4[5] = (UINT8)(Guid->Data4[5] + (UINT8)HexCharToUintn(StringGuid[1])); - StringGuid += 2; - Guid->Data4[6] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); - Guid->Data4[6] = (UINT8)(Guid->Data4[6] + (UINT8)HexCharToUintn(StringGuid[1])); - StringGuid += 2; - Guid->Data4[7] = (UINT8)(HexCharToUintn(StringGuid[0]) * 16); - Guid->Data4[7] = (UINT8)(Guid->Data4[7] = (UINT8)HexCharToUintn(StringGuid[1])); - return (EFI_SUCCESS); + Line[LastCol] = CHAR_NULL; + } + + // + // print out the blank line + // + ShellPrintEx (0, ((INT32)Row) - 1, Line); +} + +/** + Determine if the character is valid for a filename. + + @param[in] Ch The character to test. + + @retval TRUE The character is valid. + @retval FALSE The character is not valid. +**/ +BOOLEAN +EFIAPI +IsValidFileNameChar ( + IN CONST CHAR16 Ch + ) +{ + // + // See if there are any illegal characters within the name + // + if (Ch < 0x20 || Ch == L'\"' || Ch == L'*' || Ch == L'/' || Ch == L'<' || Ch == L'>' || Ch == L'?' || Ch == L'|' || Ch == L' ') { + return FALSE; + } + + return TRUE; +} + +/** + Check if file name has illegal characters. + + @param Name The filename to check. + + @retval TRUE The filename is ok. + @retval FALSE The filename is not ok. +**/ +BOOLEAN +EFIAPI +IsValidFileName ( + IN CONST CHAR16 *Name + ) +{ + + UINTN Index; + UINTN Len; + + // + // check the length of Name + // + for (Len = 0, Index = StrLen (Name) - 1; Index + 1 != 0; Index--, Len++) { + if (Name[Index] == '\\' || Name[Index] == ':') { + break; + } + } + + if (Len == 0 || Len > 255) { + return FALSE; + } + // + // check whether any char in Name not appears in valid file name char + // + for (Index = 0; Index < StrLen (Name); Index++) { + if (!IsValidFileNameChar (Name[Index])) { + return FALSE; + } } + + return TRUE; +} + +/** + Find a filename that is valid (not taken) with the given extension. + + @param[in] Extension The file extension. + + @retval NULL Something went wrong. + @return the valid filename. +**/ +CHAR16 * +EFIAPI +EditGetDefaultFileName ( + IN CONST CHAR16 *Extension + ) +{ + EFI_STATUS Status; + UINTN Suffix; + BOOLEAN FoundNewFile; + CHAR16 *FileNameTmp; + + Suffix = 0; + FoundNewFile = FALSE; + + do { + FileNameTmp = CatSPrint (NULL, L"NewFile%d.%s", Suffix, Extension); + + // + // after that filename changed to path + // + Status = ShellFileExists (FileNameTmp); + + if (Status == EFI_NOT_FOUND) { + return FileNameTmp; + } + + FreePool (FileNameTmp); + FileNameTmp = NULL; + Suffix++; + } while (Suffix != 0); + + FreePool (FileNameTmp); + return NULL; } +/** + Read a file into an allocated buffer. The buffer is the responsibility + of the caller to free. + + @param[in] FileName The filename of the file to open. + @param[out] Buffer Upon successful return, the pointer to the + address of the allocated buffer. + @param[out] BufferSize If not NULL, then the pointer to the size + of the allocated buffer. + @param[out] ReadOnly Upon successful return TRUE if the file is + read only. FALSE otherwise. + + @retval EFI_NOT_FOUND The filename did not represent a file in the + file system. + @retval EFI_SUCCESS The file was read into the buffer. + @retval EFI_OUT_OF_RESOURCES A memory allocation failed. + @retval EFI_LOAD_ERROR The file read operation failed. + @retval EFI_INVALID_PARAMETER A parameter was invalid. + @retval EFI_INVALID_PARAMETER FileName was NULL. + @retval EFI_INVALID_PARAMETER FileName was a directory. +**/ +EFI_STATUS +EFIAPI +ReadFileIntoBuffer ( + IN CONST CHAR16 *FileName, + OUT VOID **Buffer, + OUT UINTN *BufferSize OPTIONAL, + OUT BOOLEAN *ReadOnly + ) +{ + VOID *InternalBuffer; + UINTN FileSize; + SHELL_FILE_HANDLE FileHandle; + BOOLEAN CreateFile; + EFI_STATUS Status; + EFI_FILE_INFO *Info; + + InternalBuffer = NULL; + FileSize = 0; + FileHandle = NULL; + CreateFile = FALSE; + Status = EFI_SUCCESS; + Info = NULL; + + if (FileName == NULL || Buffer == NULL || ReadOnly == NULL) { + return (EFI_INVALID_PARAMETER); + } + + // + // try to open the file + // + Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ, 0); + + if (!EFI_ERROR(Status)) { + ASSERT(CreateFile == FALSE); + if (FileHandle == NULL) { + return EFI_LOAD_ERROR; + } + + Info = ShellGetFileInfo(FileHandle); + + if (Info->Attribute & EFI_FILE_DIRECTORY) { + FreePool (Info); + return EFI_INVALID_PARAMETER; + } + + if (Info->Attribute & EFI_FILE_READ_ONLY) { + *ReadOnly = TRUE; + } else { + *ReadOnly = FALSE; + } + // + // get file size + // + FileSize = (UINTN) Info->FileSize; + + FreePool (Info); + } else if (Status == EFI_NOT_FOUND) { + // + // file not exists. add create and try again + // + Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0); + if (EFI_ERROR (Status)) { + return Status; + } else { + // + // it worked. now delete it and move on with the name (now validated) + // + Status = ShellDeleteFile (&FileHandle); + if (Status == EFI_WARN_DELETE_FAILURE) { + Status = EFI_ACCESS_DENIED; + } + if (EFI_ERROR (Status)) { + return Status; + } + } + // + // file doesn't exist, so set CreateFile to TRUE and can't be read-only + // + CreateFile = TRUE; + *ReadOnly = FALSE; + } + + // + // the file exists + // + if (!CreateFile) { + // + // allocate buffer to read file + // + InternalBuffer = AllocateZeroPool (FileSize); + if (InternalBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } + // + // read file into InternalBuffer + // + Status = ShellReadFile (FileHandle, &FileSize, InternalBuffer); + ShellCloseFile(&FileHandle); + FileHandle = NULL; + if (EFI_ERROR (Status)) { + SHELL_FREE_NON_NULL (InternalBuffer); + return EFI_LOAD_ERROR; + } + } + *Buffer = InternalBuffer; + if (BufferSize != NULL) { + *BufferSize = FileSize; + } + return (EFI_SUCCESS); + +} diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h index f34889f76d..de754e8bc7 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h @@ -1,7 +1,7 @@ /** @file Main file for NULL named library for Profile1 shell command functions. - Copyright (c) 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -12,12 +12,16 @@ **/ +#if !defined (_UEFI_SHELL_DEBUG1_COMMANDS_LIB_H_) +#define _UEFI_SHELL_DEBUG1_COMMANDS_LIB_H_ + #include #include #include #include #include +#include #include #include @@ -34,6 +38,8 @@ #include #include #include +#include +#include #include #include @@ -77,7 +83,7 @@ DumpHex ( EFI System Table based on the provided GUID. @param[in] TableGuid A pointer to the table's GUID type. - @param[out] Table On exit, a pointer to a system configuration table. + @param[in,out] Table On exit, a pointer to a system configuration table. @retval EFI_SUCCESS A configuration table matching TableGuid was found. @retval EFI_NOT_FOUND A configuration table matching TableGuid was not found. @@ -329,4 +335,135 @@ ShellCommandRunDblk ( IN EFI_SYSTEM_TABLE *SystemTable ); +/** + Function for 'edit' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunEdit ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Function for 'hexedit' command. + + @param[in] ImageHandle Handle to the Image (NULL if Internal). + @param[in] SystemTable Pointer to the System Table (NULL if Internal). +**/ +SHELL_STATUS +EFIAPI +ShellCommandRunHexEdit ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Appends a formatted Unicode string to a Null-terminated Unicode string + + This function appends a formatted Unicode string to the Null-terminated + Unicode string specified by String. String is optional and may be NULL. + Storage for the formatted Unicode string returned is allocated using + AllocateZeroPool(). The pointer to the appended string is returned. The caller + is responsible for freeing the returned string. + + If String is not NULL and not aligned on a 16-bit boundary, then ASSERT(). + If Format is NULL, then ASSERT(). + If Format is not aligned on a 16-bit boundary, then ASSERT(). + + @param String A null-terminated Unicode string. + @param FormatString A null-terminated Unicode format string. + @param ... The variable argument list whose contents are accessed based + on the format string specified by Format. + + @retval NULL There was not enough available memory. + @return Null terminated Unicode string is that is the formatted + string appended to String. + @sa CatVSPrint +**/ +CHAR16* +EFIAPI +CatSPrint ( + IN CONST CHAR16 *String OPTIONAL, + IN CONST CHAR16 *FormatString, + ... + ); + +/** + Clear the line at the specified Row. + + @param[in] Row The row number to be cleared ( start from 1 ) + @param[in] LastCol The last printable column. + @param[in] LastRow The last printable row. +**/ +VOID +EFIAPI +EditorClearLine ( + IN UINTN Row, + IN UINTN LastCol, + IN UINTN LastRow + ); + +/** + Check if file name has illegal characters. + + @param Name The filename to check. + + @retval TRUE The filename is ok. + @retval FALSE The filename is not ok. +**/ +BOOLEAN +EFIAPI +IsValidFileName ( + IN CONST CHAR16 *Name + ); + +/** + Find a filename that is valid (not taken) with the given extension. + + @param[in] Extension The file extension. + + @retval NULL Something went wrong. + @return the valid filename. +**/ +CHAR16 * +EFIAPI +EditGetDefaultFileName ( + IN CONST CHAR16 *Extension + ); + +/** + Read a file into an allocated buffer. The buffer is the responsibility + of the caller to free. + + @param[in] FileName The filename of the file to open. + @param[out] Buffer Upon successful return, the pointer to the + address of the allocated buffer. + @param[out] BufferSize If not NULL, then the pointer to the size + of the allocated buffer. + @param[out] ReadOnly Upon successful return TRUE if the file is + read only. FALSE otherwise. + + @retval EFI_NOT_FOUND The filename did not represent a file in the + file system. Directories cannot be read with + this method. + @retval EFI_SUCCESS The file was read into the buffer. + @retval EFI_OUT_OF_RESOURCES A memory allocation failed. + @retval EFI_LOAD_ERROR The file read operation failed. + @retval EFI_INVALID_PARAMETER A parameter was invalid. + @retval EFI_INVALID_PARAMETER FileName was NULL. + @retval EFI_INVALID_PARAMETER FileName was a directory. +**/ +EFI_STATUS +EFIAPI +ReadFileIntoBuffer ( + IN CONST CHAR16 *FileName, + OUT VOID **Buffer, + OUT UINTN *BufferSize OPTIONAL, + OUT BOOLEAN *ReadOnly + ); +#endif diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf index e04c29b6ff..f83785b071 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf @@ -52,6 +52,48 @@ UefiShellDebug1CommandsLib.h UefiShellDebug1CommandsLib.uni +## Files shared by both editors + EditTitleBar.h + EditTitleBar.c + EditInputBar.h + EditInputBar.c + EditStatusBar.h + EditStatusBar.c + EditMenuBar.h + EditMenuBar.c + +## Files specific to the text editor + ./Edit/Edit.c + ./Edit/TextEditor.h + ./Edit/TextEditorTypes.h + ./Edit/FileBuffer.h + ./Edit/FileBuffer.c + ./Edit/MainTextEditor.h + ./Edit/MainTextEditor.c + ./Edit/Misc.h + ./Edit/Misc.c + ./Edit/TextEditStrings.uni + +## Files specific to the HEX editor + ./HexEdit/BufferImage.h + ./HexEdit/BufferImage.c + ./HexEdit/Clipboard.h + ./HexEdit/Clipboard.c + ./HexEdit/DiskImage.h + ./HexEdit/DiskImage.c + ./HexEdit/FileImage.h + ./HexEdit/FileImage.c + ./HexEdit/HexEdit.c + ./HexEdit/HexEditor.h + ./HexEdit/HexEditorTypes.h + ./HexEdit/HexeditStrings.uni + ./HexEdit/MainHexEditor.h + ./HexEdit/MainHexEditor.c + ./HexEdit/MemImage.h + ./HexEdit/MemImage.c + ./HexEdit/Misc.h + ./HexEdit/Misc.c + [Packages] MdePkg/MdePkg.dec ShellPkg/ShellPkg.dec @@ -71,14 +113,20 @@ PrintLib [Pcd] - gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask # ALWAYS_CONSUMED - gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize # ALWAYS_CONSUMED + gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask # ALWAYS_CONSUMED + gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize # ALWAYS_CONSUMED + gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength # ALWAYS_CONSUMED [Protocols] gEfiPciRootBridgeIoProtocolGuid gEfiBlockIoProtocolGuid + gEfiSimplePointerProtocolGuid [Guids] gEfiGlobalVariableGuid gEfiSmbiosTableGuid + gEfiMpsTableGuid + gEfiSalSystemTableGuid + gEfiAcpi10TableGuid + gEfiAcpi20TableGuid diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni index 925bf849f475431d45a3028bf02c2168d3f4db23..733ff4d1055dc0a0ed59b75ce8075616a89595a4 100644 GIT binary patch literal 150442 zcmeIb+jAVpmF|nzIT7c{FZLUP+OjE!LGdO^^d8R)ZnU_Ew@pB@y*WM{i4^Z)yQ-`#k3V>AAK9k2g;{W#uV#~q)g?~el7FE*aXo&5G)Joh5*-;66j zLqAXB)3a#J*wf0(^z^g%?NNMskszX7x6jj$k9znzK0l2XKH2y*{?qGM2@2ZIkf^Wc z32L_jWWf9Mm@eS-#m1B3xt)!JjlKA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