NMSIS-Core
Version 1.2.0
NMSIS-Core support for Nuclei processor-based devices
|
Functions to access the Core CSR Registers. More...
Macros | |
#define | __RV_CSR_SWAP(csr, val) |
CSR operation Macro for csrrw instruction. More... | |
#define | __RV_CSR_READ(csr) |
CSR operation Macro for csrr instruction. More... | |
#define | __RV_CSR_WRITE(csr, val) |
CSR operation Macro for csrw instruction. More... | |
#define | __RV_CSR_READ_SET(csr, val) |
CSR operation Macro for csrrs instruction. More... | |
#define | __RV_CSR_SET(csr, val) |
CSR operation Macro for csrs instruction. More... | |
#define | __RV_CSR_READ_CLEAR(csr, val) |
CSR operation Macro for csrrc instruction. More... | |
#define | __RV_CSR_CLEAR(csr, val) |
CSR operation Macro for csrc instruction. More... | |
Functions | |
__STATIC_FORCEINLINE void | __switch_mode (uint8_t mode, uintptr_t stack, void(*entry_point)(void)) |
switch privilege from machine mode to others. More... | |
__STATIC_FORCEINLINE void | __enable_irq (void) |
Enable IRQ Interrupts. More... | |
__STATIC_FORCEINLINE void | __disable_irq (void) |
Disable IRQ Interrupts. More... | |
__STATIC_FORCEINLINE void | __enable_irq_s (void) |
Enable IRQ Interrupts in supervisor mode. More... | |
__STATIC_FORCEINLINE void | __disable_irq_s (void) |
Disable IRQ Interrupts in supervisor mode. More... | |
__STATIC_FORCEINLINE uint64_t | __get_rv_cycle (void) |
Read whole 64 bits value of mcycle counter. More... | |
__STATIC_FORCEINLINE uint64_t | __get_rv_instret (void) |
Read whole 64 bits value of machine instruction-retired counter. More... | |
__STATIC_FORCEINLINE uint64_t | __get_rv_time (void) |
Read whole 64 bits value of real-time clock. More... | |
__STATIC_FORCEINLINE unsigned long | __get_cluster_id (void) |
Get cluster id of current cluster. More... | |
__STATIC_FORCEINLINE unsigned long | __get_hart_index (void) |
Get hart index of current cluster. More... | |
__STATIC_FORCEINLINE unsigned long | __get_hart_id (void) |
Get hart id of current cluster. More... | |
Functions to access the Core CSR Registers.
The following functions or macros provide access to Core CSR registers.
#define __RV_CSR_CLEAR | ( | csr, | |
val | |||
) |
CSR operation Macro for csrc instruction.
Set csr register to be csr_content & ~val
csr | CSR macro definition defined in Core CSR Registers, eg. CSR_MSTATUS |
val | Mask value to be used wih csrc instruction |
Definition at line 573 of file core_feature_base.h.
#define __RV_CSR_READ | ( | csr | ) |
CSR operation Macro for csrr instruction.
Read the content of csr register to __v and return it
csr | CSR macro definition defined in Core CSR Registers, eg. CSR_MSTATUS |
Definition at line 481 of file core_feature_base.h.
#define __RV_CSR_READ_CLEAR | ( | csr, | |
val | |||
) |
CSR operation Macro for csrrc instruction.
Read the content of csr register to __v, then set csr register to be __v & ~val, then return __v
csr | CSR macro definition defined in Core CSR Registers, eg. CSR_MSTATUS |
val | Mask value to be used wih csrrc instruction |
Definition at line 555 of file core_feature_base.h.
#define __RV_CSR_READ_SET | ( | csr, | |
val | |||
) |
CSR operation Macro for csrrs instruction.
Read the content of csr register to __v, then set csr register to be __v | val, then return __v
csr | CSR macro definition defined in Core CSR Registers, eg. CSR_MSTATUS |
val | Mask value to be used wih csrrs instruction |
Definition at line 518 of file core_feature_base.h.
#define __RV_CSR_SET | ( | csr, | |
val | |||
) |
CSR operation Macro for csrs instruction.
Set csr register to be csr_content | val
csr | CSR macro definition defined in Core CSR Registers, eg. CSR_MSTATUS |
val | Mask value to be used wih csrs instruction |
Definition at line 536 of file core_feature_base.h.
#define __RV_CSR_SWAP | ( | csr, | |
val | |||
) |
CSR operation Macro for csrrw instruction.
Read the content of csr register to __v, then write content of val into csr register, then return __v
csr | CSR macro definition defined in Core CSR Registers, eg. CSR_MSTATUS |
val | value to store into the CSR register |
Definition at line 463 of file core_feature_base.h.
#define __RV_CSR_WRITE | ( | csr, | |
val | |||
) |
CSR operation Macro for csrw instruction.
Write the content of val to csr register
csr | CSR macro definition defined in Core CSR Registers, eg. CSR_MSTATUS |
val | value to store into the CSR register |
Definition at line 499 of file core_feature_base.h.
__STATIC_FORCEINLINE void __disable_irq | ( | void | ) |
Disable IRQ Interrupts.
Disables IRQ interrupts by clearing the MIE-bit in the MSTATUS Register.
Definition at line 644 of file core_feature_base.h.
References __RV_CSR_CLEAR, CSR_MSTATUS, and MSTATUS_MIE.
__STATIC_FORCEINLINE void __disable_irq_s | ( | void | ) |
Disable IRQ Interrupts in supervisor mode.
Disables IRQ interrupts by clearing the SIE-bit in the SSTATUS Register.
Definition at line 666 of file core_feature_base.h.
References __RV_CSR_CLEAR, CSR_SSTATUS, and SSTATUS_SIE.
__STATIC_FORCEINLINE void __enable_irq | ( | void | ) |
Enable IRQ Interrupts.
Enables IRQ interrupts by setting the MIE-bit in the MSTATUS Register.
Definition at line 633 of file core_feature_base.h.
References __RV_CSR_SET, CSR_MSTATUS, and MSTATUS_MIE.
__STATIC_FORCEINLINE void __enable_irq_s | ( | void | ) |
Enable IRQ Interrupts in supervisor mode.
Enables IRQ interrupts by setting the SIE-bit in the SSTATUS Register.
Definition at line 655 of file core_feature_base.h.
References __RV_CSR_SET, CSR_SSTATUS, and SSTATUS_SIE.
__STATIC_FORCEINLINE unsigned long __get_cluster_id | ( | void | ) |
Get cluster id of current cluster.
This function will get cluster id of current cluster in a multiple cluster system
Definition at line 760 of file core_feature_base.h.
References __RV_CSR_READ, and CSR_MHARTID.
__STATIC_FORCEINLINE unsigned long __get_hart_id | ( | void | ) |
Get hart id of current cluster.
This function will get hart id of current cluster in a multiple cluster system
Definition at line 796 of file core_feature_base.h.
References __RV_CSR_READ, and CSR_MHARTID.
__STATIC_FORCEINLINE unsigned long __get_hart_index | ( | void | ) |
Get hart index of current cluster.
This function will get hart index of current cluster in a multiple cluster system, hart index is hartid - hartid offset, for example if your hartid is 1, and offset is 1, then hart index is 0
Definition at line 776 of file core_feature_base.h.
References __RV_CSR_READ, and CSR_MHARTID.
__STATIC_FORCEINLINE uint64_t __get_rv_cycle | ( | void | ) |
Read whole 64 bits value of mcycle counter.
This function will read the whole 64 bits of MCYCLE register
Definition at line 677 of file core_feature_base.h.
References __RV_CSR_READ, CSR_MCYCLE, and CSR_MCYCLEH.
Referenced by __get_hpm_counter().
__STATIC_FORCEINLINE uint64_t __get_rv_instret | ( | void | ) |
Read whole 64 bits value of machine instruction-retired counter.
This function will read the whole 64 bits of MINSTRET register
Definition at line 704 of file core_feature_base.h.
References __RV_CSR_READ, CSR_MINSTRET, and CSR_MINSTRETH.
Referenced by __get_hpm_counter().
__STATIC_FORCEINLINE uint64_t __get_rv_time | ( | void | ) |
Read whole 64 bits value of real-time clock.
This function will read the whole 64 bits of TIME register
Definition at line 732 of file core_feature_base.h.
References __RV_CSR_READ, CSR_TIME, and CSR_TIMEH.
__STATIC_FORCEINLINE void __switch_mode | ( | uint8_t | mode, |
uintptr_t | stack, | ||
void(*)(void) | entry_point | ||
) |
switch privilege from machine mode to others.
Execute into entry_point in mode(supervisor or user) with given stack
mode | privilege mode |
stack | predefined stack, size should set enough |
entry_point | a function pointer to execute |
Definition at line 605 of file core_feature_base.h.
References __ASM, __RV_CSR_READ, __RV_CSR_WRITE, CSR_MEPC, CSR_MSTATUS, MSTATUS_MPIE, and MSTATUS_MPP.