Use distinct path for interfaces

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

@ -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 <andre.o.richter@gmail.com>
@ -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();
+}
```

@ -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 {}
}

@ -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();
}

@ -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::*};

@ -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 {}
}

@ -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();
}

Loading…
Cancel
Save