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