handlers.c 446 B

123456789101112131415161718192021
  1. //See LICENSE for license details.
  2. #include <stdint.h>
  3. #include <stdio.h>
  4. #include <unistd.h>
  5. #include "riscv_encoding.h"
  6. #include "n22_func.h"
  7. __attribute__((weak)) uintptr_t handle_nmi() {
  8. write(1, "nmi\n", 5);
  9. _exit(1);
  10. return 0;
  11. }
  12. __attribute__((weak)) uintptr_t handle_trap(uintptr_t mcause, uintptr_t sp) {
  13. if (mcause == 0xFFF) {
  14. handle_nmi();
  15. }
  16. write(1, "trap\n", 5);
  17. _exit(mcause);
  18. return 0;
  19. }