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