mirror of https://github.com/acidanthera/audk.git
ArmPkg: remove BdsLib and remaining ARM BDS related PCDs
With the last user FdtPlatformDxe removed, we can finally get rid of the last bit of ARM BDS related cruft. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
This commit is contained in:
parent
34b17101ef
commit
fc82cfc24c
|
@ -113,14 +113,6 @@
|
|||
#
|
||||
gArmTokenSpaceGuid.PcdL2x0ControllerBase|0|UINT32|0x0000001B
|
||||
|
||||
#
|
||||
# BdsLib
|
||||
#
|
||||
# The compressed Linux kernel is expected to be under 128MB from the beginning of the System Memory
|
||||
gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset|0x08000000|UINT32|0x0000001F
|
||||
# Maximum file size for TFTP servers that do not support 'tsize' extension
|
||||
gArmTokenSpaceGuid.PcdMaxTftpFileSize|0x01000000|UINT32|0x00000000
|
||||
|
||||
#
|
||||
# ARM Normal (or Non Secure) Firmware PCDs
|
||||
#
|
||||
|
|
|
@ -76,7 +76,6 @@
|
|||
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
|
||||
SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
|
||||
|
||||
BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf
|
||||
FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
|
||||
|
||||
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
|
||||
|
@ -104,7 +103,6 @@
|
|||
[Components.common]
|
||||
ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
|
||||
ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
|
||||
ArmPkg/Library/BdsLib/BdsLib.inf
|
||||
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
|
||||
ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
|
||||
ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
|
||||
|
|
|
@ -1,253 +0,0 @@
|
|||
/** @file
|
||||
*
|
||||
* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
|
||||
*
|
||||
* 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 "BdsInternal.h"
|
||||
|
||||
/**
|
||||
Locate an EFI application in a the Firmware Volumes by its Name
|
||||
|
||||
@param EfiAppGuid Guid of the EFI Application into the Firmware Volume
|
||||
@param DevicePath EFI Device Path of the EFI application
|
||||
|
||||
@return EFI_SUCCESS The function completed successfully.
|
||||
@return EFI_NOT_FOUND The protocol could not be located.
|
||||
@return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
LocateEfiApplicationInFvByName (
|
||||
IN CONST CHAR16* EfiAppName,
|
||||
OUT EFI_DEVICE_PATH **DevicePath
|
||||
)
|
||||
{
|
||||
VOID *Key;
|
||||
EFI_STATUS Status, FileStatus;
|
||||
EFI_GUID NameGuid;
|
||||
EFI_FV_FILETYPE FileType;
|
||||
EFI_FV_FILE_ATTRIBUTES Attributes;
|
||||
UINTN Size;
|
||||
UINTN UiStringLen;
|
||||
CHAR16 *UiSection;
|
||||
UINT32 Authentication;
|
||||
EFI_DEVICE_PATH *FvDevicePath;
|
||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileDevicePath;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
UINTN NumberOfHandles;
|
||||
UINTN Index;
|
||||
EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance;
|
||||
|
||||
ASSERT (DevicePath != NULL);
|
||||
|
||||
// Length of FilePath
|
||||
UiStringLen = StrLen (EfiAppName);
|
||||
|
||||
// Locate all the Firmware Volume protocols.
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
&gEfiFirmwareVolume2ProtocolGuid,
|
||||
NULL,
|
||||
&NumberOfHandles,
|
||||
&HandleBuffer
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
*DevicePath = NULL;
|
||||
|
||||
// Looking for FV with ACPI storage file
|
||||
for (Index = 0; Index < NumberOfHandles; Index++) {
|
||||
//
|
||||
// Get the protocol on this handle
|
||||
// This should not fail because of LocateHandleBuffer
|
||||
//
|
||||
Status = gBS->HandleProtocol (
|
||||
HandleBuffer[Index],
|
||||
&gEfiFirmwareVolume2ProtocolGuid,
|
||||
(VOID**) &FvInstance
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FREE_HANDLE_BUFFER;
|
||||
}
|
||||
|
||||
// Allocate Key
|
||||
Key = AllocatePool (FvInstance->KeySize);
|
||||
ASSERT (Key != NULL);
|
||||
ZeroMem (Key, FvInstance->KeySize);
|
||||
|
||||
do {
|
||||
// Search in all files
|
||||
FileType = EFI_FV_FILETYPE_ALL;
|
||||
|
||||
Status = FvInstance->GetNextFile (FvInstance, Key, &FileType, &NameGuid, &Attributes, &Size);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
UiSection = NULL;
|
||||
FileStatus = FvInstance->ReadSection (
|
||||
FvInstance,
|
||||
&NameGuid,
|
||||
EFI_SECTION_USER_INTERFACE,
|
||||
0,
|
||||
(VOID **)&UiSection,
|
||||
&Size,
|
||||
&Authentication
|
||||
);
|
||||
if (!EFI_ERROR (FileStatus)) {
|
||||
if (StrnCmp (EfiAppName, UiSection, UiStringLen) == 0) {
|
||||
//
|
||||
// We found a UiString match.
|
||||
//
|
||||
Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **)&FvDevicePath);
|
||||
|
||||
// Generate the Device Path for the file
|
||||
EfiInitializeFwVolDevicepathNode (&FileDevicePath, &NameGuid);
|
||||
*DevicePath = AppendDevicePathNode (FvDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&FileDevicePath);
|
||||
ASSERT (*DevicePath != NULL);
|
||||
|
||||
FreePool (Key);
|
||||
FreePool (UiSection);
|
||||
FreePool (HandleBuffer);
|
||||
return FileStatus;
|
||||
}
|
||||
FreePool (UiSection);
|
||||
}
|
||||
}
|
||||
} while (!EFI_ERROR (Status));
|
||||
|
||||
FreePool (Key);
|
||||
}
|
||||
|
||||
FREE_HANDLE_BUFFER:
|
||||
FreePool (HandleBuffer);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
Locate an EFI application in a the Firmware Volumes by its GUID
|
||||
|
||||
@param EfiAppGuid Guid of the EFI Application into the Firmware Volume
|
||||
@param DevicePath EFI Device Path of the EFI application
|
||||
|
||||
@return EFI_SUCCESS The function completed successfully.
|
||||
@return EFI_NOT_FOUND The protocol could not be located.
|
||||
@return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
LocateEfiApplicationInFvByGuid (
|
||||
IN CONST EFI_GUID *EfiAppGuid,
|
||||
OUT EFI_DEVICE_PATH **DevicePath
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH *FvDevicePath;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
UINTN NumberOfHandles;
|
||||
UINTN Index;
|
||||
EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance;
|
||||
EFI_FV_FILE_ATTRIBUTES Attributes;
|
||||
UINT32 AuthenticationStatus;
|
||||
EFI_FV_FILETYPE Type;
|
||||
UINTN Size;
|
||||
CHAR16 *UiSection;
|
||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FvFileDevicePath;
|
||||
|
||||
ASSERT (DevicePath != NULL);
|
||||
|
||||
// Locate all the Firmware Volume protocols.
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
&gEfiFirmwareVolume2ProtocolGuid,
|
||||
NULL,
|
||||
&NumberOfHandles,
|
||||
&HandleBuffer
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
*DevicePath = NULL;
|
||||
|
||||
// Looking for FV with ACPI storage file
|
||||
for (Index = 0; Index < NumberOfHandles; Index++) {
|
||||
//
|
||||
// Get the protocol on this handle
|
||||
// This should not fail because of LocateHandleBuffer
|
||||
//
|
||||
Status = gBS->HandleProtocol (
|
||||
HandleBuffer[Index],
|
||||
&gEfiFirmwareVolume2ProtocolGuid,
|
||||
(VOID**) &FvInstance
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FREE_HANDLE_BUFFER;
|
||||
}
|
||||
|
||||
Status = FvInstance->ReadFile (
|
||||
FvInstance,
|
||||
EfiAppGuid,
|
||||
NULL,
|
||||
&Size,
|
||||
&Type,
|
||||
&Attributes,
|
||||
&AuthenticationStatus
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// Skip if no EFI application file in the FV
|
||||
//
|
||||
continue;
|
||||
} else {
|
||||
UiSection = NULL;
|
||||
Status = FvInstance->ReadSection (
|
||||
FvInstance,
|
||||
EfiAppGuid,
|
||||
EFI_SECTION_USER_INTERFACE,
|
||||
0,
|
||||
(VOID **)&UiSection,
|
||||
&Size,
|
||||
&AuthenticationStatus
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
// Create the EFI Device Path for the application using the Filename of the application
|
||||
//
|
||||
*DevicePath = FileDevicePath (HandleBuffer[Index], UiSection);
|
||||
} else {
|
||||
Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID**)&FvDevicePath);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Create the EFI Device Path for the application using the EFI GUID of the application
|
||||
//
|
||||
EfiInitializeFwVolDevicepathNode (&FvFileDevicePath, EfiAppGuid);
|
||||
|
||||
*DevicePath = AppendDevicePathNode (FvDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&FvFileDevicePath);
|
||||
ASSERT (*DevicePath != NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FREE_HANDLE_BUFFER:
|
||||
//
|
||||
// Free any allocated buffers
|
||||
//
|
||||
FreePool (HandleBuffer);
|
||||
|
||||
if (*DevicePath == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
} else {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,183 +0,0 @@
|
|||
/** @file
|
||||
*
|
||||
* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
|
||||
*
|
||||
* 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 "BdsInternal.h"
|
||||
|
||||
EFI_STATUS
|
||||
ShutdownUefiBootServices (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN MemoryMapSize;
|
||||
EFI_MEMORY_DESCRIPTOR *MemoryMap;
|
||||
UINTN MapKey;
|
||||
UINTN DescriptorSize;
|
||||
UINT32 DescriptorVersion;
|
||||
UINTN Pages;
|
||||
|
||||
MemoryMap = NULL;
|
||||
MemoryMapSize = 0;
|
||||
Pages = 0;
|
||||
|
||||
do {
|
||||
Status = gBS->GetMemoryMap (
|
||||
&MemoryMapSize,
|
||||
MemoryMap,
|
||||
&MapKey,
|
||||
&DescriptorSize,
|
||||
&DescriptorVersion
|
||||
);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
|
||||
Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1;
|
||||
MemoryMap = AllocatePages (Pages);
|
||||
|
||||
//
|
||||
// Get System MemoryMap
|
||||
//
|
||||
Status = gBS->GetMemoryMap (
|
||||
&MemoryMapSize,
|
||||
MemoryMap,
|
||||
&MapKey,
|
||||
&DescriptorSize,
|
||||
&DescriptorVersion
|
||||
);
|
||||
}
|
||||
|
||||
// Don't do anything between the GetMemoryMap() and ExitBootServices()
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = gBS->ExitBootServices (gImageHandle, MapKey);
|
||||
if (EFI_ERROR(Status)) {
|
||||
FreePages (MemoryMap, Pages);
|
||||
MemoryMap = NULL;
|
||||
MemoryMapSize = 0;
|
||||
}
|
||||
}
|
||||
} while (EFI_ERROR(Status));
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Connect all DXE drivers
|
||||
|
||||
@retval EFI_SUCCESS All drivers have been connected
|
||||
@retval EFI_NOT_FOUND No handles match the search.
|
||||
@retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BdsConnectAllDrivers (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN HandleCount, Index;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
EFI_STATUS Status;
|
||||
|
||||
do {
|
||||
// Locate all the driver handles
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
AllHandles,
|
||||
NULL,
|
||||
NULL,
|
||||
&HandleCount,
|
||||
&HandleBuffer
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Connect every handles
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
|
||||
// Check if new handles have been created after the start of the previous handles
|
||||
Status = gDS->Dispatch ();
|
||||
} while (!EFI_ERROR(Status));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
GetGlobalEnvironmentVariable (
|
||||
IN CONST CHAR16* VariableName,
|
||||
IN VOID* DefaultValue,
|
||||
IN OUT UINTN* Size,
|
||||
OUT VOID** Value
|
||||
)
|
||||
{
|
||||
return GetEnvironmentVariable (VariableName, &gEfiGlobalVariableGuid,
|
||||
DefaultValue, Size, Value);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
GetEnvironmentVariable (
|
||||
IN CONST CHAR16* VariableName,
|
||||
IN EFI_GUID* VendorGuid,
|
||||
IN VOID* DefaultValue,
|
||||
IN OUT UINTN* Size,
|
||||
OUT VOID** Value
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN VariableSize;
|
||||
|
||||
// Try to get the variable size.
|
||||
*Value = NULL;
|
||||
VariableSize = 0;
|
||||
Status = gRT->GetVariable ((CHAR16 *) VariableName, VendorGuid, NULL, &VariableSize, *Value);
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
if ((DefaultValue != NULL) && (Size != NULL) && (*Size != 0)) {
|
||||
// If the environment variable does not exist yet then set it with the default value
|
||||
Status = gRT->SetVariable (
|
||||
(CHAR16*)VariableName,
|
||||
VendorGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
*Size,
|
||||
DefaultValue
|
||||
);
|
||||
*Value = AllocateCopyPool (*Size, DefaultValue);
|
||||
} else {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
} else if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
// Get the environment variable value
|
||||
*Value = AllocatePool (VariableSize);
|
||||
if (*Value == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = gRT->GetVariable ((CHAR16 *)VariableName, VendorGuid, NULL, &VariableSize, *Value);
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool(*Value);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Size) {
|
||||
*Size = VariableSize;
|
||||
}
|
||||
} else {
|
||||
*Value = AllocateCopyPool (*Size, DefaultValue);
|
||||
return Status;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
/** @file
|
||||
*
|
||||
* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
|
||||
*
|
||||
* 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 __BDS_INTERNAL_H__
|
||||
#define __BDS_INTERNAL_H__
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Library/ArmLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DxeServicesTableLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BdsLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
|
||||
#include <Guid/GlobalVariable.h>
|
||||
#include <Guid/FileInfo.h>
|
||||
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/DevicePathFromText.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <Protocol/FirmwareVolume2.h>
|
||||
#include <Protocol/LoadFile.h>
|
||||
#include <Protocol/PxeBaseCode.h>
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
/**
|
||||
* Check if the file loader can support this device path.
|
||||
*
|
||||
* @param DevicePath EFI Device Path of the image to load.
|
||||
* This device path generally comes from the boot entry (ie: Boot####).
|
||||
* @param Handle Handle of the driver supporting the device path
|
||||
* @param RemainingDevicePath Part of the EFI Device Path that has not been resolved during
|
||||
* the Device Path discovery
|
||||
*/
|
||||
typedef BOOLEAN (*BDS_FILE_LOADER_SUPPORT) (
|
||||
IN EFI_DEVICE_PATH *DevicePath,
|
||||
IN EFI_HANDLE Handle,
|
||||
IN EFI_DEVICE_PATH *RemainingDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
* Function to load an image from a given Device Path for a
|
||||
* specific support (FileSystem, TFTP, PXE, ...)
|
||||
*
|
||||
* @param DevicePath EFI Device Path of the image to load.
|
||||
* This device path generally comes from the boot entry (ie: Boot####).
|
||||
* This path is also defined as 'OUT' as there are some device paths that
|
||||
* might not be completed such as EFI path for removable device. In these
|
||||
* cases, it is expected the loader to add \EFI\BOOT\BOOT(ARM|AA64).EFI
|
||||
* @param Handle Handle of the driver supporting the device path
|
||||
* @param RemainingDevicePath Part of the EFI Device Path that has not been resolved during
|
||||
* the Device Path discovery
|
||||
* @param Type Define where the image should be loaded (see EFI_ALLOCATE_TYPE definition)
|
||||
* @param Image Base Address of the image has been loaded
|
||||
* @param ImageSize Size of the image that has been loaded
|
||||
*/
|
||||
typedef EFI_STATUS (*BDS_FILE_LOADER_LOAD_IMAGE) (
|
||||
IN OUT EFI_DEVICE_PATH **DevicePath,
|
||||
IN EFI_HANDLE Handle,
|
||||
IN EFI_DEVICE_PATH *RemainingDevicePath,
|
||||
IN EFI_ALLOCATE_TYPE Type,
|
||||
IN OUT EFI_PHYSICAL_ADDRESS* Image,
|
||||
OUT UINTN *ImageSize
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
BDS_FILE_LOADER_SUPPORT Support;
|
||||
BDS_FILE_LOADER_LOAD_IMAGE LoadImage;
|
||||
} BDS_FILE_LOADER;
|
||||
|
||||
typedef struct _BDS_SYSTEM_MEMORY_RESOURCE {
|
||||
LIST_ENTRY Link; // This attribute must be the first entry of this structure (to avoid pointer computation)
|
||||
EFI_PHYSICAL_ADDRESS PhysicalStart;
|
||||
UINT64 ResourceLength;
|
||||
} BDS_SYSTEM_MEMORY_RESOURCE;
|
||||
|
||||
typedef struct {
|
||||
UINT64 FileSize;
|
||||
UINT64 DownloadedNbOfBytes;
|
||||
UINT64 LastReportedNbOfBytes;
|
||||
} BDS_TFTP_CONTEXT;
|
||||
|
||||
EFI_STATUS
|
||||
BdsLoadImage (
|
||||
IN EFI_DEVICE_PATH *DevicePath,
|
||||
IN EFI_ALLOCATE_TYPE Type,
|
||||
IN OUT EFI_PHYSICAL_ADDRESS* Image,
|
||||
OUT UINTN *FileSize
|
||||
);
|
||||
|
||||
#endif
|
|
@ -1,69 +0,0 @@
|
|||
#/* @file
|
||||
#
|
||||
# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
|
||||
#
|
||||
# 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 = 0x00010005
|
||||
BASE_NAME = BdsLib
|
||||
FILE_GUID = ddbf73a0-bb25-11df-8e4e-0002a5d5c51b
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = BdsLib
|
||||
|
||||
[Sources.common]
|
||||
BdsFilePath.c
|
||||
BdsAppLoader.c
|
||||
BdsHelper.c
|
||||
BdsLoadOption.c
|
||||
|
||||
[Packages]
|
||||
EmbeddedPkg/EmbeddedPkg.dec
|
||||
ArmPkg/ArmPkg.dec
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
ArmPlatformPkg/ArmPlatformPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
ArmLib
|
||||
BaseLib
|
||||
DebugLib
|
||||
DevicePathLib
|
||||
HobLib
|
||||
PcdLib
|
||||
NetLib
|
||||
|
||||
[Guids]
|
||||
gEfiFileInfoGuid
|
||||
|
||||
[Protocols]
|
||||
gEfiBdsArchProtocolGuid
|
||||
gEfiDevicePathProtocolGuid
|
||||
gEfiDevicePathFromTextProtocolGuid
|
||||
gEfiSimpleFileSystemProtocolGuid
|
||||
gEfiFirmwareVolume2ProtocolGuid
|
||||
gEfiLoadFileProtocolGuid
|
||||
gEfiPxeBaseCodeProtocolGuid
|
||||
gEfiDiskIoProtocolGuid
|
||||
gEfiUsbIoProtocolGuid
|
||||
gEfiLoadedImageProtocolGuid
|
||||
gEfiSimpleNetworkProtocolGuid
|
||||
gEfiDhcp4ServiceBindingProtocolGuid
|
||||
gEfiDhcp4ProtocolGuid
|
||||
gEfiMtftp4ServiceBindingProtocolGuid
|
||||
gEfiMtftp4ProtocolGuid
|
||||
|
||||
[FixedPcd]
|
||||
gArmTokenSpaceGuid.PcdMaxTftpFileSize
|
||||
|
||||
[Depex]
|
||||
TRUE
|
|
@ -1,272 +0,0 @@
|
|||
/** @file
|
||||
*
|
||||
* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
|
||||
*
|
||||
* 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 "BdsInternal.h"
|
||||
|
||||
EFI_STATUS
|
||||
BootOptionParseLoadOption (
|
||||
IN EFI_LOAD_OPTION *EfiLoadOption,
|
||||
IN UINTN EfiLoadOptionSize,
|
||||
IN OUT BDS_LOAD_OPTION **BdsLoadOption
|
||||
)
|
||||
{
|
||||
BDS_LOAD_OPTION *LoadOption;
|
||||
UINTN DescriptionLength;
|
||||
UINTN EfiLoadOptionPtr;
|
||||
|
||||
if (EfiLoadOption == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (EfiLoadOptionSize < sizeof(UINT32) + sizeof(UINT16) + sizeof(CHAR16) + sizeof(EFI_DEVICE_PATH_PROTOCOL)) {
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
if (*BdsLoadOption == NULL) {
|
||||
LoadOption = (BDS_LOAD_OPTION*)AllocateZeroPool (sizeof(BDS_LOAD_OPTION));
|
||||
if (LoadOption == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
} else {
|
||||
LoadOption = *BdsLoadOption;
|
||||
}
|
||||
|
||||
EfiLoadOptionPtr = (UINTN)EfiLoadOption;
|
||||
LoadOption->LoadOption = EfiLoadOption;
|
||||
LoadOption->LoadOptionSize = EfiLoadOptionSize;
|
||||
|
||||
LoadOption->Attributes = *(UINT32*)EfiLoadOptionPtr;
|
||||
LoadOption->FilePathListLength = *(UINT16*)(EfiLoadOptionPtr + sizeof(UINT32));
|
||||
LoadOption->Description = (CHAR16*)(EfiLoadOptionPtr + sizeof(UINT32) + sizeof(UINT16));
|
||||
DescriptionLength = StrSize (LoadOption->Description);
|
||||
LoadOption->FilePathList = (EFI_DEVICE_PATH_PROTOCOL*)(EfiLoadOptionPtr + sizeof(UINT32) + sizeof(UINT16) + DescriptionLength);
|
||||
|
||||
// If ((End of EfiLoadOptiony - Start of EfiLoadOption) == EfiLoadOptionSize) then No Optional Data
|
||||
if ((UINTN)((UINTN)LoadOption->FilePathList + LoadOption->FilePathListLength - EfiLoadOptionPtr) == EfiLoadOptionSize) {
|
||||
LoadOption->OptionalData = NULL;
|
||||
LoadOption->OptionalDataSize = 0;
|
||||
} else {
|
||||
LoadOption->OptionalData = (VOID*)((UINTN)(LoadOption->FilePathList) + LoadOption->FilePathListLength);
|
||||
LoadOption->OptionalDataSize = EfiLoadOptionSize - ((UINTN)LoadOption->OptionalData - EfiLoadOptionPtr);
|
||||
}
|
||||
|
||||
if (*BdsLoadOption == NULL) {
|
||||
*BdsLoadOption = LoadOption;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
BootOptionFromLoadOptionVariable (
|
||||
IN CHAR16* BootVariableName,
|
||||
OUT BDS_LOAD_OPTION** BdsLoadOption
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_LOAD_OPTION *EfiLoadOption;
|
||||
UINTN EfiLoadOptionSize;
|
||||
|
||||
Status = GetGlobalEnvironmentVariable (BootVariableName, NULL, &EfiLoadOptionSize, (VOID**)&EfiLoadOption);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
*BdsLoadOption = NULL;
|
||||
Status = BootOptionParseLoadOption (EfiLoadOption, EfiLoadOptionSize, BdsLoadOption);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
BootOptionFromLoadOptionIndex (
|
||||
IN UINT16 LoadOptionIndex,
|
||||
OUT BDS_LOAD_OPTION **BdsLoadOption
|
||||
)
|
||||
{
|
||||
CHAR16 BootVariableName[9];
|
||||
EFI_STATUS Status;
|
||||
|
||||
UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", LoadOptionIndex);
|
||||
|
||||
Status = BootOptionFromLoadOptionVariable (BootVariableName, BdsLoadOption);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
(*BdsLoadOption)->LoadOptionIndex = LoadOptionIndex;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
BootOptionToLoadOptionVariable (
|
||||
IN BDS_LOAD_OPTION* BdsLoadOption
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN DescriptionSize;
|
||||
//UINT16 FilePathListLength;
|
||||
EFI_DEVICE_PATH_PROTOCOL* DevicePathNode;
|
||||
UINTN NodeLength;
|
||||
UINT8* EfiLoadOptionPtr;
|
||||
VOID* OldLoadOption;
|
||||
CHAR16 BootVariableName[9];
|
||||
UINTN BootOrderSize;
|
||||
UINT16* BootOrder;
|
||||
|
||||
// If we are overwriting an existent Boot Option then we have to free previously allocated memory
|
||||
if (BdsLoadOption->LoadOptionSize > 0) {
|
||||
OldLoadOption = BdsLoadOption->LoadOption;
|
||||
} else {
|
||||
OldLoadOption = NULL;
|
||||
|
||||
// If this function is called at the creation of the Boot Device entry (not at the update) the
|
||||
// BootOption->LoadOptionSize must be zero then we get a new BootIndex for this entry
|
||||
BdsLoadOption->LoadOptionIndex = BootOptionAllocateBootIndex ();
|
||||
|
||||
//TODO: Add to the the Boot Entry List
|
||||
}
|
||||
|
||||
DescriptionSize = StrSize(BdsLoadOption->Description);
|
||||
|
||||
// Ensure the FilePathListLength information is correct
|
||||
ASSERT (GetDevicePathSize (BdsLoadOption->FilePathList) == BdsLoadOption->FilePathListLength);
|
||||
|
||||
// Allocate the memory for the EFI Load Option
|
||||
BdsLoadOption->LoadOptionSize = sizeof(UINT32) + sizeof(UINT16) + DescriptionSize + BdsLoadOption->FilePathListLength + BdsLoadOption->OptionalDataSize;
|
||||
|
||||
BdsLoadOption->LoadOption = (EFI_LOAD_OPTION *)AllocateZeroPool (BdsLoadOption->LoadOptionSize);
|
||||
if (BdsLoadOption->LoadOption == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
EfiLoadOptionPtr = (UINT8 *) BdsLoadOption->LoadOption;
|
||||
|
||||
//
|
||||
// Populate the EFI Load Option and BDS Boot Option structures
|
||||
//
|
||||
|
||||
// Attributes fields
|
||||
*(UINT32*)EfiLoadOptionPtr = BdsLoadOption->Attributes;
|
||||
EfiLoadOptionPtr += sizeof(UINT32);
|
||||
|
||||
// FilePath List fields
|
||||
*(UINT16*)EfiLoadOptionPtr = BdsLoadOption->FilePathListLength;
|
||||
EfiLoadOptionPtr += sizeof(UINT16);
|
||||
|
||||
// Boot description fields
|
||||
CopyMem (EfiLoadOptionPtr, BdsLoadOption->Description, DescriptionSize);
|
||||
EfiLoadOptionPtr += DescriptionSize;
|
||||
|
||||
// File path fields
|
||||
DevicePathNode = BdsLoadOption->FilePathList;
|
||||
while (!IsDevicePathEndType (DevicePathNode)) {
|
||||
NodeLength = DevicePathNodeLength(DevicePathNode);
|
||||
CopyMem (EfiLoadOptionPtr, DevicePathNode, NodeLength);
|
||||
EfiLoadOptionPtr += NodeLength;
|
||||
DevicePathNode = NextDevicePathNode (DevicePathNode);
|
||||
}
|
||||
|
||||
// Set the End Device Path Type
|
||||
SetDevicePathEndNode (EfiLoadOptionPtr);
|
||||
EfiLoadOptionPtr += sizeof(EFI_DEVICE_PATH);
|
||||
|
||||
// Fill the Optional Data
|
||||
if (BdsLoadOption->OptionalDataSize > 0) {
|
||||
CopyMem (EfiLoadOptionPtr, BdsLoadOption->OptionalData, BdsLoadOption->OptionalDataSize);
|
||||
}
|
||||
|
||||
// Case where the fields have been updated
|
||||
if (OldLoadOption) {
|
||||
// Now, the old data has been copied to the new allocated packed structure, we need to update the pointers of BdsLoadOption
|
||||
BootOptionParseLoadOption (BdsLoadOption->LoadOption, BdsLoadOption->LoadOptionSize, &BdsLoadOption);
|
||||
// Free the old packed structure
|
||||
FreePool (OldLoadOption);
|
||||
}
|
||||
|
||||
// Create/Update Boot#### environment variable
|
||||
UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BdsLoadOption->LoadOptionIndex);
|
||||
Status = gRT->SetVariable (
|
||||
BootVariableName,
|
||||
&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
BdsLoadOption->LoadOptionSize,
|
||||
BdsLoadOption->LoadOption
|
||||
);
|
||||
|
||||
// When it is a new entry we must add the entry to the BootOrder
|
||||
if (OldLoadOption == NULL) {
|
||||
// Add the new Boot Index to the list
|
||||
Status = GetGlobalEnvironmentVariable (L"BootOrder", NULL, &BootOrderSize, (VOID**)&BootOrder);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
BootOrder = ReallocatePool (BootOrderSize, BootOrderSize + sizeof(UINT16), BootOrder);
|
||||
// Add the new index at the end
|
||||
BootOrder[BootOrderSize / sizeof(UINT16)] = BdsLoadOption->LoadOptionIndex;
|
||||
BootOrderSize += sizeof(UINT16);
|
||||
} else {
|
||||
// BootOrder does not exist. Create it
|
||||
BootOrderSize = sizeof(UINT16);
|
||||
BootOrder = &(BdsLoadOption->LoadOptionIndex);
|
||||
}
|
||||
|
||||
// Update (or Create) the BootOrder environment variable
|
||||
gRT->SetVariable (
|
||||
L"BootOrder",
|
||||
&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
BootOrderSize,
|
||||
BootOrder
|
||||
);
|
||||
DEBUG((EFI_D_ERROR,"Create %s\n",BootVariableName));
|
||||
|
||||
// Free memory allocated by GetGlobalEnvironmentVariable
|
||||
if (!EFI_ERROR(Status)) {
|
||||
FreePool (BootOrder);
|
||||
}
|
||||
} else {
|
||||
DEBUG((EFI_D_ERROR,"Update %s\n",BootVariableName));
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
UINT16
|
||||
BootOptionAllocateBootIndex (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
UINT32 BootIndex;
|
||||
UINT16 *BootOrder;
|
||||
UINTN BootOrderSize;
|
||||
BOOLEAN Found;
|
||||
|
||||
// Get the Boot Option Order from the environment variable
|
||||
Status = GetGlobalEnvironmentVariable (L"BootOrder", NULL, &BootOrderSize, (VOID**)&BootOrder);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
for (BootIndex = 0; BootIndex <= 0xFFFF; BootIndex++) {
|
||||
Found = FALSE;
|
||||
for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {
|
||||
if (BootOrder[Index] == BootIndex) {
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!Found) {
|
||||
return BootIndex;
|
||||
}
|
||||
}
|
||||
FreePool (BootOrder);
|
||||
}
|
||||
// Return the first index
|
||||
return 0;
|
||||
}
|
|
@ -345,9 +345,6 @@
|
|||
# Size of the region used by UEFI in permanent memory (Reserved 16MB)
|
||||
gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x01000000
|
||||
|
||||
# Size of the region reserved for fixed address allocations (Reserved 32MB)
|
||||
gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset|0x02000000
|
||||
|
||||
gArmTokenSpaceGuid.PcdCpuVectorBaseAddress|0x80008000
|
||||
gArmTokenSpaceGuid.PcdCpuResetAddress|0x80008000
|
||||
|
||||
|
|
|
@ -129,7 +129,6 @@
|
|||
[LibraryClasses.ARM, LibraryClasses.AARCH64]
|
||||
ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
|
||||
ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
|
||||
BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf
|
||||
SemihostLib|ArmPkg/Library/SemihostLib/SemihostLib.inf
|
||||
NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
|
||||
|
||||
|
|
Loading…
Reference in New Issue