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