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