]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg/DxeCore: Add UEFI image protection.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / DxeMain.h
CommitLineData
162ed594 1/** @file\r
504214c4
LG
2 The internal header file includes the common header files, defines\r
3 internal structure and functions used by DxeCore module.\r
23c98c94 4\r
ac72474d 5Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 6This program and the accompanying materials\r
23c98c94 7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
28a00297 13\r
797a9d67 14**/\r
28a00297 15\r
16#ifndef _DXE_MAIN_H_\r
17#define _DXE_MAIN_H_\r
18\r
19\r
ed7748fe 20\r
28a00297 21#include <PiDxe.h>\r
ed7748fe 22\r
28a00297 23#include <Protocol/LoadedImage.h>\r
24#include <Protocol/GuidedSectionExtraction.h>\r
28a00297 25#include <Protocol/DevicePath.h>\r
26#include <Protocol/Runtime.h>\r
27#include <Protocol/LoadFile.h>\r
0a9fe763 28#include <Protocol/LoadFile2.h>\r
28a00297 29#include <Protocol/DriverBinding.h>\r
30#include <Protocol/VariableWrite.h>\r
31#include <Protocol/PlatformDriverOverride.h>\r
32#include <Protocol/Variable.h>\r
28a00297 33#include <Protocol/Timer.h>\r
34#include <Protocol/SimpleFileSystem.h>\r
35#include <Protocol/Bds.h>\r
28a00297 36#include <Protocol/RealTimeClock.h>\r
28a00297 37#include <Protocol/WatchdogTimer.h>\r
0c2b5da8 38#include <Protocol/FirmwareVolume2.h>\r
28a00297 39#include <Protocol/MonotonicCounter.h>\r
28a00297 40#include <Protocol/StatusCode.h>\r
28a00297 41#include <Protocol/Decompress.h>\r
023c0fec 42#include <Protocol/LoadPe32Image.h>\r
28a00297 43#include <Protocol/Security.h>\r
bc2dfdbc 44#include <Protocol/Security2.h>\r
28a00297 45#include <Protocol/Ebc.h>\r
28a00297 46#include <Protocol/Reset.h>\r
28a00297 47#include <Protocol/Cpu.h>\r
28a00297 48#include <Protocol/Metronome.h>\r
49#include <Protocol/FirmwareVolumeBlock.h>\r
50#include <Protocol/Capsule.h>\r
51#include <Protocol/BusSpecificDriverOverride.h>\r
396e9039 52#include <Protocol/DriverFamilyOverride.h>\r
022c6d45 53#include <Protocol/TcgService.h>\r
7547649f 54#include <Protocol/HiiPackageList.h>\r
0803854b 55#include <Protocol/SmmBase2.h>\r
022c6d45 56#include <Guid/MemoryTypeInformation.h>\r
57#include <Guid/FirmwareFileSystem2.h>\r
6c85d162 58#include <Guid/FirmwareFileSystem3.h>\r
022c6d45 59#include <Guid/HobList.h>\r
60#include <Guid/DebugImageInfoTable.h>\r
61#include <Guid/FileInfo.h>\r
62#include <Guid/Apriori.h>\r
63#include <Guid/DxeServices.h>\r
64#include <Guid/MemoryAllocationHob.h>\r
65#include <Guid/EventLegacyBios.h>\r
66#include <Guid/EventGroup.h>\r
044824d9 67#include <Guid/EventExitBootServiceFailed.h>\r
54ea99a7 68#include <Guid/LoadModuleAtFixedAddress.h>\r
54cd17e9 69#include <Guid/IdleLoopEvent.h>\r
57f360f2
JF
70#include <Guid/VectorHandoffTable.h>\r
71#include <Ppi/VectorHandoffInfo.h>\r
84edd20b 72#include <Guid/MemoryProfile.h>\r
ed7748fe 73\r
28a00297 74#include <Library/DxeCoreEntryPoint.h>\r
75#include <Library/DebugLib.h>\r
76#include <Library/UefiLib.h>\r
77#include <Library/BaseLib.h>\r
78#include <Library/HobLib.h>\r
79#include <Library/PerformanceLib.h>\r
80#include <Library/UefiDecompressLib.h>\r
18fd8d65 81#include <Library/ExtractGuidedSectionLib.h>\r
28a00297 82#include <Library/CacheMaintenanceLib.h>\r
83#include <Library/BaseMemoryLib.h>\r
3d7b0992 84#include <Library/PeCoffLib.h>\r
b43619d0 85#include <Library/PeCoffGetEntryPointLib.h>\r
86#include <Library/PeCoffExtraActionLib.h>\r
797a9d67 87#include <Library/PcdLib.h>\r
c4869732 88#include <Library/MemoryAllocationLib.h>\r
070f0cf7 89#include <Library/DevicePathLib.h>\r
0e9b156d 90#include <Library/UefiBootServicesTableLib.h>\r
2680a308 91#include <Library/ReportStatusCodeLib.h>\r
7cff25d6 92#include <Library/TimerLib.h>\r
7748df3d 93#include <Library/DxeServicesLib.h>\r
e7af83ae 94#include <Library/DebugAgentLib.h>\r
1e172d6b 95#include <Library/CpuExceptionHandlerLib.h>\r
28a00297 96\r
54ea99a7 97\r
28a00297 98//\r
99// attributes for reserved memory before it is promoted to system memory\r
100//\r
101#define EFI_MEMORY_PRESENT 0x0100000000000000ULL\r
102#define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL\r
103#define EFI_MEMORY_TESTED 0x0400000000000000ULL\r
104\r
105//\r
106// range for memory mapped port I/O on IPF\r
107//\r
108#define EFI_MEMORY_PORT_IO 0x4000000000000000ULL\r
109\r
110\r
111///\r
6393d9c8
GL
112/// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependency expression\r
113/// to save time. A EFI_DEP_PUSH is evaluated one an\r
7f932291 114/// replaced with EFI_DEP_REPLACE_TRUE. If PI spec's Vol 2\r
115/// Driver Execution Environment Core Interface use 0xff\r
116/// as new DEPEX opcode. EFI_DEP_REPLACE_TRUE should be\r
117/// defined to a new value that is not conflicting with PI spec.\r
28a00297 118///\r
119#define EFI_DEP_REPLACE_TRUE 0xff\r
120\r
121///\r
122/// Define the initial size of the dependency expression evaluation stack\r
123///\r
124#define DEPEX_STACK_SIZE_INCREMENT 0x1000\r
125\r
d2f87ac0
AB
126#if defined (MDE_CPU_IPF)\r
127///\r
128/// For Itanium machines make the default allocations 8K aligned\r
129///\r
130#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2)\r
131#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2)\r
132\r
133#elif defined (MDE_CPU_AARCH64)\r
134///\r
135/// 64-bit ARM systems allow the OS to execute with 64 KB page size,\r
136/// so for improved interoperability with the firmware, align the\r
137/// runtime regions to 64 KB as well\r
138///\r
139#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (SIZE_64KB)\r
140#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)\r
141\r
142#else\r
143///\r
6393d9c8 144/// For generic EFI machines make the default allocations 4K aligned\r
d2f87ac0
AB
145///\r
146#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)\r
147#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)\r
148\r
149#endif\r
150\r
28a00297 151typedef struct {\r
152 EFI_GUID *ProtocolGuid;\r
153 VOID **Protocol;\r
154 EFI_EVENT Event;\r
155 VOID *Registration;\r
156 BOOLEAN Present;\r
74e44290 157} EFI_CORE_PROTOCOL_NOTIFY_ENTRY;\r
28a00297 158\r
28a00297 159//\r
160// DXE Dispatcher Data structures\r
161//\r
162\r
f3f2e05d 163#define KNOWN_HANDLE_SIGNATURE SIGNATURE_32('k','n','o','w')\r
28a00297 164typedef struct {\r
165 UINTN Signature;\r
022c6d45 166 LIST_ENTRY Link; // mFvHandleList\r
28a00297 167 EFI_HANDLE Handle;\r
2fc46f86 168 EFI_GUID FvNameGuid;\r
28a00297 169} KNOWN_HANDLE;\r
170\r
171\r
f3f2e05d 172#define EFI_CORE_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('d','r','v','r')\r
28a00297 173typedef struct {\r
174 UINTN Signature;\r
175 LIST_ENTRY Link; // mDriverList\r
176\r
177 LIST_ENTRY ScheduledLink; // mScheduledQueue\r
178\r
179 EFI_HANDLE FvHandle;\r
180 EFI_GUID FileName;\r
181 EFI_DEVICE_PATH_PROTOCOL *FvFileDevicePath;\r
0c2b5da8 182 EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
28a00297 183\r
184 VOID *Depex;\r
185 UINTN DepexSize;\r
186\r
187 BOOLEAN Before;\r
188 BOOLEAN After;\r
189 EFI_GUID BeforeAfterGuid;\r
190\r
191 BOOLEAN Dependent;\r
192 BOOLEAN Unrequested;\r
193 BOOLEAN Scheduled;\r
194 BOOLEAN Untrusted;\r
195 BOOLEAN Initialized;\r
196 BOOLEAN DepexProtocolError;\r
197\r
198 EFI_HANDLE ImageHandle;\r
d3592549 199 BOOLEAN IsFvImage;\r
28a00297 200\r
201} EFI_CORE_DRIVER_ENTRY;\r
202\r
203//\r
204//The data structure of GCD memory map entry\r
205//\r
f3f2e05d 206#define EFI_GCD_MAP_SIGNATURE SIGNATURE_32('g','c','d','m')\r
28a00297 207typedef struct {\r
208 UINTN Signature;\r
209 LIST_ENTRY Link;\r
210 EFI_PHYSICAL_ADDRESS BaseAddress;\r
211 UINT64 EndAddress;\r
212 UINT64 Capabilities;\r
213 UINT64 Attributes;\r
214 EFI_GCD_MEMORY_TYPE GcdMemoryType;\r
215 EFI_GCD_IO_TYPE GcdIoType;\r
216 EFI_HANDLE ImageHandle;\r
217 EFI_HANDLE DeviceHandle;\r
218} EFI_GCD_MAP_ENTRY;\r
219\r
84edd20b
SZ
220\r
221#define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','d','r','i')\r
222\r
223typedef struct {\r
224 UINTN Signature;\r
225 /// Image handle\r
226 EFI_HANDLE Handle; \r
227 /// Image type\r
228 UINTN Type; \r
229 /// If entrypoint has been called\r
230 BOOLEAN Started; \r
231 /// The image's entry point\r
232 EFI_IMAGE_ENTRY_POINT EntryPoint; \r
233 /// loaded image protocol\r
234 EFI_LOADED_IMAGE_PROTOCOL Info; \r
235 /// Location in memory\r
236 EFI_PHYSICAL_ADDRESS ImageBasePage; \r
237 /// Number of pages\r
238 UINTN NumberOfPages; \r
239 /// Original fixup data\r
240 CHAR8 *FixupData; \r
241 /// Tpl of started image\r
242 EFI_TPL Tpl; \r
243 /// Status returned by started image\r
244 EFI_STATUS Status; \r
245 /// Size of ExitData from started image\r
246 UINTN ExitDataSize; \r
247 /// Pointer to exit data from started image\r
248 VOID *ExitData; \r
6393d9c8 249 /// Pointer to pool allocation for context save/restore\r
84edd20b 250 VOID *JumpBuffer; \r
6393d9c8 251 /// Pointer to buffer for context save/restore\r
84edd20b
SZ
252 BASE_LIBRARY_JUMP_BUFFER *JumpContext; \r
253 /// Machine type from PE image\r
254 UINT16 Machine; \r
255 /// EBC Protocol pointer\r
256 EFI_EBC_PROTOCOL *Ebc; \r
257 /// Runtime image list\r
258 EFI_RUNTIME_IMAGE_ENTRY *RuntimeData; \r
6393d9c8 259 /// Pointer to Loaded Image Device Path Protocol\r
84edd20b
SZ
260 EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath; \r
261 /// PeCoffLoader ImageContext\r
262 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; \r
263 /// Status returned by LoadImage() service.\r
264 EFI_STATUS LoadImageStatus;\r
265} LOADED_IMAGE_PRIVATE_DATA;\r
266\r
267#define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \\r
268 CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE)\r
269\r
d0e92aad
JY
270#define IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE SIGNATURE_32 ('I','P','R','C')\r
271\r
272typedef struct {\r
273 UINT32 Signature;\r
274 LIST_ENTRY Link;\r
275 EFI_PHYSICAL_ADDRESS CodeSegmentBase;\r
276 UINT64 CodeSegmentSize;\r
277} IMAGE_PROPERTIES_RECORD_CODE_SECTION;\r
278\r
279#define IMAGE_PROPERTIES_RECORD_SIGNATURE SIGNATURE_32 ('I','P','R','D')\r
280\r
281typedef struct {\r
282 UINT32 Signature;\r
283 LIST_ENTRY Link;\r
284 EFI_PHYSICAL_ADDRESS ImageBase;\r
285 UINT64 ImageSize;\r
286 UINTN CodeSegmentCount;\r
287 LIST_ENTRY CodeSegmentList;\r
288} IMAGE_PROPERTIES_RECORD;\r
289\r
28a00297 290//\r
291// DXE Core Global Variables\r
292//\r
293extern EFI_SYSTEM_TABLE *gDxeCoreST;\r
28a00297 294extern EFI_RUNTIME_SERVICES *gDxeCoreRT;\r
295extern EFI_DXE_SERVICES *gDxeCoreDS;\r
296extern EFI_HANDLE gDxeCoreImageHandle;\r
297\r
74a88770
SZ
298extern BOOLEAN gMemoryMapTerminated;\r
299\r
28a00297 300extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress;\r
28a00297 301\r
302extern EFI_RUNTIME_ARCH_PROTOCOL *gRuntime;\r
303extern EFI_CPU_ARCH_PROTOCOL *gCpu;\r
304extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer;\r
305extern EFI_METRONOME_ARCH_PROTOCOL *gMetronome;\r
306extern EFI_TIMER_ARCH_PROTOCOL *gTimer;\r
307extern EFI_SECURITY_ARCH_PROTOCOL *gSecurity;\r
bc2dfdbc 308extern EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2;\r
28a00297 309extern EFI_BDS_ARCH_PROTOCOL *gBds;\r
0803854b 310extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2;\r
28a00297 311\r
312extern EFI_TPL gEfiCurrentTpl;\r
313\r
314extern EFI_GUID *gDxeCoreFileName;\r
315extern EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;\r
316\r
317extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1];\r
318\r
319extern BOOLEAN gDispatcherRunning;\r
320extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate;\r
321\r
54ea99a7 322extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable;\r
323extern BOOLEAN gLoadFixedAddressCodeMemoryReady;\r
28a00297 324//\r
325// Service Initialization Functions\r
326//\r
327\r
328\r
162ed594 329\r
330/**\r
331 Called to initialize the pool.\r
332\r
333**/\r
28a00297 334VOID\r
335CoreInitializePool (\r
336 VOID\r
23c98c94 337 );\r
28a00297 338\r
28a00297 339\r
162ed594 340/**\r
341 Called to initialize the memory map and add descriptors to\r
342 the current descriptor list.\r
343 The first descriptor that is added must be general usable\r
344 memory as the addition allocates heap.\r
28a00297 345\r
022c6d45 346 @param Type The type of memory to add\r
347 @param Start The starting address in the memory range Must be\r
348 page aligned\r
349 @param NumberOfPages The number of pages in the range\r
350 @param Attribute Attributes of the memory to add\r
28a00297 351\r
162ed594 352 @return None. The range is added to the memory map\r
28a00297 353\r
162ed594 354**/\r
28a00297 355VOID\r
356CoreAddMemoryDescriptor (\r
357 IN EFI_MEMORY_TYPE Type,\r
358 IN EFI_PHYSICAL_ADDRESS Start,\r
359 IN UINT64 NumberOfPages,\r
360 IN UINT64 Attribute\r
23c98c94 361 );\r
28a00297 362\r
28a00297 363\r
162ed594 364/**\r
365 Release memory lock on mGcdMemorySpaceLock.\r
28a00297 366\r
162ed594 367**/\r
28a00297 368VOID\r
369CoreReleaseGcdMemoryLock (\r
370 VOID\r
23c98c94 371 );\r
28a00297 372\r
28a00297 373\r
162ed594 374/**\r
375 Acquire memory lock on mGcdMemorySpaceLock.\r
28a00297 376\r
162ed594 377**/\r
28a00297 378VOID\r
379CoreAcquireGcdMemoryLock (\r
380 VOID\r
23c98c94 381 );\r
28a00297 382\r
28a00297 383\r
162ed594 384/**\r
c18f12d3 385 External function. Initializes memory services based on the memory\r
386 descriptor HOBs. This function is responsible for priming the memory\r
387 map, so memory allocations and resource allocations can be made.\r
388 The first part of this function can not depend on any memory services\r
389 until at least one memory descriptor is provided to the memory services.\r
28a00297 390\r
022c6d45 391 @param HobStart The start address of the HOB.\r
392 @param MemoryBaseAddress Start address of memory region found to init DXE\r
393 core.\r
394 @param MemoryLength Length of memory region found to init DXE core.\r
28a00297 395\r
162ed594 396 @retval EFI_SUCCESS Memory services successfully initialized.\r
28a00297 397\r
162ed594 398**/\r
28a00297 399EFI_STATUS\r
400CoreInitializeMemoryServices (\r
23c98c94 401 IN VOID **HobStart,\r
402 OUT EFI_PHYSICAL_ADDRESS *MemoryBaseAddress,\r
403 OUT UINT64 *MemoryLength\r
404 );\r
162ed594 405\r
28a00297 406\r
28a00297 407\r
162ed594 408/**\r
409 External function. Initializes the GCD and memory services based on the memory\r
28a00297 410 descriptor HOBs. This function is responsible for priming the GCD map and the\r
c18f12d3 411 memory map, so memory allocations and resource allocations can be made. The\r
412 HobStart will be relocated to a pool buffer.\r
28a00297 413\r
022c6d45 414 @param HobStart The start address of the HOB\r
415 @param MemoryBaseAddress Start address of memory region found to init DXE\r
416 core.\r
417 @param MemoryLength Length of memory region found to init DXE core.\r
28a00297 418\r
162ed594 419 @retval EFI_SUCCESS GCD services successfully initialized.\r
28a00297 420\r
162ed594 421**/\r
28a00297 422EFI_STATUS\r
423CoreInitializeGcdServices (\r
022c6d45 424 IN OUT VOID **HobStart,\r
28a00297 425 IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress,\r
426 IN UINT64 MemoryLength\r
23c98c94 427 );\r
28a00297 428\r
28a00297 429\r
162ed594 430/**\r
1947c70c 431 Initializes "event" support.\r
28a00297 432\r
162ed594 433 @retval EFI_SUCCESS Always return success\r
28a00297 434\r
162ed594 435**/\r
28a00297 436EFI_STATUS\r
437CoreInitializeEventServices (\r
438 VOID\r
23c98c94 439 );\r
28a00297 440\r
28a00297 441\r
162ed594 442/**\r
443 Add the Image Services to EFI Boot Services Table and install the protocol\r
444 interfaces for this image.\r
28a00297 445\r
022c6d45 446 @param HobStart The HOB to initialize\r
28a00297 447\r
162ed594 448 @return Status code.\r
28a00297 449\r
162ed594 450**/\r
28a00297 451EFI_STATUS\r
452CoreInitializeImageServices (\r
453 IN VOID *HobStart\r
23c98c94 454 );\r
28a00297 455\r
28a00297 456\r
162ed594 457/**\r
458 Creates an event that is fired everytime a Protocol of a specific type is installed.\r
28a00297 459\r
162ed594 460**/\r
28a00297 461VOID\r
74e44290 462CoreNotifyOnProtocolInstallation (\r
28a00297 463 VOID\r
23c98c94 464 );\r
28a00297 465\r
28a00297 466\r
162ed594 467/**\r
6393d9c8 468 Return TRUE if all AP services are available.\r
28a00297 469\r
022c6d45 470 @retval EFI_SUCCESS All AP services are available\r
162ed594 471 @retval EFI_NOT_FOUND At least one AP service is not available\r
28a00297 472\r
162ed594 473**/\r
28a00297 474EFI_STATUS\r
475CoreAllEfiServicesAvailable (\r
476 VOID\r
23c98c94 477 );\r
28a00297 478\r
28a00297 479\r
162ed594 480/**\r
481 Calcualte the 32-bit CRC in a EFI table using the service provided by the\r
482 gRuntime service.\r
28a00297 483\r
162ed594 484 @param Hdr Pointer to an EFI standard header\r
28a00297 485\r
162ed594 486**/\r
28a00297 487VOID\r
488CalculateEfiHdrCrc (\r
489 IN OUT EFI_TABLE_HEADER *Hdr\r
23c98c94 490 );\r
28a00297 491\r
28a00297 492\r
162ed594 493/**\r
494 Called by the platform code to process a tick.\r
28a00297 495\r
6393d9c8 496 @param Duration The number of 100ns elapsed since the last call\r
162ed594 497 to TimerTick\r
28a00297 498\r
162ed594 499**/\r
28a00297 500VOID\r
501EFIAPI\r
502CoreTimerTick (\r
23c98c94 503 IN UINT64 Duration\r
504 );\r
28a00297 505\r
28a00297 506\r
162ed594 507/**\r
508 Initialize the dispatcher. Initialize the notification function that runs when\r
022c6d45 509 an FV2 protocol is added to the system.\r
28a00297 510\r
162ed594 511**/\r
28a00297 512VOID\r
513CoreInitializeDispatcher (\r
514 VOID\r
23c98c94 515 );\r
28a00297 516\r
28a00297 517\r
162ed594 518/**\r
519 This is the POSTFIX version of the dependency evaluator. This code does\r
520 not need to handle Before or After, as it is not valid to call this\r
521 routine in this case. The SOR is just ignored and is a nop in the grammer.\r
522 POSTFIX means all the math is done on top of the stack.\r
28a00297 523\r
022c6d45 524 @param DriverEntry DriverEntry element to update.\r
28a00297 525\r
022c6d45 526 @retval TRUE If driver is ready to run.\r
527 @retval FALSE If driver is not ready to run or some fatal error\r
162ed594 528 was found.\r
28a00297 529\r
162ed594 530**/\r
28a00297 531BOOLEAN\r
532CoreIsSchedulable (\r
022c6d45 533 IN EFI_CORE_DRIVER_ENTRY *DriverEntry\r
23c98c94 534 );\r
28a00297 535\r
28a00297 536\r
162ed594 537/**\r
538 Preprocess dependency expression and update DriverEntry to reflect the\r
539 state of Before, After, and SOR dependencies. If DriverEntry->Before\r
540 or DriverEntry->After is set it will never be cleared. If SOR is set\r
541 it will be cleared by CoreSchedule(), and then the driver can be\r
542 dispatched.\r
28a00297 543\r
022c6d45 544 @param DriverEntry DriverEntry element to update .\r
28a00297 545\r
162ed594 546 @retval EFI_SUCCESS It always works.\r
28a00297 547\r
162ed594 548**/\r
28a00297 549EFI_STATUS\r
550CorePreProcessDepex (\r
022c6d45 551 IN EFI_CORE_DRIVER_ENTRY *DriverEntry\r
23c98c94 552 );\r
28a00297 553\r
28a00297 554\r
28a00297 555\r
162ed594 556/**\r
557 Terminates all boot services.\r
28a00297 558\r
022c6d45 559 @param ImageHandle Handle that identifies the exiting image.\r
162ed594 560 @param MapKey Key to the latest memory map.\r
28a00297 561\r
022c6d45 562 @retval EFI_SUCCESS Boot Services terminated\r
162ed594 563 @retval EFI_INVALID_PARAMETER MapKey is incorrect.\r
28a00297 564\r
162ed594 565**/\r
28a00297 566EFI_STATUS\r
567EFIAPI\r
568CoreExitBootServices (\r
569 IN EFI_HANDLE ImageHandle,\r
570 IN UINTN MapKey\r
23c98c94 571 );\r
28a00297 572\r
28a00297 573\r
162ed594 574/**\r
575 Make sure the memory map is following all the construction rules,\r
576 it is the last time to check memory map error before exit boot services.\r
28a00297 577\r
022c6d45 578 @param MapKey Memory map key\r
28a00297 579\r
022c6d45 580 @retval EFI_INVALID_PARAMETER Memory map not consistent with construction\r
581 rules.\r
162ed594 582 @retval EFI_SUCCESS Valid memory map.\r
28a00297 583\r
162ed594 584**/\r
28a00297 585EFI_STATUS\r
586CoreTerminateMemoryMap (\r
23c98c94 587 IN UINTN MapKey\r
588 );\r
28a00297 589\r
28a00297 590\r
162ed594 591/**\r
592 Signals all events in the EventGroup.\r
28a00297 593\r
162ed594 594 @param EventGroup The list to signal\r
28a00297 595\r
162ed594 596**/\r
28a00297 597VOID\r
598CoreNotifySignalList (\r
599 IN EFI_GUID *EventGroup\r
23c98c94 600 );\r
28a00297 601\r
28a00297 602\r
28a00297 603\r
162ed594 604/**\r
605 Boot Service called to add, modify, or remove a system configuration table from\r
606 the EFI System Table.\r
28a00297 607\r
022c6d45 608 @param Guid Pointer to the GUID for the entry to add, update, or\r
609 remove\r
610 @param Table Pointer to the configuration table for the entry to add,\r
611 update, or remove, may be NULL.\r
28a00297 612\r
162ed594 613 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.\r
614 @return EFI_INVALID_PARAMETER Input GUID not valid.\r
615 @return EFI_NOT_FOUND Attempted to delete non-existant entry\r
616 @return EFI_OUT_OF_RESOURCES Not enough memory available\r
28a00297 617\r
162ed594 618**/\r
28a00297 619EFI_STATUS\r
620EFIAPI\r
621CoreInstallConfigurationTable (\r
23c98c94 622 IN EFI_GUID *Guid,\r
623 IN VOID *Table\r
624 );\r
28a00297 625\r
28a00297 626\r
28a00297 627\r
162ed594 628/**\r
629 Raise the task priority level to the new level.\r
630 High level is implemented by disabling processor interrupts.\r
28a00297 631\r
022c6d45 632 @param NewTpl New task priority level\r
28a00297 633\r
162ed594 634 @return The previous task priority level\r
28a00297 635\r
162ed594 636**/\r
28a00297 637EFI_TPL\r
638EFIAPI\r
639CoreRaiseTpl (\r
23c98c94 640 IN EFI_TPL NewTpl\r
641 );\r
28a00297 642\r
28a00297 643\r
28a00297 644\r
162ed594 645/**\r
646 Lowers the task priority to the previous value. If the new\r
647 priority unmasks events at a higher priority, they are dispatched.\r
28a00297 648\r
162ed594 649 @param NewTpl New, lower, task priority\r
28a00297 650\r
162ed594 651**/\r
28a00297 652VOID\r
653EFIAPI\r
654CoreRestoreTpl (\r
23c98c94 655 IN EFI_TPL NewTpl\r
656 );\r
28a00297 657\r
28a00297 658\r
28a00297 659\r
162ed594 660/**\r
661 Introduces a fine-grained stall.\r
28a00297 662\r
162ed594 663 @param Microseconds The number of microseconds to stall execution.\r
28a00297 664\r
022c6d45 665 @retval EFI_SUCCESS Execution was stalled for at least the requested\r
666 amount of microseconds.\r
162ed594 667 @retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet\r
28a00297 668\r
162ed594 669**/\r
28a00297 670EFI_STATUS\r
671EFIAPI\r
672CoreStall (\r
673 IN UINTN Microseconds\r
23c98c94 674 );\r
28a00297 675\r
28a00297 676\r
28a00297 677\r
162ed594 678/**\r
679 Sets the system's watchdog timer.\r
28a00297 680\r
162ed594 681 @param Timeout The number of seconds to set the watchdog timer to.\r
682 A value of zero disables the timer.\r
683 @param WatchdogCode The numeric code to log on a watchdog timer timeout\r
684 event. The firmware reserves codes 0x0000 to 0xFFFF.\r
685 Loaders and operating systems may use other timeout\r
686 codes.\r
687 @param DataSize The size, in bytes, of WatchdogData.\r
688 @param WatchdogData A data buffer that includes a Null-terminated Unicode\r
689 string, optionally followed by additional binary data.\r
690 The string is a description that the call may use to\r
691 further indicate the reason to be logged with a\r
692 watchdog event.\r
693\r
694 @return EFI_SUCCESS Timeout has been set\r
695 @return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet\r
696 @return EFI_UNSUPPORTED System does not have a timer (currently not used)\r
697 @return EFI_DEVICE_ERROR Could not complete due to hardware error\r
28a00297 698\r
162ed594 699**/\r
28a00297 700EFI_STATUS\r
701EFIAPI\r
702CoreSetWatchdogTimer (\r
23c98c94 703 IN UINTN Timeout,\r
704 IN UINT64 WatchdogCode,\r
705 IN UINTN DataSize,\r
706 IN CHAR16 *WatchdogData OPTIONAL\r
707 );\r
28a00297 708\r
28a00297 709\r
28a00297 710\r
162ed594 711/**\r
712 Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which\r
713 Calls the private one which contains a BOOLEAN parameter for notifications\r
28a00297 714\r
022c6d45 715 @param UserHandle The handle to install the protocol handler on,\r
716 or NULL if a new handle is to be allocated\r
717 @param Protocol The protocol to add to the handle\r
718 @param InterfaceType Indicates whether Interface is supplied in\r
719 native form.\r
720 @param Interface The interface for the protocol being added\r
28a00297 721\r
162ed594 722 @return Status code\r
28a00297 723\r
162ed594 724**/\r
28a00297 725EFI_STATUS\r
726EFIAPI\r
727CoreInstallProtocolInterface (\r
728 IN OUT EFI_HANDLE *UserHandle,\r
729 IN EFI_GUID *Protocol,\r
730 IN EFI_INTERFACE_TYPE InterfaceType,\r
731 IN VOID *Interface\r
23c98c94 732 );\r
28a00297 733\r
28a00297 734\r
162ed594 735/**\r
736 Installs a protocol interface into the boot services environment.\r
28a00297 737\r
022c6d45 738 @param UserHandle The handle to install the protocol handler on,\r
739 or NULL if a new handle is to be allocated\r
740 @param Protocol The protocol to add to the handle\r
741 @param InterfaceType Indicates whether Interface is supplied in\r
742 native form.\r
743 @param Interface The interface for the protocol being added\r
744 @param Notify indicates whether notify the notification list\r
745 for this protocol\r
28a00297 746\r
022c6d45 747 @retval EFI_INVALID_PARAMETER Invalid parameter\r
748 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate\r
162ed594 749 @retval EFI_SUCCESS Protocol interface successfully installed\r
28a00297 750\r
162ed594 751**/\r
28a00297 752EFI_STATUS\r
753CoreInstallProtocolInterfaceNotify (\r
754 IN OUT EFI_HANDLE *UserHandle,\r
755 IN EFI_GUID *Protocol,\r
756 IN EFI_INTERFACE_TYPE InterfaceType,\r
757 IN VOID *Interface,\r
758 IN BOOLEAN Notify\r
23c98c94 759 );\r
28a00297 760\r
28a00297 761\r
28a00297 762\r
162ed594 763/**\r
764 Installs a list of protocol interface into the boot services environment.\r
765 This function calls InstallProtocolInterface() in a loop. If any error\r
766 occures all the protocols added by this function are removed. This is\r
767 basically a lib function to save space.\r
28a00297 768\r
022c6d45 769 @param Handle The handle to install the protocol handlers on,\r
770 or NULL if a new handle is to be allocated\r
771 @param ... EFI_GUID followed by protocol instance. A NULL\r
772 terminates the list. The pairs are the\r
773 arguments to InstallProtocolInterface(). All the\r
774 protocols are added to Handle.\r
28a00297 775\r
5a7b9bbe
SQ
776 @retval EFI_SUCCESS All the protocol interface was installed.\r
777 @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.\r
778 @retval EFI_ALREADY_STARTED A Device Path Protocol instance was passed in that is already present in\r
779 the handle database.\r
022c6d45 780 @retval EFI_INVALID_PARAMETER Handle is NULL.\r
5a7b9bbe 781 @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle.\r
28a00297 782\r
162ed594 783**/\r
28a00297 784EFI_STATUS\r
785EFIAPI\r
786CoreInstallMultipleProtocolInterfaces (\r
787 IN OUT EFI_HANDLE *Handle,\r
788 ...\r
23c98c94 789 );\r
28a00297 790\r
28a00297 791\r
28a00297 792\r
162ed594 793/**\r
794 Uninstalls a list of protocol interface in the boot services environment.\r
795 This function calls UnisatllProtocolInterface() in a loop. This is\r
796 basically a lib function to save space.\r
28a00297 797\r
022c6d45 798 @param Handle The handle to uninstall the protocol\r
799 @param ... EFI_GUID followed by protocol instance. A NULL\r
800 terminates the list. The pairs are the\r
801 arguments to UninstallProtocolInterface(). All\r
802 the protocols are added to Handle.\r
28a00297 803\r
162ed594 804 @return Status code\r
28a00297 805\r
162ed594 806**/\r
28a00297 807EFI_STATUS\r
808EFIAPI\r
809CoreUninstallMultipleProtocolInterfaces (\r
810 IN EFI_HANDLE Handle,\r
811 ...\r
23c98c94 812 );\r
28a00297 813\r
28a00297 814\r
28a00297 815\r
162ed594 816/**\r
817 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.\r
28a00297 818\r
022c6d45 819 @param UserHandle Handle on which the interface is to be\r
820 reinstalled\r
821 @param Protocol The numeric ID of the interface\r
822 @param OldInterface A pointer to the old interface\r
823 @param NewInterface A pointer to the new interface\r
28a00297 824\r
162ed594 825 @retval EFI_SUCCESS The protocol interface was installed\r
826 @retval EFI_NOT_FOUND The OldInterface on the handle was not found\r
827 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value\r
28a00297 828\r
162ed594 829**/\r
28a00297 830EFI_STATUS\r
831EFIAPI\r
832CoreReinstallProtocolInterface (\r
833 IN EFI_HANDLE UserHandle,\r
834 IN EFI_GUID *Protocol,\r
835 IN VOID *OldInterface,\r
836 IN VOID *NewInterface\r
23c98c94 837 );\r
28a00297 838\r
839\r
28a00297 840\r
162ed594 841/**\r
842 Uninstalls all instances of a protocol:interfacer from a handle.\r
843 If the last protocol interface is remove from the handle, the\r
844 handle is freed.\r
28a00297 845\r
022c6d45 846 @param UserHandle The handle to remove the protocol handler from\r
847 @param Protocol The protocol, of protocol:interface, to remove\r
848 @param Interface The interface, of protocol:interface, to remove\r
28a00297 849\r
022c6d45 850 @retval EFI_INVALID_PARAMETER Protocol is NULL.\r
162ed594 851 @retval EFI_SUCCESS Protocol interface successfully uninstalled.\r
28a00297 852\r
162ed594 853**/\r
28a00297 854EFI_STATUS\r
855EFIAPI\r
856CoreUninstallProtocolInterface (\r
857 IN EFI_HANDLE UserHandle,\r
858 IN EFI_GUID *Protocol,\r
859 IN VOID *Interface\r
23c98c94 860 );\r
28a00297 861\r
28a00297 862\r
28a00297 863\r
162ed594 864/**\r
865 Queries a handle to determine if it supports a specified protocol.\r
28a00297 866\r
022c6d45 867 @param UserHandle The handle being queried.\r
868 @param Protocol The published unique identifier of the protocol.\r
869 @param Interface Supplies the address where a pointer to the\r
870 corresponding Protocol Interface is returned.\r
28a00297 871\r
162ed594 872 @return The requested protocol interface for the handle\r
28a00297 873\r
162ed594 874**/\r
28a00297 875EFI_STATUS\r
876EFIAPI\r
877CoreHandleProtocol (\r
23c98c94 878 IN EFI_HANDLE UserHandle,\r
879 IN EFI_GUID *Protocol,\r
880 OUT VOID **Interface\r
881 );\r
28a00297 882\r
28a00297 883\r
28a00297 884\r
162ed594 885/**\r
886 Locates the installed protocol handler for the handle, and\r
887 invokes it to obtain the protocol interface. Usage information\r
888 is registered in the protocol data base.\r
28a00297 889\r
022c6d45 890 @param UserHandle The handle to obtain the protocol interface on\r
891 @param Protocol The ID of the protocol\r
892 @param Interface The location to return the protocol interface\r
893 @param ImageHandle The handle of the Image that is opening the\r
894 protocol interface specified by Protocol and\r
895 Interface.\r
896 @param ControllerHandle The controller handle that is requiring this\r
897 interface.\r
898 @param Attributes The open mode of the protocol interface\r
899 specified by Handle and Protocol.\r
900\r
901 @retval EFI_INVALID_PARAMETER Protocol is NULL.\r
162ed594 902 @retval EFI_SUCCESS Get the protocol interface.\r
28a00297 903\r
162ed594 904**/\r
28a00297 905EFI_STATUS\r
906EFIAPI\r
907CoreOpenProtocol (\r
908 IN EFI_HANDLE UserHandle,\r
909 IN EFI_GUID *Protocol,\r
910 OUT VOID **Interface OPTIONAL,\r
911 IN EFI_HANDLE ImageHandle,\r
912 IN EFI_HANDLE ControllerHandle,\r
913 IN UINT32 Attributes\r
23c98c94 914 );\r
28a00297 915\r
28a00297 916\r
28a00297 917\r
162ed594 918/**\r
919 Return information about Opened protocols in the system\r
28a00297 920\r
022c6d45 921 @param UserHandle The handle to close the protocol interface on\r
922 @param Protocol The ID of the protocol\r
923 @param EntryBuffer A pointer to a buffer of open protocol\r
924 information in the form of\r
925 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.\r
162ed594 926 @param EntryCount Number of EntryBuffer entries\r
28a00297 927\r
162ed594 928**/\r
28a00297 929EFI_STATUS\r
930EFIAPI\r
931CoreOpenProtocolInformation (\r
932 IN EFI_HANDLE UserHandle,\r
933 IN EFI_GUID *Protocol,\r
934 OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,\r
935 OUT UINTN *EntryCount\r
23c98c94 936 );\r
28a00297 937\r
28a00297 938\r
28a00297 939\r
162ed594 940/**\r
941 Closes a protocol on a handle that was opened using OpenProtocol().\r
28a00297 942\r
022c6d45 943 @param UserHandle The handle for the protocol interface that was\r
944 previously opened with OpenProtocol(), and is\r
945 now being closed.\r
946 @param Protocol The published unique identifier of the protocol.\r
947 It is the caller's responsibility to pass in a\r
948 valid GUID.\r
949 @param AgentHandle The handle of the agent that is closing the\r
950 protocol interface.\r
951 @param ControllerHandle If the agent that opened a protocol is a driver\r
952 that follows the EFI Driver Model, then this\r
953 parameter is the controller handle that required\r
954 the protocol interface. If the agent does not\r
955 follow the EFI Driver Model, then this parameter\r
956 is optional and may be NULL.\r
957\r
958 @retval EFI_SUCCESS The protocol instance was closed.\r
959 @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a\r
960 valid EFI_HANDLE.\r
961 @retval EFI_NOT_FOUND Can not find the specified protocol or\r
162ed594 962 AgentHandle.\r
28a00297 963\r
162ed594 964**/\r
28a00297 965EFI_STATUS\r
966EFIAPI\r
967CoreCloseProtocol (\r
968 IN EFI_HANDLE UserHandle,\r
969 IN EFI_GUID *Protocol,\r
162ed594 970 IN EFI_HANDLE AgentHandle,\r
022c6d45 971 IN EFI_HANDLE ControllerHandle\r
23c98c94 972 );\r
28a00297 973\r
28a00297 974\r
28a00297 975\r
162ed594 976/**\r
977 Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated\r
978 from pool.\r
979\r
022c6d45 980 @param UserHandle The handle from which to retrieve the list of\r
981 protocol interface GUIDs.\r
982 @param ProtocolBuffer A pointer to the list of protocol interface GUID\r
983 pointers that are installed on Handle.\r
984 @param ProtocolBufferCount A pointer to the number of GUID pointers present\r
985 in ProtocolBuffer.\r
986\r
987 @retval EFI_SUCCESS The list of protocol interface GUIDs installed\r
988 on Handle was returned in ProtocolBuffer. The\r
989 number of protocol interface GUIDs was returned\r
990 in ProtocolBufferCount.\r
991 @retval EFI_INVALID_PARAMETER Handle is NULL.\r
992 @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.\r
993 @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.\r
994 @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.\r
995 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the\r
162ed594 996 results.\r
28a00297 997\r
162ed594 998**/\r
28a00297 999EFI_STATUS\r
1000EFIAPI\r
1001CoreProtocolsPerHandle (\r
23c98c94 1002 IN EFI_HANDLE UserHandle,\r
1003 OUT EFI_GUID ***ProtocolBuffer,\r
1004 OUT UINTN *ProtocolBufferCount\r
1005 );\r
28a00297 1006\r
28a00297 1007\r
28a00297 1008\r
162ed594 1009/**\r
1010 Add a new protocol notification record for the request protocol.\r
28a00297 1011\r
022c6d45 1012 @param Protocol The requested protocol to add the notify\r
1013 registration\r
1014 @param Event The event to signal\r
1015 @param Registration Returns the registration record\r
28a00297 1016\r
022c6d45 1017 @retval EFI_INVALID_PARAMETER Invalid parameter\r
1018 @retval EFI_SUCCESS Successfully returned the registration record\r
162ed594 1019 that has been added\r
28a00297 1020\r
162ed594 1021**/\r
28a00297 1022EFI_STATUS\r
1023EFIAPI\r
1024CoreRegisterProtocolNotify (\r
23c98c94 1025 IN EFI_GUID *Protocol,\r
1026 IN EFI_EVENT Event,\r
022c6d45 1027 OUT VOID **Registration\r
23c98c94 1028 );\r
022c6d45 1029\r
28a00297 1030\r
ec90508b 1031/**\r
1032 Removes all the events in the protocol database that match Event.\r
1033\r
1034 @param Event The event to search for in the protocol\r
1035 database.\r
1036\r
1037 @return EFI_SUCCESS when done searching the entire database.\r
1038\r
1039**/\r
1040EFI_STATUS\r
1041CoreUnregisterProtocolNotify (\r
1042 IN EFI_EVENT Event\r
1043 );\r
1044\r
28a00297 1045\r
162ed594 1046/**\r
1047 Locates the requested handle(s) and returns them in Buffer.\r
28a00297 1048\r
022c6d45 1049 @param SearchType The type of search to perform to locate the\r
1050 handles\r
1051 @param Protocol The protocol to search for\r
1052 @param SearchKey Dependant on SearchType\r
1053 @param BufferSize On input the size of Buffer. On output the\r
1054 size of data returned.\r
1055 @param Buffer The buffer to return the results in\r
28a00297 1056\r
022c6d45 1057 @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is\r
1058 returned in BufferSize.\r
1059 @retval EFI_INVALID_PARAMETER Invalid parameter\r
1060 @retval EFI_SUCCESS Successfully found the requested handle(s) and\r
162ed594 1061 returns them in Buffer.\r
28a00297 1062\r
162ed594 1063**/\r
28a00297 1064EFI_STATUS\r
1065EFIAPI\r
1066CoreLocateHandle (\r
23c98c94 1067 IN EFI_LOCATE_SEARCH_TYPE SearchType,\r
1068 IN EFI_GUID *Protocol OPTIONAL,\r
1069 IN VOID *SearchKey OPTIONAL,\r
1070 IN OUT UINTN *BufferSize,\r
1071 OUT EFI_HANDLE *Buffer\r
1072 );\r
022c6d45 1073\r
28a00297 1074\r
28a00297 1075\r
162ed594 1076/**\r
1077 Locates the handle to a device on the device path that best matches the specified protocol.\r
28a00297 1078\r
022c6d45 1079 @param Protocol The protocol to search for.\r
1080 @param DevicePath On input, a pointer to a pointer to the device\r
1081 path. On output, the device path pointer is\r
1082 modified to point to the remaining part of the\r
1083 devicepath.\r
1084 @param Device A pointer to the returned device handle.\r
28a00297 1085\r
022c6d45 1086 @retval EFI_SUCCESS The resulting handle was returned.\r
1087 @retval EFI_NOT_FOUND No handles matched the search.\r
162ed594 1088 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
28a00297 1089\r
162ed594 1090**/\r
28a00297 1091EFI_STATUS\r
1092EFIAPI\r
1093CoreLocateDevicePath (\r
23c98c94 1094 IN EFI_GUID *Protocol,\r
1095 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r
1096 OUT EFI_HANDLE *Device\r
1097 );\r
28a00297 1098\r
022c6d45 1099\r
28a00297 1100\r
162ed594 1101/**\r
1102 Function returns an array of handles that support the requested protocol\r
1103 in a buffer allocated from pool. This is a version of CoreLocateHandle()\r
1104 that allocates a buffer for the caller.\r
28a00297 1105\r
022c6d45 1106 @param SearchType Specifies which handle(s) are to be returned.\r
1107 @param Protocol Provides the protocol to search by. This\r
1108 parameter is only valid for SearchType\r
1109 ByProtocol.\r
1110 @param SearchKey Supplies the search key depending on the\r
1111 SearchType.\r
1112 @param NumberHandles The number of handles returned in Buffer.\r
1113 @param Buffer A pointer to the buffer to return the requested\r
1114 array of handles that support Protocol.\r
1115\r
1116 @retval EFI_SUCCESS The result array of handles was returned.\r
1117 @retval EFI_NOT_FOUND No handles match the search.\r
1118 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the\r
1119 matching results.\r
6393d9c8 1120 @retval EFI_INVALID_PARAMETER One or more parameters are not valid.\r
28a00297 1121\r
162ed594 1122**/\r
28a00297 1123EFI_STATUS\r
1124EFIAPI\r
1125CoreLocateHandleBuffer (\r
23c98c94 1126 IN EFI_LOCATE_SEARCH_TYPE SearchType,\r
1127 IN EFI_GUID *Protocol OPTIONAL,\r
1128 IN VOID *SearchKey OPTIONAL,\r
1129 IN OUT UINTN *NumberHandles,\r
1130 OUT EFI_HANDLE **Buffer\r
1131 );\r
28a00297 1132\r
022c6d45 1133\r
28a00297 1134\r
162ed594 1135/**\r
1136 Return the first Protocol Interface that matches the Protocol GUID. If\r
8bc18cc6 1137 Registration is passed in, return a Protocol Instance that was just add\r
1138 to the system. If Registration is NULL return the first Protocol Interface\r
162ed594 1139 you find.\r
28a00297 1140\r
44310938 1141 @param Protocol The protocol to search for\r
1142 @param Registration Optional Registration Key returned from\r
1143 RegisterProtocolNotify()\r
1144 @param Interface Return the Protocol interface (instance).\r
28a00297 1145\r
44310938 1146 @retval EFI_SUCCESS If a valid Interface is returned\r
1147 @retval EFI_INVALID_PARAMETER Invalid parameter\r
162ed594 1148 @retval EFI_NOT_FOUND Protocol interface not found\r
28a00297 1149\r
162ed594 1150**/\r
28a00297 1151EFI_STATUS\r
1152EFIAPI\r
1153CoreLocateProtocol (\r
23c98c94 1154 IN EFI_GUID *Protocol,\r
1155 IN VOID *Registration OPTIONAL,\r
1156 OUT VOID **Interface\r
1157 );\r
28a00297 1158\r
28a00297 1159\r
162ed594 1160/**\r
1161 return handle database key.\r
28a00297 1162\r
28a00297 1163\r
162ed594 1164 @return Handle database key.\r
28a00297 1165\r
162ed594 1166**/\r
28a00297 1167UINT64\r
1168CoreGetHandleDatabaseKey (\r
1169 VOID\r
23c98c94 1170 );\r
28a00297 1171\r
28a00297 1172\r
162ed594 1173/**\r
1174 Go connect any handles that were created or modified while a image executed.\r
28a00297 1175\r
022c6d45 1176 @param Key The Key to show that the handle has been\r
162ed594 1177 created/modified\r
28a00297 1178\r
162ed594 1179**/\r
28a00297 1180VOID\r
1181CoreConnectHandlesByKey (\r
1182 UINT64 Key\r
23c98c94 1183 );\r
28a00297 1184\r
28a00297 1185\r
28a00297 1186\r
162ed594 1187/**\r
1188 Connects one or more drivers to a controller.\r
28a00297 1189\r
bc2dfdbc
LG
1190 @param ControllerHandle The handle of the controller to which driver(s) are to be connected.\r
1191 @param DriverImageHandle A pointer to an ordered list handles that support the\r
1192 EFI_DRIVER_BINDING_PROTOCOL.\r
1193 @param RemainingDevicePath A pointer to the device path that specifies a child of the\r
1194 controller specified by ControllerHandle.\r
1195 @param Recursive If TRUE, then ConnectController() is called recursively\r
1196 until the entire tree of controllers below the controller specified\r
1197 by ControllerHandle have been created. If FALSE, then\r
1198 the tree of controllers is only expanded one level.\r
1199\r
1200 @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.\r
1201 2) No drivers were connected to ControllerHandle, but\r
1202 RemainingDevicePath is not NULL, and it is an End Device\r
1203 Path Node.\r
1204 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
1205 @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances\r
1206 present in the system.\r
1207 2) No drivers were connected to ControllerHandle.\r
1208 @retval EFI_SECURITY_VIOLATION \r
1209 The user has no permission to start UEFI device drivers on the device path \r
1210 associated with the ControllerHandle or specified by the RemainingDevicePath.\r
28a00297 1211\r
162ed594 1212**/\r
022c6d45 1213EFI_STATUS\r
28a00297 1214EFIAPI\r
1215CoreConnectController (\r
1216 IN EFI_HANDLE ControllerHandle,\r
1217 IN EFI_HANDLE *DriverImageHandle OPTIONAL,\r
1218 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,\r
1219 IN BOOLEAN Recursive\r
23c98c94 1220 );\r
28a00297 1221\r
28a00297 1222\r
28a00297 1223\r
162ed594 1224/**\r
1225 Disonnects a controller from a driver\r
28a00297 1226\r
022c6d45 1227 @param ControllerHandle ControllerHandle The handle of\r
1228 the controller from which\r
1229 driver(s) are to be\r
1230 disconnected.\r
1231 @param DriverImageHandle DriverImageHandle The driver to\r
1232 disconnect from ControllerHandle.\r
1233 @param ChildHandle ChildHandle The handle of the\r
1234 child to destroy.\r
1235\r
1236 @retval EFI_SUCCESS One or more drivers were\r
1237 disconnected from the controller.\r
1238 @retval EFI_SUCCESS On entry, no drivers are managing\r
1239 ControllerHandle.\r
1240 @retval EFI_SUCCESS DriverImageHandle is not NULL,\r
1241 and on entry DriverImageHandle is\r
1242 not managing ControllerHandle.\r
284ee2e8 1243 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
022c6d45 1244 @retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,\r
1245 and it is not a valid EFI_HANDLE.\r
1246 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it\r
1247 is not a valid EFI_HANDLE.\r
1248 @retval EFI_OUT_OF_RESOURCES There are not enough resources\r
1249 available to disconnect any\r
1250 drivers from ControllerHandle.\r
1251 @retval EFI_DEVICE_ERROR The controller could not be\r
1252 disconnected because of a device\r
162ed594 1253 error.\r
28a00297 1254\r
162ed594 1255**/\r
022c6d45 1256EFI_STATUS\r
28a00297 1257EFIAPI\r
1258CoreDisconnectController (\r
23c98c94 1259 IN EFI_HANDLE ControllerHandle,\r
1260 IN EFI_HANDLE DriverImageHandle OPTIONAL,\r
1261 IN EFI_HANDLE ChildHandle OPTIONAL\r
1262 );\r
28a00297 1263\r
28a00297 1264\r
28a00297 1265\r
162ed594 1266/**\r
1267 Allocates pages from the memory map.\r
28a00297 1268\r
022c6d45 1269 @param Type The type of allocation to perform\r
1270 @param MemoryType The type of memory to turn the allocated pages\r
1271 into\r
1272 @param NumberOfPages The number of pages to allocate\r
1273 @param Memory A pointer to receive the base allocated memory\r
1274 address\r
28a00297 1275\r
162ed594 1276 @return Status. On success, Memory is filled in with the base address allocated\r
022c6d45 1277 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in\r
1278 spec.\r
1279 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.\r
1280 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.\r
162ed594 1281 @retval EFI_SUCCESS Pages successfully allocated.\r
28a00297 1282\r
162ed594 1283**/\r
28a00297 1284EFI_STATUS\r
1285EFIAPI\r
1286CoreAllocatePages (\r
23c98c94 1287 IN EFI_ALLOCATE_TYPE Type,\r
1288 IN EFI_MEMORY_TYPE MemoryType,\r
1289 IN UINTN NumberOfPages,\r
1290 IN OUT EFI_PHYSICAL_ADDRESS *Memory\r
1291 );\r
28a00297 1292\r
162ed594 1293/**\r
1294 Frees previous allocated pages.\r
28a00297 1295\r
022c6d45 1296 @param Memory Base address of memory being freed\r
1297 @param NumberOfPages The number of pages to free\r
28a00297 1298\r
022c6d45 1299 @retval EFI_NOT_FOUND Could not find the entry that covers the range\r
1300 @retval EFI_INVALID_PARAMETER Address not aligned\r
162ed594 1301 @return EFI_SUCCESS -Pages successfully freed.\r
28a00297 1302\r
162ed594 1303**/\r
022c6d45 1304EFI_STATUS\r
28a00297 1305EFIAPI\r
1306CoreFreePages (\r
1307 IN EFI_PHYSICAL_ADDRESS Memory,\r
1308 IN UINTN NumberOfPages\r
23c98c94 1309 );\r
28a00297 1310\r
162ed594 1311/**\r
1312 This function returns a copy of the current memory map. The map is an array of\r
1313 memory descriptors, each of which describes a contiguous block of memory.\r
28a00297 1314\r
022c6d45 1315 @param MemoryMapSize A pointer to the size, in bytes, of the\r
1316 MemoryMap buffer. On input, this is the size of\r
1317 the buffer allocated by the caller. On output,\r
1318 it is the size of the buffer returned by the\r
1319 firmware if the buffer was large enough, or the\r
1320 size of the buffer needed to contain the map if\r
1321 the buffer was too small.\r
1322 @param MemoryMap A pointer to the buffer in which firmware places\r
1323 the current memory map.\r
1324 @param MapKey A pointer to the location in which firmware\r
1325 returns the key for the current memory map.\r
1326 @param DescriptorSize A pointer to the location in which firmware\r
1327 returns the size, in bytes, of an individual\r
1328 EFI_MEMORY_DESCRIPTOR.\r
1329 @param DescriptorVersion A pointer to the location in which firmware\r
1330 returns the version number associated with the\r
1331 EFI_MEMORY_DESCRIPTOR.\r
1332\r
1333 @retval EFI_SUCCESS The memory map was returned in the MemoryMap\r
1334 buffer.\r
1335 @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current\r
1336 buffer size needed to hold the memory map is\r
1337 returned in MemoryMapSize.\r
162ed594 1338 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
28a00297 1339\r
162ed594 1340**/\r
28a00297 1341EFI_STATUS\r
1342EFIAPI\r
1343CoreGetMemoryMap (\r
23c98c94 1344 IN OUT UINTN *MemoryMapSize,\r
1345 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,\r
1346 OUT UINTN *MapKey,\r
1347 OUT UINTN *DescriptorSize,\r
1348 OUT UINT32 *DescriptorVersion\r
1349 );\r
28a00297 1350\r
28a00297 1351\r
28a00297 1352\r
162ed594 1353/**\r
1354 Allocate pool of a particular type.\r
28a00297 1355\r
022c6d45 1356 @param PoolType Type of pool to allocate\r
1357 @param Size The amount of pool to allocate\r
1358 @param Buffer The address to return a pointer to the allocated\r
1359 pool\r
28a00297 1360\r
3e058701 1361 @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL\r
022c6d45 1362 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.\r
162ed594 1363 @retval EFI_SUCCESS Pool successfully allocated.\r
28a00297 1364\r
162ed594 1365**/\r
28a00297 1366EFI_STATUS\r
1367EFIAPI\r
1368CoreAllocatePool (\r
23c98c94 1369 IN EFI_MEMORY_TYPE PoolType,\r
1370 IN UINTN Size,\r
1371 OUT VOID **Buffer\r
1372 );\r
28a00297 1373\r
84edd20b
SZ
1374/**\r
1375 Allocate pool of a particular type.\r
1376\r
1377 @param PoolType Type of pool to allocate\r
1378 @param Size The amount of pool to allocate\r
1379 @param Buffer The address to return a pointer to the allocated\r
1380 pool\r
28a00297 1381\r
84edd20b
SZ
1382 @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL\r
1383 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.\r
1384 @retval EFI_SUCCESS Pool successfully allocated.\r
1385\r
1386**/\r
1387EFI_STATUS\r
1388EFIAPI\r
1389CoreInternalAllocatePool (\r
1390 IN EFI_MEMORY_TYPE PoolType,\r
1391 IN UINTN Size,\r
1392 OUT VOID **Buffer\r
1393 );\r
28a00297 1394\r
162ed594 1395/**\r
1396 Frees pool.\r
28a00297 1397\r
022c6d45 1398 @param Buffer The allocated pool entry to free\r
28a00297 1399\r
022c6d45 1400 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.\r
162ed594 1401 @retval EFI_SUCCESS Pool successfully freed.\r
28a00297 1402\r
162ed594 1403**/\r
28a00297 1404EFI_STATUS\r
1405EFIAPI\r
1406CoreFreePool (\r
23c98c94 1407 IN VOID *Buffer\r
1408 );\r
28a00297 1409\r
84edd20b
SZ
1410/**\r
1411 Frees pool.\r
1412\r
1413 @param Buffer The allocated pool entry to free\r
925f0d1a 1414 @param PoolType Pointer to pool type\r
28a00297 1415\r
84edd20b
SZ
1416 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.\r
1417 @retval EFI_SUCCESS Pool successfully freed.\r
1418\r
1419**/\r
1420EFI_STATUS\r
1421EFIAPI\r
1422CoreInternalFreePool (\r
925f0d1a
SZ
1423 IN VOID *Buffer,\r
1424 OUT EFI_MEMORY_TYPE *PoolType OPTIONAL\r
84edd20b 1425 );\r
28a00297 1426\r
162ed594 1427/**\r
1428 Loads an EFI image into memory and returns a handle to the image.\r
28a00297 1429\r
022c6d45 1430 @param BootPolicy If TRUE, indicates that the request originates\r
1431 from the boot manager, and that the boot\r
1432 manager is attempting to load FilePath as a\r
1433 boot selection.\r
1434 @param ParentImageHandle The caller's image handle.\r
1435 @param FilePath The specific file path from which the image is\r
1436 loaded.\r
1437 @param SourceBuffer If not NULL, a pointer to the memory location\r
1438 containing a copy of the image to be loaded.\r
1439 @param SourceSize The size in bytes of SourceBuffer.\r
1440 @param ImageHandle Pointer to the returned image handle that is\r
1441 created when the image is successfully loaded.\r
1442\r
1443 @retval EFI_SUCCESS The image was loaded into memory.\r
1444 @retval EFI_NOT_FOUND The FilePath was not found.\r
1445 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
1446 @retval EFI_UNSUPPORTED The image type is not supported, or the device\r
1447 path cannot be parsed to locate the proper\r
1448 protocol for loading the file.\r
1449 @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient\r
162ed594 1450 resources.\r
b695e7ff
LG
1451 @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not\r
1452 understood.\r
1453 @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.\r
1454 @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the \r
1455 image from being loaded. NULL is returned in *ImageHandle.\r
1456 @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a \r
1457 valid EFI_LOADED_IMAGE_PROTOCOL. However, the current \r
1458 platform policy specifies that the image should not be started.\r
28a00297 1459\r
162ed594 1460**/\r
28a00297 1461EFI_STATUS\r
1462EFIAPI\r
1463CoreLoadImage (\r
23c98c94 1464 IN BOOLEAN BootPolicy,\r
1465 IN EFI_HANDLE ParentImageHandle,\r
1466 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
1467 IN VOID *SourceBuffer OPTIONAL,\r
1468 IN UINTN SourceSize,\r
1469 OUT EFI_HANDLE *ImageHandle\r
1470 );\r
28a00297 1471\r
28a00297 1472\r
28a00297 1473\r
162ed594 1474/**\r
1475 Unloads an image.\r
28a00297 1476\r
022c6d45 1477 @param ImageHandle Handle that identifies the image to be\r
1478 unloaded.\r
28a00297 1479\r
022c6d45 1480 @retval EFI_SUCCESS The image has been unloaded.\r
6393d9c8 1481 @retval EFI_UNSUPPORTED The image has been started, and does not support\r
022c6d45 1482 unload.\r
162ed594 1483 @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.\r
28a00297 1484\r
162ed594 1485**/\r
28a00297 1486EFI_STATUS\r
1487EFIAPI\r
1488CoreUnloadImage (\r
1489 IN EFI_HANDLE ImageHandle\r
23c98c94 1490 );\r
28a00297 1491\r
28a00297 1492\r
28a00297 1493\r
162ed594 1494/**\r
1495 Transfer control to a loaded image's entry point.\r
28a00297 1496\r
022c6d45 1497 @param ImageHandle Handle of image to be started.\r
1498 @param ExitDataSize Pointer of the size to ExitData\r
1499 @param ExitData Pointer to a pointer to a data buffer that\r
b695e7ff 1500 includes a Null-terminated string,\r
022c6d45 1501 optionally followed by additional binary data.\r
1502 The string is a description that the caller may\r
1503 use to further indicate the reason for the\r
1504 image's exit.\r
1505\r
1506 @retval EFI_INVALID_PARAMETER Invalid parameter\r
1507 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate\r
bc2dfdbc 1508 @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.\r
022c6d45 1509 @retval EFI_SUCCESS Successfully transfer control to the image's\r
162ed594 1510 entry point.\r
28a00297 1511\r
162ed594 1512**/\r
28a00297 1513EFI_STATUS\r
1514EFIAPI\r
1515CoreStartImage (\r
23c98c94 1516 IN EFI_HANDLE ImageHandle,\r
1517 OUT UINTN *ExitDataSize,\r
1518 OUT CHAR16 **ExitData OPTIONAL\r
1519 );\r
28a00297 1520\r
28a00297 1521\r
28a00297 1522\r
162ed594 1523/**\r
1524 Terminates the currently loaded EFI image and returns control to boot services.\r
28a00297 1525\r
022c6d45 1526 @param ImageHandle Handle that identifies the image. This\r
1527 parameter is passed to the image on entry.\r
1528 @param Status The image's exit code.\r
1529 @param ExitDataSize The size, in bytes, of ExitData. Ignored if\r
1530 ExitStatus is EFI_SUCCESS.\r
1531 @param ExitData Pointer to a data buffer that includes a\r
1532 Null-terminated Unicode string, optionally\r
1533 followed by additional binary data. The string\r
1534 is a description that the caller may use to\r
1535 further indicate the reason for the image's\r
1536 exit.\r
1537\r
1538 @retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current\r
1539 image.\r
1540 @retval EFI_SUCCESS Successfully terminates the currently loaded\r
1541 EFI image.\r
1542 @retval EFI_ACCESS_DENIED Should never reach there.\r
162ed594 1543 @retval EFI_OUT_OF_RESOURCES Could not allocate pool\r
28a00297 1544\r
162ed594 1545**/\r
28a00297 1546EFI_STATUS\r
1547EFIAPI\r
1548CoreExit (\r
1549 IN EFI_HANDLE ImageHandle,\r
1550 IN EFI_STATUS Status,\r
1551 IN UINTN ExitDataSize,\r
1552 IN CHAR16 *ExitData OPTIONAL\r
23c98c94 1553 );\r
28a00297 1554\r
28a00297 1555\r
28a00297 1556\r
162ed594 1557/**\r
670d4d88 1558 Creates an event.\r
28a00297 1559\r
022c6d45 1560 @param Type The type of event to create and its mode and\r
1561 attributes\r
1562 @param NotifyTpl The task priority level of event notifications\r
1563 @param NotifyFunction Pointer to the events notification function\r
1564 @param NotifyContext Pointer to the notification functions context;\r
1565 corresponds to parameter "Context" in the\r
1566 notification function\r
1567 @param Event Pointer to the newly created event if the call\r
1568 succeeds; undefined otherwise\r
1569\r
1570 @retval EFI_SUCCESS The event structure was created\r
1571 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value\r
162ed594 1572 @retval EFI_OUT_OF_RESOURCES The event could not be allocated\r
28a00297 1573\r
162ed594 1574**/\r
28a00297 1575EFI_STATUS\r
1576EFIAPI\r
1577CoreCreateEvent (\r
23c98c94 1578 IN UINT32 Type,\r
1579 IN EFI_TPL NotifyTpl,\r
1580 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
1581 IN VOID *NotifyContext, OPTIONAL\r
1582 OUT EFI_EVENT *Event\r
1583 );\r
28a00297 1584\r
28a00297 1585\r
28a00297 1586\r
162ed594 1587/**\r
670d4d88 1588 Creates an event in a group.\r
28a00297 1589\r
022c6d45 1590 @param Type The type of event to create and its mode and\r
1591 attributes\r
1592 @param NotifyTpl The task priority level of event notifications\r
1593 @param NotifyFunction Pointer to the events notification function\r
1594 @param NotifyContext Pointer to the notification functions context;\r
1595 corresponds to parameter "Context" in the\r
1596 notification function\r
1597 @param EventGroup GUID for EventGroup if NULL act the same as\r
1598 gBS->CreateEvent().\r
1599 @param Event Pointer to the newly created event if the call\r
1600 succeeds; undefined otherwise\r
1601\r
1602 @retval EFI_SUCCESS The event structure was created\r
1603 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value\r
162ed594 1604 @retval EFI_OUT_OF_RESOURCES The event could not be allocated\r
28a00297 1605\r
162ed594 1606**/\r
28a00297 1607EFI_STATUS\r
1608EFIAPI\r
1609CoreCreateEventEx (\r
1610 IN UINT32 Type,\r
1611 IN EFI_TPL NotifyTpl,\r
1612 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
1613 IN CONST VOID *NotifyContext, OPTIONAL\r
1614 IN CONST EFI_GUID *EventGroup, OPTIONAL\r
1615 OUT EFI_EVENT *Event\r
23c98c94 1616 );\r
28a00297 1617\r
670d4d88
SZ
1618/**\r
1619 Creates a general-purpose event structure\r
1620\r
1621 @param Type The type of event to create and its mode and\r
1622 attributes\r
1623 @param NotifyTpl The task priority level of event notifications\r
1624 @param NotifyFunction Pointer to the events notification function\r
1625 @param NotifyContext Pointer to the notification functions context;\r
1626 corresponds to parameter "Context" in the\r
1627 notification function\r
1628 @param EventGroup GUID for EventGroup if NULL act the same as\r
1629 gBS->CreateEvent().\r
1630 @param Event Pointer to the newly created event if the call\r
1631 succeeds; undefined otherwise\r
28a00297 1632\r
670d4d88
SZ
1633 @retval EFI_SUCCESS The event structure was created\r
1634 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value\r
1635 @retval EFI_OUT_OF_RESOURCES The event could not be allocated\r
1636\r
1637**/\r
1638EFI_STATUS\r
1639EFIAPI\r
1640CoreCreateEventInternal (\r
1641 IN UINT32 Type,\r
1642 IN EFI_TPL NotifyTpl,\r
1643 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
1644 IN CONST VOID *NotifyContext, OPTIONAL\r
1645 IN CONST EFI_GUID *EventGroup, OPTIONAL\r
1646 OUT EFI_EVENT *Event\r
1647 );\r
28a00297 1648\r
162ed594 1649/**\r
1650 Sets the type of timer and the trigger time for a timer event.\r
28a00297 1651\r
022c6d45 1652 @param UserEvent The timer event that is to be signaled at the\r
1653 specified time\r
1654 @param Type The type of time that is specified in\r
1655 TriggerTime\r
1656 @param TriggerTime The number of 100ns units until the timer\r
1657 expires\r
28a00297 1658\r
022c6d45 1659 @retval EFI_SUCCESS The event has been set to be signaled at the\r
1660 requested time\r
162ed594 1661 @retval EFI_INVALID_PARAMETER Event or Type is not valid\r
28a00297 1662\r
162ed594 1663**/\r
28a00297 1664EFI_STATUS\r
1665EFIAPI\r
1666CoreSetTimer (\r
23c98c94 1667 IN EFI_EVENT UserEvent,\r
28a00297 1668 IN EFI_TIMER_DELAY Type,\r
1669 IN UINT64 TriggerTime\r
23c98c94 1670 );\r
28a00297 1671\r
28a00297 1672\r
28a00297 1673\r
162ed594 1674/**\r
022c6d45 1675 Signals the event. Queues the event to be notified if needed.\r
28a00297 1676\r
022c6d45 1677 @param UserEvent The event to signal .\r
28a00297 1678\r
022c6d45 1679 @retval EFI_INVALID_PARAMETER Parameters are not valid.\r
162ed594 1680 @retval EFI_SUCCESS The event was signaled.\r
28a00297 1681\r
162ed594 1682**/\r
28a00297 1683EFI_STATUS\r
1684EFIAPI\r
1685CoreSignalEvent (\r
23c98c94 1686 IN EFI_EVENT UserEvent\r
1687 );\r
28a00297 1688\r
28a00297 1689\r
28a00297 1690\r
162ed594 1691/**\r
1692 Stops execution until an event is signaled.\r
28a00297 1693\r
022c6d45 1694 @param NumberOfEvents The number of events in the UserEvents array\r
1695 @param UserEvents An array of EFI_EVENT\r
1696 @param UserIndex Pointer to the index of the event which\r
1697 satisfied the wait condition\r
28a00297 1698\r
022c6d45 1699 @retval EFI_SUCCESS The event indicated by Index was signaled.\r
1700 @retval EFI_INVALID_PARAMETER The event indicated by Index has a notification\r
1701 function or Event was not a valid type\r
162ed594 1702 @retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION\r
28a00297 1703\r
162ed594 1704**/\r
28a00297 1705EFI_STATUS\r
1706EFIAPI\r
1707CoreWaitForEvent (\r
23c98c94 1708 IN UINTN NumberOfEvents,\r
1709 IN EFI_EVENT *UserEvents,\r
1710 OUT UINTN *UserIndex\r
1711 );\r
28a00297 1712\r
28a00297 1713\r
28a00297 1714\r
162ed594 1715/**\r
1716 Closes an event and frees the event structure.\r
28a00297 1717\r
022c6d45 1718 @param UserEvent Event to close\r
28a00297 1719\r
022c6d45 1720 @retval EFI_INVALID_PARAMETER Parameters are not valid.\r
162ed594 1721 @retval EFI_SUCCESS The event has been closed\r
28a00297 1722\r
162ed594 1723**/\r
28a00297 1724EFI_STATUS\r
1725EFIAPI\r
1726CoreCloseEvent (\r
23c98c94 1727 IN EFI_EVENT UserEvent\r
1728 );\r
28a00297 1729\r
28a00297 1730\r
28a00297 1731\r
162ed594 1732/**\r
1733 Check the status of an event.\r
28a00297 1734\r
022c6d45 1735 @param UserEvent The event to check\r
28a00297 1736\r
022c6d45 1737 @retval EFI_SUCCESS The event is in the signaled state\r
1738 @retval EFI_NOT_READY The event is not in the signaled state\r
162ed594 1739 @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL\r
28a00297 1740\r
162ed594 1741**/\r
28a00297 1742EFI_STATUS\r
1743EFIAPI\r
1744CoreCheckEvent (\r
23c98c94 1745 IN EFI_EVENT UserEvent\r
1746 );\r
28a00297 1747\r
28a00297 1748\r
162ed594 1749/**\r
1750 Adds reserved memory, system memory, or memory-mapped I/O resources to the\r
1751 global coherency domain of the processor.\r
28a00297 1752\r
022c6d45 1753 @param GcdMemoryType Memory type of the memory space.\r
1754 @param BaseAddress Base address of the memory space.\r
1755 @param Length Length of the memory space.\r
1756 @param Capabilities alterable attributes of the memory space.\r
28a00297 1757\r
162ed594 1758 @retval EFI_SUCCESS Merged this memory space into GCD map.\r
28a00297 1759\r
162ed594 1760**/\r
28a00297 1761EFI_STATUS\r
3b6ffb6a 1762EFIAPI\r
28a00297 1763CoreAddMemorySpace (\r
1764 IN EFI_GCD_MEMORY_TYPE GcdMemoryType,\r
1765 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1766 IN UINT64 Length,\r
1767 IN UINT64 Capabilities\r
23c98c94 1768 );\r
28a00297 1769\r
28a00297 1770\r
162ed594 1771/**\r
1772 Allocates nonexistent memory, reserved memory, system memory, or memorymapped\r
1773 I/O resources from the global coherency domain of the processor.\r
28a00297 1774\r
022c6d45 1775 @param GcdAllocateType The type of allocate operation\r
1776 @param GcdMemoryType The desired memory type\r
1777 @param Alignment Align with 2^Alignment\r
1778 @param Length Length to allocate\r
1779 @param BaseAddress Base address to allocate\r
1780 @param ImageHandle The image handle consume the allocated space.\r
1781 @param DeviceHandle The device handle consume the allocated space.\r
28a00297 1782\r
022c6d45 1783 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1784 @retval EFI_NOT_FOUND No descriptor contains the desired space.\r
162ed594 1785 @retval EFI_SUCCESS Memory space successfully allocated.\r
28a00297 1786\r
162ed594 1787**/\r
28a00297 1788EFI_STATUS\r
3b6ffb6a 1789EFIAPI\r
28a00297 1790CoreAllocateMemorySpace (\r
1791 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,\r
1792 IN EFI_GCD_MEMORY_TYPE GcdMemoryType,\r
1793 IN UINTN Alignment,\r
1794 IN UINT64 Length,\r
1795 IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,\r
1796 IN EFI_HANDLE ImageHandle,\r
1797 IN EFI_HANDLE DeviceHandle OPTIONAL\r
23c98c94 1798 );\r
28a00297 1799\r
28a00297 1800\r
162ed594 1801/**\r
1802 Frees nonexistent memory, reserved memory, system memory, or memory-mapped\r
1803 I/O resources from the global coherency domain of the processor.\r
28a00297 1804\r
022c6d45 1805 @param BaseAddress Base address of the memory space.\r
1806 @param Length Length of the memory space.\r
28a00297 1807\r
162ed594 1808 @retval EFI_SUCCESS Space successfully freed.\r
28a00297 1809\r
162ed594 1810**/\r
28a00297 1811EFI_STATUS\r
3b6ffb6a 1812EFIAPI\r
28a00297 1813CoreFreeMemorySpace (\r
1814 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1815 IN UINT64 Length\r
23c98c94 1816 );\r
28a00297 1817\r
28a00297 1818\r
162ed594 1819/**\r
1820 Removes reserved memory, system memory, or memory-mapped I/O resources from\r
1821 the global coherency domain of the processor.\r
28a00297 1822\r
022c6d45 1823 @param BaseAddress Base address of the memory space.\r
1824 @param Length Length of the memory space.\r
28a00297 1825\r
162ed594 1826 @retval EFI_SUCCESS Successfully remove a segment of memory space.\r
28a00297 1827\r
162ed594 1828**/\r
28a00297 1829EFI_STATUS\r
3b6ffb6a 1830EFIAPI\r
28a00297 1831CoreRemoveMemorySpace (\r
1832 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1833 IN UINT64 Length\r
23c98c94 1834 );\r
28a00297 1835\r
28a00297 1836\r
162ed594 1837/**\r
1838 Retrieves the descriptor for a memory region containing a specified address.\r
28a00297 1839\r
022c6d45 1840 @param BaseAddress Specified start address\r
1841 @param Descriptor Specified length\r
28a00297 1842\r
022c6d45 1843 @retval EFI_INVALID_PARAMETER Invalid parameter\r
162ed594 1844 @retval EFI_SUCCESS Successfully get memory space descriptor.\r
28a00297 1845\r
162ed594 1846**/\r
28a00297 1847EFI_STATUS\r
3b6ffb6a 1848EFIAPI\r
28a00297 1849CoreGetMemorySpaceDescriptor (\r
1850 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1851 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor\r
23c98c94 1852 );\r
28a00297 1853\r
28a00297 1854\r
162ed594 1855/**\r
1856 Modifies the attributes for a memory region in the global coherency domain of the\r
1857 processor.\r
28a00297 1858\r
022c6d45 1859 @param BaseAddress Specified start address\r
1860 @param Length Specified length\r
1861 @param Attributes Specified attributes\r
28a00297 1862\r
fc8ff20f 1863 @retval EFI_SUCCESS The attributes were set for the memory region.\r
1864 @retval EFI_INVALID_PARAMETER Length is zero. \r
1865 @retval EFI_UNSUPPORTED The processor does not support one or more bytes of the memory\r
1866 resource range specified by BaseAddress and Length.\r
1867 @retval EFI_UNSUPPORTED The bit mask of attributes is not support for the memory resource\r
1868 range specified by BaseAddress and Length.\r
771ee501 1869 @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by\r
fc8ff20f 1870 BaseAddress and Length cannot be modified.\r
1871 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the attributes of\r
1872 the memory resource range.\r
1873 @retval EFI_NOT_AVAILABLE_YET The attributes cannot be set because CPU architectural protocol is\r
1874 not available yet.\r
28a00297 1875\r
162ed594 1876**/\r
28a00297 1877EFI_STATUS\r
3b6ffb6a 1878EFIAPI\r
28a00297 1879CoreSetMemorySpaceAttributes (\r
1880 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1881 IN UINT64 Length,\r
1882 IN UINT64 Attributes\r
23c98c94 1883 );\r
28a00297 1884\r
28a00297 1885\r
771ee501
EC
1886/**\r
1887 Modifies the capabilities for a memory region in the global coherency domain of the\r
1888 processor.\r
1889\r
1890 @param BaseAddress The physical address that is the start address of a memory region.\r
1891 @param Length The size in bytes of the memory region.\r
1892 @param Capabilities The bit mask of capabilities that the memory region supports.\r
1893\r
1894 @retval EFI_SUCCESS The capabilities were set for the memory region.\r
1895 @retval EFI_INVALID_PARAMETER Length is zero.\r
1896 @retval EFI_UNSUPPORTED The capabilities specified by Capabilities do not include the\r
1897 memory region attributes currently in use.\r
1898 @retval EFI_ACCESS_DENIED The capabilities for the memory resource range specified by\r
1899 BaseAddress and Length cannot be modified.\r
1900 @retval EFI_OUT_OF_RESOURCES There are not enough system resources to modify the capabilities\r
1901 of the memory resource range.\r
1902**/\r
1903EFI_STATUS\r
1904EFIAPI\r
1905CoreSetMemorySpaceCapabilities (\r
1906 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1907 IN UINT64 Length,\r
1908 IN UINT64 Capabilities\r
1909 );\r
1910\r
1911\r
162ed594 1912/**\r
1913 Returns a map of the memory resources in the global coherency domain of the\r
1914 processor.\r
28a00297 1915\r
022c6d45 1916 @param NumberOfDescriptors Number of descriptors.\r
1917 @param MemorySpaceMap Descriptor array\r
28a00297 1918\r
022c6d45 1919 @retval EFI_INVALID_PARAMETER Invalid parameter\r
1920 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate\r
162ed594 1921 @retval EFI_SUCCESS Successfully get memory space map.\r
28a00297 1922\r
162ed594 1923**/\r
28a00297 1924EFI_STATUS\r
3b6ffb6a 1925EFIAPI\r
28a00297 1926CoreGetMemorySpaceMap (\r
1927 OUT UINTN *NumberOfDescriptors,\r
1928 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **MemorySpaceMap\r
23c98c94 1929 );\r
28a00297 1930\r
28a00297 1931\r
162ed594 1932/**\r
1933 Adds reserved I/O or I/O resources to the global coherency domain of the processor.\r
28a00297 1934\r
022c6d45 1935 @param GcdIoType IO type of the segment.\r
1936 @param BaseAddress Base address of the segment.\r
1937 @param Length Length of the segment.\r
28a00297 1938\r
022c6d45 1939 @retval EFI_SUCCESS Merged this segment into GCD map.\r
162ed594 1940 @retval EFI_INVALID_PARAMETER Parameter not valid\r
28a00297 1941\r
162ed594 1942**/\r
28a00297 1943EFI_STATUS\r
3b6ffb6a 1944EFIAPI\r
28a00297 1945CoreAddIoSpace (\r
1946 IN EFI_GCD_IO_TYPE GcdIoType,\r
1947 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1948 IN UINT64 Length\r
23c98c94 1949 );\r
28a00297 1950\r
28a00297 1951\r
162ed594 1952/**\r
1953 Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency\r
1954 domain of the processor.\r
28a00297 1955\r
022c6d45 1956 @param GcdAllocateType The type of allocate operation\r
1957 @param GcdIoType The desired IO type\r
1958 @param Alignment Align with 2^Alignment\r
1959 @param Length Length to allocate\r
1960 @param BaseAddress Base address to allocate\r
1961 @param ImageHandle The image handle consume the allocated space.\r
1962 @param DeviceHandle The device handle consume the allocated space.\r
28a00297 1963\r
022c6d45 1964 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1965 @retval EFI_NOT_FOUND No descriptor contains the desired space.\r
162ed594 1966 @retval EFI_SUCCESS IO space successfully allocated.\r
28a00297 1967\r
162ed594 1968**/\r
28a00297 1969EFI_STATUS\r
3b6ffb6a 1970EFIAPI\r
28a00297 1971CoreAllocateIoSpace (\r
1972 IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,\r
1973 IN EFI_GCD_IO_TYPE GcdIoType,\r
1974 IN UINTN Alignment,\r
1975 IN UINT64 Length,\r
1976 IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,\r
1977 IN EFI_HANDLE ImageHandle,\r
1978 IN EFI_HANDLE DeviceHandle OPTIONAL\r
23c98c94 1979 );\r
28a00297 1980\r
28a00297 1981\r
162ed594 1982/**\r
1983 Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency\r
1984 domain of the processor.\r
28a00297 1985\r
022c6d45 1986 @param BaseAddress Base address of the segment.\r
1987 @param Length Length of the segment.\r
28a00297 1988\r
162ed594 1989 @retval EFI_SUCCESS Space successfully freed.\r
28a00297 1990\r
162ed594 1991**/\r
28a00297 1992EFI_STATUS\r
3b6ffb6a 1993EFIAPI\r
28a00297 1994CoreFreeIoSpace (\r
1995 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1996 IN UINT64 Length\r
23c98c94 1997 );\r
28a00297 1998\r
28a00297 1999\r
162ed594 2000/**\r
2001 Removes reserved I/O or I/O resources from the global coherency domain of the\r
2002 processor.\r
28a00297 2003\r
022c6d45 2004 @param BaseAddress Base address of the segment.\r
2005 @param Length Length of the segment.\r
28a00297 2006\r
162ed594 2007 @retval EFI_SUCCESS Successfully removed a segment of IO space.\r
28a00297 2008\r
162ed594 2009**/\r
28a00297 2010EFI_STATUS\r
3b6ffb6a 2011EFIAPI\r
28a00297 2012CoreRemoveIoSpace (\r
2013 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
2014 IN UINT64 Length\r
23c98c94 2015 );\r
28a00297 2016\r
28a00297 2017\r
162ed594 2018/**\r
2019 Retrieves the descriptor for an I/O region containing a specified address.\r
28a00297 2020\r
022c6d45 2021 @param BaseAddress Specified start address\r
2022 @param Descriptor Specified length\r
28a00297 2023\r
022c6d45 2024 @retval EFI_INVALID_PARAMETER Descriptor is NULL.\r
162ed594 2025 @retval EFI_SUCCESS Successfully get the IO space descriptor.\r
28a00297 2026\r
162ed594 2027**/\r
28a00297 2028EFI_STATUS\r
3b6ffb6a 2029EFIAPI\r
28a00297 2030CoreGetIoSpaceDescriptor (\r
2031 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
2032 OUT EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor\r
23c98c94 2033 );\r
28a00297 2034\r
28a00297 2035\r
162ed594 2036/**\r
2037 Returns a map of the I/O resources in the global coherency domain of the processor.\r
28a00297 2038\r
022c6d45 2039 @param NumberOfDescriptors Number of descriptors.\r
2040 @param IoSpaceMap Descriptor array\r
28a00297 2041\r
022c6d45 2042 @retval EFI_INVALID_PARAMETER Invalid parameter\r
2043 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate\r
162ed594 2044 @retval EFI_SUCCESS Successfully get IO space map.\r
28a00297 2045\r
162ed594 2046**/\r
28a00297 2047EFI_STATUS\r
3b6ffb6a 2048EFIAPI\r
28a00297 2049CoreGetIoSpaceMap (\r
2050 OUT UINTN *NumberOfDescriptors,\r
2051 OUT EFI_GCD_IO_SPACE_DESCRIPTOR **IoSpaceMap\r
23c98c94 2052 );\r
28a00297 2053\r
28a00297 2054\r
162ed594 2055/**\r
2056 This is the main Dispatcher for DXE and it exits when there are no more\r
2057 drivers to run. Drain the mScheduledQueue and load and start a PE\r
2058 image for each driver. Search the mDiscoveredList to see if any driver can\r
2059 be placed on the mScheduledQueue. If no drivers are placed on the\r
2060 mScheduledQueue exit the function. On exit it is assumed the Bds()\r
2061 will be called, and when the Bds() exits the Dispatcher will be called\r
2062 again.\r
28a00297 2063\r
022c6d45 2064 @retval EFI_ALREADY_STARTED The DXE Dispatcher is already running\r
2065 @retval EFI_NOT_FOUND No DXE Drivers were dispatched\r
2066 @retval EFI_SUCCESS One or more DXE Drivers were dispatched\r
28a00297 2067\r
23c98c94 2068**/\r
28a00297 2069EFI_STATUS\r
2070EFIAPI\r
2071CoreDispatcher (\r
2072 VOID\r
23c98c94 2073 );\r
28a00297 2074\r
162ed594 2075/**\r
2076 Check every driver and locate a matching one. If the driver is found, the Unrequested\r
2077 state flag is cleared.\r
28a00297 2078\r
022c6d45 2079 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains\r
2080 the firmware file specified by DriverName.\r
2081 @param DriverName The Driver name to put in the Dependent state.\r
28a00297 2082\r
022c6d45 2083 @retval EFI_SUCCESS The DriverName was found and it's SOR bit was\r
2084 cleared\r
2085 @retval EFI_NOT_FOUND The DriverName does not exist or it's SOR bit was\r
2086 not set.\r
28a00297 2087\r
23c98c94 2088**/\r
28a00297 2089EFI_STATUS\r
2090EFIAPI\r
2091CoreSchedule (\r
2092 IN EFI_HANDLE FirmwareVolumeHandle,\r
2093 IN EFI_GUID *DriverName\r
23c98c94 2094 );\r
28a00297 2095\r
28a00297 2096\r
162ed594 2097/**\r
022c6d45 2098 Convert a driver from the Untrused back to the Scheduled state.\r
28a00297 2099\r
022c6d45 2100 @param FirmwareVolumeHandle The handle of the Firmware Volume that contains\r
2101 the firmware file specified by DriverName.\r
2102 @param DriverName The Driver name to put in the Scheduled state\r
28a00297 2103\r
022c6d45 2104 @retval EFI_SUCCESS The file was found in the untrusted state, and it\r
2105 was promoted to the trusted state.\r
2106 @retval EFI_NOT_FOUND The file was not found in the untrusted state.\r
28a00297 2107\r
23c98c94 2108**/\r
28a00297 2109EFI_STATUS\r
2110EFIAPI\r
2111CoreTrust (\r
2112 IN EFI_HANDLE FirmwareVolumeHandle,\r
2113 IN EFI_GUID *DriverName\r
23c98c94 2114 );\r
28a00297 2115\r
28a00297 2116\r
162ed594 2117/**\r
2118 This routine is the driver initialization entry point. It initializes the\r
2119 libraries, and registers two notification functions. These notification\r
2120 functions are responsible for building the FV stack dynamically.\r
28a00297 2121\r
022c6d45 2122 @param ImageHandle The image handle.\r
2123 @param SystemTable The system table.\r
28a00297 2124\r
162ed594 2125 @retval EFI_SUCCESS Function successfully returned.\r
28a00297 2126\r
162ed594 2127**/\r
28a00297 2128EFI_STATUS\r
2129EFIAPI\r
2130FwVolDriverInit (\r
2131 IN EFI_HANDLE ImageHandle,\r
2132 IN EFI_SYSTEM_TABLE *SystemTable\r
23c98c94 2133 );\r
28a00297 2134\r
28a00297 2135\r
162ed594 2136/**\r
2137 Entry point of the section extraction code. Initializes an instance of the\r
2138 section extraction interface and installs it on a new handle.\r
2139\r
2140 @param ImageHandle A handle for the image that is initializing this driver\r
2141 @param SystemTable A pointer to the EFI system table\r
28a00297 2142\r
162ed594 2143 @retval EFI_SUCCESS Driver initialized successfully\r
2144 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources\r
2145\r
2146**/\r
28a00297 2147EFI_STATUS\r
2148EFIAPI\r
2149InitializeSectionExtraction (\r
2150 IN EFI_HANDLE ImageHandle,\r
2151 IN EFI_SYSTEM_TABLE *SystemTable\r
23c98c94 2152 );\r
28a00297 2153\r
28a00297 2154\r
162ed594 2155/**\r
2156 This DXE service routine is used to process a firmware volume. In\r
2157 particular, it can be called by BDS to process a single firmware\r
2158 volume found in a capsule.\r
28a00297 2159\r
022c6d45 2160 @param FvHeader pointer to a firmware volume header\r
2161 @param Size the size of the buffer pointed to by FvHeader\r
2162 @param FVProtocolHandle the handle on which a firmware volume protocol\r
2163 was produced for the firmware volume passed in.\r
28a00297 2164\r
022c6d45 2165 @retval EFI_OUT_OF_RESOURCES if an FVB could not be produced due to lack of\r
2166 system resources\r
2167 @retval EFI_VOLUME_CORRUPTED if the volume was corrupted\r
2168 @retval EFI_SUCCESS a firmware volume protocol was produced for the\r
162ed594 2169 firmware volume\r
28a00297 2170\r
162ed594 2171**/\r
28a00297 2172EFI_STATUS\r
3b6ffb6a 2173EFIAPI\r
28a00297 2174CoreProcessFirmwareVolume (\r
23c98c94 2175 IN VOID *FvHeader,\r
022c6d45 2176 IN UINTN Size,\r
23c98c94 2177 OUT EFI_HANDLE *FVProtocolHandle\r
2178 );\r
28a00297 2179\r
2180//\r
2181//Functions used during debug buils\r
2182//\r
162ed594 2183\r
2184/**\r
2185 Displays Architectural protocols that were not loaded and are required for DXE\r
23c98c94 2186 core to function. Only used in Debug Builds.\r
162ed594 2187\r
2188**/\r
28a00297 2189VOID\r
2190CoreDisplayMissingArchProtocols (\r
2191 VOID\r
23c98c94 2192 );\r
022c6d45 2193\r
28a00297 2194\r
162ed594 2195/**\r
2196 Traverse the discovered list for any drivers that were discovered but not loaded\r
2197 because the dependency experessions evaluated to false.\r
28a00297 2198\r
162ed594 2199**/\r
28a00297 2200VOID\r
2201CoreDisplayDiscoveredNotDispatched (\r
2202 VOID\r
23c98c94 2203 );\r
28a00297 2204\r
28a00297 2205\r
162ed594 2206/**\r
23c98c94 2207 Place holder function until all the Boot Services and Runtime Services are\r
2208 available.\r
28a00297 2209\r
162ed594 2210 @return EFI_NOT_AVAILABLE_YET\r
28a00297 2211\r
162ed594 2212**/\r
28a00297 2213EFI_STATUS\r
2214EFIAPI\r
2215CoreEfiNotAvailableYetArg0 (\r
2216 VOID\r
23c98c94 2217 );\r
28a00297 2218\r
28a00297 2219\r
162ed594 2220/**\r
23c98c94 2221 Place holder function until all the Boot Services and Runtime Services are\r
2222 available.\r
28a00297 2223\r
022c6d45 2224 @param Arg1 Undefined\r
28a00297 2225\r
162ed594 2226 @return EFI_NOT_AVAILABLE_YET\r
28a00297 2227\r
162ed594 2228**/\r
28a00297 2229EFI_STATUS\r
2230EFIAPI\r
2231CoreEfiNotAvailableYetArg1 (\r
2232 UINTN Arg1\r
23c98c94 2233 );\r
28a00297 2234\r
28a00297 2235\r
162ed594 2236/**\r
2237 Place holder function until all the Boot Services and Runtime Services are available.\r
28a00297 2238\r
022c6d45 2239 @param Arg1 Undefined\r
2240 @param Arg2 Undefined\r
28a00297 2241\r
162ed594 2242 @return EFI_NOT_AVAILABLE_YET\r
28a00297 2243\r
162ed594 2244**/\r
28a00297 2245EFI_STATUS\r
2246EFIAPI\r
2247CoreEfiNotAvailableYetArg2 (\r
2248 UINTN Arg1,\r
2249 UINTN Arg2\r
23c98c94 2250 );\r
28a00297 2251\r
28a00297 2252\r
162ed594 2253/**\r
2254 Place holder function until all the Boot Services and Runtime Services are available.\r
28a00297 2255\r
022c6d45 2256 @param Arg1 Undefined\r
2257 @param Arg2 Undefined\r
2258 @param Arg3 Undefined\r
28a00297 2259\r
162ed594 2260 @return EFI_NOT_AVAILABLE_YET\r
28a00297 2261\r
162ed594 2262**/\r
28a00297 2263EFI_STATUS\r
2264EFIAPI\r
2265CoreEfiNotAvailableYetArg3 (\r
2266 UINTN Arg1,\r
2267 UINTN Arg2,\r
2268 UINTN Arg3\r
23c98c94 2269 );\r
28a00297 2270\r
28a00297 2271\r
162ed594 2272/**\r
2273 Place holder function until all the Boot Services and Runtime Services are available.\r
28a00297 2274\r
022c6d45 2275 @param Arg1 Undefined\r
2276 @param Arg2 Undefined\r
2277 @param Arg3 Undefined\r
2278 @param Arg4 Undefined\r
28a00297 2279\r
162ed594 2280 @return EFI_NOT_AVAILABLE_YET\r
28a00297 2281\r
162ed594 2282**/\r
28a00297 2283EFI_STATUS\r
2284EFIAPI\r
2285CoreEfiNotAvailableYetArg4 (\r
2286 UINTN Arg1,\r
2287 UINTN Arg2,\r
2288 UINTN Arg3,\r
2289 UINTN Arg4\r
23c98c94 2290 );\r
28a00297 2291\r
28a00297 2292\r
162ed594 2293/**\r
2294 Place holder function until all the Boot Services and Runtime Services are available.\r
28a00297 2295\r
022c6d45 2296 @param Arg1 Undefined\r
2297 @param Arg2 Undefined\r
2298 @param Arg3 Undefined\r
2299 @param Arg4 Undefined\r
2300 @param Arg5 Undefined\r
28a00297 2301\r
162ed594 2302 @return EFI_NOT_AVAILABLE_YET\r
28a00297 2303\r
162ed594 2304**/\r
28a00297 2305EFI_STATUS\r
2306EFIAPI\r
2307CoreEfiNotAvailableYetArg5 (\r
2308 UINTN Arg1,\r
2309 UINTN Arg2,\r
2310 UINTN Arg3,\r
2311 UINTN Arg4,\r
2312 UINTN Arg5\r
23c98c94 2313 );\r
28a00297 2314\r
28a00297 2315\r
162ed594 2316/**\r
2317 Given a compressed source buffer, this function retrieves the size of the\r
2318 uncompressed buffer and the size of the scratch buffer required to decompress\r
2319 the compressed source buffer.\r
2320\r
2321 The GetInfo() function retrieves the size of the uncompressed buffer and the\r
2322 temporary scratch buffer required to decompress the buffer specified by Source\r
2323 and SourceSize. If the size of the uncompressed buffer or the size of the\r
2324 scratch buffer cannot be determined from the compressed data specified by\r
2325 Source and SourceData, then EFI_INVALID_PARAMETER is returned. Otherwise, the\r
2326 size of the uncompressed buffer is returned in DestinationSize, the size of\r
2327 the scratch buffer is returned in ScratchSize, and EFI_SUCCESS is returned.\r
2328 The GetInfo() function does not have scratch buffer available to perform a\r
2329 thorough checking of the validity of the source data. It just retrieves the\r
2330 "Original Size" field from the beginning bytes of the source data and output\r
2331 it as DestinationSize. And ScratchSize is specific to the decompression\r
2332 implementation.\r
2333\r
2334 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.\r
2335 @param Source The source buffer containing the compressed data.\r
2336 @param SourceSize The size, in bytes, of the source buffer.\r
2337 @param DestinationSize A pointer to the size, in bytes, of the\r
2338 uncompressed buffer that will be generated when the\r
2339 compressed buffer specified by Source and\r
2340 SourceSize is decompressed.\r
2341 @param ScratchSize A pointer to the size, in bytes, of the scratch\r
2342 buffer that is required to decompress the\r
2343 compressed buffer specified by Source and\r
2344 SourceSize.\r
022c6d45 2345\r
162ed594 2346 @retval EFI_SUCCESS The size of the uncompressed data was returned in\r
2347 DestinationSize and the size of the scratch buffer\r
2348 was returned in ScratchSize.\r
2349 @retval EFI_INVALID_PARAMETER The size of the uncompressed data or the size of\r
2350 the scratch buffer cannot be determined from the\r
2351 compressed data specified by Source and\r
2352 SourceSize.\r
28a00297 2353\r
162ed594 2354**/\r
28a00297 2355EFI_STATUS\r
23c98c94 2356EFIAPI\r
28a00297 2357DxeMainUefiDecompressGetInfo (\r
2358 IN EFI_DECOMPRESS_PROTOCOL *This,\r
2359 IN VOID *Source,\r
2360 IN UINT32 SourceSize,\r
2361 OUT UINT32 *DestinationSize,\r
2362 OUT UINT32 *ScratchSize\r
2363 );\r
2364\r
162ed594 2365\r
2366/**\r
2367 Decompresses a compressed source buffer.\r
2368\r
2369 The Decompress() function extracts decompressed data to its original form.\r
2370 This protocol is designed so that the decompression algorithm can be\r
2371 implemented without using any memory services. As a result, the Decompress()\r
2372 Function is not allowed to call AllocatePool() or AllocatePages() in its\r
db405d1b 2373 implementation. It is the caller's responsibility to allocate and free the\r
162ed594 2374 Destination and Scratch buffers.\r
2375 If the compressed source data specified by Source and SourceSize is\r
2376 sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If\r
2377 the compressed source data specified by Source and SourceSize is not in a\r
2378 valid compressed data format, then EFI_INVALID_PARAMETER is returned.\r
2379\r
2380 @param This A pointer to the EFI_DECOMPRESS_PROTOCOL instance.\r
2381 @param Source The source buffer containing the compressed data.\r
2382 @param SourceSize SourceSizeThe size of source data.\r
2383 @param Destination On output, the destination buffer that contains\r
2384 the uncompressed data.\r
2385 @param DestinationSize The size of the destination buffer. The size of\r
2386 the destination buffer needed is obtained from\r
2387 EFI_DECOMPRESS_PROTOCOL.GetInfo().\r
2388 @param Scratch A temporary scratch buffer that is used to perform\r
2389 the decompression.\r
2390 @param ScratchSize The size of scratch buffer. The size of the\r
2391 scratch buffer needed is obtained from GetInfo().\r
022c6d45 2392\r
162ed594 2393 @retval EFI_SUCCESS Decompression completed successfully, and the\r
2394 uncompressed buffer is returned in Destination.\r
2395 @retval EFI_INVALID_PARAMETER The source buffer specified by Source and\r
2396 SourceSize is corrupted (not in a valid\r
2397 compressed format).\r
2398\r
2399**/\r
28a00297 2400EFI_STATUS\r
2401EFIAPI\r
2402DxeMainUefiDecompress (\r
022c6d45 2403 IN EFI_DECOMPRESS_PROTOCOL *This,\r
28a00297 2404 IN VOID *Source,\r
2405 IN UINT32 SourceSize,\r
2406 IN OUT VOID *Destination,\r
2407 IN UINT32 DestinationSize,\r
2408 IN OUT VOID *Scratch,\r
2409 IN UINT32 ScratchSize\r
2410 );\r
2411\r
162ed594 2412/**\r
2413 SEP member function. This function creates and returns a new section stream\r
2414 handle to represent the new section stream.\r
28a00297 2415\r
022c6d45 2416 @param SectionStreamLength Size in bytes of the section stream.\r
2417 @param SectionStream Buffer containing the new section stream.\r
2418 @param SectionStreamHandle A pointer to a caller allocated UINTN that on\r
2419 output contains the new section stream handle.\r
28a00297 2420\r
162ed594 2421 @retval EFI_SUCCESS The section stream is created successfully.\r
022c6d45 2422 @retval EFI_OUT_OF_RESOURCES memory allocation failed.\r
2423 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end\r
162ed594 2424 of last section.\r
28a00297 2425\r
162ed594 2426**/\r
797a9d67 2427EFI_STATUS\r
2428EFIAPI\r
2429OpenSectionStream (\r
2430 IN UINTN SectionStreamLength,\r
2431 IN VOID *SectionStream,\r
2432 OUT UINTN *SectionStreamHandle\r
2433 );\r
2434\r
162ed594 2435\r
2436\r
2437/**\r
2438 SEP member function. Retrieves requested section from section stream.\r
2439\r
2440 @param SectionStreamHandle The section stream from which to extract the\r
2441 requested section.\r
2442 @param SectionType A pointer to the type of section to search for.\r
2443 @param SectionDefinitionGuid If the section type is EFI_SECTION_GUID_DEFINED,\r
2444 then SectionDefinitionGuid indicates which of\r
2445 these types of sections to search for.\r
2446 @param SectionInstance Indicates which instance of the requested\r
2447 section to return.\r
2448 @param Buffer Double indirection to buffer. If *Buffer is\r
2449 non-null on input, then the buffer is caller\r
2450 allocated. If Buffer is NULL, then the buffer\r
2451 is callee allocated. In either case, the\r
2048c585 2452 required buffer size is returned in *BufferSize.\r
162ed594 2453 @param BufferSize On input, indicates the size of *Buffer if\r
2454 *Buffer is non-null on input. On output,\r
2455 indicates the required size (allocated size if\r
2456 callee allocated) of *Buffer.\r
2457 @param AuthenticationStatus A pointer to a caller-allocated UINT32 that\r
2458 indicates the authentication status of the\r
db405d1b 2459 output buffer. If the input section's\r
162ed594 2460 GuidedSectionHeader.Attributes field\r
2461 has the EFI_GUIDED_SECTION_AUTH_STATUS_VALID\r
2462 bit as clear, AuthenticationStatus must return\r
2463 zero. Both local bits (19:16) and aggregate\r
2464 bits (3:0) in AuthenticationStatus are returned\r
2465 by ExtractSection(). These bits reflect the\r
2466 status of the extraction operation. The bit\r
2467 pattern in both regions must be the same, as\r
2468 the local and aggregate authentication statuses\r
2469 have equivalent meaning at this level. If the\r
2470 function returns anything other than\r
2471 EFI_SUCCESS, the value of *AuthenticationStatus\r
2472 is undefined.\r
6c85d162 2473 @param IsFfs3Fv Indicates the FV format.\r
162ed594 2474\r
2475 @retval EFI_SUCCESS Section was retrieved successfully\r
2476 @retval EFI_PROTOCOL_ERROR A GUID defined section was encountered in the\r
2477 section stream with its\r
2478 EFI_GUIDED_SECTION_PROCESSING_REQUIRED bit set,\r
2479 but there was no corresponding GUIDed Section\r
2480 Extraction Protocol in the handle database.\r
2481 *Buffer is unmodified.\r
2482 @retval EFI_NOT_FOUND An error was encountered when parsing the\r
2483 SectionStream. This indicates the SectionStream\r
2484 is not correctly formatted.\r
2485 @retval EFI_NOT_FOUND The requested section does not exist.\r
2486 @retval EFI_OUT_OF_RESOURCES The system has insufficient resources to process\r
2487 the request.\r
2488 @retval EFI_INVALID_PARAMETER The SectionStreamHandle does not exist.\r
2489 @retval EFI_WARN_TOO_SMALL The size of the caller allocated input buffer is\r
2490 insufficient to contain the requested section.\r
2491 The input buffer is filled and section contents\r
2492 are truncated.\r
2493\r
2494**/\r
797a9d67 2495EFI_STATUS\r
2496EFIAPI\r
2497GetSection (\r
2498 IN UINTN SectionStreamHandle,\r
2499 IN EFI_SECTION_TYPE *SectionType,\r
2500 IN EFI_GUID *SectionDefinitionGuid,\r
2501 IN UINTN SectionInstance,\r
2502 IN VOID **Buffer,\r
2503 IN OUT UINTN *BufferSize,\r
6c85d162
SZ
2504 OUT UINT32 *AuthenticationStatus,\r
2505 IN BOOLEAN IsFfs3Fv\r
797a9d67 2506 );\r
2507\r
162ed594 2508\r
2509/**\r
2510 SEP member function. Deletes an existing section stream\r
2511\r
022c6d45 2512 @param StreamHandleToClose Indicates the stream to close\r
eb1cace2
SZ
2513 @param FreeStreamBuffer TRUE - Need to free stream buffer;\r
2514 FALSE - No need to free stream buffer.\r
162ed594 2515\r
2516 @retval EFI_SUCCESS The section stream is closed sucessfully.\r
022c6d45 2517 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r
2518 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end\r
162ed594 2519 of last section.\r
2520\r
2521**/\r
797a9d67 2522EFI_STATUS\r
2523EFIAPI\r
2524CloseSectionStream (\r
eb1cace2
SZ
2525 IN UINTN StreamHandleToClose,\r
2526 IN BOOLEAN FreeStreamBuffer\r
797a9d67 2527 );\r
2528\r
ec90508b 2529/**\r
2530 Creates and initializes the DebugImageInfo Table. Also creates the configuration\r
2531 table and registers it into the system table.\r
2532\r
2533 Note:\r
2534 This function allocates memory, frees it, and then allocates memory at an\r
2535 address within the initial allocation. Since this function is called early\r
2536 in DXE core initialization (before drivers are dispatched), this should not\r
2537 be a problem.\r
2538\r
2539**/\r
2540VOID\r
2541CoreInitializeDebugImageInfoTable (\r
2542 VOID\r
2543 );\r
2544\r
2545\r
2546/**\r
2547 Update the CRC32 in the Debug Table.\r
2548 Since the CRC32 service is made available by the Runtime driver, we have to\r
2549 wait for the Runtime Driver to be installed before the CRC32 can be computed.\r
2550 This function is called elsewhere by the core when the runtime architectural\r
2551 protocol is produced.\r
2552\r
2553**/\r
2554VOID\r
2555CoreUpdateDebugTableCrc32 (\r
2556 VOID\r
2557 );\r
2558\r
2559\r
2560/**\r
2561 Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates\r
2562 the table if it's not large enough to accomidate another entry.\r
2563\r
2564 @param ImageInfoType type of debug image information\r
2565 @param LoadedImage pointer to the loaded image protocol for the image being\r
2566 loaded\r
2567 @param ImageHandle image handle for the image being loaded\r
2568\r
2569**/\r
2570VOID\r
2571CoreNewDebugImageInfoEntry (\r
2572 IN UINT32 ImageInfoType,\r
2573 IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,\r
2574 IN EFI_HANDLE ImageHandle\r
2575 );\r
2576\r
2577\r
2578/**\r
2579 Removes and frees an entry from the DebugImageInfo Table.\r
2580\r
2581 @param ImageHandle image handle for the image being unloaded\r
2582\r
2583**/\r
2584VOID\r
2585CoreRemoveDebugImageInfoEntry (\r
2586 EFI_HANDLE ImageHandle\r
2587 );\r
2588\r
2589\r
2590/**\r
2591 This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.\r
2592\r
2593 @param ImageHandle The image handle.\r
2594 @param SystemTable The system table.\r
2595\r
2596 @retval EFI_SUCCESS Successfully initialized firmware volume block\r
2597 driver.\r
2598\r
2599**/\r
2600EFI_STATUS\r
2601EFIAPI\r
2602FwVolBlockDriverInit (\r
2603 IN EFI_HANDLE ImageHandle,\r
2604 IN EFI_SYSTEM_TABLE *SystemTable\r
2605 );\r
2606\r
0c3a1db4
SZ
2607/**\r
2608\r
2609 Get FVB authentication status\r
2610\r
2611 @param FvbProtocol FVB protocol.\r
2612\r
2613 @return Authentication status.\r
2614\r
2615**/\r
2616UINT32\r
2617GetFvbAuthenticationStatus (\r
2618 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol\r
2619 );\r
ec90508b 2620\r
2621/**\r
2622 This routine produces a firmware volume block protocol on a given\r
2623 buffer.\r
2624\r
2625 @param BaseAddress base address of the firmware volume image\r
2626 @param Length length of the firmware volume image\r
2627 @param ParentHandle handle of parent firmware volume, if this image\r
0c3a1db4 2628 came from an FV image file and section in another firmware\r
ec90508b 2629 volume (ala capsules)\r
0c3a1db4
SZ
2630 @param AuthenticationStatus Authentication status inherited, if this image\r
2631 came from an FV image file and section in another firmware volume.\r
ec90508b 2632 @param FvProtocol Firmware volume block protocol produced.\r
2633\r
2634 @retval EFI_VOLUME_CORRUPTED Volume corrupted.\r
2635 @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.\r
2636 @retval EFI_SUCCESS Successfully produced a FVB protocol on given\r
2637 buffer.\r
2638\r
2639**/\r
2640EFI_STATUS\r
2641ProduceFVBProtocolOnBuffer (\r
2642 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
2643 IN UINT64 Length,\r
2644 IN EFI_HANDLE ParentHandle,\r
0c3a1db4 2645 IN UINT32 AuthenticationStatus,\r
ec90508b 2646 OUT EFI_HANDLE *FvProtocol OPTIONAL\r
2647 );\r
2648\r
2649\r
2650/**\r
2651 Raising to the task priority level of the mutual exclusion\r
2652 lock, and then acquires ownership of the lock.\r
2653\r
2654 @param Lock The lock to acquire\r
2655\r
2656 @return Lock owned\r
2657\r
2658**/\r
2659VOID\r
2660CoreAcquireLock (\r
2661 IN EFI_LOCK *Lock\r
2662 );\r
2663\r
2664\r
2665/**\r
2666 Initialize a basic mutual exclusion lock. Each lock\r
2667 provides mutual exclusion access at it's task priority\r
2668 level. Since there is no-premption (at any TPL) or\r
2669 multiprocessor support, acquiring the lock only consists\r
2670 of raising to the locks TPL.\r
2671\r
2672 @param Lock The EFI_LOCK structure to initialize\r
2673\r
2674 @retval EFI_SUCCESS Lock Owned.\r
2675 @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned.\r
2676\r
2677**/\r
2678EFI_STATUS\r
2679CoreAcquireLockOrFail (\r
2680 IN EFI_LOCK *Lock\r
2681 );\r
2682\r
2683\r
2684/**\r
2685 Releases ownership of the mutual exclusion lock, and\r
2686 restores the previous task priority level.\r
2687\r
2688 @param Lock The lock to release\r
2689\r
2690 @return Lock unowned\r
2691\r
2692**/\r
2693VOID\r
2694CoreReleaseLock (\r
2695 IN EFI_LOCK *Lock\r
2696 );\r
2697\r
2fc46f86
LG
2698/**\r
2699 Read data from Firmware Block by FVB protocol Read. \r
2700 The data may cross the multi block ranges.\r
2701\r
2702 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to read data.\r
2703 @param StartLba Pointer to StartLba.\r
2704 On input, the start logical block index from which to read.\r
2705 On output,the end logical block index after reading.\r
2706 @param Offset Pointer to Offset\r
2707 On input, offset into the block at which to begin reading.\r
2708 On output, offset into the end block after reading.\r
2709 @param DataSize Size of data to be read.\r
2710 @param Data Pointer to Buffer that the data will be read into.\r
2711\r
2712 @retval EFI_SUCCESS Successfully read data from firmware block.\r
2713 @retval others\r
2714**/\r
2715EFI_STATUS\r
2716ReadFvbData (\r
2717 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,\r
2718 IN OUT EFI_LBA *StartLba,\r
2719 IN OUT UINTN *Offset,\r
2720 IN UINTN DataSize,\r
2721 OUT UINT8 *Data\r
2722 );\r
2723\r
2724/**\r
2725 Given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and\r
2726 copy the real length volume header into it.\r
2727\r
2728 @param Fvb The FW_VOL_BLOCK_PROTOCOL instance from which to\r
2729 read the volume header\r
2730 @param FwVolHeader Pointer to pointer to allocated buffer in which\r
2731 the volume header is returned.\r
2732\r
2733 @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.\r
2734 @retval EFI_SUCCESS Successfully read volume header to the allocated\r
2735 buffer.\r
4888d15e
SZ
2736 @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or\r
2737 the file system could not be understood.\r
2fc46f86
LG
2738\r
2739**/\r
2740EFI_STATUS\r
2741GetFwVolHeader (\r
2742 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,\r
2743 OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader\r
2744 );\r
2745\r
2746/**\r
2747 Verify checksum of the firmware volume header.\r
2748\r
2749 @param FvHeader Points to the firmware volume header to be checked\r
2750\r
2751 @retval TRUE Checksum verification passed\r
2752 @retval FALSE Checksum verification failed\r
2753\r
2754**/\r
2755BOOLEAN\r
2756VerifyFvHeaderChecksum (\r
2757 IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader\r
2758 );\r
2759\r
84edd20b
SZ
2760/**\r
2761 Initialize memory profile.\r
2762\r
2763 @param HobStart The start address of the HOB.\r
2764\r
2765**/\r
2766VOID\r
2767MemoryProfileInit (\r
2768 IN VOID *HobStart\r
2769 );\r
2770\r
2771/**\r
2772 Install memory profile protocol.\r
2773\r
2774**/\r
2775VOID\r
2776MemoryProfileInstallProtocol (\r
2777 VOID\r
2778 );\r
2779\r
2780/**\r
2781 Register image to memory profile.\r
2782\r
2783 @param DriverEntry Image info.\r
2784 @param FileType Image file type.\r
2785\r
1d60fe96
SZ
2786 @return EFI_SUCCESS Register successfully.\r
2787 @return EFI_UNSUPPORTED Memory profile unsupported,\r
2788 or memory profile for the image is not required.\r
2789 @return EFI_OUT_OF_RESOURCES No enough resource for this register.\r
84edd20b
SZ
2790\r
2791**/\r
1d60fe96 2792EFI_STATUS\r
84edd20b
SZ
2793RegisterMemoryProfileImage (\r
2794 IN LOADED_IMAGE_PRIVATE_DATA *DriverEntry,\r
2795 IN EFI_FV_FILETYPE FileType\r
2796 );\r
2797\r
2798/**\r
2799 Unregister image from memory profile.\r
2800\r
2801 @param DriverEntry Image info.\r
2802\r
1d60fe96
SZ
2803 @return EFI_SUCCESS Unregister successfully.\r
2804 @return EFI_UNSUPPORTED Memory profile unsupported,\r
2805 or memory profile for the image is not required.\r
2806 @return EFI_NOT_FOUND The image is not found.\r
84edd20b
SZ
2807\r
2808**/\r
1d60fe96 2809EFI_STATUS\r
84edd20b
SZ
2810UnregisterMemoryProfileImage (\r
2811 IN LOADED_IMAGE_PRIVATE_DATA *DriverEntry\r
2812 );\r
2813\r
2814/**\r
2815 Update memory profile information.\r
2816\r
2817 @param CallerAddress Address of caller who call Allocate or Free.\r
2818 @param Action This Allocate or Free action.\r
2819 @param MemoryType Memory type.\r
1d60fe96 2820 EfiMaxMemoryType means the MemoryType is unknown.\r
84edd20b
SZ
2821 @param Size Buffer size.\r
2822 @param Buffer Buffer address.\r
1d60fe96
SZ
2823 @param ActionString String for memory profile action.\r
2824 Only needed for user defined allocate action.\r
84edd20b 2825\r
1d60fe96
SZ
2826 @return EFI_SUCCESS Memory profile is updated.\r
2827 @return EFI_UNSUPPORTED Memory profile is unsupported,\r
2828 or memory profile for the image is not required,\r
2829 or memory profile for the memory type is not required.\r
2830 @return EFI_ACCESS_DENIED It is during memory profile data getting.\r
2831 @return EFI_ABORTED Memory profile recording is not enabled.\r
2832 @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.\r
2833 @return EFI_NOT_FOUND No matched allocate info found for free action.\r
84edd20b
SZ
2834\r
2835**/\r
1d60fe96
SZ
2836EFI_STATUS\r
2837EFIAPI\r
84edd20b
SZ
2838CoreUpdateProfile (\r
2839 IN EFI_PHYSICAL_ADDRESS CallerAddress,\r
2840 IN MEMORY_PROFILE_ACTION Action,\r
dea0d6bf 2841 IN EFI_MEMORY_TYPE MemoryType,\r
84edd20b 2842 IN UINTN Size, // Valid for AllocatePages/FreePages/AllocatePool\r
1d60fe96
SZ
2843 IN VOID *Buffer,\r
2844 IN CHAR8 *ActionString OPTIONAL\r
84edd20b
SZ
2845 );\r
2846\r
771ee501
EC
2847/**\r
2848 Internal function. Converts a memory range to use new attributes.\r
2849\r
2850 @param Start The first address of the range Must be page\r
2851 aligned\r
2852 @param NumberOfPages The number of pages to convert\r
2853 @param NewAttributes The new attributes value for the range.\r
2854\r
771ee501
EC
2855**/\r
2856VOID\r
2857CoreUpdateMemoryAttributes (\r
2858 IN EFI_PHYSICAL_ADDRESS Start,\r
2859 IN UINT64 NumberOfPages,\r
2860 IN UINT64 NewAttributes\r
2861 );\r
2862\r
03d486b2
JY
2863/**\r
2864 Initialize PropertiesTable support.\r
2865**/\r
2866VOID\r
2867EFIAPI\r
2868CoreInitializePropertiesTable (\r
2869 VOID\r
2870 );\r
2871\r
67ab389a
JY
2872/**\r
2873 Initialize MemoryAttrubutesTable support.\r
2874**/\r
2875VOID\r
2876EFIAPI\r
2877CoreInitializeMemoryAttributesTable (\r
2878 VOID\r
2879 );\r
2880\r
d0e92aad
JY
2881/**\r
2882 Initialize Memory Protection support.\r
2883**/\r
2884VOID\r
2885EFIAPI\r
2886CoreInitializeMemoryProtection (\r
2887 VOID\r
2888 );\r
2889\r
74a88770
SZ
2890/**\r
2891 Install MemoryAttributesTable on memory allocation.\r
2892\r
2893 @param[in] MemoryType EFI memory type.\r
2894**/\r
2895VOID\r
2896InstallMemoryAttributesTableOnMemoryAllocation (\r
2897 IN EFI_MEMORY_TYPE MemoryType\r
2898 );\r
2899\r
03d486b2
JY
2900/**\r
2901 Insert image record.\r
2902\r
2903 @param RuntimeImage Runtime image information\r
2904**/\r
2905VOID\r
2906InsertImageRecord (\r
2907 IN EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage\r
2908 );\r
2909\r
2910/**\r
2911 Remove Image record.\r
2912\r
2913 @param RuntimeImage Runtime image information\r
2914**/\r
2915VOID\r
2916RemoveImageRecord (\r
2917 IN EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage\r
2918 );\r
2919\r
d0e92aad
JY
2920/**\r
2921 Protect UEFI image.\r
2922\r
2923 @param[in] LoadedImage The loaded image protocol\r
2924 @param[in] LoadedImageDevicePath The loaded image device path protocol\r
2925**/\r
2926VOID\r
2927ProtectUefiImage (\r
2928 IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,\r
2929 IN EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath\r
2930 );\r
2931\r
2932/**\r
2933 Unprotect UEFI image.\r
2934\r
2935 @param[in] LoadedImage The loaded image protocol\r
2936 @param[in] LoadedImageDevicePath The loaded image device path protocol\r
2937**/\r
2938VOID\r
2939UnprotectUefiImage (\r
2940 IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,\r
2941 IN EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath\r
2942 );\r
2943\r
2944/**\r
2945 ExitBootServices Callback function for memory protection.\r
2946**/\r
2947VOID\r
2948MemoryProtectionExitBootServicesCallback (\r
2949 VOID\r
2950 );\r
2951\r
28a00297 2952#endif\r