MdePkg: Add LoongArch64 local interrupt function set into BaseLib

Adding LoongArch local interrupt function set, which is used to control
the opening or closing of the local interrupt when the global interrupt
is enabled.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Chao Li 2023-10-12 11:08:16 +08:00 committed by Liming Gao
parent 57684402e4
commit 2ff435b264
3 changed files with 54 additions and 10 deletions

View File

@ -307,6 +307,26 @@ SetTlbRebaseAddress (
IN UINT64 IN UINT64
); );
/**
Enables local CPU interrupts.
@param Needs to enable local interrupt bit.
**/
VOID
EnableLocalInterrupts (
IN UINT16
);
/**
Disables local CPU interrupts.
@param Needs to disable local interrupt bit.
**/
VOID
DisableLocalInterrupts (
IN UINT16
);
#endif // defined (MDE_CPU_LOONGARCH64) #endif // defined (MDE_CPU_LOONGARCH64)
// //

View File

@ -1,21 +1,33 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# #
# LoongArch interrupt disable # LoongArch interrupt disable operations
# #
# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR> # Copyright (c) 2024, Loongson Technology Corporation Limited. All rights reserved.<BR>
# #
# SPDX-License-Identifier: BSD-2-Clause-Patent # SPDX-License-Identifier: BSD-2-Clause-Patent
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
#include <Base.h>
#include <Register/LoongArch64/Csr.h>
ASM_GLOBAL ASM_PFX(DisableLocalInterrupts)
ASM_GLOBAL ASM_PFX(DisableInterrupts) ASM_GLOBAL ASM_PFX(DisableInterrupts)
#/** #/**
# Disables CPU interrupts. # Disables local CPU interrupts.
#
# @param Needs to disable local interrupt bit.
#**/ #**/
ASM_PFX(DisableLocalInterrupts):
csrxchg $zero, $a0, LOONGARCH_CSR_ECFG
jirl $zero, $ra, 0
#/**
# Disables global CPU interrupts.
#**/
ASM_PFX(DisableInterrupts): ASM_PFX(DisableInterrupts):
li.w $t0, 0x4 li.w $t0, BIT2
csrxchg $zero, $t0, 0x0 csrxchg $zero, $t0, LOONGARCH_CSR_CRMD
jirl $zero, $ra, 0 jirl $zero, $ra, 0
.end .end

View File

@ -1,21 +1,33 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# #
# LoongArch interrupt enable # LoongArch interrupt enable operations
# #
# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR> # Copyright (c) 2024, Loongson Technology Corporation Limited. All rights reserved.<BR>
# #
# SPDX-License-Identifier: BSD-2-Clause-Patent # SPDX-License-Identifier: BSD-2-Clause-Patent
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
#include <Base.h>
#include <Register/LoongArch64/Csr.h>
ASM_GLOBAL ASM_PFX(EnableLocalInterrupts)
ASM_GLOBAL ASM_PFX(EnableInterrupts) ASM_GLOBAL ASM_PFX(EnableInterrupts)
#/** #/**
# Enables CPU interrupts. # Enables local CPU interrupts.
#
# @param Needs to enable local interrupt bit.
#**/ #**/
ASM_PFX(EnableLocalInterrupts):
csrxchg $a0, $a0, LOONGARCH_CSR_ECFG
jirl $zero, $ra, 0
#/**
# Enables global CPU interrupts.
#**/
ASM_PFX(EnableInterrupts): ASM_PFX(EnableInterrupts):
li.w $t0, 0x4 li.w $t0, BIT2
csrxchg $t0, $t0, 0x0 csrxchg $t0, $t0, LOONGARCH_CSR_CRMD
jirl $zero, $ra, 0 jirl $zero, $ra, 0
.end .end