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