Add JTAG debugger wait function

This commit is contained in:
Berkus Decker 2019-02-23 22:57:59 +02:00
parent 6f9e51cd7b
commit 4858ae0159
2 changed files with 18 additions and 0 deletions

View File

@ -126,6 +126,8 @@ fn setup_and_enter_el1_from_el2() -> ! {
pub unsafe extern "C" fn _boot_cores() -> ! {
use cortex_a::{asm, regs::*};
// crate::arch::aarch64::jtag_dbg_wait();
const CORE_0: u64 = 0;
const CORE_MASK: u64 = 0x3;
const EL1: u32 = CurrentEL::EL::EL1.value;

View File

@ -8,6 +8,22 @@ pub use mmu::*;
use cortex_a::{asm, barrier, regs::*};
static mut WAIT_FLAG: bool = true;
/// Wait for debugger to attach.
/// Then in gdb issue `> set var *(&WAIT_FLAG) = 0`
/// from inside this function's frame to contiue running.
#[inline]
pub fn jtag_dbg_wait() {
use core::ptr::{read_volatile, write_volatile};
while unsafe { read_volatile(&WAIT_FLAG) } {
asm::nop();
}
// Reset the flag so that next jtag_dbg_wait() would block again.
unsafe { write_volatile(&mut WAIT_FLAG, true) }
}
// Data memory barrier
#[inline]
pub fn dmb() {