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
17 use vmbase::{eprintln, power::reboot, read_sysreg};
18
19 #[no_mangle]
sync_exception_current(_elr: u64, _spsr: u64)20 extern "C" fn sync_exception_current(_elr: u64, _spsr: u64) {
21 eprintln!("sync_exception_current");
22 print_esr();
23 reboot();
24 }
25
26 #[no_mangle]
irq_current(_elr: u64, _spsr: u64)27 extern "C" fn irq_current(_elr: u64, _spsr: u64) {
28 eprintln!("irq_current");
29 reboot();
30 }
31
32 #[no_mangle]
fiq_current(_elr: u64, _spsr: u64)33 extern "C" fn fiq_current(_elr: u64, _spsr: u64) {
34 eprintln!("fiq_current");
35 reboot();
36 }
37
38 #[no_mangle]
serr_current(_elr: u64, _spsr: u64)39 extern "C" fn serr_current(_elr: u64, _spsr: u64) {
40 eprintln!("serr_current");
41 print_esr();
42 reboot();
43 }
44
45 #[no_mangle]
sync_lower(_elr: u64, _spsr: u64)46 extern "C" fn sync_lower(_elr: u64, _spsr: u64) {
47 eprintln!("sync_lower");
48 print_esr();
49 reboot();
50 }
51
52 #[no_mangle]
irq_lower(_elr: u64, _spsr: u64)53 extern "C" fn irq_lower(_elr: u64, _spsr: u64) {
54 eprintln!("irq_lower");
55 reboot();
56 }
57
58 #[no_mangle]
fiq_lower(_elr: u64, _spsr: u64)59 extern "C" fn fiq_lower(_elr: u64, _spsr: u64) {
60 eprintln!("fiq_lower");
61 reboot();
62 }
63
64 #[no_mangle]
serr_lower(_elr: u64, _spsr: u64)65 extern "C" fn serr_lower(_elr: u64, _spsr: u64) {
66 eprintln!("serr_lower");
67 print_esr();
68 reboot();
69 }
70
71 #[inline]
print_esr()72 fn print_esr() {
73 let esr = read_sysreg!("esr_el1");
74 eprintln!("esr={:#08x}", esr);
75 }
76