2020-04-07 09:53:22 +02:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// RISC-V Supervisor Mode interrupt enable/disable
|
|
|
|
//
|
|
|
|
// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ASM_GLOBAL ASM_PFX(RiscVDisableSupervisorModeInterrupts)
|
|
|
|
ASM_GLOBAL ASM_PFX(RiscVEnableSupervisorModeInterrupt)
|
|
|
|
ASM_GLOBAL ASM_PFX(RiscVGetSupervisorModeInterrupts)
|
|
|
|
|
2020-07-16 06:35:32 +02:00
|
|
|
#define SSTATUS_SIE 0x00000002
|
|
|
|
#define CSR_SSTATUS 0x100
|
|
|
|
#define SSTATUS_SPP_BIT_POSITION 8
|
2020-04-07 09:53:22 +02:00
|
|
|
|
2020-07-16 06:35:32 +02:00
|
|
|
//
|
|
|
|
// This routine disables supervisor mode interrupt
|
|
|
|
//
|
2020-04-07 09:53:22 +02:00
|
|
|
ASM_PFX(RiscVDisableSupervisorModeInterrupts):
|
2020-07-16 06:35:32 +02:00
|
|
|
add sp, sp, -(__SIZEOF_POINTER__)
|
|
|
|
sd a1, (sp)
|
|
|
|
li a1, SSTATUS_SIE
|
|
|
|
csrc CSR_SSTATUS, a1
|
|
|
|
ld a1, (sp)
|
|
|
|
add sp, sp, (__SIZEOF_POINTER__)
|
2020-04-07 09:53:22 +02:00
|
|
|
ret
|
|
|
|
|
2020-07-16 06:35:32 +02:00
|
|
|
//
|
|
|
|
// This routine enables supervisor mode interrupt
|
|
|
|
//
|
2020-04-07 09:53:22 +02:00
|
|
|
ASM_PFX(RiscVEnableSupervisorModeInterrupt):
|
2020-07-16 06:35:32 +02:00
|
|
|
add sp, sp, -2*(__SIZEOF_POINTER__)
|
|
|
|
sd a0, (0*__SIZEOF_POINTER__)(sp)
|
|
|
|
sd a1, (1*__SIZEOF_POINTER__)(sp)
|
|
|
|
|
|
|
|
csrr a0, CSR_SSTATUS
|
|
|
|
and a0, a0, (1 << SSTATUS_SPP_BIT_POSITION)
|
|
|
|
bnez a0, InTrap // We are in supervisor mode (SMode)
|
|
|
|
// trap handler.
|
|
|
|
// Skip enabling SIE becasue SIE
|
|
|
|
// is set to disabled by RISC-V hart
|
|
|
|
// when the trap takes hart to SMode.
|
|
|
|
|
|
|
|
li a1, SSTATUS_SIE
|
|
|
|
csrs CSR_SSTATUS, a1
|
|
|
|
InTrap:
|
|
|
|
ld a0, (0*__SIZEOF_POINTER__)(sp)
|
|
|
|
ld a1, (1*__SIZEOF_POINTER__)(sp)
|
|
|
|
add sp, sp, 2*(__SIZEOF_POINTER__)
|
2020-04-07 09:53:22 +02:00
|
|
|
ret
|
|
|
|
|
2020-07-16 06:35:32 +02:00
|
|
|
//
|
|
|
|
// This routine returns supervisor mode interrupt
|
|
|
|
// status.
|
|
|
|
//
|
2020-04-07 09:53:22 +02:00
|
|
|
ASM_PFX(RiscVGetSupervisorModeInterrupts):
|
|
|
|
csrr a0, CSR_SSTATUS
|
2020-07-16 06:35:32 +02:00
|
|
|
andi a0, a0, SSTATUS_SIE
|
2020-04-07 09:53:22 +02:00
|
|
|
ret
|
|
|
|
|