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),