49 LINUX_EFI_INITRD_MEDIA_GUID
51 END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
58IsOtherInitrdDevicePathAlreadyInstalled (
67 Status =
gBS->LocateDevicePath (
68 &gEfiLoadFile2ProtocolGuid,
72 if (EFI_ERROR (Status)) {
80 if (Handle == mInitrdLoadFile2Handle) {
93 IN BOOLEAN BootPolicy,
95 OUT VOID *Buffer OPTIONAL
99 return EFI_UNSUPPORTED;
103 return EFI_INVALID_PARAMETER;
106 if ((FilePath->Type != END_DEVICE_PATH_TYPE) ||
107 (FilePath->SubType != END_ENTIRE_DEVICE_PATH_SUBTYPE) ||
108 (mInitrdFileSize == 0))
110 return EFI_NOT_FOUND;
113 if ((Buffer ==
NULL) || (*BufferSize < mInitrdFileSize)) {
114 *BufferSize = mInitrdFileSize;
115 return EFI_BUFFER_TOO_SMALL;
118 ASSERT (mInitrdFileAddress != 0);
120 gBS->CopyMem (Buffer, (VOID *)(
UINTN)mInitrdFileAddress, mInitrdFileSize);
121 *BufferSize = mInitrdFileSize;
131UninstallLoadFile2Protocol (
137 if (mInitrdLoadFile2Handle !=
NULL) {
138 Status =
gBS->UninstallMultipleProtocolInterfaces (
139 mInitrdLoadFile2Handle,
140 &gEfiDevicePathProtocolGuid,
142 &gEfiLoadFile2ProtocolGuid,
146 if (!EFI_ERROR (Status)) {
147 mInitrdLoadFile2Handle =
NULL;
162 if (mInitrdFileSize != 0) {
171 IN SHELL_FILE_HANDLE FileHandle
178 Status = gEfiShellProtocol->GetFileSize (FileHandle, &FileSize);
179 if (EFI_ERROR (Status)) {
183 if ((FileSize == 0) || (FileSize > MAX_UINTN)) {
184 return EFI_UNSUPPORTED;
187 Status =
gBS->AllocatePages (
193 if (EFI_ERROR (Status)) {
197 ReadSize = (
UINTN)FileSize;
198 Status = gEfiShellProtocol->ReadFile (
201 (VOID *)(
UINTN)mInitrdFileAddress
203 if (EFI_ERROR (Status) || (ReadSize < FileSize)) {
206 "%a: failed to read initrd file - %r 0x%lx 0x%lx\n",
215 if (mInitrdLoadFile2Handle ==
NULL) {
216 Status =
gBS->InstallMultipleProtocolInterfaces (
217 &mInitrdLoadFile2Handle,
218 &gEfiDevicePathProtocolGuid,
220 &gEfiLoadFile2ProtocolGuid,
227 mInitrdFileSize = (
UINTN)FileSize;
251 CHAR16 *ProblemParam;
255 SHELL_FILE_HANDLE FileHandle;
267 if (EFI_ERROR (Status)) {
268 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam !=
NULL)) {
274 mLinuxInitrdShellCommandHiiHandle,
283 }
else if (IsOtherInitrdDevicePathAlreadyInstalled ()) {
289 mLinuxInitrdShellCommandHiiHandle,
300 mLinuxInitrdShellCommandHiiHandle,
307 UninstallLoadFile2Protocol ();
314 mLinuxInitrdShellCommandHiiHandle,
321 ASSERT (Param !=
NULL);
324 if (Filename ==
NULL) {
330 mLinuxInitrdShellCommandHiiHandle,
342 if (!EFI_ERROR (Status)) {
344 Status = CacheInitrdFile (FileHandle);
348 if (EFI_ERROR (Status)) {
354 mLinuxInitrdShellCommandHiiHandle,
392 gEfiShellParametersProtocol = ShellParameters;
393 gEfiShellProtocol = Shell;
419 mLinuxInitrdShellCommandHiiHandle,
451 Status =
gBS->OpenProtocol (
453 &gEfiHiiPackageListProtocolGuid,
454 (VOID **)&PackageList,
457 EFI_OPEN_PROTOCOL_GET_PROTOCOL
460 if (EFI_ERROR (Status)) {
474 if (EFI_ERROR (Status)) {
503 if (mLinuxInitrdShellCommandHiiHandle ==
NULL) {
507 Status =
gBS->InstallProtocolInterface (
509 &gEfiShellDynamicCommandProtocolGuid,
511 &mLinuxInitrdDynamicCommand
535 Status = UninstallLoadFile2Protocol ();
536 if (EFI_ERROR (Status)) {
540 Status =
gBS->UninstallProtocolInterface (
542 &gEfiShellDynamicCommandProtocolGuid,
543 &mLinuxInitrdDynamicCommand
545 if (EFI_ERROR (Status)) {
#define MEDIA_VENDOR_DP
Media vendor device path subtype.
BOOLEAN EFIAPI IsDevicePathValid(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINTN MaxSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
VOID EFIAPI HiiRemovePackages(IN EFI_HII_HANDLE HiiHandle)
EFI_STATUS EFIAPI LinuxInitrdDynamicShellCommandUnload(IN EFI_HANDLE ImageHandle)
STATIC EFI_HII_HANDLE InitializeHiiPackage(EFI_HANDLE ImageHandle)
EFI_STATUS EFIAPI LinuxInitrdDynamicShellCommandEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
SHELL_STATUS EFIAPI LinuxInitrdCommandHandler(IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, IN EFI_SYSTEM_TABLE *SystemTable, IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN EFI_SHELL_PROTOCOL *Shell)
STATIC SHELL_STATUS EFIAPI RunInitrd(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC CHAR16 *EFIAPI LinuxInitrdGetHelp(IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, IN CONST CHAR8 *Language)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
@ SHELL_INVALID_PARAMETER
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
@ TypeFlag
A flag that is present or not present only (IE "-a").
EFI_STATUS EFIAPI ShellOpenFileByName(IN CONST CHAR16 *FileName, OUT SHELL_FILE_HANDLE *FileHandle, IN UINT64 OpenMode, IN UINT64 Attributes)
EFI_STATUS EFIAPI ShellInitialize(VOID)
CHAR16 *EFIAPI ShellFindFilePath(IN CONST CHAR16 *FileName)
CONST CHAR16 *EFIAPI ShellCommandLineGetRawValue(IN CONST LIST_ENTRY *CONST CheckPackage, IN UINTN Position)
UINTN EFIAPI ShellCommandLineGetCount(IN CONST LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellCloseFile(IN SHELL_FILE_HANDLE *FileHandle)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_SIZE_TO_PAGES(Size)
EFI_HII_DATABASE_PROTOCOL * gHiiDatabase
EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL protocol structure.