summaryrefslogtreecommitdiff
path: root/ShellPkg/Library
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-03-25 21:13:43 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-03-25 21:13:43 +0000
commit361a8267362f755cca29495afa79efa0e9fd9714 (patch)
tree2fe16e35f4813ccc25263498f73060e2bbf2f3cb /ShellPkg/Library
parent1a63ec8f82705d4fb97e4034c1471c8e2a5c9cc5 (diff)
downloadedk2-platforms-361a8267362f755cca29495afa79efa0e9fd9714.tar.xz
connect - add comments and add input verification
devices - add comments and add input verification devtree - add comments and add input verification dh - add comments, add input verification, add support for "-d" disconnect - add comments and add input verification drivers - add comments drvcfg - add comment drvdiag - add comments, add input verification, and fix language use openinfo - add comments and add input verification reconnect - add comment unload - add input verification. main library files: add comments, #define protection, and more output to the user. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11434 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c95
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c20
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Devices.c52
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c604
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c33
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c41
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c8
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c345
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c22
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c8
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.c10
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h7
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.unibin60696 -> 65240 bytes
-rw-r--r--ShellPkg/Library/UefiShellDriver1CommandsLib/Unload.c19
14 files changed, 1039 insertions, 225 deletions
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c
index 47818f7d88..7073c44260 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c
@@ -1,7 +1,7 @@
/** @file
Main file for connect shell Driver1 function.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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 "UefiShellDriver1CommandsLib.h"
/**
+ Connect controller(s) and driver(s).
+
+ @param[in] ControllerHandle The handle to the controller. Should have driver binding on it.
+ @param[in] DriverHandle The handle to the driver. Should have driver binding.
+ @param[in] Recursive TRUE to connect recursively, FALSE otherwise.
+ @param[in] Output TRUE to have info on the screen, FALSE otherwise.
+ @param[in] AlwaysOutput Override Output for errors.
+
+ @retval EFI_SUCCESS The operation was successful.
**/
EFI_STATUS
EFIAPI
@@ -42,7 +51,7 @@ ConnectControllers (
if (DriverHandle == NULL) {
DriverHandleList = NULL;
} else {
- DriverHandleList = AllocatePool(2*sizeof(EFI_HANDLE));
+ DriverHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
if (DriverHandleList == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
@@ -90,6 +99,13 @@ ConnectControllers (
return (Status2);
}
+/**
+ Do a connect from an EFI variable via it's key name.
+
+ @param[in] Key The name of the EFI Variable.
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
EFIAPI
ConnectFromDevPaths (
@@ -110,7 +126,7 @@ ConnectFromDevPaths (
//
Status = gRT->GetVariable((CHAR16*)Key, (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, DevPath);
if (Status == EFI_BUFFER_TOO_SMALL) {
- DevPath = AllocatePool(Length);
+ DevPath = AllocateZeroPool(Length);
Status = gRT->GetVariable((CHAR16*)Key, (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, DevPath);
}
@@ -150,32 +166,27 @@ ConnectFromDevPaths (
return (Status);
}
+/**
+ Convert the handle identifiers from strings and then connect them.
+
+ One of them should have driver binding and either can be NULL.
+
+ @param[in] Handle1 The first handle.
+ @param[in] Handle2 The second handle.
+ @param[in] Recursive TRUE to do connect recursively. FALSE otherwise.
+ @param[in] Output TRUE to have output to screen. FALSE otherwise.
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
EFIAPI
ConvertAndConnectControllers (
- IN CONST CHAR16 *StringHandle1 OPTIONAL,
- IN CONST CHAR16 *StringHandle2 OPTIONAL,
+ IN EFI_HANDLE *Handle1 OPTIONAL,
+ IN EFI_HANDLE *Handle2 OPTIONAL,
IN CONST BOOLEAN Recursive,
IN CONST BOOLEAN Output
)
{
- EFI_HANDLE Handle1;
- EFI_HANDLE Handle2;
-
- //
- // Convert the command line parameters to HANDLES. They must be in HEX according to spec.
- //
- if (StringHandle1 != NULL) {
- Handle1 = ConvertHandleIndexToHandle(StrHexToUintn(StringHandle1));
- } else {
- Handle1 = NULL;
- }
- if (StringHandle2 != NULL) {
- Handle2 = ConvertHandleIndexToHandle(StrHexToUintn(StringHandle2));
- } else {
- Handle2 = NULL;
- }
-
//
// if only one is NULL verify it's the proper one...
//
@@ -206,7 +217,7 @@ ConvertAndConnectControllers (
}
}
- return (ConnectControllers(Handle1, Handle2, Recursive, Output, FALSE));
+ return (ConnectControllers(Handle1, Handle2, Recursive, Output, (BOOLEAN)(Handle2 != NULL && Handle1 != NULL)));
}
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
@@ -235,6 +246,9 @@ ShellCommandRunConnect (
CONST CHAR16 *Param1;
CONST CHAR16 *Param2;
UINTN Count;
+ EFI_HANDLE Handle1;
+ EFI_HANDLE Handle2;
+ UINT64 Intermediate;
ShellStatus = SHELL_SUCCESS;
@@ -310,19 +324,36 @@ ShellCommandRunConnect (
//
// 0, 1, or 2 specific handles and possibly recursive
//
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- Param2 = ShellCommandLineGetRawValue(Package, 2);
- Count = ShellCommandLineGetCount(Package);
- if (Param1 != NULL && ConvertHandleIndexToHandle(StrHexToUintn(Param1)) == NULL){
+ Param1 = ShellCommandLineGetRawValue(Package, 1);
+ Param2 = ShellCommandLineGetRawValue(Package, 2);
+ Count = ShellCommandLineGetCount(Package);
+
+ Status = ShellConvertStringToUint64(Param1, &Intermediate, TRUE, FALSE);
+ Handle1 = ConvertHandleIndexToHandle((UINTN)Intermediate);
+ if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param1);
ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (Param2 != NULL && ConvertHandleIndexToHandle(StrHexToUintn(Param2)) == NULL) {
+ }
+ Status = ShellConvertStringToUint64(Param2, &Intermediate, TRUE, FALSE);
+ Handle2 = ConvertHandleIndexToHandle((UINTN)Intermediate);
+ if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param2);
ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = ConvertAndConnectControllers(Param1, Param2, ShellCommandLineGetFlag(Package, L"-r"), (BOOLEAN)(Count!=0));
- if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_DEVICE_ERROR;
+ }
+
+ if (ShellStatus == SHELL_SUCCESS) {
+ if (Param1 != NULL && Handle1 == NULL){
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param1);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else if (Param2 != NULL && Handle2 == NULL) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param2);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ Status = ConvertAndConnectControllers(Handle1, Handle2, ShellCommandLineGetFlag(Package, L"-r"), (BOOLEAN)(Count!=0));
+ if (EFI_ERROR(Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CONNECT_NONE), gShellDriver1HiiHandle);
+ ShellStatus = SHELL_DEVICE_ERROR;
+ }
}
}
}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c
index 8a5c79b8cb..a66bdec06b 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c
@@ -1,7 +1,7 @@
/** @file
Main file for DevTree shell Driver1 function.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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
@@ -20,6 +20,18 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{NULL, TypeMax}
};
+/**
+ Display a tree starting from this handle.
+
+ @param[in] TheHandle The handle to start with.
+ @param[in] Lang Optionally, a UEFI defined language code.
+ @param[in] UseDevPaths TRUE to display info from DevPath as identifiers.
+ FALSE will use component name protocol instead.
+ @param[in] IndentCharCount How many characters to indent (allows for recursion).
+ @param[in] HiiString The string from HII to use for output.
+
+ @retval SHELL_SUCCESS The operation was successful.
+**/
SHELL_STATUS
EFIAPI
DoDevTreeForHandle(
@@ -156,6 +168,7 @@ ShellCommandRunDevTree (
UINTN LoopVar;
EFI_HANDLE TheHandle;
BOOLEAN FlagD;
+ UINT64 Intermediate;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
@@ -216,11 +229,12 @@ ShellCommandRunDevTree (
ShellStatus = DoDevTreeForHandle(TheHandle, Language, FlagD, 0, HiiString);
}
} else {
- if (!ShellIsHexOrDecimalNumber(Lang, TRUE, FALSE) || ConvertHandleIndexToHandle(StrHexToUintn(Lang)) == NULL) {
+ Status = ShellConvertStringToUint64(Lang, &Intermediate, TRUE, FALSE);
+ if (EFI_ERROR(Status) || ConvertHandleIndexToHandle((UINTN)Intermediate) == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Lang);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- ShellStatus = DoDevTreeForHandle(ConvertHandleIndexToHandle(StrHexToUintn(Lang)), Language, FlagD, 0, HiiString);
+ ShellStatus = DoDevTreeForHandle(ConvertHandleIndexToHandle((UINTN)Intermediate), Language, FlagD, 0, HiiString);
}
}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Devices.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Devices.c
index 1af1773849..658e7df219 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Devices.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Devices.c
@@ -1,7 +1,7 @@
/** @file
Main file for devices shell Driver1 function.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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,16 +14,42 @@
#include "UefiShellDriver1CommandsLib.h"
+/**
+ Get lots of info about a device from its handle.
+
+ @param[in] TheHandle The device handle to get info on.
+ @param[in,out] Type On successful return R, B, or D (root, bus, or
+ device) will be placed in this buffer.
+ @param[in,out] Cfg On successful return this buffer will be
+ TRUE if the handle has configuration, FALSE
+ otherwise.
+ @param[in,out] Diag On successful return this buffer will be
+ TRUE if the handle has disgnostics, FALSE
+ otherwise.
+ @param[in,out] Parents On successful return this buffer will be
+ contain the number of parent handles.
+ @param[in,out] Devices On successful return this buffer will be
+ contain the number of devices controlled.
+ @param[in,out] Children On successful return this buffer will be
+ contain the number of child handles.
+ @param[out] Name The pointer to a buffer that will be allocated
+ and contain the string name of the handle.
+ The caller must free this memory.
+ @param[in] Language The language code as defined by the UEFI spec.
+
+ @retval EFI_SUCCESS The info is there.
+ @retval EFI_INVALID_PARAMETER A parameter was invalid.
+**/
EFI_STATUS
EFIAPI
GetDeviceHandleInfo (
IN EFI_HANDLE TheHandle,
- IN CHAR16 *Type,
- IN BOOLEAN *Cfg,
- IN BOOLEAN *Diag,
- IN UINTN *Parents,
- IN UINTN *Devices,
- IN UINTN *Children,
+ IN OUT CHAR16 *Type,
+ IN OUT BOOLEAN *Cfg,
+ IN OUT BOOLEAN *Diag,
+ IN OUT UINTN *Parents,
+ IN OUT UINTN *Devices,
+ IN OUT UINTN *Children,
OUT CHAR16 **Name,
IN CONST CHAR8 *Language
)
@@ -32,6 +58,8 @@ GetDeviceHandleInfo (
EFI_HANDLE *HandleBuffer;
UINTN Count;
+ UINTN TestHandle = 0x43;
+
if (TheHandle == NULL
|| Type == NULL
|| Cfg == NULL
@@ -43,6 +71,10 @@ GetDeviceHandleInfo (
return (EFI_INVALID_PARAMETER);
}
+ if (ConvertHandleToHandleIndex(TheHandle) == TestHandle) {
+ TestHandle = TestHandle;
+ }
+
*Cfg = FALSE;
*Diag = FALSE;
*Children = 0;
@@ -56,7 +88,7 @@ GetDeviceHandleInfo (
gEfiShellProtocol->GetDeviceName(TheHandle, EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Language, Name);
Status = ParseHandleDatabaseForChildControllers(TheHandle, Children, NULL);
- if (!EFI_ERROR(Status)) {
+// if (!EFI_ERROR(Status)) {
Status = PARSE_HANDLE_DATABASE_PARENTS(TheHandle, Parents, NULL);
if (/*!EFI_ERROR(Status) && */Parents != NULL && Children != NULL) {
if (*Parents == 0) {
@@ -67,7 +99,7 @@ GetDeviceHandleInfo (
*Type = L'D';
}
}
- }
+// }
Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS(TheHandle, Devices, &HandleBuffer);
if (!EFI_ERROR(Status) && Devices != NULL && HandleBuffer != NULL) {
for (Count = 0 ; Count < *Devices ; Count++) {
@@ -195,7 +227,7 @@ ShellCommandRunDevices (
//
Name = NULL;
Status = GetDeviceHandleInfo(*HandleListWalker, &Type, &Cfg, &Diag, &Parents, &Devices, &Children, &Name, Language);
- if (Parents != 0 || Devices != 0 || Children != 0) {
+ if (Name != NULL && (Parents != 0 || Devices != 0 || Children != 0)) {
ShellPrintHiiEx(
-1,
-1,
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
index 3d3f1b19f4..852ba1d1e1 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
@@ -1,7 +1,7 @@
/** @file
Main file for Dh shell Driver1 function.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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
@@ -40,6 +40,88 @@ STATIC CONST EFI_GUID *UefiDriverModelProtocolsGuidArray[] = {
NULL
};
+/**
+ Get the name of a driver by it's handle.
+
+ If a name is found the memory must be callee freed.
+
+ @param[in] TheHandle The driver's handle.
+ @param[in] Language The language to use.
+ @param[in] NameFound Upon a successful return the name found.
+
+ @retval EFI_SUCCESS The name was found.
+**/
+EFI_STATUS
+EFIAPI
+GetDriverName (
+ IN EFI_HANDLE TheHandle,
+ IN CONST CHAR8 *Language,
+ IN CHAR16 **NameFound
+ )
+{
+ CHAR8 *Lang;
+ CHAR8 *TempChar;
+ EFI_STATUS Status;
+ EFI_COMPONENT_NAME2_PROTOCOL *CompName2;
+ CHAR16 *NameToReturn;
+ //
+ // Go through those handles until we get one that passes for GetComponentName
+ //
+ Status = gBS->OpenProtocol(
+ TheHandle,
+ &gEfiComponentName2ProtocolGuid,
+ (VOID**)&CompName2,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (EFI_ERROR(Status)) {
+ Status = gBS->OpenProtocol(
+ TheHandle,
+ &gEfiComponentNameProtocolGuid,
+ (VOID**)&CompName2,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ }
+
+ if (EFI_ERROR(Status)) {
+ return (EFI_NOT_FOUND);
+ }
+ if (Language == NULL) {
+ Lang = AllocateZeroPool(AsciiStrSize(CompName2->SupportedLanguages));
+ if (Lang == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+ AsciiStrCpy(Lang, CompName2->SupportedLanguages);
+ TempChar = AsciiStrStr(Lang, ";");
+ if (TempChar != NULL){
+ *TempChar = CHAR_NULL;
+ }
+ } else {
+ Lang = AllocateZeroPool(AsciiStrSize(Language));
+ if (Lang == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+ AsciiStrCpy(Lang, Language);
+ }
+ Status = CompName2->GetDriverName(CompName2, Lang, &NameToReturn);
+ FreePool(Lang);
+
+ if (!EFI_ERROR(Status) && NameToReturn != NULL) {
+ *NameFound = NULL;
+ StrnCatGrow(NameFound, NULL, NameToReturn, 0);
+ }
+ return (Status);
+}
+
+/**
+ Discover if a protocol guid is one of the UEFI Driver Model Protocols.
+
+ @param[in] Guid The guid to test.
+
+ @retval TRUE The guid does represent a driver model protocol.
+ @retval FALSE The guid does not represent a driver model protocol.
+**/
BOOLEAN
EFIAPI
IsDriverProt (
@@ -61,13 +143,24 @@ IsDriverProt (
return (GuidFound);
}
+/**
+ Get information for a handle.
+
+ @param[in] TheHandle The handles to show info on.
+ @param[in] Language Language string per UEFI specification.
+ @param[in] Seperator Separator string between information blocks.
+ @param[in] Verbose TRUE for extra info, FALSE otherwise.
+ @param[in] ExtraInfo TRUE for extra info, FALSE otherwise.
+
+ @retval SHELL_SUCCESS The operation was successful.
+ @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
+**/
CHAR16*
EFIAPI
GetProtocolInfoString(
IN CONST EFI_HANDLE TheHandle,
IN CONST CHAR8 *Language,
IN CONST CHAR16 *Seperator,
- IN CONST BOOLEAN DriverInfo,
IN CONST BOOLEAN Verbose,
IN CONST BOOLEAN ExtraInfo
)
@@ -81,6 +174,8 @@ GetProtocolInfoString(
CHAR16 *Temp;
ProtocolGuidArray = NULL;
+ RetVal = NULL;
+ Size = 0;
Status = gBS->ProtocolsPerHandle (
TheHandle,
@@ -88,8 +183,6 @@ GetProtocolInfoString(
&ArrayCount
);
if (!EFI_ERROR (Status)) {
- RetVal = NULL;
- Size = 0;
for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
Temp = GetStringNameFromGuid(ProtocolGuidArray[ProtocolIndex], Language);
if (Temp != NULL) {
@@ -118,18 +211,448 @@ GetProtocolInfoString(
}
}
}
- } else {
- return (NULL);
}
+
+ SHELL_FREE_NON_NULL(ProtocolGuidArray);
- if (ProtocolGuidArray != NULL) {
- FreePool(ProtocolGuidArray);
+ if (RetVal == NULL) {
+ return (NULL);
}
+
ASSERT((RetVal == NULL && Size == 0) || (RetVal != NULL));
StrnCatGrow(&RetVal, &Size, Seperator, 0);
return (RetVal);
}
+/**
+ Gets the name of the loaded image.
+
+ @param[in] TheHandle The handle of the driver to get info on.
+ @param[out] Name The pointer to the pointer. Valid upon a successful return.
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
+EFI_STATUS
+EFIAPI
+GetDriverImageName (
+ IN EFI_HANDLE TheHandle,
+ OUT CHAR16 **Name
+ )
+{
+ // get loaded image and devicepathtotext on image->Filepath
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ if (TheHandle == NULL || Name == NULL) {
+ return (EFI_INVALID_PARAMETER);
+ }
+
+ Status = gBS->OpenProtocol (
+ TheHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **) &LoadedImage,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR(Status)) {
+ return (Status);
+ }
+ DevicePath = LoadedImage->FilePath;
+ *Name = gDevPathToText->ConvertDevicePathToText(DevicePath, TRUE, TRUE);
+ return (EFI_SUCCESS);
+}
+
+/**
+ Display driver model information for a given handle.
+
+ @param[in] Handle The handle to display info on.
+ @param[in] BestName Use the best name?
+ @param[in] Language The language to output in.
+**/
+EFI_STATUS
+EFIAPI
+DisplayDriverModelHandle (
+ IN EFI_HANDLE Handle,
+ IN BOOLEAN BestName,
+ IN CONST CHAR8 *Language OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN ConfigurationStatus;
+ BOOLEAN DiagnosticsStatus;
+ UINTN DriverBindingHandleCount;
+ EFI_HANDLE *DriverBindingHandleBuffer;
+ UINTN ParentControllerHandleCount;
+ EFI_HANDLE *ParentControllerHandleBuffer;
+ UINTN ChildControllerHandleCount;
+ EFI_HANDLE *ChildControllerHandleBuffer;
+ CHAR16 *TempStringPointer;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN Index;
+ CHAR16 *DriverName;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ UINTN NumberOfChildren;
+ UINTN HandleIndex;
+ UINTN ControllerHandleCount;
+ EFI_HANDLE *ControllerHandleBuffer;
+ UINTN ChildIndex;
+ BOOLEAN Image;
+
+ //
+ // See if Handle is a device handle and display its details.
+ //
+ DriverBindingHandleBuffer = NULL;
+ Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (
+ Handle,
+ &DriverBindingHandleCount,
+ &DriverBindingHandleBuffer
+ );
+
+ ParentControllerHandleBuffer = NULL;
+ Status = PARSE_HANDLE_DATABASE_PARENTS (
+ Handle,
+ &ParentControllerHandleCount,
+ &ParentControllerHandleBuffer
+ );
+
+ ChildControllerHandleBuffer = NULL;
+ Status = ParseHandleDatabaseForChildControllers (
+ Handle,
+ &ChildControllerHandleCount,
+ &ChildControllerHandleBuffer
+ );
+
+ DiagnosticsStatus = FALSE;
+ ConfigurationStatus = FALSE;
+
+ if (!EFI_ERROR(gBS->OpenProtocol(Handle, &gEfiDriverConfigurationProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
+ ConfigurationStatus = TRUE;
+ }
+ if (!EFI_ERROR(gBS->OpenProtocol(Handle, &gEfiDriverConfiguration2ProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
+ ConfigurationStatus = TRUE;
+ }
+ if (!EFI_ERROR(gBS->OpenProtocol(Handle, &gEfiDriverDiagnosticsProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
+ DiagnosticsStatus = TRUE;
+ }
+ if (!EFI_ERROR(gBS->OpenProtocol(Handle, &gEfiDriverDiagnostics2ProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
+ DiagnosticsStatus = TRUE;
+ }
+
+ Status = EFI_SUCCESS;
+
+ if (DriverBindingHandleCount > 0 || ParentControllerHandleCount > 0 || ChildControllerHandleCount > 0) {
+
+
+
+ DevicePath = NULL;
+ TempStringPointer = NULL;
+ Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID**)&DevicePath);
+
+ Status = gEfiShellProtocol->GetDeviceName(Handle, EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Language, &TempStringPointer);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DH_OUTPUT_DRIVER1), gShellDriver1HiiHandle, TempStringPointer!=NULL?TempStringPointer:L"<Unknown>");
+ SHELL_FREE_NON_NULL(TempStringPointer);
+
+ TempStringPointer = gDevPathToText->ConvertDevicePathToText(DevicePath, TRUE, FALSE);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER2),
+ gShellDriver1HiiHandle,
+ TempStringPointer!=NULL?TempStringPointer:L"<None>",
+ ParentControllerHandleCount == 0?L"ROOT":(ChildControllerHandleCount > 0)?L"BUS":L"DEVICE",
+ ConfigurationStatus?L"YES":L"NO",
+ DiagnosticsStatus?L"YES":L"NO"
+ );
+
+ SHELL_FREE_NON_NULL(TempStringPointer);
+
+ if (DriverBindingHandleCount == 0) {
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER3),
+ gShellDriver1HiiHandle,
+ L"<None>"
+ );
+ } else {
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER3),
+ gShellDriver1HiiHandle,
+ L""
+ );
+ for (Index = 0; Index < DriverBindingHandleCount; Index++) {
+ Image = FALSE;
+ Status = GetDriverName (
+ DriverBindingHandleBuffer[Index],
+ Language,
+ &DriverName
+ );
+ if (DriverName == NULL) {
+ Status = GetDriverImageName (
+ DriverBindingHandleBuffer[Index],
+ &DriverName
+ );
+ }
+
+ if (Image) {
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER4A),
+ gShellDriver1HiiHandle,
+ ConvertHandleToHandleIndex (DriverBindingHandleBuffer[Index]),
+ DriverName!=NULL?DriverName:L"<Unknown>"
+ );
+ } else {
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER4B),
+ gShellDriver1HiiHandle,
+ ConvertHandleToHandleIndex (DriverBindingHandleBuffer[Index]),
+ DriverName!=NULL?DriverName:L"<Unknown>"
+ );
+ }
+ SHELL_FREE_NON_NULL(DriverName);
+ }
+ }
+
+ if (ParentControllerHandleCount == 0) {
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER5),
+ gShellDriver1HiiHandle,
+ L"<None>"
+ );
+ } else {
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER5),
+ gShellDriver1HiiHandle,
+ L""
+ );
+ for (Index = 0; Index < ParentControllerHandleCount; Index++) {
+ Status = gEfiShellProtocol->GetDeviceName(ParentControllerHandleBuffer[Index], EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Language, &TempStringPointer);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER5B),
+ gShellDriver1HiiHandle,
+ ConvertHandleToHandleIndex (ParentControllerHandleBuffer[Index]),
+ TempStringPointer!=NULL?TempStringPointer:L"<Unknown>"
+ );
+ SHELL_FREE_NON_NULL(TempStringPointer);
+ }
+ }
+
+ if (ChildControllerHandleCount == 0) {
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER6),
+ gShellDriver1HiiHandle,
+ L"<None>"
+ );
+ } else {
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER6),
+ gShellDriver1HiiHandle,
+ L""
+ );
+ for (Index = 0; Index < ChildControllerHandleCount; Index++) {
+ Status = gEfiShellProtocol->GetDeviceName(ChildControllerHandleBuffer[Index], EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Language, &TempStringPointer);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER6B),
+ gShellDriver1HiiHandle,
+ ConvertHandleToHandleIndex (ChildControllerHandleBuffer[Index]),
+ TempStringPointer!=NULL?TempStringPointer:L"<Unknown>"
+ );
+ SHELL_FREE_NON_NULL(TempStringPointer);
+ }
+ }
+ }
+
+ SHELL_FREE_NON_NULL(DriverBindingHandleBuffer);
+
+ SHELL_FREE_NON_NULL(ParentControllerHandleBuffer);
+
+ SHELL_FREE_NON_NULL(ChildControllerHandleBuffer);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // See if Handle is a driver binding handle and display its details.
+ //
+ Status = gBS->OpenProtocol (
+ Handle,
+ &gEfiDriverBindingProtocolGuid,
+ (VOID **) &DriverBinding,
+ NULL,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+
+ NumberOfChildren = 0;
+ ControllerHandleBuffer = NULL;
+ Status = PARSE_HANDLE_DATABASE_DEVICES (
+ Handle,
+ &ControllerHandleCount,
+ &ControllerHandleBuffer
+ );
+ if (ControllerHandleCount > 0) {
+ for (HandleIndex = 0; HandleIndex < ControllerHandleCount; HandleIndex++) {
+ Status = PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
+ Handle,
+ ControllerHandleBuffer[HandleIndex],
+ &ChildControllerHandleCount,
+ NULL
+ );
+ NumberOfChildren += ChildControllerHandleCount;
+ }
+ }
+
+ Status = GetDriverName (Handle, Language, &DriverName);
+
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER6B),
+ gShellDriver1HiiHandle,
+ ConvertHandleToHandleIndex(Handle),
+ DriverName!=NULL?DriverName:L"<Unknown>"
+ );
+ SHELL_FREE_NON_NULL(DriverName);
+ DriverName = NULL;
+ Status = GetDriverImageName (
+ Handle,
+ &DriverName
+ );
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER7B),
+ gShellDriver1HiiHandle,
+ DriverName!=NULL?DriverName:L"<Unknown>"
+ );
+ SHELL_FREE_NON_NULL(DriverName);
+
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER8),
+ gShellDriver1HiiHandle,
+ DriverBinding->Version,
+ NumberOfChildren > 0?L"Bus":ControllerHandleCount > 0?L"Device":L"<Unknown>",
+ ConfigurationStatus?L"YES":L"NO",
+ DiagnosticsStatus?L"YES":L"NO"
+ );
+
+ if (ControllerHandleCount == 0) {
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER6),
+ gShellDriver1HiiHandle,
+ L"None"
+ );
+ } else {
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER6),
+ gShellDriver1HiiHandle,
+ L""
+ );
+ for (HandleIndex = 0; HandleIndex < ControllerHandleCount; HandleIndex++) {
+ Status = gEfiShellProtocol->GetDeviceName(ControllerHandleBuffer[HandleIndex], EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Language, &TempStringPointer);
+
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER9B),
+ gShellDriver1HiiHandle,
+ ConvertHandleToHandleIndex(ControllerHandleBuffer[HandleIndex]),
+ TempStringPointer!=NULL?TempStringPointer:L"<Unknown>"
+ );
+ SHELL_FREE_NON_NULL(TempStringPointer);
+
+ Status = PARSE_HANDLE_DATABASE_MANAGED_CHILDREN (
+ Handle,
+ ControllerHandleBuffer[HandleIndex],
+ &ChildControllerHandleCount,
+ &ChildControllerHandleBuffer
+ );
+ if (!EFI_ERROR (Status)) {
+ for (ChildIndex = 0; ChildIndex < ChildControllerHandleCount; ChildIndex++) {
+ Status = gEfiShellProtocol->GetDeviceName(ChildControllerHandleBuffer[ChildIndex], EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Language, &TempStringPointer);
+
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_DH_OUTPUT_DRIVER6B),
+ gShellDriver1HiiHandle,
+ ConvertHandleToHandleIndex(ChildControllerHandleBuffer[ChildIndex]),
+ TempStringPointer!=NULL?TempStringPointer:L"<Unknown>"
+ );
+ SHELL_FREE_NON_NULL(TempStringPointer);
+ }
+
+ SHELL_FREE_NON_NULL (ChildControllerHandleBuffer);
+ }
+ }
+
+ SHELL_FREE_NON_NULL (ControllerHandleBuffer);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Display information for a handle.
+
+ @param[in] TheHandle The handles to show info on.
+ @param[in] Verbose TRUE for extra info, FALSE otherwise.
+ @param[in] Sfo TRUE to output in standard format output (spec).
+ @param[in] Language Language string per UEFI specification.
+ @param[in] DriverInfo TRUE to show all info about the handle.
+ @param[in] Multiple TRUE indicates more than will be output,
+ FALSE for a single one.
+
+ @retval SHELL_SUCCESS The operation was successful.
+ @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
+**/
SHELL_STATUS
EFIAPI
DoDhByHandle(
@@ -151,7 +674,7 @@ DoDhByHandle(
if (!Sfo) {
if (Multiple) {
- ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L" ", DriverInfo, Verbose, TRUE);
+ ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L" ", Verbose, TRUE);
ShellPrintHiiEx(
-1,
-1,
@@ -161,7 +684,7 @@ DoDhByHandle(
ConvertHandleToHandleIndex(TheHandle),
ProtocolInfoString==NULL?L"":ProtocolInfoString);
} else {
- ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L"\r\n", DriverInfo, Verbose, TRUE);
+ ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L"\r\n", Verbose, TRUE);
ShellPrintHiiEx(
-1,
-1,
@@ -172,9 +695,12 @@ DoDhByHandle(
TheHandle,
ProtocolInfoString==NULL?L"":ProtocolInfoString);
}
+
+ if (DriverInfo) {
+ DisplayDriverModelHandle ((EFI_HANDLE)TheHandle, TRUE, Language);
+ }
} else {
-//#string STR_DH_OUTPUT_SFO #language en-US "%s, %s, %s, %H%02x%N, %s, %s\r\n"
- ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L";", DriverInfo, FALSE, FALSE);
+ ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L";", FALSE, FALSE);
ShellPrintHiiEx(
-1,
-1,
@@ -198,6 +724,17 @@ DoDhByHandle(
return (ShellStatus);
}
+/**
+ Display information for all handles on a list.
+
+ @param[in] HandleList The NULL-terminated list of handles.
+ @param[in] Sfo TRUE to output in standard format output (spec).
+ @param[in] Language Language string per UEFI specification.
+ @param[in] DriverInfo TRUE to show all info about the handle.
+
+ @retval SHELL_SUCCESS The operation was successful.
+ @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
+**/
SHELL_STATUS
EFIAPI
DoDhForHandleList(
@@ -225,6 +762,16 @@ DoDhForHandleList(
return (ShellStatus);
}
+/**
+ Display information for all handles.
+
+ @param[in] Sfo TRUE to output in standard format output (spec).
+ @param[in] Language Language string per UEFI specification.
+ @param[in] DriverInfo TRUE to show all info about the handle.
+
+ @retval SHELL_SUCCESS The operation was successful.
+ @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
+**/
SHELL_STATUS
EFIAPI
DoDhForAll(
@@ -249,6 +796,17 @@ DoDhForAll(
return (ShellStatus);
}
+/**
+ Display information for all handles which have a specific protocol.
+
+ @param[in] ProtocolName The pointer to the name of the protocol.
+ @param[in] Sfo TRUE to output in standard format output (spec).
+ @param[in] Language Language string per UEFI specification.
+ @param[in] DriverInfo TRUE to show all info about the handle.
+
+ @retval SHELL_SUCCESS The operation was successful.
+ @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
+**/
SHELL_STATUS
EFIAPI
DoDhByProtocol(
@@ -263,7 +821,9 @@ DoDhByProtocol(
EFI_HANDLE *HandleList;
SHELL_STATUS ShellStatus;
- ASSERT(ProtocolName != NULL);
+ if (ProtocolName == NULL) {
+ return (SHELL_INVALID_PARAMETER);
+ }
Status = GetGuidFromStringName(ProtocolName, Language, &Guid);
if (EFI_ERROR(Status)) {
@@ -284,6 +844,12 @@ DoDhByProtocol(
return (ShellStatus);
}
+/**
+ Function for 'dh' 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
ShellCommandRunDh (
@@ -301,6 +867,7 @@ ShellCommandRunDh (
BOOLEAN SfoMode;
BOOLEAN FlagD;
BOOLEAN Verbose;
+ UINT64 Intermediate;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
@@ -350,11 +917,7 @@ ShellCommandRunDh (
SfoMode = ShellCommandLineGetFlag(Package, L"-sfo");
FlagD = ShellCommandLineGetFlag(Package, L"-d");
- if (ShellCommandLineGetFlag(Package, L"-v") || ShellCommandLineGetFlag(Package, L"-verbose")) {
- Verbose = TRUE;
- } else {
- Verbose = FALSE;
- }
+ Verbose = (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-v") || ShellCommandLineGetFlag(Package, L"-verbose"));
if (ShellCommandLineGetFlag(Package, L"-p")) {
if (ShellCommandLineGetCount(Package) > 1) {
@@ -386,7 +949,8 @@ ShellCommandRunDh (
FlagD
);
} else {
- if (!ShellIsHexOrDecimalNumber(Temp2, TRUE, FALSE) || ConvertHandleIndexToHandle(StrHexToUintn(Temp2)) == NULL) {
+ Status = ShellConvertStringToUint64(Temp2, &Intermediate, TRUE, FALSE);
+ if (EFI_ERROR(Status) || ConvertHandleIndexToHandle((UINTN)Intermediate) == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Temp2);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
@@ -394,7 +958,7 @@ ShellCommandRunDh (
// print 1 handle
//
ShellStatus = DoDhByHandle(
- ConvertHandleIndexToHandle(StrHexToUintn(Temp2)),
+ ConvertHandleIndexToHandle((UINTN)Intermediate),
Verbose,
SfoMode,
Lang==NULL?NULL:Language,
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
index d10ce56806..3a19304b66 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
@@ -1,7 +1,7 @@
/** @file
Main file for Disconnect shell Driver1 function.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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,6 +19,11 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{NULL, TypeMax}
};
+/**
+ Disconnect everything.
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
EFIAPI
DisconnectAll(
@@ -67,6 +72,12 @@ DisconnectAll(
return (EFI_SUCCESS);
}
+/**
+ Function for 'disconnect' 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
ShellCommandRunDisconnect (
@@ -84,6 +95,9 @@ ShellCommandRunDisconnect (
EFI_HANDLE Handle1;
EFI_HANDLE Handle2;
EFI_HANDLE Handle3;
+ UINT64 Intermediate1;
+ UINT64 Intermediate2;
+ UINT64 Intermediate3;
ShellStatus = SHELL_SUCCESS;
@@ -133,9 +147,12 @@ ShellCommandRunDisconnect (
Param1 = ShellCommandLineGetRawValue(Package, 1);
Param2 = ShellCommandLineGetRawValue(Package, 2);
Param3 = ShellCommandLineGetRawValue(Package, 3);
- Handle1 = Param1!=NULL?ConvertHandleIndexToHandle(StrHexToUintn(Param1)):NULL;
- Handle2 = Param2!=NULL?ConvertHandleIndexToHandle(StrHexToUintn(Param2)):NULL;
- Handle3 = Param3!=NULL?ConvertHandleIndexToHandle(StrHexToUintn(Param3)):NULL;
+ ShellConvertStringToUint64(Param1, &Intermediate1, TRUE, FALSE);
+ Handle1 = Param1!=NULL?ConvertHandleIndexToHandle((UINTN)Intermediate1):NULL;
+ ShellConvertStringToUint64(Param2, &Intermediate2, TRUE, FALSE);
+ Handle2 = Param2!=NULL?ConvertHandleIndexToHandle((UINTN)Intermediate2):NULL;
+ ShellConvertStringToUint64(Param3, &Intermediate3, TRUE, FALSE);
+ Handle3 = Param3!=NULL?ConvertHandleIndexToHandle((UINTN)Intermediate3):NULL;
if (Param1 != NULL && Handle1 == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param1);
@@ -148,18 +165,16 @@ ShellCommandRunDisconnect (
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiDevicePathProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
ASSERT(Param1 != NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_NOT), gShellDriver1HiiHandle, StrHexToUintn(Param1), L"controller handle");
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_NOT), gShellDriver1HiiHandle, ShellStrToUintn(Param1), L"controller handle");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (Handle2 != NULL && EFI_ERROR(gBS->OpenProtocol(Handle2, &gEfiDriverBindingProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
ASSERT(Param2 != NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_NOT), gShellDriver1HiiHandle, StrHexToUintn(Param2), L"driver handle");
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_NOT), gShellDriver1HiiHandle, ShellStrToUintn(Param2), L"driver handle");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(Param1 != NULL);
- ASSERT(Param2 != NULL);
- ASSERT(Param3 != NULL);
Status = gBS->DisconnectController(Handle1, Handle2, Handle3);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_3P_RESULT), gShellDriver1HiiHandle, L"Disconnect", Handle1, Handle2, Handle3, Status);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_3P_RESULT), gShellDriver1HiiHandle, L"Disconnect", Intermediate1, Intermediate2, Intermediate3, Status);
}
}
}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c
index 7784ca75d6..18912e8f07 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c
@@ -1,7 +1,7 @@
/** @file
Main file for Drivers shell Driver1 function.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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
@@ -20,6 +20,15 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{NULL, TypeMax}
};
+/**
+ Get a device path (in text format) for a given handle.
+
+ @param[in] TheHandle The handle to get the device path for.
+
+ @retval NULL An error occured.
+ @return A pointer to the driver path as a string. The callee must
+ free this memory.
+**/
CHAR16*
EFIAPI
GetDevicePathTextForHandle(
@@ -77,6 +86,14 @@ GetDevicePathTextForHandle(
return (RetVal);
}
+/**
+ Determine if the given handle has Driver Configuration protocol.
+
+ @param[in] TheHandle The handle to the driver to test.
+
+ @retval TRUE The driver does have Driver Configuration.
+ @retval FALSE The driver does not have Driver Configuration.
+**/
BOOLEAN
EFIAPI
ReturnDriverConfig(
@@ -91,6 +108,14 @@ ReturnDriverConfig(
return (TRUE);
}
+/**
+ Determine if the given handle has DriverDiagnostics protocol.
+
+ @param[in] TheHandle The handle to the driver to test.
+
+ @retval TRUE The driver does have Driver Diasgnostics.
+ @retval FALSE The driver does not have Driver Diagnostics.
+**/
BOOLEAN
EFIAPI
ReturnDriverDiag(
@@ -108,6 +133,14 @@ ReturnDriverDiag(
return (TRUE);
}
+/**
+ Finds and returns the version of the driver specified by TheHandle.
+
+ @param[in] TheHandle The driver handle to get the version of.
+
+ @return The version of the driver.
+ @retval 0xFFFFFFFF An error ocurred.
+**/
UINT32
EFIAPI
ReturnDriverVersion(
@@ -128,6 +161,12 @@ ReturnDriverVersion(
return (RetVal);
}
+/**
+ Function for 'drivers' 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
ShellCommandRunDrivers (
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
index 4f4375414c..074a49c3be 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c
@@ -1,7 +1,7 @@
/** @file
Main file for DrvCfg shell Driver1 function.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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
@@ -300,6 +300,12 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{NULL, TypeMax}
};
+/**
+ Function for 'drvcfg' 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
ShellCommandRunDrvCfg (
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c
index 9a8daecc9c..6b55d909e9 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c
@@ -1,7 +1,7 @@
/** @file
Main file for DrvDiag shell Driver1 function.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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,13 +19,27 @@ STATIC CONST EFI_GUID *DiagGuidList[] = {&gEfiDriverDiagnosticsProtocolGuid, &gE
// We need 1 more item on the list...
//
typedef enum {
- TEST_MODE_STANDARD = EfiDriverDiagnosticTypeStandard,
- TEST_MODE_EXTENDED = EfiDriverDiagnosticTypeExtended,
- TEST_MODE_MANUFACTURING = EfiDriverDiagnosticTypeManufacturing,
- TEST_MODE_LIST,
- TEST_MODE_MAX
+ TestModeStandard = EfiDriverDiagnosticTypeStandard,
+ TestModeExtended = EfiDriverDiagnosticTypeExtended,
+ TestModeManufacturing = EfiDriverDiagnosticTypeManufacturing,
+ TestModeList,
+ TestModeMax
} DRV_DIAG_TEST_MODE;
+/**
+ Do the diagnostics call for some set of handles.
+
+ @param[in] Mode The type of diagnostic test to run.
+ @param[in] Lang The language code to use.
+ @param[in] AllChilds Should the test be on all children.
+ @param[in] DriverHandle The driver handle to test with.
+ @param[in] ControllerHandle The specific controller handle to test.
+ @param[in] ChildHandle The specific child handle to test.
+
+ @retval EFI_SUCCESS The operation was successful.
+ @retval EFI_INVALID_PARAMETER A parameter had an invalid value.
+ @retval EFI_NOT_FOUND No diagnostic handle could be found.
+**/
EFI_STATUS
EFIAPI
DoDiagnostics (
@@ -56,13 +70,11 @@ DoDiagnostics (
CHAR16 *OutBuffer;
UINTN HandleIndex1;
UINTN HandleIndex2;
+ CHAR8 *Language;
+ CHAR8 *TempChar;
+ BOOLEAN Found;
- if ((ChildHandle != NULL && AllChilds) || (Mode >= TEST_MODE_MAX)){
- return (EFI_INVALID_PARAMETER);
- }
-
- if (Lang == NULL || AsciiStrLen(Lang) < 3) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"-l <value>");
+ if ((ChildHandle != NULL && AllChilds) || (Mode >= TestModeMax)){
return (EFI_INVALID_PARAMETER);
}
@@ -73,6 +85,7 @@ DoDiagnostics (
DriverHandleList = NULL;
ControllerHandleList = NULL;
ChildHandleList = NULL;
+ Language = NULL;
OutBuffer = NULL;
ErrorType = NULL;
DriverHandleListCount = 0;
@@ -87,7 +100,8 @@ DoDiagnostics (
} else {
DriverHandleList = GetHandleListByProtocolList(DiagGuidList);
if (DriverHandleList == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_NONE), gShellDriver1HiiHandle);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROTOCOL_NF), gShellDriver1HiiHandle, L"gEfiDriverDiagnosticsProtocolGuid", &gEfiDriverDiagnosticsProtocolGuid);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROTOCOL_NF), gShellDriver1HiiHandle, L"gEfiDriverDiagnostics2ProtocolGuid", &gEfiDriverDiagnostics2ProtocolGuid);
return (EFI_NOT_FOUND);
}
for (Walker = DriverHandleList ; Walker != NULL && *Walker != NULL ; DriverHandleListCount++, Walker++);
@@ -116,132 +130,186 @@ DoDiagnostics (
ChildHandleList = NULL;
}
+ if (Mode == TestModeList) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DRVDIAG_HEADER), gShellDriver1HiiHandle);
+ }
for (DriverHandleListLoop = 0
; DriverHandleListLoop < DriverHandleListCount
; DriverHandleListLoop++
){
+ if (Mode == TestModeList) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DRVDIAG_DRIVER_HEADER), gShellDriver1HiiHandle, ConvertHandleToHandleIndex(DriverHandleList[DriverHandleListLoop]));
+ }
if (ControllerHandle == NULL) {
PARSE_HANDLE_DATABASE_DEVICES(DriverHandleList[DriverHandleListLoop], &ControllerHandleListCount, &ControllerHandleList);
- }
- for (ControllerHandleListLoop = 0
- ; ControllerHandleListLoop < ControllerHandleListCount
- ; ControllerHandleListLoop++
- ){
- if (AllChilds) {
- ASSERT(ChildHandleList == NULL);
- PARSE_HANDLE_DATABASE_MANAGED_CHILDREN(
- DriverHandleList[DriverHandleListLoop],
- ControllerHandleList[ControllerHandleListLoop],
- &ChildHandleListCount,
- &ChildHandleList);
+ }
+ if (ControllerHandleListCount == 0) {
+ if (Mode == TestModeList) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DRVDIAG_DRIVER_NO_HANDLES), gShellDriver1HiiHandle);
+ }
+ } else {
+ if (Mode == TestModeList) {
+ ShellPrintEx(-1, -1, L"\r\n");
}
- for (ChildHandleListLoop = 0
- ; (ChildHandleListLoop < ChildHandleListCount || ChildHandleList == NULL)
- ; ChildHandleListLoop++
+ for (ControllerHandleListLoop = 0
+ ; ControllerHandleListLoop < ControllerHandleListCount
+ ; ControllerHandleListLoop++
){
- if (Mode != TEST_MODE_LIST) {
- if (Lang[2] == '-') {
- //
- // Get the protocol pointer and call the function
- //
- Status = gBS->OpenProtocol(
- DriverHandleList[DriverHandleListLoop],
- &gEfiDriverDiagnostics2ProtocolGuid,
- (VOID**)&DriverDiagnostics2,
- gImageHandle,
+ if (AllChilds) {
+ ASSERT(ChildHandleList == NULL);
+ PARSE_HANDLE_DATABASE_MANAGED_CHILDREN(
+ DriverHandleList[DriverHandleListLoop],
+ ControllerHandleList[ControllerHandleListLoop],
+ &ChildHandleListCount,
+ &ChildHandleList);
+ }
+ for (ChildHandleListLoop = 0
+ ; (ChildHandleListLoop < ChildHandleListCount || ChildHandleList == NULL)
+ ; ChildHandleListLoop++
+ ){
+ Found = FALSE;
+ if (Mode != TestModeList) {
+ if (Lang == NULL || Lang[2] == '-') {
+ //
+ // Get the protocol pointer and call the function
+ //
+ Status = gBS->OpenProtocol(
+ DriverHandleList[DriverHandleListLoop],
+ &gEfiDriverDiagnostics2ProtocolGuid,
+ (VOID**)&DriverDiagnostics2,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (!EFI_ERROR(Status)) {
+ if (Lang == NULL) {
+ Language = AllocateZeroPool(AsciiStrSize(DriverDiagnostics2->SupportedLanguages));
+ if (Language == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+ AsciiStrCpy(Language, DriverDiagnostics2->SupportedLanguages);
+ TempChar = AsciiStrStr(Language, ";");
+ if (TempChar != NULL){
+ *TempChar = CHAR_NULL;
+ }
+ } else {
+ Language = AllocateZeroPool(AsciiStrSize(Lang));
+ if (Language == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+ AsciiStrCpy(Language, Lang);
+ }
+ Found = TRUE;
+ Status = DriverDiagnostics2->RunDiagnostics(
+ DriverDiagnostics2,
+ ControllerHandleList[ControllerHandleListLoop],
+ ChildHandleList == NULL?NULL:ChildHandleList[ChildHandleListLoop],
+ (EFI_DRIVER_DIAGNOSTIC_TYPE)Mode,
+ Language,
+ &ErrorType,
+ &OutBufferSize,
+ &OutBuffer);
+ FreePool(Language);
+ }
+ }
+ if (Found == FALSE && (Lang == NULL||(Lang!=NULL&&Lang[2]!='-'))){
+ Status = gBS->OpenProtocol(
+ DriverHandleList[DriverHandleListLoop],
+ &gEfiDriverDiagnosticsProtocolGuid,
+ (VOID**)&DriverDiagnostics,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ if (!EFI_ERROR(Status)) {
+ if (Lang == NULL) {
+ Language = AllocateZeroPool(AsciiStrSize(DriverDiagnostics2->SupportedLanguages));
+ if (Language == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+ AsciiStrCpy(Language, DriverDiagnostics2->SupportedLanguages);
+ TempChar = AsciiStrStr(Language, ";");
+ if (TempChar != NULL){
+ *TempChar = CHAR_NULL;
+ }
+ } else {
+ Language = AllocateZeroPool(AsciiStrSize(Lang));
+ if (Language == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+ AsciiStrCpy(Language, Lang);
+ }
+ Status = DriverDiagnostics->RunDiagnostics(
+ DriverDiagnostics,
+ ControllerHandleList[ControllerHandleListLoop],
+ ChildHandleList == NULL?NULL:ChildHandleList[ChildHandleListLoop],
+ (EFI_DRIVER_DIAGNOSTIC_TYPE)Mode,
+ Language,
+ &ErrorType,
+ &OutBufferSize,
+ &OutBuffer);
+ FreePool(Language);
+ }
+ }
+ if (EFI_ERROR(Status)) {
+ Status2 = Status;
+ }
+ HandleIndex1 = ConvertHandleToHandleIndex(DriverHandleList[DriverHandleListLoop]);
+ HandleIndex2 = ConvertHandleToHandleIndex(ControllerHandleList[ControllerHandleListLoop]);
+ ShellPrintHiiEx(
+ -1,
+ -1,
NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status)) {
- Status = DriverDiagnostics2->RunDiagnostics(
- DriverDiagnostics2,
- ControllerHandleList[ControllerHandleListLoop],
- ChildHandleList == NULL?NULL:ChildHandleList[ChildHandleListLoop],
- (EFI_DRIVER_DIAGNOSTIC_TYPE)Mode,
- (CHAR8*)Lang,
- &ErrorType,
- &OutBufferSize,
- &OutBuffer);
+ STRING_TOKEN (STR_3P_RESULT),
+ gShellDriver1HiiHandle,
+ L"DrvDiag",
+ HandleIndex1,
+ HandleIndex2,
+ ChildHandleList == NULL?0:ConvertHandleToHandleIndex(ChildHandleList[ChildHandleListLoop]),
+ Status);
+ if (OutBuffer!=NULL) {
+ FreePool(OutBuffer);
+ OutBuffer = NULL;
+ }
+ if (ErrorType!=NULL) {
+ FreePool(ErrorType);
+ ErrorType = NULL;
}
} else {
- Status = gBS->OpenProtocol(
- DriverHandleList[DriverHandleListLoop],
- &gEfiDriverDiagnosticsProtocolGuid,
- (VOID**)&DriverDiagnostics,
- gImageHandle,
+ HandleIndex1 = ConvertHandleToHandleIndex(DriverHandleList[DriverHandleListLoop]);
+ HandleIndex2 = ConvertHandleToHandleIndex(ControllerHandleList[ControllerHandleListLoop]);
+ //
+ // Print out the information that this set can be tested
+ //
+ ShellPrintHiiEx(
+ -1,
+ -1,
NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status)) {
- Status = DriverDiagnostics->RunDiagnostics(
- DriverDiagnostics,
- ControllerHandleList[ControllerHandleListLoop],
- ChildHandleList == NULL?NULL:ChildHandleList[ChildHandleListLoop],
- (EFI_DRIVER_DIAGNOSTIC_TYPE)Mode,
- (CHAR8*)Lang,
- &ErrorType,
- &OutBufferSize,
- &OutBuffer);
- }
- }
- if (EFI_ERROR(Status)) {
- Status2 = Status;
- }
- HandleIndex1 = ConvertHandleToHandleIndex(DriverHandleList[DriverHandleListLoop]);
- HandleIndex2 = ConvertHandleToHandleIndex(ControllerHandleList[ControllerHandleListLoop]);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_3P_RESULT),
- gShellDriver1HiiHandle,
- L"DrvDiag",
- HandleIndex1,
- HandleIndex2,
- ChildHandleList == NULL?0:ConvertHandleToHandleIndex(ChildHandleList[ChildHandleListLoop]),
- Status);
- if (OutBuffer!=NULL) {
- FreePool(OutBuffer);
- OutBuffer = NULL;
- }
- if (ErrorType!=NULL) {
- FreePool(ErrorType);
- ErrorType = NULL;
+ STRING_TOKEN (STR_DRV_DIAG_ITEM_LINE),
+ gShellDriver1HiiHandle,
+ HandleIndex1,
+ HandleIndex2,
+ ChildHandleList == NULL?0:ConvertHandleToHandleIndex(ChildHandleList[ChildHandleListLoop])
+ );
}
- } else {
- HandleIndex1 = ConvertHandleToHandleIndex(DriverHandleList[DriverHandleListLoop]);
- HandleIndex2 = ConvertHandleToHandleIndex(ControllerHandleList[ControllerHandleListLoop]);
+
//
- // Print out the information that this set can be tested
+ // If we are doing a single pass with NULL child jump out after a single loop
//
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRV_DIAG_ITEM_LINE),
- gShellDriver1HiiHandle,
- HandleIndex1,
- HandleIndex2,
- ChildHandleList == NULL?0:ConvertHandleToHandleIndex(ChildHandleList[ChildHandleListLoop])
- );
+ if (ChildHandleList == NULL) {
+ break;
+ }
}
-
- //
- // If we are doing a single pass with NULL child jump out after a single loop
- //
- if (ChildHandleList == NULL) {
- break;
+ if (AllChilds) {
+ SHELL_FREE_NON_NULL(ChildHandleList);
+ ChildHandleList = NULL;
+ ChildHandleListCount = 0;
}
}
- if (AllChilds) {
- SHELL_FREE_NON_NULL(ChildHandleList);
- ChildHandleList = NULL;
- ChildHandleListCount = 0;
+ if (ControllerHandle == NULL) {
+ SHELL_FREE_NON_NULL(ControllerHandleList);
+ ControllerHandleList = NULL;
+ ControllerHandleListCount = 0;
+ }
}
- }
- if (ControllerHandle == NULL) {
- SHELL_FREE_NON_NULL(ControllerHandleList);
- ControllerHandleList = NULL;
- ControllerHandleListCount = 0;
- }
}
if (DriverHandleList != NULL) {
@@ -266,6 +334,12 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{NULL, TypeMax}
};
+/**
+ Function for 'drvdiag' 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
ShellCommandRunDrvDiag (
@@ -286,9 +360,10 @@ ShellCommandRunDrvDiag (
EFI_HANDLE Handle1;
EFI_HANDLE Handle2;
EFI_HANDLE Handle3;
+ UINT64 Intermediate;
ShellStatus = SHELL_SUCCESS;
- Mode = TEST_MODE_MAX;
+ Mode = TestModeMax;
Language = NULL;
//
@@ -334,11 +409,11 @@ ShellCommandRunDrvDiag (
// Run the apropriate test
//
if (ShellCommandLineGetFlag(Package, L"-s")) {
- Mode = TEST_MODE_STANDARD;
+ Mode = TestModeStandard;
} else if (ShellCommandLineGetFlag(Package, L"-e")) {
- Mode = TEST_MODE_EXTENDED;
+ Mode = TestModeExtended;
} else if (ShellCommandLineGetFlag(Package, L"-m")) {
- Mode = TEST_MODE_MANUFACTURING;
+ Mode = TestModeManufacturing;
} else {
ASSERT(FALSE);
}
@@ -346,21 +421,18 @@ ShellCommandRunDrvDiag (
//
// Do a listing of what's available to test
//
- Mode = TEST_MODE_LIST;
+ Mode = TestModeList;
}
Lang = ShellCommandLineGetValue(Package, L"-l");
- if (Lang != NULL) {
- Language = AllocateZeroPool(StrSize(Lang));
- AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
- } else if (!ShellCommandLineGetFlag(Package, L"-l")){
- Language = AllocateZeroPool(10);
- AsciiSPrint(Language, 10, "en-us");
- } else {
+ if (ShellCommandLineGetFlag(Package, L"-l") && Lang == NULL) {
ASSERT(Language == NULL);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"-l");
ShellCommandLineFreeVarList (Package);
return (SHELL_INVALID_PARAMETER);
+ } else if (Lang != NULL) {
+ Language = AllocateZeroPool(StrSize(Lang));
+ AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
}
DriverHandleStr = ShellCommandLineGetRawValue(Package, 1);
@@ -370,17 +442,20 @@ ShellCommandRunDrvDiag (
if (DriverHandleStr == NULL) {
Handle1 = NULL;
} else {
- Handle1 = ConvertHandleIndexToHandle(StrHexToUintn(DriverHandleStr ));
+ ShellConvertStringToUint64(DriverHandleStr, &Intermediate, TRUE, FALSE);
+ Handle1 = ConvertHandleIndexToHandle((UINTN)Intermediate);
}
if (ControllerHandleStr == NULL) {
Handle2 = NULL;
} else {
- Handle2 = ConvertHandleIndexToHandle(StrHexToUintn(ControllerHandleStr));
+ ShellConvertStringToUint64(ControllerHandleStr, &Intermediate, TRUE, FALSE);
+ Handle2 = ConvertHandleIndexToHandle((UINTN)Intermediate);
}
if (ChildHandleStr == NULL) {
Handle3 = NULL;
} else {
- Handle3 = ConvertHandleIndexToHandle(StrHexToUintn(ChildHandleStr ));
+ ShellConvertStringToUint64(ChildHandleStr, &Intermediate, TRUE, FALSE);
+ Handle3 = ConvertHandleIndexToHandle((UINTN)Intermediate);
}
Status = DoDiagnostics (
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c
index b60cc18333..0cb7840391 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c
@@ -1,7 +1,7 @@
/** @file
Main file for OpenInfo shell Driver1 function.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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
@@ -23,6 +23,14 @@ STATIC CONST CHAR16 StringExclusive[] = L"Exclusive";
STATIC CONST CHAR16 StringDriverEx[] = L"DriverEx ";
STATIC CONST CHAR16 StringUnknown[] = L"Unknown ";
+/**
+ Open the database and print out all the info about TheHandle.
+
+ @param[in] TheHandle The handle to print info on.
+
+ @retval EFI_SUCCESS The operation was successful.
+ @retval EFI_INVALID_PARAMETER TheHandle was NULL.
+**/
EFI_STATUS
EFIAPI
TraverseHandleDatabase (
@@ -41,7 +49,9 @@ TraverseHandleDatabase (
UINTN HandleIndex;
CONST CHAR16 *Name;
- ASSERT(TheHandle != NULL);
+ if (TheHandle == NULL) {
+ return (EFI_INVALID_PARAMETER);
+ }
//
// Retrieve the list of all the protocols on the handle
@@ -145,6 +155,7 @@ ShellCommandRunOpenInfo (
SHELL_STATUS ShellStatus;
EFI_HANDLE TheHandle;
CONST CHAR16 *Param1;
+ UINT64 Intermediate;
ShellStatus = SHELL_SUCCESS;
@@ -181,13 +192,14 @@ ShellCommandRunOpenInfo (
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Param1 = ShellCommandLineGetRawValue(Package, 1);
- if (Param1 == NULL || ConvertHandleIndexToHandle(StrHexToUintn(Param1)) == NULL){
+ Status = ShellConvertStringToUint64(Param1, &Intermediate, TRUE, FALSE);
+ if (EFI_ERROR(Status) || Param1 == NULL || ConvertHandleIndexToHandle((UINTN)Intermediate) == NULL){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param1);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- TheHandle = ConvertHandleIndexToHandle(StrHexToUintn(Param1));
+ TheHandle = ConvertHandleIndexToHandle((UINTN)Intermediate);
ASSERT(TheHandle != NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_OPENINFO_HEADER_LINE), gShellDriver1HiiHandle, StrHexToUintn(Param1), TheHandle);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_OPENINFO_HEADER_LINE), gShellDriver1HiiHandle, (UINTN)Intermediate, TheHandle);
Status = TraverseHandleDatabase (TheHandle);
if (!EFI_ERROR(Status)) {
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c
index 723ee71141..0a8e1b2be8 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c
@@ -1,7 +1,7 @@
/** @file
Main file for Reconnect shell Driver1 function.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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 "UefiShellDriver1CommandsLib.h"
+/**
+ Function for 'reconnect' 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
ShellCommandRunReconnect (
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.c
index b0e15917d8..1673d56880 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.c
@@ -1,7 +1,7 @@
/** @file
Main file for NULL named library for level 1 shell command functions.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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,11 @@ CONST EFI_GUID gShellDriver1HiiGuid = \
0xaf0b742, 0x63ec, 0x45bd, {0x8d, 0xb6, 0x71, 0xad, 0x7f, 0x2f, 0xe8, 0xe8} \
};
+/**
+ Function to return the name of the file containing help if HII will not be used.
+
+ @return The filename.
+**/
CONST CHAR16*
EFIAPI
ShellCommandGetManFileNameDriver1 (
@@ -81,6 +86,9 @@ UefiShellDriver1CommandsLibConstructor (
/**
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
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h
index c5b6a1fbda..656958342e 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.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.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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,6 +12,9 @@
**/
+#if !defined (_UEFI_SHELL_DRIVER1_COMMANDS_LIB_H_)
+#define _UEFI_SHELL_DRIVER1_COMMANDS_LIB_H_
+
#include <Uefi.h>
#include <ShellBase.h>
@@ -199,3 +202,5 @@ ShellCommandRunUnload (
IN EFI_SYSTEM_TABLE *SystemTable
);
+#endif
+
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
index 5db841ef82..0cb8ffc82b 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
Binary files differ
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Unload.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Unload.c
index 239ac4aae2..940f72d89a 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Unload.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Unload.c
@@ -1,7 +1,7 @@
/** @file
Main file for Unload shell Driver1 function.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
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
@@ -145,10 +145,13 @@ ShellCommandRunUnload (
EFI_HANDLE TheHandle;
CONST CHAR16 *Param1;
SHELL_PROMPT_RESPONSE *Resp;
+ UINT64 Value;
ShellStatus = SHELL_SUCCESS;
Package = NULL;
Resp = NULL;
+ Value = 0;
+ TheHandle = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
@@ -179,24 +182,28 @@ ShellCommandRunUnload (
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- if (Param1 == NULL || ConvertHandleIndexToHandle(StrHexToUintn(Param1)) == NULL){
+ Param1 = ShellCommandLineGetRawValue(Package, 1);
+ if (Param1 != NULL) {
+ Status = ShellConvertStringToUint64(Param1, &Value, TRUE, FALSE);
+ TheHandle = ConvertHandleIndexToHandle((UINTN)Value);
+ }
+
+ if (EFI_ERROR(Status) || Param1 == NULL || TheHandle == NULL){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, Param1);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
- TheHandle = ConvertHandleIndexToHandle(StrHexToUintn(Param1));
ASSERT(TheHandle != NULL);
if (ShellCommandLineGetFlag(Package, L"-v") || ShellCommandLineGetFlag(Package, L"-verbose")) {
DumpLoadedImageProtocolInfo(TheHandle);
}
if (!ShellCommandLineGetFlag(Package, L"-n")) {
- Status = ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_UNLOAD_CONF), gShellDriver1HiiHandle, StrHexToUintn(Param1));
+ Status = ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_UNLOAD_CONF), gShellDriver1HiiHandle, (UINTN)TheHandle);
Status = ShellPromptForResponse(ShellPromptResponseTypeYesNo, NULL, (VOID**)&Resp);
}
if (ShellCommandLineGetFlag(Package, L"-n") || (Resp != NULL && *Resp == ShellPromptResponseYes)) {
Status = gBS->UnloadImage(TheHandle);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HANDLE_RESULT), gShellDriver1HiiHandle, L"Unload", StrHexToUintn(Param1), Status);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HANDLE_RESULT), gShellDriver1HiiHandle, L"Unload", (UINTN)TheHandle, Status);
}
SHELL_FREE_NON_NULL(Resp);
}