|
|
|
@@ -41,15 +41,15 @@ Routine Description:
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
|
|
Destination - the path to append to.
|
|
|
|
|
Destination - Path to append Source to.
|
|
|
|
|
|
|
|
|
|
BufferSize - the maximum number of bytes to append.
|
|
|
|
|
BufferSize - Maximum number of bytes to append to Destination.
|
|
|
|
|
|
|
|
|
|
Source - the source path to append to Destination.
|
|
|
|
|
Source - Source path to append to Destination.
|
|
|
|
|
|
|
|
|
|
SourceSize - the size of Source, in bytes.
|
|
|
|
|
SourceSize - Size of Source, in bytes.
|
|
|
|
|
|
|
|
|
|
BufferUsed - pointer to a ULONG to store the number of bytes appended in.
|
|
|
|
|
BufferUsed - Pointer to a ULONG recieving the number of bytes appended in.
|
|
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
|
@@ -138,27 +138,21 @@ Routine Description:
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
|
|
DevicePath - EFI device path to search.
|
|
|
|
|
DevicePath - EFI_DEVICE_PATH *.
|
|
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
|
|
Pointer to the last device path node.
|
|
|
|
|
EFI_DEVICE_PATH *.
|
|
|
|
|
|
|
|
|
|
--*/
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
EFI_DEVICE_PATH *Node;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Check if the current node is the end of the path.
|
|
|
|
|
//
|
|
|
|
|
if (IsDevicePathEndType(DevicePath)) {
|
|
|
|
|
return DevicePath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Find the last non-filepath node.
|
|
|
|
|
//
|
|
|
|
|
Node = NextDevicePathNode(DevicePath);
|
|
|
|
|
while (!IsDevicePathEndType(Node)) {
|
|
|
|
|
if (DevicePathType(Node) == MEDIA_DEVICE_PATH && DevicePathSubType(Node) == MEDIA_FILEPATH_DP) {
|
|
|
|
@@ -183,19 +177,19 @@ EfiInitTranslateDevicePath (
|
|
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
|
|
Translates an EFI device path into boot device format.
|
|
|
|
|
Translates an EFI_DEVICE_PATH into a BOOT_DEVICE.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
|
|
EfiDevicePath - The EFI device path to be translated.
|
|
|
|
|
EfiDevicePath - Path to be translated.
|
|
|
|
|
|
|
|
|
|
BootDevice - Pointer to the destination device structure.
|
|
|
|
|
BootDevice - Pointer to a buffer that recieves the device.
|
|
|
|
|
|
|
|
|
|
BufferSize - The amount of available space in the buffer.
|
|
|
|
|
BufferSize - Amount of available bytes in the buffer.
|
|
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
|
|
STATUS_SUCCESS if successful,
|
|
|
|
|
STATUS_SUCCESS if successful.
|
|
|
|
|
STATUS_INVALID_PARAMETER if the buffer is too small.
|
|
|
|
|
STATUS_UNSUCCESSFUL if the path could not be translated.
|
|
|
|
|
|
|
|
|
@@ -207,17 +201,11 @@ Return Value:
|
|
|
|
|
HARDDRIVE_DEVICE_PATH *HarddriveNode;
|
|
|
|
|
PBOOT_BLOCK_IDENTIFIER BlockDevice;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Check for available buffer space.
|
|
|
|
|
//
|
|
|
|
|
if (BufferSize < sizeof(BOOT_DEVICE)) {
|
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
BootDevice->Size = sizeof(BOOT_DEVICE);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Memory mapped device paths are treated as ramdisks.
|
|
|
|
|
//
|
|
|
|
|
if (DevicePathType(EfiDevicePath) == HARDWARE_DEVICE_PATH && DevicePathSubType(EfiDevicePath) == HW_MEMMAP_DP) {
|
|
|
|
|
MemmapNode = (MEMMAP_DEVICE_PATH *)EfiDevicePath;
|
|
|
|
|
BlockDevice = &BootDevice->Block;
|
|
|
|
@@ -230,7 +218,6 @@ Return Value:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Get the device node, the device the application was loaded from.
|
|
|
|
|
// TODO: Only media devices and ramdisks are currently supported.
|
|
|
|
|
//
|
|
|
|
|
DeviceNode = EfiInitpGetDeviceNode(EfiDevicePath);
|
|
|
|
@@ -238,15 +225,12 @@ Return Value:
|
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Check device node subtype.
|
|
|
|
|
//
|
|
|
|
|
switch (DevicePathSubType(DeviceNode)) {
|
|
|
|
|
case MEDIA_HARDDRIVE_DP:
|
|
|
|
|
HarddriveNode = (HARDDRIVE_DEVICE_PATH *)DeviceNode;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Use correct block device and partition format.
|
|
|
|
|
// MBR disks still use the old partition struct.
|
|
|
|
|
//
|
|
|
|
|
if (HarddriveNode->SignatureType != SIGNATURE_TYPE_MBR) {
|
|
|
|
|
BlockDevice = &BootDevice->PartitionEx.Parent;
|
|
|
|
@@ -257,9 +241,6 @@ Return Value:
|
|
|
|
|
}
|
|
|
|
|
BlockDevice->Type = BOOT_BLOCK_DEVICE_TYPE_HARDDRIVE;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Initialize partition based on the drive's partitioning system.
|
|
|
|
|
//
|
|
|
|
|
switch (HarddriveNode->SignatureType) {
|
|
|
|
|
case SIGNATURE_TYPE_MBR:
|
|
|
|
|
BlockDevice->Harddrive.PartitionType = BOOT_HARDDRIVE_PARTITION_TYPE_MBR;
|
|
|
|
@@ -301,22 +282,23 @@ EfiInitpConvertEfiDevicePath (
|
|
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
|
|
Converts an EFI device path into BCD format.
|
|
|
|
|
Converts an EFI device path into option format.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
|
|
EfiDevicePath - The EFI device path to be converted.
|
|
|
|
|
EfiDevicePath - Path to be converted.
|
|
|
|
|
|
|
|
|
|
OptionType - The data type to be assigned to option.
|
|
|
|
|
OptionType - The data type to be assigned to Option->Type.
|
|
|
|
|
|
|
|
|
|
Option - Pointer to the destination option structure.
|
|
|
|
|
Option - Pointer to a buffer that recieves the option.
|
|
|
|
|
|
|
|
|
|
BufferSize - The amount of available space in the buffer.
|
|
|
|
|
BufferSize - The amount of available bytes in the buffer.
|
|
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
|
|
STATUS_SUCCESS if successful.
|
|
|
|
|
other NTSTATUS value if failure occurs.
|
|
|
|
|
STATUS_INVALID_PARAMETER if the buffer is too small.
|
|
|
|
|
Any status code returned by EfiInitTranslateDevicePath().
|
|
|
|
|
|
|
|
|
|
--*/
|
|
|
|
|
|
|
|
|
@@ -324,16 +306,10 @@ Return Value:
|
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
PBCDE_DEVICE DeviceElement;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Check for available buffer space.
|
|
|
|
|
//
|
|
|
|
|
if (BufferSize < sizeof(BOOT_APPLICATION_OPTION) + FIELD_OFFSET(BCDE_DEVICE, Device)) {
|
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Translate device path.
|
|
|
|
|
//
|
|
|
|
|
RtlZeroMemory(Option, sizeof(BOOT_APPLICATION_OPTION));
|
|
|
|
|
DeviceElement = (PBCDE_DEVICE)((PUCHAR)Option + sizeof(BOOT_APPLICATION_OPTION));
|
|
|
|
|
Status = EfiInitTranslateDevicePath(
|
|
|
|
@@ -345,9 +321,6 @@ Return Value:
|
|
|
|
|
return Status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Set up option structure.
|
|
|
|
|
//
|
|
|
|
|
Option->Type = OptionType;
|
|
|
|
|
Option->DataOffset = sizeof(BOOT_APPLICATION_OPTION);
|
|
|
|
|
Option->DataSize = FIELD_OFFSET(BCDE_DEVICE, Device) + DeviceElement->Device.Size;
|
|
|
|
@@ -367,22 +340,22 @@ EfiInitpConvertEfiFilePath (
|
|
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
|
|
Converts an EFI file path into BCD format.
|
|
|
|
|
Converts an EFI file path into option format.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
|
|
EfiFilePath - The EFI file path to be converted.
|
|
|
|
|
EfiFilePath - Path to be converted.
|
|
|
|
|
|
|
|
|
|
OptionType - The data type to be assigned to option.
|
|
|
|
|
OptionType - The data type to be assigned to Option->Type.
|
|
|
|
|
|
|
|
|
|
Option - Pointer to the destination option structure.
|
|
|
|
|
Option - Pointer to a buffer that recieves the option.
|
|
|
|
|
|
|
|
|
|
BufferSize - The amount of available space in the buffer.
|
|
|
|
|
BufferSize - The amount of available bytes in the buffer.
|
|
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
|
|
STATUS_SUCCESS if successful.
|
|
|
|
|
other NTSTATUS value if failure occurs.
|
|
|
|
|
STATUS_INVALID_PARAMETER if the buffer is too small.
|
|
|
|
|
|
|
|
|
|
--*/
|
|
|
|
|
|
|
|
|
@@ -392,22 +365,16 @@ Return Value:
|
|
|
|
|
PWCHAR PathStart, Position;
|
|
|
|
|
ULONG BufferRemaining, Length, Appended;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Check for available buffer space.
|
|
|
|
|
//
|
|
|
|
|
if (BufferSize < sizeof(BOOT_APPLICATION_OPTION)) {
|
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Set up option structure.
|
|
|
|
|
//
|
|
|
|
|
RtlZeroMemory(Option, sizeof(BOOT_APPLICATION_OPTION));
|
|
|
|
|
Option->Type = OptionType;
|
|
|
|
|
Option->DataOffset = sizeof(BOOT_APPLICATION_OPTION);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Add to the path one file path node at a time.
|
|
|
|
|
// Loop through nodes and add one at a time.
|
|
|
|
|
//
|
|
|
|
|
Option->DataSize = 0;
|
|
|
|
|
BufferRemaining = BufferSize - sizeof(BOOT_APPLICATION_OPTION);
|
|
|
|
@@ -415,21 +382,33 @@ Return Value:
|
|
|
|
|
PathStart = (PWCHAR)((PUCHAR)Option + Option->DataOffset);
|
|
|
|
|
Position = PathStart;
|
|
|
|
|
while (!IsDevicePathEndType(Node)) {
|
|
|
|
|
//
|
|
|
|
|
// Ignore non-filepath nodes.
|
|
|
|
|
//
|
|
|
|
|
if (DevicePathType(Node) != MEDIA_DEVICE_PATH || DevicePathSubType(Node) != MEDIA_FILEPATH_DP) {
|
|
|
|
|
Node = NextDevicePathNode(Node);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Find the length of this path.
|
|
|
|
|
//
|
|
|
|
|
Status = RtlULongSub(DevicePathNodeLength(Node), FIELD_OFFSET(FILEPATH_DEVICE_PATH, PathName), &Length);
|
|
|
|
|
if (!NT_SUCCESS(Status)) {
|
|
|
|
|
return Status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Append this path to the path string.
|
|
|
|
|
//
|
|
|
|
|
Status = EfiInitpAppendPathString(Position, BufferRemaining, &((FILEPATH_DEVICE_PATH *)Node)->PathName[0], Length, &Appended);
|
|
|
|
|
if (!NT_SUCCESS(Status)) {
|
|
|
|
|
return Status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Update counters & position.
|
|
|
|
|
//
|
|
|
|
|
Option->DataSize += Appended;
|
|
|
|
|
BufferRemaining -= Appended;
|
|
|
|
|
Position = (PWCHAR)((PUCHAR)Position + Appended);
|
|
|
|
@@ -437,7 +416,7 @@ Return Value:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Terminate path string.
|
|
|
|
|
// NULL-terminate path string.
|
|
|
|
|
//
|
|
|
|
|
if (BufferRemaining < sizeof(UNICODE_NULL)) {
|
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
@@ -446,7 +425,7 @@ Return Value:
|
|
|
|
|
Option->DataSize += sizeof(UNICODE_NULL);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// The path option is invalid if the path is NULL.
|
|
|
|
|
// The option is invalid if the path is empty.
|
|
|
|
|
//
|
|
|
|
|
if (Position == PathStart) {
|
|
|
|
|
Option->IsInvalid = TRUE;
|
|
|
|
@@ -473,29 +452,29 @@ EfiInitpCreateApplicationEntry (
|
|
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
|
|
Creates an application entry structure for the boot application.
|
|
|
|
|
Creates an application entry for the boot application.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
|
|
SystemTable - Pointer to the EFI system table.
|
|
|
|
|
|
|
|
|
|
Entry - A buffer to put the entry in.
|
|
|
|
|
Entry - Pointer to a buffer that recieves the entry.
|
|
|
|
|
|
|
|
|
|
BufferSize - The amount of available space in the buffer.
|
|
|
|
|
BufferSize - The amount of available bytes in the buffer.
|
|
|
|
|
|
|
|
|
|
EfiDevicePath - The device path for the application.
|
|
|
|
|
EfiDevicePath - The application's device path.
|
|
|
|
|
|
|
|
|
|
EfiFilePath - The file path for the application.
|
|
|
|
|
EfiFilePath - The application's file path.
|
|
|
|
|
|
|
|
|
|
LoadOptions - Firmware load options string.
|
|
|
|
|
|
|
|
|
|
LoadOptionsSize - Length of the string pointed to by LoadOptions.
|
|
|
|
|
LoadOptionsSize - Size in bytes of the string pointed to by LoadOptions.
|
|
|
|
|
|
|
|
|
|
Flags - Unused.
|
|
|
|
|
|
|
|
|
|
BufferUsed - Returns the amount of buffer space used by the routine.
|
|
|
|
|
BufferUsed - Pointer to a ULONG that recieves the buffer space used by this routine.
|
|
|
|
|
|
|
|
|
|
BootDevice - Returns a pointer to the device the application was loaded from.
|
|
|
|
|
BootDevice - Pointer to a PBOOT_DEVICE that recieves the device the application was loaded from.
|
|
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
|
@@ -513,8 +492,6 @@ Return Value:
|
|
|
|
|
PBCDE_DEVICE BootDeviceElement;
|
|
|
|
|
|
|
|
|
|
(VOID)SystemTable;
|
|
|
|
|
(VOID)EfiDevicePath;
|
|
|
|
|
(VOID)EfiFilePath;
|
|
|
|
|
(VOID)Flags;
|
|
|
|
|
|
|
|
|
|
*BufferUsed = 0;
|
|
|
|
@@ -522,23 +499,17 @@ Return Value:
|
|
|
|
|
OptionsSize = 0;
|
|
|
|
|
BcdIdentifierSet = FALSE;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Require enough space for the application entry.
|
|
|
|
|
//
|
|
|
|
|
BufferRemaining = BufferSize;
|
|
|
|
|
if (BufferRemaining < sizeof(BOOT_INPUT_APPLICATION_ENTRY)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Set up application entry structure.
|
|
|
|
|
//
|
|
|
|
|
RtlZeroMemory(Entry, sizeof(BOOT_INPUT_APPLICATION_ENTRY));
|
|
|
|
|
Entry->Signature = BOOT_INPUT_APPLICATION_ENTRY_SIGNATURE;
|
|
|
|
|
BufferRemaining -= FIELD_OFFSET(BOOT_INPUT_APPLICATION_ENTRY, Options);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Terminate load options string.
|
|
|
|
|
// Terminate load options.
|
|
|
|
|
//
|
|
|
|
|
LoadOptionsSize /= sizeof(WCHAR);
|
|
|
|
|
if (LoadOptionsSize != 0 && wcsnlen(LoadOptions, LoadOptionsSize) == LoadOptionsSize) {
|
|
|
|
@@ -546,7 +517,7 @@ Return Value:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Parse BCD GUID if present.
|
|
|
|
|
// Parse BCD GUID option if present.
|
|
|
|
|
//
|
|
|
|
|
if (LoadOptions != NULL && (BcdOptionString = wcsstr(LoadOptions, L"BCDOBJECT=")) != NULL) {
|
|
|
|
|
RtlInitUnicodeString(&UnicodeString, (PWCHAR)((PUCHAR)BcdOptionString + sizeof(L"BCDOBJECT=") - sizeof(UNICODE_NULL)));
|
|
|
|
@@ -576,7 +547,7 @@ Return Value:
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Convert the EFI file path into a boot file path option.
|
|
|
|
|
// TODO: UDP/PXE boot is not supported.
|
|
|
|
|
// TODO: UDP/PXE are not supported.
|
|
|
|
|
//
|
|
|
|
|
PrevOption = Option;
|
|
|
|
|
Option = (PBOOT_APPLICATION_OPTION)((PUCHAR)&Entry->Options + OptionsSize);
|
|
|
|
@@ -590,7 +561,7 @@ Return Value:
|
|
|
|
|
BufferRemaining -= Size;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// TODO: This section is incomplete.
|
|
|
|
|
// TODO: Additional options in LoadOptions are not parsed.
|
|
|
|
|
//
|
|
|
|
|
PrevOption = Option;
|
|
|
|
|
Option = (PBOOT_APPLICATION_OPTION)((PUCHAR)&Entry->Options + OptionsSize);
|
|
|
|
@@ -617,13 +588,14 @@ Routine Description:
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
|
|
ImageHandle - Handle for the boot manager image.
|
|
|
|
|
ImageHandle - EFI handle for the boot application image.
|
|
|
|
|
|
|
|
|
|
SystemTable - Pointer to the EFI system table.
|
|
|
|
|
|
|
|
|
|
Return Value:
|
|
|
|
|
|
|
|
|
|
Pointer to parameter structure on success or NULL on failure.
|
|
|
|
|
Pointer to parameter structure if successful.
|
|
|
|
|
NULL on failure.
|
|
|
|
|
|
|
|
|
|
--*/
|
|
|
|
|
|
|
|
|
@@ -648,9 +620,6 @@ Return Value:
|
|
|
|
|
BadPageAddress = 0x102 << PAGE_SHIFT;
|
|
|
|
|
SystemTable->BootServices->AllocatePages(AllocateAddress, EfiLoaderData, 1, &BadPageAddress);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Get boot manager image information.
|
|
|
|
|
//
|
|
|
|
|
Status = SystemTable->BootServices->HandleProtocol(
|
|
|
|
|
ImageHandle,
|
|
|
|
|
(EFI_GUID*)&EfiLoadedImageProtocol,
|
|
|
|
@@ -660,9 +629,6 @@ Return Value:
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Get boot manager image device path.
|
|
|
|
|
//
|
|
|
|
|
Status = SystemTable->BootServices->HandleProtocol(
|
|
|
|
|
LoadedImage->DeviceHandle,
|
|
|
|
|
(EFI_GUID*)&EfiDevicePathProtocol,
|
|
|
|
@@ -672,9 +638,6 @@ Return Value:
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Create input parameters structure.
|
|
|
|
|
//
|
|
|
|
|
InputParameters = (PBOOT_INPUT_PARAMETERS)(&EfiInitScratch[ScratchUsed]);
|
|
|
|
|
ScratchUsed += sizeof(BOOT_INPUT_PARAMETERS);
|
|
|
|
|
InputParameters->Signature = BOOT_INPUT_PARAMETERS_SIGNATURE;
|
|
|
|
@@ -684,9 +647,6 @@ Return Value:
|
|
|
|
|
InputParameters->ImageBase = LoadedImage->ImageBase;
|
|
|
|
|
InputParameters->ImageSize = LoadedImage->ImageSize;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Create memory info structure.
|
|
|
|
|
//
|
|
|
|
|
InputParameters->MemoryInfoOffset = ScratchUsed;
|
|
|
|
|
MemoryInfo = (PBOOT_MEMORY_INFO)(&EfiInitScratch[ScratchUsed]);
|
|
|
|
|
ScratchUsed += sizeof(BOOT_MEMORY_INFO);
|
|
|
|
@@ -696,9 +656,6 @@ Return Value:
|
|
|
|
|
MemoryInfo->DescriptorSize = sizeof(MEMORY_DESCRIPTOR);
|
|
|
|
|
MemoryInfo->BasePageOffset = FIELD_OFFSET(MEMORY_DESCRIPTOR, BasePage);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Create a memory descriptor for the boot manager image.
|
|
|
|
|
//
|
|
|
|
|
MemoryDescriptor = (PMEMORY_DESCRIPTOR)(&EfiInitScratch[ScratchUsed]);
|
|
|
|
|
ScratchUsed += sizeof(MEMORY_DESCRIPTOR);
|
|
|
|
|
MemoryDescriptor->BasePage = (UINTN)InputParameters->ImageBase >> PAGE_SHIFT;
|
|
|
|
@@ -706,9 +663,6 @@ Return Value:
|
|
|
|
|
MemoryDescriptor->Attributes = MEMORY_ATTRIBUTE_WB;
|
|
|
|
|
MemoryDescriptor->Type = MEMORY_TYPE_BOOT_APPLICATION;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Create an application entry for the boot application.
|
|
|
|
|
//
|
|
|
|
|
InputParameters->ApplicationEntryOffset = ScratchUsed;
|
|
|
|
|
EfiInitpCreateApplicationEntry(
|
|
|
|
|
SystemTable,
|
|
|
|
@@ -724,9 +678,6 @@ Return Value:
|
|
|
|
|
);
|
|
|
|
|
ScratchUsed += ApplicationEntrySize;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Copy application device to scratch area.
|
|
|
|
|
//
|
|
|
|
|
InputParameters->BootDeviceOffset = ScratchUsed;
|
|
|
|
|
if (BootDevice != NULL) {
|
|
|
|
|
RtlCopyMemory(&EfiInitScratch[ScratchUsed], BootDevice, BootDevice->Size);
|
|
|
|
@@ -736,9 +687,6 @@ Return Value:
|
|
|
|
|
ScratchUsed += sizeof(BOOT_DEVICE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Create firmware data structure.
|
|
|
|
|
//
|
|
|
|
|
InputParameters->FirmwareDataOffset = ScratchUsed;
|
|
|
|
|
FirmwareData = (PBOOT_FIRMWARE_DATA)(&EfiInitScratch[ScratchUsed]);
|
|
|
|
|
ScratchUsed += sizeof(BOOT_FIRMWARE_DATA);
|
|
|
|
@@ -747,17 +695,11 @@ Return Value:
|
|
|
|
|
FirmwareData->ImageHandle = ImageHandle;
|
|
|
|
|
FirmwareData->SystemTable = SystemTable;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Create return data structure.
|
|
|
|
|
//
|
|
|
|
|
InputParameters->ReturnDataOffset = ScratchUsed;
|
|
|
|
|
ReturnData = (PBOOT_RETURN_DATA)(&EfiInitScratch[ScratchUsed]);
|
|
|
|
|
ScratchUsed += sizeof(BOOT_RETURN_DATA);
|
|
|
|
|
ReturnData->Version = BOOT_RETURN_DATA_VERSION;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Set and validate total size.
|
|
|
|
|
//
|
|
|
|
|
InputParameters->Size = ScratchUsed;
|
|
|
|
|
if (InputParameters->Size > sizeof(EfiInitScratch)) {
|
|
|
|
|
return NULL;
|
|
|
|
|