diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/err_f.cpp | 165 |
1 files changed, 164 insertions, 1 deletions
diff --git a/src/core/hle/service/err_f.cpp b/src/core/hle/service/err_f.cpp index 8d765acb5..58c5acd1e 100644 --- a/src/core/hle/service/err_f.cpp +++ b/src/core/hle/service/err_f.cpp | |||
| @@ -10,8 +10,171 @@ | |||
| 10 | 10 | ||
| 11 | namespace ERR_F { | 11 | namespace ERR_F { |
| 12 | 12 | ||
| 13 | enum { | ||
| 14 | ErrSpecifier0 = 0, | ||
| 15 | ErrSpecifier1 = 1, | ||
| 16 | ErrSpecifier3 = 3, | ||
| 17 | ErrSpecifier4 = 4, | ||
| 18 | }; | ||
| 19 | |||
| 20 | // This is used instead of ResultCode from result.h | ||
| 21 | // because we can't have non-trivial data members in unions. | ||
| 22 | union RSL { | ||
| 23 | u32 raw; | ||
| 24 | |||
| 25 | BitField<0, 10, u32> description; | ||
| 26 | BitField<10, 8, u32> module; | ||
| 27 | BitField<21, 6, u32> summary; | ||
| 28 | BitField<27, 5, u32> level; | ||
| 29 | }; | ||
| 30 | |||
| 31 | union ErrInfo { | ||
| 32 | u8 specifier; | ||
| 33 | |||
| 34 | struct { | ||
| 35 | u8 specifier; // 0x0 | ||
| 36 | u8 rev_high; // 0x1 | ||
| 37 | u16 rev_low; // 0x2 | ||
| 38 | RSL result_code; // 0x4 | ||
| 39 | u32 address; // 0x8 | ||
| 40 | INSERT_PADDING_BYTES(4); // 0xC | ||
| 41 | u32 pid_low; // 0x10 | ||
| 42 | u32 pid_high; // 0x14 | ||
| 43 | u32 aid_low; // 0x18 | ||
| 44 | u32 aid_high; // 0x1C | ||
| 45 | } errtype1; | ||
| 46 | |||
| 47 | struct { | ||
| 48 | u8 specifier; // 0x0 | ||
| 49 | u8 rev_high; // 0x1 | ||
| 50 | u16 rev_low; // 0x2 | ||
| 51 | INSERT_PADDING_BYTES(0xC); // 0x4 | ||
| 52 | u32 pid_low; // 0x10 | ||
| 53 | u32 pid_high; // 0x14 | ||
| 54 | u32 aid_low; // 0x18 | ||
| 55 | u32 aid_high; // 0x1C | ||
| 56 | u8 error_type; // 0x20 | ||
| 57 | INSERT_PADDING_BYTES(3); // 0x21 | ||
| 58 | u32 fault_status_reg; // 0x24 | ||
| 59 | u32 fault_addr; // 0x28 | ||
| 60 | u32 fpexc; // 0x2C | ||
| 61 | u32 finst; // 0x30 | ||
| 62 | u32 finst2; // 0x34 | ||
| 63 | INSERT_PADDING_BYTES(0x34); // 0x38 | ||
| 64 | u32 sp; // 0x6C | ||
| 65 | u32 pc; // 0x70 | ||
| 66 | u32 lr; // 0x74 | ||
| 67 | u32 cpsr; // 0x78 | ||
| 68 | } errtype3; | ||
| 69 | |||
| 70 | struct { | ||
| 71 | u8 specifier; // 0x0 | ||
| 72 | u8 rev_high; // 0x1 | ||
| 73 | u16 rev_low; // 0x2 | ||
| 74 | RSL result_code; // 0x4 | ||
| 75 | INSERT_PADDING_BYTES(8); // 0x8 | ||
| 76 | u32 pid_low; // 0x10 | ||
| 77 | u32 pid_high; // 0x14 | ||
| 78 | u32 aid_low; // 0x18 | ||
| 79 | u32 aid_high; // 0x1C | ||
| 80 | char debug_string1[0x2E]; // 0x20 | ||
| 81 | char debug_string2[0x2E]; // 0x4E | ||
| 82 | } errtype4; | ||
| 83 | }; | ||
| 84 | |||
| 85 | enum { | ||
| 86 | PrefetchAbort = 0, | ||
| 87 | DataAbort = 1, | ||
| 88 | UndefInstr = 2, | ||
| 89 | VectorFP = 3 | ||
| 90 | }; | ||
| 91 | |||
| 92 | static std::string GetErrInfo3Type(u8 type_code) { | ||
| 93 | switch (type_code) { | ||
| 94 | case PrefetchAbort: return "Prefetch Abort"; | ||
| 95 | case DataAbort: return "Data Abort"; | ||
| 96 | case UndefInstr: return "Undefined Instruction"; | ||
| 97 | case VectorFP: return "Vector Floating Point"; | ||
| 98 | default: return "unknown"; | ||
| 99 | } | ||
| 100 | } | ||
| 101 | |||
| 102 | static void ThrowFatalError(Service::Interface* self) { | ||
| 103 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 104 | |||
| 105 | LOG_CRITICAL(Service_ERR, "Fatal error!"); | ||
| 106 | const ErrInfo* errinfo = reinterpret_cast<ErrInfo*>(&cmd_buff[1]); | ||
| 107 | |||
| 108 | switch (errinfo->specifier) { | ||
| 109 | case ErrSpecifier0: | ||
| 110 | case ErrSpecifier1: | ||
| 111 | { | ||
| 112 | const auto& errtype = errinfo->errtype1; | ||
| 113 | LOG_CRITICAL(Service_ERR, "PID: 0x%08X_0x%08X", errtype.pid_low, errtype.pid_high); | ||
| 114 | LOG_CRITICAL(Service_ERR, "REV: %d", errtype.rev_low | (errtype.rev_high << 16)); | ||
| 115 | LOG_CRITICAL(Service_ERR, "AID: 0x%08X_0x%08X", errtype.aid_low, errtype.aid_high); | ||
| 116 | LOG_CRITICAL(Service_ERR, "ADR: 0x%08X", errtype.address); | ||
| 117 | |||
| 118 | LOG_CRITICAL(Service_ERR, "RSL: 0x%08X", errtype.result_code.raw); | ||
| 119 | LOG_CRITICAL(Service_ERR, " Level: %u", errtype.result_code.level.Value()); | ||
| 120 | LOG_CRITICAL(Service_ERR, " Summary: %u", errtype.result_code.summary.Value()); | ||
| 121 | LOG_CRITICAL(Service_ERR, " Module: %u", errtype.result_code.module.Value()); | ||
| 122 | LOG_CRITICAL(Service_ERR, " Desc: %u", errtype.result_code.description.Value()); | ||
| 123 | break; | ||
| 124 | } | ||
| 125 | |||
| 126 | case ErrSpecifier3: | ||
| 127 | { | ||
| 128 | const auto& errtype = errinfo->errtype3; | ||
| 129 | LOG_CRITICAL(Service_ERR, "PID: 0x%08X_0x%08X", errtype.pid_low, errtype.pid_high); | ||
| 130 | LOG_CRITICAL(Service_ERR, "REV: %d", errtype.rev_low | (errtype.rev_high << 16)); | ||
| 131 | LOG_CRITICAL(Service_ERR, "AID: 0x%08X_0x%08X", errtype.aid_low, errtype.aid_high); | ||
| 132 | LOG_CRITICAL(Service_ERR, "TYPE: %s", GetErrInfo3Type(errtype.error_type).c_str()); | ||
| 133 | |||
| 134 | LOG_CRITICAL(Service_ERR, "PC: 0x%08X", errtype.pc); | ||
| 135 | LOG_CRITICAL(Service_ERR, "LR: 0x%08X", errtype.lr); | ||
| 136 | LOG_CRITICAL(Service_ERR, "SP: 0x%08X", errtype.sp); | ||
| 137 | LOG_CRITICAL(Service_ERR, "CPSR: 0x%08X", errtype.cpsr); | ||
| 138 | |||
| 139 | switch (errtype.error_type) { | ||
| 140 | case PrefetchAbort: | ||
| 141 | case DataAbort: | ||
| 142 | LOG_CRITICAL(Service_ERR, "Fault Address: 0x%08X", errtype.fault_addr); | ||
| 143 | LOG_CRITICAL(Service_ERR, "Fault Status Register: 0x%08X", errtype.fault_status_reg); | ||
| 144 | break; | ||
| 145 | case VectorFP: | ||
| 146 | LOG_CRITICAL(Service_ERR, "FPEXC: 0x%08X", errtype.fpexc); | ||
| 147 | LOG_CRITICAL(Service_ERR, "FINST: 0x%08X", errtype.finst); | ||
| 148 | LOG_CRITICAL(Service_ERR, "FINST2: 0x%08X", errtype.finst2); | ||
| 149 | break; | ||
| 150 | } | ||
| 151 | break; | ||
| 152 | } | ||
| 153 | |||
| 154 | case ErrSpecifier4: | ||
| 155 | { | ||
| 156 | const auto& errtype = errinfo->errtype4; | ||
| 157 | LOG_CRITICAL(Service_ERR, "PID: 0x%08X_0x%08X", errtype.pid_low, errtype.pid_high); | ||
| 158 | LOG_CRITICAL(Service_ERR, "REV: %d", errtype.rev_low | (errtype.rev_high << 16)); | ||
| 159 | LOG_CRITICAL(Service_ERR, "AID: 0x%08X_0x%08X", errtype.aid_low, errtype.aid_high); | ||
| 160 | |||
| 161 | LOG_CRITICAL(Service_ERR, "RSL: 0x%08X", errtype.result_code.raw); | ||
| 162 | LOG_CRITICAL(Service_ERR, " Level: %u", errtype.result_code.level.Value()); | ||
| 163 | LOG_CRITICAL(Service_ERR, " Summary: %u", errtype.result_code.summary.Value()); | ||
| 164 | LOG_CRITICAL(Service_ERR, " Module: %u", errtype.result_code.module.Value()); | ||
| 165 | LOG_CRITICAL(Service_ERR, " Desc: %u", errtype.result_code.description.Value()); | ||
| 166 | |||
| 167 | LOG_CRITICAL(Service_ERR, "%s", errtype.debug_string1); | ||
| 168 | LOG_CRITICAL(Service_ERR, "%s", errtype.debug_string2); | ||
| 169 | break; | ||
| 170 | } | ||
| 171 | } | ||
| 172 | |||
| 173 | cmd_buff[1] = 0; // No error | ||
| 174 | } | ||
| 175 | |||
| 13 | const Interface::FunctionInfo FunctionTable[] = { | 176 | const Interface::FunctionInfo FunctionTable[] = { |
| 14 | {0x00010800, nullptr, "ThrowFatalError"} | 177 | {0x00010800, ThrowFatalError, "ThrowFatalError"} |
| 15 | }; | 178 | }; |
| 16 | 179 | ||
| 17 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 180 | //////////////////////////////////////////////////////////////////////////////////////////////////// |