From 15ca70fc7fa5e9fe0ec706e546f3ba665d2c066f Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Mon, 15 Jun 2026 07:42:27 +0200 Subject: [PATCH 1/2] lib: change signature of Uart16550::config() to be more flexible Further, this removes the need to store the same data twice. --- CHANGELOG.md | 3 +++ src/lib.rs | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cf3f57..9131061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +- **Breaking:** Changed the return type of `Uart16550::config(&self)` from + `(&Config, &B::Address)` to `(&Config, &B)` + ## 0.6.0 - 2026-03-28 - Rename `Uart16550::try_send_bytes()` to `Uart16550::send_bytes()` diff --git a/src/lib.rs b/src/lib.rs index 5d28af3..dfc8c2a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -297,7 +297,6 @@ mod tty; #[derive(Debug)] pub struct Uart16550 { backend: B, - base_address: B::Address, // The currently active config. config: Config, } @@ -325,7 +324,6 @@ impl Uart16550 { Ok(Self { backend, - base_address, // Will be replaced by the actual config in init() afterwards. config: Config::default(), }) @@ -375,7 +373,6 @@ impl Uart16550 { Ok(Self { backend, - base_address, // Will be replaced by the actual config in init() afterwards. config: Config::default(), }) @@ -911,12 +908,13 @@ impl Uart16550 { /* ----- Misc ----------------------------------------------------------- */ /// Returns the config from the last call to [`Self::init`] together with - /// the base address of the underlying hardware. + /// the corresponding [`Backend`]. /// + /// Via the backend, you can get the base address using [`Backend::base()`]. /// To get the values that are currently in the registers, consider using /// [`Self::config_register_dump`]. - pub const fn config(&self) -> (&Config, B::Address) { - (&self.config, self.base_address) + pub const fn config(&self) -> (&Config, &B) { + (&self.config, &self.backend) } /// Queries the device and returns a [`ConfigRegisterDump`]. From 3e147620842f0cd0f21b4debe2b4de01d6a90d8d Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Mon, 15 Jun 2026 07:44:16 +0200 Subject: [PATCH 2/2] test: minor adjustments --- test/Cargo.lock | 6 +++--- test/Cargo.toml | 2 +- test/src/main.rs | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/Cargo.lock b/test/Cargo.lock index 0c82e29..836c88a 100644 --- a/test/Cargo.lock +++ b/test/Cargo.lock @@ -32,13 +32,13 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "qemu-exit" -version = "3.0.2" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb0fd6580eeed0103c054e3fba2c2618ff476943762f28a645b63b8692b21c9" +checksum = "8189cbf0422ac15d7d544ed5f331fbe4e5b9da88133568fd359083b186a547f3" [[package]] name = "uart_16550" -version = "0.5.0" +version = "0.6.0" dependencies = [ "bitflags", ] diff --git a/test/Cargo.toml b/test/Cargo.toml index c095881..eaa02ce 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -13,4 +13,4 @@ opt-level = "s" anyhow = { version = "1.0", default-features = false } log = { version = "0.4", default-features = false } uart_16550 = { path = "../." } -qemu-exit = { version = "3.0.2", default-features = false } +qemu-exit = { version = "4.0.0", default-features = false } diff --git a/test/src/main.rs b/test/src/main.rs index 97281cf..4b84d4b 100644 --- a/test/src/main.rs +++ b/test/src/main.rs @@ -38,7 +38,8 @@ extern "C" fn rust_entry() -> ! { fn exit_qemu(success: bool) -> ! { // configured in Makefile let port = 0xf4; - let exit = qemu_exit::X86::new(port, 73); + // SAFETY: we have exclusive access and the port is valid + let exit = unsafe { qemu_exit::X86::new(port, 73) }; if success { exit.exit_success() } else {