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