blob: 5d7768aed6ee4e6f5a723e7581a5a9fed4c60367 [file] [log] [blame]
Andrew Walbraneef98202022-04-27 16:23:06 +00001// 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::{eprintln, power::reboot, read_sysreg};
Andrew Walbraneef98202022-04-27 16:23:06 +000018
19#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010020extern "C" fn sync_exception_current(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010021 eprintln!("sync_exception_current");
Andrew Walbraneef98202022-04-27 16:23:06 +000022 print_esr();
23 reboot();
24}
25
26#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010027extern "C" fn irq_current(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010028 eprintln!("irq_current");
Andrew Walbraneef98202022-04-27 16:23:06 +000029 reboot();
30}
31
32#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010033extern "C" fn fiq_current(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010034 eprintln!("fiq_current");
Andrew Walbraneef98202022-04-27 16:23:06 +000035 reboot();
36}
37
38#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010039extern "C" fn serr_current(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010040 eprintln!("serr_current");
Andrew Walbraneef98202022-04-27 16:23:06 +000041 print_esr();
42 reboot();
43}
44
45#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010046extern "C" fn sync_lower(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010047 eprintln!("sync_lower");
Andrew Walbraneef98202022-04-27 16:23:06 +000048 print_esr();
49 reboot();
50}
51
52#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010053extern "C" fn irq_lower(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010054 eprintln!("irq_lower");
Andrew Walbraneef98202022-04-27 16:23:06 +000055 reboot();
56}
57
58#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010059extern "C" fn fiq_lower(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010060 eprintln!("fiq_lower");
Andrew Walbraneef98202022-04-27 16:23:06 +000061 reboot();
62}
63
64#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010065extern "C" fn serr_lower(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010066 eprintln!("serr_lower");
Andrew Walbraneef98202022-04-27 16:23:06 +000067 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");
Andrew Walbraneef98202022-04-27 16:23:06 +000074 eprintln!("esr={:#08x}", esr);
75}