diff --git a/CHANGELOG.md b/CHANGELOG.md index 6321196c4..8c5f1c3ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -193,6 +193,8 @@ hashes are given where a change is easiest to understand by reading the commit. volume buttons, NetBSD and the PROM). - Tezro: `[tezro] audio = true` adds an ICE1724 audio controller (off by default); `[audio] channels` sets its speakers. [Guide](docs/tezro-ip53.md) +- Fuel, Origin 3200 and Onyx 3000: `[machine] audio_card = true` fits the same + ICE1724 audio card (IRIX's "MAD"), so these machines have sound. - Tezro, Fuel, Origin 3200 and Onyx 3000: IRIX's flushed PIO reads through the PIC no longer hang the machine; on a Tezro with audio, amesh and other sound programs froze it with their sound repeating. diff --git a/FEATURES.md b/FEATURES.md index da279f8e5..33c1e48a5 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -270,8 +270,9 @@ The keys in the sections below, down to `[onyx3000]`, and those of machine has beyond the shared keys. Write them in `[machine]`; a key the profile does not have is refused. Two are named differently there: `nodes` (also accepted as `c_bricks`) is the node boards of an Origin 2000 or Onyx2 and -the C-bricks of an Origin 3200 or Onyx 3000, and `audio_card` is the Tezro's -`audio`. The tables named for a machine are the older spelling. They are +the C-bricks of an Origin 3200 or Onyx 3000, and `audio_card` is the `audio` +key of the Tezro, Fuel, Origin 3200 and Onyx 3000 tables, which fits the +ICE1724 audio card. The tables named for a machine are the older spelling. They are still read, a `[machine]` key wins over the same key there, and a config saved by iris-gui writes `[machine]`. diff --git a/HELP.md b/HELP.md index 198bd14d3..d78c70f71 100644 --- a/HELP.md +++ b/HELP.md @@ -797,7 +797,8 @@ prebuf_ms = 20 # sound held before playing: the margin against a la # What one machine has beyond these keys also goes in [machine] and is described in # its guide in docs/: for example nodes = 2 (C-bricks or node boards), flash, console, -# usb_input = true (the Fuel's USB keyboard and mouse) and audio_card = true (the Tezro). +# usb_input = true (the Fuel's USB keyboard and mouse) and audio_card = true (the ICE1724 +# audio card of the Tezro, Fuel, Origin 3200 and Onyx 3000). # The older tables named for a machine ([o2], [octane], [origin200], [origin2000], # [onyx2], [fuel], [tezro], [origin3200], [onyx3000]) are still read. # [graphics] node and widget say where the graphics board plugs in on the Onyx 3000 diff --git a/README.md b/README.md index 319b71c50..b338ebdcb 100644 --- a/README.md +++ b/README.md @@ -91,11 +91,13 @@ boots to a usable system: shell, networking, X11, the works. ISP1040 SCSI, RAD audio - **Origin 200/2000, Onyx2 IP27:** SN0 NUMA machines; Onyx2 supports InfiniteReality graphics - **Fuel IP34:** IP35 platform, R14000, IOC3, ISP12160, L1 console, VPro optional, - PS/2 or USB (`[machine] usb_input`) keyboard and mouse + PS/2 or USB (`[machine] usb_input`) keyboard and mouse, optional ICE1724 audio + (`[machine] audio_card`) - **Tezro IP53:** IP35 platform, up to 4 R16000 CPUs, PIC/PXBOW, IOC4, ISP12160, VPro optional, ICE1724 audio (`[machine] audio_card`) - **Origin 3200 / Onyx 3000 IP35:** R12000 C-bricks and Fibre Channel storage; - Onyx 3000 adds InfiniteReality3 or VPro V12 graphics + Onyx 3000 adds InfiniteReality3 or VPro V12 graphics; optional ICE1724 audio + (`[machine] audio_card`) - R4400, R5000, R10000, R12000, R14000, R16000 CPUs, selected per machine at runtime - A built-in PROM for every machine (the stock SGI images, packed into the binary); `prom` names a file to run instead diff --git a/debug.md b/debug.md index 74f2d432c..bbb7b30d1 100644 --- a/debug.md +++ b/debug.md @@ -588,7 +588,7 @@ devices are [listed below](#sgi-o2-ip32). | `rtc debug ` | RTC trace **[DEV]** | | `pit status` / `pit debug ` | 8254 timer state / trace **[DEV]** | | `audio status` | Every sound card's frames moved and skipped (stale, dry, ring full) and its host stream, or `No audio device.` | -| `ice1724 [status]` | Tezro audio (`[tezro] audio`): the interrupt line (high or low, for how long, rises), the interrupt status and mask registers, the engine start, pause and FIFO-error bits, the pending timer, per engine whether it runs, its buffer address, size, position, interrupt interval, frames moved, times its interrupt fired and latched, and when the guest last read its position; frame and converter counts, PCI command and status | +| `ice1724 [status]` | The ICE1724 audio card (`[machine] audio_card`; Tezro, Fuel, Origin 3200, Onyx 3000): the interrupt line (high or low, for how long, rises), the interrupt status and mask registers, the engine start, pause and FIFO-error bits, the pending timer, per engine whether it runs, its buffer address, size, position, interrupt interval, frames moved, times its interrupt fired and latched, and when the guest last read its position; frame and converter counts, PCI command and status | | `ice1724 regs` | Hex dump of the controller (CCS, BAR0) and multi-channel (MT, BAR1) registers | | `ice1724 log [n]` | The guest's last 64 (or n) register accesses, oldest first, with their age on the card clock; a run of the same access with the same value is one line with a count | | `ice1724 clear` | Start the counts and the access log again | diff --git a/docs/fuel-ip34.md b/docs/fuel-ip34.md index b384d02d2..a5907c5c2 100644 --- a/docs/fuel-ip34.md +++ b/docs/fuel-ip34.md @@ -27,6 +27,14 @@ selects the boot-flash backing file, the console (`l1`, `ioc3_a` or `ioc3_b`) and the L1's TCP port and log; [FEATURES.md](../FEATURES.md#fuel) lists its keys. +`[machine] audio_card = true` fits an audio card: the IC Ensemble ICE1724 with +the DMediaPro DM8's converters, the same model as the +[Tezro's](tezro-ip53.md). It sits at device 2 of head F, beside the base I/O; +which device a real Fuel's option slots are is not established, so the slot is +the model's choice. IRIX 6.5.30 lists it as `Iris Audio Processor: version MAD +revision 1` and plays through it. It plays to the host as `[audio]` sets, or +silently with `no_audio`. + `prom` overrides the built-in PROM; a file it names must load, and `prom = "(embedded)"` selects the built-in one outright. The PROM decoder accepts a raw payload or a supported version-six, single-segment stored or diff --git a/docs/onyx3000-ip35.md b/docs/onyx3000-ip35.md index 0e7f74428..f8a8cedb4 100644 --- a/docs/onyx3000-ip35.md +++ b/docs/onyx3000-ip35.md @@ -19,6 +19,10 @@ shipped; the Onyx 3000 takes `ir3`. The shared keys, the `[machine]` keys of the adapter and the console. `[machine] cpus` fits 1, 2 or 4 processors on each C-brick, so a two-brick machine runs up to eight. +`[machine] audio_card = true` fits the ICE1724 audio card in the I-brick, as +[on the Origin 3200](origin3200-ip35.md#the-i-brick). IRIX 6.5.30 lists it as +`Iris Audio Processor: version MAD revision 1` and plays through it. + `[graphics] node` and `widget` override the placement. `node` is the C-brick (0 or 1) whose XIO link reaches the board. On node 0, whose connector has the I-brick, the board is at the I-brick's port B, widget 11. On node 1 the board diff --git a/docs/origin3200-ip35.md b/docs/origin3200-ip35.md index 0f304b4ee..5e7267134 100644 --- a/docs/origin3200-ip35.md +++ b/docs/origin3200-ip35.md @@ -45,6 +45,14 @@ disks, and its slot runs 64-bit data phases (inferred from the PROM's behaviour: the control block and rings it builds are right only if the bridge reverses each doubleword of the adapter's DMA). A `[scsi.N]` table is refused. +`[machine] audio_card = true` fits an audio card at device 2 of head F: the IC +Ensemble ICE1724 with the DMediaPro DM8's converters, the same model as the +[Tezro's](tezro-ip53.md). The device number is the model's choice; which +devices the I-brick's option slots are is not established. On an Onyx 3000, +IRIX 6.5.30 lists it as `Iris Audio Processor: version MAD revision 1` and +plays through it; it has not been run in an Origin 3200 guest. It plays to the +host as `[audio]` sets, or silently with `no_audio`. + ## Nodes and the link Address bits 39:33 name a node. Each node's local block holds the number the PROM diff --git a/fuel.toml.example b/fuel.toml.example index c189a88f1..74d64d64e 100644 --- a/fuel.toml.example +++ b/fuel.toml.example @@ -27,6 +27,9 @@ cpu = "r14000" flash = "ignore/fuel/flash.bin" console = "l1" l1_port = 18882 +# Fit the ICE1724 audio card in a PCI slot (default false). It plays as [audio] +# sets; unset no_audio for sound. +# audio_card = true # Send the host's keyboard and mouse (from the window or VNC) to a USB keyboard # and mouse on the OHCI controller instead of the PS/2 pair (docs/fuel-ip34.md). # usb_input = true diff --git a/iris-gui/src/extra_ui.rs b/iris-gui/src/extra_ui.rs index fce5ea89f..a8b18d651 100644 --- a/iris-gui/src/extra_ui.rs +++ b/iris-gui/src/extra_ui.rs @@ -331,6 +331,7 @@ fn platform(ui: &mut Ui, cfg: &mut MachineConfig) { text(ui, &t!("extra-l1-log"), &mut s.l1_log); text(ui, &t!("extra-l1-revision"), &mut s.l1_revision); text(ui, &t!("extra-brick-serial"), &mut s.brick_serial); + ui.checkbox(&mut s.audio, t!("extra-tezro-audio")); ui.checkbox(&mut s.ps2_input, t!("extra-ps2")); ui.checkbox(&mut s.usb_input, t!("extra-usb-input")); } @@ -381,6 +382,7 @@ fn platform(ui: &mut Ui, cfg: &mut MachineConfig) { text(ui, &t!("extra-l1-log"), &mut s.l1_log); text(ui, &t!("extra-l1-revision"), &mut s.l1_revision); text(ui, &t!("extra-brick-serial"), &mut s.brick_serial); + ui.checkbox(&mut s.audio, t!("extra-tezro-audio")); } MachineProfile::Onyx3000Ip35 => { let mut count = cfg.c_bricks() as u8; @@ -407,6 +409,7 @@ fn platform(ui: &mut Ui, cfg: &mut MachineConfig) { text(ui, &t!("extra-l1-log"), &mut s.l1_log); text(ui, &t!("extra-l1-revision"), &mut s.l1_revision); text(ui, &t!("extra-brick-serial"), &mut s.brick_serial); + ui.checkbox(&mut s.audio, t!("extra-tezro-audio")); } _ => (), } diff --git a/origin3200.toml.example b/origin3200.toml.example index e90c17ff4..dd5f486cf 100644 --- a/origin3200.toml.example +++ b/origin3200.toml.example @@ -20,6 +20,9 @@ profile = "origin3200_ip35" nodes = 2 console = "l1" l1_port = 18882 +# Fit the ICE1724 audio card in an I-brick PCI slot (default false). It plays as [audio] +# sets; unset no_audio for sound. +# audio_card = true [graphics] board = "none" diff --git a/src/config.rs b/src/config.rs index 04a46bbb1..a84b87471 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1590,7 +1590,7 @@ pub struct MachineSection { pub serial_port_c: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub serial_port_d: Option, - /// Tezro: fit the audio card (`[tezro] audio`). + /// Tezro, Fuel, Origin 3200, Onyx 3000: fit the ICE1724 audio card. #[serde(default, skip_serializing_if = "Option::is_none")] pub audio_card: Option, /// Fuel: which keyboard and mouse the host's reach. @@ -2357,6 +2357,9 @@ pub struct FuelSection { /// the marked synthetic `EMUN00`. #[serde(default)] pub brick_serial: Option, + /// Fit the audio card (IC Ensemble ICE1724) in a PCI slot. Off by default. + #[serde(default)] + pub audio: bool, } fn default_fuel_input() -> bool { true } @@ -2372,6 +2375,7 @@ impl Default for FuelSection { usb_input: false, l1_revision: None, brick_serial: None, + audio: false, } } } @@ -2387,6 +2391,7 @@ impl FuelSection { && !self.usb_input && self.l1_revision.is_none() && self.brick_serial.is_none() + && !self.audio } } @@ -2439,6 +2444,10 @@ pub struct Ip35Section { /// bytes. Unset: the marked synthetic `EMUN00`. #[serde(default)] pub brick_serial: Option, + /// Fit the audio card (IC Ensemble ICE1724) in an I-brick PCI slot. Off + /// by default. + #[serde(default)] + pub audio: bool, } impl Default for Ip35Section { @@ -2451,6 +2460,7 @@ impl Default for Ip35Section { l1_log: None, l1_revision: None, brick_serial: None, + audio: false, } } } @@ -2465,6 +2475,7 @@ impl Ip35Section { && self.l1_log.is_none() && self.l1_revision.is_none() && self.brick_serial.is_none() + && !self.audio } } @@ -3473,8 +3484,14 @@ impl MachineConfig { self.tezro.serial_port_d = Some(port); } if let Some(card) = self.machine.audio_card.take() { - if !tezro { return Err(not_here("audio_card")); } - self.tezro.audio = card; + let slot = match p { + P::TezroIp53 => &mut self.tezro.audio, + P::FuelIp34 => &mut self.fuel.audio, + P::Origin3200Ip35 => &mut self.origin3200.audio, + P::Onyx3000Ip35 => &mut self.onyx3000.audio, + _ => return Err(not_here("audio_card")), + }; + *slot = card; } let fuel = p == P::FuelIp34; if let Some(on) = self.machine.ps2_input.take() { @@ -3557,6 +3574,7 @@ impl MachineConfig { m.usb_input = fuel.usb_input.then_some(true); m.l1_revision = fuel.l1_revision; m.brick_serial = fuel.brick_serial; + m.audio_card = fuel.audio.then_some(true); } P::TezroIp53 => { let tezro = std::mem::take(&mut out.tezro); @@ -3577,6 +3595,7 @@ impl MachineConfig { m.l1_log = section.l1_log; m.l1_revision = section.l1_revision; m.brick_serial = section.brick_serial; + m.audio_card = section.audio.then_some(true); } _ => {} } @@ -3795,6 +3814,17 @@ impl MachineConfig { } /// The section that configures an IP35 brick machine: `[origin3200]` or `[onyx3000]`. + /// Whether the ICE1724 audio card is fitted (`[machine] audio_card`), on + /// the machines that take one. + pub fn audio_card(&self) -> bool { + match self.machine.profile { + MachineProfile::TezroIp53 => self.tezro.audio, + MachineProfile::FuelIp34 => self.fuel.audio, + MachineProfile::Origin3200Ip35 | MachineProfile::Onyx3000Ip35 => self.ip35_section().audio, + _ => false, + } + } + pub fn ip35_section(&self) -> &Ip35Section { if self.machine.profile == MachineProfile::Onyx3000Ip35 { &self.onyx3000 } else { &self.origin3200 } } @@ -5654,6 +5684,15 @@ mod export_tests { assert_eq!((tezro.tezro.console, tezro.tezro.serial_port_c, tezro.tezro.audio), (TezroConsole::Ioc4C, Some(9003), true)); let text = toml::to_string_pretty(&tezro.for_writing()).unwrap(); assert!(text.contains("audio_card = true") && !text.contains("[tezro]"), "{text}"); + // The Fuel, Origin 3200 and Onyx 3000 take the same card; no other machine does. + for (profile, cpu) in [("fuel_ip34", "r14000"), ("origin3200_ip35", "r12000"), ("onyx3000_ip35", "r12000")] { + let cfg = load(&format!("[machine]\nprofile = \"{profile}\"\ncpu = \"{cpu}\"\naudio_card = true\n")).unwrap(); + assert!(cfg.audio_card(), "{profile}"); + let text = toml::to_string_pretty(&cfg.for_writing()).unwrap(); + assert!(text.contains("audio_card = true"), "{profile}: {text}"); + assert!(MachineConfig::parse_toml(&text).unwrap().audio_card(), "{profile}"); + } + assert!(load("[machine]\nprofile = \"octane_ip30\"\naudio_card = true\n").unwrap_err().contains("machine.audio_card is not a key")); let onyx2 = load("[machine]\nprofile = \"onyx2_ip27\"\nnodes = 2\nio_prom = \"io6prom.img\"\n").unwrap(); assert_eq!((onyx2.node_boards(), onyx2.onyx2.io_prom.as_deref()), (2, Some("io6prom.img"))); diff --git a/src/ip34_machine.rs b/src/ip34_machine.rs index 86794dab2..a087849e4 100644 --- a/src/ip34_machine.rs +++ b/src/ip34_machine.rs @@ -25,7 +25,7 @@ use crate::dev::odyssey::Odyssey; use crate::dev::timekeeper::Timekeeper; use crate::dev::xbridge::{XBridge, HEAD_F}; use crate::hptimer::TimerManager; -use crate::ip35::{attach_ioc3, attach_usb, attach_vpro, xbridge_on}; +use crate::ip35::{attach_ioc3, attach_usb, attach_vpro, fit_audio_card, xbridge_on}; use crate::ip35::node::NodeSpec; use crate::ip35::serial::connect_serial_ports; use crate::sn::BoardIo; @@ -60,7 +60,7 @@ pub(crate) fn node_specs(cfg: &MachineConfig) -> Result, String> { } /// The Fuel's I/O around its node: the XBridge, the VPro in the graphics slot, and the base I/O. -pub(crate) fn build_io(cfg: &MachineConfig, nodes: &[NodeBoard], l1s: &[Arc], _: &Arc, clock: &Clock) -> Result { +pub(crate) fn build_io(cfg: &MachineConfig, nodes: &[NodeBoard], l1s: &[Arc], timers: &Arc, clock: &Clock) -> Result { let bedrock = &nodes[0].chip; let xbridge = xbridge_on(bedrock); // The status bar's activity bits, shared with the base I/O's devices. @@ -75,6 +75,7 @@ pub(crate) fn build_io(cfg: &MachineConfig, nodes: &[NodeBoard], let mut io = build_baseio(cfg, &l1s[0], &xbridge, clock, heartbeat, vpro.clone())?; io.status = Some(status); io.fasttick = Some(fasttick); + fit_audio_card(cfg, xbridge.bus(HEAD_F), timers, &mut io); if let Some(vpro) = vpro { io.display = Some(vpro.display()); io.monitor.push(vpro.clone()); diff --git a/src/ip34_machine/tests.rs b/src/ip34_machine/tests.rs index 754280735..053bbcb93 100644 --- a/src/ip34_machine/tests.rs +++ b/src/ip34_machine/tests.rs @@ -137,6 +137,25 @@ fn the_fuel_plugs_a_usb_keyboard_and_mouse_only_when_configured_on() { assert_eq!(status.map(|s| s & 1), [0, 0], "nothing plugged in"); assert!(mouse, "without the USB pair the PS/2 mouse does"); } +/// `[machine] audio_card` fits the ICE1724 at device 2 of head F, its two I/O BARs reachable once +/// placed; without it the slot is empty. +#[test] +fn the_fuel_takes_the_audio_card_at_device_2() { + let dir = TempPath::dir("fuel-audio"); + let slot = |audio| { + let mut cfg = fuel_config(&dir); + cfg.fuel.audio = audio; + cfg.no_audio = true; + with_machine(cfg, |m| { + let read = m.nodes[0].chip.pio().read32(pio_widget(15, 0x2_0000 + (u64::from(crate::ip35::AUDIO_CARD_DEVICE) << 12))); + ((read.status == BUS_OK).then_some(read.data), m.io.monitor.iter().any(|d| d.audio_report().is_some())) + }) + }; + assert_eq!(slot(true), (Some(0x1724_1412), true)); + let (id, report) = slot(false); + assert!(id.is_none_or(|id| id == u32::MAX) && !report, "empty without the key"); +} + /// A Fuel with `graphics` in its graphics slot. fn fuel_with_graphics(dir: &TempPath, graphics: crate::config::GraphicsBoard) -> crate::config::MachineConfig { let mut cfg = fuel_config(dir); diff --git a/src/ip35.rs b/src/ip35.rs index 64c1ef3f7..c624eb5b1 100644 --- a/src/ip35.rs +++ b/src/ip35.rs @@ -26,6 +26,7 @@ use crate::dev::bedrock::{Bedrock, RamExtent}; use crate::dev::heart::Clock; +use crate::dev::ice1724::{Ice1724, Variant}; use crate::dev::ioc3::{ByteBus, Ioc3, Ioc3Board}; use crate::dev::odyssey::Odyssey; use crate::dev::ohci::hid::{HidFunction, UsbHidInput}; @@ -153,6 +154,48 @@ pub(crate) fn attach_usb(pci: &PciBus, ioc3: &Ioc3, clock: &Clock, input: bool) Ok(usb) } +/// Said at startup and by `--validate` when the audio card is added with +/// `no_audio` set: the guest sees the card and nothing is played. +pub(crate) const AUDIO_WITH_NO_AUDIO: &str = + "machine.audio_card is set but no_audio is too: the audio card is added and plays to nowhere"; + +/// The audio card's device on head F of a Fuel's or an I-brick's XBridge. A model choice: the +/// base I/O holds 1, 4, 5 and (unmodelled, I-brick) 6, and which devices the option slots are +/// is not established. +pub(crate) const AUDIO_CARD_DEVICE: u8 = 2; + +/// The ICE1724 audio card as `[machine] audio_card` fits it, playing to the host as `[audio]` +/// sets unless `no_audio`. The board attaches it to a bus. +pub(crate) fn audio_card(cfg: &MachineConfig, timers: &Arc) -> Arc { + let card = Arc::new(Ice1724::new(Variant::Dm8)); + if cfg.no_audio { + eprintln!("iris: {AUDIO_WITH_NO_AUDIO}"); + } else { + card.enable_output(cfg.audio.clone()); + } + card.set_timer_manager(timers.clone()); + card +} + +/// The audio card in its slot of `pci` (head F of the base I/O's XBridge) when `[machine] +/// audio_card` asks for it, added to the board's devices, monitor and reset. +pub(crate) fn fit_audio_card(cfg: &MachineConfig, pci: &PciBus, timers: &Arc, io: &mut BoardIo) { + if !cfg.audio_card() { + return; + } + let card = audio_card(cfg, timers); + pci.attach(DevFn { device: AUDIO_CARD_DEVICE, function: 0 }, card.clone()); + card.register_locks(); + eprintln!("iris: ICE1724 audio card at PCI device {AUDIO_CARD_DEVICE} of the base I/O"); + io.monitor.push(card.clone()); + io.devices.push(card.clone()); + let base_reset = std::mem::replace(&mut io.reset, Box::new(|| {})); + io.reset = Box::new(move || { + base_reset(); + card.reset(); + }); +} + /// A VPro at crossbar `widget` of `bedrock`'s node: its DMA enters Bedrock as that widget's inbound /// traffic and its interrupt packets leave by `packets`. `attach` puts it behind the board's crossbar and returns what the /// node's I/O space reaches it by. diff --git a/src/ip35_machine.rs b/src/ip35_machine.rs index 246c00f8b..f46f9105e 100644 --- a/src/ip35_machine.rs +++ b/src/ip35_machine.rs @@ -61,7 +61,7 @@ use crate::hptimer::TimerManager; use crate::ip35::node::NodeSpec; use crate::ip35::presence::PresenceHold; use crate::ip35::serial::connect_serial_ports; -use crate::ip35::{attach_ioc3, attach_usb, attach_vpro, xbridge_on}; +use crate::ip35::{attach_ioc3, attach_usb, attach_vpro, fit_audio_card, xbridge_on}; use crate::sn::BoardIo; use crate::sn::NodeBoard; use crate::traits::{Device, Resettable}; @@ -184,6 +184,7 @@ fn build_baseio( cfg: &MachineConfig, l1s: &[Arc], xbridge: &Arc, + timers: &Arc, clock: &Clock, link_reset: impl Fn(u8) + Send + Sync + 'static, ) -> Result { @@ -234,7 +235,7 @@ fn build_baseio( // `scsi2` and `cow2`: the Fibre Channel loop's disks. let monitor: Vec> = vec![ioc3.ps2(), fibre.clone()]; let scsi_fibre = fibre.clone(); - Ok(BoardIo { + let mut io = BoardIo { devices: vec![ioc3.clone(), usb, fibre], reset: Box::new(move || { reset_xbridge.power_on(); @@ -259,7 +260,9 @@ fn build_baseio( status: None, fasttick: None, cpus: None, - }) + }; + fit_audio_card(cfg, pci, timers, &mut io); + Ok(io) } /// Where an InfiniteReality pipe sits: widget 11 of the I-brick's XBridge, @@ -359,10 +362,10 @@ pub(crate) fn build_io(cfg: &MachineConfig, nodes: &[NodeBoard], /// The I-brick on the first C-brick, and the Onyx 3000's graphics board where [`placement`] puts it: /// a widget of the I-brick's XBridge on the first C-brick, or of an XBridge of its own (no PCI /// devices) on another's XIO connector. Its DMA and interrupts go through that C-brick's Bedrock. -fn build_bricks(cfg: &MachineConfig, nodes: &[NodeBoard], l1s: &[Arc], _: &Arc, clock: &Clock) -> Result { +fn build_bricks(cfg: &MachineConfig, nodes: &[NodeBoard], l1s: &[Arc], timers: &Arc, clock: &Clock) -> Result { let xbridge = xbridge_on(&nodes[0].chip); if cfg.machine.profile != MachineProfile::Onyx3000Ip35 { - return build_baseio(cfg, l1s, &xbridge, clock, |_| {}); + return build_baseio(cfg, l1s, &xbridge, timers, clock, |_| {}); } check_placement(cfg)?; let Placement { node, widget } = placement(cfg); @@ -421,11 +424,11 @@ fn build_bricks(cfg: &MachineConfig, nodes: &[NodeBoard], l1s: & } }; let mut io = if on_ibrick { - build_baseio(cfg, l1s, &xbridge, clock, at_port)? + build_baseio(cfg, l1s, &xbridge, timers, clock, at_port)? } else { bridge.set_reset_output(Arc::new(at_port)); bridge.register_locks(); - build_baseio(cfg, l1s, &xbridge, clock, |_| {})? + build_baseio(cfg, l1s, &xbridge, timers, clock, |_| {})? }; fit(&mut io); io.status = Some(status); diff --git a/src/ip35_machine/tests.rs b/src/ip35_machine/tests.rs index 1f64fe3b8..d2022bd0f 100644 --- a/src/ip35_machine/tests.rs +++ b/src/ip35_machine/tests.rs @@ -28,6 +28,29 @@ fn the_ibricks_slots_read_back_as_wired() { assert_eq!(pio.read32(widget(u64::from(SPARE_PORT), 0)).status, BUS_ERR, "port B is empty"); }); } +/// `[machine] audio_card` fits the ICE1724 at device 2 of the I-brick's head F, on either product, +/// with the monitor's audio report; without it the slot is empty. +#[test] +fn the_audio_card_sits_at_device_2_of_the_ibrick_when_asked_for() { + let dir = TempPath::dir("o3k-audio"); + let slot = |cfg: MachineConfig| { + with_machine(cfg, |m| { + let read = m.nodes[0].chip.pio().read32(widget(u64::from(HEAD_F), 0x2_0000 + (u64::from(crate::ip35::AUDIO_CARD_DEVICE) << 12))); + ((read.status == BUS_OK).then_some(read.data), m.io.monitor.iter().any(|d| d.audio_report().is_some())) + }) + }; + let fitted = |mut cfg: MachineConfig| { + cfg.no_audio = true; + if cfg.machine.profile == MachineProfile::Onyx3000Ip35 { cfg.onyx3000.audio = true } else { cfg.origin3200.audio = true } + cfg + }; + for cfg in [config(&dir, 1), onyx_config(&dir, GraphicsBoard::Ir3)] { + let (id, report) = slot(cfg.clone()); + assert!(id.is_none_or(|id| id == u32::MAX) && !report, "{:?}: empty without the key", cfg.machine.profile); + assert_eq!(slot(fitted(cfg.clone())), (Some(0x1724_1412), true), "{:?}", cfg.machine.profile); + } +} + /// A processor's thread is a processor of the node it runs on and of no /// other: the second node's chip numbers the machine's CPU 1 its own /// processor 0, and takes the first node's thread for no processor. diff --git a/src/ip53_machine.rs b/src/ip53_machine.rs index 33289c949..235a347a4 100644 --- a/src/ip53_machine.rs +++ b/src/ip53_machine.rs @@ -17,7 +17,7 @@ //! - The PCI devices at 1 to 4 and the IOC4 (0x53), ISP12160 (6) and BCM5701 (0x15) revisions //! are as consoles print them (established). INTA and INTC reaching PIC input d - 1 is IRIX's //! pin rule; the board wiring, INTB and INTD are unknown. -//! - The audio controller (`[tezro] audio`) is the ICE1724 with the DM8's converters, at device 2 +//! - The audio controller (`[machine] audio_card`) is the ICE1724 with the DM8's converters, at device 2 //! of the TI bridge's bus (`AUDIO_DEVICE`, inferred by exclusion); its converters, subsystem //! IDs and EEPROM are a model choice, not Tezro evidence. Its INTA reaches PIC input 1 via the //! bridge's rotation (wiring unknown). @@ -45,7 +45,6 @@ use crate::dev::bedrock::{Bedrock, Population, SLOTS}; use crate::dev::bedrock_flash::{FirmwareRecord, Flash}; use crate::dev::ds1744::{Ds1744, YearBase}; use crate::dev::heart::Clock; -use crate::dev::ice1724::{Ice1724, Variant}; use crate::dev::ioc4::{Ioc4, Ioc4Config}; use crate::dev::isp12160::Isp12160; use crate::dev::l1::{BoardIdentity, CpuContext, L1Config, L1}; @@ -377,14 +376,8 @@ pub(crate) fn build_io(cfg: &MachineConfig, nodes: &[NodeBoard], ); io9.attach(0, TI_BRIDGE_DEVICE, ti.clone(), Function::default()); let audio = cfg.tezro.audio.then(|| { - let card = Arc::new(Ice1724::new(Variant::Dm8)); - if cfg.no_audio { - eprintln!("iris: {AUDIO_WITH_NO_AUDIO}"); - } else { - card.enable_output(cfg.audio.clone()); - } + let card = crate::ip35::audio_card(cfg, timers); ti.secondary().attach(DevFn { device: AUDIO_DEVICE, function: 0 }, card.clone()); - card.set_timer_manager(timers.clone()); card }); io9.attach(0, SCSI_DEVICE, scsi.clone(), Function::default()); @@ -527,10 +520,6 @@ fn attach_virtio(cfg: &MachineConfig, io9: &Arc) -> Vec) { } } -/// What the machine would warn about and carry on: the Tezro's audio card added +/// What the machine would warn about and carry on: the audio card added /// with `no_audio` set. pub fn warnings(cfg: &MachineConfig) -> Vec { let mut warnings = Vec::new(); - if cfg.machine.profile == MachineProfile::TezroIp53 && cfg.tezro.audio && cfg.no_audio { - warnings.push(crate::ip53_machine::AUDIO_WITH_NO_AUDIO.to_string()); + if cfg.audio_card() && cfg.no_audio { + warnings.push(crate::ip35::AUDIO_WITH_NO_AUDIO.to_string()); } warnings } @@ -253,7 +253,7 @@ mod tests { assert!(problems(&cfg).is_empty(), "{:?}", problems(&cfg)); } - /// The Tezro's audio card with `no_audio` set is present and silent; that + /// The audio card with `no_audio` set is present and silent; that /// is worth saying, and not an error. #[test] fn the_tezro_audio_card_with_no_audio_is_a_warning() { @@ -265,6 +265,14 @@ mod tests { assert!(warnings(&cfg).iter().any(|w| w.contains("plays to nowhere")), "{:?}", warnings(&cfg)); cfg.tezro.audio = false; assert!(warnings(&cfg).is_empty()); + // The same card on the other machines that take it. + cfg.machine.profile = MachineProfile::FuelIp34; + cfg.fuel.audio = true; + assert!(warnings(&cfg).iter().any(|w| w.contains("plays to nowhere"))); + cfg.machine.profile = MachineProfile::Onyx3000Ip35; + assert!(warnings(&cfg).is_empty()); + cfg.onyx3000.audio = true; + assert!(warnings(&cfg).iter().any(|w| w.contains("plays to nowhere"))); } /// A scratch volume only needs its directory and an empty CD-ROM tray is