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