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