From e820ae27b2fdf376405fb66827d799fffe13eda5 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sat, 15 Aug 2026 11:01:31 +0200 Subject: [PATCH 1/4] Reapply "deps: bump uart_16550 to 0.6.0" This reverts commit 313769e3fb46416f50e0c1aa9ba39a841d493930. --- Cargo.lock | 92 +++++--------- Cargo.toml | 1 + common/Cargo.toml | 2 +- common/src/serial.rs | 15 ++- examples/basic/Cargo.lock | 114 +----------------- examples/basic/kernel/Cargo.toml | 2 +- examples/basic/kernel/src/main.rs | 9 +- examples/basic/src/main.rs | 6 +- tests/test_kernels/Cargo.lock | 74 ++++-------- tests/test_kernels/config_file/Cargo.toml | 2 +- tests/test_kernels/config_file/src/lib.rs | 10 +- .../test_kernels/default_settings/Cargo.toml | 2 +- .../test_kernels/default_settings/src/lib.rs | 10 +- .../fixed_kernel_address/Cargo.toml | 2 +- .../fixed_kernel_address/src/lib.rs | 9 +- tests/test_kernels/higher_half/Cargo.toml | 2 +- tests/test_kernels/higher_half/src/lib.rs | 9 +- .../test_kernels/lower_memory_free/Cargo.toml | 2 +- .../test_kernels/lower_memory_free/src/lib.rs | 10 +- tests/test_kernels/lto/Cargo.toml | 2 +- tests/test_kernels/lto/src/lib.rs | 10 +- tests/test_kernels/map_phys_mem/Cargo.toml | 2 +- tests/test_kernels/map_phys_mem/src/lib.rs | 9 +- tests/test_kernels/min_stack/Cargo.toml | 2 +- tests/test_kernels/min_stack/src/lib.rs | 10 +- tests/test_kernels/pie/Cargo.toml | 2 +- tests/test_kernels/pie/src/lib.rs | 10 +- tests/test_kernels/ramdisk/Cargo.toml | 2 +- tests/test_kernels/ramdisk/src/lib.rs | 10 +- tests/test_kernels/stack_address/Cargo.toml | 2 +- tests/test_kernels/stack_address/src/lib.rs | 9 +- .../write_usable_memory/Cargo.toml | 2 +- .../write_usable_memory/src/lib.rs | 10 +- 33 files changed, 157 insertions(+), 298 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6cb7203..0f08b937 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,7 +138,7 @@ dependencies = [ "rsdp", "serde-json-core", "usize_conversions", - "x86_64 0.15.5", + "x86_64", ] [[package]] @@ -154,9 +154,9 @@ dependencies = [ "rand_hc", "raw-cpuid", "spinning_top", - "uart_16550 0.3.2", + "uart_16550", "usize_conversions", - "x86_64 0.15.5", + "x86_64", "xmas-elf", ] @@ -170,7 +170,7 @@ dependencies = [ "log", "serde-json-core", "uefi", - "x86_64 0.15.5", + "x86_64", ] [[package]] @@ -775,8 +775,8 @@ name = "test_kernel_config_file" version = "0.1.0" dependencies = [ "bootloader_api", - "uart_16550 0.2.18", - "x86_64 0.15.5", + "uart_16550", + "x86_64", ] [[package]] @@ -784,8 +784,8 @@ name = "test_kernel_default_settings" version = "0.1.0" dependencies = [ "bootloader_api", - "uart_16550 0.2.18", - "x86_64 0.15.5", + "uart_16550", + "x86_64", ] [[package]] @@ -793,8 +793,8 @@ name = "test_kernel_fixed_kernel_address" version = "0.1.0" dependencies = [ "bootloader_api", - "uart_16550 0.2.18", - "x86_64 0.15.5", + "uart_16550", + "x86_64", ] [[package]] @@ -802,8 +802,8 @@ name = "test_kernel_higher_half" version = "0.1.0" dependencies = [ "bootloader_api", - "uart_16550 0.2.18", - "x86_64 0.15.5", + "uart_16550", + "x86_64", ] [[package]] @@ -811,8 +811,8 @@ name = "test_kernel_lower_memory_free" version = "0.1.0" dependencies = [ "bootloader_api", - "uart_16550 0.2.18", - "x86_64 0.15.5", + "uart_16550", + "x86_64", ] [[package]] @@ -820,8 +820,8 @@ name = "test_kernel_map_phys_mem" version = "0.1.0" dependencies = [ "bootloader_api", - "uart_16550 0.2.18", - "x86_64 0.15.5", + "uart_16550", + "x86_64", ] [[package]] @@ -829,8 +829,8 @@ name = "test_kernel_min_stack" version = "0.1.0" dependencies = [ "bootloader_api", - "uart_16550 0.2.18", - "x86_64 0.15.5", + "uart_16550", + "x86_64", ] [[package]] @@ -838,8 +838,8 @@ name = "test_kernel_pie" version = "0.1.0" dependencies = [ "bootloader_api", - "uart_16550 0.2.18", - "x86_64 0.15.5", + "uart_16550", + "x86_64", ] [[package]] @@ -847,8 +847,8 @@ name = "test_kernel_ramdisk" version = "0.1.0" dependencies = [ "bootloader_api", - "uart_16550 0.2.18", - "x86_64 0.15.5", + "uart_16550", + "x86_64", ] [[package]] @@ -856,8 +856,8 @@ name = "test_kernel_stack_address" version = "0.1.0" dependencies = [ "bootloader_api", - "uart_16550 0.2.18", - "x86_64 0.15.5", + "uart_16550", + "x86_64", ] [[package]] @@ -865,8 +865,8 @@ name = "test_kernel_write_usable_memory" version = "0.1.0" dependencies = [ "bootloader_api", - "uart_16550 0.2.18", - "x86_64 0.15.5", + "uart_16550", + "x86_64", ] [[package]] @@ -891,24 +891,11 @@ dependencies = [ [[package]] name = "uart_16550" -version = "0.2.18" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b074eb9300ad949edd74c529c0e8d451625af71bb948e6b65fe69f72dc1363d9" -dependencies = [ - "bitflags 1.3.2", - "rustversion", - "x86_64 0.14.13", -] - -[[package]] -name = "uart_16550" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e492212ac378a5e00da953718dafb1340d9fbaf4f27d6f3c5cab03d931d1c049" +checksum = "22ee77075ecbc5e1c9b1236d03ff013dd77c7bb06da181c5c44f1f39b6cf3ff2" dependencies = [ "bitflags 2.11.1", - "rustversion", - "x86", ] [[package]] @@ -1199,29 +1186,6 @@ dependencies = [ "tap", ] -[[package]] -name = "x86" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385" -dependencies = [ - "bit_field", - "bitflags 1.3.2", - "raw-cpuid", -] - -[[package]] -name = "x86_64" -version = "0.14.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c101112411baafbb4bf8d33e4c4a80ab5b02d74d2612331c61e8192fc9710491" -dependencies = [ - "bit_field", - "bitflags 2.11.1", - "rustversion", - "volatile", -] - [[package]] name = "x86_64" version = "0.15.5" diff --git a/Cargo.toml b/Cargo.toml index 5d753c6f..ae709d43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ members = [ "tests/runner", ] exclude = ["examples/basic", "examples/test_framework", "tests/test_kernels/"] +resolver = "3" [workspace.package] # don't forget to update `workspace.dependencies` below diff --git a/common/Cargo.toml b/common/Cargo.toml index a3217ca5..9018ea72 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -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.3.2" +uart_16550 = "0.6.0" log = "0.4.17" [dependencies.noto-sans-mono-bitmap] diff --git a/common/src/serial.rs b/common/src/serial.rs index 8435c8e1..5c950a9f 100644 --- a/common/src/serial.rs +++ b/common/src/serial.rs @@ -1,7 +1,10 @@ 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::SerialPort, + port: uart_16550::Uart16550, } impl SerialPort { @@ -9,8 +12,10 @@ impl SerialPort { /// /// unsafe because this function must only be called once pub unsafe fn init() -> Self { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); + 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"); Self { port } } } @@ -19,8 +24,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.write_str("\r\n").unwrap(), - byte => self.port.send(byte), + b'\n' => self.port.send_bytes_exact(b"\r\n"), + byte => self.port.send_bytes_exact(&[byte]), } } Ok(()) diff --git a/examples/basic/Cargo.lock b/examples/basic/Cargo.lock index 6830aac4..74f02b41 100644 --- a/examples/basic/Cargo.lock +++ b/examples/basic/Cargo.lock @@ -471,15 +471,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" -[[package]] -name = "raw-cpuid" -version = "10.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "ring" version = "0.17.14" @@ -709,13 +700,11 @@ checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" [[package]] name = "uart_16550" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d293f51425981fdb1b766beae254dbb711a17e8c4b549dc69b9b7ee0d478d5" +checksum = "22ee77075ecbc5e1c9b1236d03ff013dd77c7bb06da181c5c44f1f39b6cf3ff2" dependencies = [ "bitflags 2.13.1", - "rustversion", - "x86", ] [[package]] @@ -929,94 +918,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "wit-bindgen" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" -dependencies = [ - "wit-bindgen-rust-macro", -] - -[[package]] -name = "wit-bindgen-core" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" -dependencies = [ - "anyhow", - "heck", - "wit-parser", -] - -[[package]] -name = "wit-bindgen-rust" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" -dependencies = [ - "anyhow", - "heck", - "indexmap", - "prettyplease", - "syn", - "wasm-metadata", - "wit-bindgen-core", - "wit-component", -] - -[[package]] -name = "wit-bindgen-rust-macro" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" -dependencies = [ - "anyhow", - "prettyplease", - "proc-macro2", - "quote", - "syn", - "wit-bindgen-core", - "wit-bindgen-rust", -] - -[[package]] -name = "wit-component" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" -dependencies = [ - "anyhow", - "bitflags 2.11.0", - "indexmap", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-encoder", - "wasm-metadata", - "wasmparser", - "wit-parser", -] - -[[package]] -name = "wit-parser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" -dependencies = [ - "anyhow", - "id-arena", - "indexmap", - "log", - "semver", - "serde", - "serde_derive", - "serde_json", - "unicode-xid", - "wasmparser", -] - [[package]] name = "wyz" version = "0.5.1" @@ -1026,17 +927,6 @@ dependencies = [ "tap", ] -[[package]] -name = "x86" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385" -dependencies = [ - "bit_field", - "bitflags 1.3.2", - "raw-cpuid", -] - [[package]] name = "x86_64" version = "0.15.5" diff --git a/examples/basic/kernel/Cargo.toml b/examples/basic/kernel/Cargo.toml index 5672bb7a..d2d53a5b 100644 --- a/examples/basic/kernel/Cargo.toml +++ b/examples/basic/kernel/Cargo.toml @@ -5,5 +5,5 @@ edition = "2024" [dependencies] bootloader_api = "0.11.12" -uart_16550 = "0.4.0" +uart_16550 = "0.6.0" x86_64 = "0.15.2" diff --git a/examples/basic/kernel/src/main.rs b/examples/basic/kernel/src/main.rs index df1eb848..29dc7d62 100644 --- a/examples/basic/kernel/src/main.rs +++ b/examples/basic/kernel/src/main.rs @@ -3,6 +3,8 @@ use bootloader_api::{BootInfo, entry_point}; use core::fmt::Write; +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u32)] @@ -24,10 +26,9 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } entry_point!(kernel_main); diff --git a/examples/basic/src/main.rs b/examples/basic/src/main.rs index 4ef3713d..65684c8a 100644 --- a/examples/basic/src/main.rs +++ b/examples/basic/src/main.rs @@ -62,8 +62,8 @@ fn main() { let mut child = cmd.spawn().expect("failed to start qemu-system-x86_64"); let status = child.wait().expect("failed to wait on qemu"); match status.code().unwrap_or(1) { - 0x10 => 0, // success - 0x11 => 1, // failure - _ => 2, // unknown fault + 0x10 => 0, // success + 0x11 => 1, // failure + _ => 2, // unknown fault }; } diff --git a/tests/test_kernels/Cargo.lock b/tests/test_kernels/Cargo.lock index 8fd2eb29..f41de2d2 100644 --- a/tests/test_kernels/Cargo.lock +++ b/tests/test_kernels/Cargo.lock @@ -10,42 +10,33 @@ checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" [[package]] name = "bitflags" -version = "1.3.2" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" [[package]] name = "bootloader_api" version = "0.11.17" +[[package]] +name = "const_fn" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413d67b29ef1021b4d60f4aa1e925ca031751e213832b4b1d588fae623c05c60" + [[package]] name = "rustversion" version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" -[[package]] -name = "test_kernel_config_file" -version = "0.1.0" -dependencies = [ - "bootloader_api", - "uart_16550", - "x86_64 0.15.2", -] - [[package]] name = "test_kernel_default_settings" version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64 0.15.2", + "x86_64", ] [[package]] @@ -54,7 +45,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64 0.15.2", + "x86_64", ] [[package]] @@ -63,7 +54,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64 0.15.2", + "x86_64", ] [[package]] @@ -72,7 +63,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64 0.15.2", + "x86_64", ] [[package]] @@ -81,7 +72,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64 0.15.2", + "x86_64", ] [[package]] @@ -90,7 +81,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64 0.15.2", + "x86_64", ] [[package]] @@ -99,7 +90,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64 0.15.2", + "x86_64", ] [[package]] @@ -108,7 +99,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64 0.15.2", + "x86_64", ] [[package]] @@ -117,7 +108,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64 0.15.2", + "x86_64", ] [[package]] @@ -126,7 +117,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64 0.15.2", + "x86_64", ] [[package]] @@ -135,18 +126,16 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64 0.15.2", + "x86_64", ] [[package]] name = "uart_16550" -version = "0.2.19" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614ff2a87880d4bd4374722268598a970bbad05ced8bf630439417347254ab2e" +checksum = "22ee77075ecbc5e1c9b1236d03ff013dd77c7bb06da181c5c44f1f39b6cf3ff2" dependencies = [ - "bitflags 1.3.2", - "rustversion", - "x86_64 0.14.13", + "bitflags", ] [[package]] @@ -157,24 +146,13 @@ checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793" [[package]] name = "x86_64" -version = "0.14.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c101112411baafbb4bf8d33e4c4a80ab5b02d74d2612331c61e8192fc9710491" -dependencies = [ - "bit_field", - "bitflags 2.8.0", - "rustversion", - "volatile", -] - -[[package]] -name = "x86_64" -version = "0.15.2" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f042214de98141e9c8706e8192b73f56494087cc55ebec28ce10f26c5c364ae" +checksum = "be4ec631e1a81d50e46c35a4a00322bd076c47491b64c2fb10a7ffa89002c697" dependencies = [ "bit_field", - "bitflags 2.8.0", + "bitflags", + "const_fn", "rustversion", "volatile", ] diff --git a/tests/test_kernels/config_file/Cargo.toml b/tests/test_kernels/config_file/Cargo.toml index 57cc20eb..1cbe41d9 100644 --- a/tests/test_kernels/config_file/Cargo.toml +++ b/tests/test_kernels/config_file/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.2.10" +uart_16550 = "0.6.0" diff --git a/tests/test_kernels/config_file/src/lib.rs b/tests/test_kernels/config_file/src/lib.rs index 4e46fdb6..c1536470 100644 --- a/tests/test_kernels/config_file/src/lib.rs +++ b/tests/test_kernels/config_file/src/lib.rs @@ -1,5 +1,8 @@ #![no_std] +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; + #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u32)] pub enum QemuExitCode { @@ -20,8 +23,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } diff --git a/tests/test_kernels/default_settings/Cargo.toml b/tests/test_kernels/default_settings/Cargo.toml index 276ff900..d78fa605 100644 --- a/tests/test_kernels/default_settings/Cargo.toml +++ b/tests/test_kernels/default_settings/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.2.10" +uart_16550 = "0.6.0" diff --git a/tests/test_kernels/default_settings/src/lib.rs b/tests/test_kernels/default_settings/src/lib.rs index 4e46fdb6..c1536470 100644 --- a/tests/test_kernels/default_settings/src/lib.rs +++ b/tests/test_kernels/default_settings/src/lib.rs @@ -1,5 +1,8 @@ #![no_std] +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; + #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u32)] pub enum QemuExitCode { @@ -20,8 +23,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } diff --git a/tests/test_kernels/fixed_kernel_address/Cargo.toml b/tests/test_kernels/fixed_kernel_address/Cargo.toml index 4d8a872c..ab28d7a3 100644 --- a/tests/test_kernels/fixed_kernel_address/Cargo.toml +++ b/tests/test_kernels/fixed_kernel_address/Cargo.toml @@ -8,4 +8,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.2.10" +uart_16550 = "0.6.0" diff --git a/tests/test_kernels/fixed_kernel_address/src/lib.rs b/tests/test_kernels/fixed_kernel_address/src/lib.rs index 9a8212e2..b9e342e8 100644 --- a/tests/test_kernels/fixed_kernel_address/src/lib.rs +++ b/tests/test_kernels/fixed_kernel_address/src/lib.rs @@ -1,6 +1,8 @@ #![no_std] use bootloader_api::{BootloaderConfig, config::Mapping}; +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; pub const KERNEL_ADDR: u64 = 0x1987_6543_0000; @@ -30,8 +32,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } diff --git a/tests/test_kernels/higher_half/Cargo.toml b/tests/test_kernels/higher_half/Cargo.toml index c215c8b3..16720551 100644 --- a/tests/test_kernels/higher_half/Cargo.toml +++ b/tests/test_kernels/higher_half/Cargo.toml @@ -11,6 +11,6 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.2.10" +uart_16550 = "0.6.0" # set to higher half through profile.test.rustflags key in top-level Cargo.toml diff --git a/tests/test_kernels/higher_half/src/lib.rs b/tests/test_kernels/higher_half/src/lib.rs index 99ae71dc..47636f04 100644 --- a/tests/test_kernels/higher_half/src/lib.rs +++ b/tests/test_kernels/higher_half/src/lib.rs @@ -1,6 +1,8 @@ #![no_std] use bootloader_api::BootloaderConfig; +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; pub const BOOTLOADER_CONFIG: BootloaderConfig = { let mut config = BootloaderConfig::new_default(); @@ -28,8 +30,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } diff --git a/tests/test_kernels/lower_memory_free/Cargo.toml b/tests/test_kernels/lower_memory_free/Cargo.toml index 643c33fe..1f51ef8e 100644 --- a/tests/test_kernels/lower_memory_free/Cargo.toml +++ b/tests/test_kernels/lower_memory_free/Cargo.toml @@ -8,4 +8,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.2.10" +uart_16550 = "0.6.0" diff --git a/tests/test_kernels/lower_memory_free/src/lib.rs b/tests/test_kernels/lower_memory_free/src/lib.rs index 4e46fdb6..c1536470 100644 --- a/tests/test_kernels/lower_memory_free/src/lib.rs +++ b/tests/test_kernels/lower_memory_free/src/lib.rs @@ -1,5 +1,8 @@ #![no_std] +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; + #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u32)] pub enum QemuExitCode { @@ -20,8 +23,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } diff --git a/tests/test_kernels/lto/Cargo.toml b/tests/test_kernels/lto/Cargo.toml index 0f8e4e3c..8cd8d2cb 100644 --- a/tests/test_kernels/lto/Cargo.toml +++ b/tests/test_kernels/lto/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.2.10" +uart_16550 = "0.6.0" diff --git a/tests/test_kernels/lto/src/lib.rs b/tests/test_kernels/lto/src/lib.rs index 4e46fdb6..c1536470 100644 --- a/tests/test_kernels/lto/src/lib.rs +++ b/tests/test_kernels/lto/src/lib.rs @@ -1,5 +1,8 @@ #![no_std] +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; + #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u32)] pub enum QemuExitCode { @@ -20,8 +23,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } diff --git a/tests/test_kernels/map_phys_mem/Cargo.toml b/tests/test_kernels/map_phys_mem/Cargo.toml index 7850d9f3..fcb3d83b 100644 --- a/tests/test_kernels/map_phys_mem/Cargo.toml +++ b/tests/test_kernels/map_phys_mem/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.2.10" +uart_16550 = "0.6.0" diff --git a/tests/test_kernels/map_phys_mem/src/lib.rs b/tests/test_kernels/map_phys_mem/src/lib.rs index 86301304..5b8ba446 100644 --- a/tests/test_kernels/map_phys_mem/src/lib.rs +++ b/tests/test_kernels/map_phys_mem/src/lib.rs @@ -1,6 +1,8 @@ #![no_std] use bootloader_api::{BootloaderConfig, config::Mapping}; +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; pub const BOOTLOADER_CONFIG: BootloaderConfig = { let mut config = BootloaderConfig::new_default(); @@ -28,8 +30,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } diff --git a/tests/test_kernels/min_stack/Cargo.toml b/tests/test_kernels/min_stack/Cargo.toml index b2864ee8..6e59ef40 100644 --- a/tests/test_kernels/min_stack/Cargo.toml +++ b/tests/test_kernels/min_stack/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.2.10" +uart_16550 = "0.6.0" diff --git a/tests/test_kernels/min_stack/src/lib.rs b/tests/test_kernels/min_stack/src/lib.rs index 4e46fdb6..c1536470 100644 --- a/tests/test_kernels/min_stack/src/lib.rs +++ b/tests/test_kernels/min_stack/src/lib.rs @@ -1,5 +1,8 @@ #![no_std] +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; + #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u32)] pub enum QemuExitCode { @@ -20,8 +23,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } diff --git a/tests/test_kernels/pie/Cargo.toml b/tests/test_kernels/pie/Cargo.toml index 93f71abd..40e18bab 100644 --- a/tests/test_kernels/pie/Cargo.toml +++ b/tests/test_kernels/pie/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.2.10" +uart_16550 = "0.6.0" diff --git a/tests/test_kernels/pie/src/lib.rs b/tests/test_kernels/pie/src/lib.rs index 4e46fdb6..c1536470 100644 --- a/tests/test_kernels/pie/src/lib.rs +++ b/tests/test_kernels/pie/src/lib.rs @@ -1,5 +1,8 @@ #![no_std] +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; + #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u32)] pub enum QemuExitCode { @@ -20,8 +23,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } diff --git a/tests/test_kernels/ramdisk/Cargo.toml b/tests/test_kernels/ramdisk/Cargo.toml index cc48a77e..69e8cff4 100644 --- a/tests/test_kernels/ramdisk/Cargo.toml +++ b/tests/test_kernels/ramdisk/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.2.10" +uart_16550 = "0.6.0" diff --git a/tests/test_kernels/ramdisk/src/lib.rs b/tests/test_kernels/ramdisk/src/lib.rs index 00ea92a6..b8185d92 100644 --- a/tests/test_kernels/ramdisk/src/lib.rs +++ b/tests/test_kernels/ramdisk/src/lib.rs @@ -1,5 +1,8 @@ #![no_std] +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; + #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u32)] pub enum QemuExitCode { @@ -22,8 +25,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } diff --git a/tests/test_kernels/stack_address/Cargo.toml b/tests/test_kernels/stack_address/Cargo.toml index 28b59198..3f2614ab 100644 --- a/tests/test_kernels/stack_address/Cargo.toml +++ b/tests/test_kernels/stack_address/Cargo.toml @@ -8,4 +8,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.2.10" +uart_16550 = "0.6.0" diff --git a/tests/test_kernels/stack_address/src/lib.rs b/tests/test_kernels/stack_address/src/lib.rs index 9a8212e2..b9e342e8 100644 --- a/tests/test_kernels/stack_address/src/lib.rs +++ b/tests/test_kernels/stack_address/src/lib.rs @@ -1,6 +1,8 @@ #![no_std] use bootloader_api::{BootloaderConfig, config::Mapping}; +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; pub const KERNEL_ADDR: u64 = 0x1987_6543_0000; @@ -30,8 +32,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } diff --git a/tests/test_kernels/write_usable_memory/Cargo.toml b/tests/test_kernels/write_usable_memory/Cargo.toml index 1a9d1f96..1aa122ce 100644 --- a/tests/test_kernels/write_usable_memory/Cargo.toml +++ b/tests/test_kernels/write_usable_memory/Cargo.toml @@ -8,4 +8,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.2.10" +uart_16550 = "0.6.0" diff --git a/tests/test_kernels/write_usable_memory/src/lib.rs b/tests/test_kernels/write_usable_memory/src/lib.rs index 4e46fdb6..c1536470 100644 --- a/tests/test_kernels/write_usable_memory/src/lib.rs +++ b/tests/test_kernels/write_usable_memory/src/lib.rs @@ -1,5 +1,8 @@ #![no_std] +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; + #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u32)] pub enum QemuExitCode { @@ -20,8 +23,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! { } } -pub fn serial() -> uart_16550::SerialPort { - let mut port = unsafe { uart_16550::SerialPort::new(0x3F8) }; - port.init(); - port +pub fn serial() -> Uart16550Tty { + unsafe { Uart16550Tty::new_port(0x3F8, Config::default()) } + .expect("should initialize serial device from valid config and valid port") } From 3ad9b6bb095bfc8ee4e29c2b42a2ad2e21051e4c Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sat, 15 Aug 2026 11:02:32 +0200 Subject: [PATCH 2/4] deps: bump uart_16550 to 0.8.0 --- Cargo.lock | 24 +++++++++---------- common/Cargo.toml | 2 +- examples/basic/kernel/Cargo.toml | 2 +- tests/test_kernels/Cargo.lock | 13 ++++++++-- tests/test_kernels/config_file/Cargo.toml | 2 +- .../test_kernels/default_settings/Cargo.toml | 2 +- .../fixed_kernel_address/Cargo.toml | 2 +- tests/test_kernels/higher_half/Cargo.toml | 2 +- .../test_kernels/lower_memory_free/Cargo.toml | 2 +- tests/test_kernels/lto/Cargo.toml | 2 +- tests/test_kernels/map_phys_mem/Cargo.toml | 2 +- tests/test_kernels/min_stack/Cargo.toml | 2 +- tests/test_kernels/pie/Cargo.toml | 2 +- tests/test_kernels/ramdisk/Cargo.toml | 2 +- tests/test_kernels/stack_address/Cargo.toml | 2 +- .../write_usable_memory/Cargo.toml | 2 +- 16 files changed, 37 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f08b937..4c1a99f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,9 +52,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.11.1" +version = "2.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" +checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" [[package]] name = "bitvec" @@ -318,7 +318,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8283e7331b8c93b9756e0cfdbcfb90312852f953c6faf9bf741e684cc3b6ad69" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.1", "crc", "log", "uuid", @@ -615,7 +615,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.1", "errno", "libc", "linux-raw-sys", @@ -891,11 +891,11 @@ dependencies = [ [[package]] name = "uart_16550" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ee77075ecbc5e1c9b1236d03ff013dd77c7bb06da181c5c44f1f39b6cf3ff2" +checksum = "f9c24d1751f909d9e2d192475ca5527964e13dbc3126ce20c288dfa8f3a3e734" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.1", ] [[package]] @@ -913,7 +913,7 @@ version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8f2e1b4a439d82899da4dc0ee8ac742db07a9ff493bc4f31d345c24e12e17e9" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.1", "cfg-if", "log", "ptr_meta", @@ -940,7 +940,7 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8868c2fb03f31e55ccf9b47f72e17097bb88c45306cb82f5a2258935520c72d6" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.1", "uguid", ] @@ -1062,7 +1062,7 @@ version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.1", "hashbrown 0.15.5", "indexmap", "semver", @@ -1147,7 +1147,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" dependencies = [ "anyhow", - "bitflags 2.11.1", + "bitflags 2.13.1", "indexmap", "log", "serde", @@ -1193,7 +1193,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4ec631e1a81d50e46c35a4a00322bd076c47491b64c2fb10a7ffa89002c697" dependencies = [ "bit_field", - "bitflags 2.11.1", + "bitflags 2.13.1", "const_fn", "rustversion", "volatile", diff --git a/common/Cargo.toml b/common/Cargo.toml index 9018ea72..6ff3aee0 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -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.8.0" log = "0.4.17" [dependencies.noto-sans-mono-bitmap] diff --git a/examples/basic/kernel/Cargo.toml b/examples/basic/kernel/Cargo.toml index d2d53a5b..2ec60ce8 100644 --- a/examples/basic/kernel/Cargo.toml +++ b/examples/basic/kernel/Cargo.toml @@ -5,5 +5,5 @@ edition = "2024" [dependencies] bootloader_api = "0.11.12" -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" x86_64 = "0.15.2" diff --git a/tests/test_kernels/Cargo.lock b/tests/test_kernels/Cargo.lock index f41de2d2..ba73a5b0 100644 --- a/tests/test_kernels/Cargo.lock +++ b/tests/test_kernels/Cargo.lock @@ -30,6 +30,15 @@ version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" +[[package]] +name = "test_kernel_config_file" +version = "0.1.0" +dependencies = [ + "bootloader_api", + "uart_16550", + "x86_64", +] + [[package]] name = "test_kernel_default_settings" version = "0.1.0" @@ -131,9 +140,9 @@ dependencies = [ [[package]] name = "uart_16550" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ee77075ecbc5e1c9b1236d03ff013dd77c7bb06da181c5c44f1f39b6cf3ff2" +checksum = "f9c24d1751f909d9e2d192475ca5527964e13dbc3126ce20c288dfa8f3a3e734" dependencies = [ "bitflags", ] diff --git a/tests/test_kernels/config_file/Cargo.toml b/tests/test_kernels/config_file/Cargo.toml index 1cbe41d9..fc4d2f0f 100644 --- a/tests/test_kernels/config_file/Cargo.toml +++ b/tests/test_kernels/config_file/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" diff --git a/tests/test_kernels/default_settings/Cargo.toml b/tests/test_kernels/default_settings/Cargo.toml index d78fa605..ec600dd1 100644 --- a/tests/test_kernels/default_settings/Cargo.toml +++ b/tests/test_kernels/default_settings/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" diff --git a/tests/test_kernels/fixed_kernel_address/Cargo.toml b/tests/test_kernels/fixed_kernel_address/Cargo.toml index ab28d7a3..9e98799a 100644 --- a/tests/test_kernels/fixed_kernel_address/Cargo.toml +++ b/tests/test_kernels/fixed_kernel_address/Cargo.toml @@ -8,4 +8,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" diff --git a/tests/test_kernels/higher_half/Cargo.toml b/tests/test_kernels/higher_half/Cargo.toml index 16720551..b0d31bc9 100644 --- a/tests/test_kernels/higher_half/Cargo.toml +++ b/tests/test_kernels/higher_half/Cargo.toml @@ -11,6 +11,6 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" # set to higher half through profile.test.rustflags key in top-level Cargo.toml diff --git a/tests/test_kernels/lower_memory_free/Cargo.toml b/tests/test_kernels/lower_memory_free/Cargo.toml index 1f51ef8e..1f94ded2 100644 --- a/tests/test_kernels/lower_memory_free/Cargo.toml +++ b/tests/test_kernels/lower_memory_free/Cargo.toml @@ -8,4 +8,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" diff --git a/tests/test_kernels/lto/Cargo.toml b/tests/test_kernels/lto/Cargo.toml index 8cd8d2cb..413435b6 100644 --- a/tests/test_kernels/lto/Cargo.toml +++ b/tests/test_kernels/lto/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" diff --git a/tests/test_kernels/map_phys_mem/Cargo.toml b/tests/test_kernels/map_phys_mem/Cargo.toml index fcb3d83b..660510f2 100644 --- a/tests/test_kernels/map_phys_mem/Cargo.toml +++ b/tests/test_kernels/map_phys_mem/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" diff --git a/tests/test_kernels/min_stack/Cargo.toml b/tests/test_kernels/min_stack/Cargo.toml index 6e59ef40..83c6cb3b 100644 --- a/tests/test_kernels/min_stack/Cargo.toml +++ b/tests/test_kernels/min_stack/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" diff --git a/tests/test_kernels/pie/Cargo.toml b/tests/test_kernels/pie/Cargo.toml index 40e18bab..f3499be0 100644 --- a/tests/test_kernels/pie/Cargo.toml +++ b/tests/test_kernels/pie/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" diff --git a/tests/test_kernels/ramdisk/Cargo.toml b/tests/test_kernels/ramdisk/Cargo.toml index 69e8cff4..db0a2e52 100644 --- a/tests/test_kernels/ramdisk/Cargo.toml +++ b/tests/test_kernels/ramdisk/Cargo.toml @@ -9,4 +9,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" diff --git a/tests/test_kernels/stack_address/Cargo.toml b/tests/test_kernels/stack_address/Cargo.toml index 3f2614ab..f381e658 100644 --- a/tests/test_kernels/stack_address/Cargo.toml +++ b/tests/test_kernels/stack_address/Cargo.toml @@ -8,4 +8,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" diff --git a/tests/test_kernels/write_usable_memory/Cargo.toml b/tests/test_kernels/write_usable_memory/Cargo.toml index 1aa122ce..59d4323e 100644 --- a/tests/test_kernels/write_usable_memory/Cargo.toml +++ b/tests/test_kernels/write_usable_memory/Cargo.toml @@ -8,4 +8,4 @@ bootloader_api = { path = "../../../api" } x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", ] } -uart_16550 = "0.6.0" +uart_16550 = "0.8.0" From afcccd6c8c77e1a45b39ed6a5d7263fb1df101f5 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sun, 16 Aug 2026 10:39:37 +0200 Subject: [PATCH 3/4] uefi: take full ownership of serial device; disconnect UEFI console To properly use `Uart16550::init()`, we need to have full ownership of the serial device. Otherwise, there is undefined runtime behavior caused by the interaction with the UEFI console driver that also claims ownership of the device. This is needed to replace our own serial logger with the Uart16550Tty type of the uart_16550 crate. It ensures much clearer separations of concerns and ensures this crate can log reliably on a variety of real hardware. --- Changelog.md | 5 +++++ common/src/serial.rs | 33 --------------------------------- uefi/src/main.rs | 13 ++++++++++++- 3 files changed, 17 insertions(+), 34 deletions(-) delete mode 100644 common/src/serial.rs diff --git a/Changelog.md b/Changelog.md index cb45513a..3e308d51 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ # Unreleased +- When booting on UEFI, whatever is written to the UEFI console + (e.g., via the SIMPLE_TEXT_OUTPUT_PROTOCOL) is no longer replicated to the + serial device. The bootloader's own logger now takes full ownership of the + serial device, ensuring safe and reliable logging. + # 0.11.17 - 2026-07-27 * [Revert `uart_16550` version bump to 0.6.0](https://github.com/rust-osdev/bootloader/pull/575) diff --git a/common/src/serial.rs b/common/src/serial.rs deleted file mode 100644 index 5c950a9f..00000000 --- a/common/src/serial.rs +++ /dev/null @@ -1,33 +0,0 @@ -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, -} - -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"); - Self { port } - } -} - -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]), - } - } - Ok(()) - } -} diff --git a/uefi/src/main.rs b/uefi/src/main.rs index 13a28526..49cfdd25 100644 --- a/uefi/src/main.rs +++ b/uefi/src/main.rs @@ -10,10 +10,12 @@ use bootloader_x86_64_common::{ }; use core::net::Ipv4Addr; use core::{ptr, slice}; +use uefi::boot::SearchType; use uefi::mem::memory_map::{MemoryMap, MemoryMapMut}; +use uefi::proto::console::serial::Serial; use uefi::table::cfg::ConfigTableEntry; use uefi::{ - CStr8, CStr16, boot, + CStr8, CStr16, Identify, boot, boot::{AllocateType, MemoryType}, cstr8, cstr16, prelude::{Status, entry}, @@ -395,6 +397,15 @@ fn init_logger(config: &BootConfig) -> Option { stride: mode_info.stride(), }; + // Disconnect the UEFI console from the serial device. + // Our own logger takes full ownership of the serial device. + { + if let Ok(handles) = boot::locate_handle_buffer(SearchType::ByProtocol(&Serial::GUID)) { + for handle in handles.iter() { + let _ = boot::disconnect_controller(*handle, None, None); + } + }; + } bootloader_x86_64_common::init_logger( slice, info, From c6d62d7d85a040388229c960722674b18a9cf863 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sun, 16 Aug 2026 14:14:16 +0200 Subject: [PATCH 4/4] uefi: migrate to uart_16550 based logger --- common/src/lib.rs | 2 -- common/src/logger.rs | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/common/src/lib.rs b/common/src/lib.rs index 2e36c742..45de8f69 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -34,8 +34,6 @@ pub mod level_4_entries; pub mod load_kernel; /// Provides a logger that logs output as text in various formats. pub mod logger; -/// Provides a type that logs output as text to a Serial Being port. -pub mod serial; const PAGE_SIZE: u64 = 4096; diff --git a/common/src/logger.rs b/common/src/logger.rs index a7491c58..365f1840 100644 --- a/common/src/logger.rs +++ b/common/src/logger.rs @@ -1,8 +1,10 @@ -use crate::{framebuffer::FrameBufferWriter, serial::SerialPort}; +use crate::framebuffer::FrameBufferWriter; use bootloader_api::info::FrameBufferInfo; use conquer_once::spin::OnceCell; use core::fmt::Write; use spinning_top::Spinlock; +use uart_16550::backend::PioBackend; +use uart_16550::{Config, Uart16550Tty}; /// The global logger instance used for the `log` crate. pub static LOGGER: OnceCell = OnceCell::uninit(); @@ -10,7 +12,7 @@ pub static LOGGER: OnceCell = OnceCell::uninit(); /// A logger instance protected by a spinlock. pub struct LockedLogger { framebuffer: Option>, - serial: Option>, + serial: Option>>, } impl LockedLogger { @@ -27,7 +29,17 @@ impl LockedLogger { }; let serial = match serial_logger_status { - true => Some(Spinlock::new(unsafe { SerialPort::init() })), + true => { + // SAFETY: We have exclusive access to the device. + // + // This returns `None` if the config is invalid or the self-test fails. + // We do not panic here because we want to continue booting. + unsafe { + Uart16550Tty::new_port(0x3f8, Config::default()) + .ok() + .map(Spinlock::new) + } + } false => None, };