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