[wip] debugging mailbox code

This commit is contained in:
Berkus Decker 2019-03-07 20:50:17 +02:00
parent 791a61ffed
commit 47ff40167d
2 changed files with 15 additions and 4 deletions

View File

@ -14,6 +14,7 @@
#![allow(dead_code)] #![allow(dead_code)]
#![allow(unused_assignments)] #![allow(unused_assignments)]
#![allow(unused_must_use)] #![allow(unused_must_use)]
#![allow(unused_imports)]
//any(target_arch = "aarch64", target_arch = "x86_64") //any(target_arch = "aarch64", target_arch = "x86_64")
#[cfg(not(target_arch = "aarch64"))] #[cfg(not(target_arch = "aarch64"))]
@ -82,13 +83,11 @@ fn kmain() -> ! {
// Err(_) => endless_sleep(), // Err(_) => endless_sleep(),
// } // }
// jtag_dbg_wait();
CONSOLE.lock(|c| { CONSOLE.lock(|c| {
c.replace_with(Output::new().into()); c.replace_with(Output::new().into());
}); });
let mut out = Output::new(); jtag_dbg_wait();
writeln!(out, "JLink RTT is working!"); // @todo RttConsole
println!("\n[0] UART is live!"); println!("\n[0] UART is live!");

View File

@ -194,6 +194,8 @@ pub mod alpha_mode {
fn write(regs: &RegisterBlock, buf_ptr: u32, channel: u32) -> Result<()> { fn write(regs: &RegisterBlock, buf_ptr: u32, channel: u32) -> Result<()> {
let mut count: u32 = 0; let mut count: u32 = 0;
let buf_ptr = BcmHost::phys2bus(buf_ptr);
println!("Mailbox::write {:x}/{:x}", buf_ptr, channel); println!("Mailbox::write {:x}/{:x}", buf_ptr, channel);
// Insert a compiler fence that ensures that all stores to the // Insert a compiler fence that ensures that all stores to the
@ -221,6 +223,7 @@ fn read(regs: &RegisterBlock, expected: u32, channel: u32) -> Result<()> {
while regs.STATUS.is_set(STATUS::EMPTY) { while regs.STATUS.is_set(STATUS::EMPTY) {
count += 1; count += 1;
if count > (1 << 25) { if count > (1 << 25) {
println!("Timed out waiting for mbox response");
return Err(MboxError::Timeout); return Err(MboxError::Timeout);
} }
} }
@ -236,6 +239,11 @@ fn read(regs: &RegisterBlock, expected: u32, channel: u32) -> Result<()> {
barrier::dmb(barrier::SY); barrier::dmb(barrier::SY);
} }
println!(
"Received mbox response {:#08x}, expecting {:#08x}",
data, expected
);
// is it a response to our message? // is it a response to our message?
if ((data & CHANNEL_MASK) == channel) && ((data & !CHANNEL_MASK) == expected) { if ((data & CHANNEL_MASK) == channel) && ((data & !CHANNEL_MASK) == expected) {
// is it a valid successful response? // is it a valid successful response?
@ -298,7 +306,11 @@ impl Mailbox {
} }
pub fn read(&self, channel: u32) -> Result<()> { pub fn read(&self, channel: u32) -> Result<()> {
read(self, self.buffer.as_ptr() as u32, channel)?; read(
self,
BcmHost::phys2bus(self.buffer.as_ptr() as u32),
channel,
)?;
match self.buffer[1] { match self.buffer[1] {
response::SUCCESS => { response::SUCCESS => {