1) Fix build issues

2) Change ARCHITECTURAL_PROTOCOL_ENTRY name to EFI_CORE_PROTOCOL_NOTIFY_ENTRY so it can be used for both Architectural Protocols and optional protocols that the DXE Core may use.  Also remove BOOLEAN ArchitecturalProtocol field, so it is back to its original form.
3) Put mArchProtocols[] back to its original form, but add a NULL entry at the end so the end of the table can be easily detected in loops
4) Add mOptionalProtocols[] that at this time only has the SMM Base 2 Protocol in it.
5) Add NULL entry to mMissingProtocols[] so the end of the table can be easily detected.
6) Update all loops on mArchProtocols[], mOptionalProtocols, and mMissingProtocols[] to remove Index(s) and simply looks for a NULL ProtocolGuid to find the end of the table.
7) Update protocol notify events to pass the associated EFI_CORE_PROTOCOL_NOTIFY_ENTRY * as the Context parameter.   This simplifies GenericProtocolNotify() by completely eliminating the search loop.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10016 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
mdkinney 2010-02-16 20:59:57 +00:00
parent 27af6f9d0a
commit 74e44290e2
3 changed files with 130 additions and 113 deletions

View File

@ -117,8 +117,7 @@ typedef struct {
EFI_EVENT Event; EFI_EVENT Event;
VOID *Registration; VOID *Registration;
BOOLEAN Present; BOOLEAN Present;
BOOLEAN ArchitecturalProtocol; } EFI_CORE_PROTOCOL_NOTIFY_ENTRY;
} ARCHITECTURAL_PROTOCOL_ENTRY;
// //
// DXE Dispatcher Data structures // DXE Dispatcher Data structures
@ -348,7 +347,7 @@ CoreInitializeImageServices (
**/ **/
VOID VOID
CoreNotifyOnArchProtocolInstallation ( CoreNotifyOnProtocolInstallation (
VOID VOID
); );

View File

@ -378,8 +378,9 @@ DxeMain (
// //
// Register for the GUIDs of the Architectural Protocols, so the rest of the // Register for the GUIDs of the Architectural Protocols, so the rest of the
// EFI Boot Services and EFI Runtime Services tables can be filled in. // EFI Boot Services and EFI Runtime Services tables can be filled in.
// Also register for the GUIDs of optional protocols.
// //
CoreNotifyOnArchProtocolInstallation (); CoreNotifyOnProtocolInstallation ();
// //
// Produce Firmware Volume Protocols, one for each FV in the HOB list. // Produce Firmware Volume Protocols, one for each FV in the HOB list.

View File

@ -16,7 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "DxeMain.h" #include "DxeMain.h"
// //
// DXE Core Global Variables for all of the Architectural Protocols. // DXE Core Global Variables for all of the Architectural Protocols.
// If a protocol is installed mArchProtocols[].Present will be TRUE. // If a protocol is installed mArchProtocols[].Present will be TRUE.
@ -25,22 +24,29 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// and mArchProtocols[].Registration as it creates events for every array // and mArchProtocols[].Registration as it creates events for every array
// entry. // entry.
// //
EFI_CORE_PROTOCOL_NOTIFY_ENTRY mArchProtocols[] = {
{ &gEfiSecurityArchProtocolGuid, (VOID **)&gSecurity, NULL, NULL, FALSE },
{ &gEfiCpuArchProtocolGuid, (VOID **)&gCpu, NULL, NULL, FALSE },
{ &gEfiMetronomeArchProtocolGuid, (VOID **)&gMetronome, NULL, NULL, FALSE },
{ &gEfiTimerArchProtocolGuid, (VOID **)&gTimer, NULL, NULL, FALSE },
{ &gEfiBdsArchProtocolGuid, (VOID **)&gBds, NULL, NULL, FALSE },
{ &gEfiWatchdogTimerArchProtocolGuid, (VOID **)&gWatchdogTimer, NULL, NULL, FALSE },
{ &gEfiRuntimeArchProtocolGuid, (VOID **)&gRuntime, NULL, NULL, FALSE },
{ &gEfiVariableArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ &gEfiVariableWriteArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ &gEfiCapsuleArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ &gEfiMonotonicCounterArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ &gEfiResetArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ &gEfiRealTimeClockArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },
{ NULL, (VOID **)NULL, NULL, NULL, FALSE }
};
ARCHITECTURAL_PROTOCOL_ENTRY mArchProtocols[] = { //
{ &gEfiSecurityArchProtocolGuid, (VOID **)&gSecurity, NULL, NULL, FALSE, TRUE }, // Optional protocols that the DXE Core will use if they are present
{ &gEfiCpuArchProtocolGuid, (VOID **)&gCpu, NULL, NULL, FALSE, TRUE }, //
{ &gEfiMetronomeArchProtocolGuid, (VOID **)&gMetronome, NULL, NULL, FALSE, TRUE }, EFI_CORE_PROTOCOL_NOTIFY_ENTRY mOptionalProtocols[] = {
{ &gEfiTimerArchProtocolGuid, (VOID **)&gTimer, NULL, NULL, FALSE, TRUE }, { &gEfiSmmBase2ProtocolGuid, (VOID **)&gSmmBase2, NULL, NULL, FALSE },
{ &gEfiBdsArchProtocolGuid, (VOID **)&gBds, NULL, NULL, FALSE, TRUE }, { NULL, (VOID **)NULL, NULL, NULL, FALSE }
{ &gEfiWatchdogTimerArchProtocolGuid, (VOID **)&gWatchdogTimer, NULL, NULL, FALSE, TRUE },
{ &gEfiRuntimeArchProtocolGuid, (VOID **)&gRuntime, NULL, NULL, FALSE, TRUE },
{ &gEfiVariableArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE, TRUE },
{ &gEfiVariableWriteArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE, TRUE },
{ &gEfiCapsuleArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE, TRUE },
{ &gEfiMonotonicCounterArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE, TRUE },
{ &gEfiResetArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE, TRUE },
{ &gEfiRealTimeClockArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE, TRUE },
{ &gEfiSmmBase2ProtocolGuid, (VOID **)&gSmmBase2, NULL, NULL, FALSE, FALSE }
}; };
// //
@ -64,7 +70,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST GUID_TO_STRING_PROTOCOL_ENTRY mMissingProtoc
{ &gEfiCapsuleArchProtocolGuid, "Capsule" }, { &gEfiCapsuleArchProtocolGuid, "Capsule" },
{ &gEfiMonotonicCounterArchProtocolGuid, "Monotonic Counter" }, { &gEfiMonotonicCounterArchProtocolGuid, "Monotonic Counter" },
{ &gEfiResetArchProtocolGuid, "Reset" }, { &gEfiResetArchProtocolGuid, "Reset" },
{ &gEfiRealTimeClockArchProtocolGuid, "Real Time Clock" } { &gEfiRealTimeClockArchProtocolGuid, "Real Time Clock" },
{ NULL, "" }
}; };
/** /**
@ -79,14 +86,13 @@ CoreAllEfiServicesAvailable (
VOID VOID
) )
{ {
UINTN Index; EFI_CORE_PROTOCOL_NOTIFY_ENTRY *Entry;
for (Index = 0; Index < sizeof (mArchProtocols) / sizeof (mArchProtocols[0]); Index++) { for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {
if (mArchProtocols[Index].ArchitecturalProtocol && !mArchProtocols[Index].Present) { if (!Entry->Present) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -104,29 +110,33 @@ CoreAllEfiServicesAvailable (
**/ **/
VOID VOID
EFIAPI EFIAPI
GenericArchProtocolNotify ( GenericProtocolNotify (
IN EFI_EVENT Event, IN EFI_EVENT Event,
IN VOID *Context IN VOID *Context
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
ARCHITECTURAL_PROTOCOL_ENTRY *Entry; EFI_CORE_PROTOCOL_NOTIFY_ENTRY *Entry;
VOID *Protocol; VOID *Protocol;
BOOLEAN Found;
LIST_ENTRY *Link; LIST_ENTRY *Link;
LIST_ENTRY TempLinkNode; LIST_ENTRY TempLinkNode;
UINTN Index;
Found = FALSE; //
for (Index = 0; Index < sizeof (mArchProtocols) / sizeof (mArchProtocols[0]); Index++) { // Get Entry from Context
Entry = &mArchProtocols[Index]; //
Entry = (EFI_CORE_PROTOCOL_NOTIFY_ENTRY *)Context;
//
// See if the expected protocol is present in the handle database
//
Status = CoreLocateProtocol (Entry->ProtocolGuid, Entry->Registration, &Protocol); Status = CoreLocateProtocol (Entry->ProtocolGuid, Entry->Registration, &Protocol);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; return;
} }
Found = TRUE; //
// Mark the protocol as present
//
Entry->Present = TRUE; Entry->Present = TRUE;
// //
@ -137,6 +147,10 @@ GenericArchProtocolNotify (
*(Entry->Protocol) = Protocol; *(Entry->Protocol) = Protocol;
} }
//
// Do special operations for Architectural Protocols
//
if (CompareGuid (Entry->ProtocolGuid, &gEfiTimerArchProtocolGuid)) { if (CompareGuid (Entry->ProtocolGuid, &gEfiTimerArchProtocolGuid)) {
// //
// Register the Core timer tick handler with the Timer AP // Register the Core timer tick handler with the Timer AP
@ -178,45 +192,37 @@ GenericArchProtocolNotify (
gRuntimeTemplate.EventHead.ForwardLink = &gRuntimeTemplate.EventHead; gRuntimeTemplate.EventHead.ForwardLink = &gRuntimeTemplate.EventHead;
gRuntimeTemplate.EventHead.BackLink = &gRuntimeTemplate.EventHead; gRuntimeTemplate.EventHead.BackLink = &gRuntimeTemplate.EventHead;
} }
}
// //
// It's over kill to do them all every time, but it saves a lot of code. // It's over kill to do them all every time, but it saves a lot of code.
// //
if (Found) {
CalculateEfiHdrCrc (&gDxeCoreRT->Hdr); CalculateEfiHdrCrc (&gDxeCoreRT->Hdr);
CalculateEfiHdrCrc (&gBS->Hdr); CalculateEfiHdrCrc (&gBS->Hdr);
CalculateEfiHdrCrc (&gDxeCoreST->Hdr); CalculateEfiHdrCrc (&gDxeCoreST->Hdr);
CalculateEfiHdrCrc (&gDxeCoreDS->Hdr); CalculateEfiHdrCrc (&gDxeCoreDS->Hdr);
} }
}
/** /**
Creates an event that is fired everytime a Protocol of a specific type is installed. Creates an event for each entry in a table that is fired everytime a Protocol
of a specific type is installed.
**/ **/
VOID VOID
CoreNotifyOnArchProtocolInstallation ( CoreNotifyOnProtocolEntryTable (
VOID EFI_CORE_PROTOCOL_NOTIFY_ENTRY *Entry
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
ARCHITECTURAL_PROTOCOL_ENTRY *Entry;
UINTN Index;
for (Index = 0; Index < sizeof (mArchProtocols) / sizeof (mArchProtocols[0]); Index++) {
Entry = &mArchProtocols[Index];
for (; Entry->ProtocolGuid != NULL; Entry++) {
// //
// Create the event // Create the event
// //
Status = CoreCreateEvent ( Status = CoreCreateEvent (
EVT_NOTIFY_SIGNAL, EVT_NOTIFY_SIGNAL,
TPL_CALLBACK, TPL_CALLBACK,
GenericArchProtocolNotify, GenericProtocolNotify,
NULL, Entry,
&Entry->Event &Entry->Event
); );
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
@ -230,10 +236,23 @@ CoreNotifyOnArchProtocolInstallation (
&Entry->Registration &Entry->Registration
); );
ASSERT_EFI_ERROR(Status); ASSERT_EFI_ERROR(Status);
} }
} }
/**
Creates an events for the Architectural Protocols and the optional protocols
that are fired everytime a Protocol of a specific type is installed.
**/
VOID
CoreNotifyOnProtocolInstallation (
VOID
)
{
CoreNotifyOnProtocolEntryTable (mArchProtocols);
CoreNotifyOnProtocolEntryTable (mOptionalProtocols);
}
/** /**
Displays Architectural protocols that were not loaded and are required for DXE Displays Architectural protocols that were not loaded and are required for DXE
@ -245,14 +264,12 @@ CoreDisplayMissingArchProtocols (
VOID VOID
) )
{ {
EFI_CORE_PROTOCOL_NOTIFY_ENTRY *Entry;
CONST GUID_TO_STRING_PROTOCOL_ENTRY *MissingEntry; CONST GUID_TO_STRING_PROTOCOL_ENTRY *MissingEntry;
ARCHITECTURAL_PROTOCOL_ENTRY *Entry;
UINTN Index;
for (Index = 0; Index < sizeof (mArchProtocols) / sizeof (mArchProtocols[0]); Index++) { for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {
Entry = &mArchProtocols[Index]; if (!Entry->Present) {
if (!Entry->Present && Entry->ArchitecturalProtocol) { for (MissingEntry = mMissingProtocols; MissingEntry->ProtocolGuid != NULL; MissingEntry++) {
for (MissingEntry = mMissingProtocols; MissingEntry < sizeof (mMissingProtocols)/sizeof (mMissingProtocols[0]) ; MissingEntry++) {
if (CompareGuid (Entry->ProtocolGuid, MissingEntry->ProtocolGuid)) { if (CompareGuid (Entry->ProtocolGuid, MissingEntry->ProtocolGuid)) {
DEBUG ((DEBUG_ERROR, "\n%a Arch Protocol not present!!\n", MissingEntry->GuidString)); DEBUG ((DEBUG_ERROR, "\n%a Arch Protocol not present!!\n", MissingEntry->GuidString));
break; break;