--- /dev/null
+/** @file\r
+ Status Code Architectural Protocol implementation as defined in Tiano\r
+ Architecture Specification.\r
+\r
+ This driver has limited functionality at runtime and will not log to Data Hub\r
+ at runtime.\r
+\r
+ Notes:\r
+ This driver assumes the following ReportStatusCode strategy:\r
+ PEI -> uses PeiReportStatusCode\r
+ DXE IPL -> uses PeiReportStatusCode\r
+ early DXE -> uses PeiReportStatusCode via HOB\r
+ DXE -> This driver\r
+ RT -> This driver\r
+\r
+// Copyright (c) 2006, Intel Corporation. All rights reserved. \r
+// This software and associated documentation (if any) is furnished\r
+// under a license and may only be used or copied in accordance\r
+// with the terms of the license. Except as permitted by such\r
+// license, no part of this software or documentation may be\r
+// reproduced, stored in a retrieval system, or transmitted in any\r
+// form or by any means without the express written consent of\r
+// Intel Corporation.\r
+\r
+ Module Name: StatusCode.c\r
+\r
+**/\r
+\r
+#include "DxeStatusCode.h"\r
+\r
+/**\r
+ \r
+ Dispatch initialization request to sub status code devices based on \r
+ customized feature flags.\r
+ \r
+**/\r
+VOID\r
+InitializationDispatcherWorker (\r
+ VOID\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+ MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
+ MEMORY_STATUSCODE_RECORD *Record;\r
+ UINTN ExpectedPacketIndex = 0;\r
+ UINTN Index;\r
+ VOID *HobStart;\r
+\r
+ //\r
+ // If enable UseSerial, then initialize serial port.\r
+ // if enable UseRuntimeMemory, then initialize runtime memory status code worker.\r
+ // if enable UseDataHub, then initialize data hub status code worker.\r
+ //\r
+ if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
+ EfiSerialStatusCodeInitializeWorker ();\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
+ SerialPortInitialize ();\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
+ RtMemoryStatusCodeInitializeWorker ();\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
+ DataHubStatusCodeInitializeWorker ();\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
+ OemHookStatusCodeInitialize ();\r
+ }\r
+\r
+ //\r
+ // Replay Status code which saved in GUID'ed HOB to all supported device. \r
+ //\r
+\r
+ // \r
+ // Journal GUID'ed HOBs to find all record entry, if found, \r
+ // then output record to support replay device.\r
+ //\r
+ Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
+ HobStart = Hob.Raw;\r
+ while (Hob.Raw != NULL) {\r
+ PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
+ if (PacketHeader->PacketIndex == ExpectedPacketIndex) {\r
+ Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
+ for (Index = 0; Index < PacketHeader->RecordIndex; Index++) {\r
+ //\r
+ // Dispatch records to devices based on feature flag.\r
+ //\r
+ if (FeaturePcdGet (PcdStatusCodeReplayInSerial) && \r
+ (FeaturePcdGet (PcdStatusCodeUseHardSerial) ||\r
+ FeaturePcdGet (PcdStatusCodeUseEfiSerial))) {\r
+ SerialStatusCodeReportWorker (\r
+ Record[Index].CodeType,\r
+ Record[Index].Value,\r
+ Record[Index].Instance,\r
+ NULL,\r
+ NULL\r
+ );\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeReplayInRuntimeMemory) &&\r
+ FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
+ RtMemoryStatusCodeReportWorker (\r
+ gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE],\r
+ Record[Index].CodeType,\r
+ Record[Index].Value,\r
+ Record[Index].Instance\r
+ );\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeReplayInDataHub) &&\r
+ FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
+ DataHubStatusCodeReportWorker (\r
+ Record[Index].CodeType,\r
+ Record[Index].Value,\r
+ Record[Index].Instance,\r
+ NULL,\r
+ NULL\r
+ );\r
+ }\r
+ if (FeaturePcdGet (PcdStatusCodeReplayInOEM) &&\r
+ FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
+ OemHookStatusCodeReport (\r
+ Record[Index].CodeType,\r
+ Record[Index].Value,\r
+ Record[Index].Instance,\r
+ NULL,\r
+ NULL\r
+ );\r
+ }\r
+ }\r
+ ExpectedPacketIndex++;\r
+\r
+ //\r
+ // See whether there is gap of packet or not\r
+ //\r
+ if (HobStart) {\r
+ HobStart = NULL;\r
+ Hob.Raw = HobStart;\r
+ continue;\r
+ }\r
+ } else if (HobStart != NULL) {\r
+ //\r
+ // Cache the found packet for improve the performance\r
+ //\r
+ HobStart = Hob.Raw;\r
+ }\r
+\r
+ Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
+ }\r
+}\r
+\r