]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
34bd6411d655e730f12ca028e5ecba82d30a90a1
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / PiSmmCore.h
1 /** @file
2 The internal header file includes the common header files, defines
3 internal structure and functions used by SmmCore module.
4
5 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available
7 under the terms and conditions of the BSD License which accompanies this
8 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 _SMM_CORE_H_
17 #define _SMM_CORE_H_
18
19 #include <PiSmm.h>
20
21 #include <Protocol/DxeSmmReadyToLock.h>
22 #include <Protocol/SmmReadyToLock.h>
23 #include <Protocol/SmmEndOfDxe.h>
24 #include <Protocol/CpuIo2.h>
25 #include <Protocol/SmmCommunication.h>
26 #include <Protocol/SmmAccess2.h>
27 #include <Protocol/FirmwareVolume2.h>
28 #include <Protocol/LoadedImage.h>
29 #include <Protocol/DevicePath.h>
30 #include <Protocol/Security.h>
31 #include <Protocol/Security2.h>
32
33 #include <Guid/Apriori.h>
34 #include <Guid/EventGroup.h>
35 #include <Guid/EventLegacyBios.h>
36 #include <Guid/ZeroGuid.h>
37 #include <Guid/MemoryProfile.h>
38
39 #include <Library/BaseLib.h>
40 #include <Library/BaseMemoryLib.h>
41 #include <Library/PeCoffLib.h>
42 #include <Library/CacheMaintenanceLib.h>
43 #include <Library/DebugLib.h>
44 #include <Library/ReportStatusCodeLib.h>
45 #include <Library/MemoryAllocationLib.h>
46 #include <Library/DevicePathLib.h>
47 #include <Library/UefiLib.h>
48 #include <Library/UefiBootServicesTableLib.h>
49 #include <Library/PcdLib.h>
50 #include <Library/SmmCorePlatformHookLib.h>
51 #include <Library/PerformanceLib.h>
52 #include <Library/TimerLib.h>
53 #include <Library/HobLib.h>
54
55 #include "PiSmmCorePrivateData.h"
56
57 //
58 // Used to build a table of SMI Handlers that the SMM Core registers
59 //
60 typedef struct {
61 EFI_SMM_HANDLER_ENTRY_POINT2 Handler;
62 EFI_GUID *HandlerType;
63 EFI_HANDLE DispatchHandle;
64 BOOLEAN UnRegister;
65 } SMM_CORE_SMI_HANDLERS;
66
67 //
68 // Structure for recording the state of an SMM Driver
69 //
70 #define EFI_SMM_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('s', 'd','r','v')
71
72 typedef struct {
73 UINTN Signature;
74 LIST_ENTRY Link; // mDriverList
75
76 LIST_ENTRY ScheduledLink; // mScheduledQueue
77
78 EFI_HANDLE FvHandle;
79 EFI_GUID FileName;
80 EFI_DEVICE_PATH_PROTOCOL *FvFileDevicePath;
81 EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
82
83 VOID *Depex;
84 UINTN DepexSize;
85
86 BOOLEAN Before;
87 BOOLEAN After;
88 EFI_GUID BeforeAfterGuid;
89
90 BOOLEAN Dependent;
91 BOOLEAN Scheduled;
92 BOOLEAN Initialized;
93 BOOLEAN DepexProtocolError;
94
95 EFI_HANDLE ImageHandle;
96 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
97 //
98 // Image EntryPoint in SMRAM
99 //
100 PHYSICAL_ADDRESS ImageEntryPoint;
101 //
102 // Image Buffer in SMRAM
103 //
104 PHYSICAL_ADDRESS ImageBuffer;
105 //
106 // Image Page Number
107 //
108 UINTN NumberOfPage;
109 } EFI_SMM_DRIVER_ENTRY;
110
111 #define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')
112
113 ///
114 /// IHANDLE - contains a list of protocol handles
115 ///
116 typedef struct {
117 UINTN Signature;
118 /// All handles list of IHANDLE
119 LIST_ENTRY AllHandles;
120 /// List of PROTOCOL_INTERFACE's for this handle
121 LIST_ENTRY Protocols;
122 UINTN LocateRequest;
123 } IHANDLE;
124
125 #define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)
126
127 #define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')
128
129 ///
130 /// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol
131 /// database. Each handler that supports this protocol is listed, along
132 /// with a list of registered notifies.
133 ///
134 typedef struct {
135 UINTN Signature;
136 /// Link Entry inserted to mProtocolDatabase
137 LIST_ENTRY AllEntries;
138 /// ID of the protocol
139 EFI_GUID ProtocolID;
140 /// All protocol interfaces
141 LIST_ENTRY Protocols;
142 /// Registerd notification handlers
143 LIST_ENTRY Notify;
144 } PROTOCOL_ENTRY;
145
146 #define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')
147
148 ///
149 /// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked
150 /// with a protocol interface structure
151 ///
152 typedef struct {
153 UINTN Signature;
154 /// Link on IHANDLE.Protocols
155 LIST_ENTRY Link;
156 /// Back pointer
157 IHANDLE *Handle;
158 /// Link on PROTOCOL_ENTRY.Protocols
159 LIST_ENTRY ByProtocol;
160 /// The protocol ID
161 PROTOCOL_ENTRY *Protocol;
162 /// The interface value
163 VOID *Interface;
164 } PROTOCOL_INTERFACE;
165
166 #define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')
167
168 ///
169 /// PROTOCOL_NOTIFY - used for each register notification for a protocol
170 ///
171 typedef struct {
172 UINTN Signature;
173 PROTOCOL_ENTRY *Protocol;
174 /// All notifications for this protocol
175 LIST_ENTRY Link;
176 /// Notification function
177 EFI_SMM_NOTIFY_FN Function;
178 /// Last position notified
179 LIST_ENTRY *Position;
180 } PROTOCOL_NOTIFY;
181
182 //
183 // SMM Core Global Variables
184 //
185 extern SMM_CORE_PRIVATE_DATA *gSmmCorePrivate;
186 extern EFI_SMM_SYSTEM_TABLE2 gSmmCoreSmst;
187 extern LIST_ENTRY gHandleList;
188 extern EFI_PHYSICAL_ADDRESS gLoadModuleAtFixAddressSmramBase;
189
190 /**
191 Called to initialize the memory service.
192
193 @param SmramRangeCount Number of SMRAM Regions
194 @param SmramRanges Pointer to SMRAM Descriptors
195
196 **/
197 VOID
198 SmmInitializeMemoryServices (
199 IN UINTN SmramRangeCount,
200 IN EFI_SMRAM_DESCRIPTOR *SmramRanges
201 );
202
203 /**
204 The SmmInstallConfigurationTable() function is used to maintain the list
205 of configuration tables that are stored in the System Management System
206 Table. The list is stored as an array of (GUID, Pointer) pairs. The list
207 must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.
208
209 @param SystemTable A pointer to the SMM System Table (SMST).
210 @param Guid A pointer to the GUID for the entry to add, update, or remove.
211 @param Table A pointer to the buffer of the table to add.
212 @param TableSize The size of the table to install.
213
214 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.
215 @retval EFI_INVALID_PARAMETER Guid is not valid.
216 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.
217 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.
218
219 **/
220 EFI_STATUS
221 EFIAPI
222 SmmInstallConfigurationTable (
223 IN CONST EFI_SMM_SYSTEM_TABLE2 *SystemTable,
224 IN CONST EFI_GUID *Guid,
225 IN VOID *Table,
226 IN UINTN TableSize
227 );
228
229 /**
230 Wrapper function to SmmInstallProtocolInterfaceNotify. This is the public API which
231 Calls the private one which contains a BOOLEAN parameter for notifications
232
233 @param UserHandle The handle to install the protocol handler on,
234 or NULL if a new handle is to be allocated
235 @param Protocol The protocol to add to the handle
236 @param InterfaceType Indicates whether Interface is supplied in
237 native form.
238 @param Interface The interface for the protocol being added
239
240 @return Status code
241
242 **/
243 EFI_STATUS
244 EFIAPI
245 SmmInstallProtocolInterface (
246 IN OUT EFI_HANDLE *UserHandle,
247 IN EFI_GUID *Protocol,
248 IN EFI_INTERFACE_TYPE InterfaceType,
249 IN VOID *Interface
250 );
251
252 /**
253 Allocates pages from the memory map.
254
255 @param Type The type of allocation to perform
256 @param MemoryType The type of memory to turn the allocated pages
257 into
258 @param NumberOfPages The number of pages to allocate
259 @param Memory A pointer to receive the base allocated memory
260 address
261
262 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
263 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
264 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
265 @retval EFI_SUCCESS Pages successfully allocated.
266
267 **/
268 EFI_STATUS
269 EFIAPI
270 SmmAllocatePages (
271 IN EFI_ALLOCATE_TYPE Type,
272 IN EFI_MEMORY_TYPE MemoryType,
273 IN UINTN NumberOfPages,
274 OUT EFI_PHYSICAL_ADDRESS *Memory
275 );
276
277 /**
278 Allocates pages from the memory map.
279
280 @param Type The type of allocation to perform
281 @param MemoryType The type of memory to turn the allocated pages
282 into
283 @param NumberOfPages The number of pages to allocate
284 @param Memory A pointer to receive the base allocated memory
285 address
286
287 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
288 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
289 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
290 @retval EFI_SUCCESS Pages successfully allocated.
291
292 **/
293 EFI_STATUS
294 EFIAPI
295 SmmInternalAllocatePages (
296 IN EFI_ALLOCATE_TYPE Type,
297 IN EFI_MEMORY_TYPE MemoryType,
298 IN UINTN NumberOfPages,
299 OUT EFI_PHYSICAL_ADDRESS *Memory
300 );
301
302 /**
303 Frees previous allocated pages.
304
305 @param Memory Base address of memory being freed
306 @param NumberOfPages The number of pages to free
307
308 @retval EFI_NOT_FOUND Could not find the entry that covers the range
309 @retval EFI_INVALID_PARAMETER Address not aligned
310 @return EFI_SUCCESS Pages successfully freed.
311
312 **/
313 EFI_STATUS
314 EFIAPI
315 SmmFreePages (
316 IN EFI_PHYSICAL_ADDRESS Memory,
317 IN UINTN NumberOfPages
318 );
319
320 /**
321 Frees previous allocated pages.
322
323 @param Memory Base address of memory being freed
324 @param NumberOfPages The number of pages to free
325
326 @retval EFI_NOT_FOUND Could not find the entry that covers the range
327 @retval EFI_INVALID_PARAMETER Address not aligned
328 @return EFI_SUCCESS Pages successfully freed.
329
330 **/
331 EFI_STATUS
332 EFIAPI
333 SmmInternalFreePages (
334 IN EFI_PHYSICAL_ADDRESS Memory,
335 IN UINTN NumberOfPages
336 );
337
338 /**
339 Allocate pool of a particular type.
340
341 @param PoolType Type of pool to allocate
342 @param Size The amount of pool to allocate
343 @param Buffer The address to return a pointer to the allocated
344 pool
345
346 @retval EFI_INVALID_PARAMETER PoolType not valid
347 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
348 @retval EFI_SUCCESS Pool successfully allocated.
349
350 **/
351 EFI_STATUS
352 EFIAPI
353 SmmAllocatePool (
354 IN EFI_MEMORY_TYPE PoolType,
355 IN UINTN Size,
356 OUT VOID **Buffer
357 );
358
359 /**
360 Allocate pool of a particular type.
361
362 @param PoolType Type of pool to allocate
363 @param Size The amount of pool to allocate
364 @param Buffer The address to return a pointer to the allocated
365 pool
366
367 @retval EFI_INVALID_PARAMETER PoolType not valid
368 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
369 @retval EFI_SUCCESS Pool successfully allocated.
370
371 **/
372 EFI_STATUS
373 EFIAPI
374 SmmInternalAllocatePool (
375 IN EFI_MEMORY_TYPE PoolType,
376 IN UINTN Size,
377 OUT VOID **Buffer
378 );
379
380 /**
381 Frees pool.
382
383 @param Buffer The allocated pool entry to free
384
385 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
386 @retval EFI_SUCCESS Pool successfully freed.
387
388 **/
389 EFI_STATUS
390 EFIAPI
391 SmmFreePool (
392 IN VOID *Buffer
393 );
394
395 /**
396 Frees pool.
397
398 @param Buffer The allocated pool entry to free
399
400 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
401 @retval EFI_SUCCESS Pool successfully freed.
402
403 **/
404 EFI_STATUS
405 EFIAPI
406 SmmInternalFreePool (
407 IN VOID *Buffer
408 );
409
410 /**
411 Installs a protocol interface into the boot services environment.
412
413 @param UserHandle The handle to install the protocol handler on,
414 or NULL if a new handle is to be allocated
415 @param Protocol The protocol to add to the handle
416 @param InterfaceType Indicates whether Interface is supplied in
417 native form.
418 @param Interface The interface for the protocol being added
419 @param Notify indicates whether notify the notification list
420 for this protocol
421
422 @retval EFI_INVALID_PARAMETER Invalid parameter
423 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
424 @retval EFI_SUCCESS Protocol interface successfully installed
425
426 **/
427 EFI_STATUS
428 SmmInstallProtocolInterfaceNotify (
429 IN OUT EFI_HANDLE *UserHandle,
430 IN EFI_GUID *Protocol,
431 IN EFI_INTERFACE_TYPE InterfaceType,
432 IN VOID *Interface,
433 IN BOOLEAN Notify
434 );
435
436 /**
437 Uninstalls all instances of a protocol:interfacer from a handle.
438 If the last protocol interface is remove from the handle, the
439 handle is freed.
440
441 @param UserHandle The handle to remove the protocol handler from
442 @param Protocol The protocol, of protocol:interface, to remove
443 @param Interface The interface, of protocol:interface, to remove
444
445 @retval EFI_INVALID_PARAMETER Protocol is NULL.
446 @retval EFI_SUCCESS Protocol interface successfully uninstalled.
447
448 **/
449 EFI_STATUS
450 EFIAPI
451 SmmUninstallProtocolInterface (
452 IN EFI_HANDLE UserHandle,
453 IN EFI_GUID *Protocol,
454 IN VOID *Interface
455 );
456
457 /**
458 Queries a handle to determine if it supports a specified protocol.
459
460 @param UserHandle The handle being queried.
461 @param Protocol The published unique identifier of the protocol.
462 @param Interface Supplies the address where a pointer to the
463 corresponding Protocol Interface is returned.
464
465 @return The requested protocol interface for the handle
466
467 **/
468 EFI_STATUS
469 EFIAPI
470 SmmHandleProtocol (
471 IN EFI_HANDLE UserHandle,
472 IN EFI_GUID *Protocol,
473 OUT VOID **Interface
474 );
475
476 /**
477 Add a new protocol notification record for the request protocol.
478
479 @param Protocol The requested protocol to add the notify
480 registration
481 @param Function Points to the notification function
482 @param Registration Returns the registration record
483
484 @retval EFI_INVALID_PARAMETER Invalid parameter
485 @retval EFI_SUCCESS Successfully returned the registration record
486 that has been added
487
488 **/
489 EFI_STATUS
490 EFIAPI
491 SmmRegisterProtocolNotify (
492 IN CONST EFI_GUID *Protocol,
493 IN EFI_SMM_NOTIFY_FN Function,
494 OUT VOID **Registration
495 );
496
497 /**
498 Locates the requested handle(s) and returns them in Buffer.
499
500 @param SearchType The type of search to perform to locate the
501 handles
502 @param Protocol The protocol to search for
503 @param SearchKey Dependant on SearchType
504 @param BufferSize On input the size of Buffer. On output the
505 size of data returned.
506 @param Buffer The buffer to return the results in
507
508 @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
509 returned in BufferSize.
510 @retval EFI_INVALID_PARAMETER Invalid parameter
511 @retval EFI_SUCCESS Successfully found the requested handle(s) and
512 returns them in Buffer.
513
514 **/
515 EFI_STATUS
516 EFIAPI
517 SmmLocateHandle (
518 IN EFI_LOCATE_SEARCH_TYPE SearchType,
519 IN EFI_GUID *Protocol OPTIONAL,
520 IN VOID *SearchKey OPTIONAL,
521 IN OUT UINTN *BufferSize,
522 OUT EFI_HANDLE *Buffer
523 );
524
525 /**
526 Return the first Protocol Interface that matches the Protocol GUID. If
527 Registration is pasased in return a Protocol Instance that was just add
528 to the system. If Retistration is NULL return the first Protocol Interface
529 you find.
530
531 @param Protocol The protocol to search for
532 @param Registration Optional Registration Key returned from
533 RegisterProtocolNotify()
534 @param Interface Return the Protocol interface (instance).
535
536 @retval EFI_SUCCESS If a valid Interface is returned
537 @retval EFI_INVALID_PARAMETER Invalid parameter
538 @retval EFI_NOT_FOUND Protocol interface not found
539
540 **/
541 EFI_STATUS
542 EFIAPI
543 SmmLocateProtocol (
544 IN EFI_GUID *Protocol,
545 IN VOID *Registration OPTIONAL,
546 OUT VOID **Interface
547 );
548
549 /**
550 Manage SMI of a particular type.
551
552 @param HandlerType Points to the handler type or NULL for root SMI handlers.
553 @param Context Points to an optional context buffer.
554 @param CommBuffer Points to the optional communication buffer.
555 @param CommBufferSize Points to the size of the optional communication buffer.
556
557 @retval EFI_SUCCESS Interrupt source was processed successfully but not quiesced.
558 @retval EFI_INTERRUPT_PENDING One or more SMI sources could not be quiesced.
559 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was not handled or quiesced.
560 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED Interrupt source was handled and quiesced.
561
562 **/
563 EFI_STATUS
564 EFIAPI
565 SmiManage (
566 IN CONST EFI_GUID *HandlerType,
567 IN CONST VOID *Context OPTIONAL,
568 IN OUT VOID *CommBuffer OPTIONAL,
569 IN OUT UINTN *CommBufferSize OPTIONAL
570 );
571
572 /**
573 Registers a handler to execute within SMM.
574
575 @param Handler Handler service funtion pointer.
576 @param HandlerType Points to the handler type or NULL for root SMI handlers.
577 @param DispatchHandle On return, contains a unique handle which can be used to later unregister the handler function.
578
579 @retval EFI_SUCCESS Handler register success.
580 @retval EFI_INVALID_PARAMETER Handler or DispatchHandle is NULL.
581
582 **/
583 EFI_STATUS
584 EFIAPI
585 SmiHandlerRegister (
586 IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
587 IN CONST EFI_GUID *HandlerType OPTIONAL,
588 OUT EFI_HANDLE *DispatchHandle
589 );
590
591 /**
592 Unregister a handler in SMM.
593
594 @param DispatchHandle The handle that was specified when the handler was registered.
595
596 @retval EFI_SUCCESS Handler function was successfully unregistered.
597 @retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle.
598
599 **/
600 EFI_STATUS
601 EFIAPI
602 SmiHandlerUnRegister (
603 IN EFI_HANDLE DispatchHandle
604 );
605
606 /**
607 This function is the main entry point for an SMM handler dispatch
608 or communicate-based callback.
609
610 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
611 @param Context Points to an optional handler context which was specified when the handler was registered.
612 @param CommBuffer A pointer to a collection of data in memory that will
613 be conveyed from a non-SMM environment into an SMM environment.
614 @param CommBufferSize The size of the CommBuffer.
615
616 @return Status Code
617
618 **/
619 EFI_STATUS
620 EFIAPI
621 SmmDriverDispatchHandler (
622 IN EFI_HANDLE DispatchHandle,
623 IN CONST VOID *Context, OPTIONAL
624 IN OUT VOID *CommBuffer, OPTIONAL
625 IN OUT UINTN *CommBufferSize OPTIONAL
626 );
627
628 /**
629 This function is the main entry point for an SMM handler dispatch
630 or communicate-based callback.
631
632 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
633 @param Context Points to an optional handler context which was specified when the handler was registered.
634 @param CommBuffer A pointer to a collection of data in memory that will
635 be conveyed from a non-SMM environment into an SMM environment.
636 @param CommBufferSize The size of the CommBuffer.
637
638 @return Status Code
639
640 **/
641 EFI_STATUS
642 EFIAPI
643 SmmLegacyBootHandler (
644 IN EFI_HANDLE DispatchHandle,
645 IN CONST VOID *Context, OPTIONAL
646 IN OUT VOID *CommBuffer, OPTIONAL
647 IN OUT UINTN *CommBufferSize OPTIONAL
648 );
649
650 /**
651 This function is the main entry point for an SMM handler dispatch
652 or communicate-based callback.
653
654 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
655 @param Context Points to an optional handler context which was specified when the handler was registered.
656 @param CommBuffer A pointer to a collection of data in memory that will
657 be conveyed from a non-SMM environment into an SMM environment.
658 @param CommBufferSize The size of the CommBuffer.
659
660 @return Status Code
661
662 **/
663 EFI_STATUS
664 EFIAPI
665 SmmReadyToLockHandler (
666 IN EFI_HANDLE DispatchHandle,
667 IN CONST VOID *Context, OPTIONAL
668 IN OUT VOID *CommBuffer, OPTIONAL
669 IN OUT UINTN *CommBufferSize OPTIONAL
670 );
671
672 /**
673 This function is the main entry point for an SMM handler dispatch
674 or communicate-based callback.
675
676 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
677 @param Context Points to an optional handler context which was specified when the handler was registered.
678 @param CommBuffer A pointer to a collection of data in memory that will
679 be conveyed from a non-SMM environment into an SMM environment.
680 @param CommBufferSize The size of the CommBuffer.
681
682 @return Status Code
683
684 **/
685 EFI_STATUS
686 EFIAPI
687 SmmEndOfDxeHandler (
688 IN EFI_HANDLE DispatchHandle,
689 IN CONST VOID *Context, OPTIONAL
690 IN OUT VOID *CommBuffer, OPTIONAL
691 IN OUT UINTN *CommBufferSize OPTIONAL
692 );
693
694 /**
695 Place holder function until all the SMM System Table Service are available.
696
697 @param Arg1 Undefined
698 @param Arg2 Undefined
699 @param Arg3 Undefined
700 @param Arg4 Undefined
701 @param Arg5 Undefined
702
703 @return EFI_NOT_AVAILABLE_YET
704
705 **/
706 EFI_STATUS
707 EFIAPI
708 SmmEfiNotAvailableYetArg5 (
709 UINTN Arg1,
710 UINTN Arg2,
711 UINTN Arg3,
712 UINTN Arg4,
713 UINTN Arg5
714 );
715
716 //
717 //Functions used during debug buils
718 //
719
720 /**
721 Traverse the discovered list for any drivers that were discovered but not loaded
722 because the dependency experessions evaluated to false.
723
724 **/
725 VOID
726 SmmDisplayDiscoveredNotDispatched (
727 VOID
728 );
729
730 /**
731 Add free SMRAM region for use by memory service.
732
733 @param MemBase Base address of memory region.
734 @param MemLength Length of the memory region.
735 @param Type Memory type.
736 @param Attributes Memory region state.
737
738 **/
739 VOID
740 SmmAddMemoryRegion (
741 IN EFI_PHYSICAL_ADDRESS MemBase,
742 IN UINT64 MemLength,
743 IN EFI_MEMORY_TYPE Type,
744 IN UINT64 Attributes
745 );
746
747 /**
748 Finds the protocol entry for the requested protocol.
749
750 @param Protocol The ID of the protocol
751 @param Create Create a new entry if not found
752
753 @return Protocol entry
754
755 **/
756 PROTOCOL_ENTRY *
757 SmmFindProtocolEntry (
758 IN EFI_GUID *Protocol,
759 IN BOOLEAN Create
760 );
761
762 /**
763 Signal event for every protocol in protocol entry.
764
765 @param Prot Protocol interface
766
767 **/
768 VOID
769 SmmNotifyProtocol (
770 IN PROTOCOL_INTERFACE *Prot
771 );
772
773 /**
774 Finds the protocol instance for the requested handle and protocol.
775 Note: This function doesn't do parameters checking, it's caller's responsibility
776 to pass in valid parameters.
777
778 @param Handle The handle to search the protocol on
779 @param Protocol GUID of the protocol
780 @param Interface The interface for the protocol being searched
781
782 @return Protocol instance (NULL: Not found)
783
784 **/
785 PROTOCOL_INTERFACE *
786 SmmFindProtocolInterface (
787 IN IHANDLE *Handle,
788 IN EFI_GUID *Protocol,
789 IN VOID *Interface
790 );
791
792 /**
793 Removes Protocol from the protocol list (but not the handle list).
794
795 @param Handle The handle to remove protocol on.
796 @param Protocol GUID of the protocol to be moved
797 @param Interface The interface of the protocol
798
799 @return Protocol Entry
800
801 **/
802 PROTOCOL_INTERFACE *
803 SmmRemoveInterfaceFromProtocol (
804 IN IHANDLE *Handle,
805 IN EFI_GUID *Protocol,
806 IN VOID *Interface
807 );
808
809 /**
810 This is the POSTFIX version of the dependency evaluator. This code does
811 not need to handle Before or After, as it is not valid to call this
812 routine in this case. POSTFIX means all the math is done on top of the stack.
813
814 @param DriverEntry DriverEntry element to update.
815
816 @retval TRUE If driver is ready to run.
817 @retval FALSE If driver is not ready to run or some fatal error
818 was found.
819
820 **/
821 BOOLEAN
822 SmmIsSchedulable (
823 IN EFI_SMM_DRIVER_ENTRY *DriverEntry
824 );
825
826 //
827 // SmramProfile
828 //
829
830 /**
831 Initialize SMRAM profile.
832
833 **/
834 VOID
835 SmramProfileInit (
836 VOID
837 );
838
839 /**
840 Register SMM image to SMRAM profile.
841
842 @param DriverEntry SMM image info.
843 @param RegisterToDxe Register image to DXE.
844
845 @retval TRUE Register success.
846 @retval FALSE Register fail.
847
848 **/
849 BOOLEAN
850 RegisterSmramProfileImage (
851 IN EFI_SMM_DRIVER_ENTRY *DriverEntry,
852 IN BOOLEAN RegisterToDxe
853 );
854
855 /**
856 Unregister image from SMRAM profile.
857
858 @param DriverEntry SMM image info.
859 @param UnregisterToDxe Unregister image from DXE.
860
861 @retval TRUE Unregister success.
862 @retval FALSE Unregister fail.
863
864 **/
865 BOOLEAN
866 UnregisterSmramProfileImage (
867 IN EFI_SMM_DRIVER_ENTRY *DriverEntry,
868 IN BOOLEAN UnregisterToDxe
869 );
870
871 /**
872 Update SMRAM profile information.
873
874 @param CallerAddress Address of caller who call Allocate or Free.
875 @param Action This Allocate or Free action.
876 @param MemoryType Memory type.
877 @param Size Buffer size.
878 @param Buffer Buffer address.
879
880 @retval TRUE Profile udpate success.
881 @retval FALSE Profile update fail.
882
883 **/
884 BOOLEAN
885 SmmCoreUpdateProfile (
886 IN EFI_PHYSICAL_ADDRESS CallerAddress,
887 IN MEMORY_PROFILE_ACTION Action,
888 IN EFI_MEMORY_TYPE MemoryType, // Valid for AllocatePages/AllocatePool
889 IN UINTN Size, // Valid for AllocatePages/FreePages/AllocatePool
890 IN VOID *Buffer
891 );
892
893 /**
894 Register SMRAM profile handler.
895
896 **/
897 VOID
898 RegisterSmramProfileHandler (
899 VOID
900 );
901
902 /**
903 SMRAM profile ready to lock callback function.
904
905 **/
906 VOID
907 SmramProfileReadyToLock (
908 VOID
909 );
910
911 /**
912 Dump SMRAM infromation.
913
914 **/
915 VOID
916 DumpSmramInfo (
917 VOID
918 );
919
920 extern UINTN mFullSmramRangeCount;
921 extern EFI_SMRAM_DESCRIPTOR *mFullSmramRanges;
922
923 #endif