init.c 991 B

12345678910111213141516171819202122232425262728293031323334
  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. extern uint32_t disable_mcycle_minstret();
  9. void _init()
  10. {
  11. SystemInit();
  12. //ECLIC init
  13. eclic_init(ECLIC_NUM_INTERRUPTS);
  14. eclic_mode_enable();
  15. //printf("After ECLIC mode enabled, the mtvec value is %x \n\n\r", read_csr(mtvec));
  16. // // It must be NOTED:
  17. // // * In the RISC-V arch, if user mode and PMP supported, then by default if PMP is not configured
  18. // // with valid entries, then user mode cannot access any memory, and cannot execute any instructions.
  19. // // * So if switch to user-mode and still want to continue, then you must configure PMP first
  20. //pmp_open_all_space();
  21. //switch_m2u_mode();
  22. /* Before enter into main, add the cycle/instret disable by default to save power,
  23. only use them when needed to measure the cycle/instret */
  24. disable_mcycle_minstret();
  25. }
  26. void _fini()
  27. {
  28. }