mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-25 22:54:51 +02:00
ArmPlatformPkg/Bds: Fix various bugs in the new BDS
The errors were: - uncaught returned error - used of uninitialized variables ArmPlatformPkg/Bds: Implement the update of MemMap Boot Device git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11830 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
e862cd50c6
commit
6bab33c7b6
@ -15,6 +15,25 @@
|
|||||||
#ifndef __BDS_ENTRY_H__
|
#ifndef __BDS_ENTRY_H__
|
||||||
#define __BDS_ENTRY_H__
|
#define __BDS_ENTRY_H__
|
||||||
|
|
||||||
|
/**
|
||||||
|
Connect a Device Path and return the handle of the driver that support this DevicePath
|
||||||
|
|
||||||
|
@param DevicePath Device Path of the File to connect
|
||||||
|
@param Handle Handle of the driver that support this DevicePath
|
||||||
|
@param RemainingDevicePath Remaining DevicePath nodes that do not match the driver DevicePath
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS A driver that matches the Device Path has been found
|
||||||
|
@retval EFI_NOT_FOUND No handles match the search.
|
||||||
|
@retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
BdsConnectDevicePath (
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
|
||||||
|
OUT EFI_HANDLE *Handle,
|
||||||
|
OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Connect all DXE drivers
|
Connect all DXE drivers
|
||||||
|
|
||||||
@ -32,7 +51,7 @@ BdsConnectAllDrivers (
|
|||||||
Start a Linux kernel from a Device Path
|
Start a Linux kernel from a Device Path
|
||||||
|
|
||||||
@param LinuxKernel Device Path to the Linux Kernel
|
@param LinuxKernel Device Path to the Linux Kernel
|
||||||
@param Parameters Linux kernel agruments
|
@param Parameters Linux kernel arguments
|
||||||
@param Fdt Device Path to the Flat Device Tree
|
@param Fdt Device Path to the Flat Device Tree
|
||||||
|
|
||||||
@retval EFI_SUCCESS All drivers have been connected
|
@retval EFI_SUCCESS All drivers have been connected
|
||||||
@ -47,6 +66,23 @@ BdsBootLinux (
|
|||||||
IN EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath
|
IN EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Start an EFI Application from a Device Path
|
||||||
|
|
||||||
|
@param ParentImageHandle Handle of the calling image
|
||||||
|
@param DevicePath Location of the EFI Application
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS All drivers have been connected
|
||||||
|
@retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
|
||||||
|
@retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
BdsStartEfiApplication (
|
||||||
|
IN EFI_HANDLE ParentImageHandle,
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Start an EFI Application from any Firmware Volume
|
Start an EFI Application from any Firmware Volume
|
||||||
|
|
||||||
|
@ -298,6 +298,18 @@ TryRemovableDevice (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Connect a Device Path and return the handle of the driver that support this DevicePath
|
||||||
|
|
||||||
|
@param DevicePath Device Path of the File to connect
|
||||||
|
@param Handle Handle of the driver that support this DevicePath
|
||||||
|
@param RemainingDevicePath Remaining DevicePath nodes that do not match the driver DevicePath
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS A driver that matches the Device Path has been found
|
||||||
|
@retval EFI_NOT_FOUND No handles match the search.
|
||||||
|
@retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL
|
||||||
|
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
BdsConnectDevicePath (
|
BdsConnectDevicePath (
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
|
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
|
||||||
@ -335,7 +347,7 @@ BdsConnectDevicePath (
|
|||||||
// Now, we have got the whole Device Path connected, call again ConnectController to ensure all the supported Driver
|
// Now, we have got the whole Device Path connected, call again ConnectController to ensure all the supported Driver
|
||||||
// Binding Protocol are connected (such as DiskIo and SimpleFileSystem)
|
// Binding Protocol are connected (such as DiskIo and SimpleFileSystem)
|
||||||
Remaining = DevicePath;
|
Remaining = DevicePath;
|
||||||
Status = gBS->LocateDevicePath(&gEfiDevicePathProtocolGuid,&Remaining,Handle);
|
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid,&Remaining,Handle);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
Status = gBS->ConnectController (*Handle, NULL, Remaining, FALSE);
|
Status = gBS->ConnectController (*Handle, NULL, Remaining, FALSE);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
@ -420,6 +432,9 @@ BdsFileSystemLoadImage (
|
|||||||
|
|
||||||
File = NULL;
|
File = NULL;
|
||||||
Status = Fs->Open(Fs, &File, FilePathDevicePath->PathName, EFI_FILE_MODE_READ, 0);
|
Status = Fs->Open(Fs, &File, FilePathDevicePath->PathName, EFI_FILE_MODE_READ, 0);
|
||||||
|
if (EFI_ERROR(Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
Size = 0;
|
Size = 0;
|
||||||
File->GetInfo(File, &gEfiFileInfoGuid, &Size, NULL);
|
File->GetInfo(File, &gEfiFileInfoGuid, &Size, NULL);
|
||||||
@ -811,6 +826,17 @@ BdsLoadImage (
|
|||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Start an EFI Application from a Device Path
|
||||||
|
|
||||||
|
@param ParentImageHandle Handle of the calling image
|
||||||
|
@param DevicePath Location of the EFI Application
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS All drivers have been connected
|
||||||
|
@retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
|
||||||
|
@retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
|
||||||
|
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
BdsStartEfiApplication (
|
BdsStartEfiApplication (
|
||||||
IN EFI_HANDLE ParentImageHandle,
|
IN EFI_HANDLE ParentImageHandle,
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <Library/DevicePathLib.h>
|
#include <Library/DevicePathLib.h>
|
||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/BdsLib.h>
|
||||||
#include <Library/BdsUnixLib.h>
|
#include <Library/BdsUnixLib.h>
|
||||||
#include <Library/PerformanceLib.h>
|
#include <Library/PerformanceLib.h>
|
||||||
|
|
||||||
|
@ -258,8 +258,13 @@ BootOptionSetFields (
|
|||||||
CopyMem (&((BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments, BootArguments, AsciiStrSize(BootArguments));
|
CopyMem (&((BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments, BootArguments, AsciiStrSize(BootArguments));
|
||||||
BootOption->OptionalData = (BDS_LOADER_OPTIONAL_DATA *)EfiLoadOptionPtr;
|
BootOption->OptionalData = (BDS_LOADER_OPTIONAL_DATA *)EfiLoadOptionPtr;
|
||||||
|
|
||||||
// Fill the EFI Load option fields
|
// 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
|
||||||
|
if (BootOption->LoadOptionSize == 0) {
|
||||||
BootOption->LoadOptionIndex = BootOptionAllocateBootIndex();
|
BootOption->LoadOptionIndex = BootOptionAllocateBootIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill the EFI Load option fields
|
||||||
BootOption->LoadOption = EfiLoadOption;
|
BootOption->LoadOption = EfiLoadOption;
|
||||||
BootOption->LoadOptionSize = EfiLoadOptionSize;
|
BootOption->LoadOptionSize = EfiLoadOptionSize;
|
||||||
|
|
||||||
@ -341,20 +346,20 @@ BootOptionUpdate (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
BDS_LOAD_OPTION *BootOption;
|
|
||||||
CHAR16 BootVariableName[9];
|
CHAR16 BootVariableName[9];
|
||||||
|
|
||||||
// Update the BDS Load Option structure
|
// Update the BDS Load Option structure
|
||||||
BootOptionSetFields (BdsLoadOption, Attributes, BootDescription, DevicePath, BootType, BootArguments);
|
BootOptionSetFields (BdsLoadOption, Attributes, BootDescription, DevicePath, BootType, BootArguments);
|
||||||
|
|
||||||
// Update the related environment variables
|
// Update the related environment variables
|
||||||
UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BootOption->LoadOptionIndex);
|
UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BdsLoadOption->LoadOptionIndex);
|
||||||
|
|
||||||
Status = gRT->SetVariable (
|
Status = gRT->SetVariable (
|
||||||
BootVariableName,
|
BootVariableName,
|
||||||
&gEfiGlobalVariableGuid,
|
&gEfiGlobalVariableGuid,
|
||||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||||
BootOption->LoadOptionSize,
|
BdsLoadOption->LoadOptionSize,
|
||||||
BootOption->LoadOption
|
BdsLoadOption->LoadOption
|
||||||
);
|
);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -386,7 +386,7 @@ BdsLoadOptionFileSystemUpdateDevicePath (
|
|||||||
|
|
||||||
Print(L"File path of the EFI Application or the kernel: ");
|
Print(L"File path of the EFI Application or the kernel: ");
|
||||||
UnicodeStrToAsciiStr (EndingDevicePath->PathName,AsciiBootFilePath);
|
UnicodeStrToAsciiStr (EndingDevicePath->PathName,AsciiBootFilePath);
|
||||||
Status = EditHIInputAscii(AsciiBootFilePath,BOOT_DEVICE_FILEPATH_MAX);
|
Status = EditHIInputAscii (AsciiBootFilePath,BOOT_DEVICE_FILEPATH_MAX);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@ -567,9 +567,40 @@ BdsLoadOptionMemMapUpdateDevicePath (
|
|||||||
OUT UINT32 *Attributes
|
OUT UINT32 *Attributes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT(0);
|
EFI_STATUS Status;
|
||||||
//TODO: Implement me
|
CHAR8 AsciiStartingAddress[BOOT_DEVICE_ADDRESS_MAX];
|
||||||
return EFI_SUCCESS;
|
CHAR8 AsciiEndingAddress[BOOT_DEVICE_ADDRESS_MAX];
|
||||||
|
MEMMAP_DEVICE_PATH* EndingDevicePath;
|
||||||
|
EFI_DEVICE_PATH* DevicePath;
|
||||||
|
|
||||||
|
DevicePath = DuplicateDevicePath (BootOption->FilePathList);
|
||||||
|
EndingDevicePath = (MEMMAP_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);
|
||||||
|
|
||||||
|
Print(L"Starting Address of the binary: ");
|
||||||
|
AsciiSPrint (AsciiStartingAddress,BOOT_DEVICE_ADDRESS_MAX,"0x%X",(UINTN)EndingDevicePath->StartingAddress);
|
||||||
|
Status = EditHIInputAscii (AsciiStartingAddress,BOOT_DEVICE_ADDRESS_MAX);
|
||||||
|
if (EFI_ERROR(Status)) {
|
||||||
|
return EFI_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Print(L"Ending Address of the binary: ");
|
||||||
|
AsciiSPrint (AsciiEndingAddress,BOOT_DEVICE_ADDRESS_MAX,"0x%X",(UINTN)EndingDevicePath->EndingAddress);
|
||||||
|
Status = EditHIInputAscii (AsciiEndingAddress,BOOT_DEVICE_ADDRESS_MAX);
|
||||||
|
if (EFI_ERROR(Status)) {
|
||||||
|
return EFI_ABORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
EndingDevicePath->StartingAddress = AsciiStrHexToUint64 (AsciiStartingAddress);
|
||||||
|
EndingDevicePath->EndingAddress = AsciiStrHexToUint64 (AsciiEndingAddress);
|
||||||
|
|
||||||
|
Status = BootDeviceGetType (NULL, BootType, Attributes);
|
||||||
|
if (EFI_ERROR(Status)) {
|
||||||
|
FreePool(DevicePath);
|
||||||
|
} else {
|
||||||
|
*NewDevicePath = DevicePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user