ebreak 中断处理
| 34 | |
| 35 | // ebreak 中断处理 |
| 36 | auto EbreakHandler(uint64_t exception_code, cpu_io::TrapContext* context) |
| 37 | -> uint64_t { |
| 38 | // 读取 sepc 处的指令 |
| 39 | auto instruction = *reinterpret_cast<uint8_t*>(context->sepc); |
| 40 | |
| 41 | // 判断是否为压缩指令 (低 2 位不为 11) |
| 42 | if ((instruction & 0x3) != 0x3) { |
| 43 | // 2 字节指令 |
| 44 | context->sepc += 2; |
| 45 | } else { |
| 46 | // 4 字节指令 |
| 47 | context->sepc += 4; |
| 48 | } |
| 49 | klog::Info("Handle {}", cpu_io::ScauseInfo::kExceptionNames[exception_code]); |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | auto PageFaultHandler(uint64_t exception_code, cpu_io::TrapContext* context) |
| 54 | -> uint64_t { |