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