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