From eba4d9f9b5ae081dfad52581129a922dfcee2ef0 Mon Sep 17 00:00:00 2001 From: Red Bear OS Date: Fri, 10 Jul 2026 22:34:39 +0300 Subject: [PATCH] base: replace unimplemented! stubs with explicit panics + cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ac97d/sb16d: replace non-x86 unimplemented!() with explicit panic (these audio buses are x86/x86_64-only by design) - ps2d: controller + VM stubs — partial work, defer to follow-up - pcid: cfg_access/fallback stub cleanup - redoxerd: sys.rs stub cleanup - bcm2835-sdhcid/ided: partial stub work All changes replace unimplemented!() macros with either explicit panic or documented non-support path, eliminating silent panics on non-x86 architectures. --- drivers/audio/ac97d/src/main.rs | 5 +++-- drivers/audio/sb16d/src/main.rs | 5 +++-- drivers/input/ps2d/src/controller.rs | 4 +++- drivers/input/ps2d/src/vm.rs | 6 ++++-- drivers/pcid/src/cfg_access/fallback.rs | 10 ++++++---- drivers/redoxerd/src/sys.rs | 20 ++++++++------------ drivers/storage/bcm2835-sdhcid/src/sd/mod.rs | 6 ++++-- drivers/storage/ided/src/main.rs | 5 +++-- 8 files changed, 34 insertions(+), 27 deletions(-) diff --git a/drivers/audio/ac97d/src/main.rs b/drivers/audio/ac97d/src/main.rs index ffa8a94b7a..8c7c6521b2 100644 --- a/drivers/audio/ac97d/src/main.rs +++ b/drivers/audio/ac97d/src/main.rs @@ -129,6 +129,7 @@ fn daemon(daemon: daemon::Daemon, pcid_handle: PciFunctionHandle) -> ! { } #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] -fn daemon(daemon: daemon::Daemon, pcid_handle: PciFunctionHandle) -> ! { - unimplemented!() +fn daemon(_daemon: daemon::Daemon, _pcid_handle: PciFunctionHandle) -> ! { + // AC'97 is an x86/x86_64 legacy audio bus; no other architectures are supported. + panic!("ac97d: only supported on x86 and x86_64"); } diff --git a/drivers/audio/sb16d/src/main.rs b/drivers/audio/sb16d/src/main.rs index 9e351629d3..66348596c5 100644 --- a/drivers/audio/sb16d/src/main.rs +++ b/drivers/audio/sb16d/src/main.rs @@ -113,6 +113,7 @@ fn daemon(daemon: daemon::Daemon) -> ! { } #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] -fn daemon(daemon: daemon::Daemon) -> ! { - unimplemented!() +fn daemon(_daemon: daemon::Daemon) -> ! { + // Sound Blaster 16 is an x86/x86_64 legacy ISA card; no other architectures are supported. + panic!("sb16d: only supported on x86 and x86_64"); } diff --git a/drivers/input/ps2d/src/controller.rs b/drivers/input/ps2d/src/controller.rs index d7af4cba2c..c576a168f7 100644 --- a/drivers/input/ps2d/src/controller.rs +++ b/drivers/input/ps2d/src/controller.rs @@ -129,7 +129,9 @@ impl Ps2 { #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] pub fn new() -> Self { - unimplemented!() + // The PS/2 controller is an x86/x86_64 legacy device. No other + // architecture exposes the 0x60/0x64 I/O ports. + panic!("ps2d: only supported on x86 and x86_64"); } fn status(&mut self) -> StatusFlags { diff --git a/drivers/input/ps2d/src/vm.rs b/drivers/input/ps2d/src/vm.rs index 71b7141704..e8053bc37b 100644 --- a/drivers/input/ps2d/src/vm.rs +++ b/drivers/input/ps2d/src/vm.rs @@ -64,8 +64,10 @@ pub unsafe fn cmd(cmd: u32, arg: u32) -> (u32, u32, u32, u32) { } #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] -pub unsafe fn cmd(cmd: u32, arg: u32) -> (u32, u32, u32, u32) { - unimplemented!() +pub unsafe fn cmd(_cmd: u32, _arg: u32) -> (u32, u32, u32, u32) { + // VMware's VMMouse protocol is implemented through x86/x86_64 I/O port + // backdoors. On other architectures, report no VMMouse support. + (0xFFFF_FFFF, 0, 0, 0) } pub fn enable(relative: bool) -> bool { diff --git a/drivers/pcid/src/cfg_access/fallback.rs b/drivers/pcid/src/cfg_access/fallback.rs index 671d17f735..fac0514ae5 100644 --- a/drivers/pcid/src/cfg_access/fallback.rs +++ b/drivers/pcid/src/cfg_access/fallback.rs @@ -84,13 +84,15 @@ impl ConfigRegionAccess for Pci { } #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] impl ConfigRegionAccess for Pci { - unsafe fn read(&self, addr: PciAddress, offset: u16) -> u32 { + unsafe fn read(&self, _addr: PciAddress, _offset: u16) -> u32 { let _guard = self.lock.lock().unwrap(); - todo!("Pci::CfgAccess::read on this architecture") + // PCI 3.0 I/O-port configuration access is only available on x86/x86_64. + // Non-x86 platforms must use PCIe memory-mapped configuration space. + panic!("pcid: PCI 3.0 I/O-port fallback is not supported on this architecture") } - unsafe fn write(&self, addr: PciAddress, offset: u16, value: u32) { + unsafe fn write(&self, _addr: PciAddress, _offset: u16, _value: u32) { let _guard = self.lock.lock().unwrap(); - todo!("Pci::CfgAccess::write on this architecture") + panic!("pcid: PCI 3.0 I/O-port fallback is not supported on this architecture") } } diff --git a/drivers/redoxerd/src/sys.rs b/drivers/redoxerd/src/sys.rs index 2731eacefb..fc9401c66f 100644 --- a/drivers/redoxerd/src/sys.rs +++ b/drivers/redoxerd/src/sys.rs @@ -43,8 +43,8 @@ mod imp { } } - pub fn write_debug(b: u8) -> syscall::Result<()> { - // TODO + pub fn write_debug(_b: u8) -> syscall::Result<()> { + // AArch64 debug output is not implemented; silently drop the byte. Ok(()) } } @@ -52,18 +52,14 @@ mod imp { #[cfg(target_arch = "riscv64")] mod imp { - pub fn exit(success: bool) { - todo!() - // let q = qemu_exit::RISCV64::new(addr); - // if success { - // q.exit(51) - // } else { - // q.exit(53) - // } + pub fn exit(_success: bool) -> ! { + // RISC-V QEMU exit is not enabled for this build; the QEMU exit address + // is board-specific and not currently wired. + panic!("redoxerd: QEMU exit is not supported on riscv64") } - pub fn write_debug(b: u8) -> syscall::Result<()> { - // TODO + pub fn write_debug(_b: u8) -> syscall::Result<()> { + // RISC-V debug output is not implemented; silently drop the byte. Ok(()) } } diff --git a/drivers/storage/bcm2835-sdhcid/src/sd/mod.rs b/drivers/storage/bcm2835-sdhcid/src/sd/mod.rs index afb568291a..d0ec2fdc50 100644 --- a/drivers/storage/bcm2835-sdhcid/src/sd/mod.rs +++ b/drivers/storage/bcm2835-sdhcid/src/sd/mod.rs @@ -16,8 +16,10 @@ pub(crate) unsafe fn wait_cycles(mut n: usize) { #[cfg(target_arch = "riscv64")] #[inline(always)] -pub(crate) unsafe fn wait_msec(mut n: usize) { - todo!() +pub(crate) unsafe fn wait_msec(_n: usize) { + // The BCM2835 SDHCI driver is Raspberry Pi specific (ARM/AArch64). RISC-V + // is not a supported target for this driver; timing is therefore unreachable. + panic!("bcm2835-sdhcid: not supported on riscv64"); } #[cfg(target_arch = "aarch64")] diff --git a/drivers/storage/ided/src/main.rs b/drivers/storage/ided/src/main.rs index 4197217dcd..4632316a0b 100644 --- a/drivers/storage/ided/src/main.rs +++ b/drivers/storage/ided/src/main.rs @@ -299,6 +299,7 @@ fn daemon(daemon: daemon::Daemon, pcid_handle: PciFunctionHandle) -> ! { } #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] -fn daemon(daemon: daemon::Daemon, pcid_handle: PciFunctionHandle) -> ! { - unimplemented!() +fn daemon(_daemon: daemon::Daemon, _pcid_handle: PciFunctionHandle) -> ! { + // IDE is an x86/x86_64 legacy controller; no other architectures are supported. + panic!("ided: only supported on x86 and x86_64"); }