]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg/DxeCore: Add UEFI image protection.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / DxeMain.h
... / ...
CommitLineData
1/** @file\r
2 The internal header file includes the common header files, defines\r
3 internal structure and functions used by DxeCore module.\r
4\r
5Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
6This program and the accompanying materials\r
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
13\r
14**/\r
15\r
16#ifndef _DXE_MAIN_H_\r
17#define _DXE_MAIN_H_\r
18\r
19\r
20\r
21#include <PiDxe.h>\r
22\r
23#include <Protocol/LoadedImage.h>\r
24#include <Protocol/GuidedSectionExtraction.h>\r
25#include <Protocol/DevicePath.h>\r
26#include <Protocol/Runtime.h>\r
27#include <Protocol/LoadFile.h>\r
28#include <Protocol/LoadFile2.h>\r
29#include <Protocol/DriverBinding.h>\r
30#include <Protocol/VariableWrite.h>\r
31#include <Protocol/PlatformDriverOverride.h>\r
32#include <Protocol/Variable.h>\r
33#include <Protocol/Timer.h>\r
34#include <Protocol/SimpleFileSystem.h>\r
35#include <Protocol/Bds.h>\r
36#include <Protocol/RealTimeClock.h>\r
37#include <Protocol/WatchdogTimer.h>\r
38#include <Protocol/FirmwareVolume2.h>\r
39#include <Protocol/MonotonicCounter.h>\r
40#include <Protocol/StatusCode.h>\r
41#include <Protocol/Decompress.h>\r
42#include <Protocol/LoadPe32Image.h>\r
43#include <Protocol/Security.h>\r
44#include <Protocol/Security2.h>\r
45#include <Protocol/Ebc.h>\r
46#include <Protocol/Reset.h>\r
47#include <Protocol/Cpu.h>\r
48#include <Protocol/Metronome.h>\r
49#include <Protocol/FirmwareVolumeBlock.h>\r
50#include <Protocol/Capsule.h>\r
51#include <Protocol/BusSpecificDriverOverride.h>\r
52#include <Protocol/DriverFamilyOverride.h>\r
53#include <Protocol/TcgService.h>\r
54#include <Protocol/HiiPackageList.h>\r
55#include <Protocol/SmmBase2.h>\r
56#include <Guid/MemoryTypeInformation.h>\r
57#include <Guid/FirmwareFileSystem2.h>\r
58#include <Guid/FirmwareFileSystem3.h>\r
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
67#include <Guid/EventExitBootServiceFailed.h>\r
68#include <Guid/LoadModuleAtFixedAddress.h>\r
69#include <Guid/IdleLoopEvent.h>\r
70#include <Guid/VectorHandoffTable.h>\r
71#include <Ppi/VectorHandoffInfo.h>\r
72#include <Guid/MemoryProfile.h>\r
73\r
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
81#include <Library/ExtractGuidedSectionLib.h>\r
82#include <Library/CacheMaintenanceLib.h>\r
83#include <Library/BaseMemoryLib.h>\r
84#include <Library/PeCoffLib.h>\r
85#include <Library/PeCoffGetEntryPointLib.h>\r
86#include <Library/PeCoffExtraActionLib.h>\r
87#include <Library/PcdLib.h>\r
88#include <Library/MemoryAllocationLib.h>\r
89#include <Library/DevicePathLib.h>\r
90#include <Library/UefiBootServicesTableLib.h>\r
91#include <Library/ReportStatusCodeLib.h>\r
92#include <Library/TimerLib.h>\r
93#include <Library/DxeServicesLib.h>\r
94#include <Library/DebugAgentLib.h>\r
95#include <Library/CpuExceptionHandlerLib.h>\r
96\r
97\r
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
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
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
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
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
144/// For generic EFI machines make the default allocations 4K aligned\r
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
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
157} EFI_CORE_PROTOCOL_NOTIFY_ENTRY;\r
158\r
159//\r
160// DXE Dispatcher Data structures\r
161//\r
162\r
163#define KNOWN_HANDLE_SIGNATURE SIGNATURE_32('k','n','o','w')\r
164typedef struct {\r
165 UINTN Signature;\r
166 LIST_ENTRY Link; // mFvHandleList\r
167 EFI_HANDLE Handle;\r
168 EFI_GUID FvNameGuid;\r
169} KNOWN_HANDLE;\r
170\r
171\r
172#define EFI_CORE_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('d','r','v','r')\r
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
182 EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
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
199 BOOLEAN IsFvImage;\r
200\r
201} EFI_CORE_DRIVER_ENTRY;\r
202\r
203//\r
204//The data structure of GCD memory map entry\r
205//\r
206#define EFI_GCD_MAP_SIGNATURE SIGNATURE_32('g','c','d','m')\r
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
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
249 /// Pointer to pool allocation for context save/restore\r
250 VOID *JumpBuffer; \r
251 /// Pointer to buffer for context save/restore\r
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
259 /// Pointer to Loaded Image Device Path Protocol\r
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
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
290//\r
291// DXE Core Global Variables\r
292//\r
293extern EFI_SYSTEM_TABLE *gDxeCoreST;\r
294extern EFI_RUNTIME_SERVICES *gDxeCoreRT;\r
295extern EFI_DXE_SERVICES *gDxeCoreDS;\r
296extern EFI_HANDLE gDxeCoreImageHandle;\r
297\r
298extern BOOLEAN gMemoryMapTerminated;\r
299\r
300extern EFI_DECOMPRESS_PROTOCOL gEfiDecompress;\r
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
308extern EFI_SECURITY2_ARCH_PROTOCOL *gSecurity2;\r
309extern EFI_BDS_ARCH_PROTOCOL *gBds;\r
310extern EFI_SMM_BASE2_PROTOCOL *gSmmBase2;\r
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
322extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable;\r
323extern BOOLEAN gLoadFixedAddressCodeMemoryReady;\r
324//\r
325// Service Initialization Functions\r
326//\r
327\r
328\r
329\r
330/**\r
331 Called to initialize the pool.\r
332\r
333**/\r
334VOID\r
335CoreInitializePool (\r
336 VOID\r
337 );\r
338\r
339\r
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
345\r
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
351\r
352 @return None. The range is added to the memory map\r
353\r
354**/\r
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
361 );\r
362\r
363\r
364/**\r
365 Release memory lock on mGcdMemorySpaceLock.\r
366\r
367**/\r
368VOID\r
369CoreReleaseGcdMemoryLock (\r
370 VOID\r
371 );\r
372\r
373\r
374/**\r
375 Acquire memory lock on mGcdMemorySpaceLock.\r
376\r
377**/\r
378VOID\r
379CoreAcquireGcdMemoryLock (\r
380 VOID\r
381 );\r
382\r
383\r
384/**\r
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
390\r
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
395\r
396 @retval EFI_SUCCESS Memory services successfully initialized.\r
397\r
398**/\r
399EFI_STATUS\r
400CoreInitializeMemoryServices (\r
401 IN VOID **HobStart,\r
402 OUT EFI_PHYSICAL_ADDRESS *MemoryBaseAddress,\r
403 OUT UINT64 *MemoryLength\r
404 );\r
405\r
406\r
407\r
408/**\r
409 External function. Initializes the GCD and memory services based on the memory\r
410 descriptor HOBs. This function is responsible for priming the GCD map and the\r
411 memory map, so memory allocations and resource allocations can be made. The\r
412 HobStart will be relocated to a pool buffer.\r
413\r
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
418\r
419 @retval EFI_SUCCESS GCD services successfully initialized.\r
420\r
421**/\r
422EFI_STATUS\r
423CoreInitializeGcdServices (\r
424 IN OUT VOID **HobStart,\r
425 IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress,\r
426 IN UINT64 MemoryLength\r
427 );\r
428\r
429\r
430/**\r
431 Initializes "event" support.\r
432\r
433 @retval EFI_SUCCESS Always return success\r
434\r
435**/\r
436EFI_STATUS\r
437CoreInitializeEventServices (\r
438 VOID\r
439 );\r
440\r
441\r
442/**\r
443 Add the Image Services to EFI Boot Services Table and install the protocol\r
444 interfaces for this image.\r
445\r
446 @param HobStart The HOB to initialize\r
447\r
448 @return Status code.\r
449\r
450**/\r
451EFI_STATUS\r
452CoreInitializeImageServices (\r
453 IN VOID *HobStart\r
454 );\r
455\r
456\r
457/**\r
458 Creates an event that is fired everytime a Protocol of a specific type is installed.\r
459\r
460**/\r
461VOID\r
462CoreNotifyOnProtocolInstallation (\r
463 VOID\r
464 );\r
465\r
466\r
467/**\r
468 Return TRUE if all AP services are available.\r
469\r
470 @retval EFI_SUCCESS All AP services are available\r
471 @retval EFI_NOT_FOUND At least one AP service is not available\r
472\r
473**/\r
474EFI_STATUS\r
475CoreAllEfiServicesAvailable (\r
476 VOID\r
477 );\r
478\r
479\r
480/**\r
481 Calcualte the 32-bit CRC in a EFI table using the service provided by the\r
482 gRuntime service.\r
483\r
484 @param Hdr Pointer to an EFI standard header\r
485\r
486**/\r
487VOID\r
488CalculateEfiHdrCrc (\r
489 IN OUT EFI_TABLE_HEADER *Hdr\r
490 );\r
491\r
492\r
493/**\r
494 Called by the platform code to process a tick.\r
495\r
496 @param Duration The number of 100ns elapsed since the last call\r
497 to TimerTick\r
498\r
499**/\r
500VOID\r
501EFIAPI\r
502CoreTimerTick (\r
503 IN UINT64 Duration\r
504 );\r
505\r
506\r
507/**\r
508 Initialize the dispatcher. Initialize the notification function that runs when\r
509 an FV2 protocol is added to the system.\r
510\r
511**/\r
512VOID\r
513CoreInitializeDispatcher (\r
514 VOID\r
515 );\r
516\r
517\r
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
523\r
524 @param DriverEntry DriverEntry element to update.\r
525\r
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
528 was found.\r
529\r
530**/\r
531BOOLEAN\r
532CoreIsSchedulable (\r
533 IN EFI_CORE_DRIVER_ENTRY *DriverEntry\r
534 );\r
535\r
536\r
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
543\r
544 @param DriverEntry DriverEntry element to update .\r
545\r
546 @retval EFI_SUCCESS It always works.\r
547\r
548**/\r
549EFI_STATUS\r
550CorePreProcessDepex (\r
551 IN EFI_CORE_DRIVER_ENTRY *DriverEntry\r
552 );\r
553\r
554\r
555\r
556/**\r
557 Terminates all boot services.\r
558\r
559 @param ImageHandle Handle that identifies the exiting image.\r
560 @param MapKey Key to the latest memory map.\r
561\r
562 @retval EFI_SUCCESS Boot Services terminated\r
563 @retval EFI_INVALID_PARAMETER MapKey is incorrect.\r
564\r
565**/\r
566EFI_STATUS\r
567EFIAPI\r
568CoreExitBootServices (\r
569 IN EFI_HANDLE ImageHandle,\r
570 IN UINTN MapKey\r
571 );\r
572\r
573\r
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
577\r
578 @param MapKey Memory map key\r
579\r
580 @retval EFI_INVALID_PARAMETER Memory map not consistent with construction\r
581 rules.\r
582 @retval EFI_SUCCESS Valid memory map.\r
583\r
584**/\r
585EFI_STATUS\r
586CoreTerminateMemoryMap (\r
587 IN UINTN MapKey\r
588 );\r
589\r
590\r
591/**\r
592 Signals all events in the EventGroup.\r
593\r
594 @param EventGroup The list to signal\r
595\r
596**/\r
597VOID\r
598CoreNotifySignalList (\r
599 IN EFI_GUID *EventGroup\r
600 );\r
601\r
602\r
603\r
604/**\r
605 Boot Service called to add, modify, or remove a system configuration table from\r
606 the EFI System Table.\r
607\r
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
612\r
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
617\r
618**/\r
619EFI_STATUS\r
620EFIAPI\r
621CoreInstallConfigurationTable (\r
622 IN EFI_GUID *Guid,\r
623 IN VOID *Table\r
624 );\r
625\r
626\r
627\r
628/**\r
629 Raise the task priority level to the new level.\r
630 High level is implemented by disabling processor interrupts.\r
631\r
632 @param NewTpl New task priority level\r
633\r
634 @return The previous task priority level\r
635\r
636**/\r
637EFI_TPL\r
638EFIAPI\r
639CoreRaiseTpl (\r
640 IN EFI_TPL NewTpl\r
641 );\r
642\r
643\r
644\r
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
648\r
649 @param NewTpl New, lower, task priority\r
650\r
651**/\r
652VOID\r
653EFIAPI\r
654CoreRestoreTpl (\r
655 IN EFI_TPL NewTpl\r
656 );\r
657\r
658\r
659\r
660/**\r
661 Introduces a fine-grained stall.\r
662\r
663 @param Microseconds The number of microseconds to stall execution.\r
664\r
665 @retval EFI_SUCCESS Execution was stalled for at least the requested\r
666 amount of microseconds.\r
667 @retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet\r
668\r
669**/\r
670EFI_STATUS\r
671EFIAPI\r
672CoreStall (\r
673 IN UINTN Microseconds\r
674 );\r
675\r
676\r
677\r
678/**\r
679 Sets the system's watchdog timer.\r
680\r
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
698\r
699**/\r
700EFI_STATUS\r
701EFIAPI\r
702CoreSetWatchdogTimer (\r
703 IN UINTN Timeout,\r
704 IN UINT64 WatchdogCode,\r
705 IN UINTN DataSize,\r
706 IN CHAR16 *WatchdogData OPTIONAL\r
707 );\r
708\r
709\r
710\r
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
714\r
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
721\r
722 @return Status code\r
723\r
724**/\r
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
732 );\r
733\r
734\r
735/**\r
736 Installs a protocol interface into the boot services environment.\r
737\r
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
746\r
747 @retval EFI_INVALID_PARAMETER Invalid parameter\r
748 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate\r
749 @retval EFI_SUCCESS Protocol interface successfully installed\r
750\r
751**/\r
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
759 );\r
760\r
761\r
762\r
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
768\r
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
775\r
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
780 @retval EFI_INVALID_PARAMETER Handle is NULL.\r
781 @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle.\r
782\r
783**/\r
784EFI_STATUS\r
785EFIAPI\r
786CoreInstallMultipleProtocolInterfaces (\r
787 IN OUT EFI_HANDLE *Handle,\r
788 ...\r
789 );\r
790\r
791\r
792\r
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
797\r
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
803\r
804 @return Status code\r
805\r
806**/\r
807EFI_STATUS\r
808EFIAPI\r
809CoreUninstallMultipleProtocolInterfaces (\r
810 IN EFI_HANDLE Handle,\r
811 ...\r
812 );\r
813\r
814\r
815\r
816/**\r
817 Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.\r
818\r
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
824\r
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
828\r
829**/\r
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
837 );\r
838\r
839\r
840\r
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
845\r
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
849\r
850 @retval EFI_INVALID_PARAMETER Protocol is NULL.\r
851 @retval EFI_SUCCESS Protocol interface successfully uninstalled.\r
852\r
853**/\r
854EFI_STATUS\r
855EFIAPI\r
856CoreUninstallProtocolInterface (\r
857 IN EFI_HANDLE UserHandle,\r
858 IN EFI_GUID *Protocol,\r
859 IN VOID *Interface\r
860 );\r
861\r
862\r
863\r
864/**\r
865 Queries a handle to determine if it supports a specified protocol.\r
866\r
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
871\r
872 @return The requested protocol interface for the handle\r
873\r
874**/\r
875EFI_STATUS\r
876EFIAPI\r
877CoreHandleProtocol (\r
878 IN EFI_HANDLE UserHandle,\r
879 IN EFI_GUID *Protocol,\r
880 OUT VOID **Interface\r
881 );\r
882\r
883\r
884\r
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
889\r
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
902 @retval EFI_SUCCESS Get the protocol interface.\r
903\r
904**/\r
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
914 );\r
915\r
916\r
917\r
918/**\r
919 Return information about Opened protocols in the system\r
920\r
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
926 @param EntryCount Number of EntryBuffer entries\r
927\r
928**/\r
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
936 );\r
937\r
938\r
939\r
940/**\r
941 Closes a protocol on a handle that was opened using OpenProtocol().\r
942\r
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
962 AgentHandle.\r
963\r
964**/\r
965EFI_STATUS\r
966EFIAPI\r
967CoreCloseProtocol (\r
968 IN EFI_HANDLE UserHandle,\r
969 IN EFI_GUID *Protocol,\r
970 IN EFI_HANDLE AgentHandle,\r
971 IN EFI_HANDLE ControllerHandle\r
972 );\r
973\r
974\r
975\r
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
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
996 results.\r
997\r
998**/\r
999EFI_STATUS\r
1000EFIAPI\r
1001CoreProtocolsPerHandle (\r
1002 IN EFI_HANDLE UserHandle,\r
1003 OUT EFI_GUID ***ProtocolBuffer,\r
1004 OUT UINTN *ProtocolBufferCount\r
1005 );\r
1006\r
1007\r
1008\r
1009/**\r
1010 Add a new protocol notification record for the request protocol.\r
1011\r
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
1016\r
1017 @retval EFI_INVALID_PARAMETER Invalid parameter\r
1018 @retval EFI_SUCCESS Successfully returned the registration record\r
1019 that has been added\r
1020\r
1021**/\r
1022EFI_STATUS\r
1023EFIAPI\r
1024CoreRegisterProtocolNotify (\r
1025 IN EFI_GUID *Protocol,\r
1026 IN EFI_EVENT Event,\r
1027 OUT VOID **Registration\r
1028 );\r
1029\r
1030\r
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
1045\r
1046/**\r
1047 Locates the requested handle(s) and returns them in Buffer.\r
1048\r
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
1056\r
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
1061 returns them in Buffer.\r
1062\r
1063**/\r
1064EFI_STATUS\r
1065EFIAPI\r
1066CoreLocateHandle (\r
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
1073\r
1074\r
1075\r
1076/**\r
1077 Locates the handle to a device on the device path that best matches the specified protocol.\r
1078\r
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
1085\r
1086 @retval EFI_SUCCESS The resulting handle was returned.\r
1087 @retval EFI_NOT_FOUND No handles matched the search.\r
1088 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
1089\r
1090**/\r
1091EFI_STATUS\r
1092EFIAPI\r
1093CoreLocateDevicePath (\r
1094 IN EFI_GUID *Protocol,\r
1095 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r
1096 OUT EFI_HANDLE *Device\r
1097 );\r
1098\r
1099\r
1100\r
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
1105\r
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
1120 @retval EFI_INVALID_PARAMETER One or more parameters are not valid.\r
1121\r
1122**/\r
1123EFI_STATUS\r
1124EFIAPI\r
1125CoreLocateHandleBuffer (\r
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
1132\r
1133\r
1134\r
1135/**\r
1136 Return the first Protocol Interface that matches the Protocol GUID. If\r
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
1139 you find.\r
1140\r
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
1145\r
1146 @retval EFI_SUCCESS If a valid Interface is returned\r
1147 @retval EFI_INVALID_PARAMETER Invalid parameter\r
1148 @retval EFI_NOT_FOUND Protocol interface not found\r
1149\r
1150**/\r
1151EFI_STATUS\r
1152EFIAPI\r
1153CoreLocateProtocol (\r
1154 IN EFI_GUID *Protocol,\r
1155 IN VOID *Registration OPTIONAL,\r
1156 OUT VOID **Interface\r
1157 );\r
1158\r
1159\r
1160/**\r
1161 return handle database key.\r
1162\r
1163\r
1164 @return Handle database key.\r
1165\r
1166**/\r
1167UINT64\r
1168CoreGetHandleDatabaseKey (\r
1169 VOID\r
1170 );\r
1171\r
1172\r
1173/**\r
1174 Go connect any handles that were created or modified while a image executed.\r
1175\r
1176 @param Key The Key to show that the handle has been\r
1177 created/modified\r
1178\r
1179**/\r
1180VOID\r
1181CoreConnectHandlesByKey (\r
1182 UINT64 Key\r
1183 );\r
1184\r
1185\r
1186\r
1187/**\r
1188 Connects one or more drivers to a controller.\r
1189\r
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
1211\r
1212**/\r
1213EFI_STATUS\r
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
1220 );\r
1221\r
1222\r
1223\r
1224/**\r
1225 Disonnects a controller from a driver\r
1226\r
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
1243 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
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
1253 error.\r
1254\r
1255**/\r
1256EFI_STATUS\r
1257EFIAPI\r
1258CoreDisconnectController (\r
1259 IN EFI_HANDLE ControllerHandle,\r
1260 IN EFI_HANDLE DriverImageHandle OPTIONAL,\r
1261 IN EFI_HANDLE ChildHandle OPTIONAL\r
1262 );\r
1263\r
1264\r
1265\r
1266/**\r
1267 Allocates pages from the memory map.\r
1268\r
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
1275\r
1276 @return Status. On success, Memory is filled in with the base address allocated\r
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
1281 @retval EFI_SUCCESS Pages successfully allocated.\r
1282\r
1283**/\r
1284EFI_STATUS\r
1285EFIAPI\r
1286CoreAllocatePages (\r
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
1292\r
1293/**\r
1294 Frees previous allocated pages.\r
1295\r
1296 @param Memory Base address of memory being freed\r
1297 @param NumberOfPages The number of pages to free\r
1298\r
1299 @retval EFI_NOT_FOUND Could not find the entry that covers the range\r
1300 @retval EFI_INVALID_PARAMETER Address not aligned\r
1301 @return EFI_SUCCESS -Pages successfully freed.\r
1302\r
1303**/\r
1304EFI_STATUS\r
1305EFIAPI\r
1306CoreFreePages (\r
1307 IN EFI_PHYSICAL_ADDRESS Memory,\r
1308 IN UINTN NumberOfPages\r
1309 );\r
1310\r
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
1314\r
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
1338 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
1339\r
1340**/\r
1341EFI_STATUS\r
1342EFIAPI\r
1343CoreGetMemoryMap (\r
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
1350\r
1351\r
1352\r
1353/**\r
1354 Allocate pool of a particular type.\r
1355\r
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
1360\r
1361 @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL\r
1362 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.\r
1363 @retval EFI_SUCCESS Pool successfully allocated.\r
1364\r
1365**/\r
1366EFI_STATUS\r
1367EFIAPI\r
1368CoreAllocatePool (\r
1369 IN EFI_MEMORY_TYPE PoolType,\r
1370 IN UINTN Size,\r
1371 OUT VOID **Buffer\r
1372 );\r
1373\r
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
1381\r
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
1394\r
1395/**\r
1396 Frees pool.\r
1397\r
1398 @param Buffer The allocated pool entry to free\r
1399\r
1400 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.\r
1401 @retval EFI_SUCCESS Pool successfully freed.\r
1402\r
1403**/\r
1404EFI_STATUS\r
1405EFIAPI\r
1406CoreFreePool (\r
1407 IN VOID *Buffer\r
1408 );\r
1409\r
1410/**\r
1411 Frees pool.\r
1412\r
1413 @param Buffer The allocated pool entry to free\r
1414 @param PoolType Pointer to pool type\r
1415\r
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
1423 IN VOID *Buffer,\r
1424 OUT EFI_MEMORY_TYPE *PoolType OPTIONAL\r
1425 );\r
1426\r
1427/**\r
1428 Loads an EFI image into memory and returns a handle to the image.\r
1429\r
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
1450 resources.\r
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
1459\r
1460**/\r
1461EFI_STATUS\r
1462EFIAPI\r
1463CoreLoadImage (\r
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
1471\r
1472\r
1473\r
1474/**\r
1475 Unloads an image.\r
1476\r
1477 @param ImageHandle Handle that identifies the image to be\r
1478 unloaded.\r
1479\r
1480 @retval EFI_SUCCESS The image has been unloaded.\r
1481 @retval EFI_UNSUPPORTED The image has been started, and does not support\r
1482 unload.\r
1483 @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.\r
1484\r
1485**/\r
1486EFI_STATUS\r
1487EFIAPI\r
1488CoreUnloadImage (\r
1489 IN EFI_HANDLE ImageHandle\r
1490 );\r
1491\r
1492\r
1493\r
1494/**\r
1495 Transfer control to a loaded image's entry point.\r
1496\r
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
1500 includes a Null-terminated string,\r
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
1508 @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.\r
1509 @retval EFI_SUCCESS Successfully transfer control to the image's\r
1510 entry point.\r
1511\r
1512**/\r
1513EFI_STATUS\r
1514EFIAPI\r
1515CoreStartImage (\r
1516 IN EFI_HANDLE ImageHandle,\r
1517 OUT UINTN *ExitDataSize,\r
1518 OUT CHAR16 **ExitData OPTIONAL\r
1519 );\r
1520\r
1521\r
1522\r
1523/**\r
1524 Terminates the currently loaded EFI image and returns control to boot services.\r
1525\r
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
1543 @retval EFI_OUT_OF_RESOURCES Could not allocate pool\r
1544\r
1545**/\r
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
1553 );\r
1554\r
1555\r
1556\r
1557/**\r
1558 Creates an event.\r
1559\r
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
1572 @retval EFI_OUT_OF_RESOURCES The event could not be allocated\r
1573\r
1574**/\r
1575EFI_STATUS\r
1576EFIAPI\r
1577CoreCreateEvent (\r
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
1584\r
1585\r
1586\r
1587/**\r
1588 Creates an event in a group.\r
1589\r
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
1604 @retval EFI_OUT_OF_RESOURCES The event could not be allocated\r
1605\r
1606**/\r
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
1616 );\r
1617\r
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
1632\r
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
1648\r
1649/**\r
1650 Sets the type of timer and the trigger time for a timer event.\r
1651\r
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
1658\r
1659 @retval EFI_SUCCESS The event has been set to be signaled at the\r
1660 requested time\r
1661 @retval EFI_INVALID_PARAMETER Event or Type is not valid\r
1662\r
1663**/\r
1664EFI_STATUS\r
1665EFIAPI\r
1666CoreSetTimer (\r
1667 IN EFI_EVENT UserEvent,\r
1668 IN EFI_TIMER_DELAY Type,\r
1669 IN UINT64 TriggerTime\r
1670 );\r
1671\r
1672\r
1673\r
1674/**\r
1675 Signals the event. Queues the event to be notified if needed.\r
1676\r
1677 @param UserEvent The event to signal .\r
1678\r
1679 @retval EFI_INVALID_PARAMETER Parameters are not valid.\r
1680 @retval EFI_SUCCESS The event was signaled.\r
1681\r
1682**/\r
1683EFI_STATUS\r
1684EFIAPI\r
1685CoreSignalEvent (\r
1686 IN EFI_EVENT UserEvent\r
1687 );\r
1688\r
1689\r
1690\r
1691/**\r
1692 Stops execution until an event is signaled.\r
1693\r
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
1698\r
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
1702 @retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION\r
1703\r
1704**/\r
1705EFI_STATUS\r
1706EFIAPI\r
1707CoreWaitForEvent (\r
1708 IN UINTN NumberOfEvents,\r
1709 IN EFI_EVENT *UserEvents,\r
1710 OUT UINTN *UserIndex\r
1711 );\r
1712\r
1713\r
1714\r
1715/**\r
1716 Closes an event and frees the event structure.\r
1717\r
1718 @param UserEvent Event to close\r
1719\r
1720 @retval EFI_INVALID_PARAMETER Parameters are not valid.\r
1721 @retval EFI_SUCCESS The event has been closed\r
1722\r
1723**/\r
1724EFI_STATUS\r
1725EFIAPI\r
1726CoreCloseEvent (\r
1727 IN EFI_EVENT UserEvent\r
1728 );\r
1729\r
1730\r
1731\r
1732/**\r
1733 Check the status of an event.\r
1734\r
1735 @param UserEvent The event to check\r
1736\r
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
1739 @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL\r
1740\r
1741**/\r
1742EFI_STATUS\r
1743EFIAPI\r
1744CoreCheckEvent (\r
1745 IN EFI_EVENT UserEvent\r
1746 );\r
1747\r
1748\r
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
1752\r
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
1757\r
1758 @retval EFI_SUCCESS Merged this memory space into GCD map.\r
1759\r
1760**/\r
1761EFI_STATUS\r
1762EFIAPI\r
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
1768 );\r
1769\r
1770\r
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
1774\r
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
1782\r
1783 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1784 @retval EFI_NOT_FOUND No descriptor contains the desired space.\r
1785 @retval EFI_SUCCESS Memory space successfully allocated.\r
1786\r
1787**/\r
1788EFI_STATUS\r
1789EFIAPI\r
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
1798 );\r
1799\r
1800\r
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
1804\r
1805 @param BaseAddress Base address of the memory space.\r
1806 @param Length Length of the memory space.\r
1807\r
1808 @retval EFI_SUCCESS Space successfully freed.\r
1809\r
1810**/\r
1811EFI_STATUS\r
1812EFIAPI\r
1813CoreFreeMemorySpace (\r
1814 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1815 IN UINT64 Length\r
1816 );\r
1817\r
1818\r
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
1822\r
1823 @param BaseAddress Base address of the memory space.\r
1824 @param Length Length of the memory space.\r
1825\r
1826 @retval EFI_SUCCESS Successfully remove a segment of memory space.\r
1827\r
1828**/\r
1829EFI_STATUS\r
1830EFIAPI\r
1831CoreRemoveMemorySpace (\r
1832 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1833 IN UINT64 Length\r
1834 );\r
1835\r
1836\r
1837/**\r
1838 Retrieves the descriptor for a memory region containing a specified address.\r
1839\r
1840 @param BaseAddress Specified start address\r
1841 @param Descriptor Specified length\r
1842\r
1843 @retval EFI_INVALID_PARAMETER Invalid parameter\r
1844 @retval EFI_SUCCESS Successfully get memory space descriptor.\r
1845\r
1846**/\r
1847EFI_STATUS\r
1848EFIAPI\r
1849CoreGetMemorySpaceDescriptor (\r
1850 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1851 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor\r
1852 );\r
1853\r
1854\r
1855/**\r
1856 Modifies the attributes for a memory region in the global coherency domain of the\r
1857 processor.\r
1858\r
1859 @param BaseAddress Specified start address\r
1860 @param Length Specified length\r
1861 @param Attributes Specified attributes\r
1862\r
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
1869 @retval EFI_ACCESS_DENIED The attributes for the memory resource range specified by\r
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
1875\r
1876**/\r
1877EFI_STATUS\r
1878EFIAPI\r
1879CoreSetMemorySpaceAttributes (\r
1880 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1881 IN UINT64 Length,\r
1882 IN UINT64 Attributes\r
1883 );\r
1884\r
1885\r
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
1912/**\r
1913 Returns a map of the memory resources in the global coherency domain of the\r
1914 processor.\r
1915\r
1916 @param NumberOfDescriptors Number of descriptors.\r
1917 @param MemorySpaceMap Descriptor array\r
1918\r
1919 @retval EFI_INVALID_PARAMETER Invalid parameter\r
1920 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate\r
1921 @retval EFI_SUCCESS Successfully get memory space map.\r
1922\r
1923**/\r
1924EFI_STATUS\r
1925EFIAPI\r
1926CoreGetMemorySpaceMap (\r
1927 OUT UINTN *NumberOfDescriptors,\r
1928 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **MemorySpaceMap\r
1929 );\r
1930\r
1931\r
1932/**\r
1933 Adds reserved I/O or I/O resources to the global coherency domain of the processor.\r
1934\r
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
1938\r
1939 @retval EFI_SUCCESS Merged this segment into GCD map.\r
1940 @retval EFI_INVALID_PARAMETER Parameter not valid\r
1941\r
1942**/\r
1943EFI_STATUS\r
1944EFIAPI\r
1945CoreAddIoSpace (\r
1946 IN EFI_GCD_IO_TYPE GcdIoType,\r
1947 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1948 IN UINT64 Length\r
1949 );\r
1950\r
1951\r
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
1955\r
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
1963\r
1964 @retval EFI_INVALID_PARAMETER Invalid parameter.\r
1965 @retval EFI_NOT_FOUND No descriptor contains the desired space.\r
1966 @retval EFI_SUCCESS IO space successfully allocated.\r
1967\r
1968**/\r
1969EFI_STATUS\r
1970EFIAPI\r
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
1979 );\r
1980\r
1981\r
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
1985\r
1986 @param BaseAddress Base address of the segment.\r
1987 @param Length Length of the segment.\r
1988\r
1989 @retval EFI_SUCCESS Space successfully freed.\r
1990\r
1991**/\r
1992EFI_STATUS\r
1993EFIAPI\r
1994CoreFreeIoSpace (\r
1995 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
1996 IN UINT64 Length\r
1997 );\r
1998\r
1999\r
2000/**\r
2001 Removes reserved I/O or I/O resources from the global coherency domain of the\r
2002 processor.\r
2003\r
2004 @param BaseAddress Base address of the segment.\r
2005 @param Length Length of the segment.\r
2006\r
2007 @retval EFI_SUCCESS Successfully removed a segment of IO space.\r
2008\r
2009**/\r
2010EFI_STATUS\r
2011EFIAPI\r
2012CoreRemoveIoSpace (\r
2013 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
2014 IN UINT64 Length\r
2015 );\r
2016\r
2017\r
2018/**\r
2019 Retrieves the descriptor for an I/O region containing a specified address.\r
2020\r
2021 @param BaseAddress Specified start address\r
2022 @param Descriptor Specified length\r
2023\r
2024 @retval EFI_INVALID_PARAMETER Descriptor is NULL.\r
2025 @retval EFI_SUCCESS Successfully get the IO space descriptor.\r
2026\r
2027**/\r
2028EFI_STATUS\r
2029EFIAPI\r
2030CoreGetIoSpaceDescriptor (\r
2031 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
2032 OUT EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor\r
2033 );\r
2034\r
2035\r
2036/**\r
2037 Returns a map of the I/O resources in the global coherency domain of the processor.\r
2038\r
2039 @param NumberOfDescriptors Number of descriptors.\r
2040 @param IoSpaceMap Descriptor array\r
2041\r
2042 @retval EFI_INVALID_PARAMETER Invalid parameter\r
2043 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate\r
2044 @retval EFI_SUCCESS Successfully get IO space map.\r
2045\r
2046**/\r
2047EFI_STATUS\r
2048EFIAPI\r
2049CoreGetIoSpaceMap (\r
2050 OUT UINTN *NumberOfDescriptors,\r
2051 OUT EFI_GCD_IO_SPACE_DESCRIPTOR **IoSpaceMap\r
2052 );\r
2053\r
2054\r
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
2063\r
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
2067\r
2068**/\r
2069EFI_STATUS\r
2070EFIAPI\r
2071CoreDispatcher (\r
2072 VOID\r
2073 );\r
2074\r
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
2078\r
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
2082\r
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
2087\r
2088**/\r
2089EFI_STATUS\r
2090EFIAPI\r
2091CoreSchedule (\r
2092 IN EFI_HANDLE FirmwareVolumeHandle,\r
2093 IN EFI_GUID *DriverName\r
2094 );\r
2095\r
2096\r
2097/**\r
2098 Convert a driver from the Untrused back to the Scheduled state.\r
2099\r
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
2103\r
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
2107\r
2108**/\r
2109EFI_STATUS\r
2110EFIAPI\r
2111CoreTrust (\r
2112 IN EFI_HANDLE FirmwareVolumeHandle,\r
2113 IN EFI_GUID *DriverName\r
2114 );\r
2115\r
2116\r
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
2121\r
2122 @param ImageHandle The image handle.\r
2123 @param SystemTable The system table.\r
2124\r
2125 @retval EFI_SUCCESS Function successfully returned.\r
2126\r
2127**/\r
2128EFI_STATUS\r
2129EFIAPI\r
2130FwVolDriverInit (\r
2131 IN EFI_HANDLE ImageHandle,\r
2132 IN EFI_SYSTEM_TABLE *SystemTable\r
2133 );\r
2134\r
2135\r
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
2142\r
2143 @retval EFI_SUCCESS Driver initialized successfully\r
2144 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources\r
2145\r
2146**/\r
2147EFI_STATUS\r
2148EFIAPI\r
2149InitializeSectionExtraction (\r
2150 IN EFI_HANDLE ImageHandle,\r
2151 IN EFI_SYSTEM_TABLE *SystemTable\r
2152 );\r
2153\r
2154\r
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
2159\r
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
2164\r
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
2169 firmware volume\r
2170\r
2171**/\r
2172EFI_STATUS\r
2173EFIAPI\r
2174CoreProcessFirmwareVolume (\r
2175 IN VOID *FvHeader,\r
2176 IN UINTN Size,\r
2177 OUT EFI_HANDLE *FVProtocolHandle\r
2178 );\r
2179\r
2180//\r
2181//Functions used during debug buils\r
2182//\r
2183\r
2184/**\r
2185 Displays Architectural protocols that were not loaded and are required for DXE\r
2186 core to function. Only used in Debug Builds.\r
2187\r
2188**/\r
2189VOID\r
2190CoreDisplayMissingArchProtocols (\r
2191 VOID\r
2192 );\r
2193\r
2194\r
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
2198\r
2199**/\r
2200VOID\r
2201CoreDisplayDiscoveredNotDispatched (\r
2202 VOID\r
2203 );\r
2204\r
2205\r
2206/**\r
2207 Place holder function until all the Boot Services and Runtime Services are\r
2208 available.\r
2209\r
2210 @return EFI_NOT_AVAILABLE_YET\r
2211\r
2212**/\r
2213EFI_STATUS\r
2214EFIAPI\r
2215CoreEfiNotAvailableYetArg0 (\r
2216 VOID\r
2217 );\r
2218\r
2219\r
2220/**\r
2221 Place holder function until all the Boot Services and Runtime Services are\r
2222 available.\r
2223\r
2224 @param Arg1 Undefined\r
2225\r
2226 @return EFI_NOT_AVAILABLE_YET\r
2227\r
2228**/\r
2229EFI_STATUS\r
2230EFIAPI\r
2231CoreEfiNotAvailableYetArg1 (\r
2232 UINTN Arg1\r
2233 );\r
2234\r
2235\r
2236/**\r
2237 Place holder function until all the Boot Services and Runtime Services are available.\r
2238\r
2239 @param Arg1 Undefined\r
2240 @param Arg2 Undefined\r
2241\r
2242 @return EFI_NOT_AVAILABLE_YET\r
2243\r
2244**/\r
2245EFI_STATUS\r
2246EFIAPI\r
2247CoreEfiNotAvailableYetArg2 (\r
2248 UINTN Arg1,\r
2249 UINTN Arg2\r
2250 );\r
2251\r
2252\r
2253/**\r
2254 Place holder function until all the Boot Services and Runtime Services are available.\r
2255\r
2256 @param Arg1 Undefined\r
2257 @param Arg2 Undefined\r
2258 @param Arg3 Undefined\r
2259\r
2260 @return EFI_NOT_AVAILABLE_YET\r
2261\r
2262**/\r
2263EFI_STATUS\r
2264EFIAPI\r
2265CoreEfiNotAvailableYetArg3 (\r
2266 UINTN Arg1,\r
2267 UINTN Arg2,\r
2268 UINTN Arg3\r
2269 );\r
2270\r
2271\r
2272/**\r
2273 Place holder function until all the Boot Services and Runtime Services are available.\r
2274\r
2275 @param Arg1 Undefined\r
2276 @param Arg2 Undefined\r
2277 @param Arg3 Undefined\r
2278 @param Arg4 Undefined\r
2279\r
2280 @return EFI_NOT_AVAILABLE_YET\r
2281\r
2282**/\r
2283EFI_STATUS\r
2284EFIAPI\r
2285CoreEfiNotAvailableYetArg4 (\r
2286 UINTN Arg1,\r
2287 UINTN Arg2,\r
2288 UINTN Arg3,\r
2289 UINTN Arg4\r
2290 );\r
2291\r
2292\r
2293/**\r
2294 Place holder function until all the Boot Services and Runtime Services are available.\r
2295\r
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
2301\r
2302 @return EFI_NOT_AVAILABLE_YET\r
2303\r
2304**/\r
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
2313 );\r
2314\r
2315\r
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
2345\r
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
2353\r
2354**/\r
2355EFI_STATUS\r
2356EFIAPI\r
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
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
2373 implementation. It is the caller's responsibility to allocate and free the\r
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
2392\r
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
2400EFI_STATUS\r
2401EFIAPI\r
2402DxeMainUefiDecompress (\r
2403 IN EFI_DECOMPRESS_PROTOCOL *This,\r
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
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
2415\r
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
2420\r
2421 @retval EFI_SUCCESS The section stream is created successfully.\r
2422 @retval EFI_OUT_OF_RESOURCES memory allocation failed.\r
2423 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end\r
2424 of last section.\r
2425\r
2426**/\r
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
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
2452 required buffer size is returned in *BufferSize.\r
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
2459 output buffer. If the input section's\r
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
2473 @param IsFfs3Fv Indicates the FV format.\r
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
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
2504 OUT UINT32 *AuthenticationStatus,\r
2505 IN BOOLEAN IsFfs3Fv\r
2506 );\r
2507\r
2508\r
2509/**\r
2510 SEP member function. Deletes an existing section stream\r
2511\r
2512 @param StreamHandleToClose Indicates the stream to close\r
2513 @param FreeStreamBuffer TRUE - Need to free stream buffer;\r
2514 FALSE - No need to free stream buffer.\r
2515\r
2516 @retval EFI_SUCCESS The section stream is closed sucessfully.\r
2517 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r
2518 @retval EFI_INVALID_PARAMETER Section stream does not end concident with end\r
2519 of last section.\r
2520\r
2521**/\r
2522EFI_STATUS\r
2523EFIAPI\r
2524CloseSectionStream (\r
2525 IN UINTN StreamHandleToClose,\r
2526 IN BOOLEAN FreeStreamBuffer\r
2527 );\r
2528\r
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
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
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
2628 came from an FV image file and section in another firmware\r
2629 volume (ala capsules)\r
2630 @param AuthenticationStatus Authentication status inherited, if this image\r
2631 came from an FV image file and section in another firmware volume.\r
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
2645 IN UINT32 AuthenticationStatus,\r
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
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
2736 @retval EFI_INVALID_PARAMETER The FV Header signature is not as expected or\r
2737 the file system could not be understood.\r
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
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
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
2790\r
2791**/\r
2792EFI_STATUS\r
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
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
2807\r
2808**/\r
2809EFI_STATUS\r
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
2820 EfiMaxMemoryType means the MemoryType is unknown.\r
2821 @param Size Buffer size.\r
2822 @param Buffer Buffer address.\r
2823 @param ActionString String for memory profile action.\r
2824 Only needed for user defined allocate action.\r
2825\r
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
2834\r
2835**/\r
2836EFI_STATUS\r
2837EFIAPI\r
2838CoreUpdateProfile (\r
2839 IN EFI_PHYSICAL_ADDRESS CallerAddress,\r
2840 IN MEMORY_PROFILE_ACTION Action,\r
2841 IN EFI_MEMORY_TYPE MemoryType,\r
2842 IN UINTN Size, // Valid for AllocatePages/FreePages/AllocatePool\r
2843 IN VOID *Buffer,\r
2844 IN CHAR8 *ActionString OPTIONAL\r
2845 );\r
2846\r
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
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
2863/**\r
2864 Initialize PropertiesTable support.\r
2865**/\r
2866VOID\r
2867EFIAPI\r
2868CoreInitializePropertiesTable (\r
2869 VOID\r
2870 );\r
2871\r
2872/**\r
2873 Initialize MemoryAttrubutesTable support.\r
2874**/\r
2875VOID\r
2876EFIAPI\r
2877CoreInitializeMemoryAttributesTable (\r
2878 VOID\r
2879 );\r
2880\r
2881/**\r
2882 Initialize Memory Protection support.\r
2883**/\r
2884VOID\r
2885EFIAPI\r
2886CoreInitializeMemoryProtection (\r
2887 VOID\r
2888 );\r
2889\r
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
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
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
2952#endif\r