3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #ifndef __DXE_STATUS_CODE_H__
15 #define __DXE_STATUS_CODE_H__
18 #include <FrameworkDxe.h>
19 #include <FrameworkModuleDxe.h>
20 #include <Guid/DataHubStatusCodeRecord.h>
21 #include <Protocol/DataHub.h>
22 #include <Protocol/SerialIo.h>
23 #include <Guid/MemoryStatusCodeRecord.h>
24 #include <Protocol/StatusCode.h>
25 #include <Guid/StatusCodeDataTypeId.h>
26 #include <Guid/EventGroup.h>
28 #include <Library/BaseLib.h>
29 #include <Library/SynchronizationLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/DebugLib.h>
32 #include <Library/ReportStatusCodeLib.h>
33 #include <Library/PrintLib.h>
34 #include <Library/PcdLib.h>
35 #include <Library/HobLib.h>
36 #include <Library/UefiDriverEntryPoint.h>
37 #include <Library/UefiBootServicesTableLib.h>
38 #include <Library/UefiLib.h>
39 #include <Library/MemoryAllocationLib.h>
40 #include <Library/UefiRuntimeLib.h>
41 #include <Library/SerialPortLib.h>
42 #include <Library/OemHookStatusCodeLib.h>
45 // Data hub worker definition
47 #define MAX_NUMBER_DATAHUB_RECORDS 1000
48 #define DATAHUB_BYTES_PER_RECORD EFI_STATUS_CODE_DATA_MAX_SIZE
49 #define EMPTY_RECORD_TAG 0xFF
50 #define DATAHUB_STATUS_CODE_SIGNATURE SIGNATURE_32 ('B', 'D', 'H', 'S')
53 // Address type of pointer.
54 // The point type always equal to PHYSICAL_MODE on IA32/X64/EBC architecture
55 // Otherwise, VIRTUAL_MODE/PHYSICAL_MODE would be used on Ipf architecture,
66 UINT8 Data
[sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD
) + EFI_STATUS_CODE_DATA_MAX_SIZE
];
67 } DATAHUB_STATUSCODE_RECORD
;
71 // Runtime memory status code worker definition
75 UINT32 NumberOfRecords
;
76 UINT32 MaxRecordsNumber
;
77 } RUNTIME_MEMORY_STATUSCODE_HEADER
;
82 // Report operation nest status.
83 // If it is set, then the report operation has nested.
85 UINT32 StatusCodeNestStatus
;
87 // Runtime status code management header, the records buffer is following it.
89 RUNTIME_MEMORY_STATUSCODE_HEADER
*RtMemoryStatusCodeTable
[2];
90 } DXE_STATUS_CODE_CONTROLLER
;
95 Dispatch initialization request to sub status code devices based on
96 customized feature flags.
100 InitializationDispatcherWorker (
106 Initialize serial status code worker.
108 @return The function always return EFI_SUCCESS
112 EfiSerialStatusCodeInitializeWorker (
118 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
120 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
122 @param Value Describes the current status of a hardware or software entity.
123 This included information about the class and subclass that is used to classify the entity
124 as well as an operation. For progress codes, the operation is the current activity.
125 For error codes, it is the exception. For debug codes, it is not defined at this time.
126 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
127 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
129 @param Instance The enumeration of a hardware or software entity within the system.
130 A system may contain multiple entities that match a class/subclass pairing.
131 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
132 not meaningful, or not relevant. Valid instance numbers start with 1.
135 @param CallerId This optional parameter may be used to identify the caller.
136 This parameter allows the status code driver to apply different rules to different callers.
137 Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.
140 @param Data This optional parameter may be used to pass additional data
142 @retval EFI_SUCCESS Success to report status code to serial I/O.
143 @retval EFI_DEVICE_ERROR EFI serial device can not work after ExitBootService() is called .
147 SerialStatusCodeReportWorker (
148 IN EFI_STATUS_CODE_TYPE CodeType
,
149 IN EFI_STATUS_CODE_VALUE Value
,
151 IN EFI_GUID
*CallerId
,
152 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
156 Initialize runtime memory status code.
158 @return The function always return EFI_SUCCESS
162 RtMemoryStatusCodeInitializeWorker (
167 Report status code into runtime memory. If the runtime pool is full, roll back to the
168 first record and overwrite it.
170 @param RtMemoryStatusCodeTable
171 Point to Runtime memory table header.
173 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
175 @param Value Describes the current status of a hardware or software entity.
176 This included information about the class and subclass that is used to classify the entity
177 as well as an operation. For progress codes, the operation is the current activity.
178 For error codes, it is the exception. For debug codes, it is not defined at this time.
179 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
180 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
182 @param Instance The enumeration of a hardware or software entity within the system.
183 A system may contain multiple entities that match a class/subclass pairing.
184 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
185 not meaningful, or not relevant. Valid instance numbers start with 1.
187 @return The function always return EFI_SUCCESS.
191 RtMemoryStatusCodeReportWorker (
192 RUNTIME_MEMORY_STATUSCODE_HEADER
*RtMemoryStatusCodeTable
,
193 IN EFI_STATUS_CODE_TYPE CodeType
,
194 IN EFI_STATUS_CODE_VALUE Value
,
199 Initialize data hubstatus code.
200 Create a data hub listener.
202 @return The function always return EFI_SUCCESS
206 DataHubStatusCodeInitializeWorker (
212 Report status code into DataHub.
214 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
216 @param Value Describes the current status of a hardware or software entity.
217 This included information about the class and subclass that is used to classify the entity
218 as well as an operation. For progress codes, the operation is the current activity.
219 For error codes, it is the exception. For debug codes, it is not defined at this time.
220 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
221 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
223 @param Instance The enumeration of a hardware or software entity within the system.
224 A system may contain multiple entities that match a class/subclass pairing.
225 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
226 not meaningful, or not relevant. Valid instance numbers start with 1.
229 @param CallerId This optional parameter may be used to identify the caller.
230 This parameter allows the status code driver to apply different rules to different callers.
231 Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.
234 @param Data This optional parameter may be used to pass additional data
236 @retval EFI_OUT_OF_RESOURCES Can not acquire record buffer.
237 @retval EFI_DEVICE_ERROR EFI serial device can not work after ExitBootService() is called .
238 @retval EFI_SUCCESS Success to cache status code and signal log data event.
242 DataHubStatusCodeReportWorker (
243 IN EFI_STATUS_CODE_TYPE CodeType
,
244 IN EFI_STATUS_CODE_VALUE Value
,
246 IN EFI_GUID
*CallerId
,
247 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
252 // Declaration for callback Event.
256 VirtualAddressChangeCallBack (
262 // Declaration for original Entry Point.
266 DxeStatusCodeDriverEntry (
267 IN EFI_HANDLE ImageHandle
,
268 IN EFI_SYSTEM_TABLE
*SystemTable
272 // declaration of DXE status code controller.
274 extern DXE_STATUS_CODE_CONTROLLER gDxeStatusCode
;