]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/StatusCode/Pei/PeiStatusCode.c
c1e449059499723739d23e78a6d112afac0a9f27
[mirror_edk2.git] / EdkModulePkg / Universal / StatusCode / Pei / PeiStatusCode.c
1
2 /** @file
3 Generic PeiStatusCode Module.
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 Module Name: PeiStatusCode.c
15
16 **/
17
18 #include "PeiStatusCode.h"
19
20 /**
21 Report status code to all supported device.
22 *
23 *
24 @param PeiServices
25
26 @param Type Indicates the type of status code being reported.
27 The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
28 @param Value Describes the current status of a hardware or software entity.
29 This includes information about the class and subclass that is used to classify the entity
30 as well as an operation. For progress codes, the operation is the current activity.
31 For error codes, it is the exception. For debug codes, it is not defined at this time.
32 Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
33 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
34 @param Instance The enumeration of a hardware or software entity within the system.
35 A system may contain multiple entities that match a class/subclass pairing.
36 The instance differentiates between them. An instance of 0 indicates that instance
37 information is unavailable, not meaningful, or not relevant. Valid instance numbers start with 1.
38 @param CallerId This optional parameter may be used to identify the caller.
39 This parameter allows the status code driver to apply different rules to different callers.
40 @param Data This optional parameter may be used to pass additional data.
41 Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.
42 The contents of this data type may have additional GUID-specific data. The standard GUIDs and
43 their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.
44 **/
45 EFI_STATUS
46 EFIAPI
47 ReportDispatcher (
48 IN EFI_PEI_SERVICES **PeiServices,
49 IN EFI_STATUS_CODE_TYPE Type,
50 IN EFI_STATUS_CODE_VALUE Value,
51 IN UINT32 Instance,
52 IN EFI_GUID *CallerId OPTIONAL,
53 IN EFI_STATUS_CODE_DATA *Data OPTIONAL
54 );
55
56
57 EFI_PEI_PROGRESS_CODE_PPI mStatusCodePpi = {
58 ReportDispatcher
59 };
60
61 EFI_PEI_PPI_DESCRIPTOR mStatusCodePpiDescriptor = {
62 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
63 &gEfiPeiStatusCodePpiGuid,
64 &mStatusCodePpi
65 };
66
67 /**
68 Report status code to all supported device.
69 *
70 *
71 @param PeiServices
72
73 @param CodeType Indicates the type of status code being reported.
74 The type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
75 @param Value Describes the current status of a hardware or software entity.
76 This includes information about the class and subclass that is used to classify the entity
77 as well as an operation. For progress codes, the operation is the current activity.
78 For error codes, it is the exception. For debug codes, it is not defined at this time.
79 Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
80 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
81 @param Instance The enumeration of a hardware or software entity within the system.
82 A system may contain multiple entities that match a class/subclass pairing.
83 The instance differentiates between them. An instance of 0 indicates that instance
84 information is unavailable, not meaningful, or not relevant. Valid instance numbers start with 1.
85 @param CallerId This optional parameter may be used to identify the caller.
86 This parameter allows the status code driver to apply different rules to different callers.
87 @param Data This optional parameter may be used to pass additional data.
88 Type EFI_STATUS_CODE_DATA is defined in "Related Definitions" below.
89 The contents of this data type may have additional GUID-specific data. The standard GUIDs and
90 their associated data structures are defined in the Intel? Platform Innovation Framework for EFI Status Codes Specification.
91 **/
92 EFI_STATUS
93 EFIAPI
94 ReportDispatcher (
95 IN EFI_PEI_SERVICES **PeiServices,
96 IN EFI_STATUS_CODE_TYPE CodeType,
97 IN EFI_STATUS_CODE_VALUE Value,
98 IN UINT32 Instance,
99 IN EFI_GUID *CallerId OPTIONAL,
100 IN EFI_STATUS_CODE_DATA *Data OPTIONAL
101 )
102 {
103 if (FeaturePcdGet (PcdStatusCodeUseSerial)) {
104 SerialStatusCodeReportWorker (
105 CodeType,
106 Value,
107 Instance,
108 CallerId,
109 Data
110 );
111 }
112 if (FeaturePcdGet (PcdStatusCodeUseMemory)) {
113 MemoryStatusCodeReportWorker (
114 CodeType,
115 Value,
116 Instance
117 );
118 }
119 if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
120 OemHookStatusCodeReport (
121 CodeType,
122 Value,
123 Instance,
124 CallerId,
125 Data
126 );
127 }
128
129 return EFI_SUCCESS;
130 }
131
132 /**
133 Initialize PEI status codes and publish the status code
134 PPI.
135
136 @param FfsHeader FV this PEIM was loaded from.
137 @param PeiServices General purpose services available to every PEIM.
138
139 @return The function always returns success.
140
141 **/
142 EFI_STATUS
143 EFIAPI
144 PeiStatusCodeDriverEntry (
145 IN EFI_FFS_FILE_HEADER *FfsHeader,
146 IN EFI_PEI_SERVICES **PeiServices
147 )
148 {
149 EFI_STATUS Status;
150
151 //
152 // Dispatch initialization request to sub-statuscode-devices.
153 // If enable UseSerial, then initialize serial port.
154 // if enable UseMemory, then initialize memory status code worker.
155 // if enable UseOEM, then initialize Oem status code.
156 //
157 if (FeaturePcdGet (PcdStatusCodeUseSerial)) {
158 SerialPortInitialize();
159 }
160 if (FeaturePcdGet (PcdStatusCodeUseMemory)) {
161 MemoryStatusCodeInitializeWorker ();
162 }
163 if (FeaturePcdGet (PcdStatusCodeUseOEM)) {
164 OemHookStatusCodeInitialize ();
165 }
166
167 //
168 // Install PeiStatusCodePpi.
169 // PeiServices use this Ppi to output status code.
170 // use library
171 Status = PeiServicesInstallPpi (&mStatusCodePpiDescriptor);
172 ASSERT_EFI_ERROR (Status);
173
174 return EFI_SUCCESS;
175 }
176