2010-11-16 23:36:37 +01:00
|
|
|
/** @file
|
|
|
|
Main file for LoadPciRom shell Debug1 function.
|
|
|
|
|
2015-02-04 23:25:01 +01:00
|
|
|
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
|
2016-07-12 12:06:58 +02:00
|
|
|
Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
|
2010-11-16 23:36:37 +01:00
|
|
|
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 "UefiShellDebug1CommandsLib.h"
|
|
|
|
#include <IndustryStandard/Pci22.h>
|
|
|
|
#include <IndustryStandard/Pci23.h>
|
|
|
|
#include <IndustryStandard/PeImage.h>
|
|
|
|
#include <Protocol/Decompress.h>
|
|
|
|
|
2011-03-25 22:22:20 +01:00
|
|
|
/**
|
|
|
|
Connects all available drives and controllers.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
@retval EFI_ABORTED The abort mechanism was received.
|
|
|
|
**/
|
2010-11-16 23:36:37 +01:00
|
|
|
EFI_STATUS
|
|
|
|
LoadPciRomConnectAllDriversToAllControllers (
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2011-03-25 22:22:20 +01:00
|
|
|
/**
|
|
|
|
Command entry point.
|
2010-11-16 23:36:37 +01:00
|
|
|
|
2011-03-25 22:22:20 +01:00
|
|
|
@param[in] RomBar The Rom Base address.
|
|
|
|
@param[in] RomSize The Rom size.
|
|
|
|
@param[in] FileName The file name.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The command completed successfully.
|
|
|
|
@retval EFI_INVALID_PARAMETER Command usage error.
|
|
|
|
@retval EFI_UNSUPPORTED Protocols unsupported.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of memory.
|
|
|
|
@retval Other value Unknown error.
|
|
|
|
**/
|
2010-11-16 23:36:37 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
LoadEfiDriversFromRomImage (
|
|
|
|
VOID *RomBar,
|
|
|
|
UINTN RomSize,
|
|
|
|
CONST CHAR16 *FileName
|
|
|
|
);
|
|
|
|
|
|
|
|
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
|
|
|
{L"-nc", TypeFlag},
|
|
|
|
{NULL, TypeMax}
|
|
|
|
};
|
|
|
|
|
2011-03-25 22:22:20 +01:00
|
|
|
/**
|
|
|
|
Function for 'loadpcirom' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
2010-11-16 23:36:37 +01:00
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunLoadPciRom (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_SHELL_FILE_INFO *FileList;
|
|
|
|
UINTN SourceSize;
|
|
|
|
UINT8 *File1Buffer;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *Package;
|
|
|
|
CHAR16 *ProblemParam;
|
|
|
|
SHELL_STATUS ShellStatus;
|
|
|
|
BOOLEAN Connect;
|
|
|
|
CONST CHAR16 *Param;
|
|
|
|
UINTN ParamCount;
|
|
|
|
EFI_SHELL_FILE_INFO *Node;
|
|
|
|
//
|
|
|
|
// Local variable initializations
|
|
|
|
//
|
|
|
|
File1Buffer = NULL;
|
|
|
|
ShellStatus = SHELL_SUCCESS;
|
|
|
|
FileList = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// verify number of arguments
|
|
|
|
//
|
|
|
|
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
2015-02-03 22:22:53 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"loadpcirom", ProblemParam);
|
2010-11-16 23:36:37 +01:00
|
|
|
FreePool(ProblemParam);
|
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
} else {
|
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|
|
|
|
} else {
|
2011-03-25 22:22:20 +01:00
|
|
|
if (ShellCommandLineGetCount(Package) < 2) {
|
2015-02-03 22:22:53 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"loadpcirom");
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
} else {
|
2011-03-25 22:22:20 +01:00
|
|
|
if (ShellCommandLineGetFlag(Package, L"-nc")) {
|
2010-11-16 23:36:37 +01:00
|
|
|
Connect = FALSE;
|
|
|
|
} else {
|
|
|
|
Connect = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// get a list with each file specified by parameters
|
|
|
|
// if parameter is a directory then add all the files below it to the list
|
|
|
|
//
|
|
|
|
for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount)
|
|
|
|
; Param != NULL
|
|
|
|
; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount)
|
|
|
|
){
|
|
|
|
Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
|
|
|
|
if (EFI_ERROR(Status)) {
|
2015-02-03 22:22:53 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Param);
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellStatus = SHELL_ACCESS_DENIED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-03-25 22:22:20 +01:00
|
|
|
if (ShellStatus == SHELL_SUCCESS && FileList != NULL) {
|
2010-11-16 23:36:37 +01:00
|
|
|
//
|
|
|
|
// loop through the list and make sure we are not aborting...
|
|
|
|
//
|
|
|
|
for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link)
|
|
|
|
; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()
|
|
|
|
; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)
|
|
|
|
){
|
|
|
|
if (EFI_ERROR(Node->Status)){
|
2015-02-03 22:22:53 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (FileHandleIsDirectory(Node->Handle) == EFI_SUCCESS) {
|
2015-02-03 22:22:53 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
SourceSize = (UINTN) Node->Info->FileSize;
|
2011-03-25 22:22:20 +01:00
|
|
|
File1Buffer = AllocateZeroPool (SourceSize);
|
2016-07-12 12:06:58 +02:00
|
|
|
if (File1Buffer == NULL) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"loadpcirom");
|
|
|
|
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
|
|
|
continue;
|
|
|
|
}
|
2010-11-16 23:36:37 +01:00
|
|
|
Status = gEfiShellProtocol->ReadFile(Node->Handle, &SourceSize, File1Buffer);
|
|
|
|
if (EFI_ERROR(Status)) {
|
2015-02-03 22:22:53 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_READ_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
} else {
|
|
|
|
Status = LoadEfiDriversFromRomImage (
|
|
|
|
File1Buffer,
|
|
|
|
SourceSize,
|
|
|
|
Node->FullName
|
|
|
|
);
|
|
|
|
|
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOAD_PCI_ROM_RES), gShellDebug1HiiHandle, Node->FullName, Status);
|
|
|
|
}
|
|
|
|
FreePool(File1Buffer);
|
|
|
|
}
|
2011-03-25 22:22:20 +01:00
|
|
|
} else if (ShellStatus == SHELL_SUCCESS) {
|
2015-02-03 22:22:53 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle, "loadpcirom");
|
2011-03-25 22:22:20 +01:00
|
|
|
ShellStatus = SHELL_NOT_FOUND;
|
2010-11-16 23:36:37 +01:00
|
|
|
}
|
|
|
|
if (FileList != NULL && !IsListEmpty(&FileList->Link)) {
|
|
|
|
Status = ShellCloseFileMetaArg(&FileList);
|
|
|
|
}
|
|
|
|
FileList = NULL;
|
|
|
|
|
|
|
|
if (Connect) {
|
|
|
|
Status = LoadPciRomConnectAllDriversToAllControllers ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ShellStatus);
|
|
|
|
}
|
|
|
|
|
2011-03-25 22:22:20 +01:00
|
|
|
/**
|
|
|
|
Command entry point.
|
|
|
|
|
|
|
|
@param[in] RomBar The Rom Base address.
|
|
|
|
@param[in] RomSize The Rom size.
|
|
|
|
@param[in] FileName The file name.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The command completed successfully.
|
|
|
|
@retval EFI_INVALID_PARAMETER Command usage error.
|
|
|
|
@retval EFI_UNSUPPORTED Protocols unsupported.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of memory.
|
|
|
|
@retval Other value Unknown error.
|
|
|
|
**/
|
2010-11-16 23:36:37 +01:00
|
|
|
EFI_STATUS
|
2011-03-25 22:22:20 +01:00
|
|
|
EFIAPI
|
2010-11-16 23:36:37 +01:00
|
|
|
LoadEfiDriversFromRomImage (
|
|
|
|
VOID *RomBar,
|
|
|
|
UINTN RomSize,
|
|
|
|
CONST CHAR16 *FileName
|
|
|
|
)
|
|
|
|
|
|
|
|
{
|
|
|
|
EFI_PCI_EXPANSION_ROM_HEADER *EfiRomHeader;
|
|
|
|
PCI_DATA_STRUCTURE *Pcir;
|
|
|
|
UINTN ImageIndex;
|
|
|
|
UINTN RomBarOffset;
|
|
|
|
UINT32 ImageSize;
|
|
|
|
UINT16 ImageOffset;
|
|
|
|
EFI_HANDLE ImageHandle;
|
|
|
|
EFI_STATUS Status;
|
2011-03-25 22:22:20 +01:00
|
|
|
EFI_STATUS ReturnStatus;
|
2010-11-16 23:36:37 +01:00
|
|
|
CHAR16 RomFileName[280];
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *FilePath;
|
|
|
|
BOOLEAN SkipImage;
|
|
|
|
UINT32 DestinationSize;
|
|
|
|
UINT32 ScratchSize;
|
|
|
|
UINT8 *Scratch;
|
|
|
|
VOID *ImageBuffer;
|
|
|
|
VOID *DecompressedImageBuffer;
|
|
|
|
UINT32 ImageLength;
|
|
|
|
EFI_DECOMPRESS_PROTOCOL *Decompress;
|
2012-03-14 04:17:17 +01:00
|
|
|
UINT32 InitializationSize;
|
2010-11-16 23:36:37 +01:00
|
|
|
|
|
|
|
ImageIndex = 0;
|
2011-03-25 22:22:20 +01:00
|
|
|
ReturnStatus = EFI_NOT_FOUND;
|
2010-11-16 23:36:37 +01:00
|
|
|
RomBarOffset = (UINTN) RomBar;
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
|
|
|
EfiRomHeader = (EFI_PCI_EXPANSION_ROM_HEADER *) (UINTN) RomBarOffset;
|
|
|
|
|
2012-03-14 04:17:17 +01:00
|
|
|
if (EfiRomHeader->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
|
2015-02-03 22:22:53 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_CORRUPT), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
|
2010-11-16 23:36:37 +01:00
|
|
|
// PrintToken (STRING_TOKEN (STR_LOADPCIROM_IMAGE_CORRUPT), HiiHandle, ImageIndex);
|
2011-03-25 22:22:20 +01:00
|
|
|
return ReturnStatus;
|
2010-11-16 23:36:37 +01:00
|
|
|
}
|
|
|
|
|
2012-03-14 04:17:17 +01:00
|
|
|
//
|
|
|
|
// If the pointer to the PCI Data Structure is invalid, no further images can be located.
|
|
|
|
// The PCI Data Structure must be DWORD aligned.
|
|
|
|
//
|
|
|
|
if (EfiRomHeader->PcirOffset == 0 ||
|
|
|
|
(EfiRomHeader->PcirOffset & 3) != 0 ||
|
|
|
|
RomBarOffset - (UINTN)RomBar + EfiRomHeader->PcirOffset + sizeof (PCI_DATA_STRUCTURE) > RomSize) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-11-16 23:36:37 +01:00
|
|
|
Pcir = (PCI_DATA_STRUCTURE *) (UINTN) (RomBarOffset + EfiRomHeader->PcirOffset);
|
2012-03-14 04:17:17 +01:00
|
|
|
//
|
|
|
|
// If a valid signature is not present in the PCI Data Structure, no further images can be located.
|
|
|
|
//
|
|
|
|
if (Pcir->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
|
|
|
|
break;
|
|
|
|
}
|
2010-11-16 23:36:37 +01:00
|
|
|
ImageSize = Pcir->ImageLength * 512;
|
2012-03-14 04:17:17 +01:00
|
|
|
if (RomBarOffset - (UINTN)RomBar + ImageSize > RomSize) {
|
|
|
|
break;
|
|
|
|
}
|
2010-11-16 23:36:37 +01:00
|
|
|
|
|
|
|
if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) &&
|
2012-03-14 04:17:17 +01:00
|
|
|
(EfiRomHeader->EfiSignature == EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE) &&
|
|
|
|
((EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) ||
|
|
|
|
(EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER))) {
|
|
|
|
|
|
|
|
ImageOffset = EfiRomHeader->EfiImageHeaderOffset;
|
|
|
|
InitializationSize = EfiRomHeader->InitializationSize * 512;
|
2010-11-16 23:36:37 +01:00
|
|
|
|
2012-03-14 04:17:17 +01:00
|
|
|
if (InitializationSize <= ImageSize && ImageOffset < InitializationSize) {
|
2010-11-16 23:36:37 +01:00
|
|
|
|
|
|
|
ImageBuffer = (VOID *) (UINTN) (RomBarOffset + ImageOffset);
|
2012-03-14 04:17:17 +01:00
|
|
|
ImageLength = InitializationSize - ImageOffset;
|
2010-11-16 23:36:37 +01:00
|
|
|
DecompressedImageBuffer = NULL;
|
|
|
|
|
|
|
|
//
|
|
|
|
// decompress here if needed
|
|
|
|
//
|
|
|
|
SkipImage = FALSE;
|
|
|
|
if (EfiRomHeader->CompressionType > EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {
|
|
|
|
SkipImage = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EfiRomHeader->CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {
|
|
|
|
Status = gBS->LocateProtocol (&gEfiDecompressProtocolGuid, NULL, (VOID**)&Decompress);
|
|
|
|
ASSERT_EFI_ERROR(Status);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
SkipImage = TRUE;
|
|
|
|
} else {
|
|
|
|
SkipImage = TRUE;
|
|
|
|
Status = Decompress->GetInfo (
|
|
|
|
Decompress,
|
|
|
|
ImageBuffer,
|
|
|
|
ImageLength,
|
|
|
|
&DestinationSize,
|
|
|
|
&ScratchSize
|
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
2011-03-25 22:22:20 +01:00
|
|
|
DecompressedImageBuffer = AllocateZeroPool (DestinationSize);
|
2010-11-16 23:36:37 +01:00
|
|
|
if (ImageBuffer != NULL) {
|
2011-03-25 22:22:20 +01:00
|
|
|
Scratch = AllocateZeroPool (ScratchSize);
|
2010-11-16 23:36:37 +01:00
|
|
|
if (Scratch != NULL) {
|
|
|
|
Status = Decompress->Decompress (
|
|
|
|
Decompress,
|
|
|
|
ImageBuffer,
|
|
|
|
ImageLength,
|
|
|
|
DecompressedImageBuffer,
|
|
|
|
DestinationSize,
|
|
|
|
Scratch,
|
|
|
|
ScratchSize
|
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
ImageBuffer = DecompressedImageBuffer;
|
|
|
|
ImageLength = DestinationSize;
|
|
|
|
SkipImage = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
FreePool (Scratch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SkipImage) {
|
|
|
|
//
|
|
|
|
// load image and start image
|
|
|
|
//
|
|
|
|
UnicodeSPrint (RomFileName, sizeof (RomFileName), L"%s[%d]", FileName, ImageIndex);
|
|
|
|
FilePath = FileDevicePath (NULL, RomFileName);
|
|
|
|
|
|
|
|
Status = gBS->LoadImage (
|
|
|
|
TRUE,
|
|
|
|
gImageHandle,
|
|
|
|
FilePath,
|
|
|
|
ImageBuffer,
|
|
|
|
ImageLength,
|
|
|
|
&ImageHandle
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
2015-02-03 22:22:53 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_LOAD_FAIL), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
|
2010-11-16 23:36:37 +01:00
|
|
|
// PrintToken (STRING_TOKEN (STR_LOADPCIROM_LOAD_IMAGE_ERROR), HiiHandle, ImageIndex, Status);
|
|
|
|
} else {
|
|
|
|
Status = gBS->StartImage (ImageHandle, NULL, NULL);
|
|
|
|
if (EFI_ERROR (Status)) {
|
2015-02-03 22:22:53 +01:00
|
|
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LOADPCIROM_START_FAIL), gShellDebug1HiiHandle, L"loadpcirom", FileName, ImageIndex);
|
2010-11-16 23:36:37 +01:00
|
|
|
// PrintToken (STRING_TOKEN (STR_LOADPCIROM_START_IMAGE), HiiHandle, ImageIndex, Status);
|
|
|
|
} else {
|
2011-03-25 22:22:20 +01:00
|
|
|
ReturnStatus = Status;
|
2010-11-16 23:36:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DecompressedImageBuffer != NULL) {
|
|
|
|
FreePool (DecompressedImageBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RomBarOffset = RomBarOffset + ImageSize;
|
|
|
|
ImageIndex++;
|
|
|
|
} while (((Pcir->Indicator & 0x80) == 0x00) && ((RomBarOffset - (UINTN) RomBar) < RomSize));
|
|
|
|
|
2011-03-25 22:22:20 +01:00
|
|
|
return ReturnStatus;
|
2010-11-16 23:36:37 +01:00
|
|
|
}
|
|
|
|
|
2011-03-25 22:22:20 +01:00
|
|
|
/**
|
|
|
|
Connects all available drives and controllers.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
@retval EFI_ABORTED The abort mechanism was received.
|
|
|
|
**/
|
2010-11-16 23:36:37 +01:00
|
|
|
EFI_STATUS
|
|
|
|
LoadPciRomConnectAllDriversToAllControllers (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINTN HandleCount;
|
|
|
|
EFI_HANDLE *HandleBuffer;
|
2016-07-22 04:14:05 +02:00
|
|
|
UINTN Index;
|
|
|
|
|
|
|
|
Status = gBS->LocateHandleBuffer (
|
|
|
|
AllHandles,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&HandleCount,
|
|
|
|
&HandleBuffer
|
|
|
|
);
|
2010-11-16 23:36:37 +01:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2016-07-22 04:14:05 +02:00
|
|
|
for (Index = 0; Index < HandleCount; Index++) {
|
2010-11-16 23:36:37 +01:00
|
|
|
if (ShellGetExecutionBreakFlag ()) {
|
|
|
|
Status = EFI_ABORTED;
|
2016-07-22 04:14:05 +02:00
|
|
|
break;
|
2010-11-16 23:36:37 +01:00
|
|
|
}
|
2016-07-22 04:14:05 +02:00
|
|
|
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
|
|
|
|
}
|
2010-11-16 23:36:37 +01:00
|
|
|
|
2016-07-22 04:14:05 +02:00
|
|
|
if (HandleBuffer != NULL) {
|
2010-11-16 23:36:37 +01:00
|
|
|
FreePool (HandleBuffer);
|
|
|
|
}
|
|
|
|
return Status;
|
|
|
|
}
|