Initial import.
[mirror_edk2.git] / EdkNt32Pkg / Pei / MonoStatusCode / Nt32 / PlatformStatusCode.c
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 PlatformStatusCode.c \r
15 \r
16Abstract:\r
17\r
18 Contains NT32 specific implementations required to use status codes.\r
19\r
20--*/\r
21\r
22#include "../MonoStatusCode.h"\r
23\r
24\r
25BOOLEAN gRunningFromMemory = FALSE;\r
26//\r
27// Platform definitions\r
28//\r
29EFI_PEI_REPORT_STATUS_CODE mSecReportStatusCode = NULL;\r
30\r
31extern EFI_PEI_PROGRESS_CODE_PPI mStatusCodePpi;\r
32\r
33//\r
34// Function implementations\r
35//\r
36EFI_STATUS\r
37EFIAPI\r
38PlatformReportStatusCode (\r
39 IN EFI_PEI_SERVICES **PeiServices,\r
40 IN EFI_STATUS_CODE_TYPE CodeType,\r
41 IN EFI_STATUS_CODE_VALUE Value,\r
42 IN UINT32 Instance,\r
43 IN EFI_GUID * CallerId,\r
44 IN EFI_STATUS_CODE_DATA * Data OPTIONAL\r
45 )\r
46/*++\r
47\r
48Routine Description:\r
49\r
50 Call all status code listeners in the MonoStatusCode.\r
51\r
52Arguments:\r
53\r
54 Same as ReportStatusCode service\r
55 \r
56Returns:\r
57\r
58 EFI_SUCCESS Always returns success.\r
59\r
60--*/\r
61{\r
62 mSecReportStatusCode (PeiServices, CodeType, Value, Instance, CallerId, Data);\r
63 MemoryReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
64 return EFI_SUCCESS;\r
65}\r
66\r
67VOID\r
68PlatformInitializeStatusCode (\r
69 IN EFI_FFS_FILE_HEADER *FfsHeader,\r
70 IN EFI_PEI_SERVICES **PeiServices\r
71 )\r
72/*++\r
73\r
74Routine Description:\r
75\r
76 Initialize the status code listeners. This consists of locating the \r
77 listener produced by SecMain.exe.\r
78\r
79Arguments:\r
80\r
81 FfsHeader - FV this PEIM was loaded from.\r
82 PeiServices - General purpose services available to every PEIM.\r
83\r
84Returns:\r
85\r
86 None\r
87\r
88--*/\r
89{\r
90 EFI_STATUS Status;\r
91 EFI_PEI_PROGRESS_CODE_PPI *ReportStatusCodePpi;\r
92 EFI_PEI_PPI_DESCRIPTOR *ReportStatusCodeDescriptor;\r
93\r
94 //\r
95 // Cache the existing status code listener installed by the SEC core.\r
96 // We should actually do a heap allocate, install a PPI, etc, but since we\r
97 // know that we are running from a DLL, we can use global variables, and\r
98 // directly update the status code PPI descriptor\r
99 //\r
100 //\r
101 // Locate SEC status code PPI\r
102 //\r
103 Status = (*PeiServices)->LocatePpi (\r
104 PeiServices,\r
105 &gEfiPeiStatusCodePpiGuid,\r
106 0,\r
107 &ReportStatusCodeDescriptor,\r
108 &ReportStatusCodePpi\r
109 );\r
110 if (EFI_ERROR (Status)) {\r
111 return ;\r
112 }\r
113\r
114 mSecReportStatusCode = ReportStatusCodePpi->ReportStatusCode;\r
115 ReportStatusCodeDescriptor->Ppi = &mStatusCodePpi;\r
116\r
117 //\r
118 // Always initialize memory status code listener.\r
119 //\r
120 MemoryStatusCodeInitialize (FfsHeader, PeiServices);\r
121\r
122}\r
123\r
124EFI_STATUS\r
125EFIAPI\r
126InstallMonoStatusCode (\r
127 IN EFI_FFS_FILE_HEADER *FfsHeader,\r
128 IN EFI_PEI_SERVICES **PeiServices\r
129 )\r
130/*++\r
131\r
132Routine Description:\r
133\r
134 Install the PEIM. Publish the DXE callback as well.\r
135\r
136Arguments:\r
137\r
138 FfsHeader - FV this PEIM was loaded from.\r
139 PeiServices - General purpose services available to every PEIM.\r
140\r
141Returns:\r
142\r
143 EFI_SUCCESS The function always returns success.\r
144\r
145--*/\r
146{\r
147 if (!gRunningFromMemory) {\r
148 //\r
149 // First pass, running from flash, initialize everything\r
150 //\r
151 InitializeMonoStatusCode (FfsHeader, PeiServices);\r
152 } else {\r
153 //\r
154 // Second pass, running from memory, initialize memory listener and\r
155 // publish the DXE listener in a HOB.\r
156 //\r
157 MemoryStatusCodeInitialize (FfsHeader, PeiServices);\r
158 InitializeDxeReportStatusCode (PeiServices);\r
159 }\r
160\r
161 return EFI_SUCCESS;\r
162}\r