]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.c
Code Scrub for Status Code Runtime Dxe driver.
[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
a8cbf345 16 Copyright (c) 2006 - 2009, Intel Corporation \r
ad1a1798 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
ad1a1798 25**/\r
26\r
ad1a1798 27#include "DxeStatusCode.h"\r
28\r
29/**\r
ad1a1798 30 Dispatch initialization request to sub status code devices based on \r
31 customized feature flags.\r
32 \r
33**/\r
34VOID\r
35InitializationDispatcherWorker (\r
36 VOID\r
37 )\r
38{\r
39 EFI_PEI_HOB_POINTERS Hob;\r
40 EFI_STATUS Status;\r
41 MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
42 MEMORY_STATUSCODE_RECORD *Record;\r
a8cbf345 43 UINTN ExpectedPacketIndex;\r
ad1a1798 44 UINTN Index;\r
45 VOID *HobStart;\r
46\r
47 //\r
48 // If enable UseSerial, then initialize serial port.\r
49 // if enable UseRuntimeMemory, then initialize runtime memory status code worker.\r
50 // if enable UseDataHub, then initialize data hub status code worker.\r
51 //\r
52 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {\r
53 Status = EfiSerialStatusCodeInitializeWorker ();\r
54 ASSERT_EFI_ERROR (Status);\r
55 }\r
56 if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {\r
a8cbf345 57 //\r
58 // Call Serial Port Lib API to initialize serial port.\r
59 //\r
ad1a1798 60 Status = SerialPortInitialize ();\r
61 ASSERT_EFI_ERROR (Status);\r
62 }\r
63 if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
64 Status = RtMemoryStatusCodeInitializeWorker ();\r
65 ASSERT_EFI_ERROR (Status);\r
66 }\r
67 if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
68 Status = DataHubStatusCodeInitializeWorker ();\r
69 ASSERT_EFI_ERROR (Status);\r
70 }\r
71 if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
a8cbf345 72 //\r
73 // Call OEM hook status code library API to initialize OEM device for status code.\r
74 //\r
ad1a1798 75 Status = OemHookStatusCodeInitialize ();\r
76 ASSERT_EFI_ERROR (Status);\r
77 }\r
78\r
79 //\r
a8cbf345 80 // Replay Status code which saved in GUID'ed HOB to all supported devices. \r
ad1a1798 81 //\r
82\r
83 // \r
84 // Journal GUID'ed HOBs to find all record entry, if found, \r
85 // then output record to support replay device.\r
86 //\r
a8cbf345 87 ExpectedPacketIndex = 0;\r
ad1a1798 88 Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
89 HobStart = Hob.Raw;\r
90 while (Hob.Raw != NULL) {\r
91 PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
92 if (PacketHeader->PacketIndex == ExpectedPacketIndex) {\r
93 Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
94 for (Index = 0; Index < PacketHeader->RecordIndex; Index++) {\r
95 //\r
96 // Dispatch records to devices based on feature flag.\r
97 //\r
98 if (FeaturePcdGet (PcdStatusCodeReplayInSerial) && \r
99 (FeaturePcdGet (PcdStatusCodeUseHardSerial) ||\r
100 FeaturePcdGet (PcdStatusCodeUseEfiSerial))) {\r
101 SerialStatusCodeReportWorker (\r
102 Record[Index].CodeType,\r
103 Record[Index].Value,\r
104 Record[Index].Instance,\r
105 NULL,\r
106 NULL\r
107 );\r
108 }\r
109 if (FeaturePcdGet (PcdStatusCodeReplayInRuntimeMemory) &&\r
110 FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {\r
111 RtMemoryStatusCodeReportWorker (\r
ad1a1798 112 Record[Index].CodeType,\r
113 Record[Index].Value,\r
114 Record[Index].Instance\r
115 );\r
116 }\r
117 if (FeaturePcdGet (PcdStatusCodeReplayInDataHub) &&\r
118 FeaturePcdGet (PcdStatusCodeUseDataHub)) {\r
119 DataHubStatusCodeReportWorker (\r
120 Record[Index].CodeType,\r
121 Record[Index].Value,\r
122 Record[Index].Instance,\r
123 NULL,\r
124 NULL\r
125 );\r
126 }\r
127 if (FeaturePcdGet (PcdStatusCodeReplayInOEM) &&\r
128 FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
a8cbf345 129 //\r
130 // Call OEM hook status code library API to report status code to OEM device\r
131 //\r
ad1a1798 132 OemHookStatusCodeReport (\r
133 Record[Index].CodeType,\r
134 Record[Index].Value,\r
135 Record[Index].Instance,\r
136 NULL,\r
137 NULL\r
138 );\r
139 }\r
140 }\r
141 ExpectedPacketIndex++;\r
142\r
143 //\r
144 // See whether there is gap of packet or not\r
145 //\r
a8cbf345 146 if (HobStart != NULL) {\r
ad1a1798 147 HobStart = NULL;\r
148 Hob.Raw = HobStart;\r
149 continue;\r
150 }\r
151 } else if (HobStart != NULL) {\r
152 //\r
153 // Cache the found packet for improve the performance\r
154 //\r
155 HobStart = Hob.Raw;\r
156 }\r
157\r
158 Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
159 }\r
160}\r
161\r