From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web09.6458.1611904019893670470 for ; Thu, 28 Jan 2021 23:07:00 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=QdXshSlB; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: ray.ni@intel.com) IronPort-SDR: ln4MMBixv8tsM+sz5V+a5tMbyv0gAh+jE0c7O0mqTVjNR4uqRbetADvvTZCcin/w3nymBaUcKo +9MSfNULBv0A== X-IronPort-AV: E=McAfee;i="6000,8403,9878"; a="179596878" X-IronPort-AV: E=Sophos;i="5.79,384,1602572400"; d="scan'208";a="179596878" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2021 23:06:58 -0800 IronPort-SDR: nOQ5NIK+FWvEn7pmolYIsX1TKO/wTkIFbsHTYZ53qptVQZvT7cHgo1yOd9gUH6Nfs2HPc7eRjc D+VQiD0P8Wdg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,384,1602572400"; d="scan'208";a="430883008" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga001.jf.intel.com with ESMTP; 28 Jan 2021 23:06:58 -0800 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Thu, 28 Jan 2021 23:06:57 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Thu, 28 Jan 2021 23:06:57 -0800 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.44) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Thu, 28 Jan 2021 23:06:57 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=li0fGhmdJAnFPfKYIZhb58k3U4Nig8tfEsEIdKsIuOfJRMwDvOEo0Kpd8/soijil2nGYrwYG2WwZkxjs6XwZqPH+HnbqDBIveyxf+pJHcQelbSmivSm6B3BLaQUkL+asVf33pnMvOEyRgO4USKVME22pi6HtboyUvnVoC/y76EAPtHHr8265viY7F39hkV70A9Vh75Yv/VPp6Dr0f13GzAMzCTCcGmzhUzseIvonIwL4/srCpKZP1f0dDH8nZdpNgIc1KFYWBRH1wKYL/2sZczEX5jBWtDqdRhlR75sdbn3Std7dNH3KQDHK/m78Gkn2XjuDQGvQBnk6Ipr0He+cIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YSE+q4cKtPTpE6SkzAdLgrQeBE8p2jjFsQVGxRWIzwM=; b=RhNmEUCx0CTWxICPhsPH6lDKlFSyQM3Ex6VTfwn2U4TXI6RGjcJbPFSeWuEG/7miKaR9pgDGqmJ5WbLnHWY8FcMP2Vi8y6IFEzyqdTuO37jDjeZMIBKp5EZggYWTtK9dJDAVNW3ilokGQ9gQuXvbGp30lycKUT3Nwc1a/fvHXoqDBg9l2qFWUo8Qv+8gltUuJ4tkn6o9Jtk7I297hfLA4ChPUvgwxiS80AH3v1dGMcrn8+p/p3B26VQDaDNgiEgCnvjZJxCrqL91wdvRmliv0kE0YJpfuk7M7XtlHoDW4Kdop4jpECYv0RWVWcAGxMJ6NchZW+LcrTJDi+tMsKwSkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YSE+q4cKtPTpE6SkzAdLgrQeBE8p2jjFsQVGxRWIzwM=; b=QdXshSlB9HXbpbRfjd4srNb7KCkk5CV1JFn78wP/8eTxSkyFyZlT36TN6CGyKmysh0hNiOGRbOkpxWFi0iYa9ld7p0+yR1TKJ91PvMfaG+/dPQwZF5U/7Zb0QvO8W++IBLchyVT91XokxQAnRItXRvrgo77HQz45Nc15gTaiQHQ= Received: from CO1PR11MB4930.namprd11.prod.outlook.com (2603:10b6:303:9b::11) by CO1PR11MB4882.namprd11.prod.outlook.com (2603:10b6:303:97::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.16; Fri, 29 Jan 2021 07:06:55 +0000 Received: from CO1PR11MB4930.namprd11.prod.outlook.com ([fe80::8d64:91ed:c259:e95]) by CO1PR11MB4930.namprd11.prod.outlook.com ([fe80::8d64:91ed:c259:e95%6]) with mapi id 15.20.3805.021; Fri, 29 Jan 2021 07:06:55 +0000 From: "Ni, Ray" To: Kun Qin , "devel@edk2.groups.io" CC: "Dong, Eric" , Laszlo Ersek , "Kumar, Rahul1" Subject: Re: [PATCH v4 18/20] UefiCpuPkg: CpuIo2Smm: Abstract SMM specific functions into separate file Thread-Topic: [PATCH v4 18/20] UefiCpuPkg: CpuIo2Smm: Abstract SMM specific functions into separate file Thread-Index: AQHW9BwwOGKd0Yq5z0Co6VhET7R8iKo+MmHw Date: Fri, 29 Jan 2021 07:06:55 +0000 Message-ID: References: <20210126194710.2248-1-kun.q@outlook.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: outlook.com; dkim=none (message not signed) header.d=none;outlook.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.198] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2287a7cd-e53d-4fd9-4171-08d8c4247679 x-ms-traffictypediagnostic: CO1PR11MB4882: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: QYQapc39/kQLgsaCESOUzO4EtymrvZ5z6JR0Lvco2h8XO21Ww7vHPWfwzU+wIMAyoe5wMQYgCusuZh0XBaDWTfLau59ZpNEQxWzQKvIoWy0np1zz7DTy5Z6ZBSNtaGWz5i6modO8DZ8azbKJRVfWlqLrQivqkX4g1T/yq0M9RiRrxnDqH4ejnKRqJXGIuDMTEPaup48kDnxYjorvsfqE/QnPKaiQtIANaQ+l0wjvuGWcae9idxsHYaewk5FP+cVdp+t6UmYtdnHexflVIqgxfm1VRFkcsu/5ZX5fqP4pi2zrcti4VCAPstnByiV+Fdww0HSA4LX9tTlTJpoaZ8BMDeRldAJvyEjylXSlhfEuitqkFuOVjq3J9JtdnX66eWXaNFF7/Da2BZIh+B8APfsMJ1JmI8rDIF3fCJb/wJnAXkso73wgoswqdyaPD9a9HMsBF8jXTKcBTsvuFJIja4kDF6gYxVGCRe+dS6et+mfE4WdKkDAyOHi9RJWoJKfzoPu1Bu9TI6NmVC+0W7s+SPEFMA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR11MB4930.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(366004)(136003)(346002)(376002)(39860400002)(76116006)(66446008)(66476007)(5660300002)(83380400001)(66556008)(45080400002)(71200400001)(4326008)(64756008)(33656002)(52536014)(107886003)(478600001)(66946007)(9686003)(55016002)(53546011)(19627235002)(26005)(186003)(6506007)(54906003)(316002)(8676002)(86362001)(7696005)(8936002)(2906002)(110136005)(30864003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?fWFL5n8inM3RMvH/liLOXmUJfpv8v2RnEaseHbCOLU2JVTPxU6RxyXU0thOW?= =?us-ascii?Q?LDuXY9G/GaNmKWDGJa/zvMX9E+pQiv7A1efAADaRnzFndjDTMMZ3k3OS5+He?= =?us-ascii?Q?vjxJ67LwNM1DRuipIrX0ucjpK1CM+zkK5ljGIGw7JuuMzoXC5pvc9OUMfvCm?= =?us-ascii?Q?jD7d/ZmP4TEF18mzWqCm3scBsYCMhM6CzxjsRuD1KHtIaYmus5iCuFdn8r2f?= =?us-ascii?Q?DRzb3GG89qA8XSoekUrXhLIfv40l0uMBMPZay7jYtX77wZTB4V1wRDY4g+g4?= =?us-ascii?Q?rkxE90S+Qbj2K8QLimcksfCE74hQfYSTnaCFwFhWO5wM4t/d/GByOT65+/G1?= =?us-ascii?Q?rQIOX9Z7JKlOkWJ5tE4qXUBXY/J7dc2zi0L0qzLHMk+sDDr23mbF+cV2VE2S?= =?us-ascii?Q?YCOVuBN/X5pWmd/894eR4hxMh0W/jT5WIuKVm3r6Ow9+KhkgBM/Bf2acaEJZ?= =?us-ascii?Q?cc17/NOnLyPGSgcus6G4fvsAOePSxaycevXj+lwXP9pBxI6i/pCo2VLSi2rT?= =?us-ascii?Q?r89ZMtsCu1Y1YuNgtV2Yq2+ewqyjO/rUs/fpK/8aqp5TY+YFtxcV+N7p63AV?= =?us-ascii?Q?EXTF6NxxiA1Z8HvtAjp55oCXxb04tyd1lsNSfMkQn5GxpgHpriaNO8vjbZKY?= =?us-ascii?Q?bWuXMhO+4N1zypm9ubfJ1+P6JYXoIe3vKKzT72++fDAd/jnaulBG1mLYRULs?= =?us-ascii?Q?p0esD7OHFVu3yQXVXHvG8NWLD0WoPNmHnnCoVZM7yJ5I5VdKcMfEGjq6UZ3B?= =?us-ascii?Q?qnC3GT30T8ESbCUQDnirkiUqjM9EVcTEbsGGOE/LpNgJBHTCSiK9ZhC9lSWL?= =?us-ascii?Q?yB7zSj9cQrGHMneIYbBiVUjJ/e/2wL5z2NjGljyqnTJi3KuEbZH5wNR/gMKK?= =?us-ascii?Q?BBWPcLgC7aqTXv0Xrfpc+GSmFx4ccdNmWVZq1ocvNTAO/ha4VN3/c6a/dMLu?= =?us-ascii?Q?McVrZCbPle9i5+KW5rAzObD8kG2dSiiLzQ8AvBRkpx1/R3PHm2aR3/p6Vh0y?= =?us-ascii?Q?wYMP0ldADtzmp5P5s081k85gv02+hQ4tYyUyBuqVrGE05gzpJG8NGyAo2sAm?= =?us-ascii?Q?edlcLBx+?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4930.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2287a7cd-e53d-4fd9-4171-08d8c4247679 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jan 2021 07:06:55.7185 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: WU5l6fQGzPXqZUN72cHSH02P2vduWCATlklCTLJNpeEHGZ+/WyIwaEuK6g7tcfcf23U5te6ZmJeHaeGCbyM01w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR11MB4882 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: Kun Qin > Sent: Wednesday, January 27, 2021 3:47 AM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Ni, Ray ; Laszlo = Ersek ; Kumar, Rahul1 > > Subject: [PATCH v4 18/20] UefiCpuPkg: CpuIo2Smm: Abstract SMM specific fu= nctions into separate file >=20 > This change abstracts CpuIo2Smm driver entrypoint into separate file and > moves functions/definitions that are not substantially specific to > Traditional MM (SMM) into CpuIo2Mm.* in order to set ways for Standalone > MM support in the future. >=20 > Cc: Eric Dong > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Rahul Kumar >=20 > Signed-off-by: Kun Qin > --- >=20 > Notes: > v4: > - Newly created patch to rename files for existed SMM driver [Ray] >=20 > UefiCpuPkg/CpuIo2Smm/{CpuIo2Smm.c =3D> CpuIo2Mm.c} | 11 +- > UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c | 385 +----------------= --- > UefiCpuPkg/CpuIo2Smm/{CpuIo2Smm.h =3D> CpuIo2Mm.h} | 12 + > UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf | 3 +- > 4 files changed, 22 insertions(+), 389 deletions(-) >=20 > diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c b/UefiCpuPkg/CpuIo2Smm/CpuI= o2Mm.c > similarity index 95% > copy from UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c > copy to UefiCpuPkg/CpuIo2Smm/CpuIo2Mm.c > index c0a2baecee03..7e314eaa1558 100644 > --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c > +++ b/UefiCpuPkg/CpuIo2Smm/CpuIo2Mm.c > @@ -6,7 +6,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ >=20 > -#include "CpuIo2Smm.h" > +#include "CpuIo2Mm.h" >=20 > // > // Handle for the SMM CPU I/O Protocol > @@ -371,18 +371,13 @@ CpuIoServiceWrite ( > /** > The module Entry Point SmmCpuIoProtocol driver >=20 > - @param[in] ImageHandle The firmware allocated handle for the EFI imag= e. > - @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= . >=20 > **/ > EFI_STATUS > -EFIAPI > -SmmCpuIo2Initialize ( > - IN EFI_HANDLE ImageHandle, > - IN EFI_SYSTEM_TABLE *SystemTable > +CommonCpuIo2Initialize ( > + VOID > ) > { > EFI_STATUS Status; > diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c b/UefiCpuPkg/CpuIo2Smm/CpuI= o2Smm.c > index c0a2baecee03..1acce9f3d462 100644 > --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c > +++ b/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c > @@ -2,374 +2,17 @@ > Produces the SMM CPU I/O Protocol. >=20 > Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) Microsoft Corporation. > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ >=20 > -#include "CpuIo2Smm.h" > +#include >=20 > -// > -// Handle for the SMM CPU I/O Protocol > -// > -EFI_HANDLE mHandle =3D NULL; > - > -// > -// SMM CPU I/O Protocol instance > -// > -EFI_SMM_CPU_IO2_PROTOCOL mSmmCpuIo2 =3D { > - { > - CpuMemoryServiceRead, > - CpuMemoryServiceWrite > - }, > - { > - CpuIoServiceRead, > - CpuIoServiceWrite > - } > -}; > - > -// > -// Lookup table for increment values based on transfer widths > -// > -UINT8 mStride[] =3D { > - 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 P= ort operation. > - @param[in] Width Signifies the width of the I/O operations. > - @param[in] Address The base address of the I/O operations. Th= e caller is > - responsible for aligning the Address if req= uired. > - @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 sou= rce buffer > - from which to write data. > - > - @retval EFI_SUCCESS The data was read from or written to th= e device. > - @retval EFI_UNSUPPORTED The Address is not valid for this syste= m. > - @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 =3D=3D 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 =3D=3D SMM_IO_UINT64)) { > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // Check to see if any address associated with this transfer exceeds t= he maximum > - // allowed address. The maximum address implied by the parameters pas= sed in is > - // Address + Size * Count. If the following condition is met, then th= e transfer > - // is not supported. > - // > - // Address + Size * Count > (MmioOperation ? MAX_ADDRESS : MAX_IO_P= ORT_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 ra= nge > - // check must be adjusted to avoid all overflow conditions. > - // > - // The following form of the range check is equivalent but assumes tha= t > - // MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1). > - // > - Limit =3D (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS); > - if (Count =3D=3D 0) { > - if (Address > Limit) { > - return EFI_UNSUPPORTED; > - } > - } else { > - MaxCount =3D 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)) !=3D 0) { > - return EFI_UNSUPPORTED; > - } > - > - return EFI_SUCCESS; > -} > - > -/** > - Reads memory-mapped registers. > - > - The I/O operations are carried out exactly as requested. The caller i= s > - responsible for any alignment and I/O width issues that the bus, devic= e, > - 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 call= er 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 st= ore > - the results. For write operations, the source bu= ffer > - from which to write data. > - > - @retval EFI_SUCCESS The data was read from or written to th= e device. > - @retval EFI_UNSUPPORTED The Address is not valid for this syste= m. > - @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 =3D CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - // > - // Select loop based on the width of the transfer > - // > - Stride =3D mStride[Width]; > - for (Uint8Buffer =3D Buffer; Count > 0; Address +=3D Stride, Uint8Buff= er +=3D Stride, Count--) { > - if (Width =3D=3D SMM_IO_UINT8) { > - *Uint8Buffer =3D MmioRead8 ((UINTN)Address); > - } else if (Width =3D=3D SMM_IO_UINT16) { > - *((UINT16 *)Uint8Buffer) =3D MmioRead16 ((UINTN)Address); > - } else if (Width =3D=3D SMM_IO_UINT32) { > - *((UINT32 *)Uint8Buffer) =3D MmioRead32 ((UINTN)Address); > - } else if (Width =3D=3D SMM_IO_UINT64) { > - *((UINT64 *)Uint8Buffer) =3D MmioRead64 ((UINTN)Address); > - } > - } > - return EFI_SUCCESS; > -} > - > -/** > - Writes memory-mapped registers. > - > - The I/O operations are carried out exactly as requested. The caller i= s > - responsible for any alignment and I/O width issues that the bus, devic= e, > - 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 call= er 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 st= ore > - the results. For write operations, the source bu= ffer > - from which to write data. > - > - @retval EFI_SUCCESS The data was read from or written to th= e device. > - @retval EFI_UNSUPPORTED The Address is not valid for this syste= m. > - @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 =3D CpuIoCheckParameter (TRUE, Width, Address, Count, Buffer); > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - // > - // Select loop based on the width of the transfer > - // > - Stride =3D mStride[Width]; > - for (Uint8Buffer =3D Buffer; Count > 0; Address +=3D Stride, Uint8Buff= er +=3D Stride, Count--) { > - if (Width =3D=3D SMM_IO_UINT8) { > - MmioWrite8 ((UINTN)Address, *Uint8Buffer); > - } else if (Width =3D=3D SMM_IO_UINT16) { > - MmioWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); > - } else if (Width =3D=3D SMM_IO_UINT32) { > - MmioWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); > - } else if (Width =3D=3D 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 i= s > - responsible for any alignment and I/O width issues that the bus, devic= e, > - 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 call= er 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 st= ore > - the results. For write operations, the source bu= ffer > - from which to write data. > - > - @retval EFI_SUCCESS The data was read from or written to th= e device. > - @retval EFI_UNSUPPORTED The Address is not valid for this syste= m. > - @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 =3D CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - // > - // Select loop based on the width of the transfer > - // > - Stride =3D mStride[Width]; > - for (Uint8Buffer =3D Buffer; Count > 0; Address +=3D Stride, Uint8Buff= er +=3D Stride, Count--) { > - if (Width =3D=3D SMM_IO_UINT8) { > - *Uint8Buffer =3D IoRead8 ((UINTN)Address); > - } else if (Width =3D=3D SMM_IO_UINT16) { > - *((UINT16 *)Uint8Buffer) =3D IoRead16 ((UINTN)Address); > - } else if (Width =3D=3D SMM_IO_UINT32) { > - *((UINT32 *)Uint8Buffer) =3D IoRead32 ((UINTN)Address); > - } > - } > - > - return EFI_SUCCESS; > -} > - > -/** > - Write I/O registers. > - > - The I/O operations are carried out exactly as requested. The caller i= s > - responsible for any alignment and I/O width issues that the bus, devic= e, > - 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 call= er 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 st= ore > - the results. For write operations, the source bu= ffer > - from which to write data. > - > - @retval EFI_SUCCESS The data was read from or written to th= e device. > - @retval EFI_UNSUPPORTED The Address is not valid for this syste= m. > - @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 =3D CpuIoCheckParameter (FALSE, Width, Address, Count, Buffer); > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - // > - // Select loop based on the width of the transfer > - // > - Stride =3D mStride[Width]; > - for (Uint8Buffer =3D (UINT8 *)Buffer; Count > 0; Address +=3D Stride, = Uint8Buffer +=3D Stride, Count--) { > - if (Width =3D=3D SMM_IO_UINT8) { > - IoWrite8 ((UINTN)Address, *Uint8Buffer); > - } else if (Width =3D=3D SMM_IO_UINT16) { > - IoWrite16 ((UINTN)Address, *((UINT16 *)Uint8Buffer)); > - } else if (Width =3D=3D SMM_IO_UINT32) { > - IoWrite32 ((UINTN)Address, *((UINT32 *)Uint8Buffer)); > - } > - } > - > - return EFI_SUCCESS; > -} > +#include "CpuIo2Mm.h" >=20 > /** > - The module Entry Point SmmCpuIoProtocol driver > + The module Entry Point for Traditional MM CpuIoProtocol driver >=20 > @param[in] ImageHandle The firmware allocated handle for the EFI imag= e. > @param[in] SystemTable A pointer to the EFI System Table. > @@ -385,23 +28,5 @@ SmmCpuIo2Initialize ( > IN EFI_SYSTEM_TABLE *SystemTable > ) > { > - EFI_STATUS Status; > - > - // > - // Copy the SMM CPU I/O Protocol instance into the System Management S= ystem Table > - // > - CopyMem (&gMmst->MmIo, &mSmmCpuIo2, sizeof (mSmmCpuIo2)); > - > - // > - // Install the SMM CPU I/O Protocol into the MM protocol database > - // > - Status =3D gMmst->MmInstallProtocolInterface ( > - &mHandle, > - &gEfiSmmCpuIo2ProtocolGuid, > - EFI_NATIVE_INTERFACE, > - &mSmmCpuIo2 > - ); > - ASSERT_EFI_ERROR (Status); > - > - return Status; > + return CommonCpuIo2Initialize (); > } > diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h b/UefiCpuPkg/CpuIo2Smm/CpuI= o2Mm.h > similarity index 93% > rename from UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h > rename to UefiCpuPkg/CpuIo2Smm/CpuIo2Mm.h > index c80261945f71..eda9fbb090cd 100644 > --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h > +++ b/UefiCpuPkg/CpuIo2Smm/CpuIo2Mm.h > @@ -153,4 +153,16 @@ CpuIoServiceWrite ( > IN VOID *Buffer > ); >=20 > +/** > + 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/Cp= uIo2Smm.inf > index b743a5e0e316..304f0ce83c62 100644 > --- a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf > +++ b/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf > @@ -24,7 +24,8 @@ [Defines] >=20 > [Sources] > CpuIo2Smm.c > - CpuIo2Smm.h > + CpuIo2Mm.c > + CpuIo2Mm.h >=20 > [Packages] > MdePkg/MdePkg.dec > -- > 2.30.0.windows.1