From e986f4ce969e8d95a966dd2f19a3559b336e48f5 Mon Sep 17 00:00:00 2001 From: "Liu, Zhiguang" Date: Mon, 12 Dec 2022 15:30:22 +0800 Subject: MdePkg/BaseCpuLib: Remove assembly for CpuFlushTlb For different compilers, both IA32 and X64 can use Ia32/CpuFlushTlbGcc.c, which is C code (no inline assembly code). To simplify, remove other assemly file for CpuFlushTlb, and rename Ia32/CpuFlushTlbGcc.c to X86CpuFlushTlb.c. Reviewed-by: Michael D Kinney Cc: Liming Gao Signed-off-by: Ray Ni Signed-off-by: Zhiguang Liu --- MdePkg/Library/BaseCpuLib/BaseCpuLib.inf | 10 +++----- MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.c | 25 ------------------- MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.nasm | 31 ------------------------ MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlbGcc.c | 25 ------------------- MdePkg/Library/BaseCpuLib/X64/CpuFlushTlb.nasm | 32 ------------------------- MdePkg/Library/BaseCpuLib/X86CpuFlushTlb.c | 25 +++++++++++++++++++ 6 files changed, 28 insertions(+), 120 deletions(-) delete mode 100644 MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.c delete mode 100644 MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.nasm delete mode 100644 MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlbGcc.c delete mode 100644 MdePkg/Library/BaseCpuLib/X64/CpuFlushTlb.nasm create mode 100644 MdePkg/Library/BaseCpuLib/X86CpuFlushTlb.c (limited to 'MdePkg/Library') diff --git a/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf b/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf index 6b230f6e6d..5b18343c59 100644 --- a/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf +++ b/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf @@ -4,7 +4,7 @@ # CPU Library implemented using ASM functions for IA32, X64, ARM, AARCH64, # PAL CALLs for IPF, and empty functions for EBC. # -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
# Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.
@@ -31,16 +31,12 @@ [Sources.IA32] Ia32/CpuSleep.c | MSFT - Ia32/CpuFlushTlb.c | MSFT - Ia32/CpuSleep.nasm| INTEL - Ia32/CpuFlushTlb.nasm| INTEL - Ia32/CpuSleepGcc.c | GCC - Ia32/CpuFlushTlbGcc.c | GCC + X86CpuFlushTlb.c [Sources.X64] - X64/CpuFlushTlb.nasm + X86CpuFlushTlb.c X64/CpuSleep.nasm diff --git a/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.c b/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.c deleted file mode 100644 index 549f4eb8a0..0000000000 --- a/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.c +++ /dev/null @@ -1,25 +0,0 @@ -/** @file - CpuFlushTlb function. - - Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -/** - Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. - - Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. - -**/ -VOID -EFIAPI -CpuFlushTlb ( - VOID - ) -{ - _asm { - mov eax, cr3 - mov cr3, eax - } -} diff --git a/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.nasm b/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.nasm deleted file mode 100644 index bc3b68e3f2..0000000000 --- a/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlb.nasm +++ /dev/null @@ -1,31 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2006, Intel Corporation. All rights reserved.
-; SPDX-License-Identifier: BSD-2-Clause-Patent -; -; Module Name: -; -; CpuFlushTlb.Asm -; -; Abstract: -; -; CpuFlushTlb function -; -; Notes: -; -;------------------------------------------------------------------------------ - - SECTION .text - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; CpuFlushTlb ( -; VOID -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(CpuFlushTlb) -ASM_PFX(CpuFlushTlb): - mov eax, cr3 - mov cr3, eax ; moving to CR3 flushes TLB - ret - diff --git a/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlbGcc.c b/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlbGcc.c deleted file mode 100644 index ee44f2ea6e..0000000000 --- a/MdePkg/Library/BaseCpuLib/Ia32/CpuFlushTlbGcc.c +++ /dev/null @@ -1,25 +0,0 @@ -/** @file - CpuFlushTlb function for Ia32/X64 GCC. - - Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include - -/** - Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. - - Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. - -**/ -VOID -EFIAPI -CpuFlushTlb ( - VOID - ) -{ - AsmWriteCr3 (AsmReadCr3 ()); -} diff --git a/MdePkg/Library/BaseCpuLib/X64/CpuFlushTlb.nasm b/MdePkg/Library/BaseCpuLib/X64/CpuFlushTlb.nasm deleted file mode 100644 index 8ddf7a2864..0000000000 --- a/MdePkg/Library/BaseCpuLib/X64/CpuFlushTlb.nasm +++ /dev/null @@ -1,32 +0,0 @@ -;------------------------------------------------------------------------------ ; -; Copyright (c) 2006, Intel Corporation. All rights reserved.
-; SPDX-License-Identifier: BSD-2-Clause-Patent -; -; Module Name: -; -; CpuFlushTlb.Asm -; -; Abstract: -; -; CpuFlushTlb function -; -; Notes: -; -;------------------------------------------------------------------------------ - - DEFAULT REL - SECTION .text - -;------------------------------------------------------------------------------ -; VOID -; EFIAPI -; CpuFlushTlb ( -; VOID -; ); -;------------------------------------------------------------------------------ -global ASM_PFX(CpuFlushTlb) -ASM_PFX(CpuFlushTlb): - mov rax, cr3 - mov cr3, rax - ret - diff --git a/MdePkg/Library/BaseCpuLib/X86CpuFlushTlb.c b/MdePkg/Library/BaseCpuLib/X86CpuFlushTlb.c new file mode 100644 index 0000000000..17a351d054 --- /dev/null +++ b/MdePkg/Library/BaseCpuLib/X86CpuFlushTlb.c @@ -0,0 +1,25 @@ +/** @file + CpuFlushTlb function for Ia32/X64. + + Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
+ Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/** + Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. + + Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU. + +**/ +VOID +EFIAPI +CpuFlushTlb ( + VOID + ) +{ + AsmWriteCr3 (AsmReadCr3 ()); +} -- cgit v1.2.3