+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006 - 2007, 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
- DxeProtocolNotify.c\r
-\r
-Abstract:\r
-\r
- This file deals with Architecture Protocol (AP) registration in\r
- the Dxe Core. The mArchProtocols[] array represents a list of\r
- events that represent the Architectural Protocols.\r
-\r
---*/\r
-\r
-#include <DxeMain.h>\r
-\r
-\r
-//\r
-// DXE Core Global Variables for all of the Architectural Protocols.\r
-// If a protocol is installed mArchProtocols[].Present will be TRUE.\r
-//\r
-// CoreNotifyOnArchProtocolInstallation () fills in mArchProtocols[].Event\r
-// and mArchProtocols[].Registration as it creates events for every array\r
-// entry.\r
-//\r
-\r
-ARCHITECTURAL_PROTOCOL_ENTRY mArchProtocols[] = {\r
- { &gEfiSecurityArchProtocolGuid, (VOID **)&gSecurity, NULL, NULL, FALSE },\r
- { &gEfiCpuArchProtocolGuid, (VOID **)&gCpu, NULL, NULL, FALSE },\r
- { &gEfiMetronomeArchProtocolGuid, (VOID **)&gMetronome, NULL, NULL, FALSE },\r
- { &gEfiTimerArchProtocolGuid, (VOID **)&gTimer, NULL, NULL, FALSE },\r
- { &gEfiBdsArchProtocolGuid, (VOID **)&gBds, NULL, NULL, FALSE },\r
- { &gEfiWatchdogTimerArchProtocolGuid, (VOID **)&gWatchdogTimer, NULL, NULL, FALSE },\r
- { &gEfiRuntimeArchProtocolGuid, (VOID **)&gRuntime, NULL, NULL, FALSE },\r
- { &gEfiVariableArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },\r
- { &gEfiVariableWriteArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },\r
- { &gEfiCapsuleArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE},\r
- { &gEfiMonotonicCounterArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },\r
- { &gEfiResetArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },\r
- { &gEfiRealTimeClockArchProtocolGuid, (VOID **)NULL, NULL, NULL, FALSE },\r
- { NULL, (VOID **)NULL, NULL, NULL, FALSE }\r
-};\r
-\r
-\r
-EFI_STATUS\r
-CoreAllEfiServicesAvailable (\r
- VOID\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- Return TRUE if all AP services are availible.\r
-\r
-Arguments:\r
- NONE\r
-\r
-Returns:\r
- EFI_SUCCESS - All AP services are available\r
- EFI_NOT_FOUND - At least one AP service is not available\r
-\r
---*/\r
-{\r
- ARCHITECTURAL_PROTOCOL_ENTRY *Entry;\r
-\r
- for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {\r
- if (!Entry->Present) {\r
- return EFI_NOT_FOUND;\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-STATIC\r
-VOID\r
-EFIAPI\r
-GenericArchProtocolNotify (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- Notification event handler registered by CoreNotifyOnArchProtocolInstallation ().\r
- This notify function is registered for every architectural protocol. This handler\r
- updates mArchProtocol[] array entry with protocol instance data and sets it's\r
- present flag to TRUE. If any constructor is required it is executed. The EFI\r
- System Table headers are updated.\r
-\r
-Arguments:\r
-\r
- Event - The Event that is being processed, not used.\r
-\r
- Context - Event Context, not used.\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\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
-\r
- Status = CoreLocateProtocol (Entry->ProtocolGuid, Entry->Registration, &Protocol);\r
- if (EFI_ERROR (Status)) {\r
- continue;\r
- }\r
-\r
- Found = TRUE;\r
- Entry->Present = TRUE;\r
-\r
- //\r
- // Update protocol global variable if one exists. Entry->Protocol points to a global variable\r
- // if one exists in the DXE core for this Architectural Protocol\r
- //\r
- if (Entry->Protocol != NULL) {\r
- *(Entry->Protocol) = Protocol;\r
- }\r
-\r
- if (CompareGuid (Entry->ProtocolGuid, &gEfiTimerArchProtocolGuid)) {\r
- //\r
- // Register the Core timer tick handler with the Timer AP\r
- //\r
- gTimer->RegisterHandler (gTimer, CoreTimerTick);\r
- }\r
-\r
- if (CompareGuid (Entry->ProtocolGuid, &gEfiRuntimeArchProtocolGuid)) {\r
- //\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
- // It's over kill to do them all every time, but it saves a lot of code.\r
- //\r
- if (Found) {\r
- CalculateEfiHdrCrc (&gDxeCoreRT->Hdr);\r
- CalculateEfiHdrCrc (&gDxeCoreBS->Hdr);\r
- CalculateEfiHdrCrc (&gDxeCoreST->Hdr);\r
- CalculateEfiHdrCrc (&gDxeCoreDS->Hdr);\r
- }\r
-}\r
-\r
-\r
-\r
-VOID\r
-CoreNotifyOnArchProtocolInstallation (\r
- VOID\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- Creates an event that is fired everytime a Protocol of a specific type is installed\r
-\r
-Arguments:\r
- NONE\r
-\r
-Returns:\r
- NONE\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- ARCHITECTURAL_PROTOCOL_ENTRY *Entry;\r
-\r
- for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {\r
-\r
- //\r
- // Create the event\r
- //\r
- Status = CoreCreateEvent (\r
- EVT_NOTIFY_SIGNAL,\r
- TPL_CALLBACK,\r
- GenericArchProtocolNotify,\r
- NULL,\r
- &Entry->Event\r
- );\r
- ASSERT_EFI_ERROR(Status);\r
-\r
- //\r
- // Register for protocol notifactions on this event\r
- //\r
- Status = CoreRegisterProtocolNotify (\r
- Entry->ProtocolGuid,\r
- Entry->Event,\r
- &Entry->Registration\r
- );\r
- ASSERT_EFI_ERROR(Status);\r
-\r
- }\r
-}\r
-\r
-//\r
-// Following is needed to display missing architectural protocols in debug builds\r
-//\r
-typedef struct {\r
- EFI_GUID *ProtocolGuid;\r
- CHAR16 *GuidString;\r
-} GUID_TO_STRING_PROTOCOL_ENTRY;\r
-\r
-static const GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols[] = {\r
- { &gEfiSecurityArchProtocolGuid, (CHAR16 *)L"Security" },\r
- { &gEfiCpuArchProtocolGuid, (CHAR16 *)L"CPU" },\r
- { &gEfiMetronomeArchProtocolGuid, (CHAR16 *)L"Metronome" },\r
- { &gEfiTimerArchProtocolGuid, (CHAR16 *)L"Timer" },\r
- { &gEfiBdsArchProtocolGuid, (CHAR16 *)L"Bds" },\r
- { &gEfiWatchdogTimerArchProtocolGuid, (CHAR16 *)L"Watchdog Timer" },\r
- { &gEfiRuntimeArchProtocolGuid, (CHAR16 *)L"Runtime" },\r
- { &gEfiVariableArchProtocolGuid, (CHAR16 *)L"Variable" },\r
- { &gEfiVariableWriteArchProtocolGuid, (CHAR16 *)L"Variable Write" },\r
- { &gEfiCapsuleArchProtocolGuid, (CHAR16 *)L"Capsule" },\r
- { &gEfiMonotonicCounterArchProtocolGuid, (CHAR16 *)L"Monotonic Counter" },\r
- { &gEfiResetArchProtocolGuid, (CHAR16 *)L"Reset" },\r
-// { &gEfiStatusCodeRuntimeProtocolGuid, (CHAR16 *)L"Status Code" },\r
- { &gEfiRealTimeClockArchProtocolGuid, (CHAR16 *)L"Real Time Clock" }\r
-};\r
-\r
-VOID\r
-CoreDisplayMissingArchProtocols (\r
- VOID\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- Displays Architectural protocols that were not loaded and are required for DXE core to function\r
- Only used in Debug Builds\r
-\r
-Arguments:\r
- NONE\r
-\r
-Returns:\r
- NONE\r
-\r
---*/\r
-{\r
- const GUID_TO_STRING_PROTOCOL_ENTRY *MissingEntry;\r
- ARCHITECTURAL_PROTOCOL_ENTRY *Entry;\r
-\r
- for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {\r
- if (!Entry->Present) {\r
- MissingEntry = MissingProtocols;\r
- for (MissingEntry = MissingProtocols; TRUE ; MissingEntry++) {\r
- if (CompareGuid (Entry->ProtocolGuid, MissingEntry->ProtocolGuid)) {\r
- DEBUG ((EFI_D_ERROR, "\n%s Arch Protocol not present!!\n", MissingEntry->GuidString));\r
- break;\r
- }\r
- }\r
- }\r
- }\r
-}\r