2010-11-12 20:40:21 +01:00
|
|
|
/** @file
|
|
|
|
Main file for NULL named library for level 1 shell command functions.
|
|
|
|
|
2014-03-20 18:11:52 +01:00
|
|
|
Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:07:06 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2010-11-12 20:40:21 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "UefiShellDriver1CommandsLib.h"
|
|
|
|
|
|
|
|
STATIC CONST CHAR16 mFileName[] = L"Driver1Commands";
|
ShellPkg: stop using EFI_HANDLE in place of EFI_HII_HANDLE
The UefiShell*CommandsLib instances have constructor functions that do
something like:
gHiiHandle = HiiAddPackages (...);
...
ShellCommandRegisterCommandName (..., gHiiHandle, ...);
and destructor functions that implement the following pattern:
HiiRemovePackages (gHiiHandle);
The -- semantic, not functional -- problem is that "gHiiHandle" is
declared with type EFI_HANDLE, and not EFI_HII_HANDLE, in all of these
library instances, even though HiiAddPackages() correctly returns
EFI_HII_HANDLE, and HiiRemovePackages() takes EFI_HII_HANDLE.
Once we fix the type of "gHiiHandle", it causes sort of a butterfly
effect, because it is passed around widely. Track down and update all of
those locations.
The DynamicCommand lib instances use a similar pattern, so they are
affected too.
NOTE: in practice, this patch is a no-op, as both EFI_HII_HANDLE and
EFI_HANDLE are typedefs to (VOID*). However, we shouldn't use EFI_HANDLE
where semantically EFI_HII_HANDLE is passed around.
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
2019-09-06 23:15:42 +02:00
|
|
|
EFI_HII_HANDLE gShellDriver1HiiHandle = NULL;
|
2011-04-12 23:55:07 +02:00
|
|
|
BOOLEAN gInReconnect = FALSE;
|
|
|
|
|
2011-03-25 22:13:43 +01:00
|
|
|
/**
|
|
|
|
Function to return the name of the file containing help if HII will not be used.
|
|
|
|
|
|
|
|
@return The filename.
|
|
|
|
**/
|
2010-11-12 20:40:21 +01:00
|
|
|
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) {
|
2011-05-17 00:12:20 +02:00
|
|
|
return (EFI_SUCCESS);
|
2010-11-12 20:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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.
|
2011-03-25 22:13:43 +01:00
|
|
|
|
|
|
|
@param ImageHandle The image handle of the process.
|
|
|
|
@param SystemTable The EFI System Table pointer.
|
2010-11-12 20:40:21 +01:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
UefiShellDriver1CommandsLibDestructor (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (gShellDriver1HiiHandle != NULL) {
|
|
|
|
HiiRemovePackages (gShellDriver1HiiHandle);
|
|
|
|
}
|
2021-12-05 23:54:13 +01:00
|
|
|
|
2010-11-12 20:40:21 +01:00
|
|
|
return (EFI_SUCCESS);
|
|
|
|
}
|