From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by mx.groups.io with SMTP id smtpd.web09.1426.1610046347851203882 for ; Thu, 07 Jan 2021 11:05:48 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=L2rky+VA; spf=pass (domain: nuviainc.com, ip: 209.85.221.44, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f44.google.com with SMTP id y17so6670590wrr.10 for ; Thu, 07 Jan 2021 11:05:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Zxqmvwzj83XFZbci7HLZP77EueyoFseiUXlWMWJ5AvM=; b=L2rky+VAfsBKmhZTmZdrU1ZYOK/A48GHWOtpGJkOfDwXo5x5qyyg+YSdopoepDEJJa lrSBOZ+gGn4ACFT9vJXksy1jA+/ZLdl8EVREfXijKSw70YYa9lNXSst4jGRY3Ld4aPo1 EDcrjY0Ciz7RiB77Af7rMlzMz61Bre8HSr2T+DpZ+nGmTOLHyOUolBVKMCcDOKKEuY1r y3qPniKLgUS5KUjLjftS6UCloDyo+16lQUmSOzHBLroB2VzvTOEZ3HVHqLgCNZxUuAU2 wx1VthsZ3ux2+vitIjyfh9G7uOGq7nD90p13PCQMEEXR5Km70bPIpcDOf+YV8MkOSVNp pVvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Zxqmvwzj83XFZbci7HLZP77EueyoFseiUXlWMWJ5AvM=; b=KTvMDpcKQj2TiwX9cQyPn9OSrxrsTF6a//hMAY0s4PxBV2cVKrB1yDnS9FkNr+OC1A mczjbnqxmd44Sr2oBPAUjfA3x2K9lYilmCDnph9rO5SQ4DmnBFkJG30lN55zYJyVhtdv ojmvpiPdz0axCkum/G8iM3GYs10A5acS/zniXcXPkRCLsu4vhvyYC2D7Th+vg6G88irt KvycNO4dnAa9ijd0e/h2wtF68pxcRCnwZRRC9u2X2YmjxJ08aN+5kRPn62VdAC4c4OF7 nqCN0d+WwVAeHNuPYC82fHxMdSA7fR8sU0vulIXbXcaF2W5K6gBhm7IkloBA2JNwo60w f76w== X-Gm-Message-State: AOAM533kLj8fmRMW0dJ7Ntj9TAjm4javO8udBRt6rM0t+HQibQr+ezbC 4hVOahKhGsGO+04wHQ1A1OyRGA== X-Google-Smtp-Source: ABdhPJzpMSDSP3GKoYp5SytLA1TNMqt45vcVCFrePGU5DZmKXIYGSzFBekvjjt4gyabWpxAW3h5DMg== X-Received: by 2002:adf:fc48:: with SMTP id e8mr93692wrs.11.1610046346352; Thu, 07 Jan 2021 11:05:46 -0800 (PST) Return-Path: Received: from vanye (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id w18sm9584851wrn.2.2021.01.07.11.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 11:05:45 -0800 (PST) Date: Thu, 7 Jan 2021 19:05:43 +0000 From: "Leif Lindholm" To: Laszlo Ersek Cc: Kun Qin , devel@edk2.groups.io, Eric Dong , Ray Ni , Rahul Kumar , Michael Kinney , "Ard Biesheuvel (ARM address)" Subject: Re: [PATCH v2 15/16] UefiCpuPkg: CpuIo2Smm: Support of CpuIo driver under StandaloneMm Message-ID: <20210107190543.GH1664@vanye> References: <20210105185935.3769-1-kun.q@outlook.com> <1009ae23-a2ea-cac2-2df6-db9b76c4ef15@redhat.com> MIME-Version: 1.0 In-Reply-To: <1009ae23-a2ea-cac2-2df6-db9b76c4ef15@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Jan 06, 2021 at 16:46:57 +0100, Laszlo Ersek wrote: > On 01/05/21 19:59, Kun Qin wrote: > > This change added support of CpuIo driver under StandaloneMm. The core > > services switched to gMmst based instead of gMmst. It also abstracts > > (1) typo: "gMmst based instead of gMmst" -- that's the same thing > > (2) renames like this should not be mixed with logic changes / > refactorings, so this would be two patches minimally > > (3) in fact I disagree with renaming gSmst to gMmst (and the resultant > fallout). I see very little value in this, it only complicates the git > history, takes up reviewer resources, and risks regressions. Unless > absolutely necessary for getting the driver build in the new context, I > would strongly advise against the rename. If the rename is unavoidable, > then see (2) please -- do it in a separate patch. > > (4) If I understand correctly, this is the first time when UefiCpuPkg > content is consumed in AARCH64 platforms. I wonder if that means that > the CpuIo2Smm should no longer exist under UefiCpuPkg at all. UefiCpuPkg > has been traditionally IA32/X64 only, and while the *name* of the > package certainly does not require or imply that, over time those two > things *have* become synonymous. For example, the SMM Core lives under > MdeModulePkg; I wonder if the same should happen to CpuIo2Smm as well. > Adding Ard, Leif and Mike. I don't really have an opinion of CpuIo2Smm (but I guess it makes sense to move it if the SMM core lives in MdeModulePkg). I do think most of ArmPkg ultimately belongs under UefiCpuPkg, with the rest under MdeModulePkg. Best Regards, Leif > Thanks > Laszlo > > > standalone and traditional MM driver entrypoints into separate files to > > allow maximal common implementations. > > > > Cc: Eric Dong > > Cc: Ray Ni > > Cc: Laszlo Ersek > > Cc: Rahul Kumar > > > > Signed-off-by: Kun Qin > > --- > > > > Notes: > > v2: > > - Removed "EFIAPI" for internal functions. > > > > UefiCpuPkg/CpuIo2Smm/{CpuIo2Smm.c => CpuIo2Common.c} | 15 +- > > UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c | 384 +------------------- > > UefiCpuPkg/CpuIo2Smm/CpuIo2StandaloneMm.c | 31 ++ > > UefiCpuPkg/CpuIo2Smm/{CpuIo2Smm.h => CpuIo2Common.h} | 17 +- > > UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf | 7 +- > > UefiCpuPkg/CpuIo2Smm/{CpuIo2Smm.inf => CpuIo2StandaloneMm.inf} | 23 +- > > UefiCpuPkg/UefiCpuPkg.dsc | 6 + > > 7 files changed, 75 insertions(+), 408 deletions(-) > > > > diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c b/UefiCpuPkg/CpuIo2Smm/CpuIo2Common.c > > similarity index 94% > > copy from UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c > > copy to UefiCpuPkg/CpuIo2Smm/CpuIo2Common.c > > index b840d3e10cae..fef434795908 100644 > > --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c > > +++ b/UefiCpuPkg/CpuIo2Smm/CpuIo2Common.c > > @@ -6,7 +6,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > > > -#include "CpuIo2Smm.h" > > +#include "CpuIo2Common.h" > > > > // > > // Handle for the SMM CPU I/O Protocol > > @@ -371,18 +371,13 @@ CpuIoServiceWrite ( > > /** > > The module Entry Point SmmCpuIoProtocol driver > > > > - @param[in] ImageHandle The firmware allocated handle for the EFI image. > > - @param[in] SystemTable A pointer to the EFI System Table. > > - > > @retval EFI_SUCCESS The entry point is executed successfully. > > @retval Other Some error occurs when executing this entry point. > > > > **/ > > EFI_STATUS > > -EFIAPI > > -SmmCpuIo2Initialize ( > > - IN EFI_HANDLE ImageHandle, > > - IN EFI_SYSTEM_TABLE *SystemTable > > +CommonCpuIo2Initialize ( > > + VOID > > ) > > { > > EFI_STATUS Status; > > @@ -390,12 +385,12 @@ SmmCpuIo2Initialize ( > > // > > // Copy the SMM CPU I/O Protocol instance into the System Management System Table > > // > > - CopyMem (&gSmst->SmmIo, &mSmmCpuIo2, sizeof (mSmmCpuIo2)); > > + CopyMem (&gMmst->MmIo, &mSmmCpuIo2, sizeof (mSmmCpuIo2)); > > > > // > > // Install the SMM CPU I/O Protocol into the SMM protocol database > > // > > - Status = gSmst->SmmInstallProtocolInterface ( > > + Status = gMmst->MmInstallProtocolInterface ( > > &mHandle, > > &gEfiSmmCpuIo2ProtocolGuid, > > EFI_NATIVE_INTERFACE, > > diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c b/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c > > index b840d3e10cae..062d1a47a09f 100644 > > --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c > > +++ b/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c > > @@ -6,367 +6,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > > > -#include "CpuIo2Smm.h" > > +#include > > > > -// > > -// Handle for the SMM CPU I/O Protocol > > -// > > -EFI_HANDLE mHandle = NULL; > > - > > -// > > -// SMM CPU I/O Protocol instance > > -// > > -EFI_SMM_CPU_IO2_PROTOCOL mSmmCpuIo2 = { > > - { > > - CpuMemoryServiceRead, > > - CpuMemoryServiceWrite > > - }, > > - { > > - CpuIoServiceRead, > > - CpuIoServiceWrite > > - } > > -}; > > - > > -// > > -// Lookup table for increment values based on transfer widths > > -// > > -UINT8 mStride[] = { > > - 1, // SMM_IO_UINT8 > > - 2, // SMM_IO_UINT16 > > - 4, // SMM_IO_UINT32 > > - 8 // SMM_IO_UINT64 > > -}; > > - > > -/** > > - Check parameters to a SMM CPU I/O Protocol service request. > > - > > - @param[in] MmioOperation TRUE for an MMIO operation, FALSE for I/O Port operation. > > - @param[in] Width Signifies the width of the I/O operations. > > - @param[in] Address The base address of the I/O operations. The caller is > > - responsible for aligning the Address if required. > > - @param[in] Count The number of I/O operations to perform. > > - @param[in] Buffer For read operations, the destination buffer to store > > - the results. For write operations, the source buffer > > - from which to write data. > > - > > - @retval EFI_SUCCESS The data was read from or written to the device. > > - @retval EFI_UNSUPPORTED The Address is not valid for this system. > > - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. > > - > > -**/ > > -EFI_STATUS > > -CpuIoCheckParameter ( > > - IN BOOLEAN MmioOperation, > > - IN EFI_SMM_IO_WIDTH Width, > > - IN UINT64 Address, > > - IN UINTN Count, > > - IN VOID *Buffer > > - ) > > -{ > > - UINT64 MaxCount; > > - UINT64 Limit; > > - > > - // > > - // Check to see if Buffer is NULL > > - // > > - if (Buffer == NULL) { > > - return EFI_INVALID_PARAMETER; > > - } > > - > > - // > > - // Check to see if Width is in the valid range > > - // > > - if ((UINT32)Width > SMM_IO_UINT64) { > > - return EFI_INVALID_PARAMETER; > > - } > > - > > - // > > - // Check to see if Width is in the valid range for I/O Port operations > > - // > > - if (!MmioOperation && (Width == SMM_IO_UINT64)) { > > - return EFI_INVALID_PARAMETER; > > - } > > - > > - // > > - // Check to see if any address associated with this transfer exceeds the maximum > > - // allowed address. The maximum address implied by the parameters passed in is > > - // Address + Size * Count. If the following condition is met, then the transfer > > - // is not supported. > > - // > > - // Address + Size * Count > (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS) + 1 > > - // > > - // Since MAX_ADDRESS can be the maximum integer value supported by the CPU and Count > > - // can also be the maximum integer value supported by the CPU, this range > > - // check must be adjusted to avoid all overflow conditions. > > - // > > - // The following form of the range check is equivalent but assumes that > > - // MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1). > > - // > > - Limit = (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS); > > - if (Count == 0) { > > - if (Address > Limit) { > > - return EFI_UNSUPPORTED; > > - } > > - } else { > > - MaxCount = RShiftU64 (Limit, Width); > > - if (MaxCount < (Count - 1)) { > > - return EFI_UNSUPPORTED; > > - } > > - if (Address > LShiftU64 (MaxCount - Count + 1, Width)) { > > - return EFI_UNSUPPORTED; > > - } > > - } > > - > > - // > > - // Check to see if Address is aligned > > - // > > - if ((Address & ((UINT64)mStride[Width] - 1)) != 0) { > > - return EFI_UNSUPPORTED; > > - } > > - > > - return EFI_SUCCESS; > > -} > > - > > -/** > > - Reads memory-mapped registers. > > - > > - The I/O operations are carried out exactly as requested. The caller is > > - responsible for any alignment and I/O width issues that the bus, device, > > - platform, or type of I/O might require. > > - > > - @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. > > - @param[in] Width Signifies the width of the I/O operations. > > - @param[in] Address The base address of the I/O operations. The caller is > > - responsible for aligning the Address if required. > > - @param[in] Count The number of I/O operations to perform. > > - @param[out] Buffer For read operations, the destination buffer to store > > - the results. For write operations, the source buffer > > - from which to write data. > > - > > - @retval EFI_SUCCESS The data was read from or written to the device. > > - @retval EFI_UNSUPPORTED The Address is not valid for this system. > > - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. > > - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a > > - lack of resources > > - > > -**/ > > -EFI_STATUS > > -EFIAPI > > -CpuMemoryServiceRead ( > > - IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, > > - IN EFI_SMM_IO_WIDTH Width, > > - IN UINT64 Address, > > - IN UINTN Count, > > - OUT VOID *Buffer > > - ) > > -{ > > - EFI_STATUS Status; > > - UINT8 Stride; > > - UINT8 *Uint8Buffer; > > - > > - Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); > > - if (EFI_ERROR (Status)) { > > - return Status; > > - } > > - > > - // > > - // Select loop based on the width of the transfer > > - // > > - Stride = mStride[Width]; > > - for (Uint8Buffer = Buffer; Count > 0; Address += Stride, Uint8Buffer += Stride, Count--) { > > - if (Width == SMM_IO_UINT8) { > > - *Uint8Buffer = MmioRead8 ((UINTN)Address); > > - } else if (Width == SMM_IO_UINT16) { > > - *((UINT16 *)Uint8Buffer) = MmioRead16 ((UINTN)Address); > > - } else if (Width == SMM_IO_UINT32) { > > - *((UINT32 *)Uint8Buffer) = MmioRead32 ((UINTN)Address); > > - } else if (Width == SMM_IO_UINT64) { > > - *((UINT64 *)Uint8Buffer) = MmioRead64 ((UINTN)Address); > > - } > > - } > > - return EFI_SUCCESS; > > -} > > - > > -/** > > - Writes memory-mapped registers. > > - > > - The I/O operations are carried out exactly as requested. The caller is > > - responsible for any alignment and I/O width issues that the bus, device, > > - platform, or type of I/O might require. > > - > > - @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. > > - @param[in] Width Signifies the width of the I/O operations. > > - @param[in] Address The base address of the I/O operations. The caller is > > - responsible for aligning the Address if required. > > - @param[in] Count The number of I/O operations to perform. > > - @param[in] Buffer For read operations, the destination buffer to store > > - the results. For write operations, the source buffer > > - from which to write data. > > - > > - @retval EFI_SUCCESS The data was read from or written to the device. > > - @retval EFI_UNSUPPORTED The Address is not valid for this system. > > - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. > > - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a > > - lack of resources > > - > > -**/ > > -EFI_STATUS > > -EFIAPI > > -CpuMemoryServiceWrite ( > > - IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, > > - IN EFI_SMM_IO_WIDTH Width, > > - IN UINT64 Address, > > - IN UINTN Count, > > - IN VOID *Buffer > > - ) > > -{ > > - EFI_STATUS Status; > > - UINT8 Stride; > > - UINT8 *Uint8Buffer; > > - > > - Status = CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); > > - if (EFI_ERROR (Status)) { > > - return Status; > > - } > > - > > - // > > - // Select loop based on the width of the transfer > > - // > > - Stride = mStride[Width]; > > - for (Uint8Buffer = Buffer; Count > 0; Address += Stride, Uint8Buffer += Stride, Count--) { > > - if (Width == SMM_IO_UINT8) { > > - MmioWrite8 ((UINTN)Address, *Uint8Buffer); > > - } else if (Width == SMM_IO_UINT16) { > > - MmioWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); > > - } else if (Width == SMM_IO_UINT32) { > > - MmioWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); > > - } else if (Width == SMM_IO_UINT64) { > > - MmioWrite64 ((UINTN)Address, *((UINT64 *)Uint8Buffer)); > > - } > > - } > > - return EFI_SUCCESS; > > -} > > - > > -/** > > - Reads I/O registers. > > - > > - The I/O operations are carried out exactly as requested. The caller is > > - responsible for any alignment and I/O width issues that the bus, device, > > - platform, or type of I/O might require. > > - > > - @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. > > - @param[in] Width Signifies the width of the I/O operations. > > - @param[in] Address The base address of the I/O operations. The caller is > > - responsible for aligning the Address if required. > > - @param[in] Count The number of I/O operations to perform. > > - @param[out] Buffer For read operations, the destination buffer to store > > - the results. For write operations, the source buffer > > - from which to write data. > > - > > - @retval EFI_SUCCESS The data was read from or written to the device. > > - @retval EFI_UNSUPPORTED The Address is not valid for this system. > > - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. > > - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a > > - lack of resources > > - > > -**/ > > -EFI_STATUS > > -EFIAPI > > -CpuIoServiceRead ( > > - IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, > > - IN EFI_SMM_IO_WIDTH Width, > > - IN UINT64 Address, > > - IN UINTN Count, > > - OUT VOID *Buffer > > - ) > > -{ > > - EFI_STATUS Status; > > - UINT8 Stride; > > - UINT8 *Uint8Buffer; > > - > > - Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); > > - if (EFI_ERROR (Status)) { > > - return Status; > > - } > > - > > - // > > - // Select loop based on the width of the transfer > > - // > > - Stride = mStride[Width]; > > - for (Uint8Buffer = Buffer; Count > 0; Address += Stride, Uint8Buffer += Stride, Count--) { > > - if (Width == SMM_IO_UINT8) { > > - *Uint8Buffer = IoRead8 ((UINTN)Address); > > - } else if (Width == SMM_IO_UINT16) { > > - *((UINT16 *)Uint8Buffer) = IoRead16 ((UINTN)Address); > > - } else if (Width == SMM_IO_UINT32) { > > - *((UINT32 *)Uint8Buffer) = IoRead32 ((UINTN)Address); > > - } > > - } > > - > > - return EFI_SUCCESS; > > -} > > - > > -/** > > - Write I/O registers. > > - > > - The I/O operations are carried out exactly as requested. The caller is > > - responsible for any alignment and I/O width issues that the bus, device, > > - platform, or type of I/O might require. > > - > > - @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance. > > - @param[in] Width Signifies the width of the I/O operations. > > - @param[in] Address The base address of the I/O operations. The caller is > > - responsible for aligning the Address if required. > > - @param[in] Count The number of I/O operations to perform. > > - @param[in] Buffer For read operations, the destination buffer to store > > - the results. For write operations, the source buffer > > - from which to write data. > > - > > - @retval EFI_SUCCESS The data was read from or written to the device. > > - @retval EFI_UNSUPPORTED The Address is not valid for this system. > > - @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid. > > - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a > > - lack of resources > > - > > -**/ > > -EFI_STATUS > > -EFIAPI > > -CpuIoServiceWrite ( > > - IN CONST EFI_SMM_CPU_IO2_PROTOCOL *This, > > - IN EFI_SMM_IO_WIDTH Width, > > - IN UINT64 Address, > > - IN UINTN Count, > > - IN VOID *Buffer > > - ) > > -{ > > - EFI_STATUS Status; > > - UINT8 Stride; > > - UINT8 *Uint8Buffer; > > - > > - // > > - // Make sure the parameters are valid > > - // > > - Status = CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); > > - if (EFI_ERROR (Status)) { > > - return Status; > > - } > > - > > - // > > - // Select loop based on the width of the transfer > > - // > > - Stride = mStride[Width]; > > - for (Uint8Buffer = (UINT8 *)Buffer; Count > 0; Address += Stride, Uint8Buffer += Stride, Count--) { > > - if (Width == SMM_IO_UINT8) { > > - IoWrite8 ((UINTN)Address, *Uint8Buffer); > > - } else if (Width == SMM_IO_UINT16) { > > - IoWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); > > - } else if (Width == SMM_IO_UINT32) { > > - IoWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); > > - } > > - } > > - > > - return EFI_SUCCESS; > > -} > > +#include "CpuIo2Common.h" > > > > /** > > The module Entry Point SmmCpuIoProtocol driver > > @@ -380,28 +22,10 @@ CpuIoServiceWrite ( > > **/ > > EFI_STATUS > > EFIAPI > > -SmmCpuIo2Initialize ( > > +TraditionalMmCpuIo2Initialize ( > > IN EFI_HANDLE ImageHandle, > > IN EFI_SYSTEM_TABLE *SystemTable > > ) > > { > > - EFI_STATUS Status; > > - > > - // > > - // Copy the SMM CPU I/O Protocol instance into the System Management System Table > > - // > > - CopyMem (&gSmst->SmmIo, &mSmmCpuIo2, sizeof (mSmmCpuIo2)); > > - > > - // > > - // Install the SMM CPU I/O Protocol into the SMM protocol database > > - // > > - Status = gSmst->SmmInstallProtocolInterface ( > > - &mHandle, > > - &gEfiSmmCpuIo2ProtocolGuid, > > - EFI_NATIVE_INTERFACE, > > - &mSmmCpuIo2 > > - ); > > - ASSERT_EFI_ERROR (Status); > > - > > - return Status; > > + return CommonCpuIo2Initialize (); > > } > > diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2StandaloneMm.c b/UefiCpuPkg/CpuIo2Smm/CpuIo2StandaloneMm.c > > new file mode 100644 > > index 000000000000..2978f82eb815 > > --- /dev/null > > +++ b/UefiCpuPkg/CpuIo2Smm/CpuIo2StandaloneMm.c > > @@ -0,0 +1,31 @@ > > +/** @file > > + Produces the SMM CPU I/O Protocol. > > + > > +Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
> > +SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#include > > + > > +#include "CpuIo2Common.h" > > + > > +/** > > + The module Entry Point SmmCpuIoProtocol driver > > + > > + @param[in] ImageHandle The firmware allocated handle for the EFI image. > > + @param[in] SystemTable A pointer to the EFI System Table. > > + > > + @retval EFI_SUCCESS The entry point is executed successfully. > > + @retval Other Some error occurs when executing this entry point. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +StandaloneMmCpuIo2Initialize ( > > + IN EFI_HANDLE ImageHandle, > > + IN EFI_MM_SYSTEM_TABLE *SystemTable > > + ) > > +{ > > + return CommonCpuIo2Initialize (); > > +} > > diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h b/UefiCpuPkg/CpuIo2Smm/CpuIo2Common.h > > similarity index 92% > > rename from UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h > > rename to UefiCpuPkg/CpuIo2Smm/CpuIo2Common.h > > index 4c133b58c9f4..6759cc1c8777 100644 > > --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h > > +++ b/UefiCpuPkg/CpuIo2Smm/CpuIo2Common.h > > @@ -9,14 +9,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > #ifndef _CPU_IO2_SMM_H_ > > #define _CPU_IO2_SMM_H_ > > > > -#include > > +#include > > > > #include > > > > #include > > #include > > #include > > -#include > > +#include > > #include > > > > #define MAX_IO_PORT_ADDRESS 0xFFFF > > @@ -153,4 +153,17 @@ CpuIoServiceWrite ( > > IN VOID *Buffer > > ); > > > > + > > +/** > > + The module Entry Point SmmCpuIoProtocol driver > > + > > + @retval EFI_SUCCESS The entry point is executed successfully. > > + @retval Other Some error occurs when executing this entry point. > > + > > +**/ > > +EFI_STATUS > > +CommonCpuIo2Initialize ( > > + VOID > > + ); > > + > > #endif > > diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf b/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf > > index bc78fa4e42d2..031db1d100b9 100644 > > --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf > > +++ b/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf > > @@ -14,7 +14,7 @@ [Defines] > > MODULE_TYPE = DXE_SMM_DRIVER > > VERSION_STRING = 1.0 > > PI_SPECIFICATION_VERSION = 0x0001000A > > - ENTRY_POINT = SmmCpuIo2Initialize > > + ENTRY_POINT = TraditionalMmCpuIo2Initialize > > > > # > > # The following information is for reference only and not required by the build tools. > > @@ -24,7 +24,8 @@ [Defines] > > > > [Sources] > > CpuIo2Smm.c > > - CpuIo2Smm.h > > + CpuIo2Common.c > > + CpuIo2Common.h > > > > [Packages] > > MdePkg/MdePkg.dec > > @@ -34,7 +35,7 @@ [LibraryClasses] > > BaseLib > > DebugLib > > IoLib > > - SmmServicesTableLib > > + MmServicesTableLib > > BaseMemoryLib > > > > [Protocols] > > diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf b/UefiCpuPkg/CpuIo2Smm/CpuIo2StandaloneMm.inf > > similarity index 56% > > copy from UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf > > copy to UefiCpuPkg/CpuIo2Smm/CpuIo2StandaloneMm.inf > > index bc78fa4e42d2..cce7742bee7a 100644 > > --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf > > +++ b/UefiCpuPkg/CpuIo2Smm/CpuIo2StandaloneMm.inf > > @@ -8,13 +8,12 @@ > > > > [Defines] > > INF_VERSION = 0x00010005 > > - BASE_NAME = CpuIo2Smm > > - MODULE_UNI_FILE = CpuIo2Smm.uni > > - FILE_GUID = A47EE2D8-F60E-42fd-8E58-7BD65EE4C29B > > - MODULE_TYPE = DXE_SMM_DRIVER > > + BASE_NAME = CpuIo2StandaloneMm > > + FILE_GUID = E3121A26-BB1C-4A18-8E23-2EA3F0412248 > > + MODULE_TYPE = MM_STANDALONE > > VERSION_STRING = 1.0 > > - PI_SPECIFICATION_VERSION = 0x0001000A > > - ENTRY_POINT = SmmCpuIo2Initialize > > + PI_SPECIFICATION_VERSION = 0x00010032 > > + ENTRY_POINT = StandaloneMmCpuIo2Initialize > > > > # > > # The following information is for reference only and not required by the build tools. > > @@ -23,18 +22,19 @@ [Defines] > > # > > > > [Sources] > > - CpuIo2Smm.c > > - CpuIo2Smm.h > > + CpuIo2StandaloneMm.c > > + CpuIo2Common.c > > + CpuIo2Common.h > > > > [Packages] > > MdePkg/MdePkg.dec > > > > [LibraryClasses] > > - UefiDriverEntryPoint > > + StandaloneMmDriverEntryPoint > > BaseLib > > DebugLib > > IoLib > > - SmmServicesTableLib > > + MmServicesTableLib > > BaseMemoryLib > > > > [Protocols] > > @@ -42,6 +42,3 @@ [Protocols] > > > > [Depex] > > TRUE > > - > > -[UserExtensions.TianoCore."ExtraFiles"] > > - CpuIo2SmmExtra.uni > > diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc > > index b2b6d78a71b0..4e46c600788f 100644 > > --- a/UefiCpuPkg/UefiCpuPkg.dsc > > +++ b/UefiCpuPkg/UefiCpuPkg.dsc > > @@ -38,6 +38,7 @@ [LibraryClasses] > > UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf > > UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf > > UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf > > + StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf > > DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf > > PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf > > PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf > > @@ -89,10 +90,14 @@ [LibraryClasses.common.DXE_DRIVER] > > > > [LibraryClasses.common.DXE_SMM_DRIVER] > > SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf > > + MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf > > MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf > > HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf > > CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf > > > > +[LibraryClasses.common.MM_STANDALONE] > > + MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf > > + > > [LibraryClasses.common.UEFI_APPLICATION] > > UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf > > MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf > > @@ -121,6 +126,7 @@ [Components.IA32, Components.X64] > > NULL|UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf > > } > > UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf > > + UefiCpuPkg/CpuIo2Smm/CpuIo2StandaloneMm.inf > > UefiCpuPkg/CpuMpPei/CpuMpPei.inf > > UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf > > UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf > > >