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