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