1 //See LICENSE for license details.
2 #include <gd32vf103.h>
3 #include <stdint.h>
4 #include <stdio.h>
5 #include <unistd.h>
6 #include "riscv_encoding.h"
7 #include "n200_func.h"
8 
9 extern uint32_t disable_mcycle_minstret();
_init()10 void _init()
11 {
12 	SystemInit();
13 
14 	//ECLIC init
15 	eclic_init(ECLIC_NUM_INTERRUPTS);
16 	eclic_mode_enable();
17 
18 	//printf("After ECLIC mode enabled, the mtvec value is %x \n\n\r", read_csr(mtvec));
19 
20 	// // It must be NOTED:
21 	//  //    * In the RISC-V arch, if user mode and PMP supported, then by default if PMP is not configured
22 	//  //      with valid entries, then user mode cannot access any memory, and cannot execute any instructions.
23 	//  //    * So if switch to user-mode and still want to continue, then you must configure PMP first
24 	//pmp_open_all_space();
25 	//switch_m2u_mode();
26 
27     /* Before enter into main, add the cycle/instret disable by default to save power,
28     only use them when needed to measure the cycle/instret */
29 	disable_mcycle_minstret();
30 }
31 
_fini()32 void _fini()
33 {
34 }
35