Replace uart.puts() with writeln!()

This commit is contained in:
Berkus Decker 2019-01-17 19:40:01 +02:00
parent 67b3b95d9a
commit 3831a411b9
2 changed files with 26 additions and 27 deletions

View File

@ -193,11 +193,11 @@ pub mod alpha_mode {
fn write(regs: &RegisterBlock, buf_ptr: u32, channel: u32) -> Result<()> {
let mut count: u32 = 0;
// {
// let mut uart = MiniUart::new();
// uart.init();
// write!(uart, "Mailbox::write {:x}/{:x}\n", buf_ptr, channel);
// }
{
let mut uart = MiniUart::new();
uart.init();
writeln!(uart, "Mailbox::write {:x}/{:x}", buf_ptr, channel);
}
while regs.STATUS.is_set(STATUS::FULL) {
count += 1;
@ -214,8 +214,8 @@ fn write(regs: &RegisterBlock, buf_ptr: u32, channel: u32) -> Result<()> {
fn read(regs: &RegisterBlock, expected: u32, channel: u32) -> Result<()> {
let mut count: u32 = 0;
// let mut uart = MiniUart::new();
// uart.init();
// let mut uart = MiniUart::new();
// uart.init();
loop {
while regs.STATUS.is_set(STATUS::EMPTY) {
@ -237,7 +237,7 @@ fn read(regs: &RegisterBlock, expected: u32, channel: u32) -> Result<()> {
// is it a valid successful response?
return Ok(());
} else {
return Err(MboxError::ResponseError); //@fixme ignore invalid responses and loop again?
// return Err(MboxError::ResponseError); //@fixme ignore invalid responses and loop again?
}
}
}
@ -289,20 +289,20 @@ impl Mailbox {
pub fn read(&self, channel: u32) -> Result<()> {
read(self, phys2bus(self.buffer.as_ptr() as u32), channel)?;
//let mut uart = MiniUart::new();
//uart.init();
let mut uart = MiniUart::new();
uart.init();
match self.buffer[1] {
response::SUCCESS => {
//uart.puts("\n######\nMailbox::returning SUCCESS\n");
writeln!(uart, "\n######\nMailbox::returning SUCCESS");
Ok(())
}
response::ERROR => {
//uart.puts("\n######\nMailbox::returning ResponseError\n");
writeln!(uart, "\n######\nMailbox::returning ResponseError");
Err(MboxError::ResponseError)
}
_ => {
//uart.puts("\n######\nMailbox::returning UnknownError\n");
writeln!(uart, "\n######\nMailbox::returning UnknownError");
Err(MboxError::UnknownError)
}
}

View File

@ -11,13 +11,12 @@ impl VC {
pub fn init_fb(size: Size2d, uart: &mut MiniUart) -> Option<Display> {
let mut fb_info = GpuFb::new(size, 32);
uart.puts("initing fb_info\n");
writeln!(uart, "initing fb_info");
fb_info.call().map_err(|_| {
uart.puts("fb_info error\n");
()
writeln!(uart, "fb_info error");
});
// write!(uart, "inited fb_info: {}\n", fb_info);
writeln!(uart, "inited fb_info: {}", fb_info);
let mut mbox = Mailbox::new();
@ -62,7 +61,7 @@ impl VC {
/* Need to set up max_x/max_y before using Display::write */
let max_x = fb_info.vwidth / CHARSIZE_X;
let max_y = fb_info.vheight / CHARSIZE_Y;
uart.puts("inited fb_info #2\n");
writeln!(uart, "inited fb_info #2");
Some(Display::new(
bus2phys(fb_info.pointer),
@ -79,7 +78,7 @@ impl VC {
/*
fn get_display_size() -> Option<Size2d> {
let mut mbox = Mbox::new();
mbox.0[0] = 8 * 4; // Total size
mbox.0[1] = MAILBOX_REQ_CODE; // Request
mbox.0[2] = Tag::GetPhysicalWH as u32; // Display size // tag
@ -88,9 +87,9 @@ impl VC {
mbox.0[5] = 0; // Space for horizontal resolution
mbox.0[6] = 0; // Space for vertical resolution
mbox.0[7] = Tag::End as u32; // End tag
mbox.call(Channel::PropertyTagsArmToVc)?;
// if mbox.0[1] != MAILBOX_RESP_CODE_SUCCESS {
// return None;
// }
@ -103,12 +102,12 @@ impl VC {
y: mbox.0[6],
})
}
fn set_display_size(size: Size2d) -> Option<Display> {
// @todo Make Display use VC functions internally instead
let mut mbox = Mbox::new();
let mut count: usize = 0;
count += 1;
mbox.0[count] = MAILBOX_REQ_CODE; // Request
count += 1;
@ -152,15 +151,15 @@ impl VC {
count += 1;
mbox.0[count] = Tag::End as u32;
mbox.0[0] = (count * 4) as u32; // Total size
let max_count = count;
Mailbox::call(Channel::PropertyTagsArmToVc as u8, &mbox.0 as *const u32 as *const u8)?;
if mbox.0[1] != MAILBOX_RESP_CODE_SUCCESS {
return None;
}
count = 2; /* First tag */
while mbox.0[count] != 0 {
if mbox.0[count] == Tag::AllocateBuffer as u32 {