diff options
author | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-04-12 21:55:07 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-04-12 21:55:07 +0000 |
commit | 6878e7a7be6a29da75fca61ba42681fc64a3fdf3 (patch) | |
tree | b4b4e4df7635d4c1da30ad3b6ae0cc2e4d87970a /ShellPkg/Library/UefiShellInstall1CommandsLib | |
parent | eaf4f336ea42dc32e1a5b31d6b7822c125a15d34 (diff) | |
download | edk2-platforms-6878e7a7be6a29da75fca61ba42681fc64a3fdf3.tar.xz |
update Bcfg to correctly remove by option index not variable name and add driver order items properly.
update connect and reconnect to account for ignoring the child handle in the connect operation.
update disconnect to output correctly.
hexedit corrected to properly display status bar and title bar and refresh when required.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11525 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiShellInstall1CommandsLib')
-rw-r--r-- | ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c | 189 |
1 files changed, 143 insertions, 46 deletions
diff --git a/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c b/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c index aeb3fcd10e..f7126e32b7 100644 --- a/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c +++ b/ShellPkg/Library/UefiShellInstall1CommandsLib/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
+GetDevicePathForDriverHandleInstall1 (
+ 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 @@ BcfgAddInstall1( 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 @@ BcfgAddInstall1( UINTN ChildControllerHandleCount;
SHELL_STATUS ShellStatus;
UINT16 *NewOrder;
- UINT64 Intermediate;
if (!UseHandle) {
if (File == NULL || Desc == NULL) {
@@ -125,42 +181,79 @@ BcfgAddInstall1( 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), gShellInstall1HiiHandle, File);
+ CurHandle = ConvertHandleIndexToHandle(HandleNumber);
+ if (CurHandle == NULL) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellInstall1HiiHandle, 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), gShellInstall1HiiHandle, 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), gShellInstall1HiiHandle, Intermediate);
- ShellStatus = SHELL_INVALID_PARAMETER;
+
+ if (DriverBindingHandleCount > 0
+ || ParentControllerHandleCount > 0
+ || ChildControllerHandleCount > 0
+ || !EFI_ERROR(Status) ) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellInstall1HiiHandle, L"Handle Number");
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ //
+ // Get the DevicePath from the loaded image information.
+ //
+ Status = GetDevicePathForDriverHandleInstall1(CurHandle, &FilePath);
+ }
}
}
} else {
@@ -199,6 +292,7 @@ BcfgAddInstall1( ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE_DP), gShellInstall1HiiHandle, Arg->FullName);
ShellStatus = SHELL_UNSUPPORTED;
} else {
+/*
if (UsePath) {
DevPath = DevicePath;
while (!IsDevicePathEnd(DevPath)) {
@@ -221,9 +315,11 @@ BcfgAddInstall1( FilePath = AppendDevicePath(DevicePath, FileNode);
FreePool(FileNode);
} else {
+*/
FilePath = DuplicateDevicePath(DevicePath);
+/*
}
-
+*/
FreePool(DevicePath);
}
}
@@ -364,16 +460,15 @@ BcfgRemoveInstall1( 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 @@ BcfgRemoveInstall1( 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 @@ BcfgDisplayDumpInstall1( 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,
|