Make 06 more SD card boot friendly

pull/35/head
Andre Richter 5 years ago
parent 18c49eb59f
commit e7cd63ce4c
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

@ -221,7 +221,7 @@ diff -uNr 05_safe_globals/src/bsp/driver/bcm/bcm2837_gpio.rs 06_drivers_gpio_uar
diff -uNr 05_safe_globals/src/bsp/driver/bcm/bcm2xxx_mini_uart.rs 06_drivers_gpio_uart/src/bsp/driver/bcm/bcm2xxx_mini_uart.rs
--- 05_safe_globals/src/bsp/driver/bcm/bcm2xxx_mini_uart.rs
+++ 06_drivers_gpio_uart/src/bsp/driver/bcm/bcm2xxx_mini_uart.rs
@@ -0,0 +1,258 @@
@@ -0,0 +1,282 @@
+// SPDX-License-Identifier: MIT
+//
+// Copyright (c) 2018-2019 Andre Richter <andre.o.richter@gmail.com>
@ -473,7 +473,32 @@ diff -uNr 05_safe_globals/src/bsp/driver/bcm/bcm2xxx_mini_uart.rs 06_drivers_gpi
+ }
+}
+
+impl interface::console::Read for MiniUart {}
+impl interface::console::Read for MiniUart {
+ fn read_char(&self) -> char {
+ let mut r = &self.inner;
+ r.lock(|inner| {
+ // Wait until buffer is is filled.
+ loop {
+ if inner.AUX_MU_LSR.is_set(AUX_MU_LSR::DATA_READY) {
+ break;
+ }
+
+ arch::nop();
+ }
+
+ // Read one character.
+ let mut ret = inner.AUX_MU_IO.get() as u8 as char;
+
+ // Convert carrige return to newline.
+ if ret == ' ' {
+ ret = '
'
+ }
+
+ ret
+ })
+ }
+}
+
+impl interface::console::Statistics for MiniUart {
+ fn chars_written(&self) -> usize {
@ -732,27 +757,40 @@ diff -uNr 05_safe_globals/src/interface.rs 06_drivers_gpio_uart/src/interface.rs
diff -uNr 05_safe_globals/src/main.rs 06_drivers_gpio_uart/src/main.rs
--- 05_safe_globals/src/main.rs
+++ 06_drivers_gpio_uart/src/main.rs
@@ -38,10 +38,19 @@
@@ -36,12 +36,29 @@
/// Entrypoint of the `kernel`.
fn kernel_entry() -> ! {
use interface::console::Statistics;
- use interface::console::Statistics;
+ use interface::console::{Read, Statistics};
- println!("[0] Hello from pure Rust!");
+ // Run the BSP's initialization code.
+ bsp::init();
- println!("[1] Chars written: {}", bsp::console().chars_written());
+ // UART should be functional now and `println!()` calls are transmitted on
+ // the physical wires.
+ println!("[0] Booting on: <{}>.", bsp::board_name());
+ // UART should be functional now. Wait for user to hit Enter.
+ loop {
+ if bsp::console().read_char() == '
' {
+ break;
+ }
+ }
- println!("[2] Stopping here.");
- arch::wait_forever()
+ println!("[0] Booting on: <{}>.", bsp::board_name());
+
+ println!("[1] Drivers loaded:");
+ for (i, driver) in bsp::device_drivers().iter().enumerate() {
+ println!(" {}. {}", i + 1, driver.compatible());
+ }
+
+ println!("[2] Chars written: {}", bsp::console().chars_written());
+ println!("[3] Stopping here.");
arch::wait_forever()
+ println!("[3] Echoing input now.");
+
+ loop {
+ print!("{}", bsp::console().read_char());
+ }
}
```

Binary file not shown.

Binary file not shown.

@ -248,7 +248,31 @@ impl interface::console::Write for MiniUart {
}
}
impl interface::console::Read for MiniUart {}
impl interface::console::Read for MiniUart {
fn read_char(&self) -> char {
let mut r = &self.inner;
r.lock(|inner| {
// Wait until buffer is is filled.
loop {
if inner.AUX_MU_LSR.is_set(AUX_MU_LSR::DATA_READY) {
break;
}
arch::nop();
}
// Read one character.
let mut ret = inner.AUX_MU_IO.get() as u8 as char;
// Convert carrige return to newline.
if ret == '\r' {
ret = '\n'
}
ret
})
}
}
impl interface::console::Statistics for MiniUart {
fn chars_written(&self) -> usize {

@ -36,13 +36,18 @@ mod print;
/// Entrypoint of the `kernel`.
fn kernel_entry() -> ! {
use interface::console::Statistics;
use interface::console::{Read, Statistics};
// Run the BSP's initialization code.
bsp::init();
// UART should be functional now and `println!()` calls are transmitted on
// the physical wires.
// UART should be functional now. Wait for user to hit Enter.
loop {
if bsp::console().read_char() == '\n' {
break;
}
}
println!("[0] Booting on: <{}>.", bsp::board_name());
println!("[1] Drivers loaded:");
@ -51,6 +56,9 @@ fn kernel_entry() -> ! {
}
println!("[2] Chars written: {}", bsp::console().chars_written());
println!("[3] Stopping here.");
arch::wait_forever()
println!("[3] Echoing input now.");
loop {
print!("{}", bsp::console().read_char());
}
}

Loading…
Cancel
Save