From de3957009b538164cb3eedcea82d99250e6ce9c5 Mon Sep 17 00:00:00 2001 From: Andre Richter Date: Sun, 6 Oct 2019 11:52:32 +0200 Subject: [PATCH] Use distinct path for interfaces --- 03_hacky_hello_world/README.md | 12 +++++++----- 03_hacky_hello_world/src/bsp/rpi3.rs | 6 +++--- 03_hacky_hello_world/src/print.rs | 4 +++- 04_zero_overhead_abstraction/README.md | 2 +- 04_zero_overhead_abstraction/src/bsp/rpi3.rs | 6 +++--- 04_zero_overhead_abstraction/src/print.rs | 4 +++- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/03_hacky_hello_world/README.md b/03_hacky_hello_world/README.md index 1773905a..e5cc895f 100644 --- a/03_hacky_hello_world/README.md +++ b/03_hacky_hello_world/README.md @@ -57,7 +57,7 @@ diff -uNr 02_runtime_init/src/bsp/rpi3.rs 03_hacky_hello_world/src/bsp/rpi3.rs mod panic_wait; -+use crate::interface::console; ++use crate::interface; +use core::fmt; + global_asm!(include_str!("rpi3/start.S")); @@ -72,7 +72,7 @@ diff -uNr 02_runtime_init/src/bsp/rpi3.rs 03_hacky_hello_world/src/bsp/rpi3.rs +/// See [`src/print.rs`]. +/// +/// [`src/print.rs`]: ../../print/index.html -+impl console::Write for QEMUOutput { ++impl interface::console::Write for QEMUOutput { + fn write_str(&mut self, s: &str) -> fmt::Result { + for c in s.chars() { + unsafe { @@ -89,7 +89,7 @@ diff -uNr 02_runtime_init/src/bsp/rpi3.rs 03_hacky_hello_world/src/bsp/rpi3.rs +//////////////////////////////////////////////////////////////////////////////// + +/// Returns a ready-to-use `console::Write` implementation. -+pub fn console() -> impl console::Write { ++pub fn console() -> impl interface::console::Write { + QEMUOutput {} +} @@ -173,7 +173,7 @@ diff -uNr 02_runtime_init/src/main.rs 03_hacky_hello_world/src/main.rs diff -uNr 02_runtime_init/src/print.rs 03_hacky_hello_world/src/print.rs --- 02_runtime_init/src/print.rs +++ 03_hacky_hello_world/src/print.rs -@@ -0,0 +1,32 @@ +@@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +// +// Copyright (c) 2018-2019 Andre Richter @@ -181,7 +181,7 @@ diff -uNr 02_runtime_init/src/print.rs 03_hacky_hello_world/src/print.rs +//! Printing facilities. + +use crate::bsp; -+use crate::interface::console::Write; ++use crate::interface; +use core::fmt; + +/// Prints without a newline. @@ -205,6 +205,8 @@ diff -uNr 02_runtime_init/src/print.rs 03_hacky_hello_world/src/print.rs +} + +pub fn _print(args: fmt::Arguments) { ++ use interface::console::Write; ++ + bsp::console().write_fmt(args).unwrap(); +} ``` diff --git a/03_hacky_hello_world/src/bsp/rpi3.rs b/03_hacky_hello_world/src/bsp/rpi3.rs index 0776bdab..21385952 100644 --- a/03_hacky_hello_world/src/bsp/rpi3.rs +++ b/03_hacky_hello_world/src/bsp/rpi3.rs @@ -6,7 +6,7 @@ mod panic_wait; -use crate::interface::console; +use crate::interface; use core::fmt; global_asm!(include_str!("rpi3/start.S")); @@ -21,7 +21,7 @@ struct QEMUOutput; /// See [`src/print.rs`]. /// /// [`src/print.rs`]: ../../print/index.html -impl console::Write for QEMUOutput { +impl interface::console::Write for QEMUOutput { fn write_str(&mut self, s: &str) -> fmt::Result { for c in s.chars() { unsafe { @@ -38,6 +38,6 @@ impl console::Write for QEMUOutput { //////////////////////////////////////////////////////////////////////////////// /// Returns a ready-to-use `console::Write` implementation. -pub fn console() -> impl console::Write { +pub fn console() -> impl interface::console::Write { QEMUOutput {} } diff --git a/03_hacky_hello_world/src/print.rs b/03_hacky_hello_world/src/print.rs index 9a7dc63c..c85d37e7 100644 --- a/03_hacky_hello_world/src/print.rs +++ b/03_hacky_hello_world/src/print.rs @@ -5,7 +5,7 @@ //! Printing facilities. use crate::bsp; -use crate::interface::console::Write; +use crate::interface; use core::fmt; /// Prints without a newline. @@ -28,5 +28,7 @@ macro_rules! println { } pub fn _print(args: fmt::Arguments) { + use interface::console::Write; + bsp::console().write_fmt(args).unwrap(); } diff --git a/04_zero_overhead_abstraction/README.md b/04_zero_overhead_abstraction/README.md index c18d7d19..2fc28047 100644 --- a/04_zero_overhead_abstraction/README.md +++ b/04_zero_overhead_abstraction/README.md @@ -81,7 +81,7 @@ diff -uNr 03_hacky_hello_world/src/bsp/rpi3.rs 04_zero_overhead_abstraction/src/ +++ 04_zero_overhead_abstraction/src/bsp/rpi3.rs @@ -8,8 +8,34 @@ - use crate::interface::console; + use crate::interface; use core::fmt; +use cortex_a::{asm, regs::*}; diff --git a/04_zero_overhead_abstraction/src/bsp/rpi3.rs b/04_zero_overhead_abstraction/src/bsp/rpi3.rs index d9824e9f..bdff3767 100644 --- a/04_zero_overhead_abstraction/src/bsp/rpi3.rs +++ b/04_zero_overhead_abstraction/src/bsp/rpi3.rs @@ -6,7 +6,7 @@ mod panic_wait; -use crate::interface::console; +use crate::interface; use core::fmt; use cortex_a::{asm, regs::*}; @@ -47,7 +47,7 @@ struct QEMUOutput; /// See [`src/print.rs`]. /// /// [`src/print.rs`]: ../../print/index.html -impl console::Write for QEMUOutput { +impl interface::console::Write for QEMUOutput { fn write_str(&mut self, s: &str) -> fmt::Result { for c in s.chars() { unsafe { @@ -64,6 +64,6 @@ impl console::Write for QEMUOutput { //////////////////////////////////////////////////////////////////////////////// /// Returns a ready-to-use `console::Write` implementation. -pub fn console() -> impl console::Write { +pub fn console() -> impl interface::console::Write { QEMUOutput {} } diff --git a/04_zero_overhead_abstraction/src/print.rs b/04_zero_overhead_abstraction/src/print.rs index 9a7dc63c..c85d37e7 100644 --- a/04_zero_overhead_abstraction/src/print.rs +++ b/04_zero_overhead_abstraction/src/print.rs @@ -5,7 +5,7 @@ //! Printing facilities. use crate::bsp; -use crate::interface::console::Write; +use crate::interface; use core::fmt; /// Prints without a newline. @@ -28,5 +28,7 @@ macro_rules! println { } pub fn _print(args: fmt::Arguments) { + use interface::console::Write; + bsp::console().write_fmt(args).unwrap(); }