mirror of https://github.com/acidanthera/audk.git
EmbeddedPkg/FdtPlatformDxe: Add 'setfdt' EFI Shell command
The 'setfdt' EFI Shell command allows to define a new FDT as the prefered one for development purposes. It allows to trigger the run of the FDT installation process as well. Please refer to the README.txt file for more comprehensive description. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ronald Cron <Ronald.Cron@arm.com> Reviewed-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16934 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
158497a094
commit
3c1e53ce8f
|
@ -20,11 +20,15 @@
|
|||
#include <Library/PcdLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
|
||||
#include <Library/HiiLib.h>
|
||||
#include <Library/BdsLib.h>
|
||||
#include <Library/ShellLib.h>
|
||||
|
||||
#include <Protocol/DevicePathToText.h>
|
||||
#include <Protocol/DevicePathFromText.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/EfiShell.h>
|
||||
#include <Protocol/EfiShellDynamicCommand.h>
|
||||
|
||||
#include <Guid/EventGroup.h>
|
||||
#include <Guid/Fdt.h>
|
||||
|
@ -34,6 +38,7 @@
|
|||
//
|
||||
// Internal types
|
||||
//
|
||||
|
||||
STATIC VOID OnEndOfDxe (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
|
@ -45,6 +50,48 @@ STATIC EFI_STATUS InstallFdt (
|
|||
IN CONST CHAR16* TextDevicePath
|
||||
);
|
||||
|
||||
STATIC SHELL_STATUS EFIAPI ShellDynCmdSetFdtHandler (
|
||||
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable,
|
||||
IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
|
||||
IN EFI_SHELL_PROTOCOL *Shell
|
||||
);
|
||||
|
||||
STATIC CHAR16* EFIAPI ShellDynCmdSetFdtGetHelp (
|
||||
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
|
||||
IN CONST CHAR8 *Language
|
||||
);
|
||||
|
||||
STATIC SHELL_STATUS UpdateFdtTextDevicePath (
|
||||
IN EFI_SHELL_PROTOCOL *Shell,
|
||||
IN CONST CHAR16 *FilePath
|
||||
);
|
||||
|
||||
STATIC SHELL_STATUS EfiCodeToShellCode (
|
||||
IN EFI_STATUS Status
|
||||
);
|
||||
|
||||
//
|
||||
// Internal variables
|
||||
//
|
||||
|
||||
STATIC CONST EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mShellDynCmdProtocolSetFdt = {
|
||||
L"setfdt", // Name of the command
|
||||
ShellDynCmdSetFdtHandler, // Handler
|
||||
ShellDynCmdSetFdtGetHelp // GetHelp
|
||||
};
|
||||
|
||||
STATIC CONST EFI_GUID mFdtPlatformDxeHiiGuid = {
|
||||
0x8afa7610, 0x62b1, 0x46aa,
|
||||
{0xb5, 0x34, 0xc3, 0xde, 0xff, 0x39, 0x77, 0x8c}
|
||||
};
|
||||
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
||||
{L"-i", TypeFlag },
|
||||
{NULL , TypeMax }
|
||||
};
|
||||
|
||||
STATIC EFI_HANDLE mFdtPlatformDxeHiiHandle;
|
||||
|
||||
/**
|
||||
Main entry point of the FDT platform driver.
|
||||
|
||||
|
@ -53,7 +100,10 @@ STATIC EFI_STATUS InstallFdt (
|
|||
@param[in] *SystemTable A pointer to the EFI System table.
|
||||
|
||||
@retval EFI_SUCCESS The driver was initialized.
|
||||
@retval EFI_OUT_OF_RESOURCES The "End of DXE" event could not be allocated.
|
||||
@retval EFI_OUT_OF_RESOURCES The "End of DXE" event could not be allocated or
|
||||
there was not enough memory in pool to install
|
||||
the Shell Dynamic Command protocol.
|
||||
@retval EFI_LOAD_ERROR Unable to add the HII package.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
|
@ -80,6 +130,57 @@ FdtPlatformEntryPoint (
|
|||
&EndOfDxeEvent
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// If the development features are enabled, install the dynamic shell
|
||||
// command "setfdt" to be able to define a device path for the FDT
|
||||
// that has precedence over the device paths defined by
|
||||
// "PcdFdtDevicePaths".
|
||||
//
|
||||
|
||||
if (FeaturePcdGet (PcdOverridePlatformFdt)) {
|
||||
//
|
||||
// Register the strings for the user interface in the HII Database.
|
||||
// This shows the way to the multi-language support, even if
|
||||
// only the English language is actually supported. The strings to register
|
||||
// are stored in the "FdtPlatformDxeStrings[]" array. This array is
|
||||
// built by the building process from the "*.uni" file associated to
|
||||
// the present driver (cf. FdtPlatfromDxe.inf). Examine your Build
|
||||
// folder under your package's DEBUG folder and you will find the array
|
||||
// defined in a xxxStrDefs.h file.
|
||||
//
|
||||
mFdtPlatformDxeHiiHandle = HiiAddPackages (
|
||||
&mFdtPlatformDxeHiiGuid,
|
||||
ImageHandle,
|
||||
FdtPlatformDxeStrings,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (mFdtPlatformDxeHiiHandle != NULL) {
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&ImageHandle,
|
||||
&gEfiShellDynamicCommandProtocolGuid,
|
||||
&mShellDynCmdProtocolSetFdt,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
HiiRemovePackages (mFdtPlatformDxeHiiHandle);
|
||||
}
|
||||
} else {
|
||||
Status = EFI_LOAD_ERROR;
|
||||
}
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((
|
||||
EFI_D_WARN,
|
||||
"Unable to install \"setfdt\" EFI Shell command - %r \n",
|
||||
Status
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -352,8 +453,6 @@ Error :
|
|||
return Status;
|
||||
}
|
||||
|
||||
=======
|
||||
|
||||
/**
|
||||
This is the shell command "setfdt" handler function. This function handles
|
||||
the command when it is invoked in the shell.
|
||||
|
@ -739,4 +838,3 @@ EfiCodeToShellCode (
|
|||
|
||||
return ShellStatus;
|
||||
}
|
||||
>>>>>>> 4ac4fed... EmbeddedPkg/FdtPlatformDxe: Fix typo issue
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
[Defines]
|
||||
INF_VERSION = 0x00010006
|
||||
BASE_NAME = FdtPlatformDxe
|
||||
MODULE_UNI_FILE = FdtPlatformDxe.uni
|
||||
FILE_GUID = 6e9a4c69-57c6-4fcd-b083-4f2c3bdb6051
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 0.1
|
||||
|
@ -22,11 +23,14 @@
|
|||
|
||||
[Sources.common]
|
||||
FdtPlatform.c
|
||||
FdtPlatformDxe.uni
|
||||
|
||||
[Packages]
|
||||
EmbeddedPkg/EmbeddedPkg.dec
|
||||
ArmPkg/ArmPkg.dec
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
ShellPkg/ShellPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
UefiDriverEntryPoint
|
||||
|
@ -36,9 +40,13 @@
|
|||
DebugLib
|
||||
UefiBootServicesTableLib
|
||||
UefiRuntimeServicesTableLib
|
||||
HiiLib
|
||||
ShellLib
|
||||
|
||||
[Protocols]
|
||||
gEfiDevicePathToTextProtocolGuid
|
||||
gEfiDevicePathFromTextProtocolGuid
|
||||
gEfiShellDynamicCommandProtocolGuid
|
||||
|
||||
[Guids]
|
||||
gEfiEndOfDxeEventGroupGuid
|
||||
|
|
Binary file not shown.
|
@ -15,7 +15,7 @@
|
|||
The purpose of the FdtPlatformDxe UEFI driver is to install the Flat Device
|
||||
Tree (FDT) of the platform the UEFI frimware is running on into the UEFI
|
||||
Configuration Table. The FDT is identified within the UEFI Configuration
|
||||
Table by the "gFdtTableGuid" GUID defined in EmbeddedPkg.dec.
|
||||
Table by the "gFdtTableGuid" GUID defined in "EmbeddedPkg.dec".
|
||||
|
||||
Once installed, an UEFI application or OS boot loader can get from the UEFI
|
||||
Configuration Table the FDT of the platform from the "gFdtTableGuid" GUID.
|
||||
|
@ -48,3 +48,25 @@ driver tries to install it using the device path defined by the UEFI variable
|
|||
"Fdt". If the variable does not exist or the installation using the device path
|
||||
defined by the UEFI variable fails then the installation proceeds as described
|
||||
above.
|
||||
|
||||
Furthermore and again for development purposes only, if the feature PCD
|
||||
"PcdOverridePlatformFdt" is equal to TRUE, the current driver provides the EFI
|
||||
Shell command "setfdt" to define the location of the FDT by the mean of an EFI
|
||||
Shell file path (like "fs2:\boot\fdt.dtb") or a device path.
|
||||
|
||||
If the path passed in to the command is a valid EFI Shell file path, the
|
||||
command translates it into the corresponding device path and stores that
|
||||
device path in the "Fdt" UEFI variable asking for the variable to be non
|
||||
volatile.
|
||||
|
||||
If the path passed in to the command is not recognised as a valid EFI
|
||||
Shell device path, the command handles it as device path and stored
|
||||
in the "Fdt" UEFI variable as it is.
|
||||
|
||||
Finally, the "-i" option of the "setfdt" command allows to trigger the FDT
|
||||
installation process. The installation process is completed when the command
|
||||
returns. The command can be invoked with the "-i" option only and in that
|
||||
case the "Fdt" UEFI variable is not updated and the command just runs the
|
||||
FDT installation process. If the command is invoked with the "-i" option and
|
||||
an EFI Shell file path then first the "Fdt" UEFI variable is updated accordingly
|
||||
and then the FDT installation process is run.
|
||||
|
|
|
@ -101,6 +101,11 @@
|
|||
AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf
|
||||
FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
|
||||
|
||||
# Shell libraries
|
||||
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
|
||||
FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
|
||||
SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
|
||||
|
||||
# Networking Requirements
|
||||
NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
|
||||
HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
|
||||
|
|
Loading…
Reference in New Issue