adds csr access functions
This commit is contained in:
1
env/riscv_vp/platform.h
vendored
1
env/riscv_vp/platform.h
vendored
@@ -21,6 +21,7 @@
|
|||||||
#include "minres/devices/qspi.h"
|
#include "minres/devices/qspi.h"
|
||||||
#include "minres/devices/timer.h"
|
#include "minres/devices/timer.h"
|
||||||
#include "minres/devices/uart.h"
|
#include "minres/devices/uart.h"
|
||||||
|
#include <riscv/riscv_csr.h>
|
||||||
|
|
||||||
#define PERIPH(TYPE, ADDR) ((volatile TYPE*)(ADDR))
|
#define PERIPH(TYPE, ADDR) ((volatile TYPE*)(ADDR))
|
||||||
// values from memory_map.ld
|
// values from memory_map.ld
|
||||||
|
|||||||
@@ -1,27 +1,36 @@
|
|||||||
#ifndef _DEVICES_ACLINT_H
|
#ifndef _DEVICES_ACLINT_H
|
||||||
#define _DEVICES_ACLINT_H
|
#define _DEVICES_ACLINT_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "gen/aclint.h"
|
#include "gen/aclint.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
static void set_aclint_mtime(volatile aclint_t* reg, uint64_t value) {
|
||||||
static void set_aclint_mtime(volatile aclint_t* reg, uint64_t value){
|
|
||||||
set_aclint_mtime_hi(reg, (uint32_t)(value >> 32));
|
set_aclint_mtime_hi(reg, (uint32_t)(value >> 32));
|
||||||
set_aclint_mtime_lo(reg, (uint32_t)value);
|
set_aclint_mtime_lo(reg, (uint32_t)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t get_aclint_mtime(volatile aclint_t* reg){
|
static uint64_t get_aclint_mtime(volatile aclint_t* reg) {
|
||||||
uint64_t value = ((uint64_t)get_aclint_mtime_hi(reg) << 32) | (uint64_t)get_aclint_mtime_lo(reg);
|
// #if ( __riscv_xlen == 64)
|
||||||
return value;
|
// volatile uint64_t *mtime = (volatile uint64_t *)(RISCV_MTIME_ADDR);
|
||||||
|
// return *mtime;
|
||||||
|
// #else
|
||||||
|
uint32_t mtimeh_val;
|
||||||
|
uint32_t mtimel_val;
|
||||||
|
do {
|
||||||
|
mtimeh_val = get_aclint_mtime_hi(reg);
|
||||||
|
mtimel_val = get_aclint_mtime_lo(reg);
|
||||||
|
} while(mtimeh_val != get_aclint_mtime_hi(reg));
|
||||||
|
return (uint64_t)((((uint64_t)mtimeh_val) << 32) | mtimel_val);
|
||||||
|
// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_aclint_mtimecmp(volatile aclint_t* reg, uint64_t value){
|
static void set_aclint_mtimecmp(volatile aclint_t* reg, uint64_t value) {
|
||||||
set_aclint_mtimecmp0lo(reg, (uint32_t)0xFFFFFFFF);
|
set_aclint_mtimecmp0lo(reg, (uint32_t)0xFFFFFFFF);
|
||||||
set_aclint_mtimecmp0hi(reg, (uint32_t)(value >> 32));
|
set_aclint_mtimecmp0hi(reg, (uint32_t)(value >> 32));
|
||||||
set_aclint_mtimecmp0lo(reg, (uint32_t)value);
|
set_aclint_mtimecmp0lo(reg, (uint32_t)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t get_aclint_mtimecmp(volatile aclint_t* reg){
|
static uint64_t get_aclint_mtimecmp(volatile aclint_t* reg) {
|
||||||
uint64_t value = ((uint64_t)get_aclint_mtimecmp0hi(reg) << 32) | (uint64_t)get_aclint_mtimecmp0lo(reg);
|
uint64_t value = ((uint64_t)get_aclint_mtimecmp0hi(reg) << 32) | (uint64_t)get_aclint_mtimecmp0lo(reg);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
3790
include/riscv/riscv_csr.h
Normal file
3790
include/riscv/riscv_csr.h
Normal file
File diff suppressed because it is too large
Load Diff
13609
include/riscv/riscv_csr.hpp
Normal file
13609
include/riscv/riscv_csr.hpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user