Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 64 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ members = [
"tests/runner",
]
exclude = ["examples/basic", "examples/test_framework", "tests/test_kernels/"]
resolver = "3"

[workspace.package]
# don't forget to update `workspace.dependencies` below
Expand Down
2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ xmas-elf = "0.8.0"
raw-cpuid = "10.2.0"
rand = { version = "0.8.6", default-features = false }
rand_hc = "0.3.1"
uart_16550 = "0.6.0"
uart_16550 = "0.3.2"
log = "0.4.17"

[dependencies.noto-sans-mono-bitmap]
Expand Down
15 changes: 5 additions & 10 deletions common/src/serial.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
use core::fmt;
use uart_16550::backend::PioBackend;

// TODO this type can be replaced with Uart16550Tty but using it currently panics
// in the new constructor.
pub struct SerialPort {
port: uart_16550::Uart16550<PioBackend>,
port: uart_16550::SerialPort,
}

impl SerialPort {
/// # Safety
///
/// unsafe because this function must only be called once
pub unsafe fn init() -> Self {
let mut port =
unsafe { uart_16550::Uart16550::new_port(0x3F8) }.expect("should be valid port");
port.init(uart_16550::Config::default())
.expect("should init successfully");
let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) };
port.init();
Self { port }
}
}
Expand All @@ -24,8 +19,8 @@ impl fmt::Write for SerialPort {
fn write_str(&mut self, s: &str) -> fmt::Result {
for char in s.bytes() {
match char {
b'\n' => self.port.send_bytes_exact(b"\r\n"),
byte => self.port.send_bytes_exact(&[byte]),
b'\n' => self.port.write_str("\r\n").unwrap(),
byte => self.port.send(byte),
}
}
Ok(())
Expand Down
Loading
Loading