]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
MdeModulePkg/SmmIpl: expose MM communicate 2 protocol
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / PiSmmIpl.c
index 20b84eaee2772409d4ea5bc1eb30ea4b525e937b..0385f1d4bdeea037a8daa24e3bc4816bcaa64338 100644 (file)
@@ -10,6 +10,7 @@
 \r
 #include <Protocol/SmmBase2.h>\r
 #include <Protocol/SmmCommunication.h>\r
+#include <Protocol/MmCommunication2.h>\r
 #include <Protocol/SmmAccess2.h>\r
 #include <Protocol/SmmConfiguration.h>\r
 #include <Protocol/SmmControl2.h>\r
@@ -118,6 +119,39 @@ SmmCommunicationCommunicate (
   IN OUT UINTN                             *CommSize OPTIONAL\r
   );\r
 \r
+/**\r
+  Communicates with a registered handler.\r
+\r
+  This function provides a service to send and receive messages from a registered UEFI service.\r
+\r
+  @param[in] This                The EFI_MM_COMMUNICATION_PROTOCOL instance.\r
+  @param[in] CommBufferPhysical  Physical address of the MM communication buffer\r
+  @param[in] CommBufferVirtual   Virtual address of the MM communication buffer\r
+  @param[in] CommSize            The size of the data buffer being passed in. On exit, the size of data\r
+                                 being returned. Zero if the handler does not wish to reply with any data.\r
+                                 This parameter is optional and may be NULL.\r
+\r
+  @retval EFI_SUCCESS            The message was successfully posted.\r
+  @retval EFI_INVALID_PARAMETER  The CommBuffer was NULL.\r
+  @retval EFI_BAD_BUFFER_SIZE    The buffer is too large for the MM implementation.\r
+                                 If this error is returned, the MessageLength field\r
+                                 in the CommBuffer header or the integer pointed by\r
+                                 CommSize, are updated to reflect the maximum payload\r
+                                 size the implementation can accommodate.\r
+  @retval EFI_ACCESS_DENIED      The CommunicateBuffer parameter or CommSize parameter,\r
+                                 if not omitted, are in address range that cannot be\r
+                                 accessed by the MM environment.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmCommunicationMmCommunicate2 (\r
+  IN CONST EFI_MM_COMMUNICATION2_PROTOCOL   *This,\r
+  IN OUT VOID                               *CommBufferPhysical,\r
+  IN OUT VOID                               *CommBufferVirtual,\r
+  IN OUT UINTN                              *CommSize OPTIONAL\r
+  );\r
+\r
 /**\r
   Event notification that is fired every time a gEfiSmmConfigurationProtocol installs.\r
 \r
@@ -240,6 +274,13 @@ EFI_SMM_COMMUNICATION_PROTOCOL  mSmmCommunication = {
   SmmCommunicationCommunicate\r
 };\r
 \r
+//\r
+// PI 1.7 MM Communication Protocol 2 instance\r
+//\r
+EFI_MM_COMMUNICATION2_PROTOCOL  mMmCommunication2 = {\r
+  SmmCommunicationMmCommunicate2\r
+};\r
+\r
 //\r
 // SMM Core Private Data structure that contains the data shared between\r
 // the SMM IPL and the SMM Core.\r
@@ -576,6 +617,44 @@ SmmCommunicationCommunicate (
   return (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;\r
 }\r
 \r
+/**\r
+  Communicates with a registered handler.\r
+\r
+  This function provides a service to send and receive messages from a registered UEFI service.\r
+\r
+  @param[in] This                The EFI_MM_COMMUNICATION_PROTOCOL instance.\r
+  @param[in] CommBufferPhysical  Physical address of the MM communication buffer\r
+  @param[in] CommBufferVirtual   Virtual address of the MM communication buffer\r
+  @param[in] CommSize            The size of the data buffer being passed in. On exit, the size of data\r
+                                 being returned. Zero if the handler does not wish to reply with any data.\r
+                                 This parameter is optional and may be NULL.\r
+\r
+  @retval EFI_SUCCESS            The message was successfully posted.\r
+  @retval EFI_INVALID_PARAMETER  The CommBuffer was NULL.\r
+  @retval EFI_BAD_BUFFER_SIZE    The buffer is too large for the MM implementation.\r
+                                 If this error is returned, the MessageLength field\r
+                                 in the CommBuffer header or the integer pointed by\r
+                                 CommSize, are updated to reflect the maximum payload\r
+                                 size the implementation can accommodate.\r
+  @retval EFI_ACCESS_DENIED      The CommunicateBuffer parameter or CommSize parameter,\r
+                                 if not omitted, are in address range that cannot be\r
+                                 accessed by the MM environment.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmCommunicationMmCommunicate2 (\r
+  IN CONST EFI_MM_COMMUNICATION2_PROTOCOL   *This,\r
+  IN OUT VOID                               *CommBufferPhysical,\r
+  IN OUT VOID                               *CommBufferVirtual,\r
+  IN OUT UINTN                              *CommSize OPTIONAL\r
+  )\r
+{\r
+  return SmmCommunicationCommunicate (&mSmmCommunication,\r
+                                      CommBufferPhysical,\r
+                                      CommSize);\r
+}\r
+\r
 /**\r
   Event notification that is fired when GUIDed Event Group is signaled.\r
 \r
@@ -1758,6 +1837,7 @@ SmmIplEntry (
                   &mSmmIplHandle,\r
                   &gEfiSmmBase2ProtocolGuid,         &mSmmBase2,\r
                   &gEfiSmmCommunicationProtocolGuid, &mSmmCommunication,\r
+                  &gEfiMmCommunication2ProtocolGuid, &mMmCommunication2,\r
                   NULL\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r