extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1];\r
\r
extern BOOLEAN gDispatcherRunning;\r
+extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate;\r
\r
//\r
// Service Initialization Functions\r
--*/\r
;\r
\r
-EFI_STATUS\r
-CoreShutdownEventServices (\r
- VOID\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Register all runtime events to make sure they are still available after ExitBootService.\r
-\r
-Arguments:\r
-\r
- None\r
- \r
-Returns:\r
-\r
- EFI_SUCCESS - Always return success\r
-\r
---*/\r
-;\r
-\r
EFI_STATUS\r
CoreInitializeImageServices (\r
IN VOID *HobStart\r
--*/\r
;\r
\r
-EFI_STATUS\r
-CoreShutdownImageServices (\r
- VOID\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Transfer control of runtime images to runtime service\r
-\r
-Arguments:\r
-\r
- None\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - Function successfully returned\r
-\r
---*/\r
-;\r
-\r
VOID\r
CoreNotifyOnArchProtocolInstallation (\r
VOID\r
EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL;\r
EFI_BDS_ARCH_PROTOCOL *gBds = NULL;\r
EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL;\r
-EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = NULL;\r
+\r
\r
//\r
// BugBug: I'n not runtime, but is the PPI?\r
#endif\r
};\r
\r
+EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate = {\r
+ INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.ImageHead),\r
+ INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.EventHead),\r
+\r
+ //\r
+ // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will\r
+ // prevent people from having pointer math bugs in their code.\r
+ // now you have to use *DescriptorSize to make things work.\r
+ //\r
+ sizeof (EFI_MEMORY_DESCRIPTOR) + sizeof (UINT64) - (sizeof (EFI_MEMORY_DESCRIPTOR) % sizeof (UINT64)), \r
+ EFI_MEMORY_DESCRIPTOR_VERSION, \r
+ 0,\r
+ NULL,\r
+ NULL,\r
+ FALSE,\r
+ FALSE\r
+};\r
+\r
+EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = &gRuntimeTemplate;\r
+\r
//\r
// DXE Core Global Variables for the EFI System Table, Boot Services Table, \r
// DXE Services Table, and Runtime Services Table\r
\r
Routine Description:\r
\r
- EFI 1.0 API to terminate Boot Services\r
+ Terminates all boot services.\r
\r
Arguments:\r
\r
- ImageHandle - Handle that represents the identity of the calling image\r
+ ImageHandle - Handle that identifies the exiting image.\r
\r
MapKey -Key to the latest memory map.\r
\r
//\r
gCpu->DisableInterrupt (gCpu);\r
\r
- //\r
- // Register Runtime events with the Runtime Architectural Protocol\r
- //\r
- CoreShutdownEventServices ();\r
-\r
- //\r
- // Register Runtime images with the Runtime Architectural Protocol\r
- //\r
- CoreShutdownImageServices ();\r
-\r
//\r
// Report that ExitBootServices() has been called\r
//\r
//\r
SetMem (gBS, sizeof (EFI_BOOT_SERVICES), 0);\r
gBS = NULL;\r
-\r
+ \r
+ //\r
+ // Update the AtRuntime field in Runtiem AP.\r
+ //\r
+ gRuntime->AtRuntime = TRUE;\r
+ \r
return Status;\r
}\r
\r
ARCHITECTURAL_PROTOCOL_ENTRY *Entry;\r
VOID *Protocol;\r
BOOLEAN Found;\r
+ LIST_ENTRY *Link;\r
+ LIST_ENTRY TempLinkNode;\r
\r
Found = FALSE;\r
for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {\r
// When runtime architectural protocol is available, updates CRC32 in the Debug Table\r
//\r
CoreUpdateDebugTableCrc32 ();\r
+\r
+ //\r
+ // Update the Runtime Architectural protocol with the template that the core was\r
+ // using so there would not need to be a dependency on the Runtime AP\r
+ //\r
+\r
+ //\r
+ // Copy all the registered Image to new gRuntime protocol\r
+ //\r
+ for (Link = gRuntimeTemplate.ImageHead.ForwardLink; Link != &gRuntimeTemplate.ImageHead; Link = TempLinkNode.ForwardLink) {\r
+ CopyMem (&TempLinkNode, Link, sizeof(LIST_ENTRY));\r
+ InsertTailList (&gRuntime->ImageHead, Link);\r
+ }\r
+ //\r
+ // Copy all the registered Event to new gRuntime protocol\r
+ //\r
+ for (Link = gRuntimeTemplate.EventHead.ForwardLink; Link != &gRuntimeTemplate.EventHead; Link = TempLinkNode.ForwardLink) {\r
+ CopyMem (&TempLinkNode, Link, sizeof(LIST_ENTRY));\r
+ InsertTailList (&gRuntime->EventHead, Link);\r
+ }\r
+ \r
+ //\r
+ // Clean up gRuntimeTemplate\r
+ //\r
+ gRuntimeTemplate.ImageHead.ForwardLink = &gRuntimeTemplate.ImageHead;\r
+ gRuntimeTemplate.ImageHead.BackLink = &gRuntimeTemplate.ImageHead;\r
+ gRuntimeTemplate.EventHead.ForwardLink = &gRuntimeTemplate.EventHead;\r
+ gRuntimeTemplate.EventHead.BackLink = &gRuntimeTemplate.EventHead;\r
}\r
}\r
\r
}\r
\r
\r
-EFI_STATUS\r
-CoreShutdownEventServices (\r
- VOID\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Register all runtime events to make sure they are still available after ExitBootService.\r
-\r
-Arguments:\r
-\r
- None\r
- \r
-Returns:\r
-\r
- EFI_SUCCESS - Always return success.\r
-\r
---*/\r
-{\r
- LIST_ENTRY *Link;\r
- IEVENT *Event;\r
-\r
- //\r
- // The Runtime AP is required for the core to function!\r
- //\r
- ASSERT (gRuntime != NULL);\r
-\r
- for (Link = mRuntimeEventList.ForwardLink; Link != &mRuntimeEventList; Link = Link->ForwardLink) {\r
- Event = CR (Link, IEVENT, RuntimeLink, EVENT_SIGNATURE);\r
- gRuntime->RegisterEvent (\r
- gRuntime, \r
- Event->Type, \r
- Event->NotifyTpl, \r
- Event->NotifyFunction, \r
- Event->NotifyContext, \r
- (VOID **)Event\r
- );\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
VOID\r
CoreDispatchEventNotifies (\r
IN EFI_TPL Priority\r
//\r
// Keep a list of all RT events so we can tell the RT AP.\r
//\r
- InsertTailList (&mRuntimeEventList, &IEvent->RuntimeLink);\r
+ IEvent->RuntimeData.Type = Type;\r
+ IEvent->RuntimeData.NotifyTpl = NotifyTpl;\r
+ IEvent->RuntimeData.NotifyFunction = NotifyFunction;\r
+ IEvent->RuntimeData.NotifyContext = (VOID *) NotifyContext;\r
+ IEvent->RuntimeData.Event = (EFI_EVENT *) IEvent;\r
+ InsertTailList (&gRuntime->EventHead, &IEvent->RuntimeData.Link);\r
}\r
\r
CoreAcquireEventLock ();\r
//\r
// If the event is queued somewhere, remove it\r
//\r
-\r
- if (Event->RuntimeLink.ForwardLink != NULL) {\r
- RemoveEntryList (&Event->RuntimeLink);\r
+ \r
+ if (Event->RuntimeData.Link.ForwardLink != NULL) {\r
+ RemoveEntryList (&Event->RuntimeData.Link);\r
}\r
-\r
+ \r
if (Event->NotifyLink.ForwardLink != NULL) {\r
RemoveEntryList (&Event->NotifyLink);\r
}\r
//\r
LIST_ENTRY gEventSignalQueue = INITIALIZE_LIST_HEAD_VARIABLE (gEventSignalQueue);\r
\r
-//\r
-// LIST of runtime events that need to be fired by RT AP.\r
-//\r
-LIST_ENTRY mRuntimeEventList = INITIALIZE_LIST_HEAD_VARIABLE (mRuntimeEventList);\r
//\r
// A list of all runtime events\r
//\r
- LIST_ENTRY RuntimeLink;\r
+ EFI_RUNTIME_EVENT_ENTRY RuntimeData;\r
\r
//\r
// Information by event type\r
extern LIST_ENTRY gEventQueue[];\r
extern LIST_ENTRY gEventSignalQueue;\r
extern UINT8 gHSB[];\r
-extern LIST_ENTRY mRuntimeEventList;\r
\r
#endif\r
\r
EFI_EBC_PROTOCOL *Ebc; // EBC Protocol pointer\r
\r
- BOOLEAN RuntimeFixupValid; // True if RT image needs fixup\r
- VOID *RuntimeFixup; // Copy of fixup data;\r
- LIST_ENTRY Link; // List of RT LOADED_IMAGE_PRIVATE_DATA\r
+ EFI_RUNTIME_IMAGE_ENTRY *RuntimeData; // Runtime image list\r
\r
- PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; // PeCoffLoader ImageContext\r
+ PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; // PeCoffLoader ImageContext\r
\r
} LOADED_IMAGE_PRIVATE_DATA;\r
\r
// Module Globals\r
//\r
\r
-//\r
-// LIST of runtime images that need to be relocated.\r
-//\r
-LIST_ENTRY mRuntimeImageList = INITIALIZE_LIST_HEAD_VARIABLE (mRuntimeImageList);\r
-\r
LOADED_IMAGE_PRIVATE_DATA *mCurrentImage = NULL;\r
\r
LOAD_PE32_IMAGE_PRIVATE_DATA mLoadPe32PrivateData = {\r
NULL, // JumpContext\r
0, // Machine\r
NULL, // Ebc\r
- FALSE, // RuntimeFixupValid\r
- NULL, // RuntimeFixup\r
- { NULL, NULL }, // Link\r
+ NULL, // RuntimeData\r
};\r
\r
\r
);\r
}\r
\r
-\r
-EFI_STATUS\r
-CoreShutdownImageServices (\r
- VOID\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Transfer control of runtime images to runtime service\r
-\r
-Arguments:\r
-\r
- None\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - Function successfully returned\r
-\r
---*/\r
-{\r
- LIST_ENTRY *Link;\r
- LOADED_IMAGE_PRIVATE_DATA *Image;\r
-\r
- //\r
- // The Runtime AP is required for the core to function!\r
- //\r
- ASSERT (gRuntime != NULL);\r
-\r
- for (Link = mRuntimeImageList.ForwardLink; Link != &mRuntimeImageList; Link = Link->ForwardLink) {\r
- Image = CR (Link, LOADED_IMAGE_PRIVATE_DATA, Link, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE);\r
- if (Image->RuntimeFixupValid) {\r
- gRuntime->RegisterImage (\r
- gRuntime,\r
- (UINT64)(UINTN)(Image->Info.ImageBase),\r
- (EFI_SIZE_TO_PAGES ((UINTN)Image->Info.ImageSize)),\r
- Image->RuntimeFixup\r
- );\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-\r
EFI_STATUS\r
CoreLoadPeImage (\r
IN VOID *Pe32Handle,\r
\r
--*/\r
{\r
- EFI_STATUS Status;\r
- UINTN Size;\r
+ EFI_STATUS Status;\r
+ BOOLEAN DstBufAlocated;\r
+ UINTN Size;\r
\r
ZeroMem (&Image->ImageContext, sizeof (Image->ImageContext));\r
\r
//\r
// Allocate memory of the correct memory type aligned on the required image boundry\r
//\r
-\r
+ DstBufAlocated = FALSE;\r
if (DstBuffer == 0) {\r
//\r
// Allocate Destination Buffer as caller did not pass it in\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
-\r
- Image->ImageBasePage = Image->ImageContext.ImageAddress;\r
+ DstBufAlocated = TRUE;\r
\r
} else {\r
//\r
\r
Image->NumberOfPages = EFI_SIZE_TO_PAGES ((UINTN)Image->ImageContext.ImageSize + Image->ImageContext.SectionAlignment);\r
Image->ImageContext.ImageAddress = DstBuffer;\r
- Image->ImageBasePage = Image->ImageContext.ImageAddress;\r
}\r
\r
+ Image->ImageBasePage = Image->ImageContext.ImageAddress;\r
Image->ImageContext.ImageAddress =\r
(Image->ImageContext.ImageAddress + Image->ImageContext.SectionAlignment - 1) &\r
~((UINTN)Image->ImageContext.SectionAlignment - 1);\r
//\r
Status = gEfiPeiPeCoffLoader->LoadImage (gEfiPeiPeCoffLoader, &Image->ImageContext);\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ goto Done;\r
}\r
\r
//\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Done;\r
}\r
-\r
- //\r
- // Make a list off all the RT images so we can let the RT AP know about them\r
- //\r
- Image->RuntimeFixupValid = TRUE;\r
- Image->RuntimeFixup = Image->ImageContext.FixupData;\r
- InsertTailList (&mRuntimeImageList, &Image->Link);\r
}\r
}\r
\r
//\r
Status = gEfiPeiPeCoffLoader->RelocateImage (gEfiPeiPeCoffLoader, &Image->ImageContext);\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ goto Done;\r
}\r
\r
//\r
Image->Info.ImageSize = Image->ImageContext.ImageSize;\r
Image->Info.ImageCodeType = Image->ImageContext.ImageCodeMemoryType;\r
Image->Info.ImageDataType = Image->ImageContext.ImageDataMemoryType;\r
-\r
+ if (Attribute & EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION) {\r
+ if (Image->ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) {\r
+ //\r
+ // Make a list off all the RT images so we can let the RT AP know about them.\r
+ //\r
+ Image->RuntimeData = CoreAllocateRuntimePool (sizeof(EFI_RUNTIME_IMAGE_ENTRY));\r
+ if (Image->RuntimeData == NULL) {\r
+ goto Done;\r
+ }\r
+ Image->RuntimeData->ImageBase = Image->Info.ImageBase;\r
+ Image->RuntimeData->ImageSize = (UINT64) (Image->Info.ImageSize);\r
+ Image->RuntimeData->RelocationData = Image->ImageContext.FixupData;\r
+ Image->RuntimeData->Handle = Image->Handle;\r
+ InsertTailList (&gRuntime->ImageHead, &Image->RuntimeData->Link);\r
+ }\r
+ }\r
+ \r
//\r
// Fill in the entry point of the image if it is available\r
//\r
return EFI_SUCCESS;\r
\r
Done:\r
+\r
//\r
- // Free memory\r
+ // Free memory.\r
//\r
- CoreFreePages (Image->ImageContext.ImageAddress, Image->NumberOfPages);\r
+ \r
+ if (DstBufAlocated) {\r
+ CoreFreePages (Image->ImageContext.ImageAddress, Image->NumberOfPages);\r
+ }\r
+ \r
+ if (Image->ImageContext.FixupData != NULL) {\r
+ CoreFreePool (Image->ImageContext.FixupData);\r
+ }\r
+\r
return Status;\r
}\r
\r
);\r
}\r
\r
- if (Image->RuntimeFixupValid) {\r
- //\r
- // Remove the Image from the Runtime Image list as we are about to Free it!\r
- //\r
- RemoveEntryList (&Image->Link);\r
+ if (Image->RuntimeData != NULL) {\r
+ if (Image->RuntimeData->Link.ForwardLink != NULL) {\r
+ //\r
+ // Remove the Image from the Runtime Image list as we are about to Free it!\r
+ //\r
+ RemoveEntryList (&Image->RuntimeData->Link);\r
+ }\r
+ CoreFreePool (Image->RuntimeData);\r
}\r
-\r
+ \r
//\r
// Free the Image from memory\r
//\r
\r
Routine Description:\r
\r
+ Calculate CRC32 for target data\r
+\r
Arguments:\r
\r
+ Data - The target data.\r
+ DataSize - The target data size.\r
+ CrcOut - The CRC32 for target data.\r
+\r
Returns:\r
\r
+ EFI_SUCCESS - The CRC32 for target data is calculated successfully.\r
+ EFI_INVALID_PARAMETER - Some parameter is not valid, so the CRC32 is not \r
+ calculated.\r
+\r
--*/\r
{\r
UINT32 Crc;\r
\r
Routine Description:\r
\r
+ Reverse bits for 32bit data.\r
+\r
Arguments:\r
\r
+ Value - the data to be reversed.\r
+\r
Returns:\r
\r
+ UINT32 data reversed.\r
+\r
--*/\r
{\r
UINTN Index;\r
\r
Routine Description:\r
\r
+ Initialize CRC32 table.\r
+\r
Arguments:\r
\r
+ None.\r
+\r
Returns:\r
\r
+ None.\r
+\r
--*/\r
{\r
UINTN TableEntry;\r
+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- PeHotRelocate.c\r
-\r
-Abstract:\r
-\r
-\r
---*/\r
-\r
-#include "Runtime.h"\r
-\r
-STATIC\r
-VOID *\r
-RuntimePeImageAddress (\r
- IN RUNTIME_IMAGE_RELOCATION_DATA *Image,\r
- IN UINTN Address\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Converts an image address to the loaded address\r
-\r
-Arguments:\r
-\r
- Image - The relocation data of the image being loaded\r
-\r
- Address - The address to be converted to the loaded address\r
-\r
-Returns:\r
-\r
- NULL if the address can not be converted, otherwise, the converted address\r
-\r
---*/\r
-{\r
- if (Address >= (Image->ImageSize) << EFI_PAGE_SHIFT) {\r
- return NULL;\r
- }\r
-\r
- return (CHAR8 *) ((UINTN) Image->ImageBase + Address);\r
-}\r
-\r
#include "Runtime.h"\r
\r
//\r
-// This is a only short term solution.\r
-// There is a change coming to the Runtime AP that\r
-// will make it so the Runtime driver will not have to allocate any buffers. \r
+// Global Variables\r
//\r
-#define MAX_RUNTIME_IMAGE_NUM (64)\r
-#define MAX_RUNTIME_EVENT_NUM (64)\r
-RUNTIME_IMAGE_RELOCATION_DATA mRuntimeImageBuffer[MAX_RUNTIME_IMAGE_NUM];\r
-RUNTIME_NOTIFY_EVENT_DATA mRuntimeEventBuffer[MAX_RUNTIME_EVENT_NUM];\r
-UINTN mRuntimeImageNumber;\r
-UINTN mRuntimeEventNumber;\r
+EFI_MEMORY_DESCRIPTOR *mVirtualMap = NULL;\r
+UINTN mVirtualMapDescriptorSize;\r
+UINTN mVirtualMapMaxIndex;\r
+VOID *mMyImageBase;\r
\r
//\r
// The handle onto which the Runtime Architectural Protocol instance is installed\r
// The Runtime Architectural Protocol instance produced by this driver\r
//\r
EFI_RUNTIME_ARCH_PROTOCOL mRuntime = {\r
- RuntimeDriverRegisterImage,\r
- RuntimeDriverRegisterEvent\r
-};\r
-\r
-//\r
-// Global Variables\r
-//\r
-LIST_ENTRY mRelocationList = INITIALIZE_LIST_HEAD_VARIABLE(mRelocationList);\r
-LIST_ENTRY mEventList = INITIALIZE_LIST_HEAD_VARIABLE(mEventList);\r
-BOOLEAN mEfiVirtualMode = FALSE;\r
-EFI_GUID mLocalEfiUgaIoProtocolGuid = EFI_UGA_IO_PROTOCOL_GUID;\r
-EFI_MEMORY_DESCRIPTOR *mVirtualMap = NULL;\r
-UINTN mVirtualMapDescriptorSize;\r
-UINTN mVirtualMapMaxIndex;\r
+ INITIALIZE_LIST_HEAD_VARIABLE (mRuntime.ImageHead),\r
+ INITIALIZE_LIST_HEAD_VARIABLE (mRuntime.EventHead),\r
\r
-EFI_LOADED_IMAGE_PROTOCOL *mMyLoadedImage;\r
+ //\r
+ // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will\r
+ // prevent people from having pointer math bugs in their code.\r
+ // now you have to use *DescriptorSize to make things work.\r
+ //\r
+ sizeof (EFI_MEMORY_DESCRIPTOR) + sizeof (UINT64) - (sizeof (EFI_MEMORY_DESCRIPTOR) % sizeof (UINT64)), \r
+ EFI_MEMORY_DESCRIPTOR_VERSION, \r
+ 0,\r
+ NULL,\r
+ NULL,\r
+ FALSE,\r
+ FALSE\r
+};\r
\r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-STATIC EFI_GUID mEfiCapsuleHeaderGuid = EFI_CAPSULE_GUID;\r
-#endif\r
//\r
// Worker Functions\r
//\r
\r
EFI_STATUS\r
EFIAPI\r
-RuntimeDriverRegisterImage (\r
- IN EFI_RUNTIME_ARCH_PROTOCOL *This,\r
- IN EFI_PHYSICAL_ADDRESS ImageBase,\r
- IN UINTN ImageSize,\r
- IN VOID *RelocationData\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- When a SetVirtualAddressMap() is performed all the runtime images loaded by \r
- DXE must be fixed up with the new virtual address map. To facilitate this the \r
- Runtime Architectural Protocol needs to be informed of every runtime driver \r
- that is registered. All the runtime images loaded by DXE should be registered \r
- with this service by the DXE Core when ExitBootServices() is called. The \r
- images that are registered with this service must have successfully been \r
- loaded into memory with the Boot Service LoadImage(). As a result, no \r
- parameter checking needs to be performed.\r
-\r
-Arguments:\r
-\r
- This - The EFI_RUNTIME_ARCH_PROTOCOL instance. \r
-\r
- ImageBase - Start of image that has been loaded in memory. It is either \r
- a pointer to the DOS or PE header of the image.\r
-\r
- ImageSize - Size of the image in bytes.\r
-\r
- RelocationData - Information about the fixups that were performed on ImageBase \r
- when it was loaded into memory. This information is needed \r
- when the virtual mode fix-ups are reapplied so that data that \r
- has been programmatically updated will not be fixed up. If \r
- code updates a global variable the code is responsible for \r
- fixing up the variable for virtual mode.\r
-\r
-Returns: \r
-\r
- EFI_SUCCESS - The ImageBase has been registered.\r
-\r
---*/\r
-{\r
- RUNTIME_IMAGE_RELOCATION_DATA *RuntimeImage;\r
-\r
- if (mMyLoadedImage->ImageBase == (VOID *) (UINTN) ImageBase) {\r
- //\r
- // We don't want to relocate our selves, as we only run in physical mode.\r
- //\r
- return EFI_SUCCESS;\r
- }\r
-\r
- RuntimeImage = &mRuntimeImageBuffer[mRuntimeImageNumber];\r
- mRuntimeImageNumber++;\r
- ASSERT (mRuntimeImageNumber < MAX_RUNTIME_IMAGE_NUM);\r
-\r
- RuntimeImage->Valid = TRUE;\r
- RuntimeImage->ImageBase = ImageBase;\r
- RuntimeImage->ImageSize = ImageSize;\r
- RuntimeImage->RelocationData = RelocationData;\r
-\r
- InsertTailList (&mRelocationList, &RuntimeImage->Link);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-RuntimeDriverRegisterEvent (\r
- IN EFI_RUNTIME_ARCH_PROTOCOL *This,\r
- IN UINT32 Type,\r
- IN EFI_TPL NotifyTpl,\r
- IN EFI_EVENT_NOTIFY NotifyFunction,\r
- IN VOID *NotifyContext,\r
- IN EFI_EVENT *Event\r
+RuntimeDriverConvertPointer (\r
+ IN UINTN DebugDisposition,\r
+ IN OUT VOID **ConvertAddress\r
)\r
/*++\r
\r
Routine Description:\r
\r
- This function is used to support the required runtime events. Currently only \r
- runtime events of type EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE needs to be \r
- registered with this service. All the runtime events that exist in the DXE \r
- Core should be registered with this service when ExitBootServices() is called. \r
- All the events that are registered with this service must have been created \r
- with the Boot Service CreateEvent(). As a result, no parameter checking needs \r
- to be performed.\r
+ Determines the new virtual address that is to be used on subsequent memory accesses.\r
\r
Arguments:\r
+ \r
+ DebugDisposition - Supplies type information for the pointer being converted.\r
+ ConvertAddress - A pointer to a pointer that is to be fixed to be the value needed\r
+ for the new virtual address mappings being applied.\r
\r
- This - The EFI_RUNTIME_ARCH_PROTOCOL instance. \r
-\r
- Type - The same as Type passed into CreateEvent().\r
-\r
- NotifyTpl - The same as NotifyTpl passed into CreateEvent().\r
-\r
- NotifyFunction - The same as NotifyFunction passed into CreateEvent().\r
-\r
- NotifyContext - The same as NotifyContext passed into CreateEvent().\r
-\r
- Event - The EFI_EVENT returned by CreateEvent(). Event must be in \r
- runtime memory.\r
-\r
-Returns: \r
+Returns:\r
\r
- EFI_SUCCESS - The Event has been registered.\r
+ EFI_SUCCESS - The pointer pointed to by Address was modified.\r
+ EFI_NOT_FOUND - The pointer pointed to by Address was not found to be part\r
+ of the current memory map. This is normally fatal.\r
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value.\r
\r
--*/\r
-{\r
- RUNTIME_NOTIFY_EVENT_DATA *RuntimeEvent;\r
-\r
- RuntimeEvent = &mRuntimeEventBuffer[mRuntimeEventNumber];\r
- mRuntimeEventNumber++;\r
- ASSERT (mRuntimeEventNumber < MAX_RUNTIME_EVENT_NUM);\r
-\r
- RuntimeEvent->Type = Type;\r
- RuntimeEvent->NotifyTpl = NotifyTpl;\r
- RuntimeEvent->NotifyFunction = NotifyFunction;\r
- RuntimeEvent->NotifyContext = NotifyContext;\r
- RuntimeEvent->Event = Event;\r
-\r
- InsertTailList (&mEventList, &RuntimeEvent->Link);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-RuntimeDriverConvertPointer (\r
- IN UINTN DebugDisposition,\r
- IN OUT VOID **ConvertAddress\r
- )\r
{\r
UINTN Address;\r
VOID *PlabelConvertAddress;\r
// platforms. If you get this ASSERT remove the UINTN and do a 64-bit\r
// multiply.\r
//\r
- ASSERT ((VirtEntry->NumberOfPages < 0xffffffff) || (sizeof (UINTN) > 4));\r
+ ASSERT (((UINTN) VirtEntry->NumberOfPages < 0xffffffff) || (sizeof (UINTN) > 4));\r
\r
if ((VirtEntry->Attribute & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {\r
if (Address >= VirtEntry->PhysicalStart) {\r
RuntimeDriverConvertInternalPointer (\r
IN OUT VOID **ConvertAddress\r
)\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Determines the new virtual address that is to be used on subsequent memory accesses \r
+ for internal pointers.\r
+\r
+Arguments:\r
+ \r
+ ConvertAddress - A pointer to a pointer that is to be fixed to be the value needed\r
+ for the new virtual address mappings being applied.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The pointer pointed to by Address was modified.\r
+ EFI_NOT_FOUND - The pointer pointed to by Address was not found to be part\r
+ of the current memory map. This is normally fatal.\r
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value.\r
+\r
+--*/\r
{\r
return RuntimeDriverConvertPointer (0x0, ConvertAddress);\r
}\r
IN UINT32 DescriptorVersion,\r
IN EFI_MEMORY_DESCRIPTOR *VirtualMap\r
)\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Changes the runtime addressing mode of EFI firmware from physical to virtual.\r
+\r
+Arguments:\r
+ \r
+ MemoryMapSize - The size in bytes of VirtualMap.\r
+ DescriptorSize - The size in bytes of an entry in the VirtualMap.\r
+ DescriptorVersion - The version of the structure entries in VirtualMap.\r
+ VirtualMap - An array of memory descriptors which contain new virtual\r
+ address mapping information for all runtime ranges.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The virtual address map has been applied.\r
+ EFI_UNSUPPORTED - EFI firmware is not at runtime, or the EFI firmware is already in\r
+ virtual address mapped mode.\r
+ EFI_INVALID_PARAMETER - DescriptorSize or DescriptorVersion is invalid.\r
+ EFI_NO_MAPPING - A virtual address was not supplied for a range in the memory\r
+ map that requires a mapping.\r
+ EFI_NOT_FOUND - A virtual address was supplied for an address that is not found\r
+ in the memory map.\r
+\r
+--*/ \r
{\r
EFI_STATUS Status;\r
- RUNTIME_NOTIFY_EVENT_DATA *RuntimeEvent;\r
- RUNTIME_IMAGE_RELOCATION_DATA *RuntimeImage;\r
+ EFI_RUNTIME_EVENT_ENTRY *RuntimeEvent;\r
+ EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage;\r
LIST_ENTRY *Link;\r
UINTN Index;\r
UINTN Index1;\r
// Can only switch to virtual addresses once the memory map is locked down,\r
// and can only set it once\r
//\r
- if (!EfiAtRuntime () || mEfiVirtualMode) {\r
+ if (!mRuntime.AtRuntime || mRuntime.VirtualMode) {\r
return EFI_UNSUPPORTED;\r
}\r
//\r
return EFI_INVALID_PARAMETER;\r
}\r
//\r
- // BugBug: Add code here to verify the memory map. We should\r
- // cache a copy of the system memory map in the EFI System Table\r
- // as a GUID pointer pair.\r
- //\r
- //\r
- // Make sure all virtual translations are satisfied\r
- //\r
- mVirtualMapMaxIndex = MemoryMapSize / DescriptorSize;\r
-\r
- //\r
- // BugBug :The following code does not work hence commented out.\r
- // Need to be replaced by something that works.\r
- //\r
- // VirtEntry = VirtualMap;\r
- // for (Index = 0; Index < mVirtualMapMaxIndex; Index++) {\r
- // if (((VirtEntry->Attribute & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) &&\r
- // (VirtEntry->VirtualStart != 0) ) {\r
- // return EFI_NO_MAPPING;\r
- // }\r
- // VirtEntry = NextMemoryDescriptor(VirtEntry, DescriptorSize);\r
- // }\r
- //\r
// We are now committed to go to virtual mode, so lets get to it!\r
//\r
- mEfiVirtualMode = TRUE;\r
+ mRuntime.VirtualMode = TRUE;\r
\r
//\r
// ConvertPointer() needs this mVirtualMap to do the conversion. So set up\r
// globals we need to parse the virtual address map.\r
//\r
mVirtualMapDescriptorSize = DescriptorSize;\r
+ mVirtualMapMaxIndex = MemoryMapSize / DescriptorSize;\r
mVirtualMap = VirtualMap;\r
\r
- //\r
- // Signal all the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE events.\r
- // The core call RuntimeDriverRegisterEvent() for\r
- // every runtime event and we stored them in the mEventList\r
- //\r
//\r
// Currently the bug in StatusCode/RuntimeLib has been fixed, it will\r
// check whether in Runtime or not (this is judged by looking at\r
);\r
\r
//\r
- // BugBug - Commented out for now because the status code driver is not\r
- // ready for runtime yet. The Status Code driver calls data hub with does\r
- // a bunch of Boot Service things (locks, AllocatePool) and hangs somewhere\r
- // on the way.\r
- //\r
- // ReportStatusCode (\r
- // EfiProgressCode, EfiMaxErrorSeverity,\r
- // 0x03, 0x01, 12, // ReadyToBoot Progress code\r
- // 0x00, 30, L"ConvertPointer"\r
- // );\r
+ // Signal all the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE events.\r
+ // All runtime events are stored in a list in Runtime AP.\r
//\r
- for (Link = mEventList.ForwardLink; Link != &mEventList; Link = Link->ForwardLink) {\r
- RuntimeEvent = _CR (Link, RUNTIME_NOTIFY_EVENT_DATA, Link);\r
+ for (Link = mRuntime.EventHead.ForwardLink; Link != &mRuntime.EventHead; Link = Link->ForwardLink) {\r
+ RuntimeEvent = _CR (Link, EFI_RUNTIME_EVENT_ENTRY, Link);\r
if ((RuntimeEvent->Type & EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) == EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) {\r
RuntimeEvent->NotifyFunction (\r
RuntimeEvent->Event,\r
);\r
}\r
}\r
+\r
//\r
- // Relocate runtime images. Runtime images loaded before the runtime AP was\r
- // started will not be relocated, since they would not have gotten registered.\r
- // This includes the code in this file.\r
+ // Relocate runtime images. All runtime images are stored in a list in Runtime AP.\r
//\r
- for (Link = mRelocationList.ForwardLink; Link != &mRelocationList; Link = Link->ForwardLink) {\r
- RuntimeImage = _CR (Link, RUNTIME_IMAGE_RELOCATION_DATA, Link);\r
- if (RuntimeImage->Valid) {\r
+ for (Link = mRuntime.ImageHead.ForwardLink; Link != &mRuntime.ImageHead; Link = Link->ForwardLink) {\r
+ RuntimeImage = _CR (Link, EFI_RUNTIME_IMAGE_ENTRY, Link);\r
+ //\r
+ // We don't want to relocate our selves, as we only run in physical mode.\r
+ //\r
+ if (mMyImageBase != RuntimeImage->ImageBase) {\r
\r
- VirtImageBase = RuntimeImage->ImageBase;\r
+ VirtImageBase = (EFI_PHYSICAL_ADDRESS) (UINTN) RuntimeImage->ImageBase;\r
Status = RuntimeDriverConvertPointer (0, (VOID **) &VirtImageBase);\r
ASSERT_EFI_ERROR (Status);\r
\r
PeCoffLoaderRelocateImageForRuntime (\r
- RuntimeImage->ImageBase,\r
+ (EFI_PHYSICAL_ADDRESS) (UINTN) RuntimeImage->ImageBase,\r
VirtImageBase,\r
- RuntimeImage->ImageSize,\r
+ (UINTN) RuntimeImage->ImageSize,\r
RuntimeImage->RelocationData\r
);\r
\r
- InvalidateInstructionCacheRange ((VOID *)(UINTN)RuntimeImage->ImageBase, (UINTN)RuntimeImage->ImageSize);\r
+ InvalidateInstructionCacheRange (RuntimeImage->ImageBase, (UINTN)RuntimeImage->ImageSize);\r
}\r
}\r
+\r
//\r
// Convert all the Runtime Services except ConvertPointer() and SetVirtualAddressMap()\r
// and recompute the CRC-32\r
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetWakeupTime);\r
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->SetWakeupTime);\r
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->ResetSystem);\r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
+ RuntimeDriverConvertInternalPointer ((VOID **) &gRT->ReportStatusCode);\r
+#endif\r
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetNextHighMonotonicCount);\r
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetVariable);\r
RuntimeDriverConvertInternalPointer ((VOID **) &gRT->SetVariable);\r
// Convert the UGA OS Handoff Table if it is present in the Configuration Table\r
//\r
for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {\r
- if (CompareGuid (&mLocalEfiUgaIoProtocolGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {\r
+ if (CompareGuid (&gEfiUgaIoProtocolGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {\r
DriverOsHandoffHeader = gST->ConfigurationTable[Index].VendorTable;\r
for (Index1 = 0; Index1 < DriverOsHandoffHeader->NumberOfEntries; Index1++) {\r
DriverOsHandoff = (EFI_DRIVER_OS_HANDOFF *)\r
\r
RuntimeDriverConvertPointer (EFI_OPTIONAL_POINTER, (VOID **) &(gST->ConfigurationTable[Index].VendorTable));\r
}\r
+\r
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
- if (CompareGuid (&mEfiCapsuleHeaderGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {\r
+ if (CompareGuid (&gEfiCapsuleGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {\r
CapsuleTable = gST->ConfigurationTable[Index].VendorTable;\r
for (Index1 = 0; Index1 < CapsuleTable->CapsuleArrayNumber; Index1++) {\r
RuntimeDriverConvertPointer (EFI_OPTIONAL_POINTER, (VOID **) &CapsuleTable->CapsulePtr[Index1]);\r
\r
--*/\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
+ EFI_LOADED_IMAGE_PROTOCOL *MyLoadedImage;\r
\r
//\r
// This image needs to be exclued from relocation for virtual mode, so cache\r
Status = gBS->HandleProtocol (\r
ImageHandle,\r
&gEfiLoadedImageProtocolGuid,\r
- (VOID **) &mMyLoadedImage\r
+ &MyLoadedImage\r
);\r
ASSERT_EFI_ERROR (Status);\r
+ mMyImageBase = MyLoadedImage->ImageBase;\r
\r
//\r
// Initialize the table used to compute 32-bit CRCs\r
//\r
// Fill in the entries of the EFI Boot Services and EFI Runtime Services Tables\r
//\r
- gBS->CalculateCrc32 = RuntimeDriverCalculateCrc32;\r
+ gBS->CalculateCrc32 = RuntimeDriverCalculateCrc32;\r
gRT->SetVirtualAddressMap = RuntimeDriverSetVirtualAddressMap;\r
gRT->ConvertPointer = RuntimeDriverConvertPointer;\r
\r
NULL\r
);\r
ASSERT_EFI_ERROR (Status);\r
-\r
- mRuntimeImageNumber = 0;\r
- mRuntimeEventNumber = 0;\r
-\r
- return Status;\r
+ \r
+ return EFI_SUCCESS;\r
}\r
\r
Runtime Architectural Protocol as defined in the DXE CIS\r
\r
- This code is used to produce the EFI runtime virtual switch over\r
+ This code is used to produce the EFI runtime architectural protocol.\r
\r
--*/\r
\r
#ifndef _RUNTIME_H_\r
#define _RUNTIME_H_\r
\r
-//\r
-// Data structures\r
-//\r
-typedef struct {\r
- LIST_ENTRY Link;\r
- BOOLEAN Valid;\r
- EFI_PHYSICAL_ADDRESS ImageBase;\r
- UINTN ImageSize; // In no. of pages\r
- VOID *RelocationData;\r
-} RUNTIME_IMAGE_RELOCATION_DATA;\r
-\r
-typedef struct {\r
- LIST_ENTRY Link;\r
- IN UINT32 Type;\r
- IN EFI_TPL NotifyTpl;\r
- IN EFI_EVENT_NOTIFY NotifyFunction;\r
- IN VOID *NotifyContext;\r
- IN EFI_EVENT Event;\r
-} RUNTIME_NOTIFY_EVENT_DATA;\r
-\r
//\r
// Function Prototypes\r
//\r
-VOID\r
-RelocatePeImageForRuntime (\r
- RUNTIME_IMAGE_RELOCATION_DATA *Image\r
- );\r
-\r
EFI_STATUS\r
EFIAPI\r
RuntimeDriverCalculateCrc32 (\r
IN VOID *Data,\r
IN UINTN DataSize,\r
OUT UINT32 *CrcOut\r
- );\r
+ )\r
+/*++\r
\r
-EFI_STATUS\r
-EFIAPI\r
-RuntimeDriverRegisterImage (\r
- IN EFI_RUNTIME_ARCH_PROTOCOL *This,\r
- IN EFI_PHYSICAL_ADDRESS ImageBase,\r
- IN UINTN ImageSize,\r
- IN VOID *RelocationData\r
- );\r
+Routine Description:\r
\r
-EFI_STATUS\r
-EFIAPI\r
-RuntimeDriverRegisterEvent (\r
- IN EFI_RUNTIME_ARCH_PROTOCOL *This,\r
- IN UINT32 Type,\r
- IN EFI_TPL NotifyTpl,\r
- IN EFI_EVENT_NOTIFY NotifyFunction,\r
- IN VOID *NotifyContext,\r
- IN EFI_EVENT *Event\r
- );\r
+ Calculate CRC32 for target data\r
+\r
+Arguments:\r
+\r
+ Data - The target data.\r
+ DataSize - The target data size.\r
+ CrcOut - The CRC32 for target data.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The CRC32 for target data is calculated successfully.\r
+ EFI_INVALID_PARAMETER - Some parameter is not valid, so the CRC32 is not \r
+ calculated.\r
+\r
+--*/\r
+;\r
\r
EFI_STATUS\r
EFIAPI\r
RuntimeDriverConvertPointer (\r
IN UINTN DebugDisposition,\r
IN OUT VOID **ConvertAddress\r
- );\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Determines the new virtual address that is to be used on subsequent memory accesses.\r
+\r
+Arguments:\r
+ \r
+ DebugDisposition - Supplies type information for the pointer being converted.\r
+ ConvertAddress - A pointer to a pointer that is to be fixed to be the value needed\r
+ for the new virtual address mappings being applied.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The pointer pointed to by Address was modified.\r
+ EFI_NOT_FOUND - The pointer pointed to by Address was not found to be part\r
+ of the current memory map. This is normally fatal.\r
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+RuntimeDriverSetVirtualAddressMap (\r
+ IN UINTN MemoryMapSize,\r
+ IN UINTN DescriptorSize,\r
+ IN UINT32 DescriptorVersion,\r
+ IN EFI_MEMORY_DESCRIPTOR *VirtualMap\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Changes the runtime addressing mode of EFI firmware from physical to virtual.\r
+\r
+Arguments:\r
+ \r
+ MemoryMapSize - The size in bytes of VirtualMap.\r
+ DescriptorSize - The size in bytes of an entry in the VirtualMap.\r
+ DescriptorVersion - The version of the structure entries in VirtualMap.\r
+ VirtualMap - An array of memory descriptors which contain new virtual\r
+ address mapping information for all runtime ranges.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The virtual address map has been applied.\r
+ EFI_UNSUPPORTED - EFI firmware is not at runtime, or the EFI firmware is already in\r
+ virtual address mapped mode.\r
+ EFI_INVALID_PARAMETER - DescriptorSize or DescriptorVersion is invalid.\r
+ EFI_NO_MAPPING - A virtual address was not supplied for a range in the memory\r
+ map that requires a mapping.\r
+ EFI_NOT_FOUND - A virtual address was supplied for an address that is not found\r
+ in the memory map.\r
+\r
+--*/\r
+;\r
\r
VOID\r
RuntimeDriverInitializeCrc32Table (\r
VOID\r
- );\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Initialize CRC32 table.\r
+\r
+Arguments:\r
+\r
+ None.\r
+\r
+Returns:\r
+\r
+ None.\r
+\r
+--*/\r
+;\r
\r
EFI_STATUS\r
EFIAPI\r
RuntimeDriverInitialize (\r
IN EFI_HANDLE ImageHandle,\r
IN EFI_SYSTEM_TABLE *SystemTable\r
- );\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Install Runtime AP. This code includes the EfiRuntimeLib, but it only \r
+ functions at RT in physical mode. \r
\r
+Arguments:\r
+ \r
+ ImageHandle - Image handle of this driver.\r
+ SystemTable - Pointer to the EFI System Table.\r
\r
+Returns:\r
+\r
+ EFI_SUCEESS - Runtime Driver Architectural Protocol installed.\r
+\r
+--*/\r
+;\r
\r
#endif\r
<Protocol Usage="ALWAYS_CONSUMED">\r
<ProtocolCName>gEfiLoadedImageProtocolGuid</ProtocolCName>\r
</Protocol>\r
- <Protocol Usage="ALWAYS_CONSUMED">\r
+ <Protocol Usage="SOMETIMES_CONSUMED">\r
+ <ProtocolCName>gEfiUgaIoProtocolGuid</ProtocolCName>\r
+ </Protocol> \r
+ <Protocol Usage="ALWAYS_PRODUCED">\r
<ProtocolCName>gEfiRuntimeArchProtocolGuid</ProtocolCName>\r
</Protocol>\r
</Protocols>\r
+ <Guids>\r
+ <GuidCNames Usage="SOMETIMES_CONSUMED">\r
+ <GuidCName>gEfiCapsuleGuid</GuidCName>\r
+ </GuidCNames>\r
+ </Guids>\r
<Externs>\r
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
\r
typedef UINT64 PHYSICAL_ADDRESS;\r
\r
+//\r
+// LIST_ENTRY definition\r
+//\r
+typedef struct _LIST_ENTRY LIST_ENTRY;\r
+\r
+struct _LIST_ENTRY {\r
+ LIST_ENTRY *ForwardLink;\r
+ LIST_ENTRY *BackLink;\r
+};\r
+\r
#endif\r
Module Name: Runtime.h\r
\r
@par Revision Reference:\r
- Version 0.90.\r
+ Version 0.91.\r
\r
**/\r
\r
// Global ID for the Runtime Architectural Protocol\r
//\r
#define EFI_RUNTIME_ARCH_PROTOCOL_GUID \\r
- { 0x96d08253, 0x8483, 0x11d4, {0xbc, 0xf1, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }\r
+ { 0xb7dfb4e1, 0x52f, 0x449f, {0x87, 0xbe, 0x98, 0x18, 0xfc, 0x91, 0xb7, 0x33 } }\r
\r
-typedef struct _EFI_RUNTIME_ARCH_PROTOCOL EFI_RUNTIME_ARCH_PROTOCOL;\r
+typedef struct _EFI_RUNTIME_ARCH_PROTOCOL EFI_RUNTIME_ARCH_PROTOCOL;\r
\r
-/**\r
- When a SetVirtualAddressMap() is performed all the runtime images loaded by \r
- DXE must be fixed up with the new virtual address map. To facilitate this the \r
- Runtime Architectural Protocol needs to be informed of every runtime driver \r
- that is registered. All the runtime images loaded by DXE should be registered \r
- with this service by the DXE Core when ExitBootServices() is called. The \r
- images that are registered with this service must have successfully been \r
- loaded into memory with the Boot Service LoadImage(). As a result, no \r
- parameter checking needs to be performed.\r
-\r
- @param This The EFI_RUNTIME_ARCH_PROTOCOL instance.\r
- @param ImageBase Start of image that has been loaded in memory. It is either\r
- a pointer to the DOS or PE header of the image.\r
- @param ImageSize Size of the image in bytes.\r
- @param RelocationData Information about the fixups that were performed on ImageBase\r
- when it was loaded into memory. This information is needed\r
- when the virtual mode fix-ups are reapplied so that data that\r
- has been programmatically updated will not be fixed up. If\r
- code updates a global variable the code is responsible for\r
- fixing up the variable for virtual mode.\r
-\r
- @retval EFI_SUCCESS The ImageBase has been registered.\r
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to register ImageBase.\r
+//\r
+// LIST_ENTRY from BaseType \r
+//\r
+typedef LIST_ENTRY EFI_LIST_ENTRY;\r
\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_RUNTIME_REGISTER_IMAGE) (\r
- IN EFI_RUNTIME_ARCH_PROTOCOL *This,\r
- IN EFI_PHYSICAL_ADDRESS ImageBase, \r
- IN UINTN ImageSize, \r
- IN VOID *RelocationData \r
- );\r
+typedef struct _EFI_RUNTIME_IMAGE_ENTRY EFI_RUNTIME_IMAGE_ENTRY;\r
\r
+struct _EFI_RUNTIME_IMAGE_ENTRY {\r
+ VOID *ImageBase;\r
+ UINT64 ImageSize;\r
+ VOID *RelocationData;\r
+ EFI_HANDLE Handle;\r
+ EFI_LIST_ENTRY Link;\r
+};\r
\r
-/**\r
- This function is used to support the required runtime events. Currently only \r
- runtime events of type EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE needs to be \r
- registered with this service. All the runtime events that exist in the DXE \r
- Core should be registered with this service when ExitBootServices() is called. \r
- All the events that are registered with this service must have been created \r
- with the Boot Service CreateEvent(). As a result, no parameter checking needs \r
- to be performed.\r
-\r
- @param This The EFI_RUNTIME_ARCH_PROTOCOL instance.\r
- @param Type The same as Type passed into CreateEvent().\r
- @param NotifyTpl The same as NotifyTpl passed into CreateEvent().\r
- @param NotifyFunction The same as NotifyFunction passed into CreateEvent().\r
- @param NotifyContext The same as NotifyContext passed into CreateEvent().\r
- @param Event The EFI_EVENT returned by CreateEvent(). Event must be in\r
- runtime memory.\r
-\r
- @retval EFI_SUCCESS The Event has been registered.\r
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to register Event.\r
+typedef struct _EFI_RUNTIME_EVENT_ENTRY EFI_RUNTIME_EVENT_ENTRY;\r
\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *EFI_RUNTIME_REGISTER_EVENT) (\r
- IN EFI_RUNTIME_ARCH_PROTOCOL *This,\r
- IN UINT32 Type,\r
- IN EFI_TPL NotifyTpl,\r
- IN EFI_EVENT_NOTIFY NotifyFunction,\r
- IN VOID *NotifyContext,\r
- IN EFI_EVENT *Event\r
- );\r
+struct _EFI_RUNTIME_EVENT_ENTRY {\r
+ UINT32 Type;\r
+ EFI_TPL NotifyTpl;\r
+ EFI_EVENT_NOTIFY NotifyFunction;\r
+ VOID *NotifyContext;\r
+ EFI_EVENT *Event;\r
+ EFI_LIST_ENTRY Link;\r
+};\r
\r
//\r
// Interface stucture for the Runtime Architectural Protocol\r
//\r
/**\r
@par Protocol Description:\r
- The DXE driver that produces this protocol must be a runtime driver. This \r
- driver is responsible for initializing the SetVirtualAddressMap() and \r
- ConvertPointer() fields of the EFI Runtime Services Table and the \r
- CalculateCrc32() field of the EFI Boot Services Table. See the Runtime \r
- Services chapter and the Boot Services chapter for details on these services.\r
- After the two fields of the EFI Runtime Services Table and the one field of \r
- the EFI Boot Services Table have been initialized, the driver must install \r
- the EFI_RUNTIME_ARCH_PROTOCOL_GUID on a new handle with an EFI_RUNTIME_ARCH_ \r
- PROTOCOL interface pointer. The installation of this protocol informs the \r
- DXE core that the virtual memory services and the 32-bit CRC services are \r
- now available, and the DXE core must update the 32-bit CRC of the EFI Runtime \r
- Services Table and the 32-bit CRC of the EFI Boot Services Table.\r
-\r
- All runtime core services are provided by the EFI_RUNTIME_ARCH_PROTOCOL. \r
- This includes the support for registering runtime images that must be \r
- re-fixed up when a transition is made from physical mode to virtual mode. \r
- This protocol also supports all events that are defined to fire at runtime. \r
- This protocol also contains a CRC-32 function that will be used by the DXE \r
- core as a boot service. The EFI_RUNTIME_ARCH_PROTOCOL needs the CRC-32 \r
- function when a transition is made from physical mode to virtual mode and \r
- the EFI System Table and EFI Runtime Table are fixed up with virtual pointers.\r
-\r
- @param RegisterRuntimeImage\r
- Register a runtime image so it can be converted to virtual mode if the EFI Runtime Services \r
- SetVirtualAddressMap() is called.\r
-\r
- @param RegisterRuntimeEvent\r
- Register an event than needs to be notified at runtime. \r
+ Allows the runtime functionality of the DXE Foundation to be contained in a \r
+ separate driver. It also provides hooks for the DXE Foundation to export \r
+ information that is needed at runtime. As such, this protocol allows the DXE \r
+ Foundation to manage runtime drivers and events. This protocol also implies \r
+ that the runtime services required to transition to virtual mode, \r
+ SetVirtualAddressMap() and ConvertPointer(), have been registered into the \r
+ EFI Runtime Table in the EFI System Partition. This protocol must be produced \r
+ by a runtime DXE driver and may only be consumed by the DXE Foundation.\r
+\r
+ @param ImageHead\r
+ A list of type EFI_RUNTIME_IMAGE_ENTRY.\r
+\r
+ @param EventHead\r
+ A list of type EFI_RUNTIME_EVENT_ENTRY.\r
+\r
+ @param MemoryDescriptorSize\r
+ Size of a memory descriptor that is return by GetMemoryMap().\r
+\r
+ @param MemoryDescriptorVersion\r
+ Version of a memory descriptor that is return by GetMemoryMap().\r
+\r
+ @param MemoryMapSize \r
+ Size of the memory map in bytes contained in MemoryMapPhysical and MemoryMapVirtual. \r
+\r
+ @param MemoryMapPhysical\r
+ Pointer to a runtime buffer that contains a copy of \r
+ the memory map returned via GetMemoryMap().\r
+\r
+ @param MemoryMapVirtual\r
+ Pointer to MemoryMapPhysical that is updated to virtual mode after SetVirtualAddressMap().\r
+\r
+ @param VirtualMode\r
+ Boolean that is TRUE if SetVirtualAddressMap() has been called.\r
+\r
+ @param AtRuntime\r
+ Boolean that is TRUE if ExitBootServices () has been called.\r
\r
**/\r
struct _EFI_RUNTIME_ARCH_PROTOCOL {\r
- EFI_RUNTIME_REGISTER_IMAGE RegisterImage;\r
- EFI_RUNTIME_REGISTER_EVENT RegisterEvent;\r
+ EFI_LIST_ENTRY ImageHead;\r
+ EFI_LIST_ENTRY EventHead;\r
+ UINTN MemoryDescriptorSize;\r
+ UINT32 MemoryDesciptorVersion;\r
+ UINTN MemoryMapSize;\r
+ EFI_MEMORY_DESCRIPTOR *MemoryMapPhysical;\r
+ EFI_MEMORY_DESCRIPTOR *MemoryMapVirtual;\r
+ BOOLEAN VirtualMode;\r
+ BOOLEAN AtRuntime;\r
};\r
\r
extern EFI_GUID gEfiRuntimeArchProtocolGuid;\r
// DXE Services Table\r
//\r
#define EFI_DXE_SERVICES_SIGNATURE 0x565245535f455844ULL\r
-#define EFI_DXE_SERVICES_REVISION ((0 << 16) | (25))\r
+#define EFI_DXE_SERVICES_REVISION ((0 << 16) | (90))\r
\r
typedef struct {\r
EFI_TABLE_HEADER Hdr;\r
IN UINT8 Value\r
);\r
\r
-//\r
-// LIST_ENTRY definition\r
-//\r
-typedef struct _LIST_ENTRY LIST_ENTRY;\r
-\r
-struct _LIST_ENTRY {\r
- LIST_ENTRY *ForwardLink;\r
- LIST_ENTRY *BackLink;\r
-};\r
-\r
//\r
// Linked List Functions and Macros\r
//\r
</Entry>\r
<Entry Name="Runtime">\r
<C_Name>gEfiRuntimeArchProtocolGuid</C_Name>\r
- <GuidValue>96D08253-8483-11D4-BCF1-0080C73C8881</GuidValue>\r
+ <GuidValue>b7dfb4e1-052f-449f-87be-9818fc91b733</GuidValue>\r
<HelpText/>\r
</Entry>\r
<Entry Name="Security">\r