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: "Tian, Feng" <[email protected]> Cc: "Laszlo Ersek" <[email protected]> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: "Yao, Jiewen" <[email protected]> Reviewed-by: "Tian, Feng" <[email protected]> --- MdeModulePkg/MdeModulePkg.dsc | 1 + .../SmmCommunicationBuffer.c | 99 +++++++++++++++++++++ .../SmmCommunicationBuffer.inf | 62 +++++++++++++ .../SmmCommunicationBuffer.uni | Bin 0 -> 2794 bytes .../SmmCommunicationBufferExtra.uni | Bin 0 -> 1372 bytes 5 files changed, 162 insertions(+) create mode 100644 MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBuffer.c create mode 100644 MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBuffer.inf create mode 100644 MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBuffer.uni create mode 100644 MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBufferExtra.uni diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index c2f5171..8cdcb07 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/SmmCommunicationBuffer/SmmCommunicationBuffer.inf [Components.X64] MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf diff --git a/MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBuffer.c b/MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBuffer.c new file mode 100644 index 0000000..3ad264b --- /dev/null +++ b/MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBuffer.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.<BR> +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 <PiDxe.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/UefiRuntimeServicesTableLib.h> +#include <Library/BaseLib.h> +#include <Library/BaseMemoryLib.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/DebugLib.h> +#include <Library/UefiLib.h> +#include <Library/PcdLib.h> +#include <Guid/PiSmmCommunicationRegionTable.h> + +#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/SmmCommunicationBuffer/SmmCommunicationBuffer.inf b/MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBuffer.inf new file mode 100644 index 0000000..d231af9 --- /dev/null +++ b/MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBuffer.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.<BR> +# +# 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 = SmmCommunicationBuffer + MODULE_UNI_FILE = SmmCommunicationBuffer.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] + SmmCommunicationBuffer.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"] + SmmCommunicationBufferExtra.uni diff --git a/MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBuffer.uni b/MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBuffer.uni new file mode 100644 index 0000000000000000000000000000000000000000..58aafd74d26622f7d7835abc48747fc6c25c44cb GIT binary patch literal 2794 zcmd6p(Qgt#5XR@(#Q$N_zNl%b`rv~x#@1eysD%Jc^{IhE;UYcA0oMNW>hIfSZ-Hvm z#6&{w_I7r5=9_P3cKQD8zz)puJmTl<m0ekGV;k6gyN6V3hdg~Nk$*v6GV7u-wuxQx zHAgl>cFFvj-^2=LZTrA4Nf$`-rGCED>DdBrS4*3@-<Ns+EpJo4<gt&Xfwx@Rt#x>& z%xe|GgtTKLya>(q;oYn7Iyf5<fq2UKcEq!=9*hdRRun<dkwyV06S%ncY)AIy$ed+% zVs%EbFTLD`*eW+PyWaW$y&Laww1Q=bjlO+Go?DZr?X&nAd&=hByeT(B^yIIDAK@O@ z8#Ht5q^ziJ3UcMp46&$k*7KsMR83QUiayj+j8HRiG{nAGij2%Fui9H+(}BOh&&`U~ zYCWb3iPF1qIU-5*nBqu##mSV2)CoiKBuo#${E+dfJ+>$I%=Y-MgGF62=39G8cImBN z39;2!Ib>ZL$(piWvTw!{E5Bwh?8sX7vdUP()2XU`iv9#l@^Ouo$Vz0a3(64r)UVxw zqd?!G9XePj)YY@fkE{rdL#oWEUWH6-NBi2{_c~oVwTs@Ecc=*GYe%cfaYQ0sRLP1p zS`jj3QN0lO(dvY1PWz6i%VXy6*RUimZaf#4yk&Pi+8m#;qvGkHaSoE)XFd8=UK~}e z9(4F$5RY;s)L(gTqFQGru&IjgE%#5B90=2Vg;~|koT_;4Pgqq|U|0I3=ep)AX2|-w zj~S94*!#A>u~Ngzh$nIqN5%7&9(Qzi%NlfQi`vuKT!&K!s~S5<>r~nqUzun6%uX3I z<jF$HLY>Oa&}e(h4Zc*-dhamGuB`4b9{IUut0&+&>%!IW9-W<|)$+(rk=L;*8x8Nh z#Z1^Glg|#i(vjDob%L(Ee`0*cijb=lv!$01MP?r>JIQ(-E}GPpd>*fyUx`26j0c`q z$#$#C2^|!;yTD3={byLp>;g36N~|8jR0k}-`t6cOb%M_AE^k$ys$m~nLMc8s&&}<) ze|P?p6ID|iHdJZNDuX}c<@cPVvv2)I*#>4*dEvY(`1)Tryzb3^d$VuTjsEBVENgU- G`t}F0BGF|4 literal 0 HcmV?d00001 diff --git a/MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBufferExtra.uni b/MdeModulePkg/Universal/SmmCommunicationBuffer/SmmCommunicationBufferExtra.uni new file mode 100644 index 0000000000000000000000000000000000000000..55752a00caf49e35411a64f21653671a5cfaf25a GIT binary patch literal 1372 zcmZXUNsrS&5QXcE#DB2D1<*_a95^6^NQeQ8$)YR*PNVE&DVv<kK=|>%_o}^wAj_`q zs_Iv-U$y(s?}jxj;(g8&*?U`BYHM5AV|#>Gv7v2vKG@Ffy=}>u*~E_69kZ6*vueqj zjO-hHimr+N!Z&w>Be9g+l^vK*7|AcpEjSDR78MH{;(I&!+Lhgr8QD|NpJ89w3wvp= z?TT@dqpWkx%=RE>XB_K9ns8Evm;^L&$*6vC?hnqkZg1Jqz}}S#RD4EoNPP!;*6l!1 zjSVQpj*et3d_IGx6x)03l<z*mBju!3%4iK*g+FmNk!v?2XY0(QRDrM6^Sr_XWA$oc zQ@*OI-YBX*6ih;`jk7LL#7vnfS)qqgVn+|FbuIedW`09P#iio<!?l?46}x|To5Dee z;t=#wtpjuIdJ4~?uKE(0bQS+4k<cTt{z=v)E1jx}O;Gbh)-+$g%QX<E<C(HLJ4br) z#?SPQQBYU;nIqQOe?~_e7wRAIOyNGa>x)Polsn!+lfr60pDl(}pL5i+Pkfu!VV<CA zgsQS5ya^|5%qVuH$JWKh_$!2}3kiQqOvccWdyI6V^{rurE7Tgc<#WxhN^X&TB`#h) zuc&#GN@CW<pMWZio>w0*6L<Mkb3~SMR5fIMBv&iHW4{m)bNz{NUM1`zwr?d)g`S{A zpL3;}ZL60YEB$mAHQX=Xlk()~{?L6S?QU~*`=AWU9o&N519c33OimY;9Yz61|B5i~ su`53@ItABc4?UxX?eK(~N4MVpx1IDozwg@YQN3>a+14GB(FN7}3omol@c;k- literal 0 HcmV?d00001 -- 2.7.4.windows.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

