StandaloneMmCore.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853
  1. /** @file
  2. The internal header file includes the common header files, defines
  3. internal structure and functions used by MmCore module.
  4. Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
  5. Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR>
  6. SPDX-License-Identifier: BSD-2-Clause-Patent
  7. **/
  8. #ifndef _MM_CORE_H_
  9. #define _MM_CORE_H_
  10. #include <PiMm.h>
  11. #include <StandaloneMm.h>
  12. #include <Protocol/DxeMmReadyToLock.h>
  13. #include <Protocol/MmReadyToLock.h>
  14. #include <Protocol/MmEndOfDxe.h>
  15. #include <Protocol/MmCommunication2.h>
  16. #include <Protocol/LoadedImage.h>
  17. #include <Protocol/MmConfiguration.h>
  18. #include <Guid/Apriori.h>
  19. #include <Guid/EventGroup.h>
  20. #include <Guid/EventLegacyBios.h>
  21. #include <Guid/ZeroGuid.h>
  22. #include <Guid/MemoryProfile.h>
  23. #include <Guid/HobList.h>
  24. #include <Guid/MmFvDispatch.h>
  25. #include <Guid/MmramMemoryReserve.h>
  26. #include <Library/StandaloneMmCoreEntryPoint.h>
  27. #include <Library/BaseLib.h>
  28. #include <Library/BaseMemoryLib.h>
  29. #include <Library/PeCoffLib.h>
  30. #include <Library/CacheMaintenanceLib.h>
  31. #include <Library/DebugLib.h>
  32. #include <Library/ReportStatusCodeLib.h>
  33. #include <Library/MemoryAllocationLib.h>
  34. #include <Library/PcdLib.h>
  35. #include <Library/StandaloneMmMemLib.h>
  36. #include <Library/HobLib.h>
  37. #include "StandaloneMmCorePrivateData.h"
  38. //
  39. // Used to build a table of MMI Handlers that the MM Core registers
  40. //
  41. typedef struct {
  42. EFI_MM_HANDLER_ENTRY_POINT Handler;
  43. EFI_GUID *HandlerType;
  44. EFI_HANDLE DispatchHandle;
  45. BOOLEAN UnRegister;
  46. } MM_CORE_MMI_HANDLERS;
  47. //
  48. // Structure for recording the state of an MM Driver
  49. //
  50. #define EFI_MM_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('s', 'd','r','v')
  51. typedef struct {
  52. UINTN Signature;
  53. LIST_ENTRY Link; // mDriverList
  54. LIST_ENTRY ScheduledLink; // mScheduledQueue
  55. EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
  56. EFI_GUID FileName;
  57. VOID *Pe32Data;
  58. UINTN Pe32DataSize;
  59. VOID *Depex;
  60. UINTN DepexSize;
  61. BOOLEAN Before;
  62. BOOLEAN After;
  63. EFI_GUID BeforeAfterGuid;
  64. BOOLEAN Dependent;
  65. BOOLEAN Scheduled;
  66. BOOLEAN Initialized;
  67. BOOLEAN DepexProtocolError;
  68. EFI_HANDLE ImageHandle;
  69. EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
  70. //
  71. // Image EntryPoint in MMRAM
  72. //
  73. PHYSICAL_ADDRESS ImageEntryPoint;
  74. //
  75. // Image Buffer in MMRAM
  76. //
  77. PHYSICAL_ADDRESS ImageBuffer;
  78. //
  79. // Image Page Number
  80. //
  81. UINTN NumberOfPage;
  82. } EFI_MM_DRIVER_ENTRY;
  83. #define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')
  84. ///
  85. /// IHANDLE - contains a list of protocol handles
  86. ///
  87. typedef struct {
  88. UINTN Signature;
  89. /// All handles list of IHANDLE
  90. LIST_ENTRY AllHandles;
  91. /// List of PROTOCOL_INTERFACE's for this handle
  92. LIST_ENTRY Protocols;
  93. UINTN LocateRequest;
  94. } IHANDLE;
  95. #define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)
  96. #define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')
  97. ///
  98. /// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol
  99. /// database. Each handler that supports this protocol is listed, along
  100. /// with a list of registered notifies.
  101. ///
  102. typedef struct {
  103. UINTN Signature;
  104. /// Link Entry inserted to mProtocolDatabase
  105. LIST_ENTRY AllEntries;
  106. /// ID of the protocol
  107. EFI_GUID ProtocolID;
  108. /// All protocol interfaces
  109. LIST_ENTRY Protocols;
  110. /// Registered notification handlers
  111. LIST_ENTRY Notify;
  112. } PROTOCOL_ENTRY;
  113. #define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')
  114. ///
  115. /// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked
  116. /// with a protocol interface structure
  117. ///
  118. typedef struct {
  119. UINTN Signature;
  120. /// Link on IHANDLE.Protocols
  121. LIST_ENTRY Link;
  122. /// Back pointer
  123. IHANDLE *Handle;
  124. /// Link on PROTOCOL_ENTRY.Protocols
  125. LIST_ENTRY ByProtocol;
  126. /// The protocol ID
  127. PROTOCOL_ENTRY *Protocol;
  128. /// The interface value
  129. VOID *Interface;
  130. } PROTOCOL_INTERFACE;
  131. #define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')
  132. ///
  133. /// PROTOCOL_NOTIFY - used for each register notification for a protocol
  134. ///
  135. typedef struct {
  136. UINTN Signature;
  137. PROTOCOL_ENTRY *Protocol;
  138. /// All notifications for this protocol
  139. LIST_ENTRY Link;
  140. /// Notification function
  141. EFI_MM_NOTIFY_FN Function;
  142. /// Last position notified
  143. LIST_ENTRY *Position;
  144. } PROTOCOL_NOTIFY;
  145. //
  146. // MM Core Global Variables
  147. //
  148. extern MM_CORE_PRIVATE_DATA *gMmCorePrivate;
  149. extern EFI_MM_SYSTEM_TABLE gMmCoreMmst;
  150. extern LIST_ENTRY gHandleList;
  151. extern EFI_PHYSICAL_ADDRESS gLoadModuleAtFixAddressMmramBase;
  152. /**
  153. Called to initialize the memory service.
  154. @param MmramRangeCount Number of MMRAM Regions
  155. @param MmramRanges Pointer to MMRAM Descriptors
  156. **/
  157. VOID
  158. MmInitializeMemoryServices (
  159. IN UINTN MmramRangeCount,
  160. IN EFI_MMRAM_DESCRIPTOR *MmramRanges
  161. );
  162. /**
  163. The MmInstallConfigurationTable() function is used to maintain the list
  164. of configuration tables that are stored in the System Management System
  165. Table. The list is stored as an array of (GUID, Pointer) pairs. The list
  166. must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.
  167. @param SystemTable A pointer to the MM System Table (SMST).
  168. @param Guid A pointer to the GUID for the entry to add, update, or remove.
  169. @param Table A pointer to the buffer of the table to add.
  170. @param TableSize The size of the table to install.
  171. @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.
  172. @retval EFI_INVALID_PARAMETER Guid is not valid.
  173. @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.
  174. @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.
  175. **/
  176. EFI_STATUS
  177. EFIAPI
  178. MmInstallConfigurationTable (
  179. IN CONST EFI_MM_SYSTEM_TABLE *SystemTable,
  180. IN CONST EFI_GUID *Guid,
  181. IN VOID *Table,
  182. IN UINTN TableSize
  183. );
  184. /**
  185. Wrapper function to MmInstallProtocolInterfaceNotify. This is the public API which
  186. Calls the private one which contains a BOOLEAN parameter for notifications
  187. @param UserHandle The handle to install the protocol handler on,
  188. or NULL if a new handle is to be allocated
  189. @param Protocol The protocol to add to the handle
  190. @param InterfaceType Indicates whether Interface is supplied in
  191. native form.
  192. @param Interface The interface for the protocol being added
  193. @return Status code
  194. **/
  195. EFI_STATUS
  196. EFIAPI
  197. MmInstallProtocolInterface (
  198. IN OUT EFI_HANDLE *UserHandle,
  199. IN EFI_GUID *Protocol,
  200. IN EFI_INTERFACE_TYPE InterfaceType,
  201. IN VOID *Interface
  202. );
  203. /**
  204. Allocates pages from the memory map.
  205. @param Type The type of allocation to perform
  206. @param MemoryType The type of memory to turn the allocated pages
  207. into
  208. @param NumberOfPages The number of pages to allocate
  209. @param Memory A pointer to receive the base allocated memory
  210. address
  211. @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
  212. @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
  213. @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
  214. @retval EFI_SUCCESS Pages successfully allocated.
  215. **/
  216. EFI_STATUS
  217. EFIAPI
  218. MmAllocatePages (
  219. IN EFI_ALLOCATE_TYPE Type,
  220. IN EFI_MEMORY_TYPE MemoryType,
  221. IN UINTN NumberOfPages,
  222. OUT EFI_PHYSICAL_ADDRESS *Memory
  223. );
  224. /**
  225. Allocates pages from the memory map.
  226. @param Type The type of allocation to perform
  227. @param MemoryType The type of memory to turn the allocated pages
  228. into
  229. @param NumberOfPages The number of pages to allocate
  230. @param Memory A pointer to receive the base allocated memory
  231. address
  232. @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
  233. @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
  234. @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
  235. @retval EFI_SUCCESS Pages successfully allocated.
  236. **/
  237. EFI_STATUS
  238. EFIAPI
  239. MmInternalAllocatePages (
  240. IN EFI_ALLOCATE_TYPE Type,
  241. IN EFI_MEMORY_TYPE MemoryType,
  242. IN UINTN NumberOfPages,
  243. OUT EFI_PHYSICAL_ADDRESS *Memory
  244. );
  245. /**
  246. Frees previous allocated pages.
  247. @param Memory Base address of memory being freed
  248. @param NumberOfPages The number of pages to free
  249. @retval EFI_NOT_FOUND Could not find the entry that covers the range
  250. @retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.
  251. @return EFI_SUCCESS Pages successfully freed.
  252. **/
  253. EFI_STATUS
  254. EFIAPI
  255. MmFreePages (
  256. IN EFI_PHYSICAL_ADDRESS Memory,
  257. IN UINTN NumberOfPages
  258. );
  259. /**
  260. Frees previous allocated pages.
  261. @param Memory Base address of memory being freed
  262. @param NumberOfPages The number of pages to free
  263. @retval EFI_NOT_FOUND Could not find the entry that covers the range
  264. @retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.
  265. @return EFI_SUCCESS Pages successfully freed.
  266. **/
  267. EFI_STATUS
  268. EFIAPI
  269. MmInternalFreePages (
  270. IN EFI_PHYSICAL_ADDRESS Memory,
  271. IN UINTN NumberOfPages
  272. );
  273. /**
  274. Allocate pool of a particular type.
  275. @param PoolType Type of pool to allocate
  276. @param Size The amount of pool to allocate
  277. @param Buffer The address to return a pointer to the allocated
  278. pool
  279. @retval EFI_INVALID_PARAMETER PoolType not valid
  280. @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
  281. @retval EFI_SUCCESS Pool successfully allocated.
  282. **/
  283. EFI_STATUS
  284. EFIAPI
  285. MmAllocatePool (
  286. IN EFI_MEMORY_TYPE PoolType,
  287. IN UINTN Size,
  288. OUT VOID **Buffer
  289. );
  290. /**
  291. Allocate pool of a particular type.
  292. @param PoolType Type of pool to allocate
  293. @param Size The amount of pool to allocate
  294. @param Buffer The address to return a pointer to the allocated
  295. pool
  296. @retval EFI_INVALID_PARAMETER PoolType not valid
  297. @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
  298. @retval EFI_SUCCESS Pool successfully allocated.
  299. **/
  300. EFI_STATUS
  301. EFIAPI
  302. MmInternalAllocatePool (
  303. IN EFI_MEMORY_TYPE PoolType,
  304. IN UINTN Size,
  305. OUT VOID **Buffer
  306. );
  307. /**
  308. Frees pool.
  309. @param Buffer The allocated pool entry to free
  310. @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
  311. @retval EFI_SUCCESS Pool successfully freed.
  312. **/
  313. EFI_STATUS
  314. EFIAPI
  315. MmFreePool (
  316. IN VOID *Buffer
  317. );
  318. /**
  319. Frees pool.
  320. @param Buffer The allocated pool entry to free
  321. @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
  322. @retval EFI_SUCCESS Pool successfully freed.
  323. **/
  324. EFI_STATUS
  325. EFIAPI
  326. MmInternalFreePool (
  327. IN VOID *Buffer
  328. );
  329. /**
  330. Installs a protocol interface into the boot services environment.
  331. @param UserHandle The handle to install the protocol handler on,
  332. or NULL if a new handle is to be allocated
  333. @param Protocol The protocol to add to the handle
  334. @param InterfaceType Indicates whether Interface is supplied in
  335. native form.
  336. @param Interface The interface for the protocol being added
  337. @param Notify indicates whether notify the notification list
  338. for this protocol
  339. @retval EFI_INVALID_PARAMETER Invalid parameter
  340. @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
  341. @retval EFI_SUCCESS Protocol interface successfully installed
  342. **/
  343. EFI_STATUS
  344. MmInstallProtocolInterfaceNotify (
  345. IN OUT EFI_HANDLE *UserHandle,
  346. IN EFI_GUID *Protocol,
  347. IN EFI_INTERFACE_TYPE InterfaceType,
  348. IN VOID *Interface,
  349. IN BOOLEAN Notify
  350. );
  351. /**
  352. Uninstalls all instances of a protocol:interfacer from a handle.
  353. If the last protocol interface is remove from the handle, the
  354. handle is freed.
  355. @param UserHandle The handle to remove the protocol handler from
  356. @param Protocol The protocol, of protocol:interface, to remove
  357. @param Interface The interface, of protocol:interface, to remove
  358. @retval EFI_INVALID_PARAMETER Protocol is NULL.
  359. @retval EFI_SUCCESS Protocol interface successfully uninstalled.
  360. **/
  361. EFI_STATUS
  362. EFIAPI
  363. MmUninstallProtocolInterface (
  364. IN EFI_HANDLE UserHandle,
  365. IN EFI_GUID *Protocol,
  366. IN VOID *Interface
  367. );
  368. /**
  369. Queries a handle to determine if it supports a specified protocol.
  370. @param UserHandle The handle being queried.
  371. @param Protocol The published unique identifier of the protocol.
  372. @param Interface Supplies the address where a pointer to the
  373. corresponding Protocol Interface is returned.
  374. @return The requested protocol interface for the handle
  375. **/
  376. EFI_STATUS
  377. EFIAPI
  378. MmHandleProtocol (
  379. IN EFI_HANDLE UserHandle,
  380. IN EFI_GUID *Protocol,
  381. OUT VOID **Interface
  382. );
  383. /**
  384. Add a new protocol notification record for the request protocol.
  385. @param Protocol The requested protocol to add the notify
  386. registration
  387. @param Function Points to the notification function
  388. @param Registration Returns the registration record
  389. @retval EFI_INVALID_PARAMETER Invalid parameter
  390. @retval EFI_SUCCESS Successfully returned the registration record
  391. that has been added
  392. **/
  393. EFI_STATUS
  394. EFIAPI
  395. MmRegisterProtocolNotify (
  396. IN CONST EFI_GUID *Protocol,
  397. IN EFI_MM_NOTIFY_FN Function,
  398. OUT VOID **Registration
  399. );
  400. /**
  401. Locates the requested handle(s) and returns them in Buffer.
  402. @param SearchType The type of search to perform to locate the
  403. handles
  404. @param Protocol The protocol to search for
  405. @param SearchKey Dependant on SearchType
  406. @param BufferSize On input the size of Buffer. On output the
  407. size of data returned.
  408. @param Buffer The buffer to return the results in
  409. @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
  410. returned in BufferSize.
  411. @retval EFI_INVALID_PARAMETER Invalid parameter
  412. @retval EFI_SUCCESS Successfully found the requested handle(s) and
  413. returns them in Buffer.
  414. **/
  415. EFI_STATUS
  416. EFIAPI
  417. MmLocateHandle (
  418. IN EFI_LOCATE_SEARCH_TYPE SearchType,
  419. IN EFI_GUID *Protocol OPTIONAL,
  420. IN VOID *SearchKey OPTIONAL,
  421. IN OUT UINTN *BufferSize,
  422. OUT EFI_HANDLE *Buffer
  423. );
  424. /**
  425. Return the first Protocol Interface that matches the Protocol GUID. If
  426. Registration is passed in return a Protocol Instance that was just add
  427. to the system. If Registration is NULL return the first Protocol Interface
  428. you find.
  429. @param Protocol The protocol to search for
  430. @param Registration Optional Registration Key returned from
  431. RegisterProtocolNotify()
  432. @param Interface Return the Protocol interface (instance).
  433. @retval EFI_SUCCESS If a valid Interface is returned
  434. @retval EFI_INVALID_PARAMETER Invalid parameter
  435. @retval EFI_NOT_FOUND Protocol interface not found
  436. **/
  437. EFI_STATUS
  438. EFIAPI
  439. MmLocateProtocol (
  440. IN EFI_GUID *Protocol,
  441. IN VOID *Registration OPTIONAL,
  442. OUT VOID **Interface
  443. );
  444. /**
  445. Manage MMI of a particular type.
  446. @param HandlerType Points to the handler type or NULL for root MMI handlers.
  447. @param Context Points to an optional context buffer.
  448. @param CommBuffer Points to the optional communication buffer.
  449. @param CommBufferSize Points to the size of the optional communication buffer.
  450. @retval EFI_SUCCESS Interrupt source was processed successfully but not quiesced.
  451. @retval EFI_INTERRUPT_PENDING One or more MMI sources could not be quiesced.
  452. @retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was not handled or quiesced.
  453. @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED Interrupt source was handled and quiesced.
  454. **/
  455. EFI_STATUS
  456. EFIAPI
  457. MmiManage (
  458. IN CONST EFI_GUID *HandlerType,
  459. IN CONST VOID *Context OPTIONAL,
  460. IN OUT VOID *CommBuffer OPTIONAL,
  461. IN OUT UINTN *CommBufferSize OPTIONAL
  462. );
  463. /**
  464. Registers a handler to execute within MM.
  465. @param Handler Handler service function pointer.
  466. @param HandlerType Points to the handler type or NULL for root MMI handlers.
  467. @param DispatchHandle On return, contains a unique handle which can be used to later unregister the handler function.
  468. @retval EFI_SUCCESS Handler register success.
  469. @retval EFI_INVALID_PARAMETER Handler or DispatchHandle is NULL.
  470. **/
  471. EFI_STATUS
  472. EFIAPI
  473. MmiHandlerRegister (
  474. IN EFI_MM_HANDLER_ENTRY_POINT Handler,
  475. IN CONST EFI_GUID *HandlerType OPTIONAL,
  476. OUT EFI_HANDLE *DispatchHandle
  477. );
  478. /**
  479. Unregister a handler in MM.
  480. @param DispatchHandle The handle that was specified when the handler was registered.
  481. @retval EFI_SUCCESS Handler function was successfully unregistered.
  482. @retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle.
  483. **/
  484. EFI_STATUS
  485. EFIAPI
  486. MmiHandlerUnRegister (
  487. IN EFI_HANDLE DispatchHandle
  488. );
  489. /**
  490. This function is the main entry point for an MM handler dispatch
  491. or communicate-based callback.
  492. @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().
  493. @param Context Points to an optional handler context which was specified when the handler was registered.
  494. @param CommBuffer A pointer to a collection of data in memory that will
  495. be conveyed from a non-MM environment into an MM environment.
  496. @param CommBufferSize The size of the CommBuffer.
  497. @return Status Code
  498. **/
  499. EFI_STATUS
  500. EFIAPI
  501. MmDriverDispatchHandler (
  502. IN EFI_HANDLE DispatchHandle,
  503. IN CONST VOID *Context OPTIONAL,
  504. IN OUT VOID *CommBuffer OPTIONAL,
  505. IN OUT UINTN *CommBufferSize OPTIONAL
  506. );
  507. /**
  508. This function is the main entry point for an MM handler dispatch
  509. or communicate-based callback.
  510. @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().
  511. @param Context Points to an optional handler context which was specified when the handler was registered.
  512. @param CommBuffer A pointer to a collection of data in memory that will
  513. be conveyed from a non-MM environment into an MM environment.
  514. @param CommBufferSize The size of the CommBuffer.
  515. @return Status Code
  516. **/
  517. EFI_STATUS
  518. EFIAPI
  519. MmExitBootServiceHandler (
  520. IN EFI_HANDLE DispatchHandle,
  521. IN CONST VOID *Context OPTIONAL,
  522. IN OUT VOID *CommBuffer OPTIONAL,
  523. IN OUT UINTN *CommBufferSize OPTIONAL
  524. );
  525. /**
  526. This function is the main entry point for an MM handler dispatch
  527. or communicate-based callback.
  528. @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().
  529. @param Context Points to an optional handler context which was specified when the handler was registered.
  530. @param CommBuffer A pointer to a collection of data in memory that will
  531. be conveyed from a non-MM environment into an MM environment.
  532. @param CommBufferSize The size of the CommBuffer.
  533. @return Status Code
  534. **/
  535. EFI_STATUS
  536. EFIAPI
  537. MmReadyToBootHandler (
  538. IN EFI_HANDLE DispatchHandle,
  539. IN CONST VOID *Context OPTIONAL,
  540. IN OUT VOID *CommBuffer OPTIONAL,
  541. IN OUT UINTN *CommBufferSize OPTIONAL
  542. );
  543. /**
  544. This function is the main entry point for an MM handler dispatch
  545. or communicate-based callback.
  546. @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().
  547. @param Context Points to an optional handler context which was specified when the handler was registered.
  548. @param CommBuffer A pointer to a collection of data in memory that will
  549. be conveyed from a non-MM environment into an MM environment.
  550. @param CommBufferSize The size of the CommBuffer.
  551. @return Status Code
  552. **/
  553. EFI_STATUS
  554. EFIAPI
  555. MmReadyToLockHandler (
  556. IN EFI_HANDLE DispatchHandle,
  557. IN CONST VOID *Context OPTIONAL,
  558. IN OUT VOID *CommBuffer OPTIONAL,
  559. IN OUT UINTN *CommBufferSize OPTIONAL
  560. );
  561. /**
  562. This function is the main entry point for an MM handler dispatch
  563. or communicate-based callback.
  564. @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().
  565. @param Context Points to an optional handler context which was specified when the handler was registered.
  566. @param CommBuffer A pointer to a collection of data in memory that will
  567. be conveyed from a non-MM environment into an MM environment.
  568. @param CommBufferSize The size of the CommBuffer.
  569. @return Status Code
  570. **/
  571. EFI_STATUS
  572. EFIAPI
  573. MmEndOfDxeHandler (
  574. IN EFI_HANDLE DispatchHandle,
  575. IN CONST VOID *Context OPTIONAL,
  576. IN OUT VOID *CommBuffer OPTIONAL,
  577. IN OUT UINTN *CommBufferSize OPTIONAL
  578. );
  579. /**
  580. Place holder function until all the MM System Table Service are available.
  581. @param Arg1 Undefined
  582. @param Arg2 Undefined
  583. @param Arg3 Undefined
  584. @param Arg4 Undefined
  585. @param Arg5 Undefined
  586. @return EFI_NOT_AVAILABLE_YET
  587. **/
  588. EFI_STATUS
  589. EFIAPI
  590. MmEfiNotAvailableYetArg5 (
  591. UINTN Arg1,
  592. UINTN Arg2,
  593. UINTN Arg3,
  594. UINTN Arg4,
  595. UINTN Arg5
  596. );
  597. //
  598. // Functions used during debug builds
  599. //
  600. /**
  601. Traverse the discovered list for any drivers that were discovered but not loaded
  602. because the dependency expressions evaluated to false.
  603. **/
  604. VOID
  605. MmDisplayDiscoveredNotDispatched (
  606. VOID
  607. );
  608. /**
  609. Add free MMRAM region for use by memory service.
  610. @param MemBase Base address of memory region.
  611. @param MemLength Length of the memory region.
  612. @param Type Memory type.
  613. @param Attributes Memory region state.
  614. **/
  615. VOID
  616. MmAddMemoryRegion (
  617. IN EFI_PHYSICAL_ADDRESS MemBase,
  618. IN UINT64 MemLength,
  619. IN EFI_MEMORY_TYPE Type,
  620. IN UINT64 Attributes
  621. );
  622. /**
  623. Finds the protocol entry for the requested protocol.
  624. @param Protocol The ID of the protocol
  625. @param Create Create a new entry if not found
  626. @return Protocol entry
  627. **/
  628. PROTOCOL_ENTRY *
  629. MmFindProtocolEntry (
  630. IN EFI_GUID *Protocol,
  631. IN BOOLEAN Create
  632. );
  633. /**
  634. Signal event for every protocol in protocol entry.
  635. @param Prot Protocol interface
  636. **/
  637. VOID
  638. MmNotifyProtocol (
  639. IN PROTOCOL_INTERFACE *Prot
  640. );
  641. /**
  642. Finds the protocol instance for the requested handle and protocol.
  643. Note: This function doesn't do parameters checking, it's caller's responsibility
  644. to pass in valid parameters.
  645. @param Handle The handle to search the protocol on
  646. @param Protocol GUID of the protocol
  647. @param Interface The interface for the protocol being searched
  648. @return Protocol instance (NULL: Not found)
  649. **/
  650. PROTOCOL_INTERFACE *
  651. MmFindProtocolInterface (
  652. IN IHANDLE *Handle,
  653. IN EFI_GUID *Protocol,
  654. IN VOID *Interface
  655. );
  656. /**
  657. Removes Protocol from the protocol list (but not the handle list).
  658. @param Handle The handle to remove protocol on.
  659. @param Protocol GUID of the protocol to be moved
  660. @param Interface The interface of the protocol
  661. @return Protocol Entry
  662. **/
  663. PROTOCOL_INTERFACE *
  664. MmRemoveInterfaceFromProtocol (
  665. IN IHANDLE *Handle,
  666. IN EFI_GUID *Protocol,
  667. IN VOID *Interface
  668. );
  669. /**
  670. This is the POSTFIX version of the dependency evaluator. This code does
  671. not need to handle Before or After, as it is not valid to call this
  672. routine in this case. POSTFIX means all the math is done on top of the stack.
  673. @param DriverEntry DriverEntry element to update.
  674. @retval TRUE If driver is ready to run.
  675. @retval FALSE If driver is not ready to run or some fatal error
  676. was found.
  677. **/
  678. BOOLEAN
  679. MmIsSchedulable (
  680. IN EFI_MM_DRIVER_ENTRY *DriverEntry
  681. );
  682. /**
  683. Dump MMRAM information.
  684. **/
  685. VOID
  686. DumpMmramInfo (
  687. VOID
  688. );
  689. extern UINTN mMmramRangeCount;
  690. extern EFI_MMRAM_DESCRIPTOR *mMmramRanges;
  691. extern EFI_SYSTEM_TABLE *mEfiSystemTable;
  692. #endif