From nobody Sun Feb 8 06:00:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+88195+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+88195+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1648583831; cv=none; d=zohomail.com; s=zohoarc; b=igpg7lP0fI/gNR8D+BvcfUH+eLlt9cjv5MCLbiYMFNigHe6SDJOPI9whUbVCzr8tHSAktOCjZ/AXtHc1+c4f0/qGRoBgtm1CLmRLOgNTKTmf2iX2lqPYVQKYdU7U9V0VIz/Pj2LAMwgjC/M+VYbNLpwxzO5C8ajRLmJX53dht9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648583831; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=rgsKZubBsAPhMDPVqPWKMNEkonKKSLM43KjLDeF6pZY=; b=eoal/MdCMY9x5qxtU9AEkQrbPnXYsGxct/udnwYVrwKWhjMjJGCsBaAY3lnl30wqrrkBCZf+MNrrqsLaUplgxpMd/BC0bqY5c8scyJP5GDiUTLzuDqHggXSsbSOcmZu5BO2oOtQI0evhYopvUVobodWAZwzhKal3swDPtvJ6Upo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+88195+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1648583831673234.55129886572365; Tue, 29 Mar 2022 12:57:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id C5fUYY1788612xI7JolX4GwG; Tue, 29 Mar 2022 12:57:11 -0700 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.3562.1648535835036332664 for ; Mon, 28 Mar 2022 23:37:30 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10300"; a="258003897" X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="258003897" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 23:37:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="521316616" X-Received: from shwdeopenlab704.ccr.corp.intel.com ([10.239.182.50]) by orsmga006.jf.intel.com with ESMTP; 28 Mar 2022 23:37:28 -0700 From: Yu Pu To: devel@edk2.groups.io Cc: Yu Pu , Eric Dong , Ray Ni , Rahul Kumar Subject: [edk2-devel] [PATCH v1 08/15] UefiCpuPkg: Move API and implementation from UefiCpuLib to CpuLib Date: Tue, 29 Mar 2022 14:36:56 +0800 Message-Id: <20220329063703.549-9-yu.pu@intel.com> In-Reply-To: <20220329063703.549-1-yu.pu@intel.com> References: <20220329063703.549-1-yu.pu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,yu.pu@intel.com X-Gm-Message-State: 8FQbHmsUF2Bvgx12klgLXpJ4x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1648583831; bh=cVArOKekKLmCHIDoE/E3SxXAwOqIr+SEqCX/O/D6qCM=; h=Cc:Date:From:Reply-To:Subject:To; b=sf2nW8yGcBuZ1A85n7oKZPcdeZkgz0iDrWeTcsu/qFPwvLFnCjHeLz4k+W04PJuxr/E o2RnpNWJ+f3EVvTy6IQdHkajMt4JNcx66Sf3GZ4bhuO2CS7ORjKlgMYpqe0GlZviPeJ07 HOjsoCAsDtY3eQ1Cm1zSGIF5BkMUIRkkuUA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1648583833469100040 Content-Type: text/plain; charset="utf-8" Step 2 to merge UefiCpuLib to CpuLib. Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Signed-off-by: Yu Pu --- UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c | 81 -----------= --------- UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c | 16 ++++ UefiCpuPkg/Include/Library/UefiCpuLib.h | 61 -----------= ---- UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf | 8 +- UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm | 68 -----------= ----- UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm | 51 ------------ 6 files changed, 17 insertions(+), 268 deletions(-) diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c b/UefiCpuPk= g/Library/BaseUefiCpuLib/BaseUefiCpuLib.c deleted file mode 100644 index 5d925bc273f8..000000000000 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c +++ /dev/null @@ -1,81 +0,0 @@ -/** @file - This library defines some routines that are generic for IA32 family CPU. - - The library routines are UEFI specification compliant. - - Copyright (c) 2020, AMD Inc. All rights reserved.
- Copyright (c) 2021, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include -#include - -#include -#include - -/** - Determine if the standard CPU signature is "AuthenticAMD". - - @retval TRUE The CPU signature matches. - @retval FALSE The CPU signature does not match. - -**/ -BOOLEAN -EFIAPI -StandardSignatureIsAuthenticAMD ( - VOID - ) -{ - UINT32 RegEbx; - UINT32 RegEcx; - UINT32 RegEdx; - - AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx); - return (RegEbx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EBX && - RegEcx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_ECX && - RegEdx =3D=3D CPUID_SIGNATURE_AUTHENTIC_AMD_EDX); -} - -/** - Return the 32bit CPU family and model value. - - @return CPUID[01h].EAX with Processor Type and Stepping ID cleared. -**/ -UINT32 -EFIAPI -GetCpuFamilyModel ( - VOID - ) -{ - CPUID_VERSION_INFO_EAX Eax; - - AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL); - - // - // Mask other fields than Family and Model. - // - Eax.Bits.SteppingId =3D 0; - Eax.Bits.ProcessorType =3D 0; - Eax.Bits.Reserved1 =3D 0; - Eax.Bits.Reserved2 =3D 0; - return Eax.Uint32; -} - -/** - Return the CPU stepping ID. - @return CPU stepping ID value in CPUID[01h].EAX. -**/ -UINT8 -EFIAPI -GetCpuSteppingId ( - VOID - ) -{ - CPUID_VERSION_INFO_EAX Eax; - - AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL); - - return (UINT8)Eax.Bits.SteppingId; -} diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c b/UefiC= puPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c new file mode 100644 index 000000000000..eaecd4ae5ed7 --- /dev/null +++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c @@ -0,0 +1,16 @@ +/** @file +This library contains a dummy function to pass build. + +Copyright (c) 2022, Intel Corporation. All rights reserved. + +SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include +STATIC +VOID +Dummy ( + VOID + ) +{ + +} diff --git a/UefiCpuPkg/Include/Library/UefiCpuLib.h b/UefiCpuPkg/Include/L= ibrary/UefiCpuLib.h index 0ff4a35774c1..c9de5a62d991 100644 --- a/UefiCpuPkg/Include/Library/UefiCpuLib.h +++ b/UefiCpuPkg/Include/Library/UefiCpuLib.h @@ -1,65 +1,4 @@ -/** @file - Public header file for UEFI CPU library class. - - This library class defines some routines that are generic for IA32 famil= y CPU - to be UEFI specification compliant. - - Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
- Copyright (c) 2020, AMD Inc. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - #ifndef __UEFI_CPU_LIB_H__ #define __UEFI_CPU_LIB_H__ =20 -/** - Initializes floating point units for requirement of UEFI specification. - - This function initializes floating-point control word to 0x027F (all exc= eptions - masked,double-precision, round-to-nearest) and multimedia-extensions con= trol word - (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush= to zero - for masked underflow). - -**/ -VOID -EFIAPI -InitializeFloatingPointUnits ( - VOID - ); - -/** - Determine if the standard CPU signature is "AuthenticAMD". - - @retval TRUE The CPU signature matches. - @retval FALSE The CPU signature does not match. - -**/ -BOOLEAN -EFIAPI -StandardSignatureIsAuthenticAMD ( - VOID - ); - -/** - Return the 32bit CPU family and model value. - - @return CPUID[01h].EAX with Processor Type and Stepping ID cleared. -**/ -UINT32 -EFIAPI -GetCpuFamilyModel ( - VOID - ); - -/** - Return the CPU stepping ID. - @return CPU stepping ID value in CPUID[01h].EAX. -**/ -UINT8 -EFIAPI -GetCpuSteppingId ( - VOID - ); - #endif diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf b/UefiCpu= Pkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf index 34d3a7bb4303..9f8b62d87aae 100644 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf +++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf @@ -24,14 +24,8 @@ # VALID_ARCHITECTURES =3D IA32 X64 # =20 -[Sources.IA32] - Ia32/InitializeFpu.nasm - -[Sources.X64] - X64/InitializeFpu.nasm - [Sources] - BaseUefiCpuLib.c + BaseUefiCpuLibNull.c =20 [Packages] MdePkg/MdePkg.dec diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm b/Ue= fiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm deleted file mode 100644 index 5e27cc325012..000000000000 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm +++ /dev/null @@ -1,68 +0,0 @@ -;-------------------------------------------------------------------------= ----- -;* -;* Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
-;* SPDX-License-Identifier: BSD-2-Clause-Patent -;* -;* -;-------------------------------------------------------------------------= ----- - - SECTION .rodata - -; -; Float control word initial value: -; all exceptions masked, double-precision, round-to-nearest -; -mFpuControlWord: DW 0x27F -; -; Multimedia-extensions control word: -; all exceptions masked, round-to-nearest, flush to zero for masked underf= low -; -mMmxControlWord: DD 0x1F80 - - SECTION .text - -; -; Initializes floating point units for requirement of UEFI specification. -; -; This function initializes floating-point control word to 0x027F (all exc= eptions -; masked,double-precision, round-to-nearest) and multimedia-extensions con= trol word -; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush= to zero -; for masked underflow). -; -global ASM_PFX(InitializeFloatingPointUnits) -ASM_PFX(InitializeFloatingPointUnits): - - push ebx - - ; - ; Initialize floating point units - ; - finit - fldcw [mFpuControlWord] - - ; - ; Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] =3D 1) to test - ; whether the processor supports SSE instruction. - ; - mov eax, 1 - cpuid - bt edx, 25 - jnc Done - - ; - ; Set OSFXSR bit 9 in CR4 - ; - mov eax, cr4 - or eax, BIT9 - mov cr4, eax - - ; - ; The processor should support SSE instruction and we can use - ; ldmxcsr instruction - ; - ldmxcsr [mMmxControlWord] -Done: - pop ebx - - ret - diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm b/Uef= iCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm deleted file mode 100644 index 8485b4713548..000000000000 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm +++ /dev/null @@ -1,51 +0,0 @@ -;-------------------------------------------------------------------------= ----- -;* -;* Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
-;* SPDX-License-Identifier: BSD-2-Clause-Patent -;* -;* -;-------------------------------------------------------------------------= ----- - - SECTION .rodata -; -; Float control word initial value: -; all exceptions masked, double-extended-precision, round-to-nearest -; -mFpuControlWord: DW 0x37F -; -; Multimedia-extensions control word: -; all exceptions masked, round-to-nearest, flush to zero for masked underf= low -; -mMmxControlWord: DD 0x1F80 - -DEFAULT REL -SECTION .text - -; -; Initializes floating point units for requirement of UEFI specification. -; -; This function initializes floating-point control word to 0x027F (all exc= eptions -; masked,double-precision, round-to-nearest) and multimedia-extensions con= trol word -; (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush= to zero -; for masked underflow). -; -global ASM_PFX(InitializeFloatingPointUnits) -ASM_PFX(InitializeFloatingPointUnits): - - ; - ; Initialize floating point units - ; - finit - fldcw [mFpuControlWord] - - ; - ; Set OSFXSR bit 9 in CR4 - ; - mov rax, cr4 - or rax, BIT9 - mov cr4, rax - - ldmxcsr [mMmxControlWord] - - ret - --=20 2.30.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#88195): https://edk2.groups.io/g/devel/message/88195 Mute This Topic: https://groups.io/mt/90116968/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-