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