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