2019-02-26 02:02:50 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2005-2019, Haiku, Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Axel Dörfler <axeld@pinc-software.de>
|
|
|
|
* Ingo Weinhold <bonefish@cs.tu-berlin.de>
|
|
|
|
*/
|
|
|
|
#ifndef _KERNEL_ARCH_RISCV64_INT_H
|
|
|
|
#define _KERNEL_ARCH_RISCV64_INT_H
|
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
2021-06-06 16:20:49 +03:00
|
|
|
#include <arch_cpu_defs.h>
|
2019-02-26 02:02:50 +03:00
|
|
|
|
|
|
|
#define NUM_IO_VECTORS 256
|
|
|
|
|
2021-04-22 20:15:57 +03:00
|
|
|
|
2021-11-09 21:39:16 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2021-04-22 20:15:57 +03:00
|
|
|
static inline void
|
|
|
|
arch_int_enable_interrupts_inline(void)
|
|
|
|
{
|
2021-06-06 16:20:49 +03:00
|
|
|
// TODO: Use atomic CSRRS?
|
|
|
|
SstatusReg status(Sstatus());
|
|
|
|
status.ie |= (1 << modeS);
|
|
|
|
SetSstatus(status.val);
|
2021-04-22 20:15:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
arch_int_disable_interrupts_inline(void)
|
|
|
|
{
|
2021-06-06 16:20:49 +03:00
|
|
|
// TODO: Use atomic CSRRC?
|
|
|
|
SstatusReg status(Sstatus());
|
|
|
|
int oldState = ((1 << modeS) & status.ie) != 0;
|
|
|
|
status.ie &= ~(1 << modeS);
|
|
|
|
SetSstatus(status.val);
|
|
|
|
return oldState;
|
2021-04-22 20:15:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
arch_int_restore_interrupts_inline(int oldState)
|
|
|
|
{
|
2021-06-06 16:20:49 +03:00
|
|
|
if (oldState)
|
|
|
|
arch_int_enable_interrupts_inline();
|
2021-04-22 20:15:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
arch_int_are_interrupts_enabled_inline(void)
|
|
|
|
{
|
2021-06-06 16:20:49 +03:00
|
|
|
SstatusReg status(Sstatus());
|
|
|
|
return ((1 << modeS) & status.ie) != 0;
|
2021-04-22 20:15:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// map the functions to the inline versions
|
|
|
|
#define arch_int_enable_interrupts() arch_int_enable_interrupts_inline()
|
|
|
|
#define arch_int_disable_interrupts() arch_int_disable_interrupts_inline()
|
|
|
|
#define arch_int_restore_interrupts(status) \
|
|
|
|
arch_int_restore_interrupts_inline(status)
|
|
|
|
#define arch_int_are_interrupts_enabled() \
|
|
|
|
arch_int_are_interrupts_enabled_inline()
|
|
|
|
|
|
|
|
|
2021-06-06 16:20:49 +03:00
|
|
|
enum {
|
|
|
|
kMSyscallSwitchToSmode = 0,
|
|
|
|
kMSyscallSetTimer = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
extern "C" status_t MSyscall(uint64 op, ...);
|
|
|
|
|
2021-11-09 21:39:16 +03:00
|
|
|
#endif
|
|
|
|
|
2021-06-06 16:20:49 +03:00
|
|
|
|
2019-02-26 02:02:50 +03:00
|
|
|
#endif /* _KERNEL_ARCH_RISCV64_INT_H */
|