diff options
author | Guo Mang <mang.guo@intel.com> | 2017-08-02 09:54:47 +0800 |
---|---|---|
committer | Guo Mang <mang.guo@intel.com> | 2017-09-05 19:45:08 +0800 |
commit | 6c128c65b5ec0e5b8b5a0ccb165f3afd29e485f8 (patch) | |
tree | 444372d92a0ae8991fe4d15eb3937df43690dfda /ShellPkg/Library/UefiShellDriver1CommandsLib | |
parent | b207c6434d7a5a4502975d322312e07017e8a8cb (diff) | |
download | edk2-platforms-6c128c65b5ec0e5b8b5a0ccb165f3afd29e485f8.tar.xz |
Remove core packages since we can get them from edk2 repository
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Guo Mang <mang.guo@intel.com>
Diffstat (limited to 'ShellPkg/Library/UefiShellDriver1CommandsLib')
15 files changed, 0 insertions, 5322 deletions
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c deleted file mode 100644 index 5d61c2f601..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c +++ /dev/null @@ -1,551 +0,0 @@ -/** @file
- Main file for connect shell Driver1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2014, 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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "UefiShellDriver1CommandsLib.h"
-
-/**
- Create all handles associate with every device path node.
-
- @param DevicePathToConnect The device path which will be connected.
-
- @retval EFI_SUCCESS All handles associate with every device path node
- have been created.
- @retval EFI_INVALID_PARAMETER DevicePathToConnect is NULL.
- @retval EFI_NOT_FOUND Create the handle associate with one device path
- node failed
-
-**/
-EFI_STATUS
-ShellConnectDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- EFI_HANDLE PreviousHandle;
-
- if (DevicePathToConnect == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- PreviousHandle = NULL;
- do{
- RemainingDevicePath = DevicePathToConnect;
- Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);
-
- if (!EFI_ERROR (Status) && (Handle != NULL)) {
- if (PreviousHandle == Handle) {
- Status = EFI_NOT_FOUND;
- } else {
- PreviousHandle = Handle;
- Status = gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
- }
- }
-
- } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath) );
-
- return Status;
-
-}
-
-/**
- Connect drivers for PCI root bridge.
-
- @retval EFI_SUCCESS Connect drivers successfully.
- @retval EFI_NOT_FOUND Cannot find PCI root bridge device.
-
-**/
-EFI_STATUS
-ShellConnectPciRootBridge (
- VOID
- )
-{
- UINTN RootBridgeHandleCount;
- EFI_HANDLE *RootBridgeHandleBuffer;
- UINTN RootBridgeIndex;
- EFI_STATUS Status;
-
- RootBridgeHandleCount = 0;
-
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiPciRootBridgeIoProtocolGuid,
- NULL,
- &RootBridgeHandleCount,
- &RootBridgeHandleBuffer
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- for (RootBridgeIndex = 0; RootBridgeIndex < RootBridgeHandleCount; RootBridgeIndex++) {
- gBS->ConnectController (RootBridgeHandleBuffer[RootBridgeIndex], NULL, NULL, FALSE);
- }
-
- FreePool (RootBridgeHandleBuffer);
-
- return EFI_SUCCESS;
-}
-
-
-/**
- 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
-ConnectControllers (
- IN CONST EFI_HANDLE ControllerHandle OPTIONAL,
- IN CONST EFI_HANDLE DriverHandle OPTIONAL,
- IN CONST BOOLEAN Recursive,
- IN CONST BOOLEAN Output,
- IN CONST BOOLEAN AlwaysOutput
- )
-{
- EFI_STATUS Status;
- EFI_STATUS Status2;
- EFI_HANDLE *ControllerHandleList;
- EFI_HANDLE *DriverHandleList;
- EFI_HANDLE *HandleWalker;
-
- ControllerHandleList = NULL;
- Status = EFI_NOT_FOUND;
- Status2 = EFI_NOT_FOUND;
-
- //
- // If we have a single handle to connect make that a 'list'
- //
- if (DriverHandle == NULL) {
- DriverHandleList = NULL;
- } else {
- DriverHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
- if (DriverHandleList == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- DriverHandleList[0] = DriverHandle;
- DriverHandleList[1] = NULL;
- }
-
- //
- // do we connect all controllers (with a loop) or a single one...
- // This is where we call the gBS->ConnectController function.
- //
- if (ControllerHandle == NULL) {
- ControllerHandleList = GetHandleListByProtocol(&gEfiDevicePathProtocolGuid);
- for (HandleWalker = ControllerHandleList
- ; HandleWalker != NULL && *HandleWalker != NULL
- ; HandleWalker++
- ){
- Status = gBS->ConnectController(*HandleWalker, DriverHandleList, NULL, Recursive);
- if (!EFI_ERROR(Status)) {
- Status2 = EFI_SUCCESS;
- }
- if ((Output && !EFI_ERROR(Status)) || AlwaysOutput) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_HANDLE_RESULT), gShellDriver1HiiHandle, L"Connect", ConvertHandleToHandleIndex(*HandleWalker), Status);
- }
- }
- } else {
- Status = gBS->ConnectController(ControllerHandle, DriverHandleList, NULL, Recursive);
- if (!EFI_ERROR(Status)) {
- Status2 = EFI_SUCCESS;
- }
- if ((Output && !EFI_ERROR(Status)) || AlwaysOutput) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_HANDLE_RESULT), gShellDriver1HiiHandle, L"Connect", ConvertHandleToHandleIndex(ControllerHandle), Status);
- }
- }
-
- //
- // Free any memory we allocated.
- //
- if (ControllerHandleList != NULL) {
- FreePool(ControllerHandleList);
- }
- if (DriverHandleList != NULL) {
- FreePool(DriverHandleList);
- }
- 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
-ShellConnectFromDevPaths (
- IN CONST CHAR16 *Key
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
- EFI_DEVICE_PATH_PROTOCOL *CopyOfDevPath;
- EFI_DEVICE_PATH_PROTOCOL *Instance;
- EFI_DEVICE_PATH_PROTOCOL *Next;
- UINTN Length;
- UINTN Index;
- UINTN HandleArrayCount;
- UINTN Size;
- EFI_HANDLE *HandleArray;
- EFI_STATUS Status;
- BOOLEAN AtLeastOneConnected;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT8 Class[3];
-
- DevPath = NULL;
- Length = 0;
- AtLeastOneConnected = FALSE;
-
- //
- // Get the DevicePath buffer from the variable...
- //
- Status = gRT->GetVariable((CHAR16*)Key, (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, DevPath);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- DevPath = AllocateZeroPool(Length);
- if (DevPath == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- Status = gRT->GetVariable((CHAR16*)Key, (EFI_GUID*)&gEfiGlobalVariableGuid, NULL, &Length, DevPath);
- if (EFI_ERROR (Status)) {
- if (DevPath != NULL) {
- FreePool (DevPath);
- }
- return Status;
- }
- } else if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = EFI_NOT_FOUND;
-
- CopyOfDevPath = DevPath;
- //
- // walk the list of devices and connect them
- //
- do {
- //
- // Check every instance of the console variable
- //
- Instance = GetNextDevicePathInstance (&CopyOfDevPath, &Size);
- if (Instance == NULL) {
- if (DevPath != NULL) {
- FreePool (DevPath);
- }
- return EFI_UNSUPPORTED;
- }
-
- Next = Instance;
- while (!IsDevicePathEndType (Next)) {
- Next = NextDevicePathNode (Next);
- }
-
- SetDevicePathEndNode (Next);
- //
- // connect short form device path
- //
- if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&
- ((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)
- || (DevicePathSubType (Instance) == MSG_USB_WWID_DP)
- )) {
-
- Status = ShellConnectPciRootBridge ();
- if (EFI_ERROR(Status)) {
- FreePool(Instance);
- FreePool(DevPath);
- return Status;
- }
-
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiPciIoProtocolGuid,
- NULL,
- &HandleArrayCount,
- &HandleArray
- );
-
- if (!EFI_ERROR (Status)) {
- for (Index = 0; Index < HandleArrayCount; Index++) {
- Status = gBS->HandleProtocol (
- HandleArray[Index],
- &gEfiPciIoProtocolGuid,
- (VOID **)&PciIo
- );
-
- if (!EFI_ERROR (Status)) {
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
- if (!EFI_ERROR (Status)) {
- if ((PCI_CLASS_SERIAL == Class[2]) &&
- (PCI_CLASS_SERIAL_USB == Class[1])) {
- Status = gBS->ConnectController (
- HandleArray[Index],
- NULL,
- Instance,
- FALSE
- );
- if (!EFI_ERROR(Status)) {
- AtLeastOneConnected = TRUE;
- }
- }
- }
- }
- }
- }
-
- if (HandleArray != NULL) {
- FreePool (HandleArray);
- }
- } else {
- //
- // connect the entire device path
- //
- Status = ShellConnectDevicePath (Instance);
- if (!EFI_ERROR (Status)) {
- AtLeastOneConnected = TRUE;
- }
- }
- FreePool (Instance);
-
- } while (CopyOfDevPath != NULL);
-
- if (DevPath != NULL) {
- FreePool(DevPath);
- }
-
- if (AtLeastOneConnected) {
- return EFI_SUCCESS;
- } else {
- return EFI_NOT_FOUND;
- }
-
-}
-
-/**
- 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 EFI_HANDLE *Handle1 OPTIONAL,
- IN EFI_HANDLE *Handle2 OPTIONAL,
- IN CONST BOOLEAN Recursive,
- IN CONST BOOLEAN Output
- )
-{
- //
- // if only one is NULL verify it's the proper one...
- //
- if ( (Handle1 == NULL && Handle2 != NULL)
- || (Handle1 != NULL && Handle2 == NULL)
- ){
- //
- // Figure out which one should be NULL and move the handle to the right place.
- // If Handle1 is NULL then test Handle2 and vise versa.
- // The one that DOES has driver binding must be Handle2
- //
- if (Handle1 == NULL) {
- if (EFI_ERROR(gBS->OpenProtocol(Handle2, &gEfiDriverBindingProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- // swap
- Handle1 = Handle2;
- Handle2 = NULL;
- } else {
- // We're all good...
- }
- } else {
- if (EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiDriverBindingProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- // We're all good...
- } else {
- // swap
- Handle2 = Handle1;
- Handle1 = NULL;
- }
- }
- }
-
- return (ConnectControllers(Handle1, Handle2, Recursive, Output, (BOOLEAN)(Handle2 != NULL && Handle1 != NULL)));
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-c", TypeFlag},
- {L"-r", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'connect' 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
-ShellCommandRunConnect (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Param1;
- CONST CHAR16 *Param2;
- UINTN Count;
- EFI_HANDLE Handle1;
- EFI_HANDLE Handle2;
- UINT64 Intermediate;
-
- ShellStatus = SHELL_SUCCESS;
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- 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), gShellDriver1HiiHandle, L"connect", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // if more than 2 'value' parameters (plus the name one) or either -r or -c with any value parameters we have too many parameters
- //
- Count = (gInReconnect?0x4:0x3);
- if ((ShellCommandLineGetCount(Package) > Count)
- ||((ShellCommandLineGetFlag(Package, L"-r") || ShellCommandLineGetFlag(Package, L"-c")) && ShellCommandLineGetCount(Package)>1)
- ||(ShellCommandLineGetFlag(Package, L"-r") && ShellCommandLineGetFlag(Package, L"-c") )
- ){
- //
- // error for too many parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"connect");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-c")) {
- //
- // do the conin and conout from EFI variables
- // if the first fails dont 'loose' the error
- //
- Status = ShellConnectFromDevPaths(L"ConInDev");
- if (EFI_ERROR(Status)) {
- ShellConnectFromDevPaths(L"ConOutDev");
- } else {
- Status = ShellConnectFromDevPaths(L"ConOutDev");
- }
- if (EFI_ERROR(Status)) {
- ShellConnectFromDevPaths(L"ErrOutDev");
- } else {
- Status = ShellConnectFromDevPaths(L"ErrOutDev");
- }
- if (EFI_ERROR(Status)) {
- ShellConnectFromDevPaths(L"ErrOut");
- } else {
- Status = ShellConnectFromDevPaths(L"ErrOut");
- }
- if (EFI_ERROR(Status)) {
- ShellConnectFromDevPaths(L"ConIn");
- } else {
- Status = ShellConnectFromDevPaths(L"ConIn");
- }
- if (EFI_ERROR(Status)) {
- ShellConnectFromDevPaths(L"ConOut");
- } else {
- Status = ShellConnectFromDevPaths(L"ConOut");
- }
- if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else {
- //
- // 0, 1, or 2 specific handles and possibly recursive
- //
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- Param2 = ShellCommandLineGetRawValue(Package, 2);
- Count = ShellCommandLineGetCount(Package);
-
- if (Param1 != NULL) {
- 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, L"connect", Param1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- } else {
- Handle1 = NULL;
- }
-
- if (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, L"connect", Param2);
- ShellStatus = SHELL_INVALID_PARAMETER;
- }
- } else {
- Handle2 = NULL;
- }
-
- if (ShellStatus == SHELL_SUCCESS) {
- if (Param1 != NULL && Handle1 == NULL){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"connect", Param1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (Param2 != NULL && Handle2 == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"connect", Param2);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (Handle2 != NULL && Handle1 != NULL && EFI_ERROR(gBS->OpenProtocol(Handle2, &gEfiDriverBindingProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"connect", 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;
- }
- }
- }
- }
-
- ShellCommandLineFreeVarList (Package);
- }
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c deleted file mode 100644 index fb9de10a54..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c +++ /dev/null @@ -1,277 +0,0 @@ -/** @file
- Main file for DevTree shell Driver1 function.
-
- (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2012, 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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-d", TypeFlag},
- {L"-l", TypeValue},
- {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(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST CHAR8 *Lang OPTIONAL,
- IN CONST BOOLEAN UseDevPaths,
- IN CONST UINTN IndentCharCount,
- IN CONST CHAR16 *HiiString
- )
-{
- SHELL_STATUS ShellStatus;
- EFI_STATUS Status;
- CHAR16 *FormatString;
- CHAR16 *Name;
- EFI_HANDLE *ChildHandleBuffer;
- UINTN ChildCount;
- UINTN LoopVar;
-
- Status = EFI_SUCCESS;
- ShellStatus = SHELL_SUCCESS;
- Name = NULL;
- ChildHandleBuffer = NULL;
- ChildCount = 0;
-
- ASSERT(TheHandle != NULL);
-
- if (ShellGetExecutionBreakFlag()) {
- ShellStatus = SHELL_ABORTED;
- return ShellStatus;
- }
-
- //
- // We want controller handles. they will not have LoadedImage or DriverBinding (or others...)
- //
- Status = gBS->OpenProtocol (
- TheHandle,
- &gEfiDriverBindingProtocolGuid,
- NULL,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- return SHELL_SUCCESS;
- }
-
- Status = gBS->OpenProtocol (
- TheHandle,
- &gEfiLoadedImageProtocolGuid,
- NULL,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- return SHELL_SUCCESS;
- }
-
- FormatString = AllocateZeroPool(StrSize(HiiString) + (10)*sizeof(FormatString[0]));
-
- ASSERT(HiiString != NULL);
- ASSERT(FormatString != NULL);
-
- //
- // we generate the format string on the fly so that we can control the
- // number of space characters that the first (empty) string has. this
- // handles the indenting.
- //
-
- UnicodeSPrint(FormatString, StrSize(HiiString) + (10)*sizeof(FormatString[0]), L"%%%ds %s", IndentCharCount, HiiString);
- gEfiShellProtocol->GetDeviceName((EFI_HANDLE)TheHandle, !UseDevPaths?EFI_DEVICE_NAME_USE_COMPONENT_NAME|EFI_DEVICE_NAME_USE_DEVICE_PATH:EFI_DEVICE_NAME_USE_DEVICE_PATH, (CHAR8*)Lang, &Name);
- //
- // print out the information for ourselves
- //
- ShellPrintEx(
- -1,
- -1,
- FormatString,
- L"",
- ConvertHandleToHandleIndex(TheHandle),
- Name==NULL?L"Unknown":Name);
-
- FreePool(FormatString);
- if (Name != NULL) {
- FreePool(Name);
- }
-
- //
- // recurse on each child handle with IndentCharCount + 2
- //
- ParseHandleDatabaseForChildControllers(TheHandle, &ChildCount, &ChildHandleBuffer);
- for (LoopVar = 0 ; LoopVar < ChildCount && ShellStatus == SHELL_SUCCESS; LoopVar++){
- ShellStatus = DoDevTreeForHandle(ChildHandleBuffer[LoopVar], Lang, UseDevPaths, IndentCharCount+2, HiiString);
- if (ShellStatus == SHELL_ABORTED) {
- break;
- }
- }
-
- if (ChildHandleBuffer != NULL) {
- FreePool(ChildHandleBuffer);
- }
-
- return (ShellStatus);
-}
-
-/**
- Function for 'devtree' 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
-ShellCommandRunDevTree (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CHAR8 *Language;
- CONST CHAR16 *Lang;
- CHAR16 *HiiString;
- UINTN LoopVar;
- EFI_HANDLE TheHandle;
- BOOLEAN FlagD;
- UINT64 Intermediate;
- UINTN ParentControllerHandleCount;
- EFI_HANDLE *ParentControllerHandleBuffer;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- Language = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- 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), gShellDriver1HiiHandle, L"devtree", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"devtree");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- }
- Lang = ShellCommandLineGetValue(Package, L"-l");
- if (Lang != NULL) {
- Language = AllocateZeroPool(StrSize(Lang));
- AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
- } else if (!ShellCommandLineGetFlag(Package, L"-l")){
- ASSERT(Language == NULL);
-// Language = AllocateZeroPool(10);
-// AsciiSPrint(Language, 10, "en-us");
- } else {
- ASSERT(Language == NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"devtree", L"-l");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- }
- FlagD = ShellCommandLineGetFlag(Package, L"-d");
-
- Lang = ShellCommandLineGetRawValue(Package, 1);
- HiiString = HiiGetString(gShellDriver1HiiHandle, STRING_TOKEN (STR_DEV_TREE_OUTPUT), Language);
-
- if (Lang == NULL) {
- for (LoopVar = 1 ; ; LoopVar++){
- TheHandle = ConvertHandleIndexToHandle(LoopVar);
- if (TheHandle == NULL){
- break;
- }
-
- //
- // Skip handles that do not have device path protocol
- //
- Status = gBS->OpenProtocol (
- TheHandle,
- &gEfiDevicePathProtocolGuid,
- NULL,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- //
- // Skip handles that do have parents
- //
- ParentControllerHandleBuffer = NULL;
- Status = PARSE_HANDLE_DATABASE_PARENTS (
- TheHandle,
- &ParentControllerHandleCount,
- &ParentControllerHandleBuffer
- );
- SHELL_FREE_NON_NULL (ParentControllerHandleBuffer);
- if (ParentControllerHandleCount > 0) {
- continue;
- }
-
- //
- // Start a devtree from TheHandle that has a device path and no parents
- //
- ShellStatus = DoDevTreeForHandle(TheHandle, Language, FlagD, 0, HiiString);
- }
- } else {
- 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, L"devtree", Lang);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ShellStatus = DoDevTreeForHandle(ConvertHandleIndexToHandle((UINTN)Intermediate), Language, FlagD, 0, HiiString);
- }
- }
-
- if (HiiString != NULL) {
- FreePool(HiiString);
- }
- SHELL_FREE_NON_NULL(Language);
- ShellCommandLineFreeVarList (Package);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Devices.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Devices.c deleted file mode 100644 index d229b352c8..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Devices.c +++ /dev/null @@ -1,270 +0,0 @@ -/** @file
- Main file for devices shell Driver1 function.
-
- (C) Copyright 2012-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2014, 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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#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 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
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN Count;
-
- if (TheHandle == NULL
- || Type == NULL
- || Cfg == NULL
- || Diag == NULL
- || Parents == NULL
- || Devices == NULL
- || Children == NULL
- || Name == NULL ) {
- return (EFI_INVALID_PARAMETER);
- }
-
- *Cfg = FALSE;
- *Diag = FALSE;
- *Children = 0;
- *Parents = 0;
- *Devices = 0;
- *Type = L' ';
- *Name = CHAR_NULL;
- HandleBuffer = NULL;
- Status = EFI_SUCCESS;
-
- 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)) {
- Status = PARSE_HANDLE_DATABASE_PARENTS(TheHandle, Parents, NULL);
- if (/*!EFI_ERROR(Status) && */Parents != NULL && Children != NULL) {
- if (*Parents == 0) {
- *Type = L'R';
- } else if (*Children > 0) {
- *Type = L'B';
- } else {
- *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++) {
- if (!EFI_ERROR(gBS->OpenProtocol(HandleBuffer[Count], &gEfiDriverConfigurationProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- *Cfg = TRUE;
- }
- if (!EFI_ERROR(gBS->OpenProtocol(HandleBuffer[Count], &gEfiDriverDiagnosticsProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- *Diag = TRUE;
- }
- if (!EFI_ERROR(gBS->OpenProtocol(HandleBuffer[Count], &gEfiDriverDiagnostics2ProtocolGuid, NULL, NULL, gImageHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- *Diag = TRUE;
- }
- }
- SHELL_FREE_NON_NULL(HandleBuffer);
- }
-
- return (Status);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-sfo", TypeFlag},
- {L"-l", TypeValue},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'devices' 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
-ShellCommandRunDevices (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CHAR8 *Language;
- EFI_HANDLE *HandleList;
- EFI_HANDLE *HandleListWalker;
- CHAR16 Type;
- BOOLEAN Cfg;
- BOOLEAN Diag;
- UINTN Parents;
- UINTN Devices;
- UINTN Children;
- CHAR16 *Name;
- CONST CHAR16 *Lang;
- BOOLEAN SfoFlag;
-
- ShellStatus = SHELL_SUCCESS;
- Language = NULL;
- SfoFlag = FALSE;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- 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), gShellDriver1HiiHandle, L"devices", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // if more than 0 'value' parameters we have too many parameters
- //
- if (ShellCommandLineGetRawValue(Package, 1) != NULL){
- //
- // error for too many parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"devices");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // get the language if necessary
- //
- Lang = ShellCommandLineGetValue(Package, L"-l");
- if (Lang != NULL) {
- Language = AllocateZeroPool(StrSize(Lang));
- AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
- } else if (!ShellCommandLineGetFlag(Package, L"-l")){
- ASSERT(Language == NULL);
-// Language = AllocateZeroPool(10);
-// AsciiSPrint(Language, 10, "en-us");
- } else {
- ASSERT(Language == NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"devices", L"-l");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- }
-
-
- //
- // Print Header
-
- //
- if (ShellCommandLineGetFlag (Package, L"-sfo")) {
- ShellPrintHiiEx (-1, -1, Language, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellDriver1HiiHandle, L"devices");
- SfoFlag = TRUE;
- } else {
- ShellPrintHiiEx (-1, -1, Language, STRING_TOKEN (STR_DEVICES_HEADER_LINES), gShellDriver1HiiHandle);
- }
-
- //
- // loop through each handle
- //
- HandleList = GetHandleListByProtocol(NULL);
- ASSERT(HandleList != NULL);
- for (HandleListWalker = HandleList
- ; HandleListWalker != NULL && *HandleListWalker != NULL /*&& !EFI_ERROR(Status)*/
- ; HandleListWalker++
- ){
-
- //
- // get all the info on each handle
- //
- Name = NULL;
- Status = GetDeviceHandleInfo(*HandleListWalker, &Type, &Cfg, &Diag, &Parents, &Devices, &Children, &Name, Language);
- if (Name != NULL && (Parents != 0 || Devices != 0 || Children != 0)) {
- ShellPrintHiiEx (
- -1,
- -1,
- Language,
- SfoFlag?STRING_TOKEN (STR_DEVICES_ITEM_LINE_SFO):STRING_TOKEN (STR_DEVICES_ITEM_LINE),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex (*HandleListWalker),
- Type,
- Cfg?(SfoFlag?L'Y':L'X'):(SfoFlag?L'N':L'-'),
- Diag?(SfoFlag?L'Y':L'X'):(SfoFlag?L'N':L'-'),
- Parents,
- Devices,
- Children,
- Name!=NULL?Name:L"<UNKNOWN>");
- }
- if (Name != NULL) {
- FreePool(Name);
- }
- if (ShellGetExecutionBreakFlag ()) {
- ShellStatus = SHELL_ABORTED;
- break;
- }
-
- }
-
- if (HandleList != NULL) {
- FreePool(HandleList);
- }
-
- }
- SHELL_FREE_NON_NULL(Language);
- ShellCommandLineFreeVarList (Package);
- }
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c deleted file mode 100644 index 0a1b9a9206..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c +++ /dev/null @@ -1,984 +0,0 @@ -/** @file
- Main file for Dh shell Driver1 function.
-
- (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2014, 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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-p", TypeValue},
- {L"-d", TypeFlag},
- {L"-v", TypeFlag},
- {L"-verbose", TypeFlag},
- {L"-sfo", TypeFlag},
- {L"-l", TypeValue},
- {NULL, TypeMax}
- };
-
-STATIC CONST EFI_GUID *UefiDriverModelProtocolsGuidArray[] = {
- &gEfiDriverBindingProtocolGuid,
- &gEfiPlatformDriverOverrideProtocolGuid,
- &gEfiBusSpecificDriverOverrideProtocolGuid,
- &gEfiDriverDiagnosticsProtocolGuid,
- &gEfiDriverDiagnostics2ProtocolGuid,
- &gEfiComponentNameProtocolGuid,
- &gEfiComponentName2ProtocolGuid,
- &gEfiPlatformToDriverConfigurationProtocolGuid,
- &gEfiDriverSupportedEfiVersionProtocolGuid,
- &gEfiDriverFamilyOverrideProtocolGuid,
- &gEfiDriverHealthProtocolGuid,
- &gEfiLoadedImageProtocolGuid,
- 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;
- 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);
- }
- Lang = GetBestLanguageForDriver (CompName2->SupportedLanguages, Language, FALSE);
- 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 (
- IN CONST EFI_GUID *Guid
- )
-{
- CONST EFI_GUID **GuidWalker;
- BOOLEAN GuidFound;
- GuidFound = FALSE;
- for (GuidWalker = UefiDriverModelProtocolsGuidArray
- ; GuidWalker != NULL && *GuidWalker != NULL
- ; GuidWalker++
- ){
- if (CompareGuid(*GuidWalker, Guid)) {
- GuidFound = TRUE;
- break;
- }
- }
- 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 Verbose,
- IN CONST BOOLEAN ExtraInfo
- )
-{
- EFI_GUID **ProtocolGuidArray;
- UINTN ArrayCount;
- UINTN ProtocolIndex;
- EFI_STATUS Status;
- CHAR16 *RetVal;
- UINTN Size;
- CHAR16 *Temp;
-
- ProtocolGuidArray = NULL;
- RetVal = NULL;
- Size = 0;
-
- Status = gBS->ProtocolsPerHandle (
- TheHandle,
- &ProtocolGuidArray,
- &ArrayCount
- );
- if (!EFI_ERROR (Status)) {
- for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
- Temp = GetStringNameFromGuid(ProtocolGuidArray[ProtocolIndex], Language);
- if (Temp != NULL) {
- ASSERT((RetVal == NULL && Size == 0) || (RetVal != NULL));
- if (Size != 0) {
- StrnCatGrow(&RetVal, &Size, Seperator, 0);
- }
- StrnCatGrow(&RetVal, &Size, L"%H", 0);
- StrnCatGrow(&RetVal, &Size, Temp, 0);
- StrnCatGrow(&RetVal, &Size, L"%N", 0);
- FreePool(Temp);
- }
- if (ExtraInfo) {
- Temp = GetProtocolInformationDump(TheHandle, ProtocolGuidArray[ProtocolIndex], Verbose);
- if (Temp != NULL) {
- ASSERT((RetVal == NULL && Size == 0) || (RetVal != NULL));
- if (!Verbose) {
- StrnCatGrow(&RetVal, &Size, L"(", 0);
- StrnCatGrow(&RetVal, &Size, Temp, 0);
- StrnCatGrow(&RetVal, &Size, L")\r\n", 0);
- } else {
- StrnCatGrow(&RetVal, &Size, Seperator, 0);
- StrnCatGrow(&RetVal, &Size, Temp, 0);
- }
- FreePool(Temp);
- }
- }
- }
- }
-
- SHELL_FREE_NON_NULL(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 = 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;
-
- DriverName = NULL;
-
- //
- // 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 = 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 (EFI_ERROR (Status)) {
- Status = GetDriverImageName (
- DriverBindingHandleBuffer[Index],
- &DriverName
- );
- if (EFI_ERROR (Status)) {
- DriverName = NULL;
- }
- }
-
- 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);
- if (EFI_ERROR (Status)) {
- DriverName = NULL;
- }
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_DRIVER6B),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex(Handle),
- DriverName!=NULL?DriverName:L"<Unknown>"
- );
- SHELL_FREE_NON_NULL(DriverName);
- Status = GetDriverImageName (
- Handle,
- &DriverName
- );
- if (EFI_ERROR (Status)) {
- DriverName = NULL;
- }
- 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(
- IN CONST EFI_HANDLE TheHandle,
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN Sfo,
- IN CONST CHAR8 *Language,
- IN CONST BOOLEAN DriverInfo,
- IN CONST BOOLEAN Multiple
- )
-{
- CHAR16 *ProtocolInfoString;
- SHELL_STATUS ShellStatus;
-
- ShellStatus = SHELL_SUCCESS;
- ProtocolInfoString = NULL;
-
- if (!Sfo) {
- if (Multiple) {
- ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L" ", Verbose, TRUE);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex(TheHandle),
- ProtocolInfoString==NULL?L"":ProtocolInfoString);
- } else {
- ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L"\r\n", Verbose, TRUE);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_SINGLE),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex(TheHandle),
- TheHandle,
- ProtocolInfoString==NULL?L"":ProtocolInfoString);
- }
-
- if (DriverInfo) {
- DisplayDriverModelHandle ((EFI_HANDLE)TheHandle, TRUE, Language);
- }
- } else {
- ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L";", FALSE, FALSE);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DH_OUTPUT_SFO),
- gShellDriver1HiiHandle,
- Multiple ?L"HandlesInfo":L"HandleInfo",
- L"DriverName",
- L"ControllerName",
- ConvertHandleToHandleIndex(TheHandle),
- L"DevPath",
- ProtocolInfoString==NULL?L"":ProtocolInfoString);
-
-
- }
-
-
- if (ProtocolInfoString != NULL) {
- FreePool(ProtocolInfoString);
- }
- return (ShellStatus);
-}
-
-/**
- Display information for all handles on a list.
-
- @param[in] HandleList The NULL-terminated list of handles.
- @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.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
-**/
-SHELL_STATUS
-EFIAPI
-DoDhForHandleList(
- IN CONST EFI_HANDLE *HandleList,
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN Sfo,
- IN CONST CHAR8 *Language,
- IN CONST BOOLEAN DriverInfo
- )
-{
- CONST EFI_HANDLE *HandleWalker;
- SHELL_STATUS ShellStatus;
-
- ShellStatus = SHELL_SUCCESS;
-
- for (HandleWalker = HandleList ; HandleWalker != NULL && *HandleWalker != NULL && ShellStatus == SHELL_SUCCESS; HandleWalker++) {
- ShellStatus = DoDhByHandle(
- *HandleWalker,
- Verbose,
- Sfo,
- Language,
- DriverInfo,
- TRUE
- );
- if (ShellGetExecutionBreakFlag ()) {
- ShellStatus = SHELL_ABORTED;
- break;
- }
- }
- return (ShellStatus);
-}
-
-/**
- Display information for all handles.
-
- @param[in] Sfo TRUE to output in standard format output (spec).
- @param[in] Verbose TRUE for extra info, FALSE otherwise.
- @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(
- IN CONST BOOLEAN Sfo,
- IN CONST BOOLEAN Verbose,
- IN CONST CHAR8 *Language,
- IN CONST BOOLEAN DriverInfo
- )
-{
- EFI_HANDLE *HandleList;
- SHELL_STATUS ShellStatus;
-
- HandleList = GetHandleListByProtocol(NULL);
-
- ShellStatus = DoDhForHandleList(
- HandleList,
- Verbose,
- Sfo,
- Language,
- DriverInfo);
-
- FreePool(HandleList);
-
- 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] 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.
-
- @retval SHELL_SUCCESS The operation was successful.
- @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
-**/
-SHELL_STATUS
-EFIAPI
-DoDhByProtocol(
- IN CONST CHAR16 *ProtocolName,
- IN CONST BOOLEAN Verbose,
- IN CONST BOOLEAN Sfo,
- IN CONST CHAR8 *Language,
- IN CONST BOOLEAN DriverInfo
- )
-{
- EFI_GUID *Guid;
- EFI_STATUS Status;
- EFI_HANDLE *HandleList;
- SHELL_STATUS ShellStatus;
-
- if (ProtocolName == NULL) {
- return (SHELL_INVALID_PARAMETER);
- }
-
- Status = GetGuidFromStringName(ProtocolName, Language, &Guid);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DH_NO_GUID_FOUND), gShellDriver1HiiHandle, ProtocolName);
- return (SHELL_INVALID_PARAMETER);
- }
-
- HandleList = GetHandleListByProtocol(Guid);
-
- ShellStatus = DoDhForHandleList(
- HandleList,
- Verbose,
- Sfo,
- Language,
- DriverInfo);
-
- SHELL_FREE_NON_NULL(HandleList);
-
- 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 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CHAR8 *Language;
- CONST CHAR16 *Lang;
- CONST CHAR16 *Temp2;
- BOOLEAN SfoMode;
- BOOLEAN FlagD;
- BOOLEAN Verbose;
- UINT64 Intermediate;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- Language = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- 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), gShellDriver1HiiHandle, L"dh", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"dh");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- }
-
- 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 {
- ASSERT(Language == NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"dh", L"-l");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- }
-
- SfoMode = ShellCommandLineGetFlag(Package, L"-sfo");
- FlagD = ShellCommandLineGetFlag(Package, L"-d");
- Verbose = (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-v") || ShellCommandLineGetFlag(Package, L"-verbose"));
-
- if (ShellCommandLineGetFlag(Package, L"-p")) {
- if (ShellCommandLineGetCount(Package) > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"dh");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetValue(Package, L"-p") == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"dh", L"-p");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // print by protocol
- //
- ShellStatus = DoDhByProtocol(
- ShellCommandLineGetValue(Package, L"-p"),
- Verbose,
- SfoMode,
- Lang==NULL?NULL:Language,
- FlagD
- );
- }
- } else {
- Temp2 = ShellCommandLineGetRawValue(Package, 1);
- if (Temp2 == NULL) {
- //
- // Print everything
- //
- ShellStatus = DoDhForAll(
- SfoMode,
- Verbose,
- Lang==NULL?NULL:Language,
- FlagD
- );
- } else {
- 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, L"dh", Temp2);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // print 1 handle
- //
- ShellStatus = DoDhByHandle(
- ConvertHandleIndexToHandle((UINTN)Intermediate),
- Verbose,
- SfoMode,
- Lang==NULL?NULL:Language,
- FlagD,
- FALSE
- );
- }
- }
- }
-
-
- ShellCommandLineFreeVarList (Package);
- SHELL_FREE_NON_NULL(Language);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c deleted file mode 100644 index 9afbf07329..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c +++ /dev/null @@ -1,189 +0,0 @@ -/** @file
- Main file for Disconnect shell Driver1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2012, 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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-r", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Disconnect everything.
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-DisconnectAll(
- VOID
- )
-{
- //
- // Stolen from UEFI 2.3 spec (May 2009 version)
- // Pages 171/172
- // Removed gBS local definition
- //
-
- //
- // Disconnect All Handles Example
- // The following example recusively disconnects all drivers from all
- // controllers in a platform.
- //
- EFI_STATUS Status;
-// EFI_BOOT_SERVICES *gBS;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN HandleIndex;
- //
- // Retrieve the list of all handles from the handle database
- //
- Status = gBS->LocateHandleBuffer (
- AllHandles,
- NULL,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
- if (!EFI_ERROR (Status)) {
- for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
- Status = gBS->DisconnectController (
- HandleBuffer[HandleIndex],
- NULL,
- NULL
- );
- }
- gBS->FreePool(HandleBuffer);
- //
- // end of stealing
- //
- }
- 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 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Param1;
- CONST CHAR16 *Param2;
- CONST CHAR16 *Param3;
- EFI_HANDLE Handle1;
- EFI_HANDLE Handle2;
- EFI_HANDLE Handle3;
- UINT64 Intermediate1;
- UINT64 Intermediate2;
- UINT64 Intermediate3;
-
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- 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), gShellDriver1HiiHandle, L"disconnect", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetFlag(Package, L"-r")){
- if (ShellCommandLineGetCount(Package) > 1){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"disconnect");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) < 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle, L"disconnect");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Status = DisconnectAll();
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 4){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"disconnect");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) < 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle, L"disconnect");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- //
- // must have between 1 and 3 handles passed in ...
- //
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- Param2 = ShellCommandLineGetRawValue(Package, 2);
- Param3 = ShellCommandLineGetRawValue(Package, 3);
- 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, L"disconnect", Param1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (Param2 != NULL && Handle2 == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"disconnect", Param2);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (Param3 != NULL && Handle3 == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"disconnect", Param3);
- 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, L"disconnect", ShellStrToUintn(Param2), L"driver handle");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(Param1 != NULL);
- Status = gBS->DisconnectController(Handle1, Handle2, Handle3);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_3P_RESULT), gShellDriver1HiiHandle, L"Disconnect", (UINTN)Intermediate1, (UINTN)Intermediate2, (UINTN)Intermediate3, Status);
- }
- }
- }
- }
- if (ShellStatus == SHELL_SUCCESS) {
- if (Status == EFI_SECURITY_VIOLATION) {
- ShellStatus = SHELL_SECURITY_VIOLATION;
- } else if (Status == EFI_INVALID_PARAMETER) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c deleted file mode 100644 index d6d75f0625..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Drivers.c +++ /dev/null @@ -1,321 +0,0 @@ -/** @file
- Main file for Drivers shell Driver1 function.
-
- (C) Copyright 2012-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2015, 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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "UefiShellDriver1CommandsLib.h"
-
-#define MAX_LEN_DRIVER_NAME 35
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-sfo", TypeFlag},
- {L"-l", TypeValue},
- {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(
- IN EFI_HANDLE TheHandle
- )
-{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *FinalPath;
- CHAR16 *RetVal;
-
- FinalPath = NULL;
-
- 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)) {
- FinalPath = AppendDevicePath (ImageDevicePath, LoadedImage->FilePath);
- gBS->CloseProtocol(
- LoadedImage->DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- gImageHandle,
- NULL);
- }
- gBS->CloseProtocol(
- TheHandle,
- &gEfiLoadedImageProtocolGuid,
- gImageHandle,
- NULL);
- }
-
- if (FinalPath == NULL) {
- return (NULL);
- }
- RetVal = gEfiShellProtocol->GetFilePathFromDevicePath(FinalPath);
- if (RetVal == NULL) {
- RetVal = ConvertDevicePathToText(FinalPath, TRUE, TRUE);
- }
- FreePool(FinalPath);
- 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(
- IN CONST EFI_HANDLE TheHandle
- )
-{
- EFI_STATUS Status;
- Status = gBS->OpenProtocol((EFI_HANDLE)TheHandle, &gEfiDriverConfigurationProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL);
- if (EFI_ERROR(Status)) {
- return (FALSE);
- }
- 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(
- IN CONST EFI_HANDLE TheHandle
- )
-{
- EFI_STATUS Status;
- Status = gBS->OpenProtocol((EFI_HANDLE)TheHandle, &gEfiDriverDiagnostics2ProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL);
- if (EFI_ERROR(Status)) {
- Status = gBS->OpenProtocol((EFI_HANDLE)TheHandle, &gEfiDriverDiagnosticsProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL);
- if (EFI_ERROR(Status)) {
- return (FALSE);
- }
- }
- 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(
- IN CONST EFI_HANDLE TheHandle
- )
-{
- EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
- EFI_STATUS Status;
- UINT32 RetVal;
-
- RetVal = (UINT32)-1;
-
- Status = gBS->OpenProtocol((EFI_HANDLE)TheHandle, &gEfiDriverBindingProtocolGuid, (VOID**)&DriverBinding, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status)) {
- RetVal = DriverBinding->Version;
- gBS->CloseProtocol(TheHandle, &gEfiDriverBindingProtocolGuid, gImageHandle, NULL);
- }
- 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 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CHAR8 *Language;
- CONST CHAR16 *Lang;
- EFI_HANDLE *HandleList;
- EFI_HANDLE *HandleWalker;
- UINTN ChildCount;
- UINTN DeviceCount;
- CHAR16 *Temp2;
- CONST CHAR16 *FullDriverName;
- CHAR16 *TruncatedDriverName;
- CHAR16 *FormatString;
- UINT32 DriverVersion;
- BOOLEAN DriverConfig;
- BOOLEAN DriverDiag;
- BOOLEAN SfoFlag;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- Language = NULL;
- FormatString = NULL;
- SfoFlag = FALSE;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- 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), gShellDriver1HiiHandle, L"drivers", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"drivers");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (ShellCommandLineGetFlag(Package, L"-l")){
- Lang = ShellCommandLineGetValue(Package, L"-l");
- if (Lang != NULL) {
- Language = AllocateZeroPool(StrSize(Lang));
- AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
- } else {
- ASSERT(Language == NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drivers", L"-l");
- ShellCommandLineFreeVarList (Package);
- return (SHELL_INVALID_PARAMETER);
- }
- }
-
- if (ShellCommandLineGetFlag (Package, L"-sfo")) {
- SfoFlag = TRUE;
- FormatString = HiiGetString (gShellDriver1HiiHandle, STRING_TOKEN (STR_DRIVERS_ITEM_LINE_SFO), Language);
- //
- // print the SFO header
- //
- ShellPrintHiiEx (
- -1,
- -1,
- Language,
- STRING_TOKEN (STR_GEN_SFO_HEADER),
- gShellDriver1HiiHandle,
- L"drivers");
- } else {
- FormatString = HiiGetString (gShellDriver1HiiHandle, STRING_TOKEN (STR_DRIVERS_ITEM_LINE), Language);
- //
- // print the header row
- //
- ShellPrintHiiEx(
- -1,
- -1,
- Language,
- STRING_TOKEN (STR_DRIVERS_HEADER_LINES),
- gShellDriver1HiiHandle);
- }
-
- HandleList = GetHandleListByProtocol(&gEfiDriverBindingProtocolGuid);
- for (HandleWalker = HandleList ; HandleWalker != NULL && *HandleWalker != NULL ; HandleWalker++){
- ChildCount = 0;
- DeviceCount = 0;
- Status = ParseHandleDatabaseForChildDevices (*HandleWalker, &ChildCount , NULL);
- Status = PARSE_HANDLE_DATABASE_DEVICES (*HandleWalker, &DeviceCount, NULL);
- Temp2 = GetDevicePathTextForHandle(*HandleWalker);
- DriverVersion = ReturnDriverVersion(*HandleWalker);
- DriverConfig = ReturnDriverConfig(*HandleWalker);
- DriverDiag = ReturnDriverDiag (*HandleWalker);
- FullDriverName = GetStringNameFromHandle(*HandleWalker, Language);
-
- TruncatedDriverName = NULL;
- if (!SfoFlag && (FullDriverName != NULL)) {
- TruncatedDriverName = AllocateZeroPool ((MAX_LEN_DRIVER_NAME + 1) * sizeof (CHAR16));
- StrnCpyS (TruncatedDriverName, MAX_LEN_DRIVER_NAME + 1, FullDriverName, MAX_LEN_DRIVER_NAME);
- }
-
- ShellPrintEx(
- -1,
- -1,
- FormatString,
- ConvertHandleToHandleIndex(*HandleWalker),
- DriverVersion,
- ChildCount > 0?L'B':(DeviceCount > 0?L'D':L'?'),
- DriverConfig?L'Y':L'N',
- DriverDiag?L'Y':L'N',
- DeviceCount,
- ChildCount,
- SfoFlag?FullDriverName:TruncatedDriverName,
- Temp2==NULL?L"":Temp2
- );
- if (TruncatedDriverName != NULL) {
- FreePool (TruncatedDriverName);
- }
- if (Temp2 != NULL) {
- FreePool(Temp2);
- }
-
- if (ShellGetExecutionBreakFlag ()) {
- ShellStatus = SHELL_ABORTED;
- break;
- }
- }
- }
- SHELL_FREE_NON_NULL(Language);
- ShellCommandLineFreeVarList (Package);
- SHELL_FREE_NON_NULL(FormatString);
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c deleted file mode 100644 index 609d076da0..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c +++ /dev/null @@ -1,1407 +0,0 @@ -/** @file
- Main file for DrvCfg shell Driver1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2015, 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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "UefiShellDriver1CommandsLib.h"
-#include <Protocol/HiiConfigAccess.h>
-#include <Protocol/HiiDatabase.h>
-
-STATIC CONST EFI_GUID *CfgGuidList[] = {&gEfiDriverConfigurationProtocolGuid, &gEfiDriverConfiguration2ProtocolGuid, NULL};
-
-/**
- Find the EFI_HII_HANDLE by device path.
-
- @param[in] DevPath1 The Device Path to match.
- @param[out] HiiHandle The EFI_HII_HANDLE after the converstion.
- @param[in] HiiDb The Hii database protocol
-
- @retval EFI_SUCCESS The operation was successful.
- @retval EFI_NOT_FOUND There was no EFI_HII_HANDLE found for that deviec path.
-**/
-EFI_STATUS
-EFIAPI
-FindHiiHandleViaDevPath(
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath1,
- OUT EFI_HII_HANDLE *HiiHandle,
- IN EFI_HII_DATABASE_PROTOCOL *HiiDb
- )
-{
- EFI_HII_HANDLE *HandleBuffer;
- UINTN HandleBufferSize;
- VOID *MainBuffer;
- UINTN MainBufferSize;
- EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
- EFI_HII_PACKAGE_HEADER *PackageHeader;
- UINTN LoopVariable;
- EFI_DEVICE_PATH_PROTOCOL *DevPath2;
- EFI_STATUS Status;
-
- ASSERT(DevPath1 != NULL);
- ASSERT(HiiHandle != NULL);
- ASSERT(*HiiHandle == NULL);
- ASSERT(HiiDb != NULL);
-
- HandleBufferSize = 0;
- HandleBuffer = NULL;
- Status = HiiDb->ListPackageLists(HiiDb, EFI_HII_PACKAGE_DEVICE_PATH, NULL, &HandleBufferSize, HandleBuffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- HandleBuffer = AllocateZeroPool(HandleBufferSize);
- ASSERT (HandleBuffer != NULL);
- Status = HiiDb->ListPackageLists(HiiDb, EFI_HII_PACKAGE_DEVICE_PATH, NULL, &HandleBufferSize, HandleBuffer);
- }
- if (EFI_ERROR(Status)) {
- SHELL_FREE_NON_NULL(HandleBuffer);
- return (Status);
- }
-
- if (HandleBuffer == NULL) {
- return EFI_NOT_FOUND;
- }
-
- for (LoopVariable = 0 ; LoopVariable < (HandleBufferSize/sizeof(HandleBuffer[0])) && *HiiHandle == NULL ; LoopVariable++) {
- MainBufferSize = 0;
- MainBuffer = NULL;
- Status = HiiDb->ExportPackageLists(HiiDb, HandleBuffer[LoopVariable], &MainBufferSize, MainBuffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- MainBuffer = AllocateZeroPool(MainBufferSize);
- ASSERT (MainBuffer != NULL);
- Status = HiiDb->ExportPackageLists(HiiDb, HandleBuffer[LoopVariable], &MainBufferSize, MainBuffer);
- }
- //
- // Enumerate through the block of returned memory.
- // This should actually be a small block, but we need to be sure.
- //
- for (PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER*)MainBuffer
- ; PackageListHeader != NULL && ((CHAR8*)PackageListHeader) < (((CHAR8*)MainBuffer)+MainBufferSize) && *HiiHandle == NULL
- ; PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER*)(((CHAR8*)(PackageListHeader)) + PackageListHeader->PackageLength )) {
- for (PackageHeader = (EFI_HII_PACKAGE_HEADER*)(((CHAR8*)(PackageListHeader))+sizeof(EFI_HII_PACKAGE_LIST_HEADER))
- ; PackageHeader != NULL && ((CHAR8*)PackageHeader) < (((CHAR8*)MainBuffer)+MainBufferSize) && PackageHeader->Type != EFI_HII_PACKAGE_END && *HiiHandle == NULL
- ; PackageHeader = (EFI_HII_PACKAGE_HEADER*)(((CHAR8*)(PackageHeader))+PackageHeader->Length)) {
- if (PackageHeader->Type == EFI_HII_PACKAGE_DEVICE_PATH) {
- DevPath2 = (EFI_DEVICE_PATH_PROTOCOL*)(((CHAR8*)PackageHeader) + sizeof(EFI_HII_PACKAGE_HEADER));
- if (DevicePathCompare(&DevPath1, &DevPath2) == 0) {
- *HiiHandle = HandleBuffer[LoopVariable];
- break;
- }
- }
- }
- }
- SHELL_FREE_NON_NULL(MainBuffer);
- }
- SHELL_FREE_NON_NULL(HandleBuffer);
-
- if (*HiiHandle == NULL) {
- return (EFI_NOT_FOUND);
- }
- return (EFI_SUCCESS);
-}
-
-/**
- Convert a EFI_HANDLE to a EFI_HII_HANDLE.
-
- @param[in] Handle The EFI_HANDLE to convert.
- @param[out] HiiHandle The EFI_HII_HANDLE after the converstion.
- @param[in] HiiDb The Hii database protocol
-
- @retval EFI_SUCCESS The operation was successful.
-**/
-EFI_STATUS
-EFIAPI
-ConvertHandleToHiiHandle(
- IN CONST EFI_HANDLE Handle,
- OUT EFI_HII_HANDLE *HiiHandle,
- IN EFI_HII_DATABASE_PROTOCOL *HiiDb
- )
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevPath1;
-
- if (HiiHandle == NULL || HiiDb == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
- *HiiHandle = NULL;
-
- if (Handle == NULL) {
- return (EFI_SUCCESS);
- }
-
- DevPath1 = NULL;
- Status = gBS->OpenProtocol(Handle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath1, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR(Status) || DevPath1 == NULL) {
- return (EFI_NOT_FOUND);
- }
-
- return (FindHiiHandleViaDevPath(DevPath1, HiiHandle, HiiDb));
-}
-
-/**
- Function to print out all HII configuration information to a file.
-
- @param[in] Handle The handle to get info on. NULL to do all handles.
- @param[in] FileName The filename to rwite the info to.
-**/
-SHELL_STATUS
-EFIAPI
-ConfigToFile(
- IN CONST EFI_HANDLE Handle,
- IN CONST CHAR16 *FileName
- )
-{
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
- EFI_STATUS Status;
- VOID *MainBuffer;
- UINTN MainBufferSize;
- EFI_HII_HANDLE HiiHandle;
- SHELL_FILE_HANDLE FileHandle;
-
- HiiDatabase = NULL;
- MainBufferSize = 0;
- MainBuffer = NULL;
- FileHandle = NULL;
-
- Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_FILE_OPEN_FAIL),
- gShellDriver1HiiHandle,
- L"drvcfg",
- FileName,
- Status);
- return (SHELL_DEVICE_ERROR);
- }
-
- //
- // Locate HII Database protocol
- //
- Status = gBS->LocateProtocol (
- &gEfiHiiDatabaseProtocolGuid,
- NULL,
- (VOID **) &HiiDatabase
- );
-
- if (EFI_ERROR(Status) || HiiDatabase == NULL) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_PROTOCOL_NF),
- gShellDriver1HiiHandle,
- L"drvcfg",
- L"EfiHiiDatabaseProtocol",
- &gEfiHiiDatabaseProtocolGuid);
- ShellCloseFile(&FileHandle);
- return (SHELL_NOT_FOUND);
- }
-
- HiiHandle = NULL;
- Status = ConvertHandleToHiiHandle(Handle, &HiiHandle, HiiDatabase);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_HANDLE_NOT),
- gShellDriver1HiiHandle,
- L"drvcfg",
- ConvertHandleToHandleIndex(Handle),
- L"Device");
- ShellCloseFile(&FileHandle);
- return (SHELL_DEVICE_ERROR);
- }
-
- Status = HiiDatabase->ExportPackageLists(HiiDatabase, HiiHandle, &MainBufferSize, MainBuffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- MainBuffer = AllocateZeroPool(MainBufferSize);
- Status = HiiDatabase->ExportPackageLists(HiiDatabase, HiiHandle, &MainBufferSize, MainBuffer);
- }
-
- Status = ShellWriteFile(FileHandle, &MainBufferSize, MainBuffer);
-
- ShellCloseFile(&FileHandle);
- SHELL_FREE_NON_NULL(MainBuffer);
-
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_FILE_WRITE_FAIL),
- gShellDriver1HiiHandle,
- L"drvcfg",
- FileName);
- return (SHELL_DEVICE_ERROR);
- }
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_DRVCFG_COMP),
- gShellDriver1HiiHandle);
-
- return (SHELL_SUCCESS);
-}
-
-/**
- Function to read in HII configuration information from a file.
-
- @param[in] Handle The handle to get info for.
- @param[in] FileName The filename to read the info from.
-**/
-SHELL_STATUS
-EFIAPI
-ConfigFromFile(
- IN EFI_HANDLE Handle,
- IN CONST CHAR16 *FileName
- )
-{
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
- EFI_STATUS Status;
- VOID *MainBuffer;
- UINT64 Temp;
- UINTN MainBufferSize;
- EFI_HII_HANDLE HiiHandle;
- SHELL_FILE_HANDLE FileHandle;
- CHAR16 *TempDevPathString;
- EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
- EFI_HII_PACKAGE_HEADER *PackageHeader;
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
- UINTN HandleIndex;
-
- HiiDatabase = NULL;
- MainBufferSize = 0;
- MainBuffer = NULL;
- FileHandle = NULL;
-
- Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_FILE_OPEN_FAIL),
- gShellDriver1HiiHandle,
- L"drvcfg",
- FileName,
- Status);
- return (SHELL_DEVICE_ERROR);
- }
-
- //
- // Locate HII Database protocol
- //
- Status = gBS->LocateProtocol (
- &gEfiHiiDatabaseProtocolGuid,
- NULL,
- (VOID **) &HiiDatabase
- );
-
- if (EFI_ERROR(Status) || HiiDatabase == NULL) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_PROTOCOL_NF),
- gShellDriver1HiiHandle,
- L"drvcfg",
- L"EfiHiiDatabaseProtocol",
- &gEfiHiiDatabaseProtocolGuid);
- ShellCloseFile(&FileHandle);
- return (SHELL_NOT_FOUND);
- }
-
- Status = ShellGetFileSize(FileHandle, &Temp);
- MainBufferSize = (UINTN)Temp;
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_FILE_READ_FAIL),
- gShellDriver1HiiHandle,
- L"drvcfg",
- FileName);
-
- ShellCloseFile(&FileHandle);
- return (SHELL_DEVICE_ERROR);
- }
- MainBuffer = AllocateZeroPool((UINTN)MainBufferSize);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_OUT_MEM),
- gShellDriver1HiiHandle, L"drvcfg");
- ShellCloseFile(&FileHandle);
- return (SHELL_DEVICE_ERROR);
- }
- Status = ShellReadFile(FileHandle, &MainBufferSize, MainBuffer);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_FILE_READ_FAIL),
- gShellDriver1HiiHandle,
- L"drvcfg",
- FileName);
-
- ShellCloseFile(&FileHandle);
- SHELL_FREE_NON_NULL(MainBuffer);
- return (SHELL_DEVICE_ERROR);
- }
-
- ShellCloseFile(&FileHandle);
-
- if (Handle != NULL) {
- //
- // User override in place. Just do it.
- //
- HiiHandle = NULL;
- Status = ConvertHandleToHiiHandle(Handle, &HiiHandle, HiiDatabase);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_HANDLE_NOT),
- gShellDriver1HiiHandle, L"drvcfg",
- ConvertHandleToHandleIndex(Handle),
- L"Device");
- ShellCloseFile(&FileHandle);
- return (SHELL_DEVICE_ERROR);
- }
- Status = HiiDatabase->UpdatePackageList(HiiDatabase, HiiHandle, MainBuffer);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_UEFI_FUNC_WARN),
- gShellDriver1HiiHandle,
- L"drvcfg",
- L"HiiDatabase->UpdatePackageList",
- Status);
- return (SHELL_DEVICE_ERROR);
- }
- } else {
- //
- // we need to parse the buffer and try to match the device paths for each item to try to find it's device path.
- //
-
- for (PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER*)MainBuffer
- ; PackageListHeader != NULL && ((CHAR8*)PackageListHeader) < (((CHAR8*)MainBuffer)+MainBufferSize)
- ; PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER*)(((CHAR8*)(PackageListHeader)) + PackageListHeader->PackageLength )) {
- for (PackageHeader = (EFI_HII_PACKAGE_HEADER*)(((CHAR8*)(PackageListHeader))+sizeof(EFI_HII_PACKAGE_LIST_HEADER))
- ; PackageHeader != NULL && ((CHAR8*)PackageHeader) < (((CHAR8*)MainBuffer)+MainBufferSize) && PackageHeader->Type != EFI_HII_PACKAGE_END
- ; PackageHeader = (EFI_HII_PACKAGE_HEADER*)(((CHAR8*)(PackageHeader))+PackageHeader->Length)) {
- if (PackageHeader->Type == EFI_HII_PACKAGE_DEVICE_PATH) {
- HiiHandle = NULL;
- Status = FindHiiHandleViaDevPath((EFI_DEVICE_PATH_PROTOCOL*)(((CHAR8*)PackageHeader) + sizeof(EFI_HII_PACKAGE_HEADER)), &HiiHandle, HiiDatabase);
- if (EFI_ERROR(Status)) {
- //
- // print out an error.
- //
- TempDevPathString = ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL*)(((CHAR8*)PackageHeader) + sizeof(EFI_HII_PACKAGE_HEADER)), TRUE, TRUE);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_DRVCFG_IN_FILE_NF),
- gShellDriver1HiiHandle,
- TempDevPathString);
- SHELL_FREE_NON_NULL(TempDevPathString);
- } else {
- Status = HiiDatabase->UpdatePackageList(HiiDatabase, HiiHandle, PackageListHeader);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_GEN_UEFI_FUNC_WARN),
- gShellDriver1HiiHandle,
- L"drvcfg",
- L"HiiDatabase->UpdatePackageList",
- Status);
- return (SHELL_DEVICE_ERROR);
- } else {
- DevPath = (EFI_DEVICE_PATH_PROTOCOL*)(((CHAR8*)PackageHeader) + sizeof(EFI_HII_PACKAGE_HEADER));
- gBS->LocateDevicePath(&gEfiHiiConfigAccessProtocolGuid, &DevPath, &Handle);
- HandleIndex = ConvertHandleToHandleIndex(Handle);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_DRVCFG_DONE_HII),
- gShellDriver1HiiHandle,
- HandleIndex);
- }
- }
- }
- }
- }
- }
-
- SHELL_FREE_NON_NULL(MainBuffer);
-
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_DRVCFG_COMP),
- gShellDriver1HiiHandle);
- return (SHELL_SUCCESS);
-}
-
-/**
- Present a requested action to the user.
-
- @param[in] DriverImageHandle The handle for the driver to configure.
- @param[in] ControllerHandle The handle of the device being managed by the Driver specified.
- @param[in] ChildHandle The handle of a child device of the specified device.
- @param[in] ActionRequired The required HII action.
-
- @retval SHELL_INVALID_PARAMETER A parameter has a invalid value.
-**/
-EFI_STATUS
-EFIAPI
-ShellCmdDriverConfigurationProcessActionRequired (
- EFI_HANDLE DriverImageHandle,
- EFI_HANDLE ControllerHandle,
- EFI_HANDLE ChildHandle,
- EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED ActionRequired
- )
-{
- EFI_HANDLE ConnectControllerContextOverride[2];
-
- switch (ActionRequired) {
- case EfiDriverConfigurationActionNone:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_NONE), gShellDriver1HiiHandle);
- break;
-
- case EfiDriverConfigurationActionStopController:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_STOP), gShellDriver1HiiHandle);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_ENTER_S), gShellDriver1HiiHandle, L"stop controller");
- ShellPromptForResponse(ShellPromptResponseTypeEnterContinue, NULL, NULL);
-
- gBS->DisconnectController (ControllerHandle, DriverImageHandle, ChildHandle);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_CTLR_S), gShellDriver1HiiHandle, L"stopped");
- break;
-
- case EfiDriverConfigurationActionRestartController:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_RESTART_S), gShellDriver1HiiHandle, L"controller");
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_ENTER_S), gShellDriver1HiiHandle, L"restart controller");
- ShellPromptForResponse(ShellPromptResponseTypeEnterContinue, NULL, NULL);
-
- gBS->DisconnectController (ControllerHandle, DriverImageHandle, ChildHandle);
- ConnectControllerContextOverride[0] = DriverImageHandle;
- ConnectControllerContextOverride[1] = NULL;
- gBS->ConnectController (ControllerHandle, ConnectControllerContextOverride, NULL, TRUE);
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_CTLR_S), gShellDriver1HiiHandle, L"restarted");
- break;
-
- case EfiDriverConfigurationActionRestartPlatform:
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_RESTART_S), gShellDriver1HiiHandle, L"platform");
- ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_ENTER_S), gShellDriver1HiiHandle, L"restart platform");
- ShellPromptForResponse(ShellPromptResponseTypeEnterContinue, NULL, NULL);
-
- gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
- break;
-
- default:
- return (EFI_INVALID_PARAMETER);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Do the configuration in an environment without HII.
-
- @param[in] Language The language code.
- @param[in] ForceDefaults TRUE to force defaults, FALSE otherwise.
- @param[in] DefaultType If ForceDefaults is TRUE, specifies the default type.
- @param[in] AllChildren TRUE to configure all children, FALSE otherwise.
- @param[in] ValidateOptions TRUE to validate existing options, FALSE otherwise.
- @param[in] SetOptions TRUE to set options, FALSE otherwise.
- @param[in] DriverImageHandle The handle for the driver to configure.
- @param[in] DeviceHandle The handle of the device being managed by the Driver specified.
- @param[in] ChildHandle The handle of a child device of the specified device.
-
- @retval SHELL_NOT_FOUND A specified handle could not be found.
- @retval SHELL_INVALID_PARAMETER A parameter has a invalid value.
-**/
-SHELL_STATUS
-EFIAPI
-PreHiiDrvCfg (
- IN CONST CHAR8 *Language,
- IN BOOLEAN ForceDefaults,
- IN UINT32 DefaultType,
- IN BOOLEAN AllChildren,
- IN BOOLEAN ValidateOptions,
- IN BOOLEAN SetOptions,
- IN EFI_HANDLE DriverImageHandle,
- IN EFI_HANDLE DeviceHandle,
- IN EFI_HANDLE ChildHandle
- )
-{
- EFI_STATUS Status;
- SHELL_STATUS ShellStatus;
- UINTN OuterLoopCounter;
- CHAR8 *BestLanguage;
- UINTN DriverImageHandleCount;
- EFI_HANDLE *DriverImageHandleBuffer;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN *HandleType;
- UINTN LoopCounter;
- UINTN ChildIndex;
- UINTN ChildHandleCount;
- EFI_HANDLE *ChildHandleBuffer;
- UINTN *ChildHandleType;
- EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED ActionRequired;
- EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;
- BOOLEAN Iso639Language;
- UINTN HandleIndex1;
- UINTN HandleIndex2;
- UINTN HandleIndex3;
-
- ShellStatus = SHELL_SUCCESS;
-
- if (ChildHandle == NULL && AllChildren) {
- SetOptions = FALSE;
- }
-
- if (ForceDefaults) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_FORCE_D),
- gShellDriver1HiiHandle,
- DefaultType);
- } else if (ValidateOptions) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_VALIDATE),
- gShellDriver1HiiHandle);
- } else if (SetOptions) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_SET),
- gShellDriver1HiiHandle);
- }
-
- if (DriverImageHandle == 0) {
- DriverImageHandleBuffer = GetHandleListByProtocolList(CfgGuidList);
- if (DriverImageHandleBuffer == NULL) {
- ShellStatus = SHELL_NOT_FOUND;
- goto Done;
- }
- for (
- HandleBuffer = DriverImageHandleBuffer, DriverImageHandleCount = 0
- ; HandleBuffer != NULL && *HandleBuffer != NULL
- ; HandleBuffer++,DriverImageHandleCount++);
- } else {
- DriverImageHandleCount = 1;
- //
- // Allocate buffer to hold the image handle so as to
- // keep consistent with the above clause
- //
- DriverImageHandleBuffer = AllocatePool (sizeof (EFI_HANDLE));
- ASSERT (DriverImageHandleBuffer);
- DriverImageHandleBuffer[0] = DriverImageHandle;
- }
-
- for (OuterLoopCounter = 0; OuterLoopCounter < DriverImageHandleCount; OuterLoopCounter++) {
- Iso639Language = FALSE;
- Status = gBS->OpenProtocol (
- DriverImageHandleBuffer[OuterLoopCounter],
- &gEfiDriverConfiguration2ProtocolGuid,
- (VOID **) &DriverConfiguration,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- Iso639Language = TRUE;
- Status = gBS->OpenProtocol (
- DriverImageHandleBuffer[OuterLoopCounter],
- &gEfiDriverConfigurationProtocolGuid,
- (VOID **) &DriverConfiguration,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- }
- if (EFI_ERROR (Status)) {
-// ShellPrintHiiEx(
-// -1,
-// -1,
-// NULL,
-// STRING_TOKEN (STR_DRVCFG_NOT_SUPPORT),
-// gShellDriver1HiiHandle,
-// ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter])
-// );
- ShellStatus = SHELL_UNSUPPORTED;
- continue;
- }
-
- BestLanguage = GetBestLanguage (
- DriverConfiguration->SupportedLanguages,
- Iso639Language,
- Language!=NULL?Language:"",
- DriverConfiguration->SupportedLanguages,
- NULL
- );
- if (BestLanguage == NULL) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_NO_VALUE),
- gShellDriver1HiiHandle,
- L"drvcfg",
- L"-l"
- );
- ShellStatus = SHELL_INVALID_PARAMETER;
- continue;
- }
-
- Status = ParseHandleDatabaseByRelationshipWithType (
- DriverImageHandleBuffer[OuterLoopCounter],
- NULL,
- &HandleCount,
- &HandleBuffer,
- &HandleType
- );
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- if (SetOptions && DeviceHandle == NULL) {
-
- gST->ConOut->ClearScreen (gST->ConOut);
- Status = DriverConfiguration->SetOptions (
- DriverConfiguration,
- NULL,
- NULL,
- BestLanguage,
- &ActionRequired
- );
- gST->ConOut->ClearScreen (gST->ConOut);
-
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_ALL_LANG),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]),
- DriverConfiguration->SupportedLanguages
- );
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_SET),
- gShellDriver1HiiHandle);
- for (LoopCounter = 0; LoopCounter < HandleCount; LoopCounter++) {
- if ((HandleType[LoopCounter] & HR_CONTROLLER_HANDLE) == HR_CONTROLLER_HANDLE) {
- ShellCmdDriverConfigurationProcessActionRequired (
- DriverImageHandleBuffer[OuterLoopCounter],
- HandleBuffer[LoopCounter],
- NULL,
- ActionRequired
- );
- }
- }
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_NOT_SET),
- gShellDriver1HiiHandle,
- Status);
- }
- continue;
- }
-
- for (LoopCounter = 0; LoopCounter < HandleCount; LoopCounter++) {
- if ((HandleType[LoopCounter] & HR_CONTROLLER_HANDLE) != HR_CONTROLLER_HANDLE) {
- continue;
- }
- if (DeviceHandle != NULL && DeviceHandle != HandleBuffer[LoopCounter]) {
- continue;
- }
- if (ChildHandle == NULL) {
- HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
- HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_CTRL_LANG),
- gShellDriver1HiiHandle,
- HandleIndex1,
- HandleIndex2,
- DriverConfiguration->SupportedLanguages
- );
-
- if (ForceDefaults) {
- Status = DriverConfiguration->ForceDefaults (
- DriverConfiguration,
- HandleBuffer[LoopCounter],
- NULL,
- DefaultType,
- &ActionRequired
- );
-
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_DEF_FORCED),
- gShellDriver1HiiHandle);
- ShellCmdDriverConfigurationProcessActionRequired (
- DriverImageHandleBuffer[OuterLoopCounter],
- HandleBuffer[LoopCounter],
- NULL,
- ActionRequired
- );
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_FORCE_FAILED),
- gShellDriver1HiiHandle,
- Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else if (ValidateOptions) {
- Status = DriverConfiguration->OptionsValid (
- DriverConfiguration,
- HandleBuffer[LoopCounter],
- NULL
- );
-
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_VALID),
- gShellDriver1HiiHandle);
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_INV),
- gShellDriver1HiiHandle,
- Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else if (SetOptions) {
- gST->ConOut->ClearScreen (gST->ConOut);
- Status = DriverConfiguration->SetOptions (
- DriverConfiguration,
- HandleBuffer[LoopCounter],
- NULL,
- BestLanguage,
- &ActionRequired
- );
- gST->ConOut->ClearScreen (gST->ConOut);
- HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
- HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_CTRL_LANG),
- gShellDriver1HiiHandle,
- HandleIndex1,
- HandleIndex2,
- DriverConfiguration->SupportedLanguages
- );
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_SET),
- gShellDriver1HiiHandle);
-
- ShellCmdDriverConfigurationProcessActionRequired (
- DriverImageHandleBuffer[OuterLoopCounter],
- HandleBuffer[LoopCounter],
- NULL,
- ActionRequired
- );
-
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_NOT_SET),
- gShellDriver1HiiHandle,
- Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else {
- Print (L"\n");
- }
- }
-
- if (ChildHandle == NULL && !AllChildren) {
- continue;
- }
-
- Status = ParseHandleDatabaseByRelationshipWithType (
- DriverImageHandleBuffer[OuterLoopCounter],
- HandleBuffer[LoopCounter],
- &ChildHandleCount,
- &ChildHandleBuffer,
- &ChildHandleType
- );
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- for (ChildIndex = 0; ChildIndex < ChildHandleCount; ChildIndex++) {
-
- if ((ChildHandleType[ChildIndex] & HR_CHILD_HANDLE) != HR_CHILD_HANDLE) {
- continue;
- }
-
- if (ChildHandle != NULL && ChildHandle != ChildHandleBuffer[ChildIndex]) {
- continue;
- }
-
- HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
- HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
- HandleIndex3 = ConvertHandleToHandleIndex (ChildHandleBuffer[ChildIndex]);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_CHILD_LANG),
- gShellDriver1HiiHandle,
- HandleIndex1,
- HandleIndex2,
- HandleIndex3,
- DriverConfiguration->SupportedLanguages);
-
- if (ForceDefaults) {
- Status = DriverConfiguration->ForceDefaults (
- DriverConfiguration,
- HandleBuffer[LoopCounter],
- ChildHandleBuffer[ChildIndex],
- DefaultType,
- &ActionRequired
- );
-
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_DEF_FORCED),
- gShellDriver1HiiHandle);
-
- ShellCmdDriverConfigurationProcessActionRequired (
- DriverImageHandleBuffer[OuterLoopCounter],
- HandleBuffer[LoopCounter],
- ChildHandleBuffer[ChildIndex],
- ActionRequired
- );
-
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_FORCE_FAILED),
- gShellDriver1HiiHandle,
- Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else if (ValidateOptions) {
- Status = DriverConfiguration->OptionsValid (
- DriverConfiguration,
- HandleBuffer[LoopCounter],
- ChildHandleBuffer[ChildIndex]
- );
-
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_VALID),
- gShellDriver1HiiHandle);
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_INV),
- gShellDriver1HiiHandle,
- Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else if (SetOptions) {
- gST->ConOut->ClearScreen (gST->ConOut);
- Status = DriverConfiguration->SetOptions (
- DriverConfiguration,
- HandleBuffer[LoopCounter],
- ChildHandleBuffer[ChildIndex],
- BestLanguage,
- &ActionRequired
- );
- gST->ConOut->ClearScreen (gST->ConOut);
- HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
- HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
- HandleIndex3 = ConvertHandleToHandleIndex (ChildHandleBuffer[ChildIndex]);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_CHILD_LANG),
- gShellDriver1HiiHandle,
- HandleIndex1,
- HandleIndex2,
- HandleIndex3,
- DriverConfiguration->SupportedLanguages
- );
- if (!EFI_ERROR (Status)) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_OPTIONS_SET),
- gShellDriver1HiiHandle);
-
- ShellCmdDriverConfigurationProcessActionRequired (
- DriverImageHandleBuffer[OuterLoopCounter],
- HandleBuffer[LoopCounter],
- ChildHandleBuffer[ChildIndex],
- ActionRequired
- );
-
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_NOT_SET),
- gShellDriver1HiiHandle,
- Status);
- ShellStatus = SHELL_DEVICE_ERROR;
- }
- } else {
- Print (L"\n");
- }
- }
-
- FreePool (ChildHandleBuffer);
- FreePool (ChildHandleType);
- }
-
- FreePool (BestLanguage);
- FreePool (HandleBuffer);
- FreePool (HandleType);
- }
-
- if (DriverImageHandle != NULL && DriverImageHandleCount != 0) {
- FreePool (DriverImageHandleBuffer);
- }
-
-Done:
- return ShellStatus;
-}
-
-/**
- Function to print out configuration information on all configurable handles.
-
- @param[in] ChildrenToo TRUE to tewst for children.
- @param[in] Language ASCII string for language code.
- @param[in] UseHii TRUE to check for Hii and DPC, FALSE for DCP only.
-
- @retval SHELL_SUCCESS The operation was successful.
-**/
-SHELL_STATUS
-EFIAPI
-PrintConfigInfoOnAll(
- IN CONST BOOLEAN ChildrenToo,
- IN CONST CHAR8 *Language,
- IN CONST BOOLEAN UseHii
- )
-{
- EFI_HANDLE *HandleList;
- EFI_HANDLE *CurrentHandle;
- BOOLEAN Found;
- UINTN Index2;
-
-
- Found = FALSE;
- HandleList = NULL;
- CurrentHandle = NULL;
-
- if (UseHii) {
- //
- // HII method
- //
- HandleList = GetHandleListByProtocol(&gEfiHiiConfigAccessProtocolGuid);
- for (CurrentHandle = HandleList ; CurrentHandle != NULL && *CurrentHandle != NULL; CurrentHandle++){
- Found = TRUE;
- Index2 = *CurrentHandle == NULL ? 0 : ConvertHandleToHandleIndex(*CurrentHandle);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_LINE_HII),
- gShellDriver1HiiHandle,
- Index2
- );
- }
- SHELL_FREE_NON_NULL(HandleList);
- }
-
- if (PreHiiDrvCfg (
- Language,
- FALSE,
- 0,
- ChildrenToo,
- FALSE,
- FALSE,
- 0,
- 0,
- 0) == SHELL_SUCCESS) {
- Found = TRUE;
- }
-
- if (!Found) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_NONE_FOUND), gShellDriver1HiiHandle);
- return (SHELL_SUCCESS);
- }
-
- return (SHELL_SUCCESS);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamListHii[] = {
- {L"-s", TypeFlag},
- {L"-l", TypeValue},
- {L"-f", TypeValue},
- {L"-o", TypeValue},
- {L"-i", TypeValue},
- {NULL, TypeMax}
- };
-STATIC CONST SHELL_PARAM_ITEM ParamListPreHii[] = {
- {L"-c", TypeFlag},
- {L"-s", TypeFlag},
- {L"-v", TypeFlag},
- {L"-l", TypeValue},
- {L"-f", TypeValue},
- {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 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CHAR8 *Language;
- CONST CHAR16 *Lang;
- CONST CHAR16 *HandleIndex1;
- CONST CHAR16 *HandleIndex2;
- CONST CHAR16 *HandleIndex3;
- CONST CHAR16 *ForceTypeString;
- BOOLEAN Force;
- BOOLEAN Set;
- BOOLEAN Validate;
- BOOLEAN InFromFile;
- BOOLEAN OutToFile;
- BOOLEAN AllChildren;
- BOOLEAN UseHii;
- UINT32 ForceType;
- UINT64 Intermediate;
- EFI_HANDLE Handle1;
- EFI_HANDLE Handle2;
- EFI_HANDLE Handle3;
- CONST CHAR16 *FileName;
-
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
- Language = NULL;
- UseHii = TRUE;
- ProblemParam = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (ParamListHii, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status) || ShellCommandLineGetCount(Package) > 2) {
- UseHii = FALSE;
- if (Package != NULL) {
- ShellCommandLineFreeVarList (Package);
- }
- SHELL_FREE_NON_NULL(ProblemParam);
- Status = ShellCommandLineParse (ParamListPreHii, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"drvcfg", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- } else {
- ASSERT(FALSE);
- }
- }
- }
- if (ShellStatus == SHELL_SUCCESS) {
- Lang = ShellCommandLineGetValue(Package, L"-l");
- if (Lang != NULL) {
- Language = AllocateZeroPool(StrSize(Lang));
- AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
- } else if (ShellCommandLineGetFlag(Package, L"-l")){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drvcfg", L"-l");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- Set = ShellCommandLineGetFlag (Package, L"-s");
- Validate = ShellCommandLineGetFlag (Package, L"-v");
- InFromFile = ShellCommandLineGetFlag (Package, L"-i");
- OutToFile = ShellCommandLineGetFlag (Package, L"-o");
- AllChildren = ShellCommandLineGetFlag (Package, L"-c");
- Force = ShellCommandLineGetFlag (Package, L"-f");
- ForceTypeString = ShellCommandLineGetValue(Package, L"-f");
-
- if (OutToFile) {
- FileName = ShellCommandLineGetValue(Package, L"-o");
- } else if (InFromFile) {
- FileName = ShellCommandLineGetValue(Package, L"-i");
- } else {
- FileName = NULL;
- }
-
- if (InFromFile && EFI_ERROR(ShellFileExists(FileName))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FIND_FAIL), gShellDriver1HiiHandle, L"drvcfg", FileName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (OutToFile && !EFI_ERROR(ShellFileExists(FileName))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_EXIST), gShellDriver1HiiHandle, L"drvcfg", FileName);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (Force && ForceTypeString == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drvcfg", L"-f");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (Force) {
- Status = ShellConvertStringToUint64(ForceTypeString, &Intermediate, FALSE, FALSE);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDriver1HiiHandle, L"drvcfg", ForceTypeString, L"-f");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- ForceType = (UINT32)Intermediate;
- } else {
- ForceType = 0;
- }
- HandleIndex1 = ShellCommandLineGetRawValue(Package, 1);
- Handle1 = NULL;
- if (HandleIndex1 != NULL && !EFI_ERROR(ShellConvertStringToUint64(HandleIndex1, &Intermediate, TRUE, FALSE))) {
- Handle1 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- if (Handle1 == NULL || (UINT64)(UINTN)Intermediate != Intermediate) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"drvcfg", HandleIndex1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
- HandleIndex2 = ShellCommandLineGetRawValue(Package, 2);
- Handle2 = NULL;
- if (HandleIndex2 != NULL && !EFI_ERROR(ShellConvertStringToUint64(HandleIndex2, &Intermediate, TRUE, FALSE))) {
- Handle2 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- if (Handle2 == NULL || (UINT64)(UINTN)Intermediate != Intermediate) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"drvcfg", HandleIndex2);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
- HandleIndex3 = ShellCommandLineGetRawValue(Package, 3);
- Handle3 = NULL;
- if (HandleIndex3 != NULL && !EFI_ERROR(ShellConvertStringToUint64(HandleIndex3, &Intermediate, TRUE, FALSE))) {
- Handle3 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- if (Handle3 == NULL || (UINT64)(UINTN)Intermediate != Intermediate) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"drvcfg", HandleIndex3);
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
-
- if ((InFromFile || OutToFile) && (FileName == NULL)) {
- if (FileName == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drvcfg", InFromFile?L"-i":L"-o");
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_REQ), gShellDriver1HiiHandle, L"drvcfg");
- }
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (!UseHii && (InFromFile || OutToFile)) {
- if (InFromFile) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDriver1HiiHandle, L"drvcfg", L"-i");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (OutToFile) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDriver1HiiHandle, L"drvcfg", L"-o");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- }
- if (Validate && Force) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDriver1HiiHandle, L"drvcfg", L"-v", L"-f");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (Validate && Set) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDriver1HiiHandle, L"drvcfg", L"-v", L"-s");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (Set && Force) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDriver1HiiHandle, L"drvcfg", L"-s", L"-f");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
- if (OutToFile && InFromFile) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDriver1HiiHandle, L"drvcfg", L"-i", L"-o");
- ShellStatus = SHELL_INVALID_PARAMETER;
- goto Done;
- }
-
- //
- // We do HII first.
- //
- if (UseHii) {
- if (Handle1 != NULL && EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiHiiConfigAccessProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- //
- // no HII on this handle.
- //
- ShellStatus = SHELL_UNSUPPORTED;
- } else if (Validate) {
- } else if (Force) {
- } else if (Set) {
- } else if (InFromFile) {
- ShellStatus = ConfigFromFile(Handle1, FileName);
- if (Handle1 != NULL && ShellStatus == SHELL_SUCCESS) {
- goto Done;
- }
- } else if (OutToFile) {
- ShellStatus = ConfigToFile(Handle1, FileName);
- if (Handle1 != NULL && ShellStatus == SHELL_SUCCESS) {
- goto Done;
- }
- } else if (HandleIndex1 == NULL) {
- //
- // display all that are configurable
- //
- ShellStatus = PrintConfigInfoOnAll(AllChildren, Language, UseHii);
- goto Done;
- } else {
- if (!EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiHiiConfigAccessProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_LINE_HII),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex(Handle1)
- );
- goto Done;
- }
- }
- }
-
- //
- // We allways need to do this one since it does both by default.
- //
- if (!InFromFile && !OutToFile) {
- ShellStatus = PreHiiDrvCfg (
- Language,
- Force,
- ForceType,
- AllChildren,
- Validate,
- Set,
- Handle1,
- Handle2,
- Handle3);
- }
-
- if (ShellStatus == SHELL_UNSUPPORTED) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRVCFG_NOT_SUPPORT),
- gShellDriver1HiiHandle,
- ConvertHandleToHandleIndex(Handle1)
- );
- }
- }
-
-Done:
- ShellCommandLineFreeVarList (Package);
- SHELL_FREE_NON_NULL(Language);
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c deleted file mode 100644 index 271271120b..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c +++ /dev/null @@ -1,455 +0,0 @@ -/** @file
- Main file for DrvDiag shell Driver1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2013, 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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST EFI_GUID *DiagGuidList[] = {&gEfiDriverDiagnosticsProtocolGuid, &gEfiDriverDiagnostics2ProtocolGuid, NULL};
-//
-// We need 1 more item on the list...
-//
-typedef enum {
- 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 (
- IN CONST DRV_DIAG_TEST_MODE Mode,
- IN CONST CHAR8 *Lang,
- IN CONST BOOLEAN AllChilds,
- IN CONST EFI_HANDLE DriverHandle,
- IN CONST EFI_HANDLE ControllerHandle,
- IN CONST EFI_HANDLE ChildHandle
- )
-{
- EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics;
- EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2;
- EFI_HANDLE *DriverHandleList;
- EFI_HANDLE *ControllerHandleList;
- EFI_HANDLE *ChildHandleList;
- EFI_HANDLE *Walker;
- UINTN DriverHandleListCount;
- UINTN ControllerHandleListCount;
- UINTN ChildHandleListCount;
- UINTN DriverHandleListLoop;
- UINTN ControllerHandleListLoop;
- UINTN ChildHandleListLoop;
- EFI_STATUS Status;
- EFI_STATUS Status2;
- EFI_GUID *ErrorType;
- UINTN OutBufferSize;
- CHAR16 *OutBuffer;
- UINTN HandleIndex1;
- UINTN HandleIndex2;
- CHAR8 *Language;
- BOOLEAN Found;
-
- if ((ChildHandle != NULL && AllChilds) || (Mode >= TestModeMax)){
- return (EFI_INVALID_PARAMETER);
- }
-
- DriverDiagnostics = NULL;
- DriverDiagnostics2 = NULL;
- Status = EFI_SUCCESS;
- Status2 = EFI_SUCCESS;
- DriverHandleList = NULL;
- ControllerHandleList = NULL;
- ChildHandleList = NULL;
- Language = NULL;
- OutBuffer = NULL;
- ErrorType = NULL;
- DriverHandleListCount = 0;
- ControllerHandleListCount = 0;
- ChildHandleListCount = 0;
-
- if (DriverHandle != NULL) {
- DriverHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
- ASSERT(DriverHandleList!=NULL);
- DriverHandleList[0] = DriverHandle;
- DriverHandleListCount = 1;
- } else {
- DriverHandleList = GetHandleListByProtocolList(DiagGuidList);
- if (DriverHandleList == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROTOCOL_NF), gShellDriver1HiiHandle, L"drvdiag", L"gEfiDriverDiagnosticsProtocolGuid", &gEfiDriverDiagnosticsProtocolGuid);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROTOCOL_NF), gShellDriver1HiiHandle, L"drvdiag", L"gEfiDriverDiagnostics2ProtocolGuid", &gEfiDriverDiagnostics2ProtocolGuid);
- return (EFI_NOT_FOUND);
- }
- for (Walker = DriverHandleList ; Walker != NULL && *Walker != NULL ; DriverHandleListCount++, Walker++);
- }
-
- if (ControllerHandle != NULL) {
- ControllerHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
- ASSERT(ControllerHandleList!=NULL);
- ControllerHandleList[0] = ControllerHandle;
- ControllerHandleListCount = 1;
- } else {
- ControllerHandleList = NULL;
- }
-
- if (ChildHandle != NULL) {
- ChildHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
- ASSERT(ChildHandleList!=NULL);
- ChildHandleList[0] = ChildHandle;
- ChildHandleListCount = 1;
- } else if (AllChilds) {
- ChildHandleList = NULL;
- //
- // This gets handled in the loop below.
- //
- } else {
- 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);
- }
- 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 (ControllerHandleListLoop = 0
- ; ControllerHandleListLoop < ControllerHandleListCount
- ; ControllerHandleListLoop++
- ){
- 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) && (DriverDiagnostics2 != NULL)) {
- Language = GetBestLanguageForDriver(DriverDiagnostics2->SupportedLanguages, Lang, FALSE);
- 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 && (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)) {
- Language = GetBestLanguageForDriver(DriverDiagnostics->SupportedLanguages, Lang, FALSE);
- 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,
- 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 {
- HandleIndex1 = ConvertHandleToHandleIndex(DriverHandleList[DriverHandleListLoop]);
- HandleIndex2 = ConvertHandleToHandleIndex(ControllerHandleList[ControllerHandleListLoop]);
- //
- // Print out the information that this set can be tested
- //
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_DRV_DIAG_ITEM_LINE),
- gShellDriver1HiiHandle,
- HandleIndex1,
- HandleIndex2,
- ChildHandleList == NULL?0:ConvertHandleToHandleIndex(ChildHandleList[ChildHandleListLoop])
- );
- }
-
- //
- // 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 (ControllerHandle == NULL) {
- SHELL_FREE_NON_NULL(ControllerHandleList);
- ControllerHandleList = NULL;
- ControllerHandleListCount = 0;
- }
- }
- }
-
- if (DriverHandleList != NULL) {
- FreePool(DriverHandleList);
- }
- if (ControllerHandleList != NULL) {
- FreePool(ControllerHandleList);
- }
- if (ChildHandleList != NULL) {
- FreePool(ChildHandleList);
- }
- return (Status2);
-}
-
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-c", TypeFlag},
- {L"-s", TypeFlag},
- {L"-e", TypeFlag},
- {L"-m", TypeFlag},
- {L"-l", TypeValue},
- {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 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- DRV_DIAG_TEST_MODE Mode;
- CHAR8 *Language;
- CONST CHAR16 *DriverHandleStr;
- CONST CHAR16 *ControllerHandleStr;
- CONST CHAR16 *ChildHandleStr;
- CONST CHAR16 *Lang;
- EFI_HANDLE Handle1;
- EFI_HANDLE Handle2;
- EFI_HANDLE Handle3;
- UINT64 Intermediate;
-
- ShellStatus = SHELL_SUCCESS;
- Mode = TestModeMax;
- Language = NULL;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- 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), gShellDriver1HiiHandle, L"drvdiag", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // if more than 3 'value' parameters (plus the name one) or we have any 2 mode flags
- //
- if ((ShellCommandLineGetCount(Package) > 4)
- ||(ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetFlag(Package, L"-e"))
- ||(ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetFlag(Package, L"-m"))
- ||(ShellCommandLineGetFlag(Package, L"-e") && ShellCommandLineGetFlag(Package, L"-m"))
- ){
- //
- // error for too many parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"drvdiag");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if ((ShellCommandLineGetFlag(Package, L"-s"))
- || (ShellCommandLineGetFlag(Package, L"-e"))
- || (ShellCommandLineGetFlag(Package, L"-m"))
- ){
- //
- // Run the apropriate test
- //
- if (ShellCommandLineGetFlag(Package, L"-s")) {
- Mode = TestModeStandard;
- } else if (ShellCommandLineGetFlag(Package, L"-e")) {
- Mode = TestModeExtended;
- } else if (ShellCommandLineGetFlag(Package, L"-m")) {
- Mode = TestModeManufacturing;
- } else {
- ASSERT(FALSE);
- }
- } else {
- //
- // Do a listing of what's available to test
- //
- Mode = TestModeList;
- }
-
- Lang = ShellCommandLineGetValue(Package, L"-l");
- if (ShellCommandLineGetFlag(Package, L"-l") && Lang == NULL) {
- ASSERT(Language == NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drvdiag", 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);
- ControllerHandleStr = ShellCommandLineGetRawValue(Package, 2);
- ChildHandleStr = ShellCommandLineGetRawValue(Package, 3);
-
- if (DriverHandleStr == NULL) {
- Handle1 = NULL;
- } else {
- ShellConvertStringToUint64(DriverHandleStr, &Intermediate, TRUE, FALSE);
- Handle1 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- }
- if (ControllerHandleStr == NULL) {
- Handle2 = NULL;
- } else {
- ShellConvertStringToUint64(ControllerHandleStr, &Intermediate, TRUE, FALSE);
- Handle2 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- }
- if (ChildHandleStr == NULL) {
- Handle3 = NULL;
- } else {
- ShellConvertStringToUint64(ChildHandleStr, &Intermediate, TRUE, FALSE);
- Handle3 = ConvertHandleIndexToHandle((UINTN)Intermediate);
- }
-
- Status = DoDiagnostics (
- Mode,
- Language,
- ShellCommandLineGetFlag(Package, L"-c"),
- Handle1,
- Handle2,
- Handle3
- );
-
- SHELL_FREE_NON_NULL(Language);
- ShellCommandLineFreeVarList (Package);
-
- }
- if (ShellStatus == SHELL_SUCCESS) {
- if (Status == EFI_SECURITY_VIOLATION) {
- ShellStatus = SHELL_SECURITY_VIOLATION;
- } else if (Status == EFI_INVALID_PARAMETER) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (Status == EFI_NOT_FOUND) {
- ShellStatus = SHELL_NOT_FOUND;
- } else if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
-
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c deleted file mode 100644 index e11873aa10..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/OpenInfo.c +++ /dev/null @@ -1,217 +0,0 @@ -/** @file
- Main file for OpenInfo shell Driver1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST CHAR16 StringHandProt[] = L"HandProt ";
-STATIC CONST CHAR16 StringGetProt[] = L"GetProt ";
-STATIC CONST CHAR16 StringTestProt[] = L"TestProt ";
-STATIC CONST CHAR16 StringChild[] = L"Child ";
-STATIC CONST CHAR16 StringDriver[] = L"Driver ";
-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 (
- IN CONST EFI_HANDLE TheHandle
- )
-{
- EFI_STATUS Status;
- EFI_GUID **ProtocolGuidArray;
- UINTN ArrayCount;
- UINTN ProtocolIndex;
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;
- UINTN OpenInfoCount;
- UINTN OpenInfoIndex;
- CONST CHAR16 *OpenTypeString;
- CHAR16 *TempString;
- UINTN HandleIndex;
- CONST CHAR16 *Name;
- UINTN ControllerIndex;
-
- if (TheHandle == NULL) {
- return (EFI_INVALID_PARAMETER);
- }
-
- //
- // Retrieve the list of all the protocols on the handle
- //
- Status = gBS->ProtocolsPerHandle (
- TheHandle,
- &ProtocolGuidArray,
- &ArrayCount
- );
- ASSERT_EFI_ERROR(Status);
- if (!EFI_ERROR (Status)) {
-
- for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
- //
- // print out the human readable name for this one.
- //
- TempString = GetStringNameFromGuid(ProtocolGuidArray[ProtocolIndex], NULL);
- if (TempString == NULL) {
- continue;
- }
- ShellPrintEx(-1, -1, L"%H%s%N\r\n", TempString);
- FreePool(TempString);
-
- //
- // Retrieve the list of agents that have opened each protocol
- //
- Status = gBS->OpenProtocolInformation (
- TheHandle,
- ProtocolGuidArray[ProtocolIndex],
- &OpenInfo,
- &OpenInfoCount
- );
- ASSERT_EFI_ERROR(Status);
- if (!EFI_ERROR (Status)) {
- for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
- switch (OpenInfo[OpenInfoIndex].Attributes) {
- case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL: OpenTypeString = StringHandProt; break;
- case EFI_OPEN_PROTOCOL_GET_PROTOCOL: OpenTypeString = StringGetProt; break;
- case EFI_OPEN_PROTOCOL_TEST_PROTOCOL: OpenTypeString = StringTestProt; break;
- case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER: OpenTypeString = StringChild; break;
- case EFI_OPEN_PROTOCOL_BY_DRIVER: OpenTypeString = StringDriver; break;
- case EFI_OPEN_PROTOCOL_EXCLUSIVE: OpenTypeString = StringExclusive; break;
- case EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE:
- OpenTypeString = StringDriverEx; break;
- default: OpenTypeString = StringUnknown; break;
- }
- HandleIndex = ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].AgentHandle);
- Name = GetStringNameFromHandle(OpenInfo[OpenInfoIndex].AgentHandle, NULL);
- ControllerIndex = ConvertHandleToHandleIndex(OpenInfo[OpenInfoIndex].ControllerHandle);
- if (ControllerIndex != 0) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_OPENINFO_LINE),
- gShellDriver1HiiHandle,
- HandleIndex,
- ControllerIndex,
- OpenInfo[OpenInfoIndex].OpenCount,
- OpenTypeString,
- Name
- );
- } else {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_OPENINFO_MIN_LINE),
- gShellDriver1HiiHandle,
- HandleIndex,
- OpenInfo[OpenInfoIndex].OpenCount,
- OpenTypeString,
- Name
- );
- }
- }
- FreePool (OpenInfo);
- }
- }
- FreePool (ProtocolGuidArray);
- }
-
- return Status;
-}
-
-/**
- Function for 'openinfo' 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
-ShellCommandRunOpenInfo (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- EFI_HANDLE TheHandle;
- CONST CHAR16 *Param1;
- UINT64 Intermediate;
-
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR(Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"openinfo", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 2){
- //
- // error for too many parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"openinfo");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) == 0) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle, L"openinfo");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- Param1 = ShellCommandLineGetRawValue(Package, 1);
- 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, L"openinfo", Param1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- TheHandle = ConvertHandleIndexToHandle((UINTN)Intermediate);
- ASSERT(TheHandle != NULL);
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_OPENINFO_HEADER_LINE), gShellDriver1HiiHandle, (UINTN)Intermediate, TheHandle);
-
- Status = TraverseHandleDatabase (TheHandle);
- if (!EFI_ERROR(Status)) {
- } else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"openinfo", Param1);
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- }
- }
- return (ShellStatus);
-}
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c deleted file mode 100644 index d2ae8e8271..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c +++ /dev/null @@ -1,99 +0,0 @@ -/** @file
- Main file for Reconnect shell Driver1 function.
-
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-r", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Connect all the possible console devices.
-
-**/
-VOID
-ConnectAllConsoles (
- VOID
- )
-{
- ShellConnectFromDevPaths(L"ConInDev");
- ShellConnectFromDevPaths(L"ConOutDev");
- ShellConnectFromDevPaths(L"ErrOutDev");
-
- ShellConnectFromDevPaths(L"ErrOut");
- ShellConnectFromDevPaths(L"ConIn");
- ShellConnectFromDevPaths(L"ConOut");
-}
-
-
-/**
- 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 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- SHELL_STATUS ShellStatus;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- EFI_STATUS Status;
-
- gInReconnect = TRUE;
- ShellStatus = SHELL_SUCCESS;
-
- //
- // initialize the shell lib (we must be in non-auto-init...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- 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), gShellDriver1HiiHandle, L"reconnect", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- ShellStatus = ShellCommandRunDisconnect(ImageHandle, SystemTable);
- if (ShellStatus == SHELL_SUCCESS) {
- if (ShellCommandLineGetFlag(Package, L"-r")) {
- ConnectAllConsoles();
- }
- ShellStatus = ShellCommandRunConnect(ImageHandle, SystemTable);
- }
- }
-
- gInReconnect = FALSE;
-
- return (ShellStatus);
-}
-
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.c deleted file mode 100644 index 95cd9a0ca8..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.c +++ /dev/null @@ -1,104 +0,0 @@ -/** @file
- Main file for NULL named library for level 1 shell command functions.
-
- Copyright (c) 2010 - 2014, 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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "UefiShellDriver1CommandsLib.h"
-
-STATIC CONST CHAR16 mFileName[] = L"Driver1Commands";
-EFI_HANDLE gShellDriver1HiiHandle = NULL;
-BOOLEAN gInReconnect = FALSE;
-
-/**
- Function to return the name of the file containing help if HII will not be used.
-
- @return The filename.
-**/
-CONST CHAR16*
-EFIAPI
-ShellCommandGetManFileNameDriver1 (
- VOID
- )
-{
- return (mFileName);
-}
-
-/**
- Constructor for the Shell Driver1 Commands library.
-
- @param ImageHandle the image handle of the process
- @param SystemTable the EFI System Table pointer
-
- @retval EFI_SUCCESS the shell command handlers were installed sucessfully
- @retval EFI_UNSUPPORTED the shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-UefiShellDriver1CommandsLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- //
- // check our bit of the profiles mask
- //
- if ((PcdGet8(PcdShellProfileMask) & BIT0) == 0) {
- return (EFI_SUCCESS);
- }
-
- //
- // install the HII stuff.
- //
- gShellDriver1HiiHandle = HiiAddPackages (&gShellDriver1HiiGuid, gImageHandle, UefiShellDriver1CommandsLibStrings, NULL);
- if (gShellDriver1HiiHandle == NULL) {
- return (EFI_DEVICE_ERROR);
- }
-
- //
- // install our shell command handlers that are always installed
- //
- ShellCommandRegisterCommandName(L"connect", ShellCommandRunConnect , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_CONNECT) );
- ShellCommandRegisterCommandName(L"devices", ShellCommandRunDevices , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DEVICES) );
- ShellCommandRegisterCommandName(L"openinfo", ShellCommandRunOpenInfo , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_OPENINFO) );
- ShellCommandRegisterCommandName(L"disconnect", ShellCommandRunDisconnect , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DISCONNECT));
- ShellCommandRegisterCommandName(L"reconnect", ShellCommandRunReconnect , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_RECONNECT) );
- ShellCommandRegisterCommandName(L"unload", ShellCommandRunUnload , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_UNLOAD) );
- ShellCommandRegisterCommandName(L"drvdiag", ShellCommandRunDrvDiag , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DRVDIAG) );
- ShellCommandRegisterCommandName(L"dh", ShellCommandRunDh , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DH) );
- ShellCommandRegisterCommandName(L"drivers", ShellCommandRunDrivers , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DRIVERS) );
- ShellCommandRegisterCommandName(L"devtree", ShellCommandRunDevTree , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DEVTREE) );
- ShellCommandRegisterCommandName(L"drvcfg", ShellCommandRunDrvCfg , ShellCommandGetManFileNameDriver1, 0, L"Driver1", TRUE, gShellDriver1HiiHandle, STRING_TOKEN(STR_GET_HELP_DRVCFG) );
-
- return (EFI_SUCCESS);
-}
-
-/**
- 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
-UefiShellDriver1CommandsLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- if (gShellDriver1HiiHandle != NULL) {
- HiiRemovePackages(gShellDriver1HiiHandle);
- }
- return (EFI_SUCCESS);
-}
-
-
-
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h deleted file mode 100644 index c65d0ed695..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.h +++ /dev/null @@ -1,226 +0,0 @@ -/** @file
- Main file for NULL named library for Profile1 shell command functions.
-
- Copyright (c) 2010 - 2014, 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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _UEFI_SHELL_DRIVER1_COMMANDS_LIB_H_
-#define _UEFI_SHELL_DRIVER1_COMMANDS_LIB_H_
-
-#include <Uefi.h>
-#include <ShellBase.h>
-
-#include <Guid/GlobalVariable.h>
-#include <Guid/ConsoleInDevice.h>
-#include <Guid/ConsoleOutDevice.h>
-#include <Guid/ShellLibHiiGuid.h>
-
-#include <IndustryStandard/Pci.h>
-
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellParameters.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/UnicodeCollation.h>
-#include <Protocol/DriverDiagnostics2.h>
-#include <Protocol/DriverDiagnostics.h>
-#include <Protocol/PlatformDriverOverride.h>
-#include <Protocol/BusSpecificDriverOverride.h>
-#include <Protocol/PlatformToDriverConfiguration.h>
-#include <Protocol/DriverSupportedEfiVersion.h>
-#include <Protocol/DriverFamilyOverride.h>
-#include <Protocol/DriverHealth.h>
-#include <Protocol/PciIo.h>
-#include <Protocol/PciRootBridgeIo.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/ShellCommandLib.h>
-#include <Library/ShellLib.h>
-#include <Library/SortLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/HiiLib.h>
-#include <Library/FileHandleLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/PrintLib.h>
-#include <Library/HandleParsingLib.h>
-#include <Library/PeCoffGetEntryPointLib.h>
-#include <Library/HandleParsingLib.h>
-
-
-extern EFI_HANDLE gShellDriver1HiiHandle;
-extern BOOLEAN gInReconnect;
-
-/**
- Function for 'connect' 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
-ShellCommandRunConnect (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'devices' 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
-ShellCommandRunDevices (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'openinfo' 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
-ShellCommandRunOpenInfo (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'devtree' 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
-ShellCommandRunDevTree (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- 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 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- 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 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- 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 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- 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 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- 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 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- 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 (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- Function for 'unload' 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
-ShellCommandRunUnload (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-/**
- 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
-ShellConnectFromDevPaths (
- IN CONST CHAR16 *Key
- );
-
-
-
-#endif
-
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf deleted file mode 100644 index f2a2e4c581..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf +++ /dev/null @@ -1,73 +0,0 @@ -## @file
-# Provides shell driver1 profile functions
-#
-# Copyright (c) 2010 - 2015, 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
-# http://opensource.org/licenses/bsd-license.php
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-##
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = UefiShellDriver1CommandsLib
- FILE_GUID = 313D3674-3ED4-48fd-BF97-7DB35D4190D1
- MODULE_TYPE = UEFI_APPLICATION
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = UefiShellDriver1CommandsLibConstructor
- DESTRUCTOR = UefiShellDriver1CommandsLibDestructor
-
-[Sources]
- Connect.c
- Devices.c
- OpenInfo.c
- Disconnect.c
- Reconnect.c
- Unload.c
- DrvDiag.c
- Dh.c
- Drivers.c
- DevTree.c
- DrvCfg.c
- UefiShellDriver1CommandsLib.c
- UefiShellDriver1CommandsLib.h
- UefiShellDriver1CommandsLib.uni
-
-[Packages]
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- BaseMemoryLib
- DebugLib
- ShellCommandLib
- ShellLib
- UefiLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- SortLib
- PrintLib
- PeCoffGetEntryPointLib
-
-[Pcd]
- gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask ## CONSUMES
-
-[Protocols]
- gEfiDriverHealthProtocolGuid ## CONSUMES
- gEfiDriverFamilyOverrideProtocolGuid ## CONSUMES
- gEfiHiiConfigAccessProtocolGuid ## CONSUMES
- gEfiHiiDatabaseProtocolGuid ## CONSUMES
-
-[Guids]
- gEfiGlobalVariableGuid ## CONSUMES ## GUID
- gEfiConsoleInDeviceGuid ## CONSUMES ## GUID
- gEfiConsoleOutDeviceGuid ## CONSUMES ## GUID
- gShellDriver1HiiGuid ## PRODUCES ## HII
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni Binary files differdeleted file mode 100644 index a28985300e..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni +++ /dev/null diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Unload.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Unload.c deleted file mode 100644 index 0d48f9d5d7..0000000000 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Unload.c +++ /dev/null @@ -1,149 +0,0 @@ -/** @file
- Main file for Unload shell Driver1 function.
-
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2014, 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
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "UefiShellDriver1CommandsLib.h"
-
-/**
- Function to dump LoadedImage info from TheHandle.
-
- @param[in] TheHandle The handle to dump info from.
-
- @retval EFI_SUCCESS The info was dumped.
- @retval EFI_INVALID_PARAMETER The handle did not have LoadedImage
-**/
-EFI_STATUS
-EFIAPI
-DumpLoadedImageProtocolInfo (
- IN EFI_HANDLE TheHandle
- )
-{
- CHAR16 *TheString;
-
- TheString = GetProtocolInformationDump(TheHandle, &gEfiLoadedImageProtocolGuid, TRUE);
-
- ShellPrintEx(-1, -1, L"%s", TheString);
-
- SHELL_FREE_NON_NULL(TheString);
-
- return (EFI_SUCCESS);
-}
-
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-n", TypeFlag},
- {L"-v", TypeFlag},
- {L"-verbose", TypeFlag},
- {NULL, TypeMax}
- };
-
-/**
- Function for 'unload' 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
-ShellCommandRunUnload (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- 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...)
- //
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
-
- //
- // parse the command line
- //
- 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), gShellDriver1HiiHandle,L"unload", ProblemParam);
- FreePool(ProblemParam);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- ASSERT(FALSE);
- }
- } else {
- if (ShellCommandLineGetCount(Package) > 2){
- //
- // error for too many parameters
- //
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"unload");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) < 2) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle, L"unload");
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- 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, L"unload", Param1);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- 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, (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", (UINTN)TheHandle, Status);
- }
- SHELL_FREE_NON_NULL(Resp);
- }
- }
- }
- if (ShellStatus == SHELL_SUCCESS) {
- if (Status == EFI_SECURITY_VIOLATION) {
- ShellStatus = SHELL_SECURITY_VIOLATION;
- } else if (Status == EFI_INVALID_PARAMETER) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (EFI_ERROR(Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
-
- if (Package != NULL) {
- ShellCommandLineFreeVarList(Package);
- }
-
- return (ShellStatus);
-}
|