blob: 3c12c259eeb4717ee917076af2ddf659ba3e2e67 [file] [log] [blame]
David Brazdil66fc1202022-07-04 21:48:45 +01001// 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 Tosi9a7328e2023-07-07 15:51:51 +000017use vmbase::{console::emergency_write_str, eprintln, power::reboot, read_sysreg};
David Brazdil66fc1202022-07-04 21:48:45 +010018
19#[no_mangle]
20extern "C" fn sync_exception_current() {
21 emergency_write_str("sync_exception_current\n");
22 print_esr();
23 reboot();
24}
25
26#[no_mangle]
27extern "C" fn irq_current() {
28 emergency_write_str("irq_current\n");
29 reboot();
30}
31
32#[no_mangle]
33extern "C" fn fiq_current() {
34 emergency_write_str("fiq_current\n");
35 reboot();
36}
37
38#[no_mangle]
39extern "C" fn serr_current() {
40 emergency_write_str("serr_current\n");
41 print_esr();
42 reboot();
43}
44
45#[no_mangle]
46extern "C" fn sync_lower() {
47 emergency_write_str("sync_lower\n");
48 print_esr();
49 reboot();
50}
51
52#[no_mangle]
53extern "C" fn irq_lower() {
54 emergency_write_str("irq_lower\n");
55 reboot();
56}
57
58#[no_mangle]
59extern "C" fn fiq_lower() {
60 emergency_write_str("fiq_lower\n");
61 reboot();
62}
63
64#[no_mangle]
65extern "C" fn serr_lower() {
66 emergency_write_str("serr_lower\n");
67 print_esr();
68 reboot();
69}
70
71#[inline]
72fn print_esr() {
Pierre-Clément Tosi9a7328e2023-07-07 15:51:51 +000073 let esr = read_sysreg!("esr_el1");
David Brazdil66fc1202022-07-04 21:48:45 +010074 eprintln!("esr={:#08x}", esr);
75}