MdeModulePkg: Add new driver to publish EDKII_PI_SMM_COMMUNICATION_REGION_TABLE.
authorJiewen Yao <jiewen.yao@intel.com>
Fri, 22 Apr 2016 07:04:45 +0000 (15:04 +0800)
committerJiewen Yao <jiewen.yao@intel.com>
Fri, 29 Apr 2016 04:49:09 +0000 (12:49 +0800)
Add a driver to publish EDKII_PI_SMM_COMMUNICATION_REGION_TABLE, so that
other DXE driver can consume this table directly. NOTE: This is sample driver.
A platform may uses its own way to define default SMM communication buffer
region and publish information in its own
EDKII_PI_SMM_COMMUNICATION_REGION_TABLE.

This is designed to meet Microsoft WSMT table definition on FIXED_COMM_BUFFERS
requirement.

Cc: Feng Tian <feng.tian@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Feng, Tian <feng.tian@intel.com>
MdeModulePkg/MdeModulePkg.dsc
MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c [new file with mode: 0644]
MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.inf [new file with mode: 0644]
MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.uni [new file with mode: 0644]
MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferExtraDxe.uni [new file with mode: 0644]

index c2f51714511bad979a0a11c6b3df8f9e7288d013..936f46d94358b916d39e06328d37c159a4b532a9 100644 (file)
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf\r
   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf\r
   MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf\r
+  MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.inf\r
 \r
 [Components.X64]\r
   MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf\r
diff --git a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c
new file mode 100644 (file)
index 0000000..3ad264b
--- /dev/null
@@ -0,0 +1,99 @@
+/** @file\r
+A driver allocates common SMM communication buffer in EfiReservedMemoryType.\r
+\r
+This driver allocates common SMM communication buffer in EfiReservedMemoryType,\r
+then it publishes the information to EFI configuration table with\r
+gEdkiiPiSmmCommunicationRegionTableGuid.\r
+Any other driver or application can get the table and know the common\r
+communication buffer.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Guid/PiSmmCommunicationRegionTable.h>\r
+\r
+#define DEFAULT_COMMON_PI_SMM_COMMUNIATION_REGION_PAGES  4\r
+\r
+/**\r
+  Entry Point for SMM communication buffer driver.\r
+\r
+  @param[in] ImageHandle  Image handle of this driver.\r
+  @param[in] SystemTable  A Pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCEESS\r
+  @return Others          Some error occurs.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmCommunicationBufferEntryPoint (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS                               Status;\r
+  UINT32                                   DescriptorSize;\r
+  EDKII_PI_SMM_COMMUNICATION_REGION_TABLE  *PiSmmCommunicationRegionTable;\r
+  EFI_MEMORY_DESCRIPTOR                    *Entry;\r
+\r
+  DescriptorSize = sizeof(EFI_MEMORY_DESCRIPTOR);\r
+  //\r
+  // Make sure Size != sizeof(EFI_MEMORY_DESCRIPTOR). This will\r
+  // prevent people from having pointer math bugs in their code.\r
+  // now you have to use *DescriptorSize to make things work.\r
+  //\r
+  DescriptorSize += sizeof(UINT64) - (DescriptorSize % sizeof (UINT64));\r
+\r
+  //\r
+  // Allocate and fill PiSmmCommunicationRegionTable\r
+  //\r
+  PiSmmCommunicationRegionTable = AllocateReservedPool (sizeof(EDKII_PI_SMM_COMMUNICATION_REGION_TABLE) + DescriptorSize);\r
+  ASSERT(PiSmmCommunicationRegionTable != NULL);\r
+  ZeroMem (PiSmmCommunicationRegionTable, sizeof(EDKII_PI_SMM_COMMUNICATION_REGION_TABLE) + DescriptorSize);\r
+\r
+  PiSmmCommunicationRegionTable->Version         = EDKII_PI_SMM_COMMUNICATION_REGION_TABLE_VERSION;\r
+  PiSmmCommunicationRegionTable->NumberOfEntries = 1;\r
+  PiSmmCommunicationRegionTable->DescriptorSize  = DescriptorSize;\r
+  Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);\r
+  Entry->Type          = EfiConventionalMemory;\r
+  Entry->PhysicalStart = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateReservedPages (DEFAULT_COMMON_PI_SMM_COMMUNIATION_REGION_PAGES);\r
+  ASSERT(Entry->PhysicalStart != 0);\r
+  Entry->VirtualStart  = 0;\r
+  Entry->NumberOfPages = DEFAULT_COMMON_PI_SMM_COMMUNIATION_REGION_PAGES;\r
+  Entry->Attribute     = 0;\r
+\r
+  DEBUG ((EFI_D_INFO, "PiSmmCommunicationRegionTable:(0x%x)\n", PiSmmCommunicationRegionTable));\r
+  DEBUG ((EFI_D_INFO, "  Version         - 0x%x\n", PiSmmCommunicationRegionTable->Version));\r
+  DEBUG ((EFI_D_INFO, "  NumberOfEntries - 0x%x\n", PiSmmCommunicationRegionTable->NumberOfEntries));\r
+  DEBUG ((EFI_D_INFO, "  DescriptorSize  - 0x%x\n", PiSmmCommunicationRegionTable->DescriptorSize));\r
+  DEBUG ((EFI_D_INFO, "Entry:(0x%x)\n", Entry));\r
+  DEBUG ((EFI_D_INFO, "  Type            - 0x%x\n", Entry->Type));\r
+  DEBUG ((EFI_D_INFO, "  PhysicalStart   - 0x%lx\n", Entry->PhysicalStart));\r
+  DEBUG ((EFI_D_INFO, "  VirtualStart    - 0x%lx\n", Entry->VirtualStart));\r
+  DEBUG ((EFI_D_INFO, "  NumberOfPages   - 0x%lx\n", Entry->NumberOfPages));\r
+  DEBUG ((EFI_D_INFO, "  Attribute       - 0x%lx\n", Entry->Attribute));\r
+\r
+  //\r
+  // Publish this table, so that other driver can use the buffer.\r
+  //\r
+  Status = gBS->InstallConfigurationTable (&gEdkiiPiSmmCommunicationRegionTableGuid, PiSmmCommunicationRegionTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
diff --git a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.inf b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.inf
new file mode 100644 (file)
index 0000000..84a2318
--- /dev/null
@@ -0,0 +1,62 @@
+## @file\r
+# A driver allocates common SMM communication buffer in EfiReservedMemoryType.\r
+#\r
+# This driver allocates common SMM communication buffer in EfiReservedMemoryType,\r
+# then it publishes the information to EFI configuration table with\r
+# gEdkiiPiSmmCommunicationRegionTableGuid.\r
+# Any other driver or application can get the table and know the common\r
+# communication buffer.\r
+#\r
+# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+#\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = SmmCommunicationBufferDxe\r
+  MODULE_UNI_FILE                = SmmCommunicationBufferDxe.uni\r
+  FILE_GUID                      = 8FAAD0A7-02B4-432F-8F5C-B880965D8B41\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  ENTRY_POINT                    = SmmCommunicationBufferEntryPoint\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources]\r
+  SmmCommunicationBufferDxe.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  UefiDriverEntryPoint\r
+  UefiBootServicesTableLib\r
+  UefiRuntimeServicesTableLib\r
+  BaseLib\r
+  BaseMemoryLib\r
+  MemoryAllocationLib\r
+  HobLib\r
+  DebugLib\r
+  PcdLib\r
+\r
+[Guids]\r
+  gEdkiiPiSmmCommunicationRegionTableGuid     ## PRODUCES   ## SystemTable\r
+\r
+[Depex]\r
+  TRUE\r
+\r
+[UserExtensions.TianoCore."ExtraFiles"]\r
+  SmmCommunicationBufferExtraDxe.uni\r
diff --git a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.uni b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.uni
new file mode 100644 (file)
index 0000000..dfb5579
--- /dev/null
@@ -0,0 +1,24 @@
+// /** @file\r
+// A driver allocates common SMM communication buffer in EfiReservedMemoryType.\r
+//\r
+// This driver allocates common SMM communication buffer in EfiReservedMemoryType,\r
+// then it publishes the information to EFI configuration table with\r
+// gEdkiiPiSmmCommunicationRegionTableGuid.\r
+// Any other driver or application can get the table and know the common\r
+// communication buffer.\r
+//\r
+// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+//\r
+// This program and the accompanying materials\r
+// are licensed and made available under the terms and conditions of the BSD License\r
+// which accompanies this distribution.  The full text of the license may be found at\r
+// http://opensource.org/licenses/bsd-license.php\r
+//\r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+// **/\r
+\r
+#string STR_MODULE_ABSTRACT             #language en-US "A driver allocates common SMM communication buffer in EfiReservedMemoryType."\r
+\r
+#string STR_MODULE_DESCRIPTION          #language en-US "This driver allocates common SMM communication buffer in EfiReservedMemoryType, then it publishes the information to EFI configuration table with gEdkiiPiSmmCommunicationRegionTableGuid. Any other driver or application can get the table and know the common communication buffer."\r
diff --git a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferExtraDxe.uni b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferExtraDxe.uni
new file mode 100644 (file)
index 0000000..14b3a69
--- /dev/null
@@ -0,0 +1,18 @@
+// /** @file\r
+// SmmCommunicationBuffer Localized Strings and Content\r
+//\r
+// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+//\r
+// This program and the accompanying materials\r
+// are licensed and made available under the terms and conditions of the BSD License\r
+// which accompanies this distribution.  The full text of the license may be found at\r
+// http://opensource.org/licenses/bsd-license.php\r
+//\r
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+// **/\r
+\r
+#string STR_PROPERTIES_MODULE_NAME\r
+#language en-US\r
+"SMM Communication Buffer DXE Driver"\r