Merge R8->R9 tracker 5935 and 7080 to update runtime arch protocol to DxeCis 0.91. Update DxeCore and Runtime driver to follow new definitions.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2101 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4
2006-12-14 10:14:24 +00:00
parent d43eee260f
commit 3ec2611d34
18 changed files with 464 additions and 616 deletions

View File

@@ -130,6 +130,7 @@ extern EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;
extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1];
extern BOOLEAN gDispatcherRunning;
extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate;
//
// Service Initialization Functions
@@ -315,27 +316,6 @@ Returns:
--*/
;
EFI_STATUS
CoreShutdownEventServices (
VOID
)
/*++
Routine Description:
Register all runtime events to make sure they are still available after ExitBootService.
Arguments:
None
Returns:
EFI_SUCCESS - Always return success
--*/
;
EFI_STATUS
CoreInitializeImageServices (
IN VOID *HobStart
@@ -358,27 +338,6 @@ Returns:
--*/
;
EFI_STATUS
CoreShutdownImageServices (
VOID
)
/*++
Routine Description:
Transfer control of runtime images to runtime service
Arguments:
None
Returns:
EFI_SUCCESS - Function successfully returned
--*/
;
VOID
CoreNotifyOnArchProtocolInstallation (
VOID

View File

@@ -157,7 +157,7 @@ EFI_METRONOME_ARCH_PROTOCOL *gMetronome = NULL;
EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL;
EFI_BDS_ARCH_PROTOCOL *gBds = NULL;
EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL;
EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = NULL;
//
// BugBug: I'n not runtime, but is the PPI?
@@ -324,6 +324,26 @@ EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = {
#endif
};
EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate = {
INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.ImageHead),
INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.EventHead),
//
// Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will
// prevent people from having pointer math bugs in their code.
// now you have to use *DescriptorSize to make things work.
//
sizeof (EFI_MEMORY_DESCRIPTOR) + sizeof (UINT64) - (sizeof (EFI_MEMORY_DESCRIPTOR) % sizeof (UINT64)),
EFI_MEMORY_DESCRIPTOR_VERSION,
0,
NULL,
NULL,
FALSE,
FALSE
};
EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = &gRuntimeTemplate;
//
// DXE Core Global Variables for the EFI System Table, Boot Services Table,
// DXE Services Table, and Runtime Services Table
@@ -886,11 +906,11 @@ CoreExitBootServices (
Routine Description:
EFI 1.0 API to terminate Boot Services
Terminates all boot services.
Arguments:
ImageHandle - Handle that represents the identity of the calling image
ImageHandle - Handle that identifies the exiting image.
MapKey -Key to the latest memory map.
@@ -926,16 +946,6 @@ Returns:
//
gCpu->DisableInterrupt (gCpu);
//
// Register Runtime events with the Runtime Architectural Protocol
//
CoreShutdownEventServices ();
//
// Register Runtime images with the Runtime Architectural Protocol
//
CoreShutdownImageServices ();
//
// Report that ExitBootServices() has been called
//
@@ -964,7 +974,12 @@ Returns:
//
SetMem (gBS, sizeof (EFI_BOOT_SERVICES), 0);
gBS = NULL;
//
// Update the AtRuntime field in Runtiem AP.
//
gRuntime->AtRuntime = TRUE;
return Status;
}

View File

@@ -128,6 +128,8 @@ Returns:
ARCHITECTURAL_PROTOCOL_ENTRY *Entry;
VOID *Protocol;
BOOLEAN Found;
LIST_ENTRY *Link;
LIST_ENTRY TempLinkNode;
Found = FALSE;
for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {
@@ -160,6 +162,34 @@ Returns:
// When runtime architectural protocol is available, updates CRC32 in the Debug Table
//
CoreUpdateDebugTableCrc32 ();
//
// Update the Runtime Architectural protocol with the template that the core was
// using so there would not need to be a dependency on the Runtime AP
//
//
// Copy all the registered Image to new gRuntime protocol
//
for (Link = gRuntimeTemplate.ImageHead.ForwardLink; Link != &gRuntimeTemplate.ImageHead; Link = TempLinkNode.ForwardLink) {
CopyMem (&TempLinkNode, Link, sizeof(LIST_ENTRY));
InsertTailList (&gRuntime->ImageHead, Link);
}
//
// Copy all the registered Event to new gRuntime protocol
//
for (Link = gRuntimeTemplate.EventHead.ForwardLink; Link != &gRuntimeTemplate.EventHead; Link = TempLinkNode.ForwardLink) {
CopyMem (&TempLinkNode, Link, sizeof(LIST_ENTRY));
InsertTailList (&gRuntime->EventHead, Link);
}
//
// Clean up gRuntimeTemplate
//
gRuntimeTemplate.ImageHead.ForwardLink = &gRuntimeTemplate.ImageHead;
gRuntimeTemplate.ImageHead.BackLink = &gRuntimeTemplate.ImageHead;
gRuntimeTemplate.EventHead.ForwardLink = &gRuntimeTemplate.EventHead;
gRuntimeTemplate.EventHead.BackLink = &gRuntimeTemplate.EventHead;
}
}

View File

@@ -168,50 +168,6 @@ Returns:
}
EFI_STATUS
CoreShutdownEventServices (
VOID
)
/*++
Routine Description:
Register all runtime events to make sure they are still available after ExitBootService.
Arguments:
None
Returns:
EFI_SUCCESS - Always return success.
--*/
{
LIST_ENTRY *Link;
IEVENT *Event;
//
// The Runtime AP is required for the core to function!
//
ASSERT (gRuntime != NULL);
for (Link = mRuntimeEventList.ForwardLink; Link != &mRuntimeEventList; Link = Link->ForwardLink) {
Event = CR (Link, IEVENT, RuntimeLink, EVENT_SIGNATURE);
gRuntime->RegisterEvent (
gRuntime,
Event->Type,
Event->NotifyTpl,
Event->NotifyFunction,
Event->NotifyContext,
(VOID **)Event
);
}
return EFI_SUCCESS;
}
VOID
CoreDispatchEventNotifies (
IN EFI_TPL Priority
@@ -559,7 +515,12 @@ Returns:
//
// Keep a list of all RT events so we can tell the RT AP.
//
InsertTailList (&mRuntimeEventList, &IEvent->RuntimeLink);
IEvent->RuntimeData.Type = Type;
IEvent->RuntimeData.NotifyTpl = NotifyTpl;
IEvent->RuntimeData.NotifyFunction = NotifyFunction;
IEvent->RuntimeData.NotifyContext = (VOID *) NotifyContext;
IEvent->RuntimeData.Event = (EFI_EVENT *) IEvent;
InsertTailList (&gRuntime->EventHead, &IEvent->RuntimeData.Link);
}
CoreAcquireEventLock ();
@@ -835,11 +796,11 @@ Returns:
//
// If the event is queued somewhere, remove it
//
if (Event->RuntimeLink.ForwardLink != NULL) {
RemoveEntryList (&Event->RuntimeLink);
if (Event->RuntimeData.Link.ForwardLink != NULL) {
RemoveEntryList (&Event->RuntimeData.Link);
}
if (Event->NotifyLink.ForwardLink != NULL) {
RemoveEntryList (&Event->NotifyLink);
}

View File

@@ -49,7 +49,3 @@ UINTN gEventPending = 0;
//
LIST_ENTRY gEventSignalQueue = INITIALIZE_LIST_HEAD_VARIABLE (gEventSignalQueue);
//
// LIST of runtime events that need to be fired by RT AP.
//
LIST_ENTRY mRuntimeEventList = INITIALIZE_LIST_HEAD_VARIABLE (mRuntimeEventList);

View File

@@ -56,7 +56,7 @@ typedef struct {
//
// A list of all runtime events
//
LIST_ENTRY RuntimeLink;
EFI_RUNTIME_EVENT_ENTRY RuntimeData;
//
// Information by event type
@@ -204,6 +204,5 @@ extern UINTN gEventPending;
extern LIST_ENTRY gEventQueue[];
extern LIST_ENTRY gEventSignalQueue;
extern UINT8 gHSB[];
extern LIST_ENTRY mRuntimeEventList;
#endif

View File

@@ -53,11 +53,9 @@ typedef struct {
EFI_EBC_PROTOCOL *Ebc; // EBC Protocol pointer
BOOLEAN RuntimeFixupValid; // True if RT image needs fixup
VOID *RuntimeFixup; // Copy of fixup data;
LIST_ENTRY Link; // List of RT LOADED_IMAGE_PRIVATE_DATA
EFI_RUNTIME_IMAGE_ENTRY *RuntimeData; // Runtime image list
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; // PeCoffLoader ImageContext
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; // PeCoffLoader ImageContext
} LOADED_IMAGE_PRIVATE_DATA;

View File

@@ -24,11 +24,6 @@ Abstract:
// Module Globals
//
//
// LIST of runtime images that need to be relocated.
//
LIST_ENTRY mRuntimeImageList = INITIALIZE_LIST_HEAD_VARIABLE (mRuntimeImageList);
LOADED_IMAGE_PRIVATE_DATA *mCurrentImage = NULL;
LOAD_PE32_IMAGE_PRIVATE_DATA mLoadPe32PrivateData = {
@@ -78,9 +73,7 @@ LOADED_IMAGE_PRIVATE_DATA mCorePrivateImage = {
NULL, // JumpContext
0, // Machine
NULL, // Ebc
FALSE, // RuntimeFixupValid
NULL, // RuntimeFixup
{ NULL, NULL }, // Link
NULL, // RuntimeData
};
@@ -173,52 +166,6 @@ Returns:
);
}
EFI_STATUS
CoreShutdownImageServices (
VOID
)
/*++
Routine Description:
Transfer control of runtime images to runtime service
Arguments:
None
Returns:
EFI_SUCCESS - Function successfully returned
--*/
{
LIST_ENTRY *Link;
LOADED_IMAGE_PRIVATE_DATA *Image;
//
// The Runtime AP is required for the core to function!
//
ASSERT (gRuntime != NULL);
for (Link = mRuntimeImageList.ForwardLink; Link != &mRuntimeImageList; Link = Link->ForwardLink) {
Image = CR (Link, LOADED_IMAGE_PRIVATE_DATA, Link, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE);
if (Image->RuntimeFixupValid) {
gRuntime->RegisterImage (
gRuntime,
(UINT64)(UINTN)(Image->Info.ImageBase),
(EFI_SIZE_TO_PAGES ((UINTN)Image->Info.ImageSize)),
Image->RuntimeFixup
);
}
}
return EFI_SUCCESS;
}
EFI_STATUS
CoreLoadPeImage (
IN VOID *Pe32Handle,
@@ -253,8 +200,9 @@ Returns:
--*/
{
EFI_STATUS Status;
UINTN Size;
EFI_STATUS Status;
BOOLEAN DstBufAlocated;
UINTN Size;
ZeroMem (&Image->ImageContext, sizeof (Image->ImageContext));
@@ -281,7 +229,7 @@ Returns:
//
// Allocate memory of the correct memory type aligned on the required image boundry
//
DstBufAlocated = FALSE;
if (DstBuffer == 0) {
//
// Allocate Destination Buffer as caller did not pass it in
@@ -308,8 +256,7 @@ Returns:
if (EFI_ERROR (Status)) {
return Status;
}
Image->ImageBasePage = Image->ImageContext.ImageAddress;
DstBufAlocated = TRUE;
} else {
//
@@ -334,9 +281,9 @@ Returns:
Image->NumberOfPages = EFI_SIZE_TO_PAGES ((UINTN)Image->ImageContext.ImageSize + Image->ImageContext.SectionAlignment);
Image->ImageContext.ImageAddress = DstBuffer;
Image->ImageBasePage = Image->ImageContext.ImageAddress;
}
Image->ImageBasePage = Image->ImageContext.ImageAddress;
Image->ImageContext.ImageAddress =
(Image->ImageContext.ImageAddress + Image->ImageContext.SectionAlignment - 1) &
~((UINTN)Image->ImageContext.SectionAlignment - 1);
@@ -346,7 +293,7 @@ Returns:
//
Status = gEfiPeiPeCoffLoader->LoadImage (gEfiPeiPeCoffLoader, &Image->ImageContext);
if (EFI_ERROR (Status)) {
return Status;
goto Done;
}
//
@@ -361,13 +308,6 @@ Returns:
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
//
// Make a list off all the RT images so we can let the RT AP know about them
//
Image->RuntimeFixupValid = TRUE;
Image->RuntimeFixup = Image->ImageContext.FixupData;
InsertTailList (&mRuntimeImageList, &Image->Link);
}
}
@@ -376,7 +316,7 @@ Returns:
//
Status = gEfiPeiPeCoffLoader->RelocateImage (gEfiPeiPeCoffLoader, &Image->ImageContext);
if (EFI_ERROR (Status)) {
return Status;
goto Done;
}
//
@@ -438,7 +378,23 @@ Returns:
Image->Info.ImageSize = Image->ImageContext.ImageSize;
Image->Info.ImageCodeType = Image->ImageContext.ImageCodeMemoryType;
Image->Info.ImageDataType = Image->ImageContext.ImageDataMemoryType;
if (Attribute & EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION) {
if (Image->ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) {
//
// Make a list off all the RT images so we can let the RT AP know about them.
//
Image->RuntimeData = CoreAllocateRuntimePool (sizeof(EFI_RUNTIME_IMAGE_ENTRY));
if (Image->RuntimeData == NULL) {
goto Done;
}
Image->RuntimeData->ImageBase = Image->Info.ImageBase;
Image->RuntimeData->ImageSize = (UINT64) (Image->Info.ImageSize);
Image->RuntimeData->RelocationData = Image->ImageContext.FixupData;
Image->RuntimeData->Handle = Image->Handle;
InsertTailList (&gRuntime->ImageHead, &Image->RuntimeData->Link);
}
}
//
// Fill in the entry point of the image if it is available
//
@@ -489,10 +445,19 @@ Returns:
return EFI_SUCCESS;
Done:
//
// Free memory
// Free memory.
//
CoreFreePages (Image->ImageContext.ImageAddress, Image->NumberOfPages);
if (DstBufAlocated) {
CoreFreePages (Image->ImageContext.ImageAddress, Image->NumberOfPages);
}
if (Image->ImageContext.FixupData != NULL) {
CoreFreePool (Image->ImageContext.FixupData);
}
return Status;
}
@@ -1168,13 +1133,16 @@ Returns:
);
}
if (Image->RuntimeFixupValid) {
//
// Remove the Image from the Runtime Image list as we are about to Free it!
//
RemoveEntryList (&Image->Link);
if (Image->RuntimeData != NULL) {
if (Image->RuntimeData->Link.ForwardLink != NULL) {
//
// Remove the Image from the Runtime Image list as we are about to Free it!
//
RemoveEntryList (&Image->RuntimeData->Link);
}
CoreFreePool (Image->RuntimeData);
}
//
// Free the Image from memory
//