diff options
Diffstat (limited to 'ShellPkg/Library/UefiShellDebug1CommandsLib')
3 files changed, 185 insertions, 63 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c index e6884a2d59..c2b14d7ee7 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c @@ -48,6 +48,63 @@ typedef struct { } BGFG_OPERATION;
/**
+ This function will populate the device path protocol parameter based on TheHandle.
+
+ @param[in,out] DevPath On a sucessful return the device path to the handle.
+
+ @retval EFI_SUCCESS The device path was sucessfully returned.
+ @retval other A error from gBS->HandleProtocol.
+
+ @sa HandleProtocol
+**/
+EFI_STATUS
+EFIAPI
+GetDevicePathForDriverHandleDebug1 (
+ IN EFI_HANDLE TheHandle,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath
+ )
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
+
+ Status = gBS->OpenProtocol (
+ TheHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID**)&LoadedImage,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol (
+ LoadedImage->DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID**)&ImageDevicePath,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (!EFI_ERROR (Status)) {
+// *DevPath = DuplicateDevicePath (ImageDevicePath);
+// *FilePath = DuplicateDevicePath (LoadedImage->FilePath);
+ *FilePath = AppendDevicePath(ImageDevicePath,LoadedImage->FilePath);
+ gBS->CloseProtocol(
+ LoadedImage->DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ gImageHandle,
+ NULL);
+ }
+ gBS->CloseProtocol(
+ TheHandle,
+ &gEfiLoadedImageProtocolGuid,
+ gImageHandle,
+ NULL);
+ }
+ return (Status);
+}
+
+/**
Function to add a option.
@param[in] Position The position to add Target at.
@@ -81,9 +138,9 @@ BcfgAddDebug1( EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
EFI_DEVICE_PATH_PROTOCOL *FileNode;
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
+// EFI_DEVICE_PATH_PROTOCOL *DevPath;
CHAR16 *Str;
- CONST CHAR16 *StringWalker;
+// CONST CHAR16 *StringWalker;
UINT8 *TempByteBuffer;
UINT8 *TempByteStart;
EFI_SHELL_FILE_INFO *Arg;
@@ -100,7 +157,6 @@ BcfgAddDebug1( UINTN ChildControllerHandleCount;
SHELL_STATUS ShellStatus;
UINT16 *NewOrder;
- UINT64 Intermediate;
if (!UseHandle) {
if (File == NULL || Desc == NULL) {
@@ -125,42 +181,79 @@ BcfgAddDebug1( TargetLocation = 0xFFFF;
if (UseHandle) {
- 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);
+ CurHandle = ConvertHandleIndexToHandle(HandleNumber);
+ if (CurHandle == NULL) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"Handle Number");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- //
- //Make sure that the handle should point to a real controller
- //
- Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
- CurHandle,
- &DriverBindingHandleCount,
- NULL);
-
- Status = PARSE_HANDLE_DATABASE_PARENTS (
- CurHandle,
- &ParentControllerHandleCount,
- NULL);
-
- Status = ParseHandleDatabaseForChildControllers (
- CurHandle,
- &ChildControllerHandleCount,
- NULL);
-
- if (DriverBindingHandleCount > 0
- || ParentControllerHandleCount > 0
- || ChildControllerHandleCount > 0) {
- FilePath = NULL;
+ if (Target == BcfgTargetBootOrder) {
+ //
+ //Make sure that the handle should point to a real controller
+ //
+ Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
+ CurHandle,
+ &DriverBindingHandleCount,
+ NULL);
+
+ Status = PARSE_HANDLE_DATABASE_PARENTS (
+ CurHandle,
+ &ParentControllerHandleCount,
+ NULL);
+
+ Status = ParseHandleDatabaseForChildControllers (
+ CurHandle,
+ &ChildControllerHandleCount,
+ NULL);
+
+ if (DriverBindingHandleCount > 0
+ || ParentControllerHandleCount > 0
+ || ChildControllerHandleCount > 0) {
+ FilePath = NULL;
+ Status = gBS->HandleProtocol (
+ CurHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID**)&FilePath);
+ }
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_HANDLE), gShellDebug1HiiHandle, HandleNumber);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ }
+ } else {
+ //
+ //Make sure that the handle should point to driver, not a controller.
+ //
+ Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
+ CurHandle,
+ &DriverBindingHandleCount,
+ NULL);
+
+ Status = PARSE_HANDLE_DATABASE_PARENTS (
+ CurHandle,
+ &ParentControllerHandleCount,
+ NULL);
+
+ Status = ParseHandleDatabaseForChildControllers (
+ CurHandle,
+ &ChildControllerHandleCount,
+ NULL);
+
Status = gBS->HandleProtocol (
CurHandle,
&gEfiDevicePathProtocolGuid,
(VOID**)&FilePath);
- }
- if (EFI_ERROR (Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_HANDLE), gShellDebug1HiiHandle, Intermediate);
- ShellStatus = SHELL_INVALID_PARAMETER;
+
+ if (DriverBindingHandleCount > 0
+ || ParentControllerHandleCount > 0
+ || ChildControllerHandleCount > 0
+ || !EFI_ERROR(Status) ) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"Handle Number");
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ //
+ // Get the DevicePath from the loaded image information.
+ //
+ Status = GetDevicePathForDriverHandleDebug1(CurHandle, &FilePath);
+ }
}
}
} else {
@@ -199,6 +292,7 @@ BcfgAddDebug1( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE_DP), gShellDebug1HiiHandle, Arg->FullName);
ShellStatus = SHELL_UNSUPPORTED;
} else {
+/*
if (UsePath) {
DevPath = DevicePath;
while (!IsDevicePathEnd(DevPath)) {
@@ -221,9 +315,11 @@ BcfgAddDebug1( FilePath = AppendDevicePath(DevicePath, FileNode);
FreePool(FileNode);
} else {
+*/
FilePath = DuplicateDevicePath(DevicePath);
+/*
}
-
+*/
FreePool(DevicePath);
}
}
@@ -364,16 +460,15 @@ BcfgRemoveDebug1( IN CONST BCFG_OPERATION_TARGET Target,
IN CONST UINT16 *CurrentOrder,
IN CONST UINTN OrderCount,
- IN CONST UINT16 Location
+ IN CONST UINT16 Location
)
{
CHAR16 VariableName[12];
UINT16 *NewOrder;
EFI_STATUS Status;
- UINTN LoopVar;
UINTN NewCount;
- UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", Location);
+ UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", CurrentOrder[Location]);
Status = gRT->SetVariable(
VariableName,
(EFI_GUID*)&gEfiGlobalVariableGuid,
@@ -388,12 +483,9 @@ BcfgRemoveDebug1( if (NewOrder != NULL) {
NewCount = OrderCount;
CopyMem(NewOrder, CurrentOrder, OrderCount*sizeof(CurrentOrder[0]));
- for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++){
- if (NewOrder[LoopVar] == Location) {
- CopyMem(NewOrder+LoopVar, NewOrder+LoopVar+1, (OrderCount - LoopVar - 1)*sizeof(CurrentOrder[0]));
- NewCount--;
- }
- }
+ CopyMem(NewOrder+Location, NewOrder+Location+1, (OrderCount - Location - 1)*sizeof(CurrentOrder[0]));
+ NewCount--;
+
Status = gRT->SetVariable(
Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",
(EFI_GUID*)&gEfiGlobalVariableGuid,
@@ -542,9 +634,14 @@ BcfgDisplayDumpDebug1( return (SHELL_INVALID_PARAMETER);
}
- DevPath = AllocateZeroPool(*(UINT16*)(Buffer+4));
- CopyMem(DevPath, Buffer+6+StrSize((CHAR16*)(Buffer+6)), *(UINT16*)(Buffer+4));
- DevPathString = gDevPathToText->ConvertDevicePathToText(DevPath, TRUE, FALSE);
+ if ((*(UINT16*)(Buffer+4)) != 0) {
+ DevPath = AllocateZeroPool(*(UINT16*)(Buffer+4));
+ CopyMem(DevPath, Buffer+6+StrSize((CHAR16*)(Buffer+6)), *(UINT16*)(Buffer+4));
+ DevPathString = gDevPathToText->ConvertDevicePathToText(DevPath, TRUE, FALSE);
+ } else {
+ DevPath = NULL;
+ DevPathString = NULL;
+ }
ShellPrintHiiEx(
-1,
-1,
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.c index 3fd604d818..ff3f465ad7 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EditStatusBar.c @@ -125,14 +125,23 @@ StatusBarRefresh ( //
// print row, column fields
//
- ShellPrintEx (
- 0,
- (INT32)(LastRow) - 4,
- L" Row: %d Col: %d %s",
- FileRow,
- FileCol,
- StatusString
- );
+ if (FileRow != (UINTN)(-1) && FileCol != (UINTN)(-1)) {
+ ShellPrintEx (
+ 0,
+ (INT32)(LastRow) - 4,
+ L" Row: %d Col: %d %s",
+ FileRow,
+ FileCol,
+ StatusString
+ );
+ } else {
+ ShellPrintEx (
+ 0,
+ (INT32)(LastRow) - 4,
+ L" %s",
+ StatusString
+ );
+ }
//
// print insert mode field
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c index ccd73a9882..83b31992d2 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c @@ -1704,12 +1704,28 @@ HMainEditorRefresh ( NameChange = FALSE;
ReadChange = FALSE;
- if ( HMainEditor.BufferImage->FileImage != NULL &&
- HMainEditor.BufferImage->FileImage->FileName != NULL &&
- HBufferImageBackupVar.FileImage != NULL &&
- HBufferImageBackupVar.FileImage->FileName != NULL &&
- StrCmp (HMainEditor.BufferImage->FileImage->FileName, HBufferImageBackupVar.FileImage->FileName) != 0 ) {
- NameChange = TRUE;
+ if (HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer) {
+ if (HMainEditor.BufferImage->DiskImage != NULL &&
+ HBufferImageBackupVar.DiskImage != NULL &&
+ (HMainEditor.BufferImage->DiskImage->Offset != HBufferImageBackupVar.DiskImage->Offset ||
+ HMainEditor.BufferImage->DiskImage->Size != HBufferImageBackupVar.DiskImage->Size) ){
+ NameChange = TRUE;
+ }
+ } else if (HMainEditor.BufferImage->BufferType == FileTypeMemBuffer) {
+ if (HMainEditor.BufferImage->MemImage != NULL &&
+ HBufferImageBackupVar.MemImage != NULL &&
+ (HMainEditor.BufferImage->MemImage->Offset != HBufferImageBackupVar.MemImage->Offset ||
+ HMainEditor.BufferImage->MemImage->Size != HBufferImageBackupVar.MemImage->Size) ){
+ NameChange = TRUE;
+ }
+ } else if (HMainEditor.BufferImage->BufferType == FileTypeFileBuffer) {
+ if ( HMainEditor.BufferImage->FileImage != NULL &&
+ HMainEditor.BufferImage->FileImage->FileName != NULL &&
+ HBufferImageBackupVar.FileImage != NULL &&
+ HBufferImageBackupVar.FileImage->FileName != NULL &&
+ StrCmp (HMainEditor.BufferImage->FileImage->FileName, HBufferImageBackupVar.FileImage->FileName) != 0 ) {
+ NameChange = TRUE;
+ }
}
if ( HMainEditor.BufferImage->FileImage != NULL &&
HBufferImageBackupVar.FileImage != NULL &&
@@ -1753,9 +1769,9 @@ HMainEditorRefresh ( HEditorFirst,
HMainEditor.ScreenSize.Row,
HMainEditor.ScreenSize.Column,
- 0,
- 0,
- TRUE
+ (UINTN)(-1),
+ (UINTN)(-1),
+ FALSE
);
HBufferImageRefresh ();
}
|