blob: 0522013045609249bb683bad8814e853426d7812 [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
17use core::arch::asm;
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010018use vmbase::{eprintln, power::reboot};
Andrew Walbraneef98202022-04-27 16:23:06 +000019
20#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010021extern "C" fn sync_exception_current(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010022 eprintln!("sync_exception_current");
Andrew Walbraneef98202022-04-27 16:23:06 +000023 print_esr();
24 reboot();
25}
26
27#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010028extern "C" fn irq_current(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010029 eprintln!("irq_current");
Andrew Walbraneef98202022-04-27 16:23:06 +000030 reboot();
31}
32
33#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010034extern "C" fn fiq_current(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010035 eprintln!("fiq_current");
Andrew Walbraneef98202022-04-27 16:23:06 +000036 reboot();
37}
38
39#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010040extern "C" fn serr_current(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010041 eprintln!("serr_current");
Andrew Walbraneef98202022-04-27 16:23:06 +000042 print_esr();
43 reboot();
44}
45
46#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010047extern "C" fn sync_lower(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010048 eprintln!("sync_lower");
Andrew Walbraneef98202022-04-27 16:23:06 +000049 print_esr();
50 reboot();
51}
52
53#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010054extern "C" fn irq_lower(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010055 eprintln!("irq_lower");
Andrew Walbraneef98202022-04-27 16:23:06 +000056 reboot();
57}
58
59#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010060extern "C" fn fiq_lower(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010061 eprintln!("fiq_lower");
Andrew Walbraneef98202022-04-27 16:23:06 +000062 reboot();
63}
64
65#[no_mangle]
Pierre-Clément Tosi8cbd4b72022-08-11 13:59:31 +010066extern "C" fn serr_lower(_elr: u64, _spsr: u64) {
Jakob Vukalovicbff22e12023-04-18 14:50:47 +010067 eprintln!("serr_lower");
Andrew Walbraneef98202022-04-27 16:23:06 +000068 print_esr();
69 reboot();
70}
71
72#[inline]
73fn print_esr() {
74 let mut esr: u64;
75 unsafe {
76 asm!("mrs {esr}, esr_el1", esr = out(reg) esr);
77 }
78 eprintln!("esr={:#08x}", esr);
79}