From: Jiewen Yao Date: Fri, 22 Apr 2016 07:04:45 +0000 (+0800) Subject: MdeModulePkg: Add new driver to publish EDKII_PI_SMM_COMMUNICATION_REGION_TABLE. X-Git-Tag: edk2-stable201903~7217 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=6e4e6ffda448b77a3b2f3549137aca5c1b62cb4a MdeModulePkg: Add new driver to publish EDKII_PI_SMM_COMMUNICATION_REGION_TABLE. 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 Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao Reviewed-by: Feng, Tian --- diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index c2f5171451..936f46d943 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -448,6 +448,7 @@ MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf + MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.inf [Components.X64] MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf diff --git a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c new file mode 100644 index 0000000000..3ad264b117 --- /dev/null +++ b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c @@ -0,0 +1,99 @@ +/** @file +A driver allocates common SMM communication buffer in EfiReservedMemoryType. + +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. + +Copyright (c) 2016, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEFAULT_COMMON_PI_SMM_COMMUNIATION_REGION_PAGES 4 + +/** + Entry Point for SMM communication buffer driver. + + @param[in] ImageHandle Image handle of this driver. + @param[in] SystemTable A Pointer to the EFI System Table. + + @retval EFI_SUCEESS + @return Others Some error occurs. +**/ +EFI_STATUS +EFIAPI +SmmCommunicationBufferEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + UINT32 DescriptorSize; + EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *PiSmmCommunicationRegionTable; + EFI_MEMORY_DESCRIPTOR *Entry; + + DescriptorSize = sizeof(EFI_MEMORY_DESCRIPTOR); + // + // Make sure Size != sizeof(EFI_MEMORY_DESCRIPTOR). This will + // prevent people from having pointer math bugs in their code. + // now you have to use *DescriptorSize to make things work. + // + DescriptorSize += sizeof(UINT64) - (DescriptorSize % sizeof (UINT64)); + + // + // Allocate and fill PiSmmCommunicationRegionTable + // + PiSmmCommunicationRegionTable = AllocateReservedPool (sizeof(EDKII_PI_SMM_COMMUNICATION_REGION_TABLE) + DescriptorSize); + ASSERT(PiSmmCommunicationRegionTable != NULL); + ZeroMem (PiSmmCommunicationRegionTable, sizeof(EDKII_PI_SMM_COMMUNICATION_REGION_TABLE) + DescriptorSize); + + PiSmmCommunicationRegionTable->Version = EDKII_PI_SMM_COMMUNICATION_REGION_TABLE_VERSION; + PiSmmCommunicationRegionTable->NumberOfEntries = 1; + PiSmmCommunicationRegionTable->DescriptorSize = DescriptorSize; + Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1); + Entry->Type = EfiConventionalMemory; + Entry->PhysicalStart = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateReservedPages (DEFAULT_COMMON_PI_SMM_COMMUNIATION_REGION_PAGES); + ASSERT(Entry->PhysicalStart != 0); + Entry->VirtualStart = 0; + Entry->NumberOfPages = DEFAULT_COMMON_PI_SMM_COMMUNIATION_REGION_PAGES; + Entry->Attribute = 0; + + DEBUG ((EFI_D_INFO, "PiSmmCommunicationRegionTable:(0x%x)\n", PiSmmCommunicationRegionTable)); + DEBUG ((EFI_D_INFO, " Version - 0x%x\n", PiSmmCommunicationRegionTable->Version)); + DEBUG ((EFI_D_INFO, " NumberOfEntries - 0x%x\n", PiSmmCommunicationRegionTable->NumberOfEntries)); + DEBUG ((EFI_D_INFO, " DescriptorSize - 0x%x\n", PiSmmCommunicationRegionTable->DescriptorSize)); + DEBUG ((EFI_D_INFO, "Entry:(0x%x)\n", Entry)); + DEBUG ((EFI_D_INFO, " Type - 0x%x\n", Entry->Type)); + DEBUG ((EFI_D_INFO, " PhysicalStart - 0x%lx\n", Entry->PhysicalStart)); + DEBUG ((EFI_D_INFO, " VirtualStart - 0x%lx\n", Entry->VirtualStart)); + DEBUG ((EFI_D_INFO, " NumberOfPages - 0x%lx\n", Entry->NumberOfPages)); + DEBUG ((EFI_D_INFO, " Attribute - 0x%lx\n", Entry->Attribute)); + + // + // Publish this table, so that other driver can use the buffer. + // + Status = gBS->InstallConfigurationTable (&gEdkiiPiSmmCommunicationRegionTableGuid, PiSmmCommunicationRegionTable); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.inf b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.inf new file mode 100644 index 0000000000..84a2318173 --- /dev/null +++ b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.inf @@ -0,0 +1,62 @@ +## @file +# A driver allocates common SMM communication buffer in EfiReservedMemoryType. +# +# 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. +# +# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = SmmCommunicationBufferDxe + MODULE_UNI_FILE = SmmCommunicationBufferDxe.uni + FILE_GUID = 8FAAD0A7-02B4-432F-8F5C-B880965D8B41 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = SmmCommunicationBufferEntryPoint + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + SmmCommunicationBufferDxe.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + UefiDriverEntryPoint + UefiBootServicesTableLib + UefiRuntimeServicesTableLib + BaseLib + BaseMemoryLib + MemoryAllocationLib + HobLib + DebugLib + PcdLib + +[Guids] + gEdkiiPiSmmCommunicationRegionTableGuid ## PRODUCES ## SystemTable + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + SmmCommunicationBufferExtraDxe.uni diff --git a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.uni b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.uni new file mode 100644 index 0000000000..dfb5579c45 --- /dev/null +++ b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.uni @@ -0,0 +1,24 @@ +// /** @file +// A driver allocates common SMM communication buffer in EfiReservedMemoryType. +// +// 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. +// +// Copyright (c) 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "A driver allocates common SMM communication buffer in EfiReservedMemoryType." + +#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." diff --git a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferExtraDxe.uni b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferExtraDxe.uni new file mode 100644 index 0000000000..14b3a69bf4 --- /dev/null +++ b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferExtraDxe.uni @@ -0,0 +1,18 @@ +// /** @file +// SmmCommunicationBuffer Localized Strings and Content +// +// Copyright (c) 2016, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the BSD License +// which accompanies this distribution. The full text of the license may be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"SMM Communication Buffer DXE Driver"