Skip to content

Commit

Permalink
cleaning up dependencies
Browse files Browse the repository at this point in the history
- remove unused header include
- rewrite ECLIC initialization with NMSIS function
  • Loading branch information
soburi committed Jun 5, 2021
1 parent fb9979c commit ac8f8bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Firmware/RISCV/env_Eclipse/handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdio.h>
#include <unistd.h>
#include "riscv_encoding.h"
#include "n200_func.h"
#include "nmsis_core.h"

__attribute__((weak)) uintptr_t handle_nmi()
{
Expand All @@ -20,8 +20,8 @@ __attribute__((weak)) uintptr_t handle_trap(uintptr_t mcause, uintptr_t sp)
}
write(1, "trap\n", 5);
//printf("In trap handler, the mcause is %d\n", mcause);
//printf("In trap handler, the mepc is 0x%x\n", read_csr(mepc));
//printf("In trap handler, the mtval is 0x%x\n", read_csr(mbadaddr));
//printf("In trap handler, the mepc is 0x%x\n", __RV_CSR_READ(mepc));
//printf("In trap handler, the mtval is 0x%x\n", __RV_CSR_READ(mbadaddr));
_exit(mcause);
return 0;
}
Expand Down
13 changes: 10 additions & 3 deletions Firmware/RISCV/env_Eclipse/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@
#include <stdio.h>
#include <unistd.h>
#include "riscv_encoding.h"
#include "n200_func.h"
#include "nmsis_core.h"

extern uint32_t disable_mcycle_minstret();
void _init()
{
SystemInit();

//ECLIC init
eclic_init(ECLIC_NUM_INTERRUPTS);
eclic_mode_enable();
ECLIC->CFG = 0U;
ECLIC->MTH = 0U;
for(int i=0; i<ECLIC_NUM_INTERRUPTS; i++) {
ECLIC->CTRL[i].INTIP = 0U;
ECLIC->CTRL[i].INTIE = 0U;
ECLIC->CTRL[i].INTATTR = 0U;
ECLIC->CTRL[i].INTCTRL = 0U;
}
__set_exc_entry(__RV_CSR_READ(CSR_MTVEC));

//printf("After ECLIC mode enabled, the mtvec value is %x \n\n\r", read_csr(mtvec));

Expand Down

0 comments on commit ac8f8bb

Please sign in to comment.