19 const bool is_interrupt = scause &
BIT(63);
20 const long exception = scause & ~BIT(63);
22 const char *
name =
"<unknown>";
27 case 1:
name =
"Supervisor software interrupt";
break;
28 case 5:
name =
"Supervisor timer interrupt";
goto handle_timer;
29 case 9:
name =
"Supervisor external interrupt";
goto handle_irq;
30 case 13:
name =
"Counter-overflow interrupt";
break;
31 default:
name = exception >= 16 ?
"Designated for platform use" :
"<reserved>";
38 case 0:
name =
"Instruction address misaligned";
break;
39 case 1:
name =
"Instruction access fault";
break;
40 case 2:
name =
"Illegal instruction";
goto handle_ii;
41 case 3:
name =
"Breakpoint";
goto handle_bp;
42 case 4:
name =
"Load address misaligned";
break;
43 case 5:
name =
"Load access fault";
break;
44 case 6:
name =
"Store/AMO address misaligned";
break;
45 case 7:
name =
"Store/AMO access fault";
break;
46 case 8:
name =
"Environment call from U-mode";
goto handle_syscall;
47 case 9:
name =
"Environment call from S-mode";
break;
48 case 12:
name =
"Instruction page fault";
goto handle_pf;
49 case 13:
name =
"Load page fault";
goto handle_pf;
50 case 15:
name =
"Store/AMO page fault";
goto handle_pf;
51 case 18:
name =
"Software check";
break;
52 case 19:
name =
"Hardware error";
break;
53 default:
name = ((exception >= 24 && exception <= 31) || (exception >= 48 && exception <= 63)) ?
"Designated for custom use" :
"<reserved>";
57 pr_info(
"riscv64 trap: sepc=" PTR_FMT ", scause" PTR_FMT ", stval=" PTR_FMT ", %s, code = %ld, interrupt = %d", sepc, scause, stval,
name, exception, is_interrupt);
86 MOS_ASSERT(!
"Kernel mode illegal instruction");
93 MOS_ASSERT_X(!is_interrupt,
"Page faults should not be interrupts");
99 .is_exec = exception == 12,
100 .is_write = exception == 15,
101 .is_present = present,
102 .is_user = is_userspace,
111 if (!is_interrupt && exception == 8)
118 MOS_ASSERT_X(!is_userspace,
"should not return to userspace here");
long signal_send_to_process(process_t *target, signal_t signal)
Send a signal to a process, an arbitrary thread will be chosen to receive the signal.
reg_t ksyscall_enter(reg_t number, reg_t arg1, reg_t arg2, reg_t arg3, reg_t arg4, reg_t arg5, reg_t arg6)