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