fixes for ehrenberg platform, minres peripheral functions and nanolib

This commit is contained in:
2024-03-02 12:18:38 +01:00
parent 96fa7db587
commit 6523206738
4 changed files with 36 additions and 31 deletions

15
env/ehrenberg/init.c vendored
View File

@ -5,16 +5,9 @@
#include "platform.h"
#include "encoding.h"
#if __riscv_xlen == 32
#define MCAUSE_INT 0x80000000UL
#define MCAUSE_CAUSE 0x000003FFUL
#else
#define MCAUSE_INT 0x8000000000000000UL
#define MCAUSE_CAUSE 0x00000000000003FFUL
#endif
extern int main(int argc, char** argv);
extern void trap_entry();
extern void trap_entry(void);
#define IRQ_M_SOFT 3
#define IRQ_M_TIMER 7
#define IRQ_M_EXT 11
@ -48,7 +41,7 @@ static uint32_t mtime_hi(void)
return ret;
}
uint64_t get_timer_value()
uint64_t get_timer_value(void)
{
while (1) {
uint32_t hi = mtime_hi();
@ -118,7 +111,7 @@ void _init()
#ifndef NO_INIT
init_pll();
uart_init(115200);
printf("core freq at %d Hz\n", get_cpu_freq());
printf("core freq at %lu Hz\n", get_cpu_freq());
write_csr(mtvec, &trap_entry);
if (read_csr(misa) & (1 << ('F' - 'A'))) { // if F extension is present
write_csr(mstatus, MSTATUS_FS); // allow FPU instructions without trapping
@ -133,6 +126,6 @@ void _init()
}
void _fini()
void _fini(void)
{
}

View File

@ -3,9 +3,13 @@
#ifndef _ISS_PLATFORM_H
#define _ISS_PLATFORM_H
// Some things missing from the official encoding.h
#define MCAUSE_INT 0x80000000
#define MCAUSE_CAUSE 0x7FFFFFFF
#if __riscv_xlen == 32
#define MCAUSE_INT 0x80000000UL
#define MCAUSE_CAUSE 0x000003FFUL
#else
#define MCAUSE_INT 0x8000000000000000UL
#define MCAUSE_CAUSE 0x00000000000003FFUL
#endif
#define APB_BUS