David Brazdil | 66fc120 | 2022-07-04 21:48:45 +0100 | [diff] [blame] | 1 | // Copyright 2022, The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | //! Exception handlers. |
| 16 | |
Pierre-Clément Tosi | 9a7328e | 2023-07-07 15:51:51 +0000 | [diff] [blame^] | 17 | use vmbase::{console::emergency_write_str, eprintln, power::reboot, read_sysreg}; |
David Brazdil | 66fc120 | 2022-07-04 21:48:45 +0100 | [diff] [blame] | 18 | |
| 19 | #[no_mangle] |
| 20 | extern "C" fn sync_exception_current() { |
| 21 | emergency_write_str("sync_exception_current\n"); |
| 22 | print_esr(); |
| 23 | reboot(); |
| 24 | } |
| 25 | |
| 26 | #[no_mangle] |
| 27 | extern "C" fn irq_current() { |
| 28 | emergency_write_str("irq_current\n"); |
| 29 | reboot(); |
| 30 | } |
| 31 | |
| 32 | #[no_mangle] |
| 33 | extern "C" fn fiq_current() { |
| 34 | emergency_write_str("fiq_current\n"); |
| 35 | reboot(); |
| 36 | } |
| 37 | |
| 38 | #[no_mangle] |
| 39 | extern "C" fn serr_current() { |
| 40 | emergency_write_str("serr_current\n"); |
| 41 | print_esr(); |
| 42 | reboot(); |
| 43 | } |
| 44 | |
| 45 | #[no_mangle] |
| 46 | extern "C" fn sync_lower() { |
| 47 | emergency_write_str("sync_lower\n"); |
| 48 | print_esr(); |
| 49 | reboot(); |
| 50 | } |
| 51 | |
| 52 | #[no_mangle] |
| 53 | extern "C" fn irq_lower() { |
| 54 | emergency_write_str("irq_lower\n"); |
| 55 | reboot(); |
| 56 | } |
| 57 | |
| 58 | #[no_mangle] |
| 59 | extern "C" fn fiq_lower() { |
| 60 | emergency_write_str("fiq_lower\n"); |
| 61 | reboot(); |
| 62 | } |
| 63 | |
| 64 | #[no_mangle] |
| 65 | extern "C" fn serr_lower() { |
| 66 | emergency_write_str("serr_lower\n"); |
| 67 | print_esr(); |
| 68 | reboot(); |
| 69 | } |
| 70 | |
| 71 | #[inline] |
| 72 | fn print_esr() { |
Pierre-Clément Tosi | 9a7328e | 2023-07-07 15:51:51 +0000 | [diff] [blame^] | 73 | let esr = read_sysreg!("esr_el1"); |
David Brazdil | 66fc120 | 2022-07-04 21:48:45 +0100 | [diff] [blame] | 74 | eprintln!("esr={:#08x}", esr); |
| 75 | } |