A GameCube/Wii emulator and debugger written in Rust.
sd card stub, dsp dma remaining blocks mmio
Layle384d11a6b2aa
diff --git a/crates/gecko/src/flipper/dsp.rs b/crates/gecko/src/flipper/dsp.rsindex 810eb1e..d2c029f 100644--- a/crates/gecko/src/flipper/dsp.rs+++ b/crates/gecko/src/flipper/dsp.rs@@ -265,6 +265,7 @@ crate::mmio_device_dispatch! {regs::AramDmaControl,regs::AudioDmaStartAddr,regs::AudioDmaControl,+ regs::AudioDmaBlocksLeft,],}diff --git a/crates/gecko/src/flipper/dsp/regs.rs b/crates/gecko/src/flipper/dsp/regs.rsindex 52d9c5c..ba1427d 100644--- a/crates/gecko/src/flipper/dsp/regs.rs+++ b/crates/gecko/src/flipper/dsp/regs.rs@@ -292,6 +292,21 @@ impl<const SYSTEM: SystemId> MmioAccess<System<SYSTEM>> for AudioDmaControl {}}+// 0xCC00503A 2 [R] Audio DMA Blocks Remaining++#[chapa::bitfield(u16, order = lsb0)]+#[derive(Copy, Clone, Debug)]+pub struct AudioDmaBlocksLeft {}+crate::mmio_reg!(AudioDmaBlocksLeft: u16 @ 0xCC00503A);++impl<const SYSTEM: SystemId> MmioAccess<System<SYSTEM>> for AudioDmaBlocksLeft {+ fn read(gc: &mut System<SYSTEM>) -> Self {+ Self::from_raw(gc.ai.audio_dma_remaining_blocks.saturating_sub(1))+ }++ fn write(self, _: &mut System<SYSTEM>, _: WriteMask) {}+}+// 0xCC005028 4 [R/W] ARAM DMA Count/Control#[derive(BitEnum, Debug, PartialEq, Eq)]diff --git a/crates/gecko/src/hollywood/ipc.rs b/crates/gecko/src/hollywood/ipc.rsindex 503f6ef..4ced231 100644--- a/crates/gecko/src/hollywood/ipc.rs+++ b/crates/gecko/src/hollywood/ipc.rs@@ -1,6 +1,7 @@pub mod di;pub mod es;pub mod fs;+pub mod sdio;pub mod stm;pub mod usb;diff --git a/crates/gecko/src/hollywood/ipc/sdio.rs b/crates/gecko/src/hollywood/ipc/sdio.rsnew file mode 100644index 0000000..e639bed--- /dev/null+++ b/crates/gecko/src/hollywood/ipc/sdio.rs@@ -0,0 +1,50 @@+use crate::hollywood::ipc::{IPC_EINVAL, IosDevice};++pub const IOCTL_GET_DEVICE_STATUS: u32 = 11;+pub const IOCTL_SEND_CMD: u32 = 7;++#[chapa::bitfield(u32, order = lsb0)]+#[derive(Clone, Copy)]+#[rustfmt::skip]+struct DeviceStatus {+ #[bits(0)] sd_card_inserted: bool,+ #[bits(1)] sd_card_not_inserted: bool,+ #[bits(2)] sd_card_write_unprotected: bool,+ #[bits(16)] sd_card_initialized: bool,+ #[bits(20)] sd_card_is_sdhc: bool,+}++pub struct SdCard;++impl IosDevice for SdCard {+ fn ioctl(+ &mut self,+ ctx: &mut super::DeviceContext<'_>,+ cmd: u32,+ _in_ptr: u32,+ _in_len: u32,+ out_ptr: u32,+ out_len: u32,+ ) -> i32 {+ match cmd {+ IOCTL_GET_DEVICE_STATUS => {+ let status = DeviceStatus::new()+ .with_sd_card_inserted(false)+ .with_sd_card_not_inserted(true)+ .with_sd_card_write_unprotected(false)+ .with_sd_card_initialized(false)+ .with_sd_card_is_sdhc(false);+ ctx.mmio.phys_write_u32(out_ptr, status.raw());+ 0+ }+ IOCTL_SEND_CMD => {+ ctx.mmio.phys_slice_mut(out_ptr, out_len as usize).fill(0);+ 0+ }+ _ => {+ tracing::error!(cmd = format!("{cmd:#010X}"), "SDIO: unimplemented ioctl");+ IPC_EINVAL+ }+ }+ }+}diff --git a/crates/gecko/src/starlet.rs b/crates/gecko/src/starlet.rsindex 1e2d1e9..064e557 100644--- a/crates/gecko/src/starlet.rs+++ b/crates/gecko/src/starlet.rs@@ -127,6 +127,7 @@ impl System<{ crate::WII }> {self.starlet.register("/dev/es", Box::new(ipc::es::ETicketServices));self.starlet.register("/dev/usb/oh1/57e/305", Box::new(ipc::usb::Bluetooth::new()));+ self.starlet.register("/dev/sdio/slot0", Box::new(ipc::sdio::SdCard));}pub fn create_device_context(&mut self) -> (&mut Starlet, DeviceContext<'_>) {