]>
Commit | Line | Data |
---|---|---|
31f228cf | 1 | /** @file\r |
2 | DXE Core Main Entry Point\r | |
3 | \r | |
bce776a5 | 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
31f228cf | 6 | \r |
7 | **/\r | |
8 | \r | |
9 | #include "DxeMain.h"\r | |
10 | \r | |
11 | //\r | |
12 | // DXE Core Global Variables for Protocols from PEI\r | |
13 | //\r | |
1436aea4 | 14 | EFI_HANDLE mDecompressHandle = NULL;\r |
31f228cf | 15 | \r |
16 | //\r | |
17 | // DXE Core globals for Architecture Protocols\r | |
18 | //\r | |
19 | EFI_SECURITY_ARCH_PROTOCOL *gSecurity = NULL;\r | |
bc2dfdbc | 20 | EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2 = NULL;\r |
31f228cf | 21 | EFI_CPU_ARCH_PROTOCOL *gCpu = NULL;\r |
22 | EFI_METRONOME_ARCH_PROTOCOL *gMetronome = NULL;\r | |
23 | EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL;\r | |
24 | EFI_BDS_ARCH_PROTOCOL *gBds = NULL;\r | |
25 | EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL;\r | |
26 | \r | |
0803854b | 27 | //\r |
28 | // DXE Core globals for optional protocol dependencies\r | |
29 | //\r | |
1436aea4 | 30 | EFI_SMM_BASE2_PROTOCOL *gSmmBase2 = NULL;\r |
0803854b | 31 | \r |
31f228cf | 32 | //\r |
33 | // DXE Core Global used to update core loaded image protocol handle\r | |
34 | //\r | |
1436aea4 MK |
35 | EFI_GUID *gDxeCoreFileName;\r |
36 | EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;\r | |
31f228cf | 37 | \r |
38 | //\r | |
39 | // DXE Core Module Variables\r | |
40 | //\r | |
1436aea4 | 41 | EFI_BOOT_SERVICES mBootServices = {\r |
31f228cf | 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 | |
1436aea4 MK |
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 | |
31f228cf | 93 | };\r |
94 | \r | |
1436aea4 | 95 | EFI_DXE_SERVICES mDxeServices = {\r |
31f228cf | 96 | {\r |
97 | DXE_SERVICES_SIGNATURE, // Signature\r | |
98 | DXE_SERVICES_REVISION, // Revision\r | |
99 | sizeof (DXE_SERVICES), // HeaderSize\r | |
1436aea4 MK |
100 | 0, // CRC32\r |
101 | 0 // Reserved\r | |
31f228cf | 102 | },\r |
1436aea4 MK |
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 | |
771ee501 | 120 | (EFI_SET_MEMORY_SPACE_CAPABILITIES)CoreSetMemorySpaceCapabilities, // SetMemorySpaceCapabilities\r |
31f228cf | 121 | };\r |
122 | \r | |
1436aea4 | 123 | EFI_SYSTEM_TABLE mEfiSystemTableTemplate = {\r |
31f228cf | 124 | {\r |
125 | EFI_SYSTEM_TABLE_SIGNATURE, // Signature\r | |
126 | EFI_SYSTEM_TABLE_REVISION, // Revision\r | |
127 | sizeof (EFI_SYSTEM_TABLE), // HeaderSize\r | |
128 | 0, // CRC32\r | |
129 | 0 // Reserved\r | |
130 | },\r | |
131 | NULL, // FirmwareVendor\r | |
132 | 0, // FirmwareRevision\r | |
133 | NULL, // ConsoleInHandle\r | |
134 | NULL, // ConIn\r | |
135 | NULL, // ConsoleOutHandle\r | |
136 | NULL, // ConOut\r | |
137 | NULL, // StandardErrorHandle\r | |
138 | NULL, // StdErr\r | |
139 | NULL, // RuntimeServices\r | |
140 | &mBootServices, // BootServices\r | |
141 | 0, // NumberOfConfigurationTableEntries\r | |
142 | NULL // ConfigurationTable\r | |
143 | };\r | |
144 | \r | |
1436aea4 | 145 | EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = {\r |
31f228cf | 146 | {\r |
147 | EFI_RUNTIME_SERVICES_SIGNATURE, // Signature\r | |
148 | EFI_RUNTIME_SERVICES_REVISION, // Revision\r | |
149 | sizeof (EFI_RUNTIME_SERVICES), // HeaderSize\r | |
150 | 0, // CRC32\r | |
151 | 0 // Reserved\r | |
152 | },\r | |
1436aea4 MK |
153 | (EFI_GET_TIME)CoreEfiNotAvailableYetArg2, // GetTime\r |
154 | (EFI_SET_TIME)CoreEfiNotAvailableYetArg1, // SetTime\r | |
155 | (EFI_GET_WAKEUP_TIME)CoreEfiNotAvailableYetArg3, // GetWakeupTime\r | |
156 | (EFI_SET_WAKEUP_TIME)CoreEfiNotAvailableYetArg2, // SetWakeupTime\r | |
157 | (EFI_SET_VIRTUAL_ADDRESS_MAP)CoreEfiNotAvailableYetArg4, // SetVirtualAddressMap\r | |
158 | (EFI_CONVERT_POINTER)CoreEfiNotAvailableYetArg2, // ConvertPointer\r | |
159 | (EFI_GET_VARIABLE)CoreEfiNotAvailableYetArg5, // GetVariable\r | |
160 | (EFI_GET_NEXT_VARIABLE_NAME)CoreEfiNotAvailableYetArg3, // GetNextVariableName\r | |
161 | (EFI_SET_VARIABLE)CoreEfiNotAvailableYetArg5, // SetVariable\r | |
162 | (EFI_GET_NEXT_HIGH_MONO_COUNT)CoreEfiNotAvailableYetArg1, // GetNextHighMonotonicCount\r | |
163 | (EFI_RESET_SYSTEM)CoreEfiNotAvailableYetArg4, // ResetSystem\r | |
164 | (EFI_UPDATE_CAPSULE)CoreEfiNotAvailableYetArg3, // UpdateCapsule\r | |
165 | (EFI_QUERY_CAPSULE_CAPABILITIES)CoreEfiNotAvailableYetArg4, // QueryCapsuleCapabilities\r | |
166 | (EFI_QUERY_VARIABLE_INFO)CoreEfiNotAvailableYetArg4 // QueryVariableInfo\r | |
31f228cf | 167 | };\r |
168 | \r | |
1436aea4 | 169 | EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate = {\r |
31f228cf | 170 | INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.ImageHead),\r |
171 | INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.EventHead),\r | |
172 | \r | |
173 | //\r | |
174 | // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will\r | |
175 | // prevent people from having pointer math bugs in their code.\r | |
176 | // now you have to use *DescriptorSize to make things work.\r | |
177 | //\r | |
178 | sizeof (EFI_MEMORY_DESCRIPTOR) + sizeof (UINT64) - (sizeof (EFI_MEMORY_DESCRIPTOR) % sizeof (UINT64)),\r | |
179 | EFI_MEMORY_DESCRIPTOR_VERSION,\r | |
180 | 0,\r | |
181 | NULL,\r | |
182 | NULL,\r | |
183 | FALSE,\r | |
184 | FALSE\r | |
185 | };\r | |
186 | \r | |
1436aea4 | 187 | EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = &gRuntimeTemplate;\r |
31f228cf | 188 | \r |
189 | //\r | |
190 | // DXE Core Global Variables for the EFI System Table, Boot Services Table,\r | |
191 | // DXE Services Table, and Runtime Services Table\r | |
192 | //\r | |
1436aea4 MK |
193 | EFI_DXE_SERVICES *gDxeCoreDS = &mDxeServices;\r |
194 | EFI_SYSTEM_TABLE *gDxeCoreST = NULL;\r | |
31f228cf | 195 | \r |
196 | //\r | |
197 | // For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory\r | |
198 | // but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it\r | |
199 | // a value that will not cause debug infrastructure to crash early on.\r | |
200 | //\r | |
1436aea4 | 201 | EFI_RUNTIME_SERVICES *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate;\r |
31f228cf | 202 | EFI_HANDLE gDxeCoreImageHandle = NULL;\r |
203 | \r | |
1436aea4 | 204 | BOOLEAN gMemoryMapTerminated = FALSE;\r |
31f228cf | 205 | \r |
206 | //\r | |
207 | // EFI Decompress Protocol\r | |
208 | //\r | |
209 | EFI_DECOMPRESS_PROTOCOL gEfiDecompress = {\r | |
210 | DxeMainUefiDecompressGetInfo,\r | |
211 | DxeMainUefiDecompress\r | |
212 | };\r | |
213 | \r | |
214 | //\r | |
e7af83ae | 215 | // For Loading modules at fixed address feature, the configuration table is to cache the top address below which to load\r |
216 | // Runtime code&boot time code\r | |
54ea99a7 | 217 | //\r |
1436aea4 | 218 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable = { 0, 0 };\r |
54ea99a7 | 219 | \r |
31f228cf | 220 | // Main entry point to the DXE Core\r |
221 | //\r | |
222 | \r | |
223 | /**\r | |
224 | Main entry point to DXE Core.\r | |
225 | \r | |
226 | @param HobStart Pointer to the beginning of the HOB List from PEI.\r | |
227 | \r | |
228 | @return This function should never return.\r | |
229 | \r | |
230 | **/\r | |
231 | VOID\r | |
232 | EFIAPI\r | |
233 | DxeMain (\r | |
1436aea4 | 234 | IN VOID *HobStart\r |
31f228cf | 235 | )\r |
236 | {\r | |
d0d41b52 | 237 | EFI_STATUS Status;\r |
238 | EFI_PHYSICAL_ADDRESS MemoryBaseAddress;\r | |
239 | UINT64 MemoryLength;\r | |
240 | PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;\r | |
57f360f2 JF |
241 | UINTN Index;\r |
242 | EFI_HOB_GUID_TYPE *GuidHob;\r | |
243 | EFI_VECTOR_HANDOFF_INFO *VectorInfoList;\r | |
244 | EFI_VECTOR_HANDOFF_INFO *VectorInfo;\r | |
1cf4e933 | 245 | VOID *EntryPoint;\r |
31f228cf | 246 | \r |
1e172d6b | 247 | //\r |
248 | // Setup the default exception handlers\r | |
249 | //\r | |
57f360f2 | 250 | VectorInfoList = NULL;\r |
1436aea4 | 251 | GuidHob = GetNextGuidHob (&gEfiVectorHandoffInfoPpiGuid, HobStart);\r |
57f360f2 | 252 | if (GuidHob != NULL) {\r |
1436aea4 | 253 | VectorInfoList = (EFI_VECTOR_HANDOFF_INFO *)(GET_GUID_HOB_DATA (GuidHob));\r |
57f360f2 | 254 | }\r |
1436aea4 | 255 | \r |
e7abb94d | 256 | Status = InitializeCpuExceptionHandlers (VectorInfoList);\r |
57f360f2 | 257 | ASSERT_EFI_ERROR (Status);\r |
d1102dba | 258 | \r |
e7af83ae | 259 | //\r |
260 | // Initialize Debug Agent to support source level debug in DXE phase\r | |
261 | //\r | |
4cf7e038 | 262 | InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_CORE, HobStart, NULL);\r |
e7af83ae | 263 | \r |
31f228cf | 264 | //\r |
265 | // Initialize Memory Services\r | |
266 | //\r | |
267 | CoreInitializeMemoryServices (&HobStart, &MemoryBaseAddress, &MemoryLength);\r | |
268 | \r | |
84edd20b SZ |
269 | MemoryProfileInit (HobStart);\r |
270 | \r | |
31f228cf | 271 | //\r |
272 | // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData\r | |
273 | // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table\r | |
274 | //\r | |
275 | gDxeCoreST = AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);\r | |
276 | ASSERT (gDxeCoreST != NULL);\r | |
277 | \r | |
278 | gDxeCoreRT = AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);\r | |
279 | ASSERT (gDxeCoreRT != NULL);\r | |
280 | \r | |
281 | gDxeCoreST->RuntimeServices = gDxeCoreRT;\r | |
282 | \r | |
283 | //\r | |
284 | // Start the Image Services.\r | |
285 | //\r | |
286 | Status = CoreInitializeImageServices (HobStart);\r | |
287 | ASSERT_EFI_ERROR (Status);\r | |
288 | \r | |
31f228cf | 289 | //\r |
290 | // Initialize the Global Coherency Domain Services\r | |
291 | //\r | |
292 | Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength);\r | |
293 | ASSERT_EFI_ERROR (Status);\r | |
294 | \r | |
c5d53799 SZ |
295 | //\r |
296 | // Call constructor for all libraries\r | |
297 | //\r | |
298 | ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST);\r | |
1436aea4 | 299 | PERF_CROSSMODULE_END ("PEI");\r |
67e9ab84 | 300 | PERF_CROSSMODULE_BEGIN ("DXE");\r |
c5d53799 | 301 | \r |
1366cd58 LE |
302 | //\r |
303 | // Log MemoryBaseAddress and MemoryLength again (from\r | |
304 | // CoreInitializeMemoryServices()), now that library constructors have\r | |
305 | // executed.\r | |
306 | //\r | |
1436aea4 MK |
307 | DEBUG ((\r |
308 | DEBUG_INFO,\r | |
309 | "%a: MemoryBaseAddress=0x%Lx MemoryLength=0x%Lx\n",\r | |
310 | __FUNCTION__,\r | |
311 | MemoryBaseAddress,\r | |
312 | MemoryLength\r | |
313 | ));\r | |
1366cd58 | 314 | \r |
31ffa077 SZ |
315 | //\r |
316 | // Report DXE Core image information to the PE/COFF Extra Action Library\r | |
317 | //\r | |
318 | ZeroMem (&ImageContext, sizeof (ImageContext));\r | |
1436aea4 MK |
319 | ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)gDxeCoreLoadedImage->ImageBase;\r |
320 | ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID *)(UINTN)ImageContext.ImageAddress);\r | |
321 | ImageContext.SizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)ImageContext.ImageAddress);\r | |
322 | Status = PeCoffLoaderGetEntryPoint ((VOID *)(UINTN)ImageContext.ImageAddress, &EntryPoint);\r | |
31ffa077 SZ |
323 | if (Status == EFI_SUCCESS) {\r |
324 | ImageContext.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint;\r | |
325 | }\r | |
1436aea4 MK |
326 | \r |
327 | ImageContext.Handle = (VOID *)(UINTN)gDxeCoreLoadedImage->ImageBase;\r | |
328 | ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;\r | |
31ffa077 SZ |
329 | PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r |
330 | \r | |
31f228cf | 331 | //\r |
332 | // Install the DXE Services Table into the EFI System Tables's Configuration Table\r | |
333 | //\r | |
334 | Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDxeCoreDS);\r | |
335 | ASSERT_EFI_ERROR (Status);\r | |
336 | \r | |
337 | //\r | |
338 | // Install the HOB List into the EFI System Tables's Configuration Table\r | |
339 | //\r | |
340 | Status = CoreInstallConfigurationTable (&gEfiHobListGuid, HobStart);\r | |
341 | ASSERT_EFI_ERROR (Status);\r | |
342 | \r | |
343 | //\r | |
344 | // Install Memory Type Information Table into the EFI System Tables's Configuration Table\r | |
345 | //\r | |
346 | Status = CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid, &gMemoryTypeInformation);\r | |
347 | ASSERT_EFI_ERROR (Status);\r | |
e7af83ae | 348 | \r |
54ea99a7 | 349 | //\r |
e7af83ae | 350 | // If Loading modules At fixed address feature is enabled, install Load moduels at fixed address\r |
54ea99a7 | 351 | // Configuration Table so that user could easily to retrieve the top address to load Dxe and PEI\r |
e7af83ae | 352 | // Code and Tseg base to load SMM driver.\r |
54ea99a7 | 353 | //\r |
1436aea4 | 354 | if (PcdGet64 (PcdLoadModuleAtFixAddressEnable) != 0) {\r |
54ea99a7 | 355 | Status = CoreInstallConfigurationTable (&gLoadFixedAddressConfigurationTableGuid, &gLoadModuleAtFixAddressConfigurationTable);\r |
356 | ASSERT_EFI_ERROR (Status);\r | |
357 | }\r | |
1436aea4 | 358 | \r |
31f228cf | 359 | //\r |
360 | // Report Status Code here for DXE_ENTRY_POINT once it is available\r | |
361 | //\r | |
362 | REPORT_STATUS_CODE (\r | |
363 | EFI_PROGRESS_CODE,\r | |
f9876ecf | 364 | (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_ENTRY_POINT)\r |
31f228cf | 365 | );\r |
366 | \r | |
367 | //\r | |
368 | // Create the aligned system table pointer structure that is used by external\r | |
369 | // debuggers to locate the system table... Also, install debug image info\r | |
370 | // configuration table.\r | |
371 | //\r | |
372 | CoreInitializeDebugImageInfoTable ();\r | |
373 | CoreNewDebugImageInfoEntry (\r | |
374 | EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,\r | |
375 | gDxeCoreLoadedImage,\r | |
376 | gDxeCoreImageHandle\r | |
377 | );\r | |
378 | \r | |
379 | DEBUG ((DEBUG_INFO | DEBUG_LOAD, "HOBLIST address in DXE = 0x%p\n", HobStart));\r | |
380 | \r | |
381 | DEBUG_CODE_BEGIN ();\r | |
1436aea4 MK |
382 | EFI_PEI_HOB_POINTERS Hob;\r |
383 | \r | |
384 | for (Hob.Raw = HobStart; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {\r | |
385 | if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r | |
386 | DEBUG ((\r | |
387 | DEBUG_INFO | DEBUG_LOAD,\r | |
388 | "Memory Allocation 0x%08x 0x%0lx - 0x%0lx\n", \\r | |
389 | Hob.MemoryAllocation->AllocDescriptor.MemoryType, \\r | |
390 | Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress, \\r | |
391 | Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress + Hob.MemoryAllocation->AllocDescriptor.MemoryLength - 1\r | |
392 | ));\r | |
31f228cf | 393 | }\r |
1436aea4 MK |
394 | }\r |
395 | \r | |
396 | for (Hob.Raw = HobStart; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {\r | |
397 | if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV) {\r | |
398 | DEBUG ((\r | |
399 | DEBUG_INFO | DEBUG_LOAD,\r | |
400 | "FV Hob 0x%0lx - 0x%0lx\n",\r | |
401 | Hob.FirmwareVolume->BaseAddress,\r | |
402 | Hob.FirmwareVolume->BaseAddress + Hob.FirmwareVolume->Length - 1\r | |
403 | ));\r | |
404 | } else if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV2) {\r | |
405 | DEBUG ((\r | |
406 | DEBUG_INFO | DEBUG_LOAD,\r | |
407 | "FV2 Hob 0x%0lx - 0x%0lx\n",\r | |
408 | Hob.FirmwareVolume2->BaseAddress,\r | |
409 | Hob.FirmwareVolume2->BaseAddress + Hob.FirmwareVolume2->Length - 1\r | |
410 | ));\r | |
411 | DEBUG ((\r | |
412 | DEBUG_INFO | DEBUG_LOAD,\r | |
413 | " %g - %g\n",\r | |
414 | &Hob.FirmwareVolume2->FvName,\r | |
415 | &Hob.FirmwareVolume2->FileName\r | |
416 | ));\r | |
417 | } else if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV3) {\r | |
418 | DEBUG ((\r | |
419 | DEBUG_INFO | DEBUG_LOAD,\r | |
420 | "FV3 Hob 0x%0lx - 0x%0lx - 0x%x - 0x%x\n",\r | |
421 | Hob.FirmwareVolume3->BaseAddress,\r | |
422 | Hob.FirmwareVolume3->BaseAddress + Hob.FirmwareVolume3->Length - 1,\r | |
423 | Hob.FirmwareVolume3->AuthenticationStatus,\r | |
424 | Hob.FirmwareVolume3->ExtractedFv\r | |
425 | ));\r | |
426 | if (Hob.FirmwareVolume3->ExtractedFv) {\r | |
c6037045 SZ |
427 | DEBUG ((\r |
428 | DEBUG_INFO | DEBUG_LOAD,\r | |
429 | " %g - %g\n",\r | |
1436aea4 MK |
430 | &Hob.FirmwareVolume3->FvName,\r |
431 | &Hob.FirmwareVolume3->FileName\r | |
c6037045 | 432 | ));\r |
31f228cf | 433 | }\r |
434 | }\r | |
1436aea4 MK |
435 | }\r |
436 | \r | |
31f228cf | 437 | DEBUG_CODE_END ();\r |
438 | \r | |
439 | //\r | |
440 | // Initialize the Event Services\r | |
441 | //\r | |
442 | Status = CoreInitializeEventServices ();\r | |
443 | ASSERT_EFI_ERROR (Status);\r | |
444 | \r | |
84edd20b SZ |
445 | MemoryProfileInstallProtocol ();\r |
446 | \r | |
a94d51bd | 447 | CoreInitializeMemoryAttributesTable ();\r |
d0e92aad | 448 | CoreInitializeMemoryProtection ();\r |
03d486b2 | 449 | \r |
57f360f2 JF |
450 | //\r |
451 | // Get persisted vector hand-off info from GUIDeed HOB again due to HobStart may be updated,\r | |
452 | // and install configuration table\r | |
453 | //\r | |
454 | GuidHob = GetNextGuidHob (&gEfiVectorHandoffInfoPpiGuid, HobStart);\r | |
455 | if (GuidHob != NULL) {\r | |
1436aea4 MK |
456 | VectorInfoList = (EFI_VECTOR_HANDOFF_INFO *)(GET_GUID_HOB_DATA (GuidHob));\r |
457 | VectorInfo = VectorInfoList;\r | |
458 | Index = 1;\r | |
57f360f2 | 459 | while (VectorInfo->Attribute != EFI_VECTOR_HANDOFF_LAST_ENTRY) {\r |
1436aea4 MK |
460 | VectorInfo++;\r |
461 | Index++;\r | |
57f360f2 | 462 | }\r |
1436aea4 MK |
463 | \r |
464 | VectorInfo = AllocateCopyPool (sizeof (EFI_VECTOR_HANDOFF_INFO) * Index, (VOID *)VectorInfoList);\r | |
57f360f2 | 465 | ASSERT (VectorInfo != NULL);\r |
1436aea4 | 466 | Status = CoreInstallConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID *)VectorInfo);\r |
57f360f2 JF |
467 | ASSERT_EFI_ERROR (Status);\r |
468 | }\r | |
31f228cf | 469 | \r |
470 | //\r | |
471 | // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs\r | |
472 | //\r | |
473 | // These Protocols are not architectural. This implementation is sharing code between\r | |
474 | // PEI and DXE in order to save FLASH space. These Protocols could also be implemented\r | |
475 | // as part of the DXE Core. However, that would also require the DXE Core to be ported\r | |
476 | // each time a different CPU is used, a different Decompression algorithm is used, or a\r | |
477 | // different Image type is used. By placing these Protocols in PEI, the DXE Core remains\r | |
478 | // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,\r | |
479 | // and from CPU to CPU.\r | |
480 | //\r | |
481 | \r | |
482 | //\r | |
483 | // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components\r | |
484 | //\r | |
485 | Status = CoreInstallMultipleProtocolInterfaces (\r | |
486 | &mDecompressHandle,\r | |
1436aea4 MK |
487 | &gEfiDecompressProtocolGuid,\r |
488 | &gEfiDecompress,\r | |
31f228cf | 489 | NULL\r |
490 | );\r | |
491 | ASSERT_EFI_ERROR (Status);\r | |
492 | \r | |
493 | //\r | |
494 | // Register for the GUIDs of the Architectural Protocols, so the rest of the\r | |
495 | // EFI Boot Services and EFI Runtime Services tables can be filled in.\r | |
74e44290 | 496 | // Also register for the GUIDs of optional protocols.\r |
31f228cf | 497 | //\r |
74e44290 | 498 | CoreNotifyOnProtocolInstallation ();\r |
31f228cf | 499 | \r |
500 | //\r | |
501 | // Produce Firmware Volume Protocols, one for each FV in the HOB list.\r | |
502 | //\r | |
503 | Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gDxeCoreST);\r | |
504 | ASSERT_EFI_ERROR (Status);\r | |
505 | \r | |
506 | Status = FwVolDriverInit (gDxeCoreImageHandle, gDxeCoreST);\r | |
507 | ASSERT_EFI_ERROR (Status);\r | |
508 | \r | |
509 | //\r | |
510 | // Produce the Section Extraction Protocol\r | |
511 | //\r | |
512 | Status = InitializeSectionExtraction (gDxeCoreImageHandle, gDxeCoreST);\r | |
513 | ASSERT_EFI_ERROR (Status);\r | |
514 | \r | |
515 | //\r | |
516 | // Initialize the DXE Dispatcher\r | |
517 | //\r | |
31f228cf | 518 | CoreInitializeDispatcher ();\r |
31f228cf | 519 | \r |
520 | //\r | |
521 | // Invoke the DXE Dispatcher\r | |
522 | //\r | |
31f228cf | 523 | CoreDispatcher ();\r |
31f228cf | 524 | \r |
525 | //\r | |
526 | // Display Architectural protocols that were not loaded if this is DEBUG build\r | |
527 | //\r | |
528 | DEBUG_CODE_BEGIN ();\r | |
1436aea4 | 529 | CoreDisplayMissingArchProtocols ();\r |
31f228cf | 530 | DEBUG_CODE_END ();\r |
531 | \r | |
532 | //\r | |
533 | // Display any drivers that were not dispatched because dependency expression\r | |
534 | // evaluated to false if this is a debug build\r | |
535 | //\r | |
536 | DEBUG_CODE_BEGIN ();\r | |
1436aea4 | 537 | CoreDisplayDiscoveredNotDispatched ();\r |
31f228cf | 538 | DEBUG_CODE_END ();\r |
539 | \r | |
540 | //\r | |
541 | // Assert if the Architectural Protocols are not present.\r | |
542 | //\r | |
37623a5c | 543 | Status = CoreAllEfiServicesAvailable ();\r |
1436aea4 | 544 | if (EFI_ERROR (Status)) {\r |
37623a5c | 545 | //\r |
546 | // Report Status code that some Architectural Protocols are not present.\r | |
547 | //\r | |
548 | REPORT_STATUS_CODE (\r | |
549 | EFI_ERROR_CODE | EFI_ERROR_MAJOR,\r | |
550 | (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_EC_NO_ARCH)\r | |
d1102dba | 551 | );\r |
37623a5c | 552 | }\r |
1436aea4 | 553 | \r |
37623a5c | 554 | ASSERT_EFI_ERROR (Status);\r |
31f228cf | 555 | \r |
556 | //\r | |
557 | // Report Status code before transfer control to BDS\r | |
558 | //\r | |
559 | REPORT_STATUS_CODE (\r | |
560 | EFI_PROGRESS_CODE,\r | |
f9876ecf | 561 | (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT)\r |
31f228cf | 562 | );\r |
563 | \r | |
564 | //\r | |
565 | // Transfer control to the BDS Architectural Protocol\r | |
566 | //\r | |
567 | gBds->Entry (gBds);\r | |
568 | \r | |
569 | //\r | |
570 | // BDS should never return\r | |
571 | //\r | |
572 | ASSERT (FALSE);\r | |
573 | CpuDeadLoop ();\r | |
3a7daf9e MH |
574 | \r |
575 | UNREACHABLE ();\r | |
31f228cf | 576 | }\r |
577 | \r | |
31f228cf | 578 | /**\r |
579 | Place holder function until all the Boot Services and Runtime Services are\r | |
580 | available.\r | |
581 | \r | |
582 | @param Arg1 Undefined\r | |
583 | \r | |
584 | @return EFI_NOT_AVAILABLE_YET\r | |
585 | \r | |
586 | **/\r | |
587 | EFI_STATUS\r | |
588 | EFIAPI\r | |
589 | CoreEfiNotAvailableYetArg1 (\r | |
1436aea4 | 590 | UINTN Arg1\r |
31f228cf | 591 | )\r |
592 | {\r | |
593 | //\r | |
594 | // This function should never be executed. If it does, then the architectural protocols\r | |
595 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r | |
596 | // DXE Core and all the Architectural Protocols are complete.\r | |
597 | //\r | |
598 | \r | |
599 | return EFI_NOT_AVAILABLE_YET;\r | |
600 | }\r | |
601 | \r | |
31f228cf | 602 | /**\r |
603 | Place holder function until all the Boot Services and Runtime Services are available.\r | |
604 | \r | |
605 | @param Arg1 Undefined\r | |
606 | @param Arg2 Undefined\r | |
607 | \r | |
608 | @return EFI_NOT_AVAILABLE_YET\r | |
609 | \r | |
610 | **/\r | |
611 | EFI_STATUS\r | |
612 | EFIAPI\r | |
613 | CoreEfiNotAvailableYetArg2 (\r | |
1436aea4 MK |
614 | UINTN Arg1,\r |
615 | UINTN Arg2\r | |
31f228cf | 616 | )\r |
617 | {\r | |
618 | //\r | |
619 | // This function should never be executed. If it does, then the architectural protocols\r | |
620 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r | |
621 | // DXE Core and all the Architectural Protocols are complete.\r | |
622 | //\r | |
623 | \r | |
624 | return EFI_NOT_AVAILABLE_YET;\r | |
625 | }\r | |
626 | \r | |
31f228cf | 627 | /**\r |
628 | Place holder function until all the Boot Services and Runtime Services are available.\r | |
629 | \r | |
630 | @param Arg1 Undefined\r | |
631 | @param Arg2 Undefined\r | |
632 | @param Arg3 Undefined\r | |
633 | \r | |
634 | @return EFI_NOT_AVAILABLE_YET\r | |
635 | \r | |
636 | **/\r | |
637 | EFI_STATUS\r | |
638 | EFIAPI\r | |
639 | CoreEfiNotAvailableYetArg3 (\r | |
1436aea4 MK |
640 | UINTN Arg1,\r |
641 | UINTN Arg2,\r | |
642 | UINTN Arg3\r | |
31f228cf | 643 | )\r |
644 | {\r | |
645 | //\r | |
646 | // This function should never be executed. If it does, then the architectural protocols\r | |
647 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r | |
648 | // DXE Core and all the Architectural Protocols are complete.\r | |
649 | //\r | |
650 | \r | |
651 | return EFI_NOT_AVAILABLE_YET;\r | |
652 | }\r | |
653 | \r | |
31f228cf | 654 | /**\r |
655 | Place holder function until all the Boot Services and Runtime Services are available.\r | |
656 | \r | |
657 | @param Arg1 Undefined\r | |
658 | @param Arg2 Undefined\r | |
659 | @param Arg3 Undefined\r | |
660 | @param Arg4 Undefined\r | |
661 | \r | |
662 | @return EFI_NOT_AVAILABLE_YET\r | |
663 | \r | |
664 | **/\r | |
665 | EFI_STATUS\r | |
666 | EFIAPI\r | |
667 | CoreEfiNotAvailableYetArg4 (\r | |
1436aea4 MK |
668 | UINTN Arg1,\r |
669 | UINTN Arg2,\r | |
670 | UINTN Arg3,\r | |
671 | UINTN Arg4\r | |
31f228cf | 672 | )\r |
673 | {\r | |
674 | //\r | |
675 | // This function should never be executed. If it does, then the architectural protocols\r | |
676 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r | |
677 | // DXE Core and all the Architectural Protocols are complete.\r | |
678 | //\r | |
679 | \r | |
680 | return EFI_NOT_AVAILABLE_YET;\r | |
681 | }\r | |
682 | \r | |
31f228cf | 683 | /**\r |
684 | Place holder function until all the Boot Services and Runtime Services are available.\r | |
685 | \r | |
686 | @param Arg1 Undefined\r | |
687 | @param Arg2 Undefined\r | |
688 | @param Arg3 Undefined\r | |
689 | @param Arg4 Undefined\r | |
690 | @param Arg5 Undefined\r | |
691 | \r | |
692 | @return EFI_NOT_AVAILABLE_YET\r | |
693 | \r | |
694 | **/\r | |
695 | EFI_STATUS\r | |
696 | EFIAPI\r | |
697 | CoreEfiNotAvailableYetArg5 (\r | |
1436aea4 MK |
698 | UINTN Arg1,\r |
699 | UINTN Arg2,\r | |
700 | UINTN Arg3,\r | |
701 | UINTN Arg4,\r | |
702 | UINTN Arg5\r | |
31f228cf | 703 | )\r |
704 | {\r | |
705 | //\r | |
706 | // This function should never be executed. If it does, then the architectural protocols\r | |
707 | // have not been designed correctly. The CpuBreakpoint () is commented out for now until the\r | |
708 | // DXE Core and all the Architectural Protocols are complete.\r | |
709 | //\r | |
710 | \r | |
711 | return EFI_NOT_AVAILABLE_YET;\r | |
712 | }\r | |
713 | \r | |
31f228cf | 714 | /**\r |
715 | Calcualte the 32-bit CRC in a EFI table using the service provided by the\r | |
716 | gRuntime service.\r | |
717 | \r | |
718 | @param Hdr Pointer to an EFI standard header\r | |
719 | \r | |
720 | **/\r | |
721 | VOID\r | |
722 | CalculateEfiHdrCrc (\r | |
1436aea4 | 723 | IN OUT EFI_TABLE_HEADER *Hdr\r |
31f228cf | 724 | )\r |
725 | {\r | |
1436aea4 | 726 | UINT32 Crc;\r |
31f228cf | 727 | \r |
728 | Hdr->CRC32 = 0;\r | |
729 | \r | |
730 | //\r | |
731 | // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then\r | |
732 | // Crc will come back as zero if we set it to zero here\r | |
733 | //\r | |
734 | Crc = 0;\r | |
735 | gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc);\r | |
736 | Hdr->CRC32 = Crc;\r | |
737 | }\r | |
738 | \r | |
31f228cf | 739 | /**\r |
740 | Terminates all boot services.\r | |
741 | \r | |
742 | @param ImageHandle Handle that identifies the exiting image.\r | |
743 | @param MapKey Key to the latest memory map.\r | |
744 | \r | |
745 | @retval EFI_SUCCESS Boot Services terminated\r | |
746 | @retval EFI_INVALID_PARAMETER MapKey is incorrect.\r | |
747 | \r | |
748 | **/\r | |
749 | EFI_STATUS\r | |
750 | EFIAPI\r | |
751 | CoreExitBootServices (\r | |
1436aea4 MK |
752 | IN EFI_HANDLE ImageHandle,\r |
753 | IN UINTN MapKey\r | |
31f228cf | 754 | )\r |
755 | {\r | |
1436aea4 | 756 | EFI_STATUS Status;\r |
31f228cf | 757 | \r |
785b5f5a | 758 | //\r |
759 | // Disable Timer\r | |
760 | //\r | |
761 | gTimer->SetTimerPeriod (gTimer, 0);\r | |
762 | \r | |
31f228cf | 763 | //\r |
764 | // Terminate memory services if the MapKey matches\r | |
765 | //\r | |
766 | Status = CoreTerminateMemoryMap (MapKey);\r | |
767 | if (EFI_ERROR (Status)) {\r | |
044824d9 | 768 | //\r |
d1102dba | 769 | // Notify other drivers that ExitBootServices fail\r |
044824d9 | 770 | //\r |
771 | CoreNotifySignalList (&gEventExitBootServicesFailedGuid);\r | |
31f228cf | 772 | return Status;\r |
773 | }\r | |
774 | \r | |
74a88770 SZ |
775 | gMemoryMapTerminated = TRUE;\r |
776 | \r | |
31f228cf | 777 | //\r |
778 | // Notify other drivers that we are exiting boot services.\r | |
779 | //\r | |
780 | CoreNotifySignalList (&gEfiEventExitBootServicesGuid);\r | |
781 | \r | |
e4c83a4f LG |
782 | //\r |
783 | // Report that ExitBootServices() has been called\r | |
784 | //\r | |
785 | REPORT_STATUS_CODE (\r | |
786 | EFI_PROGRESS_CODE,\r | |
787 | (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)\r | |
788 | );\r | |
789 | \r | |
1436aea4 | 790 | MemoryProtectionExitBootServicesCallback ();\r |
bce776a5 | 791 | \r |
213fecef | 792 | //\r |
793 | // Disable interrupt of Debug timer.\r | |
794 | //\r | |
795 | SaveAndSetDebugTimerInterrupt (FALSE);\r | |
796 | \r | |
31f228cf | 797 | //\r |
798 | // Disable CPU Interrupts\r | |
799 | //\r | |
800 | gCpu->DisableInterrupt (gCpu);\r | |
801 | \r | |
31f228cf | 802 | //\r |
803 | // Clear the non-runtime values of the EFI System Table\r | |
804 | //\r | |
805 | gDxeCoreST->BootServices = NULL;\r | |
806 | gDxeCoreST->ConIn = NULL;\r | |
807 | gDxeCoreST->ConsoleInHandle = NULL;\r | |
808 | gDxeCoreST->ConOut = NULL;\r | |
809 | gDxeCoreST->ConsoleOutHandle = NULL;\r | |
810 | gDxeCoreST->StdErr = NULL;\r | |
811 | gDxeCoreST->StandardErrorHandle = NULL;\r | |
812 | \r | |
813 | //\r | |
814 | // Recompute the 32-bit CRC of the EFI System Table\r | |
815 | //\r | |
816 | CalculateEfiHdrCrc (&gDxeCoreST->Hdr);\r | |
817 | \r | |
818 | //\r | |
819 | // Zero out the Boot Service Table\r | |
820 | //\r | |
821 | ZeroMem (gBS, sizeof (EFI_BOOT_SERVICES));\r | |
822 | gBS = NULL;\r | |
823 | \r | |
824 | //\r | |
825 | // Update the AtRuntime field in Runtiem AP.\r | |
826 | //\r | |
827 | gRuntime->AtRuntime = TRUE;\r | |
828 | \r | |
829 | return Status;\r | |
830 | }\r | |
831 | \r | |
31f228cf | 832 | /**\r |
833 | Given a compressed source buffer, this function retrieves the size of the\r | |
834 | uncompressed buffer and the size of the scratch buffer required to decompress\r | |
835 | the compressed source buffer.\r | |
836 | \r | |
837 | The GetInfo() function retrieves the size of the uncompressed buffer and the\r | |
838 | temporary scratch buffer required to decompress the buffer specified by Source\r | |
839 | and SourceSize. If the size of the uncompressed buffer or the size of the\r | |
840 | scratch buffer cannot be determined from the compressed data specified by\r | |
841 | Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the\r | |
842 | size of the uncompressed buffer is returned in DestinationSize, the size of\r | |
843 | the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.\r | |
844 | The GetInfo() function does not have scratch buffer available to perform a\r | |
845 | thorough checking of the validity of the source data. It just retrieves the\r | |
846 | "Original Size" field from the beginning bytes of the source data and output\r | |
847 | it as DestinationSize. And ScratchSize is specific to the decompression\r | |
848 | implementation.\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 The size, in bytes, of the source buffer.\r | |
853 | @param DestinationSize A pointer to the size, in bytes, of the\r | |
854 | uncompressed buffer that will be generated when the\r | |
855 | compressed buffer specified by Source and\r | |
856 | SourceSize is decompressed.\r | |
857 | @param ScratchSize A pointer to the size, in bytes, of the scratch\r | |
858 | buffer that is required to decompress the\r | |
859 | compressed buffer specified by Source and\r | |
860 | SourceSize.\r | |
861 | \r | |
862 | @retval EFI_SUCCESS The size of the uncompressed data was returned in\r | |
863 | DestinationSize and the size of the scratch buffer\r | |
864 | was returned in ScratchSize.\r | |
865 | @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of\r | |
866 | the scratch buffer cannot be determined from the\r | |
867 | compressed data specified by Source and\r | |
868 | SourceSize.\r | |
869 | \r | |
870 | **/\r | |
871 | EFI_STATUS\r | |
872 | EFIAPI\r | |
873 | DxeMainUefiDecompressGetInfo (\r | |
1436aea4 MK |
874 | IN EFI_DECOMPRESS_PROTOCOL *This,\r |
875 | IN VOID *Source,\r | |
876 | IN UINT32 SourceSize,\r | |
877 | OUT UINT32 *DestinationSize,\r | |
878 | OUT UINT32 *ScratchSize\r | |
31f228cf | 879 | )\r |
880 | {\r | |
1436aea4 | 881 | if ((Source == NULL) || (DestinationSize == NULL) || (ScratchSize == NULL)) {\r |
31f228cf | 882 | return EFI_INVALID_PARAMETER;\r |
883 | }\r | |
1436aea4 | 884 | \r |
31f228cf | 885 | return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);\r |
886 | }\r | |
887 | \r | |
31f228cf | 888 | /**\r |
889 | Decompresses a compressed source buffer.\r | |
890 | \r | |
891 | The Decompress() function extracts decompressed data to its original form.\r | |
892 | This protocol is designed so that the decompression algorithm can be\r | |
893 | implemented without using any memory services. As a result, the Decompress()\r | |
894 | Function is not allowed to call AllocatePool() or AllocatePages() in its\r | |
895 | implementation. It is the caller's responsibility to allocate and free the\r | |
896 | Destination and Scratch buffers.\r | |
897 | If the compressed source data specified by Source and SourceSize is\r | |
93e8d03c | 898 | successfully decompressed into Destination, then EFI_SUCCESS is returned. If\r |
31f228cf | 899 | the compressed source data specified by Source and SourceSize is not in a\r |
900 | valid compressed data format, then EFI_INVALID_PARAMETER is returned.\r | |
901 | \r | |
902 | @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.\r | |
903 | @param Source The source buffer containing the compressed data.\r | |
904 | @param SourceSize SourceSizeThe size of source data.\r | |
905 | @param Destination On output, the destination buffer that contains\r | |
906 | the uncompressed data.\r | |
907 | @param DestinationSize The size of the destination buffer. The size of\r | |
908 | the destination buffer needed is obtained from\r | |
909 | EFI_DECOMPRESS_PROTOCOL.GetInfo().\r | |
910 | @param Scratch A temporary scratch buffer that is used to perform\r | |
911 | the decompression.\r | |
912 | @param ScratchSize The size of scratch buffer. The size of the\r | |
913 | scratch buffer needed is obtained from GetInfo().\r | |
914 | \r | |
915 | @retval EFI_SUCCESS Decompression completed successfully, and the\r | |
916 | uncompressed buffer is returned in Destination.\r | |
917 | @retval EFI_INVALID_PARAMETER The source buffer specified by Source and\r | |
918 | SourceSize is corrupted (not in a valid\r | |
919 | compressed format).\r | |
920 | \r | |
921 | **/\r | |
922 | EFI_STATUS\r | |
923 | EFIAPI\r | |
924 | DxeMainUefiDecompress (\r | |
1436aea4 MK |
925 | IN EFI_DECOMPRESS_PROTOCOL *This,\r |
926 | IN VOID *Source,\r | |
927 | IN UINT32 SourceSize,\r | |
928 | IN OUT VOID *Destination,\r | |
929 | IN UINT32 DestinationSize,\r | |
930 | IN OUT VOID *Scratch,\r | |
931 | IN UINT32 ScratchSize\r | |
31f228cf | 932 | )\r |
933 | {\r | |
934 | EFI_STATUS Status;\r | |
935 | UINT32 TestDestinationSize;\r | |
936 | UINT32 TestScratchSize;\r | |
937 | \r | |
1436aea4 | 938 | if ((Source == NULL) || (Destination == NULL) || (Scratch == NULL)) {\r |
31f228cf | 939 | return EFI_INVALID_PARAMETER;\r |
940 | }\r | |
941 | \r | |
942 | Status = UefiDecompressGetInfo (Source, SourceSize, &TestDestinationSize, &TestScratchSize);\r | |
943 | if (EFI_ERROR (Status)) {\r | |
944 | return Status;\r | |
945 | }\r | |
946 | \r | |
1436aea4 | 947 | if ((ScratchSize < TestScratchSize) || (DestinationSize < TestDestinationSize)) {\r |
31f228cf | 948 | return RETURN_INVALID_PARAMETER;\r |
949 | }\r | |
950 | \r | |
951 | return UefiDecompress (Source, Destination, Scratch);\r | |
952 | }\r |