未验证 提交 2462e02d 编写于 作者: M Mike Beaton 提交者: GitHub

OpenDuet: Add missing DxeCore ImageContext HOB (#533)

上级 e5b02f13
......@@ -23,6 +23,7 @@ Revision History:
#include <Base.h>
#include <Uefi.h>
#include <Library/UefiImageLib.h>
#define EFILDR_BASE_SEGMENT 0x2000
#define EFILDR_LOAD_ADDRESS (EFILDR_BASE_SEGMENT << 4)
......@@ -31,15 +32,16 @@ Revision History:
#define EFILDR_CB_VA 0x00
typedef struct _EFILDRHANDOFF {
UINTN MemDescCount;
EFI_MEMORY_DESCRIPTOR *MemDesc;
VOID *BfvBase;
UINTN BfvSize;
VOID *DxeIplImageBase;
UINTN DxeIplImageSize;
VOID *DxeCoreImageBase;
UINTN DxeCoreImageSize;
VOID *DxeCoreEntryPoint;
UINTN MemDescCount;
EFI_MEMORY_DESCRIPTOR *MemDesc;
VOID *BfvBase;
UINTN BfvSize;
VOID *DxeIplImageBase;
UINTN DxeIplImageSize;
VOID *DxeCoreImageBase;
UINTN DxeCoreImageSize;
VOID *DxeCoreEntryPoint;
UEFI_IMAGE_LOADER_IMAGE_CONTEXT DxeCoreImageContext;
} EFILDRHANDOFF;
typedef struct {
......
......@@ -180,7 +180,8 @@ Returns:
PrepareHobDxeCore (
Handoff->DxeCoreEntryPoint,
(EFI_PHYSICAL_ADDRESS)(UINTN)Handoff->DxeCoreImageBase,
(UINTN)Handoff->DxeIplImageBase + (UINTN)Handoff->DxeIplImageSize - (UINTN)Handoff->DxeCoreImageBase
(UINTN)Handoff->DxeIplImageBase + (UINTN)Handoff->DxeIplImageSize - (UINTN)Handoff->DxeCoreImageBase,
&Handoff->DxeCoreImageContext
);
PrepareHobLegacyTable (gHob);
......
......@@ -207,12 +207,26 @@ HOB_TEMPLATE gHobTemplate = {
0x0, // PhysicalStart
0 // ResourceLength
},
{ // ImageContextDxeCore
{
{
EFI_HOB_TYPE_GUID_EXTENSION, // Hob type
sizeof (IMAGE_CONTEXT_HOB), // Hob size
0, // Reserved
},
UEFI_IMAGE_LOADER_IMAGE_CONTEXT_GUID
},
{
0, // FormatIndex
{ .Ue = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} } // Ctx.Ue
}
},
{ // Memory Map Hints to reduce fragmentation in the memory map
{
{
EFI_HOB_TYPE_GUID_EXTENSION, // Hob type
sizeof (MEMORY_TYPE_INFORMATION_HOB), // Hob size
0, // reserved
0, // Reserved
},
EFI_MEMORY_TYPE_INFORMATION_GUID
},
......@@ -297,7 +311,7 @@ HOB_TEMPLATE gHobTemplate = {
{
EFI_HOB_TYPE_GUID_EXTENSION, // Hob type
sizeof (TABLE_HOB), // Hob size
0, // reserved
0 // Reserved
},
EFI_MPS_TABLE_GUID
},
......@@ -308,35 +322,35 @@ HOB_TEMPLATE gHobTemplate = {
{ // Pointer to FlushInstructionCache
EFI_HOB_TYPE_GUID_EXTENSION, // Hob type
sizeof (PROTOCOL_HOB), // Hob size
0, // reserved
0, // Reserved
EFI_PEI_FLUSH_INSTRUCTION_CACHE_GUID,
NULL
},
{ // Pointer to TransferControl
EFI_HOB_TYPE_GUID_EXTENSION, // Hob type
sizeof (PROTOCOL_HOB), // Hob size
0, // reserved
0, // Reserved
EFI_PEI_TRANSFER_CONTROL_GUID,
NULL
},
{ // Pointer to PeCoffLoader
EFI_HOB_TYPE_GUID_EXTENSION, // Hob type
sizeof (PROTOCOL_HOB), // Hob size
0, // reserved
0, // Reserved
EFI_PEI_PE_COFF_LOADER_GUID,
NULL
},
{ // Pointer to EfiDecompress
EFI_HOB_TYPE_GUID_EXTENSION, // Hob type
sizeof (PROTOCOL_HOB), // Hob size
0, // reserved
0, // Reserved
EFI_DECOMPRESS_PROTOCOL_GUID,
NULL
},
{ // Pointer to TianoDecompress
EFI_HOB_TYPE_GUID_EXTENSION, // Hob type
sizeof (PROTOCOL_HOB), // Hob size
0, // reserved
0, // Reserved
EFI_TIANO_DECOMPRESS_PROTOCOL_GUID,
NULL
},
......@@ -754,17 +768,52 @@ PrepareHobBfv (
VOID
PrepareHobDxeCore (
VOID *DxeCoreEntryPoint,
EFI_PHYSICAL_ADDRESS DxeCoreImageBase,
UINT64 DxeCoreLength
VOID *DxeCoreEntryPoint,
EFI_PHYSICAL_ADDRESS DxeCoreImageBase,
UINT64 DxeCoreLength,
UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext
)
{
HOB_IMAGE_CONTEXT *Hob;
gHob->DxeCore.MemoryAllocationHeader.MemoryBaseAddress = DxeCoreImageBase;
gHob->DxeCore.MemoryAllocationHeader.MemoryLength = DxeCoreLength;
gHob->DxeCore.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)DxeCoreEntryPoint;
gHob->MemoryDxeCore.PhysicalStart = DxeCoreImageBase;
gHob->MemoryDxeCore.ResourceLength = DxeCoreLength;
Hob = &gHob->ImageContextDxeCore.ImageContext;
Hob->FormatIndex = ImageContext->FormatIndex;
if (Hob->FormatIndex != UefiImageFormatUe) {
Hob->Ctx.Pe.ImageBuffer = (UINT32)(UINTN)ImageContext->Ctx.Pe.ImageBuffer;
Hob->Ctx.Pe.AddressOfEntryPoint = ImageContext->Ctx.Pe.AddressOfEntryPoint;
Hob->Ctx.Pe.ImageType = ImageContext->Ctx.Pe.ImageType;
Hob->Ctx.Pe.FileBuffer = (UINT32)(UINTN)ImageContext->Ctx.Pe.FileBuffer;
Hob->Ctx.Pe.ExeHdrOffset = ImageContext->Ctx.Pe.ExeHdrOffset;
Hob->Ctx.Pe.SizeOfImage = ImageContext->Ctx.Pe.SizeOfImage;
Hob->Ctx.Pe.FileSize = ImageContext->Ctx.Pe.FileSize;
Hob->Ctx.Pe.Subsystem = ImageContext->Ctx.Pe.Subsystem;
Hob->Ctx.Pe.SectionAlignment = ImageContext->Ctx.Pe.SectionAlignment;
Hob->Ctx.Pe.SectionsOffset = ImageContext->Ctx.Pe.SectionsOffset;
Hob->Ctx.Pe.NumberOfSections = ImageContext->Ctx.Pe.NumberOfSections;
Hob->Ctx.Pe.SizeOfHeaders = ImageContext->Ctx.Pe.SizeOfHeaders;
} else {
Hob->Ctx.Ue.ImageBuffer = (UINT32)(UINTN)ImageContext->Ctx.Ue.ImageBuffer;
Hob->Ctx.Ue.FileBuffer = (UINT32)(UINTN)ImageContext->Ctx.Ue.FileBuffer;
Hob->Ctx.Ue.EntryPointAddress = ImageContext->Ctx.Ue.EntryPointAddress;
Hob->Ctx.Ue.LoadTablesFileOffset = ImageContext->Ctx.Ue.LoadTablesFileOffset;
Hob->Ctx.Ue.NumLoadTables = ImageContext->Ctx.Ue.NumLoadTables;
Hob->Ctx.Ue.LoadTables = (UINT32)(UINTN)ImageContext->Ctx.Ue.LoadTables;
Hob->Ctx.Ue.Segments = (UINT32)(UINTN)ImageContext->Ctx.Ue.Segments;
Hob->Ctx.Ue.LastSegmentIndex = ImageContext->Ctx.Ue.LastSegmentIndex;
Hob->Ctx.Ue.SegmentAlignment = ImageContext->Ctx.Ue.SegmentAlignment;
Hob->Ctx.Ue.ImageSize = ImageContext->Ctx.Ue.ImageSize;
Hob->Ctx.Ue.Subsystem = ImageContext->Ctx.Ue.Subsystem;
Hob->Ctx.Ue.SegmentImageInfoIterSize = ImageContext->Ctx.Ue.SegmentImageInfoIterSize;
Hob->Ctx.Ue.SegmentsFileOffset = ImageContext->Ctx.Ue.SegmentsFileOffset;
}
}
VOID *
......
......@@ -36,6 +36,20 @@ Revision History:
#pragma pack(1)
// FIXME: Move to audk
///
/// Identifies DxeCore ImageContext HOB
///
#define UEFI_IMAGE_LOADER_IMAGE_CONTEXT_GUID \
{ 0x05cc29cc, 0xfbdf, 0x4cc8, { 0x98, 0x25, 0x71, 0x76, 0x08, 0x5b, 0x05, 0x01 } }
////extern EFI_GUID gUefiImageLoaderImageContextGuid;
typedef struct {
EFI_HOB_GUID_TYPE Hob;
HOB_IMAGE_CONTEXT ImageContext;
} IMAGE_CONTEXT_HOB;
typedef struct {
EFI_HOB_GUID_TYPE Hob;
EFI_MEMORY_TYPE_INFORMATION Info[10];
......@@ -79,6 +93,7 @@ typedef struct {
EFI_HOB_RESOURCE_DESCRIPTOR MemoryAbove4GB;
EFI_HOB_MEMORY_ALLOCATION_MODULE DxeCore;
EFI_HOB_RESOURCE_DESCRIPTOR MemoryDxeCore;
IMAGE_CONTEXT_HOB ImageContextDxeCore;
MEMORY_TYPE_INFORMATION_HOB MemoryTypeInfo;
TABLE_HOB Acpi;
TABLE_HOB Acpi20;
......@@ -133,9 +148,10 @@ PrepareHobMemory (
VOID
PrepareHobDxeCore (
VOID *DxeCoreEntryPoint,
EFI_PHYSICAL_ADDRESS DxeCoreImageBase,
UINT64 DxeCoreLength
VOID *DxeCoreEntryPoint,
EFI_PHYSICAL_ADDRESS DxeCoreImageBase,
UINT64 DxeCoreLength,
UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext
);
VOID *
......
......@@ -88,11 +88,12 @@ VOID
EFI_STATUS
EfiLdrLoadImage (
IN VOID *FHand,
IN UINT32 BufferSize,
IN EFILDR_LOADED_IMAGE *Image,
IN UINTN *NumberOfMemoryMapEntries,
IN EFI_MEMORY_DESCRIPTOR *EfiMemoryDescriptor
IN VOID *FHand,
IN UINT32 BufferSize,
IN EFILDR_LOADED_IMAGE *Image,
IN UINTN *NumberOfMemoryMapEntries,
IN EFI_MEMORY_DESCRIPTOR *EfiMemoryDescriptor,
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext
);
#endif //_DUET_EFI_LOADER_H_
......@@ -39,7 +39,6 @@
[Sources]
Support.h
EfiLdrHandoff.h
EfiLdr.h
EfiLoader.c
PeLoader.c
......
/*++
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
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.
Module Name:
EfiLdrHandoff.h
Abstract:
Revision History:
--*/
#ifndef _EFILDR_HANDOFF_H_
#define _EFILDR_HANDOFF_H_
#define EFILDR_BASE_SEGMENT 0x2000
#define EFILDR_LOAD_ADDRESS (EFILDR_BASE_SEGMENT << 4)
#define EFILDR_HEADER_ADDRESS (EFILDR_LOAD_ADDRESS+0x2000)
#define EFILDR_CB_VA 0x00
typedef struct _EFILDRHANDOFF {
UINTN MemDescCount;
EFI_MEMORY_DESCRIPTOR *MemDesc;
VOID *BfvBase;
UINTN BfvSize;
VOID *DxeIplImageBase;
UINTN DxeIplImageSize;
VOID *DxeCoreImageBase;
UINTN DxeCoreImageSize;
VOID *DxeCoreEntryPoint;
} EFILDRHANDOFF;
typedef struct {
UINT32 CheckSum;
UINT32 Offset;
UINT32 Length;
UINT8 FileName[52];
} EFILDR_IMAGE;
typedef struct {
UINT32 Signature;
UINT32 HeaderCheckSum;
UINT32 FileLength;
UINT32 NumberOfImages;
} EFILDR_HEADER;
#endif
......@@ -142,7 +142,8 @@ EfiLoader (
DestinationSize,
&DxeIplImage,
&NumberOfMemoryMapEntries,
EfiMemoryDescriptor
EfiMemoryDescriptor,
NULL
);
if (EFI_ERROR (Status)) {
SystemHang ("Failed to load and relocate DxeIpl PE image!\n");
......@@ -184,7 +185,8 @@ EfiLoader (
DestinationSize,
&DxeCoreImage,
&NumberOfMemoryMapEntries,
EfiMemoryDescriptor
EfiMemoryDescriptor,
&Handoff.DxeCoreImageContext
);
if (EFI_ERROR (Status)) {
SystemHang ("Failed to load/relocate DxeMain!\n");
......
......@@ -26,18 +26,23 @@ Revision History:
EFI_STATUS
EfiLdrLoadImage (
IN VOID *FHand,
IN UINT32 BufferSize,
IN EFILDR_LOADED_IMAGE *Image,
IN UINTN *NumberOfMemoryMapEntries,
IN EFI_MEMORY_DESCRIPTOR *EfiMemoryDescriptor
IN VOID *FHand,
IN UINT32 BufferSize,
IN EFILDR_LOADED_IMAGE *Image,
IN UINTN *NumberOfMemoryMapEntries,
IN EFI_MEMORY_DESCRIPTOR *EfiMemoryDescriptor,
OUT UEFI_IMAGE_LOADER_IMAGE_CONTEXT *ImageContext
)
{
EFI_STATUS Status;
UEFI_IMAGE_LOADER_IMAGE_CONTEXT ImageContext;
UEFI_IMAGE_LOADER_IMAGE_CONTEXT TempImageContext;
if (ImageContext == NULL) {
ImageContext = &TempImageContext;
}
Status = UefiImageInitializeContext (
&ImageContext,
ImageContext,
FHand,
BufferSize,
UEFI_IMAGE_SOURCE_FV,
......@@ -50,7 +55,7 @@ EfiLdrLoadImage (
//
// Set the image subsystem type
//
Image->Type = UefiImageGetSubsystem (&ImageContext);
Image->Type = UefiImageGetSubsystem (ImageContext);
switch (Image->Type) {
case EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION:
......@@ -72,7 +77,7 @@ EfiLdrLoadImage (
return EFI_INVALID_PARAMETER;
}
Image->NoPages = EFI_SIZE_TO_PAGES (UefiImageGetImageSize (&ImageContext));
Image->NoPages = EFI_SIZE_TO_PAGES (UefiImageGetImageSize (ImageContext));
//
// Compute the amount of memory needed to load the image and
......@@ -99,7 +104,7 @@ EfiLdrLoadImage (
// Load and relocate image
//
Status = UefiImageLoadImageForExecution (
&ImageContext,
ImageContext,
Image->ImageBase,
(UINT32)EFI_PAGES_TO_SIZE (Image->NoPages),
NULL,
......@@ -109,7 +114,7 @@ EfiLdrLoadImage (
return Status;
}
Image->EntryPoint = (EFI_IMAGE_ENTRY_POINT)UefiImageLoaderGetImageEntryPoint (&ImageContext);
Image->EntryPoint = (EFI_IMAGE_ENTRY_POINT)UefiImageLoaderGetImageEntryPoint (ImageContext);
return Status;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册