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