19 const bool is_interrupt = scause &
BIT(63);
20 const long exception = scause &
~BIT(63);
23 const char *
name =
"<unknown>";
28 case 1:
name =
"Supervisor software interrupt";
break;
29 case 5:
name =
"Supervisor timer interrupt";
goto handle_timer;
30 case 9:
name =
"Supervisor external interrupt";
goto handle_irq;
31 case 13:
name =
"Counter-overflow interrupt";
break;
32 default:
name = exception >= 16 ?
"Designated for platform use" :
"<reserved>";
39 case 0:
name =
"Instruction address misaligned";
break;
40 case 1:
name =
"Instruction access fault";
break;
41 case 2:
name =
"Illegal instruction";
goto handle_ii;
42 case 3:
name =
"Breakpoint";
goto handle_bp;
43 case 4:
name =
"Load address misaligned";
break;
44 case 5:
name =
"Load access fault";
break;
45 case 6:
name =
"Store/AMO address misaligned";
break;
46 case 7:
name =
"Store/AMO access fault";
break;
47 case 8:
name =
"Environment call from U-mode";
goto handle_syscall;
48 case 9:
name =
"Environment call from S-mode";
break;
49 case 12:
name =
"Instruction page fault";
goto handle_pf;
50 case 13:
name =
"Load page fault";
goto handle_pf;
51 case 15:
name =
"Store/AMO page fault";
goto handle_pf;
52 case 18:
name =
"Software check";
break;
53 case 19:
name =
"Hardware error";
break;
54 default:
name = ((exception >= 24 && exception <= 31) || (exception >= 48 && exception <= 63)) ?
"Designated for custom use" :
"<reserved>";
58 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);
95 MOS_ASSERT(!
"Kernel mode illegal instruction");
104 MOS_ASSERT_X(!is_interrupt,
"Page faults should not be interrupts");
109 .is_present = present,
110 .is_write = exception == 15,
111 .is_user = is_userspace,
112 .is_exec = exception == 12,
123 if (!is_interrupt && exception == 8)
130 MOS_ASSERT_X(!is_userspace,
"should not return to userspace here");
long signal_send_to_process(Process *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)