]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.c
Change license of following files from Intel Copy Right to BSD-license.
[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 MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;
44 MEMORY_STATUSCODE_RECORD *Record;
45 UINTN ExpectedPacketIndex = 0;
46 UINTN Index;
47 VOID *HobStart;
48
49 //
50 // If enable UseSerial, then initialize serial port.
51 // if enable UseRuntimeMemory, then initialize runtime memory status code worker.
52 // if enable UseDataHub, then initialize data hub status code worker.
53 //
54 if (FeaturePcdGet (PcdStatusCodeUseEfiSerial)) {
55 EfiSerialStatusCodeInitializeWorker ();
56 }
57 if (FeaturePcdGet (PcdStatusCodeUseHardSerial)) {
58 SerialPortInitialize ();
59 }
60 if (FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {
61 RtMemoryStatusCodeInitializeWorker ();
62 }
63 if (FeaturePcdGet (PcdStatusCodeUseDataHub)) {
64 DataHubStatusCodeInitializeWorker ();
65 }
66 if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
67 OemHookStatusCodeInitialize ();
68 }
69
70 //
71 // Replay Status code which saved in GUID'ed HOB to all supported device.
72 //
73
74 //
75 // Journal GUID'ed HOBs to find all record entry, if found,
76 // then output record to support replay device.
77 //
78 Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);
79 HobStart = Hob.Raw;
80 while (Hob.Raw != NULL) {
81 PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);
82 if (PacketHeader->PacketIndex == ExpectedPacketIndex) {
83 Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);
84 for (Index = 0; Index < PacketHeader->RecordIndex; Index++) {
85 //
86 // Dispatch records to devices based on feature flag.
87 //
88 if (FeaturePcdGet (PcdStatusCodeReplayInSerial) &&
89 (FeaturePcdGet (PcdStatusCodeUseHardSerial) ||
90 FeaturePcdGet (PcdStatusCodeUseEfiSerial))) {
91 SerialStatusCodeReportWorker (
92 Record[Index].CodeType,
93 Record[Index].Value,
94 Record[Index].Instance,
95 NULL,
96 NULL
97 );
98 }
99 if (FeaturePcdGet (PcdStatusCodeReplayInRuntimeMemory) &&
100 FeaturePcdGet (PcdStatusCodeUseRuntimeMemory)) {
101 RtMemoryStatusCodeReportWorker (
102 gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE],
103 Record[Index].CodeType,
104 Record[Index].Value,
105 Record[Index].Instance
106 );
107 }
108 if (FeaturePcdGet (PcdStatusCodeReplayInDataHub) &&
109 FeaturePcdGet (PcdStatusCodeUseDataHub)) {
110 DataHubStatusCodeReportWorker (
111 Record[Index].CodeType,
112 Record[Index].Value,
113 Record[Index].Instance,
114 NULL,
115 NULL
116 );
117 }
118 if (FeaturePcdGet (PcdStatusCodeReplayInOEM) &&
119 FeaturePcdGet (PcdStatusCodeUseOEM)) {
120 OemHookStatusCodeReport (
121 Record[Index].CodeType,
122 Record[Index].Value,
123 Record[Index].Instance,
124 NULL,
125 NULL
126 );
127 }
128 }
129 ExpectedPacketIndex++;
130
131 //
132 // See whether there is gap of packet or not
133 //
134 if (HobStart) {
135 HobStart = NULL;
136 Hob.Raw = HobStart;
137 continue;
138 }
139 } else if (HobStart != NULL) {
140 //
141 // Cache the found packet for improve the performance
142 //
143 HobStart = Hob.Raw;
144 }
145
146 Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);
147 }
148 }
149