public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Yu Pu <yu.pu@intel.com>
To: devel@edk2.groups.io
Cc: Yu Pu <yu.pu@intel.com>, Eric Dong <eric.dong@intel.com>,
	Ray Ni <ray.ni@intel.com>, Rahul Kumar <rahul1.kumar@intel.com>
Subject: [PATCH v1 08/15] UefiCpuPkg: Move API and implementation from UefiCpuLib to CpuLib
Date: Mon, 11 Apr 2022 17:45:48 +0800	[thread overview]
Message-ID: <20220411094555.1375-9-yu.pu@intel.com> (raw)
In-Reply-To: <20220411094555.1375-1-yu.pu@intel.com>

There are two libraries: MdePkg/CpuLib and UefiCpuPkg/UefiCpuLib. This
patch merges UefiCpuPkg/UefiCpuLib to MdePkg/CpuLib.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Yu Pu <yu.pu@intel.com>
---
 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c        | 81 --------------------
 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c    | 16 ++++
 UefiCpuPkg/Include/Library/UefiCpuLib.h                   | 53 -------------
 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(+), 260 deletions(-)

diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c b/UefiCpuPkg/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.<BR>
-  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <Register/Intel/Cpuid.h>
-#include <Register/Amd/Cpuid.h>
-
-#include <Library/BaseLib.h>
-#include <Library/UefiCpuLib.h>
-
-/**
-  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 == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&
-          RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&
-          RegEdx == 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    = 0;
-  Eax.Bits.ProcessorType = 0;
-  Eax.Bits.Reserved1     = 0;
-  Eax.Bits.Reserved2     = 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/UefiCpuPkg/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 <Base.h>
+STATIC
+VOID
+Dummy (
+  VOID
+  )
+{
+
+}
diff --git a/UefiCpuPkg/Include/Library/UefiCpuLib.h b/UefiCpuPkg/Include/Library/UefiCpuLib.h
index 0ff4a35774c1..88fc69494c1c 100644
--- a/UefiCpuPkg/Include/Library/UefiCpuLib.h
+++ b/UefiCpuPkg/Include/Library/UefiCpuLib.h
@@ -1,65 +1,12 @@
 /** @file
   Public header file for UEFI CPU library class.
-
   This library class defines some routines that are generic for IA32 family CPU
   to be UEFI specification compliant.
-
   Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2020, AMD Inc. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
-
 **/
-
 #ifndef __UEFI_CPU_LIB_H__
 #define __UEFI_CPU_LIB_H__
 
-/**
-  Initializes floating point units for requirement of UEFI specification.
-
-  This function initializes floating-point control word to 0x027F (all exceptions
-  masked,double-precision, round-to-nearest) and multimedia-extensions control 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/UefiCpuPkg/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           = IA32 X64
 #
 
-[Sources.IA32]
-  Ia32/InitializeFpu.nasm
-
-[Sources.X64]
-  X64/InitializeFpu.nasm
-
 [Sources]
-  BaseUefiCpuLib.c
+  BaseUefiCpuLibNull.c
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm b/UefiCpuPkg/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.<BR>
-;*   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 underflow
-;
-mMmxControlWord: DD 0x1F80
-
-    SECTION .text
-
-;
-; Initializes floating point units for requirement of UEFI specification.
-;
-; This function initializes floating-point control word to 0x027F (all exceptions
-; masked,double-precision, round-to-nearest) and multimedia-extensions control 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] = 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/UefiCpuPkg/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.<BR>
-;*   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 underflow
-;
-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 exceptions
-; masked,double-precision, round-to-nearest) and multimedia-extensions control 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
-
-- 
2.30.0.windows.2


  parent reply	other threads:[~2022-04-11  9:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11  9:45 [PATCH v1 00/15] Merge UefiCpuPkg/UefiCpuLib to MdePkg/CpuLib Yu Pu
2022-04-11  9:45 ` [PATCH v1 01/15] IntelFsp2Pkg: Add CpuLib to module INFs that depend on UefiCpuLib Yu Pu
2022-04-11  9:49   ` Zeng, Star
2022-04-12  3:35   ` Chiu, Chasel
2022-04-11  9:45 ` [PATCH v1 02/15] IntelFsp2WrapperPkg: " Yu Pu
2022-04-12  3:35   ` Chiu, Chasel
2022-04-11  9:45 ` [PATCH v1 03/15] MdePkg: " Yu Pu
2022-04-11  9:45 ` [PATCH v1 04/15] OvmfPkg: " Yu Pu
2022-04-11  9:45 ` [PATCH v1 05/15] UefiCpuPkg: " Yu Pu
2022-04-11  9:45 ` [PATCH v1 06/15] UefiPayloadPkg: " Yu Pu
2022-04-11  9:45 ` [PATCH v1 07/15] MdePkg: Move API and implementation from UefiCpuLib to CpuLib Yu Pu
2022-04-11  9:45 ` Yu Pu [this message]
2022-04-11  9:45 ` [PATCH v1 09/15] IntelFsp2Pkg: Remove UefiCpuLib from module INFs Yu Pu
2022-04-12  3:36   ` Chiu, Chasel
2022-04-11  9:45 ` [PATCH v1 10/15] OvmfPkg: " Yu Pu
2022-04-11  9:45 ` [PATCH v1 11/15] PcAtChipsetPkg: " Yu Pu
2022-04-11  9:45 ` [PATCH v1 12/15] SourceLevelDebugPkg: " Yu Pu
2022-04-11  9:45 ` [PATCH v1 13/15] UefiCpuPkg: " Yu Pu
2022-04-11  9:45 ` [PATCH v1 14/15] UefiPayloadPkg: " Yu Pu
2022-04-11  9:45 ` [PATCH v1 15/15] UefiCpuLib: Remove UefiCpuLib Yu Pu
2022-04-12  1:05 ` 回复: [edk2-devel] [PATCH v1 00/15] Merge UefiCpuPkg/UefiCpuLib to MdePkg/CpuLib gaoliming
  -- strict thread matches above, loose matches on Subject: below --
2022-03-29  6:36 [PATCH v1 00/15] Merge UefiCpuLib to CpuLib Yu Pu
2022-03-29  6:36 ` [PATCH v1 08/15] UefiCpuPkg: Move API and implementation from " Yu Pu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220411094555.1375-9-yu.pu@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox