Line 50... |
Line 50... |
uint64_t neorv32_cpu_get_instret(void);
|
uint64_t neorv32_cpu_get_instret(void);
|
void neorv32_cpu_set_minstret(uint64_t value);
|
void neorv32_cpu_set_minstret(uint64_t value);
|
uint64_t neorv32_cpu_get_systime(void);
|
uint64_t neorv32_cpu_get_systime(void);
|
void neorv32_cpu_delay_ms(int16_t time_ms);
|
void neorv32_cpu_delay_ms(int16_t time_ms);
|
void __attribute__((naked)) neorv32_cpu_goto_user_mode(void);
|
void __attribute__((naked)) neorv32_cpu_goto_user_mode(void);
|
int neorv32_cpu_atomic_cas(uint32_t addr, uint32_t expected, uint32_t desired);
|
|
uint32_t neorv32_cpu_pmp_get_num_regions(void);
|
uint32_t neorv32_cpu_pmp_get_num_regions(void);
|
uint32_t neorv32_cpu_pmp_get_granularity(void);
|
uint32_t neorv32_cpu_pmp_get_granularity(void);
|
int neorv32_cpu_pmp_configure_region(uint32_t index, uint32_t base, uint32_t size, uint8_t config);
|
int neorv32_cpu_pmp_configure_region(uint32_t index, uint32_t base, uint32_t size, uint8_t config);
|
uint32_t neorv32_cpu_hpm_get_counters(void);
|
uint32_t neorv32_cpu_hpm_get_counters(void);
|
uint32_t neorv32_cpu_hpm_get_size(void);
|
uint32_t neorv32_cpu_hpm_get_size(void);
|
Line 66... |
Line 65... |
*
|
*
|
* @note An unaligned access address will raise an alignment exception.
|
* @note An unaligned access address will raise an alignment exception.
|
*
|
*
|
* @param[in] addr Address (32-bit).
|
* @param[in] addr Address (32-bit).
|
* @param[in] wdata Data word (32-bit) to store.
|
* @param[in] wdata Data word (32-bit) to store.
|
|
* @return Operation status (32-bit).
|
|
**************************************************************************/
|
|
inline uint32_t __attribute__ ((always_inline)) neorv32_cpu_store_conditional(uint32_t addr, uint32_t wdata) {
|
|
|
|
#if defined __riscv_atomic || defined __riscv_a
|
|
register uint32_t reg_addr = addr;
|
|
register uint32_t reg_data = wdata;
|
|
register uint32_t reg_status;
|
|
|
|
asm volatile ("sc.w %[status], %[da], (%[ad])" : [status] "=r" (reg_status) : [da] "r" (reg_data), [ad] "r" (reg_addr));
|
|
|
|
return reg_status;
|
|
#else
|
|
return 1; // always failing
|
|
#endif
|
|
}
|
|
|
|
|
|
/**********************************************************************//**
|
|
* Conditional store unsigned word to address space if atomic access reservation is valid.
|
|
*
|
|
* @note An unaligned access address will raise an alignment exception.
|
|
*
|
|
* @param[in] addr Address (32-bit).
|
|
* @param[in] wdata Data word (32-bit) to store.
|
**************************************************************************/
|
**************************************************************************/
|
inline void __attribute__ ((always_inline)) neorv32_cpu_store_unsigned_word(uint32_t addr, uint32_t wdata) {
|
inline void __attribute__ ((always_inline)) neorv32_cpu_store_unsigned_word(uint32_t addr, uint32_t wdata) {
|
|
|
register uint32_t reg_addr = addr;
|
register uint32_t reg_addr = addr;
|
register uint32_t reg_data = wdata;
|
register uint32_t reg_data = wdata;
|
Line 109... |
Line 133... |
asm volatile ("sb %[da], 0(%[ad])" : : [da] "r" (reg_data), [ad] "r" (reg_addr));
|
asm volatile ("sb %[da], 0(%[ad])" : : [da] "r" (reg_data), [ad] "r" (reg_addr));
|
}
|
}
|
|
|
|
|
/**********************************************************************//**
|
/**********************************************************************//**
|
|
* Load unsigned word from address space and make reservation for atomic access.
|
|
*
|
|
* @note An unaligned access address will raise an alignment exception.
|
|
*
|
|
* @param[in] addr Address (32-bit).
|
|
* @return Read data word (32-bit).
|
|
**************************************************************************/
|
|
inline uint32_t __attribute__ ((always_inline)) neorv32_cpu_load_reservate_word(uint32_t addr) {
|
|
|
|
register uint32_t reg_addr = addr;
|
|
register uint32_t reg_data;
|
|
|
|
#if defined __riscv_atomic || defined __riscv_a
|
|
asm volatile ("lr.w %[da], 0(%[ad])" : [da] "=r" (reg_data) : [ad] "r" (reg_addr));
|
|
#else
|
|
asm volatile ("lw %[da], 0(%[ad])" : [da] "=r" (reg_data) : [ad] "r" (reg_addr));
|
|
#endif
|
|
|
|
return (uint32_t)reg_data;
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************//**
|
* Load unsigned word from address space.
|
* Load unsigned word from address space.
|
*
|
*
|
* @note An unaligned access address will raise an alignment exception.
|
* @note An unaligned access address will raise an alignment exception.
|
*
|
*
|
* @param[in] addr Address (32-bit).
|
* @param[in] addr Address (32-bit).
|