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