]>
Commit | Line | Data |
---|---|---|
162ed594 | 1 | /** @file\r |
797a9d67 | 2 | DXE Core Main Entry Point\r |
23c98c94 | 3 | \r |
4 | Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r | |
28a00297 | 5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
797a9d67 | 13 | **/\r |
28a00297 | 14 | \r |
15 | #include <DxeMain.h>\r | |
16 | \r | |
17 | //\r | |
18 | // DXE Core Global Variables for Protocols from PEI\r | |
19 | //\r | |
20 | EFI_HANDLE mDecompressHandle = NULL;\r | |
28a00297 | 21 | \r |
22 | //\r | |
23 | // DXE Core globals for Architecture Protocols\r | |
24 | //\r | |
25 | EFI_SECURITY_ARCH_PROTOCOL *gSecurity = NULL;\r | |
26 | EFI_CPU_ARCH_PROTOCOL *gCpu = NULL;\r | |
27 | EFI_METRONOME_ARCH_PROTOCOL *gMetronome = NULL;\r | |
28 | EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL;\r | |
29 | EFI_BDS_ARCH_PROTOCOL *gBds = NULL;\r | |
30 | EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL;\r | |
31 | \r | |
32 | \r | |
33 | //\r | |
34 | // BugBug: I'n not runtime, but is the PPI?\r | |
35 | //\r | |
36 | EFI_STATUS_CODE_PROTOCOL gStatusCodeInstance = {\r | |
37 | NULL\r | |
38 | };\r | |
39 | \r | |
40 | EFI_STATUS_CODE_PROTOCOL *gStatusCode = &gStatusCodeInstance;\r | |
41 | \r | |
42 | \r | |
43 | //\r | |
44 | // DXE Core Global used to update core loaded image protocol handle\r | |
45 | //\r | |
46 | EFI_GUID *gDxeCoreFileName;\r | |
47 | EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;\r | |
48 | \r | |
49 | \r | |
50 | \r | |
51 | //\r | |
52 | // DXE Core Module Variables\r | |
53 | //\r | |
54 | \r | |
55 | EFI_BOOT_SERVICES mBootServices = {\r | |
56 | {\r | |
57 | EFI_BOOT_SERVICES_SIGNATURE, // Signature\r | |
58 | EFI_BOOT_SERVICES_REVISION, // Revision\r | |
59 | sizeof (EFI_BOOT_SERVICES), // HeaderSize\r | |
60 | 0, // CRC32\r | |
61 | 0 // Reserved\r | |
62 | },\r | |
63 | (EFI_RAISE_TPL) CoreRaiseTpl, // RaiseTPL\r | |
64 | (EFI_RESTORE_TPL) CoreRestoreTpl, // RestoreTPL\r | |
65 | (EFI_ALLOCATE_PAGES) CoreAllocatePages, // AllocatePages\r | |
66 | (EFI_FREE_PAGES) CoreFreePages, // FreePages\r | |
67 | (EFI_GET_MEMORY_MAP) CoreGetMemoryMap, // GetMemoryMap\r | |
68 | (EFI_ALLOCATE_POOL) CoreAllocatePool, // AllocatePool\r | |
69 | (EFI_FREE_POOL) CoreFreePool, // FreePool\r | |
70 | (EFI_CREATE_EVENT) CoreCreateEvent, // CreateEvent\r | |
71 | (EFI_SET_TIMER) CoreSetTimer, // SetTimer\r | |
72 | (EFI_WAIT_FOR_EVENT) CoreWaitForEvent, // WaitForEvent\r | |
73 | (EFI_SIGNAL_EVENT) CoreSignalEvent, // SignalEvent\r | |
74 | (EFI_CLOSE_EVENT) CoreCloseEvent, // CloseEvent\r | |
75 | (EFI_CHECK_EVENT) CoreCheckEvent, // CheckEvent\r | |
76 | (EFI_INSTALL_PROTOCOL_INTERFACE) CoreInstallProtocolInterface, // InstallProtocolInterface\r | |
77 | (EFI_REINSTALL_PROTOCOL_INTERFACE) CoreReinstallProtocolInterface, // ReinstallProtocolInterface\r | |
78 | (EFI_UNINSTALL_PROTOCOL_INTERFACE) CoreUninstallProtocolInterface, // UninstallProtocolInterface\r | |
79 | (EFI_HANDLE_PROTOCOL) CoreHandleProtocol, // HandleProtocol\r | |
80 | (VOID *) NULL, // Reserved\r | |
81 | (EFI_REGISTER_PROTOCOL_NOTIFY) CoreRegisterProtocolNotify, // RegisterProtocolNotify\r | |
82 | (EFI_LOCATE_HANDLE) CoreLocateHandle, // LocateHandle\r | |
83 | (EFI_LOCATE_DEVICE_PATH) CoreLocateDevicePath, // LocateDevicePath\r | |
84 | (EFI_INSTALL_CONFIGURATION_TABLE) CoreInstallConfigurationTable, // InstallConfigurationTable\r | |
85 | (EFI_IMAGE_LOAD) CoreLoadImage, // LoadImage\r | |
86 | (EFI_IMAGE_START) CoreStartImage, // StartImage\r | |
87 | (EFI_EXIT) CoreExit, // Exit\r | |
88 | (EFI_IMAGE_UNLOAD) CoreUnloadImage, // UnloadImage\r | |
89 | (EFI_EXIT_BOOT_SERVICES) CoreExitBootServices, // ExitBootServices\r | |
90 | (EFI_GET_NEXT_MONOTONIC_COUNT) CoreEfiNotAvailableYetArg1, // GetNextMonotonicCount\r | |
91 | (EFI_STALL) CoreStall, // Stall\r | |
92 | (EFI_SET_WATCHDOG_TIMER) CoreSetWatchdogTimer, // SetWatchdogTimer\r | |
93 | (EFI_CONNECT_CONTROLLER) CoreConnectController, // ConnectController\r | |
94 | (EFI_DISCONNECT_CONTROLLER) CoreDisconnectController, // DisconnectController\r | |
95 | (EFI_OPEN_PROTOCOL) CoreOpenProtocol, // OpenProtocol\r | |
96 | (EFI_CLOSE_PROTOCOL) CoreCloseProtocol, // CloseProtocol\r | |
97 | (EFI_OPEN_PROTOCOL_INFORMATION) CoreOpenProtocolInformation, // OpenProtocolInformation\r | |
98 | (EFI_PROTOCOLS_PER_HANDLE) CoreProtocolsPerHandle, // ProtocolsPerHandle\r | |
99 | (EFI_LOCATE_HANDLE_BUFFER) CoreLocateHandleBuffer, // LocateHandleBuffer\r | |
100 | (EFI_LOCATE_PROTOCOL) CoreLocateProtocol, // LocateProtocol\r | |
101 | (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces\r | |
102 | (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces\r | |
103 | (EFI_CALCULATE_CRC32) CoreEfiNotAvailableYetArg3, // CalculateCrc32\r | |
104 | (EFI_COPY_MEM) CopyMem, // CopyMem\r | |
105 | (EFI_SET_MEM) SetMem, // SetMem\r | |
106 | (EFI_CREATE_EVENT_EX) CoreCreateEventEx // CreateEventEx\r | |
107 | };\r | |
108 | \r | |
109 | EFI_DXE_SERVICES mDxeServices = {\r | |
110 | {\r | |
111 | DXE_SERVICES_SIGNATURE, // Signature\r | |
112 | DXE_SERVICES_REVISION, // Revision\r | |
113 | sizeof (DXE_SERVICES), // HeaderSize\r | |
114 | 0, // CRC32\r | |
115 | 0 // Reserved\r | |
116 | },\r | |
117 | (EFI_ADD_MEMORY_SPACE) CoreAddMemorySpace, // AddMemorySpace\r | |
118 | (EFI_ALLOCATE_MEMORY_SPACE) CoreAllocateMemorySpace, // AllocateMemorySpace\r | |
119 | (EFI_FREE_MEMORY_SPACE) CoreFreeMemorySpace, // FreeMemorySpace\r | |
120 | (EFI_REMOVE_MEMORY_SPACE) CoreRemoveMemorySpace, // RemoveMemorySpace\r | |
121 | (EFI_GET_MEMORY_SPACE_DESCRIPTOR) CoreGetMemorySpaceDescriptor, // GetMemorySpaceDescriptor\r | |
122 | (EFI_SET_MEMORY_SPACE_ATTRIBUTES) CoreSetMemorySpaceAttributes, // SetMemorySpaceAttributes\r | |
123 | (EFI_GET_MEMORY_SPACE_MAP) CoreGetMemorySpaceMap, // GetMemorySpaceMap\r | |
124 | (EFI_ADD_IO_SPACE) CoreAddIoSpace, // AddIoSpace\r | |
125 | (EFI_ALLOCATE_IO_SPACE) CoreAllocateIoSpace, // AllocateIoSpace\r | |
126 | (EFI_FREE_IO_SPACE) CoreFreeIoSpace, // FreeIoSpace\r | |
127 | (EFI_REMOVE_IO_SPACE) CoreRemoveIoSpace, // RemoveIoSpace\r | |
128 | (EFI_GET_IO_SPACE_DESCRIPTOR) CoreGetIoSpaceDescriptor, // GetIoSpaceDescriptor\r | |
129 | (EFI_GET_IO_SPACE_MAP) CoreGetIoSpaceMap, // GetIoSpaceMap\r | |
130 | (EFI_DISPATCH) CoreDispatcher, // Dispatch\r | |
131 | (EFI_SCHEDULE) CoreSchedule, // Schedule\r | |
132 | (EFI_TRUST) CoreTrust, // Trust\r | |
133 | (EFI_PROCESS_FIRMWARE_VOLUME) CoreProcessFirmwareVolume, // ProcessFirmwareVolume\r | |
134 | };\r | |
135 | \r | |
136 | EFI_SYSTEM_TABLE mEfiSystemTableTemplate = {\r | |
137 | {\r | |
138 | EFI_SYSTEM_TABLE_SIGNATURE, // Signature\r | |
139 | EFI_SYSTEM_TABLE_REVISION, // Revision\r | |
140 | sizeof (EFI_SYSTEM_TABLE), // HeaderSize\r | |
141 | 0, // CRC32\r | |
142 | 0 // Reserved\r | |
143 | },\r | |
144 | NULL, // FirmwareVendor\r | |
145 | 0, // FirmwareRevision\r | |
146 | NULL, // ConsoleInHandle\r | |
147 | NULL, // ConIn\r | |
148 | NULL, // ConsoleOutHandle\r | |
149 | NULL, // ConOut\r | |
150 | NULL, // StandardErrorHandle\r | |
151 | NULL, // StdErr\r | |
152 | NULL, // RuntimeServices\r | |
153 | &mBootServices, // BootServices\r | |
154 | 0, // NumberOfConfigurationTableEntries\r | |
155 | NULL // ConfigurationTable\r | |
156 | };\r | |
157 | \r | |
158 | EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = {\r | |
159 | {\r | |
160 | EFI_RUNTIME_SERVICES_SIGNATURE, // Signature\r | |
161 | EFI_RUNTIME_SERVICES_REVISION, // Revision\r | |
162 | sizeof (EFI_RUNTIME_SERVICES), // HeaderSize\r | |
163 | 0, // CRC32\r | |
164 | 0 // Reserved\r | |
165 | },\r | |
166 | (EFI_GET_TIME) CoreEfiNotAvailableYetArg2, // GetTime\r | |
167 | (EFI_SET_TIME) CoreEfiNotAvailableYetArg1, // SetTime\r | |
168 | (EFI_GET_WAKEUP_TIME) CoreEfiNotAvailableYetArg3, // GetWakeupTime\r | |
169 | (EFI_SET_WAKEUP_TIME) CoreEfiNotAvailableYetArg2, // SetWakeupTime\r | |
170 | (EFI_SET_VIRTUAL_ADDRESS_MAP) CoreEfiNotAvailableYetArg4, // SetVirtualAddressMap\r | |
171 | (EFI_CONVERT_POINTER) CoreEfiNotAvailableYetArg2, // ConvertPointer\r | |
172 | (EFI_GET_VARIABLE) CoreEfiNotAvailableYetArg5, // GetVariable\r | |
173 | (EFI_GET_NEXT_VARIABLE_NAME) CoreEfiNotAvailableYetArg3, // GetNextVariableName\r | |
174 | (EFI_SET_VARIABLE) CoreEfiNotAvailableYetArg5, // SetVariable\r | |
175 | (EFI_GET_NEXT_HIGH_MONO_COUNT) CoreEfiNotAvailableYetArg1, // GetNextHighMonotonicCount\r | |
176 | (EFI_RESET_SYSTEM) CoreEfiNotAvailableYetArg4, // ResetSystem\r | |
177 | (EFI_UPDATE_CAPSULE) CoreEfiNotAvailableYetArg3, // UpdateCapsule\r | |
178 | (EFI_QUERY_CAPSULE_CAPABILITIES) CoreEfiNotAvailableYetArg4, // QueryCapsuleCapabilities\r | |
179 | (EFI_QUERY_VARIABLE_INFO) CoreEfiNotAvailableYetArg4 // QueryVariableInfo\r | |
180 | };\r | |
181 | \r | |
182 | EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate = {\r | |
183 | INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.ImageHead),\r | |
184 | INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.EventHead),\r | |
185 | \r | |
186 | //\r | |
187 | // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will\r | |
188 | // prevent people from having pointer math bugs in their code.\r | |
189 | // now you have to use *DescriptorSize to make things work.\r | |
190 | //\r | |
191 | sizeof (EFI_MEMORY_DESCRIPTOR) + sizeof (UINT64) - (sizeof (EFI_MEMORY_DESCRIPTOR) % sizeof (UINT64)),\r | |
192 | EFI_MEMORY_DESCRIPTOR_VERSION,\r | |
193 | 0,\r | |
194 | NULL,\r | |
195 | NULL,\r | |
196 | FALSE,\r | |
197 | FALSE\r | |
198 | };\r | |
199 | \r | |
200 | EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = &gRuntimeTemplate;\r | |
201 | \r | |
202 | //\r | |
203 | // DXE Core Global Variables for the EFI System Table, Boot Services Table,\r | |
204 | // DXE Services Table, and Runtime Services Table\r | |
205 | //\r | |
206 | EFI_BOOT_SERVICES *gDxeCoreBS = &mBootServices;\r | |
207 | EFI_DXE_SERVICES *gDxeCoreDS = &mDxeServices;\r | |
208 | EFI_SYSTEM_TABLE *gDxeCoreST = NULL;\r | |
209 | \r | |
210 | //\r | |
211 | // For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory\r | |
212 | // but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it\r | |
213 | // a value that will not cause debug infrastructure to crash early on.\r | |
214 | //\r | |
215 | EFI_RUNTIME_SERVICES *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate;\r | |
216 | EFI_HANDLE gDxeCoreImageHandle = NULL;\r | |
217 | \r | |
218 | VOID *mHobStart;\r | |
219 | \r | |
220 | //\r | |
221 | // EFI Decompress Protocol\r | |
222 | //\r | |
223 | EFI_DECOMPRESS_PROTOCOL gEfiDecompress = {\r | |
224 | DxeMainUefiDecompressGetInfo,\r | |
225 | DxeMainUefiDecompress\r | |
226 | };\r | |
227 | \r | |
228 | //\r | |
229 | // Main entry point to the DXE Core\r | |
230 | //\r | |
28a00297 | 231 | \r |
162ed594 | 232 | /**\r |
28a00297 | 233 | Main entry point to DXE Core.\r |
234 | \r | |
162ed594 | 235 | @param HobStart Pointer to the beginning of the HOB List from \r |
236 | PEI \r | |
28a00297 | 237 | \r |
162ed594 | 238 | @return This function should never return\r |
28a00297 | 239 | \r |
162ed594 | 240 | **/\r |
241 | VOID\r | |
242 | EFIAPI\r | |
243 | DxeMain (\r | |
244 | IN VOID *HobStart\r | |
245 | )\r | |
28a00297 | 246 | {\r |
247 | EFI_STATUS Status;\r | |
248 | EFI_PHYSICAL_ADDRESS MemoryBaseAddress;\r | |
249 | UINT64 MemoryLength;\r | |
250 | \r | |
251 | mHobStart = HobStart;\r | |
252 | \r | |
253 | //\r | |
254 | // Initialize Memory Services\r | |
255 | //\r | |
256 | CoreInitializeMemoryServices (&HobStart, &MemoryBaseAddress, &MemoryLength);\r | |
257 | \r | |
258 | //\r | |
259 | // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData\r | |
260 | // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table\r | |
261 | //\r | |
262 | gDxeCoreST = CoreAllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);\r | |
263 | ASSERT (gDxeCoreST != NULL);\r | |
264 | \r | |
265 | gDxeCoreRT = CoreAllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);\r | |
266 | ASSERT (gDxeCoreRT != NULL);\r | |
267 | \r | |
268 | gDxeCoreST->RuntimeServices = gDxeCoreRT;\r | |
269 | \r | |
270 | //\r | |
271 | // Start the Image Services.\r | |
272 | //\r | |
273 | Status = CoreInitializeImageServices (HobStart);\r | |
274 | ASSERT_EFI_ERROR (Status);\r | |
275 | \r | |
276 | //\r | |
277 | // Call constructor for all libraries\r | |
278 | //\r | |
279 | ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST);\r | |
280 | PERF_END (0,PEI_TOK, NULL, 0) ;\r | |
281 | PERF_START (0,DXE_TOK, NULL, 0) ;\r | |
282 | \r | |
283 | //\r | |
284 | // Initialize the Global Coherency Domain Services\r | |
285 | //\r | |
286 | Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength);\r | |
287 | ASSERT_EFI_ERROR (Status);\r | |
288 | \r | |
289 | //\r | |
6979fd93 | 290 | // The HobStart is relocated in gcd service init. Sync mHobStart varible.\r |
291 | //\r | |
292 | mHobStart = HobStart;\r | |
293 | \r | |
28a00297 | 294 | // Install the DXE Services Table into the EFI System Tables's Configuration Table\r |
295 | //\r | |
296 | Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDxeCoreDS);\r | |
297 | ASSERT_EFI_ERROR (Status);\r | |
298 | \r | |
299 | //\r | |
300 | // Install the HOB List into the EFI System Tables's Configuration Table\r | |
301 | //\r | |
302 | Status = CoreInstallConfigurationTable (&gEfiHobListGuid, HobStart);\r | |
303 | ASSERT_EFI_ERROR (Status);\r | |
304 | \r | |
305 | //\r | |
306 | // Install Memory Type Information Table into the EFI System Tables's Configuration Table\r | |
307 | //\r | |
308 | Status = CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid, &gMemoryTypeInformation);\r | |
309 | ASSERT_EFI_ERROR (Status);\r | |
310 | \r | |
311 | //\r | |
312 | // Initialize the ReportStatusCode with PEI version, if available\r | |
313 | //\r | |
314 | CoreGetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **)&gStatusCode->ReportStatusCode);\r | |
315 | \r | |
316 | //\r | |
317 | // Report Status Code here for DXE_ENTRY_POINT once it is available\r | |
318 | //\r | |
797a9d67 | 319 | CoreReportProgressCode (FixedPcdGet32(PcdStatusCodeValueDxeCoreEntry));\r |
28a00297 | 320 | \r |
321 | //\r | |
322 | // Create the aligned system table pointer structure that is used by external\r | |
323 | // debuggers to locate the system table... Also, install debug image info\r | |
324 | // configuration table.\r | |
325 | //\r | |
326 | CoreInitializeDebugImageInfoTable ();\r | |
327 | CoreNewDebugImageInfoEntry (\r | |
328 | EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,\r | |
329 | gDxeCoreLoadedImage,\r | |
330 | gDxeCoreImageHandle\r | |
331 | );\r | |
332 | \r | |
162ed594 | 333 | DEBUG ((DEBUG_INFO | DEBUG_LOAD, "HOBLIST address in DXE = 0x%016lx\n", (UINT64) (UINTN) HobStart));\r |
28a00297 | 334 | \r |
335 | //\r | |
336 | // Initialize the Event Services\r | |
337 | //\r | |
338 | Status = CoreInitializeEventServices ();\r | |
339 | ASSERT_EFI_ERROR (Status);\r | |
340 | \r | |
341 | \r | |
342 | //\r | |
343 | // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs\r | |
344 | //\r | |
345 | // These Protocols are not architectural. This implementation is sharing code between\r | |
346 | // PEI and DXE in order to save FLASH space. These Protocols could also be implemented\r | |
347 | // as part of the DXE Core. However, that would also require the DXE Core to be ported\r | |
348 | // each time a different CPU is used, a different Decompression algorithm is used, or a\r | |
349 | // different Image type is used. By placing these Protocols in PEI, the DXE Core remains\r | |
350 | // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,\r | |
351 | // and from CPU to CPU.\r | |
352 | //\r | |
353 | \r | |
354 | //\r | |
355 | // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components\r | |
356 | //\r | |
357 | Status = CoreInstallMultipleProtocolInterfaces (\r | |
358 | &mDecompressHandle,\r | |
359 | &gEfiDecompressProtocolGuid, &gEfiDecompress,\r | |
360 | NULL\r | |
361 | );\r | |
362 | ASSERT_EFI_ERROR (Status);\r | |
363 | \r | |
28a00297 | 364 | //\r |
365 | // Register for the GUIDs of the Architectural Protocols, so the rest of the\r | |
366 | // EFI Boot Services and EFI Runtime Services tables can be filled in.\r | |
367 | //\r | |
368 | CoreNotifyOnArchProtocolInstallation ();\r | |
369 | \r | |
370 | //\r | |
371 | // Produce Firmware Volume Protocols, one for each FV in the HOB list.\r | |
372 | //\r | |
373 | Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gDxeCoreST);\r | |
374 | ASSERT_EFI_ERROR (Status);\r | |
375 | \r | |
376 | Status = FwVolDriverInit (gDxeCoreImageHandle, gDxeCoreST);\r | |
377 | ASSERT_EFI_ERROR (Status);\r | |
378 | \r | |
379 | //\r | |
380 | // Produce the Section Extraction Protocol\r | |
381 | //\r | |
382 | Status = InitializeSectionExtraction (gDxeCoreImageHandle, gDxeCoreST);\r | |
383 | ASSERT_EFI_ERROR (Status);\r | |
384 | \r | |
385 | //\r | |
386 | // Initialize the DXE Dispatcher\r | |
387 | //\r | |
388 | PERF_START (0,"CoreInitializeDispatcher", "DxeMain", 0) ;\r | |
389 | CoreInitializeDispatcher ();\r | |
390 | PERF_END (0,"CoreInitializeDispatcher", "DxeMain", 0) ;\r | |
391 | \r | |
392 | //\r | |
393 | // Invoke the DXE Dispatcher\r | |
394 | //\r | |
395 | PERF_START (0, "CoreDispatcher", "DxeMain", 0);\r | |
396 | CoreDispatcher ();\r | |
397 | PERF_END (0, "CoreDispatcher", "DxeMain", 0);\r | |
398 | \r | |
399 | //\r | |
400 | // Display Architectural protocols that were not loaded if this is DEBUG build\r | |
401 | //\r | |
402 | DEBUG_CODE_BEGIN ();\r | |
403 | CoreDisplayMissingArchProtocols ();\r | |
404 | DEBUG_CODE_END ();\r | |
405 | \r | |
406 | //\r | |
407 | // Assert if the Architectural Protocols are not present.\r | |
408 | //\r | |
409 | ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ());\r | |
410 | \r | |
411 | //\r | |
412 | // Report Status code before transfer control to BDS\r | |
413 | //\r | |
797a9d67 | 414 | CoreReportProgressCode (FixedPcdGet32 (PcdStatusCodeValueDxeCoreHandoffToBds));\r |
28a00297 | 415 | //\r |
416 | // Display any drivers that were not dispatched because dependency expression\r | |
417 | // evaluated to false if this is a debug build\r | |
418 | //\r | |
419 | DEBUG_CODE_BEGIN ();\r | |
420 | CoreDisplayDiscoveredNotDispatched ();\r | |
421 | DEBUG_CODE_END ();\r | |
422 | \r | |
423 | //\r | |
424 | // Transfer control to the BDS Architectural Protocol\r | |
425 | //\r | |
426 | gBds->Entry (gBds);\r | |
427 | \r | |
428 | //\r | |
429 | // BDS should never return\r | |
430 | //\r | |
431 | ASSERT (FALSE);\r | |
432 | CpuDeadLoop ();\r | |
433 | }\r | |
434 | \r | |
435 | \r | |
162ed594 | 436 | \r |
437 | /**\r | |
438 | Place holder function until all the Boot Services and Runtime Services are\r | |
439 | available.\r | |
440 | \r | |
441 | @return EFI_NOT_AVAILABLE_YET\r | |
442 | \r | |
443 | **/\r | |
28a00297 | 444 | EFI_STATUS\r |
445 | EFIAPI\r | |
446 | CoreEfiNotAvailableYetArg0 (\r | |
447 | VOID\r | |
448 | )\r | |
28a00297 | 449 | {\r |
450 | //\r | |
451 | // This function should never be executed. If it does, then the architectural protocols\r | |
452 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r | |
453 | // DXE Core and all the Architectural Protocols are complete.\r | |
454 | //\r | |
455 | \r | |
456 | return EFI_NOT_AVAILABLE_YET;\r | |
457 | }\r | |
458 | \r | |
162ed594 | 459 | \r |
460 | /**\r | |
461 | Place holder function until all the Boot Services and Runtime Services are\r | |
462 | available.\r | |
463 | \r | |
464 | @param Arg1 Undefined \r | |
465 | \r | |
466 | @return EFI_NOT_AVAILABLE_YET\r | |
467 | \r | |
468 | **/\r | |
28a00297 | 469 | EFI_STATUS\r |
470 | EFIAPI\r | |
471 | CoreEfiNotAvailableYetArg1 (\r | |
472 | UINTN Arg1\r | |
473 | )\r | |
28a00297 | 474 | {\r |
475 | //\r | |
476 | // This function should never be executed. If it does, then the architectural protocols\r | |
477 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r | |
478 | // DXE Core and all the Architectural Protocols are complete.\r | |
479 | //\r | |
480 | \r | |
481 | return EFI_NOT_AVAILABLE_YET;\r | |
482 | }\r | |
483 | \r | |
162ed594 | 484 | \r |
485 | /**\r | |
486 | Place holder function until all the Boot Services and Runtime Services are available.\r | |
487 | \r | |
488 | @param Arg1 Undefined \r | |
489 | @param Arg2 Undefined \r | |
490 | \r | |
491 | @return EFI_NOT_AVAILABLE_YET\r | |
492 | \r | |
493 | **/\r | |
28a00297 | 494 | EFI_STATUS\r |
495 | EFIAPI\r | |
496 | CoreEfiNotAvailableYetArg2 (\r | |
497 | UINTN Arg1,\r | |
498 | UINTN Arg2\r | |
499 | )\r | |
28a00297 | 500 | {\r |
501 | //\r | |
502 | // This function should never be executed. If it does, then the architectural protocols\r | |
503 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r | |
504 | // DXE Core and all the Architectural Protocols are complete.\r | |
505 | //\r | |
506 | \r | |
507 | return EFI_NOT_AVAILABLE_YET;\r | |
508 | }\r | |
509 | \r | |
162ed594 | 510 | \r |
511 | /**\r | |
512 | Place holder function until all the Boot Services and Runtime Services are available.\r | |
513 | \r | |
514 | @param Arg1 Undefined \r | |
515 | @param Arg2 Undefined \r | |
516 | @param Arg3 Undefined \r | |
517 | \r | |
518 | @return EFI_NOT_AVAILABLE_YET\r | |
519 | \r | |
520 | **/\r | |
28a00297 | 521 | EFI_STATUS\r |
522 | EFIAPI\r | |
523 | CoreEfiNotAvailableYetArg3 (\r | |
524 | UINTN Arg1,\r | |
525 | UINTN Arg2,\r | |
526 | UINTN Arg3\r | |
527 | )\r | |
28a00297 | 528 | {\r |
529 | //\r | |
530 | // This function should never be executed. If it does, then the architectural protocols\r | |
531 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r | |
532 | // DXE Core and all the Architectural Protocols are complete.\r | |
533 | //\r | |
534 | \r | |
535 | return EFI_NOT_AVAILABLE_YET;\r | |
536 | }\r | |
537 | \r | |
162ed594 | 538 | \r |
539 | /**\r | |
540 | Place holder function until all the Boot Services and Runtime Services are available.\r | |
541 | \r | |
542 | @param Arg1 Undefined \r | |
543 | @param Arg2 Undefined \r | |
544 | @param Arg3 Undefined \r | |
545 | @param Arg4 Undefined \r | |
546 | \r | |
547 | @return EFI_NOT_AVAILABLE_YET\r | |
548 | \r | |
549 | **/\r | |
28a00297 | 550 | EFI_STATUS\r |
551 | EFIAPI\r | |
552 | CoreEfiNotAvailableYetArg4 (\r | |
553 | UINTN Arg1,\r | |
554 | UINTN Arg2,\r | |
555 | UINTN Arg3,\r | |
556 | UINTN Arg4\r | |
557 | )\r | |
28a00297 | 558 | {\r |
559 | //\r | |
560 | // This function should never be executed. If it does, then the architectural protocols\r | |
561 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r | |
562 | // DXE Core and all the Architectural Protocols are complete.\r | |
563 | //\r | |
564 | \r | |
565 | return EFI_NOT_AVAILABLE_YET;\r | |
566 | }\r | |
567 | \r | |
162ed594 | 568 | \r |
569 | /**\r | |
570 | Place holder function until all the Boot Services and Runtime Services are available.\r | |
571 | \r | |
572 | @param Arg1 Undefined \r | |
573 | @param Arg2 Undefined \r | |
574 | @param Arg3 Undefined \r | |
575 | @param Arg4 Undefined \r | |
576 | @param Arg5 Undefined \r | |
577 | \r | |
578 | @return EFI_NOT_AVAILABLE_YET\r | |
579 | \r | |
580 | **/\r | |
28a00297 | 581 | EFI_STATUS\r |
582 | EFIAPI\r | |
583 | CoreEfiNotAvailableYetArg5 (\r | |
584 | UINTN Arg1,\r | |
585 | UINTN Arg2,\r | |
586 | UINTN Arg3,\r | |
587 | UINTN Arg4,\r | |
588 | UINTN Arg5\r | |
589 | )\r | |
28a00297 | 590 | {\r |
591 | //\r | |
592 | // This function should never be executed. If it does, then the architectural protocols\r | |
593 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r | |
594 | // DXE Core and all the Architectural Protocols are complete.\r | |
595 | //\r | |
596 | \r | |
597 | return EFI_NOT_AVAILABLE_YET;\r | |
598 | }\r | |
599 | \r | |
600 | \r | |
162ed594 | 601 | \r |
602 | /**\r | |
603 | Searches for a Protocol Interface passed from PEI through a HOB.\r | |
604 | \r | |
605 | @param ProtocolGuid The Protocol GUID to search for in the HOB List \r | |
606 | @param Interface A pointer to the interface for the Protocol GUID \r | |
607 | \r | |
608 | @retval EFI_SUCCESS The Protocol GUID was found and its interface is \r | |
609 | returned in Interface \r | |
610 | @retval EFI_NOT_FOUND The Protocol GUID was not found in the HOB List\r | |
611 | \r | |
612 | **/\r | |
28a00297 | 613 | EFI_STATUS\r |
614 | CoreGetPeiProtocol (\r | |
615 | IN EFI_GUID *ProtocolGuid,\r | |
616 | IN VOID **Interface\r | |
617 | )\r | |
28a00297 | 618 | {\r |
619 | EFI_HOB_GUID_TYPE *GuidHob;\r | |
620 | VOID *Buffer;\r | |
621 | \r | |
622 | GuidHob = GetNextGuidHob (ProtocolGuid, mHobStart);\r | |
623 | if (GuidHob == NULL) {\r | |
624 | return EFI_NOT_FOUND;\r | |
625 | }\r | |
626 | \r | |
627 | Buffer = GET_GUID_HOB_DATA (GuidHob);\r | |
628 | ASSERT (Buffer != NULL);\r | |
629 | \r | |
630 | *Interface = (VOID *)(*(UINTN *)(Buffer));\r | |
631 | \r | |
632 | return EFI_SUCCESS;\r | |
633 | }\r | |
634 | \r | |
635 | \r | |
28a00297 | 636 | \r |
162ed594 | 637 | /**\r |
28a00297 | 638 | Calcualte the 32-bit CRC in a EFI table using the service provided by the\r |
639 | gRuntime service.\r | |
640 | \r | |
162ed594 | 641 | @param Hdr Pointer to an EFI standard header\r |
28a00297 | 642 | \r |
162ed594 | 643 | **/\r |
644 | VOID\r | |
645 | CalculateEfiHdrCrc (\r | |
646 | IN OUT EFI_TABLE_HEADER *Hdr\r | |
647 | )\r | |
28a00297 | 648 | {\r |
649 | UINT32 Crc;\r | |
650 | \r | |
651 | Hdr->CRC32 = 0;\r | |
652 | \r | |
653 | //\r | |
654 | // If gDxeCoreBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then\r | |
655 | // Crc will come back as zero if we set it to zero here\r | |
656 | //\r | |
657 | Crc = 0;\r | |
658 | gDxeCoreBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc);\r | |
659 | Hdr->CRC32 = Crc;\r | |
660 | }\r | |
661 | \r | |
662 | \r | |
663 | \r | |
162ed594 | 664 | \r |
665 | /**\r | |
666 | Terminates all boot services.\r | |
667 | \r | |
668 | @param ImageHandle Handle that identifies the exiting image. \r | |
669 | @param MapKey Key to the latest memory map.\r | |
670 | \r | |
671 | @retval EFI_SUCCESS Boot Services terminated \r | |
672 | @retval EFI_INVALID_PARAMETER MapKey is incorrect.\r | |
673 | \r | |
674 | **/\r | |
28a00297 | 675 | EFI_STATUS\r |
676 | EFIAPI\r | |
677 | CoreExitBootServices (\r | |
678 | IN EFI_HANDLE ImageHandle,\r | |
679 | IN UINTN MapKey\r | |
680 | )\r | |
28a00297 | 681 | {\r |
682 | EFI_STATUS Status;\r | |
822360ee LG |
683 | EFI_STATUS StatusTemp;\r |
684 | EFI_TCG_PLATFORM_PROTOCOL *TcgPlatformProtocol;\r | |
685 | \r | |
686 | //\r | |
687 | // Measure invocation of ExitBootServices, \r | |
688 | // which is defined by TCG_EFI_Platform_1_20_Final Specification\r | |
689 | //\r | |
690 | TcgPlatformProtocol = NULL;\r | |
691 | Status = CoreLocateProtocol (\r | |
692 | &gEfiTcgPlatformProtocolGuid,\r | |
693 | NULL,\r | |
694 | (VOID **) &TcgPlatformProtocol\r | |
695 | );\r | |
696 | if (!EFI_ERROR (Status)) {\r | |
697 | Status = TcgPlatformProtocol->MeasureAction (EFI_EXIT_BOOT_SERVICES_INVOCATION);\r | |
698 | ASSERT_EFI_ERROR (Status);\r | |
699 | }\r | |
28a00297 | 700 | \r |
701 | //\r | |
702 | // Terminate memory services if the MapKey matches\r | |
703 | //\r | |
704 | Status = CoreTerminateMemoryMap (MapKey);\r | |
705 | if (EFI_ERROR (Status)) {\r | |
822360ee LG |
706 | //\r |
707 | // Measure failure of ExitBootServices\r | |
708 | //\r | |
709 | if (TcgPlatformProtocol != NULL) {\r | |
710 | StatusTemp = TcgPlatformProtocol->MeasureAction (EFI_EXIT_BOOT_SERVICES_FAILED);\r | |
711 | ASSERT_EFI_ERROR (StatusTemp);\r | |
712 | }\r | |
713 | \r | |
28a00297 | 714 | return Status;\r |
715 | }\r | |
716 | \r | |
717 | //\r | |
718 | // Notify other drivers that we are exiting boot services.\r | |
719 | //\r | |
720 | CoreNotifySignalList (&gEfiEventExitBootServicesGuid);\r | |
721 | \r | |
722 | //\r | |
723 | // Disable Timer\r | |
724 | //\r | |
725 | gTimer->SetTimerPeriod (gTimer, 0);\r | |
726 | \r | |
727 | //\r | |
728 | // Disable CPU Interrupts\r | |
729 | //\r | |
730 | gCpu->DisableInterrupt (gCpu);\r | |
731 | \r | |
732 | //\r | |
733 | // Report that ExitBootServices() has been called\r | |
734 | //\r | |
eba54e17 | 735 | // We are using gEfiCallerIdGuid as the caller ID for Dxe Core\r |
28a00297 | 736 | //\r |
797a9d67 | 737 | CoreReportProgressCode (FixedPcdGet32 (PcdStatusCodeValueBootServiceExit));\r |
28a00297 | 738 | \r |
739 | //\r | |
740 | // Clear the non-runtime values of the EFI System Table\r | |
741 | //\r | |
742 | gDxeCoreST->BootServices = NULL;\r | |
743 | gDxeCoreST->ConIn = NULL;\r | |
744 | gDxeCoreST->ConsoleInHandle = NULL;\r | |
745 | gDxeCoreST->ConOut = NULL;\r | |
746 | gDxeCoreST->ConsoleOutHandle = NULL;\r | |
747 | gDxeCoreST->StdErr = NULL;\r | |
748 | gDxeCoreST->StandardErrorHandle = NULL;\r | |
749 | \r | |
750 | //\r | |
751 | // Recompute the 32-bit CRC of the EFI System Table\r | |
752 | //\r | |
753 | CalculateEfiHdrCrc (&gDxeCoreST->Hdr);\r | |
754 | \r | |
755 | //\r | |
756 | // Zero out the Boot Service Table\r | |
757 | //\r | |
758 | SetMem (gDxeCoreBS, sizeof (EFI_BOOT_SERVICES), 0);\r | |
759 | gDxeCoreBS = NULL;\r | |
760 | \r | |
761 | //\r | |
762 | // Update the AtRuntime field in Runtiem AP.\r | |
763 | //\r | |
764 | gRuntime->AtRuntime = TRUE;\r | |
765 | \r | |
822360ee LG |
766 | //\r |
767 | // Measure success of ExitBootServices\r | |
768 | //\r | |
769 | if (TcgPlatformProtocol != NULL) {\r | |
770 | StatusTemp = TcgPlatformProtocol->MeasureAction (EFI_EXIT_BOOT_SERVICES_SUCCEEDED);\r | |
771 | ASSERT_EFI_ERROR (StatusTemp);\r | |
772 | }\r | |
773 | \r | |
28a00297 | 774 | return Status;\r |
775 | }\r | |
776 | \r | |
162ed594 | 777 | \r |
778 | /**\r | |
779 | Given a compressed source buffer, this function retrieves the size of the\r | |
780 | uncompressed buffer and the size of the scratch buffer required to decompress\r | |
781 | the compressed source buffer.\r | |
782 | \r | |
783 | The GetInfo() function retrieves the size of the uncompressed buffer and the\r | |
784 | temporary scratch buffer required to decompress the buffer specified by Source\r | |
785 | and SourceSize. If the size of the uncompressed buffer or the size of the\r | |
786 | scratch buffer cannot be determined from the compressed data specified by\r | |
787 | Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the\r | |
788 | size of the uncompressed buffer is returned in DestinationSize, the size of\r | |
789 | the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.\r | |
790 | The GetInfo() function does not have scratch buffer available to perform a\r | |
791 | thorough checking of the validity of the source data. It just retrieves the\r | |
792 | "Original Size" field from the beginning bytes of the source data and output\r | |
793 | it as DestinationSize. And ScratchSize is specific to the decompression\r | |
794 | implementation.\r | |
795 | \r | |
796 | @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.\r | |
797 | @param Source The source buffer containing the compressed data.\r | |
798 | @param SourceSize The size, in bytes, of the source buffer.\r | |
799 | @param DestinationSize A pointer to the size, in bytes, of the\r | |
800 | uncompressed buffer that will be generated when the\r | |
801 | compressed buffer specified by Source and\r | |
802 | SourceSize is decompressed.\r | |
803 | @param ScratchSize A pointer to the size, in bytes, of the scratch\r | |
804 | buffer that is required to decompress the\r | |
805 | compressed buffer specified by Source and\r | |
806 | SourceSize.\r | |
807 | \r | |
808 | @retval EFI_SUCCESS The size of the uncompressed data was returned in\r | |
809 | DestinationSize and the size of the scratch buffer\r | |
810 | was returned in ScratchSize.\r | |
811 | @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of\r | |
812 | the scratch buffer cannot be determined from the\r | |
813 | compressed data specified by Source and\r | |
814 | SourceSize.\r | |
815 | \r | |
816 | **/\r | |
28a00297 | 817 | EFI_STATUS\r |
162ed594 | 818 | EFIAPI\r |
28a00297 | 819 | DxeMainUefiDecompressGetInfo (\r |
820 | IN EFI_DECOMPRESS_PROTOCOL *This,\r | |
821 | IN VOID *Source,\r | |
822 | IN UINT32 SourceSize,\r | |
823 | OUT UINT32 *DestinationSize,\r | |
824 | OUT UINT32 *ScratchSize\r | |
825 | )\r | |
826 | {\r | |
827 | if (Source == NULL \r | |
828 | || DestinationSize == NULL \r | |
829 | || ScratchSize == NULL) {\r | |
830 | return EFI_INVALID_PARAMETER;\r | |
831 | }\r | |
832 | return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r | |
833 | }\r | |
834 | \r | |
162ed594 | 835 | \r |
836 | /**\r | |
837 | Decompresses a compressed source buffer.\r | |
838 | \r | |
839 | The Decompress() function extracts decompressed data to its original form.\r | |
840 | This protocol is designed so that the decompression algorithm can be\r | |
841 | implemented without using any memory services. As a result, the Decompress()\r | |
842 | Function is not allowed to call AllocatePool() or AllocatePages() in its\r | |
db405d1b | 843 | implementation. It is the caller's responsibility to allocate and free the\r |
162ed594 | 844 | Destination and Scratch buffers.\r |
845 | If the compressed source data specified by Source and SourceSize is\r | |
846 | sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If\r | |
847 | the compressed source data specified by Source and SourceSize is not in a\r | |
848 | valid compressed data format, then EFI_INVALID_PARAMETER is returned.\r | |
849 | \r | |
850 | @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.\r | |
851 | @param Source The source buffer containing the compressed data.\r | |
852 | @param SourceSize SourceSizeThe size of source data.\r | |
853 | @param Destination On output, the destination buffer that contains\r | |
854 | the uncompressed data.\r | |
855 | @param DestinationSize The size of the destination buffer. The size of\r | |
856 | the destination buffer needed is obtained from\r | |
857 | EFI_DECOMPRESS_PROTOCOL.GetInfo().\r | |
858 | @param Scratch A temporary scratch buffer that is used to perform\r | |
859 | the decompression.\r | |
860 | @param ScratchSize The size of scratch buffer. The size of the\r | |
861 | scratch buffer needed is obtained from GetInfo().\r | |
862 | \r | |
863 | @retval EFI_SUCCESS Decompression completed successfully, and the\r | |
864 | uncompressed buffer is returned in Destination.\r | |
865 | @retval EFI_INVALID_PARAMETER The source buffer specified by Source and\r | |
866 | SourceSize is corrupted (not in a valid\r | |
867 | compressed format).\r | |
868 | \r | |
869 | **/\r | |
28a00297 | 870 | EFI_STATUS\r |
871 | EFIAPI\r | |
872 | DxeMainUefiDecompress (\r | |
873 | IN EFI_DECOMPRESS_PROTOCOL *This,\r | |
874 | IN VOID *Source,\r | |
875 | IN UINT32 SourceSize,\r | |
876 | IN OUT VOID *Destination,\r | |
877 | IN UINT32 DestinationSize,\r | |
878 | IN OUT VOID *Scratch,\r | |
879 | IN UINT32 ScratchSize\r | |
880 | )\r | |
881 | {\r | |
882 | EFI_STATUS Status;\r | |
883 | UINT32 TestDestinationSize;\r | |
884 | UINT32 TestScratchSize;\r | |
885 | \r | |
886 | if (Source == NULL \r | |
887 | || Destination== NULL \r | |
888 | || Scratch == NULL) {\r | |
889 | return EFI_INVALID_PARAMETER;\r | |
890 | }\r | |
891 | \r | |
892 | Status = UefiDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize);\r | |
893 | if (EFI_ERROR (Status)) {\r | |
894 | return Status;\r | |
895 | }\r | |
896 | \r | |
897 | if (ScratchSize < TestScratchSize || DestinationSize < TestDestinationSize) {\r | |
898 | return RETURN_INVALID_PARAMETER;\r | |
899 | }\r | |
900 | \r | |
901 | return UefiDecompress (Source, Destination, Scratch);\r | |
902 | }\r |