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