From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.92.40.92]) by mx.groups.io with SMTP id smtpd.web08.18066.1611690456504436794 for ; Tue, 26 Jan 2021 11:47:36 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=TdgKLOes; spf=pass (domain: outlook.com, ip: 40.92.40.92, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H/P5vfBB9tDpYTEnvofdqnETDiefPaX/BJVDGVk/6RQgZDuCi3gShqh0DQQNi+5G8jHR8LRnNpeel8uQ2PZ57szkz1pBnxuyqnfSNVi5I9Ui1c/vlJxWuoF/Nn73ajpxS3+r4GoJLHH/ESQBM9MzQjRNB9ryMe8VgVh0u148RDo8T/9EHqN48Ijtkg8t6oIDYNmjc59PN/dpXbBGoaFmu+Kbqo4dyIDq3gUeT7mpjQmzfz+ouiZ0ErM70rapamS69lWwMYq8fxYFHY0Lp7+0Iquy0StaYPbhdTo1uRVL3SPP0ME/jC2Ksr5TelhH8dXyXgV/fDug3RXMrmm/FXKYdA== 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=VShYYFD4XK3Cjbm/Vm1mo18IIWVnILeHejc2LTltI6k=; b=DsttmFy+RbQBrX7/sJSnx2L/os42O4P4207ba9B/r2s6LHPKR8CnSFlW4mE766PGHsFKLbtYJslb/F/4AwLKy1BZF2mDTkAiCulTA1FJL3Vrb2IJICR8Y/l4M2tGtBipoACCQ7SFr7cI8DgruYZ5HgWiaq/8dujqYbNCEOBsi0WAERsLTPG0dFMKe/QhouSLDYzC7vax2MIVGvNb/DyrA3U3rV7HnKmiVIdm/ZygK4xhTtsl6KzGKJYcGzR/nEsfCbMl+1AIkHiWuuZs0MowKOMbWl9Zjmg0FUMPuAvpxvuCWf0l+cu9jGw3DzGOTU6m6MPtSA81GojwL5O1y1aiZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VShYYFD4XK3Cjbm/Vm1mo18IIWVnILeHejc2LTltI6k=; b=TdgKLOes27pLyWPdXFHOyTvd6itJsilLi/Mg1GkkRrhRrVv5tYip1Tyw2YsWafGPF7tvO04xodfnwsKWgOSU7GZ3uwYPMb/Tjb30W9zwlgYMtqDT9dNd7/W1GtK+eGv+B1j/SsVQVnca6dw/oAiQYE2Dz2Zxh2uNIpvGoyRgIfROQcxBiRiRvJBQRaYco2Y4e/ua3rpdA7hbYxUVp9jtmqnVM+znRR55/kMyVucZcch2QA0Xby209mY4V4HDtfFLK7+TSp81D8gsL6/T3V5L3bIZIfHn7pwnyI5LwsmGvjn/q/2wddU4OlwqGzRni4CeNS8LUnGr/dd0G8IiFHccRg== Received: from BN7NAM10FT059.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::42) by BN7NAM10HT176.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Tue, 26 Jan 2021 19:47:35 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e8f::4c) by BN7NAM10FT059.mail.protection.outlook.com (2a01:111:e400:7e8f::447) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Tue, 26 Jan 2021 19:47:35 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:9431E309871B60DA33C638CBCDAE40DC57C04B30A3C922690D2E7CC07ECBD512;UpperCasedChecksum:191778CED3663BC3BB5C555A70E4415F3F6C1DEC3B636738F4D61B8C6F4A8275;SizeAsReceived:7486;Count:47 Received: from MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b]) by MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b%6]) with mapi id 15.20.3784.017; Tue, 26 Jan 2021 19:47:35 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [PATCH v4 18/20] UefiCpuPkg: CpuIo2Smm: Abstract SMM specific functions into separate file Date: Tue, 26 Jan 2021 11:47:08 -0800 Message-ID: X-Mailer: git-send-email 2.30.0.windows.1 In-Reply-To: <20210126194710.2248-1-kun.q@outlook.com> References: <20210126194710.2248-1-kun.q@outlook.com> X-TMN: [1DlUEl+heRNLIzEsnRSbBeXZzj+fV+bx] X-ClientProxiedBy: MWHPR11CA0001.namprd11.prod.outlook.com (2603:10b6:301:1::11) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20210126194710.2248-16-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MWHPR11CA0001.namprd11.prod.outlook.com (2603:10b6:301:1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.14 via Frontend Transport; Tue, 26 Jan 2021 19:47:32 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: fd7ce3c2-b97e-4c1c-d7b7-08d8c23338a9 X-MS-TrafficTypeDiagnostic: BN7NAM10HT176: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /YafbjctelLWO/mFzCKmGveA3e4Ctn+N0asdux2f2Hr1pFE6mBoU21FhkzYzSTEJPBMpHUgRZFtosPpSEi5svFrObcseQpovZuB1S+apd6FaLA5HzWjonycPS5Tz+7uf/4CxEZckkIYUtjbsu9GAA5RnLbr/XllrWz6xPtwPeaQKRODLrcL5s7dsE0I9izy3obAjnR+0L8kai/t+j5TL2Z8sAuK5kwS2zhfh/EWH1QTctn3fmdxkL0C80ITiM8D064vwZNc+9AbcHvfesivMnpnxBr5RM8EXE/by/Kh+d/2vACIgvmQrqD/KA0ehE73DaAHFZlLhhdHrJPVbAWDkrPEcCXPpKh6IapfWH4ip7h5tfeRe6cbtXNnhuMfi2QPlQJlui4pf3dwtAaazHNIaUg== X-MS-Exchange-AntiSpam-MessageData: Oq1g8XfdQnhEHOCngSwu0RTy4mzTY1jYjHewZdureykeWLsHW9XFRu7uxvaVRe8jBVLPbgYyw2Yq5i6ChY23Syb/Zm3qWgI9OyqL0Jq0yi3HNKVFqJNke2EwTr7ObfIBMzjfzzxDCR9I3cQZQZc0TQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd7ce3c2-b97e-4c1c-d7b7-08d8c23338a9 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2021 19:47:32.5479 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: BN7NAM10FT059.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT176 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Signed-off-by: Kun Qin --- Notes: v4: - Newly created patch to rename files for existed SMM driver [Ray] 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(-) diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c b/UefiCpuPkg/CpuIo2Smm/CpuIo2= Mm.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 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. =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/CpuIo2= Smm.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 Por= t 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 requi= red. - @param[in] Count The number of I/O operations to perform. - @param[in] Buffer For read operations, the destination buffer t= o store - the results. For write operations, the sourc= e 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 =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 the= maximum - // allowed address. The maximum address implied by the parameters passe= d 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_POR= T_ADDRESS) + 1 - // - // Since MAX_ADDRESS can be the maximum integer value supported by the C= PU and Count - // can also be the maximum integer value supported by the CPU, this rang= e - // 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 =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 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 stor= e - the results. For write operations, the source buff= er - 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 =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, Uint8Buffer= +=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 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 stor= e - the results. For write operations, the source buff= er - 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 =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, Uint8Buffer= +=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 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 stor= e - the results. For write operations, the source buff= er - 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 =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, Uint8Buffer= +=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 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 stor= e - the results. For write operations, the source buff= er - 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 =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, Ui= nt8Buffer +=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 image. @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 Sys= tem 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/CpuIo2= Mm.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/CpuI= o2Smm.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 --=20 2.30.0.windows.1