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