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