Updated MSA by putting Specification element at the end of the header section
[mirror_edk2.git] / EdkNt32Pkg / Pei / MonoStatusCode / Nt32 / 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 mSecReportStatusCode (PeiServices, CodeType, Value, Instance, CallerId, Data);
63 MemoryReportStatusCode (CodeType, Value, Instance, CallerId, Data);
64 return EFI_SUCCESS;
65 }
66
67 VOID
68 PlatformInitializeStatusCode (
69 IN EFI_FFS_FILE_HEADER *FfsHeader,
70 IN EFI_PEI_SERVICES **PeiServices
71 )
72 /*++
73
74 Routine Description:
75
76 Initialize the status code listeners. This consists of locating the
77 listener produced by SecMain.exe.
78
79 Arguments:
80
81 FfsHeader - FV this PEIM was loaded from.
82 PeiServices - General purpose services available to every PEIM.
83
84 Returns:
85
86 None
87
88 --*/
89 {
90 EFI_STATUS Status;
91 EFI_PEI_PROGRESS_CODE_PPI *ReportStatusCodePpi;
92 EFI_PEI_PPI_DESCRIPTOR *ReportStatusCodeDescriptor;
93
94 //
95 // Cache the existing status code listener installed by the SEC core.
96 // We should actually do a heap allocate, install a PPI, etc, but since we
97 // know that we are running from a DLL, we can use global variables, and
98 // directly update the status code PPI descriptor
99 //
100 //
101 // Locate SEC status code PPI
102 //
103 Status = (*PeiServices)->LocatePpi (
104 PeiServices,
105 &gEfiPeiStatusCodePpiGuid,
106 0,
107 &ReportStatusCodeDescriptor,
108 &ReportStatusCodePpi
109 );
110 if (EFI_ERROR (Status)) {
111 return ;
112 }
113
114 mSecReportStatusCode = ReportStatusCodePpi->ReportStatusCode;
115 ReportStatusCodeDescriptor->Ppi = &mStatusCodePpi;
116
117 //
118 // Always initialize memory status code listener.
119 //
120 MemoryStatusCodeInitialize (FfsHeader, PeiServices);
121
122 }
123
124 EFI_STATUS
125 EFIAPI
126 InstallMonoStatusCode (
127 IN EFI_FFS_FILE_HEADER *FfsHeader,
128 IN EFI_PEI_SERVICES **PeiServices
129 )
130 /*++
131
132 Routine Description:
133
134 Install the PEIM. Publish the DXE callback as well.
135
136 Arguments:
137
138 FfsHeader - FV this PEIM was loaded from.
139 PeiServices - General purpose services available to every PEIM.
140
141 Returns:
142
143 EFI_SUCCESS The function always returns success.
144
145 --*/
146 {
147 if (!gRunningFromMemory) {
148 //
149 // First pass, running from flash, initialize everything
150 //
151 InitializeMonoStatusCode (FfsHeader, PeiServices);
152 } else {
153 //
154 // Second pass, running from memory, initialize memory listener and
155 // publish the DXE listener in a HOB.
156 //
157 MemoryStatusCodeInitialize (FfsHeader, PeiServices);
158 InitializeDxeReportStatusCode (PeiServices);
159 }
160
161 return EFI_SUCCESS;
162 }