Skip to content

ports: network, camera and audio as devices at their ports - #926

Merged
jamesbraid merged 4 commits into
techomancer:mainfrom
jamesbraid:ports-devices
Nov 30, 2026
Merged

jamesbraid merged 4 commits into
techomancer:mainfrom
jamesbraid:ports-devices

Conversation

@jamesbraid

@jamesbraid jamesbraid commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Builds on main: #891 has merged, and this branch is rebased onto it.

The serial ports already take their host end as a device at the port. The Ethernet, the Indy's camera and the sound chips still took theirs from [network], [vino] and [audio], plus the --net-mode, --pcap-interface and --audio-host flags. Each is a port too, so each now takes the same [[devices]] entry: net at ethernet, camera at video, audio at audio. none at a port unplugs it; it is the only way to unplug the Ethernet (backend = "none" on a net entry is refused). An unplugged Ethernet has no entry, so it has the machine's own MAC; a MAC set on a plugged port goes with the entry.

The first commit is a bug in main's graphics board code that this PR made easy to hit: graphics_entry() counted any none as "no graphics board", so none at a PCI slot of an Onyx 3000 made graphics_board() return None instead of Ir3. It is its own commit and does not depend on the rest.

none at the machine's graphics slot (graphics, gio0, an Onyx 3000 pipe slot) still only keeps the default board out and leaves the slot free; at any other slot it holds the slot, so an emptied port stays empty and nothing unplaced lands there. That includes an Octane's xio9, 10 and 11, which take a graphics board but are not its graphics slot. A board named at a none still takes the slot, in either order.

The common case writes nothing. A port with no entry gets NAT, no camera on the Indy's VINO, and host sound, as before.

One change, on the command line or in the file:

--device net@ethernet,backend=pcap:eth0

A card brings its own port under its slot. On a Tezro, an ICE1724 named snd has snd/audio:

[[devices]]
type = "ice1724"
name = "snd"
at   = "xio15/pci0/2/pci0/2"

[[devices]]
type    = "audio"
at      = "snd/audio"
backend = "file:out.wav"

iris-gui wrote [network] mode = "nat", [vino] and [audio] into every machine it saved, so refusing them would have broken every saved machine. They are now read with one warning line and turned into the entries in memory (a default value says nothing and leaves no entry; a non-default old key beside an entry at the same port is an error, as a serial tcp clash is; a table for a port the machine does not have is dropped with a warning). They are listed in the same table as the other older keys and named in the one "older config keys" line; the GUI saves the entries. The --net-mode, --pcap-interface and --audio-host flags stay as hidden options and set the same entry (the way --serial-port-a and --graphics do), and a flag beats the file, whether the file wrote an older key or an entry at the port: they are applied after the file is read through set_net and set_audio. o2.net = false follows the same rule as the other older keys. [network] keeps the NAT gateway's services (tftp_dir, rsh_dir, nfs_pcap_ip, rx_hold, the subnet and the port forwards), and no_audio stays a run-mode flag. The machine and the GUI read and write the entry through net_end(), vino() and audio() views, so the fields the code reads are unchanged.

In the GUI, the status bar reads the Ethernet once per change of the config instead of placing the machine every frame. Switching the network mode forgets the PCAP interface or stream peer of the mode it leaves; the entry keeps the current one across a save.

A serial midi_synth is not at the sound chip's port, so it takes a backend of its own (the audio values) instead of following the machine's audio entry: none at audio does not mute it, and a machine with no sound port (the Fuel, the Origin machines) can still send it to null or a file.

The GUI's MAC, stream peer and subnet fields write the config as they are typed, so its status, summary and interface reads use the entry (ethernet()) and never build a NetworkConfig. Choosing Stream before a peer is typed keeps the mode; validate reports the missing peer before Start. network(), vino() and the audio port expect a config that validates.

The camera has no model key: the Indy's VINO takes the IndyCam and nothing else.

Production lines per commit are non-test Rust (code above mod tests and non-test files), comments and blanks included, recounted on this head.

Tested on head c04bb2b (on main 3ff8298), in the iris-build image, debug profile: cargo check --all-targets at each of the four commits (root crate only); cargo nextest run --no-fail-fast: 5281 passed, 0 failed; with --features jitv2 --features rex-jit --features gputrace: 6010 passed, 0 failed; cargo nextest run -p iris-gui-core: 183 passed. The release profile and Windows were not run, and neither was an iris-ci boot-test of the pinned IRIX 6.5.22 Indy disk. New tests: a none at a PCI slot of an Onyx 3000 keeps the Ir3, a none at the Indy's gio0 leaves it free for a card, a none at an Octane's second-board slot leaves it free for a board, a none at an Octane's xio10 keeps an unplaced shoehorn out, a --net-mode off beats a net entry at nat, --audio-host null beats an audio entry, and an older key that is not the default beside an entry is an error (net, o2.net, vino, audio).

Refs #828

VINO's video source came from a `[vino]` table, away from the other host
ends. The camera is a device at a port like the rest: VINO is a slot
`vino` on the Indy (the Indigo2 has the EISA bus there) with one input,
`vino/video`, alias `video`, and a `camera` entry at it plugs a picture
in. `backend` is webcam:N, test_pattern or black, and `standard` is ntsc
or pal. The O2 models no video input, so it has no such slot. There is
no model key: VINO takes the IndyCam and nothing else. With no entry
VINO stays mapped with no source and no DMA thread, exactly what `source
= "off"` did, so that value goes and the table's default needs no entry.

iris-gui wrote a `[vino]` table into every machine it saved, so refusing
it would have made every saved machine fail to load. The table is read
with a warning and turned into the entry in memory, and the GUI saves the entry. A table at its defaults (`source = "off"`)
says nothing and leaves no entry. Any other table beside an entry at the
port is an error, as a serial port's tcp clash is; where the machine has
no video input it is dropped with a warning. The GUI edits the entry
through the machine's `vino()` view, which expects a valid backend: the
file path checks it at parse and the GUI builds it from an enum.

Production lines: +146 -54

; Conflicts:
;	src/config/legacy.rs
;	src/machine.rs
;	src/topology.rs
[audio] set the host output of every sound chip at once, and
--audio-host overrode part of it, while a serial port or the Ethernet
takes its host end as a device at the port. A sound chip's output is a
port too: `audio` on the Indy's and Indigo2's HAL2, the O2's MACE and
the Octane's and Onyx2's RAD1, and `CARD/audio` under an ice1724 card.
An `audio` entry there names the host output: default, pulse, wasapi,
coreaudio, null or file:PATH, with prebuf_ms, latency_ms and channels. A
port with no entry plays to the host as before, and `none` at it keeps
the chip and drops its sound. `no_audio` stays a run-mode flag.

The machine reads the entry through `audio()` and the GUI writes it
through `set_audio()`, as for the Ethernet and the camera; a card reads
its own port where it is built. A serial `midi_synth` is not at that
port, so it takes a `backend` of its own (the same values) instead of
following the machine's entry: `none` at `audio` no longer mutes it, and
a machine with no sound port can still send it to null or a file. A
machine with no sound chip (the Fuel, the Origin machines) has no such
port; the Tezro's channels setting moves to the entry at its card.

iris-gui wrote an `[audio]` table into every machine it saved, so
refusing it would have made every saved machine fail to load. The table
is read with a warning and turned into the entry in memory, and the GUI
saves the entry. A table at its defaults says nothing and leaves no
entry, so the Fuel's saved `[audio]` stays quiet. Any other table beside
an entry at the port is an error; where the machine has no sound port it
is dropped with a warning. The --audio-host flag is a hidden option that
sets the same entry after the file is read, so it beats the file's entry.

Production lines: +204 -60
@jamesbraid
jamesbraid force-pushed the ports-devices branch 5 times, most recently from dac0f4e to 0e3addc Compare November 29, 2026 13:50
@jamesbraid
jamesbraid marked this pull request as ready for review November 29, 2026 17:44
@jamesbraid
jamesbraid marked this pull request as draft November 29, 2026 18:38
@jamesbraid
jamesbraid marked this pull request as ready for review November 29, 2026 19:15
@jamesbraid
jamesbraid marked this pull request as draft November 29, 2026 22:16
graphics_entry() took the first board or `none` entry as the machine's
board, so a `none` anywhere (a PCI slot, a port) read as "the config
says no graphics board". On an Onyx 3000 with `none` at xio15/pci0/2,
graphics_board() returned None instead of Ir3, which feeds the vbrick
check, validation messages and the GUI summaries.

A board counts wherever it is. A `none` counts only when it names the
machine's graphics slot, which names_graphics() already answers.

Production lines: +1 -1
[network] picked one host end for the machine (NAT, a pcap interface, a
stream peer, nothing) and kept the MAC beside it, while a serial port's
host end is a device at the port. The Ethernet is a port too, so it now
follows the same three steps: a `net` entry at the port gives it a host
end, and `none` at the port empties it.

Every machine's built-in Ethernet is a slot named `ethernet`, under the
chip that owns it (hpc3, mace, or the IOC3's or BCM5701's PCI slot).
`backend` is nat, pcap, pcap:IFACE, stream:tcp:IP:PORT or
stream:unix:PATH, read by the shared backend parser, and `mac` is the
port's station address. A port with no entry has a default NAT entry
that is never written, so a config that says nothing still gets NAT. A
card that brings its own Ethernet declares `CARD/ethernet` and takes the
same entry; none does yet. The alias `ethernet` may repeat a slot's last
path step, which the alias check refused before.

The NAT gateway's own services (nat_subnet, [nfs], [[port_forward]],
tftp_dir, rsh_dir, nfs_pcap_ip, rx_hold) stay where they are: one
gateway serves the machine, not each port. The Indy and Indigo2 still
refuse an empty Ethernet.

`none` at the machine's graphics slot (gfx, gio0, a pipe slot) still only
keeps the default board out and leaves the slot free, as before; at any
other slot it now holds the slot, so a port stays empty and nothing else
is placed there. That includes an Octane's XIO slots that are not its
graphics slots, though every XIO slot takes a graphics board.

`none` at the port is the one way to unplug it: `backend = "none"` on a
`net` entry is refused, so there are not two spellings with different
results. The station address is guest-visible (the PROM reads it from
NVRAM or EEPROM, and the Fuel's host id derives from it), so it matters
what an unplugged port has: no entry, hence the machine's own address.
The MAC of a plugged port goes with the entry when the GUI unplugs it.

iris-gui wrote `[network] mode = "nat"` into every machine it saved, so
refusing the old keys would have made every saved machine fail to load.
[network] mode, pcap_interface, stream and mac are read with a warning
and turned into the entry in memory. Keys that say nothing (the GUI's
`mode = "nat"`) are dropped where an entry exists; any other key beside
an entry at the port is an error, as a serial port's tcp clash is. The
GUI saves the new form. The --net-mode and --pcap-interface flags are
hidden options that set the same entry after the file is read, so they
beat the file's entry as --graphics beats its board. `o2.net = false`
follows the key rule.

In the GUI, the entry holds only the current backend's interface or
peer, so switching PCAP to NAT and back forgets the interface. A
remembered interface would have to be kept per machine, for little; the
entry survives a save as `pcap:IFACE`. The status bar read the Ethernet
through a full placement of the machine on every frame (50 to 460 us in
a dev build, by machine); the app now reads it once per change of the
config and the started machine's once at its start.

Choosing Stream in the GUI writes an entry with no peer yet. `end()` now
reads the mode from the `stream:` prefix and leaves the peer to `check`,
so the mode follows the choice and `validate` reports a bad or missing
peer before Start. The GUI's status, summary and interface reads use the
entry (`ethernet()`) rather than `network()`, which expects a config
that validates: a half-typed subnet, MAC or peer must not panic it.

Production lines: +346 -157
@jamesbraid
jamesbraid force-pushed the ports-devices branch 3 times, most recently from 2bfc3ac to 380b07f Compare November 30, 2026 06:40
@jamesbraid
jamesbraid marked this pull request as ready for review November 30, 2026 08:38
@jamesbraid
jamesbraid merged commit 548543a into techomancer:main Nov 30, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant