Streamlining

pull/35/head
Andre Richter 5 years ago
parent 228428c2ca
commit 0ca114b408
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

@ -41,7 +41,7 @@ DOCKER_CMD = docker run -it --rm
DOCKER_ARG_CURDIR = -v $(shell pwd):/work -w /work
DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) -kernel $(OUTPUT)
.PHONY: all qemu clippy clean readelf objdump nm
.PHONY: all doc qemu clippy clean readelf objdump nm
all: clean $(OUTPUT)

Binary file not shown.

@ -41,7 +41,7 @@ DOCKER_CMD = docker run -it --rm
DOCKER_ARG_CURDIR = -v $(shell pwd):/work -w /work
DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) -kernel $(OUTPUT)
.PHONY: all qemu clippy clean readelf objdump nm
.PHONY: all doc qemu clippy clean readelf objdump nm
all: clean $(OUTPUT)

@ -121,12 +121,12 @@ diff -uNr 01_wait_forever/src/runtime_init.rs 02_runtime_init/src/runtime_init.r
+#[no_mangle]
+pub unsafe extern "C" fn init() -> ! {
+ extern "C" {
+ // Boundaries of the .bss section, provided by the linker script
+ // Boundaries of the .bss section, provided by the linker script.
+ static mut __bss_start: u64;
+ static mut __bss_end: u64;
+ }
+
+ // Zero out the .bss section
+ // Zero out the .bss section.
+ r0::zero_bss(&mut __bss_start, &mut __bss_end);
+
+ crate::kernel_entry()

Binary file not shown.

Binary file not shown.

@ -15,12 +15,12 @@
#[no_mangle]
pub unsafe extern "C" fn init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;
static mut __bss_end: u64;
}
// Zero out the .bss section
// Zero out the .bss section.
r0::zero_bss(&mut __bss_start, &mut __bss_end);
crate::kernel_entry()

@ -41,7 +41,7 @@ DOCKER_CMD = docker run -it --rm
DOCKER_ARG_CURDIR = -v $(shell pwd):/work -w /work
DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) -kernel $(OUTPUT)
.PHONY: all qemu clippy clean readelf objdump nm
.PHONY: all doc qemu clippy clean readelf objdump nm
all: clean $(OUTPUT)

Binary file not shown.

Binary file not shown.

@ -15,12 +15,12 @@
#[no_mangle]
pub unsafe extern "C" fn init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;
static mut __bss_end: u64;
}
// Zero out the .bss section
// Zero out the .bss section.
r0::zero_bss(&mut __bss_start, &mut __bss_end);
crate::kernel_entry()

@ -41,7 +41,7 @@ DOCKER_CMD = docker run -it --rm
DOCKER_ARG_CURDIR = -v $(shell pwd):/work -w /work
DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) -kernel $(OUTPUT)
.PHONY: all qemu clippy clean readelf objdump nm
.PHONY: all doc qemu clippy clean readelf objdump nm
all: clean $(OUTPUT)

@ -149,6 +149,6 @@ diff -uNr 03_hacky_hello_world/src/runtime_init.rs 04_zero_overhead_abstraction/
-pub unsafe extern "C" fn init() -> ! {
+pub unsafe fn init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;
```

@ -14,12 +14,12 @@
/// - Only a single core must be active and running this function.
pub unsafe fn init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;
static mut __bss_end: u64;
}
// Zero out the .bss section
// Zero out the .bss section.
r0::zero_bss(&mut __bss_start, &mut __bss_end);
crate::kernel_entry()

@ -41,7 +41,7 @@ DOCKER_CMD = docker run -it --rm
DOCKER_ARG_CURDIR = -v $(shell pwd):/work -w /work
DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) -kernel $(OUTPUT)
.PHONY: all qemu clippy clean readelf objdump nm
.PHONY: all doc qemu clippy clean readelf objdump nm
all: clean $(OUTPUT)

Binary file not shown.

Binary file not shown.

@ -14,12 +14,12 @@
/// - Only a single core must be active and running this function.
pub unsafe fn init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;
static mut __bss_end: u64;
}
// Zero out the .bss section
// Zero out the .bss section.
r0::zero_bss(&mut __bss_start, &mut __bss_end);
crate::kernel_entry()

@ -41,7 +41,7 @@ DOCKER_CMD = docker run -it --rm
DOCKER_ARG_CURDIR = -v $(shell pwd):/work -w /work
DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) -kernel $(OUTPUT)
.PHONY: all qemu clippy clean readelf objdump nm
.PHONY: all doc qemu clippy clean readelf objdump nm
all: clean $(OUTPUT)

@ -463,22 +463,22 @@ diff -uNr 05_safe_globals/src/bsp/driver/bcm/bcm2xxx_mini_uart.rs 06_drivers_gpi
+ inner.AUX_MU_BAUD.write(AUX_MU_BAUD::RATE.val(270)); // 115200 baud
+ inner.AUX_MU_MCR.set(0); // set "ready to send" high
+
+ // Clear FIFOs before using the device.
+ inner.AUX_MU_IIR.write(AUX_MU_IIR::FIFO_CLEAR::All);
+
+ // Enable receive and send.
+ inner
+ .AUX_MU_CNTL
+ .write(AUX_MU_CNTL::RX_EN::Enabled + AUX_MU_CNTL::TX_EN::Enabled);
+
+ // Clear FIFOs before using the device.
+ inner.AUX_MU_IIR.write(AUX_MU_IIR::FIFO_CLEAR::All);
+ });
+
+ Ok(())
+ }
+}
+
+/// Passthrough of `args` to the `core::fmt::Write` implementation, but guarded
+/// by a Mutex to serialize access.
+impl interface::console::Write for MiniUart {
+ /// Passthrough of `args` to the `core::fmt::Write` implementation, but
+ /// guarded by a Mutex to serialize access.
+ fn write_char(&self, c: char) {
+ let mut r = &self.inner;
+ r.lock(|inner| inner.write_char(c));
@ -496,7 +496,7 @@ diff -uNr 05_safe_globals/src/bsp/driver/bcm/bcm2xxx_mini_uart.rs 06_drivers_gpi
+ fn read_char(&self) -> char {
+ let mut r = &self.inner;
+ r.lock(|inner| {
+ // Wait until buffer is is filled.
+ // Wait until buffer is filled.
+ loop {
+ if inner.AUX_MU_LSR.is_set(AUX_MU_LSR::DATA_READY) {
+ break;
@ -784,7 +784,7 @@ 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
@@ -36,12 +36,30 @@
@@ -36,12 +36,23 @@
/// Entrypoint of the `kernel`.
fn kernel_entry() -> ! {
@ -796,25 +796,17 @@ diff -uNr 05_safe_globals/src/main.rs 06_drivers_gpio_uart/src/main.rs
+ bsp::init();
- println!("[1] Chars written: {}", bsp::console().chars_written());
+ // UART should be functional now. Wait for user to hit Enter.
+ loop {
+ if bsp::console().read_char() == '
' {
+ break;
+ }
+ }
+ println!("[0] Booting on: {}", bsp::board_name());
- 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] Echoing input now.");
+ println!("[3] Echoing input now");
+
+ loop {
+ let c = bsp::console().read_char();

Binary file not shown.

Binary file not shown.

@ -224,22 +224,22 @@ impl interface::driver::DeviceDriver for MiniUart {
inner.AUX_MU_BAUD.write(AUX_MU_BAUD::RATE.val(270)); // 115200 baud
inner.AUX_MU_MCR.set(0); // set "ready to send" high
// Clear FIFOs before using the device.
inner.AUX_MU_IIR.write(AUX_MU_IIR::FIFO_CLEAR::All);
// Enable receive and send.
inner
.AUX_MU_CNTL
.write(AUX_MU_CNTL::RX_EN::Enabled + AUX_MU_CNTL::TX_EN::Enabled);
// Clear FIFOs before using the device.
inner.AUX_MU_IIR.write(AUX_MU_IIR::FIFO_CLEAR::All);
});
Ok(())
}
}
/// Passthrough of `args` to the `core::fmt::Write` implementation, but guarded
/// by a Mutex to serialize access.
impl interface::console::Write for MiniUart {
/// Passthrough of `args` to the `core::fmt::Write` implementation, but
/// guarded by a Mutex to serialize access.
fn write_char(&self, c: char) {
let mut r = &self.inner;
r.lock(|inner| inner.write_char(c));
@ -257,7 +257,7 @@ 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.
// Wait until buffer is filled.
loop {
if inner.AUX_MU_LSR.is_set(AUX_MU_LSR::DATA_READY) {
break;

@ -41,14 +41,7 @@ fn kernel_entry() -> ! {
// Run the BSP's initialization code.
bsp::init();
// 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!("[0] Booting on: {}", bsp::board_name());
println!("[1] Drivers loaded:");
for (i, driver) in bsp::device_drivers().iter().enumerate() {
@ -56,7 +49,7 @@ fn kernel_entry() -> ! {
}
println!("[2] Chars written: {}", bsp::console().chars_written());
println!("[3] Echoing input now.");
println!("[3] Echoing input now");
loop {
let c = bsp::console().read_char();

@ -14,12 +14,12 @@
/// - Only a single core must be active and running this function.
pub unsafe fn init() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;
static mut __bss_end: u64;
}
// Zero out the .bss section
// Zero out the .bss section.
r0::zero_bss(&mut __bss_start, &mut __bss_end);
crate::kernel_entry()

Loading…
Cancel
Save