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