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