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