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.web11.3022.1573003917490959366 for ; Tue, 05 Nov 2019 17:31:57 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: nathaniel.l.desimone@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Nov 2019 17:31:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,272,1569308400"; d="scan'208";a="200564769" Received: from orsmsx107.amr.corp.intel.com ([10.22.240.5]) by fmsmga008.fm.intel.com with ESMTP; 05 Nov 2019 17:31:57 -0800 Received: from orsmsx155.amr.corp.intel.com (10.22.240.21) by ORSMSX107.amr.corp.intel.com (10.22.240.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 5 Nov 2019 17:31:56 -0800 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.28]) by ORSMSX155.amr.corp.intel.com ([169.254.7.105]) with mapi id 14.03.0439.000; Tue, 5 Nov 2019 17:31:56 -0800 From: "Nate DeSimone" To: "Agyeman, Prince" , "devel@edk2.groups.io" CC: "Sinha, Ankit" , "Kubacki, Michael A" Subject: Re: [edk2-platforms] [PATCH v2] SimicsOpenBoardPkg: Add CmosAccessLib to BoardX58Ich10 Thread-Topic: [edk2-platforms] [PATCH v2] SimicsOpenBoardPkg: Add CmosAccessLib to BoardX58Ich10 Thread-Index: AQHVkQ4uZNgUQ/nvAEyXo2jsHFN73ad9YT4g Date: Wed, 6 Nov 2019 01:31:55 +0000 Message-ID: <02A34F284D1DA44BB705E61F7180EF0AB5BA1C26@ORSMSX113.amr.corp.intel.com> References: <20191101234335.42520-1-prince.agyeman@intel.com> In-Reply-To: <20191101234335.42520-1-prince.agyeman@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDg1NzVmYzYtZTllNy00OTc0LWExZGMtMGQ0ZWUwNThhZTU3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiV2dzeEh5eUxuRVwvTWRjSGpRY1wvbE1HN25oTDhGZDFDM2Z5Q3V5d2tqTXRUdnNVRHY0bU1qcnloNkppZ3FJUVpNIn0= x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Return-Path: nathaniel.l.desimone@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable It looks like there are a bunch of magical CMOS locations hardcoded in here= ... specifically 0x34, 0x5B, and 0x5C. I would prefer that these were conve= rted into #defines. That can be done in a separate patch though since it is= not related to your change here. Reviewed-by: Nate DeSimone -----Original Message----- From: Agyeman, Prince =20 Sent: Friday, November 1, 2019 4:44 PM To: devel@edk2.groups.io Cc: Sinha, Ankit ; Desimone, Nathaniel L ; Kubacki, Michael A Subject: [edk2-platforms] [PATCH v2] SimicsOpenBoardPkg: Add CmosAccessLib = to BoardX58Ich10 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2164 Replaced Cmos.c and Cmos.h with BoardModulePkg's Cmos library CmosAccessLib Cc: Ankit Sinha Cc: Nate DeSimone Cc: Kubacki Michael A Signed-off-by: Prince Agyeman --- .../BoardInitLib/PeiX58Ich10InitPreMemLib.c | 46 --------------- .../BoardX58Ich10/OpenBoardPkg.dsc | 2 + .../Intel/SimicsOpenBoardPkg/SimicsPei/Cmos.c | 57 ------------------- ..= ./Intel/SimicsOpenBoardPkg/SimicsPei/Cmos.h | 50 ---------------- .../Simi= csOpenBoardPkg/SimicsPei/MemDetect.c | 19 +------ .../SimicsOpenBoardPkg/SimicsPei/Platform.c | 4 +- .../SimicsPei/SimicsPei.inf | 3 +- .../SmbiosPlatformDxe/SmbiosPlatformDxe.c | 38 +------------ .../SmbiosPlatformDxe/SmbiosPlatformDxe.h | 1 + .../SmbiosPlatformDxe/SmbiosPlatformDxe.inf | 2 + 10 files changed, 14 insertions(+), 208 deletions(-) delete mode 100644 P= latform/Intel/SimicsOpenBoardPkg/SimicsPei/Cmos.c delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/SimicsPei/Cmos.h diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/Library/BoardI= nitLib/PeiX58Ich10InitPreMemLib.c b/Platform/Intel/SimicsOpenBoardPkg/Board= X58Ich10/Library/BoardInitLib/PeiX58Ich10InitPreMemLib.c index c3a31ed426..325a341cdf 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/Library/BoardInitLib/= PeiX58Ich10InitPreMemLib.c +++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/Library/BoardInitL +++ ib/PeiX58Ich10InitPreMemLib.c @@ -20,52 +20,6 @@ =20 #include "PeiX58Ich10InitLib.h" #include -/** - Reads 8-bits of CMOS data. - - Reads the 8-bits of CMOS data at the location specified by Index. - The 8-bit read value is returned. - - @param Index The CMOS location to read. - - @return The value read. - -**/ -UINT8 -EFIAPI -CmosRead8( - IN UINTN Index - ) -{ - IoWrite8 (0x70, (UINT8)Index); - return IoRead8(0x71); -} - - -/** - Writes 8-bits of CMOS data. - - Writes 8-bits of CMOS data to the location specified by Index - with the value specified by Value and returns Value. - - @param Index The CMOS location to write. - @param Value The value to write to CMOS. - - @return The value written to CMOS. - -**/ -UINT8 -EFIAPI -CmosWrite8( - IN UINTN Index, - IN UINT8 Value - ) -{ - IoWrite8 (0x70, (UINT8)Index); - IoWrite8 (0x71, Value); - return Value; -} - =20 EFI_STATUS EFIAPI diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.d= sc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc index 78f1e80990..9b9e088cbe 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc +++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc @@ -116,6 +116,8 @@ SerializeVariablesLib|$(BOARD_PKG)/Library/SerializeVariablesLib/Seriali= zeVariablesLib.inf SiliconPolicyInitLib|$(BOARD_PKG)/Policy/Library/SiliconPolicyInitLib/Si= liconPolicyInitLib.inf SiliconPolicyUpdateLib|$(BOARD_PKG)/Policy/Library/SiliconPolicyUpdateLi= b/SiliconPolicyUpdateLib.inf + =20 + PlatformCmosAccessLib|BoardModulePkg/Library/PlatformCmosAccessLibNull + /PlatformCmosAccessLibNull.inf =20 + CmosAccessLib|BoardModulePkg/Library/CmosAccessLib/CmosAccessLib.inf =20 [LibraryClasses.common.SEC] ####################################### diff --git a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/Cmos.c b/Platform/= Intel/SimicsOpenBoardPkg/SimicsPei/Cmos.c deleted file mode 100644 index b34ba9283b..0000000000 --- a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/Cmos.c +++ /dev/null @@ -1,57 +0,0 @@ -/** @file - PC/AT CMOS access routines - - Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved.
- - SPDX-License-Identifier: BSD-2-Clause-Patent -**/ - -#include "Cmos.h" -#include "Library/IoLib.h" - -/** - Reads 8-bits of CMOS data. - - Reads the 8-bits of CMOS data at the location specified by Index. - The 8-bit read value is returned. - - @param Index The CMOS location to read. - - @return The value read. - -**/ -UINT8 -EFIAPI -CmosRead8 ( - IN UINTN Index - ) -{ - IoWrite8 (0x70, (UINT8) Index); - return IoRead8 (0x71); -} - - -/** - Writes 8-bits of CMOS data. - - Writes 8-bits of CMOS data to the location specified by Index - with the value specified by Value and returns Value. - - @param Index The CMOS location to write. - @param Value The value to write to CMOS. - - @return The value written to CMOS. - -**/ -UINT8 -EFIAPI -CmosWrite8 ( - IN UINTN Index, - IN UINT8 Value - ) -{ - IoWrite8 (0x70, (UINT8) Index); - IoWrite8 (0x71, Value); - return Value; -} - diff --git a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/Cmos.h b/Platform/= Intel/SimicsOpenBoardPkg/SimicsPei/Cmos.h deleted file mode 100644 index 07fa2e2d11..0000000000 --- a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/Cmos.h +++ /dev/null @@ -1,50 +0,0 @@ -/** @file - PC/AT CMOS access routines - - Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved.
- - SPDX-License-Identifier: BSD-2-Clause-Patent -**/ - -#ifndef __CMOS_H__ -#define __CMOS_H__ - -/** - Reads 8-bits of CMOS data. - - Reads the 8-bits of CMOS data at the location specified by Index. - The 8-bit read value is returned. - - @param Index The CMOS location to read. - - @return The value read. - -**/ -UINT8 -EFIAPI -CmosRead8 ( - IN UINTN Index - ); - -/** - Writes 8-bits of CMOS data. - - Writes 8-bits of CMOS data to the location specified by Index - with the value specified by Value and returns Value. - - @param Index The CMOS location to write. - @param Value The value to write to CMOS. - - @return The value written to CMOS. - -**/ -UINT8 -EFIAPI -CmosWrite8 ( - IN UINTN Index, - IN UINT8 Value - ); - - -#endif - diff --git a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c b/Plat= form/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c index ee0eead5a8..e547de0045 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c +++ b/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c @@ -22,11 +22,11 @@ #include #include #include +#include #include #include =20 #include "Platform.h" -#include "Cmos.h" =20 UINT8 mPhysMemAddressWidth; =20 @@ -80,9 +80,6 @@ GetSystemMemorySizeBelow4gb ( VOID ) { - UINT8 Cmos0x34; - UINT8 Cmos0x35; - // // CMOS 0x34/0x35 specifies the system memory above 16 MB. // * CMOS(0x35) is the high byte @@ -91,11 +88,7 @@ GetSystemMemorySizeBelow4gb ( // * Since this is memory above 16MB, the 16MB must be added // into the calculation to get the total memory size. // - - Cmos0x34 =3D (UINT8) CmosRead8 (0x34); - Cmos0x35 =3D (UINT8) CmosRead8 (0x35); - - return (UINT32) (((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB= ); + return (UINT32) (((UINTN)CmosRead16 (0x34) << 16) + SIZE_16MB); } =20 =20 @@ -105,8 +98,6 @@ GetSystemMemorySizeAbove4gb ( ) { UINT32 Size; - UINTN CmosIndex; - // // CMOS 0x5b-0x5d specifies the system memory above 4GB MB. // * CMOS(0x5d) is the most significant size byte @@ -114,11 +105,7 @@ G= etSystemMemorySizeAbove4gb ( // * CMOS(0x5b) is the least significant size byte // * The size is specified in 64kb chunks // - - Size =3D 0; - for (CmosIndex =3D 0x5d; CmosIndex >=3D 0x5b; CmosIndex--) { - Size =3D (UINT32) (Size << 8) + (UINT32) CmosRead8 (CmosIndex); - } + Size =3D (CmosRead16 (0x5c) << 8) + CmosRead8 (0x5b); =20 return LShiftU64 (Size, 16); } diff --git a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/Platform.c b/Platf= orm/Intel/SimicsOpenBoardPkg/SimicsPei/Platform.c index 7568d25c4e..0bec76e496 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/Platform.c +++ b/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/Platform.c @@ -22,13 +22,13 @@ #include #include #include +#include #include #include = #include #include =20 #include "Platform.h" -#include "Cmos.h" =20 EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] =3D { { EfiACPIMemoryNVS, 0x004 }, @@ -524,7 +524,7 @@ DebugDumpCmos ( VOID ) { - UINT32 Loop; + UINT8 Loop; =20 DEBUG ((EFI_D_INFO, "CMOS:\n")); =20 diff --git a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/SimicsPei.inf b/Pl= atform/Intel/SimicsOpenBoardPkg/SimicsPei/SimicsPei.inf index 9499d2aad5..710fa680be 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/SimicsPei.inf +++ b/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/SimicsPei.inf @@ -23,7 +23,6 @@ # =20 [Sources] - Cmos.c FeatureControl.c MemDetect.c Platform.c @@ -36,6 +35,7 @@ MinPlatformPkg/MinPlatformPkg.dec SimicsX58SktPkg/SktPkg.dec SimicsIch10Pkg/Ich10Pkg.dec + BoardModulePkg/BoardModulePkg.dec =20 [Guids] gEfiMemoryTypeInformationGuid @@ -53,6 +53,7 @@ PeimEntryPoint MtrrLib PcdLib + CmosAccessLib =20 [Pcd] gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsPeiMemFvBase diff --git a/Platform/Intel/SimicsOpenBoardPkg/SmbiosPlatformDxe/SmbiosPlat= formDxe.c b/Platform/Intel/SimicsOpenBoardPkg/SmbiosPlatformDxe/SmbiosPlatf= ormDxe.c index 7165c0a0c3..37c659e275 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/SmbiosPlatformDxe/SmbiosPlatformDxe= .c +++ b/Platform/Intel/SimicsOpenBoardPkg/SmbiosPlatformDxe/SmbiosPlatform +++ Dxe.c @@ -10,35 +10,11 @@ #include "SmbiosPlatformDxe.h" =20 =20 -/** -Reads 8-bits of CMOS data. - -Reads the 8-bits of CMOS data at the location specified by Index. -The 8-bit read value is returned. - -@param Index The CMOS location to read. - -@return The value read. - -**/ -UINT8 -EFIAPI -CmosRead8( - IN UINTN Index - ) -{ - IoWrite8(0x70, (UINT8)Index); - return IoRead8(0x71); -} - UINT32 GetSystemMemorySizeBelow4gb( VOID ) { - UINT8 Cmos0x34; - UINT8 Cmos0x35; - // // CMOS 0x34/0x35 specifies the system memory above 16 MB. // * CMOS(0x35) is the high byte @@ -47,11 +23,7 @@ GetSystemMemorySizeBelow4gb( // * Since this is memory above 16MB, the 16MB must be added // into the calculation to get the total memory size. // - - Cmos0x34 =3D (UINT8)CmosRead8(0x34); - Cmos0x35 =3D (UINT8)CmosRead8(0x35); - - return (UINT32)(((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB)= ; + return (UINT32) (((UINTN) CmosRead16 (0x34) << 16) + SIZE_16MB); } =20 STATIC @@ -61,8 +33,6 @@ GetSystemMemorySizeAbove4gb( ) { UINT32 Size; - UINTN CmosIndex; - // // CMOS 0x5b-0x5d specifies the system memory above 4GB MB. // * CMOS(0x5d) is the most significant size byte @@ -70,11 +40,7 @@ Get= SystemMemorySizeAbove4gb( // * CMOS(0x5b) is the least significant size byte // * The size is specified in 64kb chunks // - - Size =3D 0; - for (CmosIndex =3D 0x5d; CmosIndex >=3D 0x5b; CmosIndex--) { - Size =3D (UINT32)(Size << 8) + (UINT32)CmosRead8(CmosIndex); - } + Size =3D (CmosRead16 (0x5c) << 8) + CmosRead8 (0x5b); =20 return LShiftU64(Size, 16); } diff --git a/Platform/Intel/SimicsOpenBoardPkg/SmbiosPlatformDxe/SmbiosPlat= formDxe.h b/Platform/Intel/SimicsOpenBoardPkg/SmbiosPlatformDxe/SmbiosPlatf= ormDxe.h index f9c641845c..0dc174421c 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/SmbiosPlatformDxe/SmbiosPlatformDxe= .h +++ b/Platform/Intel/SimicsOpenBoardPkg/SmbiosPlatformDxe/SmbiosPlatform +++ Dxe.h @@ -20,6 +20,7 @@ #include #include #include +#include =20 /** Validates the SMBIOS entry point structure diff --git a/Platform/Intel/S= imicsOpenBoardPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/Platform/Intel/= SimicsOpenBoardPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf index 1420a315cf..3cc6a03564 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/SmbiosPlatformDxe/SmbiosPlatformDxe= .inf +++ b/Platform/Intel/SimicsOpenBoardPkg/SmbiosPlatformDxe/SmbiosPlatform +++ Dxe.inf @@ -32,6 +32,7 @@ MdeModulePkg/MdeModulePkg.dec SimicsOpenBoardPkg/OpenBoardPkg.dec AdvancedFeaturePkg/AdvancedFeaturePkg.dec + BoardModulePkg/BoardModulePkg.dec =20 [LibraryClasses] UefiBootServicesTableLib @@ -42,6 +43,7 @@ HobLib MemoryAllocationLib IoLib + CmosAccessLib =20 [Protocols] gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED -- 2.19.1.windows.1