blob: 3ca4e0f97b335608c680a2eaa2f7f9593d1e15ee [file] [log] [blame]
// Copyright 2022, The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Exception handlers.
use crate::{helpers::page_4kb_of, read_sysreg};
use vmbase::console;
use vmbase::{eprintln, power::reboot};
const ESR_32BIT_EXT_DABT: usize = 0x96000010;
const UART_PAGE: usize = page_4kb_of(console::BASE_ADDRESS);
#[no_mangle]
extern "C" fn sync_exception_current(_elr: u64, _spsr: u64) {
let esr = read_sysreg!("esr_el1");
let far = read_sysreg!("far_el1");
// Don't print to the UART if we're handling the exception it could raise.
if esr != ESR_32BIT_EXT_DABT || page_4kb_of(far) != UART_PAGE {
eprintln!("sync_exception_current");
eprintln!("esr={esr:#08x}");
}
reboot();
}
#[no_mangle]
extern "C" fn irq_current(_elr: u64, _spsr: u64) {
eprintln!("irq_current");
reboot();
}
#[no_mangle]
extern "C" fn fiq_current(_elr: u64, _spsr: u64) {
eprintln!("fiq_current");
reboot();
}
#[no_mangle]
extern "C" fn serr_current(_elr: u64, _spsr: u64) {
let esr = read_sysreg!("esr_el1");
eprintln!("serr_current");
eprintln!("esr={esr:#08x}");
reboot();
}
#[no_mangle]
extern "C" fn sync_lower(_elr: u64, _spsr: u64) {
let esr = read_sysreg!("esr_el1");
eprintln!("sync_lower");
eprintln!("esr={esr:#08x}");
reboot();
}
#[no_mangle]
extern "C" fn irq_lower(_elr: u64, _spsr: u64) {
eprintln!("irq_lower");
reboot();
}
#[no_mangle]
extern "C" fn fiq_lower(_elr: u64, _spsr: u64) {
eprintln!("fiq_lower");
reboot();
}
#[no_mangle]
extern "C" fn serr_lower(_elr: u64, _spsr: u64) {
let esr = read_sysreg!("esr_el1");
eprintln!("serr_lower");
eprintln!("esr={esr:#08x}");
reboot();
}