#ifndef __BDS_ENTRY_H__\r
#define __BDS_ENTRY_H__\r
\r
+/**\r
+ Connect a Device Path and return the handle of the driver that support this DevicePath\r
+\r
+ @param DevicePath Device Path of the File to connect\r
+ @param Handle Handle of the driver that support this DevicePath\r
+ @param RemainingDevicePath Remaining DevicePath nodes that do not match the driver DevicePath\r
+\r
+ @retval EFI_SUCCESS A driver that matches the Device Path has been found\r
+ @retval EFI_NOT_FOUND No handles match the search.\r
+ @retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL\r
+\r
+**/\r
+EFI_STATUS\r
+BdsConnectDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,\r
+ OUT EFI_HANDLE *Handle,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath\r
+ );\r
+\r
/**\r
Connect all DXE drivers\r
\r
Start a Linux kernel from a Device Path\r
\r
@param LinuxKernel Device Path to the Linux Kernel\r
- @param Parameters Linux kernel agruments\r
+ @param Parameters Linux kernel arguments\r
@param Fdt Device Path to the Flat Device Tree\r
\r
@retval EFI_SUCCESS All drivers have been connected\r
IN EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath\r
);\r
\r
+/**\r
+ Start an EFI Application from a Device Path\r
+\r
+ @param ParentImageHandle Handle of the calling image\r
+ @param DevicePath Location of the EFI Application\r
+\r
+ @retval EFI_SUCCESS All drivers have been connected\r
+ @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found\r
+ @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.\r
+\r
+**/\r
+EFI_STATUS\r
+BdsStartEfiApplication (\r
+ IN EFI_HANDLE ParentImageHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ );\r
+\r
/**\r
Start an EFI Application from any Firmware Volume\r
\r
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
BdsConnectDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
// 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)
Remaining = DevicePath;
- Status = gBS->LocateDevicePath(&gEfiDevicePathProtocolGuid,&Remaining,Handle);
+ Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid,&Remaining,Handle);
if (!EFI_ERROR (Status)) {
Status = gBS->ConnectController (*Handle, NULL, Remaining, FALSE);
if (EFI_ERROR (Status)) {
File = NULL;
Status = Fs->Open(Fs, &File, FilePathDevicePath->PathName, EFI_FILE_MODE_READ, 0);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
Size = 0;
File->GetInfo(File, &gEfiFileInfoGuid, &Size, NULL);
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
BdsStartEfiApplication (
IN EFI_HANDLE ParentImageHandle,
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
+#include <Library/BdsLib.h>
#include <Library/BdsUnixLib.h>
#include <Library/PerformanceLib.h>
CopyMem (&((BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments, BootArguments, AsciiStrSize(BootArguments));\r
BootOption->OptionalData = (BDS_LOADER_OPTIONAL_DATA *)EfiLoadOptionPtr;\r
\r
+ // If this function is called at the creation of the Boot Device entry (not at the update) the\r
+ // BootOption->LoadOptionSize must be zero then we get a new BootIndex for this entry\r
+ if (BootOption->LoadOptionSize == 0) {\r
+ BootOption->LoadOptionIndex = BootOptionAllocateBootIndex();\r
+ }\r
+\r
// Fill the EFI Load option fields\r
- BootOption->LoadOptionIndex = BootOptionAllocateBootIndex();\r
BootOption->LoadOption = EfiLoadOption;\r
BootOption->LoadOptionSize = EfiLoadOptionSize;\r
\r
)\r
{\r
EFI_STATUS Status;\r
- BDS_LOAD_OPTION *BootOption;\r
CHAR16 BootVariableName[9];\r
\r
// Update the BDS Load Option structure\r
BootOptionSetFields (BdsLoadOption, Attributes, BootDescription, DevicePath, BootType, BootArguments);\r
\r
// Update the related environment variables\r
- UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BootOption->LoadOptionIndex);\r
+ UnicodeSPrint (BootVariableName, 9 * sizeof(CHAR16), L"Boot%04X", BdsLoadOption->LoadOptionIndex);\r
+\r
Status = gRT->SetVariable (\r
BootVariableName,\r
&gEfiGlobalVariableGuid,\r
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
- BootOption->LoadOptionSize,\r
- BootOption->LoadOption\r
+ BdsLoadOption->LoadOptionSize,\r
+ BdsLoadOption->LoadOption\r
);\r
\r
return Status;\r
\r
Print(L"File path of the EFI Application or the kernel: ");\r
UnicodeStrToAsciiStr (EndingDevicePath->PathName,AsciiBootFilePath);\r
- Status = EditHIInputAscii(AsciiBootFilePath,BOOT_DEVICE_FILEPATH_MAX);\r
+ Status = EditHIInputAscii (AsciiBootFilePath,BOOT_DEVICE_FILEPATH_MAX);\r
if (EFI_ERROR(Status)) {\r
return Status;\r
}\r
OUT UINT32 *Attributes\r
)\r
{\r
- ASSERT(0);\r
- //TODO: Implement me\r
- return EFI_SUCCESS;\r
+ EFI_STATUS Status;\r
+ CHAR8 AsciiStartingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
+ CHAR8 AsciiEndingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
+ MEMMAP_DEVICE_PATH* EndingDevicePath;\r
+ EFI_DEVICE_PATH* DevicePath;\r
+\r
+ DevicePath = DuplicateDevicePath (BootOption->FilePathList);\r
+ EndingDevicePath = (MEMMAP_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);\r
+\r
+ Print(L"Starting Address of the binary: ");\r
+ AsciiSPrint (AsciiStartingAddress,BOOT_DEVICE_ADDRESS_MAX,"0x%X",(UINTN)EndingDevicePath->StartingAddress);\r
+ Status = EditHIInputAscii (AsciiStartingAddress,BOOT_DEVICE_ADDRESS_MAX);\r
+ if (EFI_ERROR(Status)) {\r
+ return EFI_ABORTED;\r
+ }\r
+\r
+ Print(L"Ending Address of the binary: ");\r
+ AsciiSPrint (AsciiEndingAddress,BOOT_DEVICE_ADDRESS_MAX,"0x%X",(UINTN)EndingDevicePath->EndingAddress);\r
+ Status = EditHIInputAscii (AsciiEndingAddress,BOOT_DEVICE_ADDRESS_MAX);\r
+ if (EFI_ERROR(Status)) {\r
+ return EFI_ABORTED;\r
+ }\r
+\r
+ EndingDevicePath->StartingAddress = AsciiStrHexToUint64 (AsciiStartingAddress);\r
+ EndingDevicePath->EndingAddress = AsciiStrHexToUint64 (AsciiEndingAddress);\r
+\r
+ Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+ if (EFI_ERROR(Status)) {\r
+ FreePool(DevicePath);\r
+ } else {\r
+ *NewDevicePath = DevicePath;\r
+ }\r
+\r
+ return Status;\r
}\r
\r
BOOLEAN\r