mirror of https://github.com/acidanthera/audk.git
MdePkg: Implement RISC-V Cache Management Operations
Implement Cache Management Operations (CMO) defined by RISC-V spec https://github.com/riscv/riscv-CMOs. Notes: 1. CMO only supports block based Operations. Meaning cache flush/invd/clean Operations are not available for the entire range. In that case we fallback on fence.i instructions. 2. Operations are implemented using Opcodes to make them compiler independent. binutils 2.39+ compilers support CMO instructions. Test: 1. Ensured correct instructions are refelecting in asm 2. Qemu implements basic support for CMO operations in that it allwos instructions without exceptions. Verified it works properly in that sense. 3. SG2042Pkg implements CMO-like instructions. It was verified that CpuFlushCpuDataCache works fine. This more of less confirms that framework is alright. 4. TODO: Once Silicon is available with exact instructions, we will further verify this. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Cc: Sunil V L <sunilvl@ventanamicro.com> Cc: Daniel Schaefer <git@danielschaefer.me> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Pedro Falcato <pedro.falcato@gmail.com> Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Sunil V L <sunilvl@...> Reviewed-by: Jingyu Li <jingyu.li01@...>
This commit is contained in:
parent
30faafd024
commit
26727c2ae2
|
@ -226,6 +226,39 @@ RiscVInvalidateDataCacheFenceAsm (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
RISC-V flush cache block. Atomically perform a clean operation
|
||||||
|
followed by an invalidate operation
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
RiscVCpuCacheFlushCmoAsm (
|
||||||
|
IN UINTN
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Perform a write transfer to another cache or to memory if the
|
||||||
|
data in the copy of the cache block have been modified by a store
|
||||||
|
operation
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
RiscVCpuCacheCleanCmoAsm (
|
||||||
|
IN UINTN
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deallocate the copy of the cache block
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
RiscVCpuCacheInvalCmoAsm (
|
||||||
|
IN UINTN
|
||||||
|
);
|
||||||
|
|
||||||
#endif // defined (MDE_CPU_RISCV64)
|
#endif // defined (MDE_CPU_RISCV64)
|
||||||
|
|
||||||
#if defined (MDE_CPU_LOONGARCH64)
|
#if defined (MDE_CPU_LOONGARCH64)
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* RISC-V cache operation encoding.
|
||||||
|
* Copyright (c) 2023, Rivos Inc. All rights reserved.<BR>
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
.macro RISCVCMOFLUSH
|
||||||
|
.word 0x25200f
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.macro RISCVCMOINVALIDATE
|
||||||
|
.word 0x05200f
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.macro RISCVCMOCLEAN
|
||||||
|
.word 0x15200f
|
||||||
|
.endm
|
|
@ -400,7 +400,7 @@
|
||||||
RiscV64/RiscVCpuBreakpoint.S | GCC
|
RiscV64/RiscVCpuBreakpoint.S | GCC
|
||||||
RiscV64/RiscVCpuPause.S | GCC
|
RiscV64/RiscVCpuPause.S | GCC
|
||||||
RiscV64/RiscVInterrupt.S | GCC
|
RiscV64/RiscVInterrupt.S | GCC
|
||||||
RiscV64/FlushCache.S | GCC
|
RiscV64/RiscVCacheMgmt.S | GCC
|
||||||
RiscV64/CpuScratch.S | GCC
|
RiscV64/CpuScratch.S | GCC
|
||||||
RiscV64/ReadTimer.S | GCC
|
RiscV64/ReadTimer.S | GCC
|
||||||
RiscV64/RiscVMmu.S | GCC
|
RiscV64/RiscVMmu.S | GCC
|
||||||
|
|
|
@ -3,10 +3,12 @@
|
||||||
// RISC-V cache operation.
|
// RISC-V cache operation.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
|
// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
|
||||||
|
// Copyright (c) 2023, Rivos Inc. All rights reserved.<BR>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
//
|
//
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
.include "RiscVasm.inc"
|
||||||
|
|
||||||
.align 3
|
.align 3
|
||||||
ASM_GLOBAL ASM_PFX(RiscVInvalidateInstCacheFenceAsm)
|
ASM_GLOBAL ASM_PFX(RiscVInvalidateInstCacheFenceAsm)
|
||||||
|
@ -19,3 +21,18 @@ ASM_PFX(RiscVInvalidateInstCacheFenceAsm):
|
||||||
ASM_PFX(RiscVInvalidateDataCacheFenceAsm):
|
ASM_PFX(RiscVInvalidateDataCacheFenceAsm):
|
||||||
fence
|
fence
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
ASM_GLOBAL ASM_PFX (RiscVCpuCacheFlushCmoAsm)
|
||||||
|
ASM_PFX (RiscVCpuCacheFlushCmoAsm):
|
||||||
|
RISCVCMOFLUSH
|
||||||
|
ret
|
||||||
|
|
||||||
|
ASM_GLOBAL ASM_PFX (RiscVCpuCacheCleanCmoAsm)
|
||||||
|
ASM_PFX (RiscVCpuCacheCleanCmoAsm):
|
||||||
|
RISCVCMOCLEAN
|
||||||
|
ret
|
||||||
|
|
||||||
|
ASM_GLOBAL ASM_PFX (RiscVCpuCacheInvalCmoAsm)
|
||||||
|
ASM_PFX (RiscVCpuCacheInvalCmoAsm):
|
||||||
|
RISCVCMOINVALIDATE
|
||||||
|
ret
|
Loading…
Reference in New Issue