]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.c
IntelFrameworkModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / StatusCode / Pei / StatusCodePei.c
CommitLineData
ad1a1798 1/** @file\r
d5aea10c 2 Status code PEIM which produces Status Code PPI.\r
ad1a1798 3\r
0a6f4824 4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
c0a00b14 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
ad1a1798 6\r
ad1a1798 7**/\r
8\r
85eb5794 9#include "StatusCodePei.h"\r
ad1a1798 10\r
d5aea10c 11EFI_PEI_PROGRESS_CODE_PPI mStatusCodePpi = {\r
ad1a1798 12 ReportDispatcher\r
13 };\r
14\r
ad1a1798 15EFI_PEI_PPI_DESCRIPTOR mStatusCodePpiDescriptor = {\r
16 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
17 &gEfiPeiStatusCodePpiGuid,\r
18 &mStatusCodePpi\r
19 };\r
20\r
21/**\r
d5aea10c 22 Publishes an interface that allows PEIMs to report status codes.\r
23\r
24 This function implements EFI_PEI_PROGRESS_CODE_PPI.ReportStatusCode().\r
25 It publishes an interface that allows PEIMs to report status codes.\r
26\r
27 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
28 @param CodeType Indicates the type of status code being reported.\r
29 @param Value Describes the current status of a hardware or\r
30 software entity. This includes information about the class and\r
31 subclass that is used to classify the entity as well as an operation.\r
32 For progress codes, the operation is the current activity.\r
33 For error codes, it is the exception.For debug codes,it is not defined at this time.\r
34 @param Instance The enumeration of a hardware or software entity within\r
35 the system. A system may contain multiple entities that match a class/subclass\r
36 pairing. The instance differentiates between them. An instance of 0 indicates\r
37 that instance information is unavailable, not meaningful, or not relevant.\r
38 Valid instance numbers start with 1.\r
39 @param CallerId This optional parameter may be used to identify the caller.\r
40 This parameter allows the status code driver to apply different rules to\r
41 different callers.\r
42 @param Data This optional parameter may be used to pass additional data.\r
43\r
44 @retval EFI_SUCCESS The function completed successfully.\r
ad1a1798 45\r
46**/\r
47EFI_STATUS\r
48EFIAPI\r
49ReportDispatcher (\r
507b36ca 50 IN CONST EFI_PEI_SERVICES **PeiServices,\r
d5aea10c 51 IN EFI_STATUS_CODE_TYPE CodeType,\r
52 IN EFI_STATUS_CODE_VALUE Value,\r
53 IN UINT32 Instance,\r
507b36ca 54 IN CONST EFI_GUID *CallerId OPTIONAL,\r
55 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
ad1a1798 56 )\r
57{\r
58 if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
59 SerialStatusCodeReportWorker (\r
60 CodeType,\r
61 Value,\r
62 Instance,\r
63 CallerId,\r
64 Data\r
65 );\r
66 }\r
67 if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
68 MemoryStatusCodeReportWorker (\r
69 CodeType,\r
70 Value,\r
71 Instance\r
72 );\r
73 }\r
74 if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
d5aea10c 75 //\r
76 // Call OEM hook status code library API to report status code to OEM device\r
77 //\r
ad1a1798 78 OemHookStatusCodeReport (\r
79 CodeType,\r
80 Value,\r
81 Instance,\r
507b36ca 82 (EFI_GUID *)CallerId,\r
83 (EFI_STATUS_CODE_DATA *)Data\r
ad1a1798 84 );\r
85 }\r
86\r
87 return EFI_SUCCESS;\r
88}\r
89\r
90/**\r
d5aea10c 91 Entry point of Status Code PEIM.\r
0a6f4824 92\r
d5aea10c 93 This function is the entry point of this Status Code PEIM.\r
94 It initializes supported status code devices according to PCD settings,\r
95 and installs Status Code PPI.\r
ad1a1798 96\r
8bd22b8a
LG
97 @param FileHandle Handle of the file being invoked.\r
98 @param PeiServices Describes the list of possible PEI Services.\r
ececc2eb 99\r
d5aea10c 100 @retval EFI_SUCESS The entry point of DXE IPL PEIM executes successfully.\r
ad1a1798 101\r
102**/\r
103EFI_STATUS\r
6ba0bc7c 104EFIAPI\r
ad1a1798 105PeiStatusCodeDriverEntry (\r
8bd22b8a
LG
106 IN EFI_PEI_FILE_HANDLE FileHandle,\r
107 IN CONST EFI_PEI_SERVICES **PeiServices\r
ad1a1798 108 )\r
109{\r
110 EFI_STATUS Status;\r
111\r
112 //\r
113 // Dispatch initialization request to sub-statuscode-devices.\r
114 // If enable UseSerial, then initialize serial port.\r
115 // if enable UseMemory, then initialize memory status code worker.\r
116 // if enable UseOEM, then initialize Oem status code.\r
117 //\r
118 if (FeaturePcdGet (PcdStatusCodeUseSerial)) {\r
119 Status = SerialPortInitialize();\r
120 ASSERT_EFI_ERROR (Status);\r
121 }\r
122 if (FeaturePcdGet (PcdStatusCodeUseMemory)) {\r
123 Status = MemoryStatusCodeInitializeWorker ();\r
124 ASSERT_EFI_ERROR (Status);\r
125 }\r
126 if (FeaturePcdGet (PcdStatusCodeUseOEM)) {\r
127 Status = OemHookStatusCodeInitialize ();\r
128 ASSERT_EFI_ERROR (Status);\r
129 }\r
130\r
131 //\r
d5aea10c 132 // Install Status Code PPI.\r
133 // It serves the PEI Service ReportStatusCode.\r
134 //\r
ea2d9086 135 Status = PeiServicesInstallPpi (&mStatusCodePpiDescriptor);\r
136 ASSERT_EFI_ERROR (Status);\r
ececc2eb 137\r
ad1a1798 138 return EFI_SUCCESS;\r
139}\r
140\r