Rename Protocol/FormCallback.h to Protocol/FormCallbackFramework.h to follow the...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / StatusCode / Dxe / DxeStatusCode.c
CommitLineData
ad1a1798 1/** @file\r
2 Status Code Architectural Protocol implementation as defined in Tiano\r
3 Architecture Specification.\r
4\r
5 This driver has limited functionality at runtime and will not log to Data Hub\r
6 at runtime.\r
7\r
8 Notes:\r
9 This driver assumes the following ReportStatusCode strategy:\r
10 PEI -> uses PeiReportStatusCode\r
11 DXE IPL -> uses PeiReportStatusCode\r
12 early DXE -> uses PeiReportStatusCode via HOB\r
13 DXE -> This driver\r
14 RT -> This driver\r
15\r
16 Copyright (c) 2006, Intel Corporation \r
17 All rights reserved. This program and the accompanying materials \r
18 are licensed and made available under the terms and conditions of the BSD License \r
19 which accompanies this distribution. The full text of the license may be found at \r
20 http://opensource.org/licenses/bsd-license.php \r
21 \r
22 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
23 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
24\r
25 Module Name: DxeStatusCode.c\r
26\r
27**/\r
28\r
29//\r
30// Include common header file for this module.\r
31//\r
32#include "CommonHeader.h"\r
33\r
34#include "DxeStatusCode.h"\r
35\r
36/**\r
37 \r
38 Dispatch initialization request to sub status code devices based on \r
39 customized feature flags.\r
40 \r
41**/\r
42VOID\r
43InitializationDispatcherWorker (\r
44 VOID\r
45 )\r
46{\r
47 EFI_PEI_HOB_POINTERS Hob;\r
48 EFI_STATUS Status;\r
49 MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
50 MEMORY_STATUSCODE_RECORD *Record;\r
51 UINTN ExpectedPacketIndex = 0;\r
52 UINTN Index;\r
53 VOID *HobStart;\r
54\r
55 //\r
56 // If enable UseSerial, then initialize serial port.\r
57 // if enable UseRuntimeMemory, then initialize runtime memory status code worker.\r
58 // if enable UseDataHub, then initialize data hub status code worker.\r
59 //\r
60 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
61 Status = EfiSerialStatusCodeInitializeWorker ();\r
62 ASSERT_EFI_ERROR (Status);\r
63 }\r
64 if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
65 Status = SerialPortInitialize ();\r
66 ASSERT_EFI_ERROR (Status);\r
67 }\r
68 if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
69 Status = RtMemoryStatusCodeInitializeWorker ();\r
70 ASSERT_EFI_ERROR (Status);\r
71 }\r
72 if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
73 Status = DataHubStatusCodeInitializeWorker ();\r
74 ASSERT_EFI_ERROR (Status);\r
75 }\r
76 if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
77 Status = OemHookStatusCodeInitialize ();\r
78 ASSERT_EFI_ERROR (Status);\r
79 }\r
80\r
81 //\r
82 // Replay Status code which saved in GUID'ed HOB to all supported device. \r
83 //\r
84\r
85 // \r
86 // Journal GUID'ed HOBs to find all record entry, if found, \r
87 // then output record to support replay device.\r
88 //\r
89 Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
90 HobStart = Hob.Raw;\r
91 while (Hob.Raw != NULL) {\r
92 PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
93 if (PacketHeader->PacketIndex == ExpectedPacketIndex) {\r
94 Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
95 for (Index = 0; Index < PacketHeader->RecordIndex; Index++) {\r
96 //\r
97 // Dispatch records to devices based on feature flag.\r
98 //\r
99 if (FeaturePcdGet (PcdStatusCodeReplayInSerial) && \r
100 (FeaturePcdGet (PcdStatusCodeUseHardSerial) ||\r
101 FeaturePcdGet (PcdStatusCodeUseEfiSerial))) {\r
102 SerialStatusCodeReportWorker (\r
103 Record[Index].CodeType,\r
104 Record[Index].Value,\r
105 Record[Index].Instance,\r
106 NULL,\r
107 NULL\r
108 );\r
109 }\r
110 if (FeaturePcdGet (PcdStatusCodeReplayInRuntimeMemory) &&\r
111 FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
112 RtMemoryStatusCodeReportWorker (\r
113 gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE],\r
114 Record[Index].CodeType,\r
115 Record[Index].Value,\r
116 Record[Index].Instance\r
117 );\r
118 }\r
119 if (FeaturePcdGet (PcdStatusCodeReplayInDataHub) &&\r
120 FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
121 DataHubStatusCodeReportWorker (\r
122 Record[Index].CodeType,\r
123 Record[Index].Value,\r
124 Record[Index].Instance,\r
125 NULL,\r
126 NULL\r
127 );\r
128 }\r
129 if (FeaturePcdGet (PcdStatusCodeReplayInOEM) &&\r
130 FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
131 OemHookStatusCodeReport (\r
132 Record[Index].CodeType,\r
133 Record[Index].Value,\r
134 Record[Index].Instance,\r
135 NULL,\r
136 NULL\r
137 );\r
138 }\r
139 }\r
140 ExpectedPacketIndex++;\r
141\r
142 //\r
143 // See whether there is gap of packet or not\r
144 //\r
145 if (NULL != HobStart) {\r
146 HobStart = NULL;\r
147 Hob.Raw = HobStart;\r
148 continue;\r
149 }\r
150 } else if (HobStart != NULL) {\r
151 //\r
152 // Cache the found packet for improve the performance\r
153 //\r
154 HobStart = Hob.Raw;\r
155 }\r
156\r
157 Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
158 }\r
159}\r
160\r