Skip to content

Commit 9591d6f

Browse files
authored
Merge pull request CopperlineHQ#383 from sidick/feat/hostsocket-import
hostsocket: import bundled bsdsocket.library WASM plugin board
2 parents cc9082f + 129c8aa commit 9591d6f

33 files changed

Lines changed: 10040 additions & 65 deletions

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,32 @@ jobs:
143143
path: target/probe-golden/
144144
if-no-files-found: ignore
145145

146+
hostsocket-plugin:
147+
name: HostSocket plugin (wasm32)
148+
# The bundled bsdsocket.library board (crates/hostsocket-plugin) ships
149+
# as a committed artifact (assets/hostsocket/hostsocket_plugin.wasm, the
150+
# blob a plain cargo build embeds), so nothing else in CI compiles this
151+
# crate at all. This job keeps the source buildable for its real target
152+
# and runs its native unit suite. It deliberately does not byte-compare
153+
# the artifact against a fresh build: rustc upgrades change wasm output,
154+
# and the artifact is only expected to be refreshed when the crate
155+
# itself changes (like the guest ROMs under assets/).
156+
runs-on: ubuntu-latest
157+
steps:
158+
- uses: actions/checkout@v7
159+
- uses: dtolnay/rust-toolchain@stable
160+
with:
161+
targets: wasm32-unknown-unknown
162+
- uses: Swatinem/rust-cache@v2
163+
with:
164+
workspaces: crates/hostsocket-plugin
165+
- name: Build (wasm32-unknown-unknown)
166+
working-directory: crates/hostsocket-plugin
167+
run: cargo build --release --locked --target wasm32-unknown-unknown
168+
- name: Native unit tests
169+
working-directory: crates/hostsocket-plugin
170+
run: cargo test --locked
171+
146172
diagrom-smoke:
147173
name: DiagROM boot smoke
148174
needs: build

.github/workflows/locks.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ name: Lockfile sync
33
# Verifies every committed Cargo.lock still resolves with --locked, i.e. is
44
# in sync with its workspace's manifests. The root lock is already exercised
55
# by the --locked builds in ci.yml, but the nested workspaces mostly are not:
6-
# crates/copperline-web and crates/cputest-runner carry their own committed
7-
# locks. The web lock pins the sibling `copperline` path package by version;
8-
# the cputest-runner lock pins its published `m68k` dependency. A manifest
6+
# crates/copperline-web, crates/cputest-runner, and crates/hostsocket-plugin
7+
# carry their own committed locks. The web lock pins the sibling `copperline`
8+
# path package by version; the cputest-runner lock pins its published `m68k`
9+
# dependency; the hostsocket-plugin lock pins its `smoltcp` dependency (the
10+
# committed assets/hostsocket/hostsocket_plugin.wasm is built from it). A manifest
911
# update without a lock refresh breaks `cargo build --locked` (issue #219:
1012
# the v0.12.0 tag shipped crates/copperline-web/Cargo.lock still pinning
1113
# copperline 0.11.0).
@@ -44,3 +46,6 @@ jobs:
4446
- name: crates/cputest-runner
4547
working-directory: crates/cputest-runner
4648
run: cargo tree --locked > /dev/null
49+
- name: crates/hostsocket-plugin
50+
working-directory: crates/hostsocket-plugin
51+
run: cargo tree --locked > /dev/null

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
# Standalone cputest runner build output.
2525
/crates/cputest-runner/target
26+
# Standalone HostSocket plugin build output (the committed artifact is
27+
# assets/hostsocket/hostsocket_plugin.wasm).
28+
/crates/hostsocket-plugin/target
2629
# CD images (cue/bin) are local assets, never committed.
2730
*.[Cc][Uu][Ee]
2831
*.[Bb][Ii][Nn]
@@ -34,6 +37,7 @@
3437
!/assets/aros/aros-amiga-m68k-rom.bin
3538
!/assets/aros/aros-amiga-m68k-ext.bin
3639
!/assets/services/services_rom.bin
40+
!/assets/hostsocket/hostsocket_rom.bin
3741

3842
# Local run artifacts (screenshots, recordings, save states, input scripts,
3943
# RTC battery-RAM backing files).

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ against real hardware.
5858
DrawBridge / Greaseweazle / Supercard Pro via the bundled FloppyBridge,
5959
`docs/guide/floppybridge.md`), Gayle and A4000 IDE, SCSI (A2091,
6060
A4091, or the A3000's onboard Super DMAC), CDTV/CD32 CD, A2065 Ethernet,
61+
a bundled host-backed `bsdsocket.library` (socket networking for guest
62+
applications with no guest TCP/IP stack to boot),
6163
Z3660 and Picasso II/II+ RTG cards (high-colour Picasso96 screens), the serial
6264
port bridged to host stdout/TCP/PTY/MIDI, a parallel-port printer capture and
6365
audio sampler, host directories served live as AmigaDOS volumes, and Zorro
@@ -340,7 +342,7 @@ channel are in
340342
| Floppy / ADF / DMS / SCP | DF0-DF3 standard DD ADF read/write, read-only ADZ/DMS, UAE extended ADF, initial read-only SCP flux import, track-timed disk DMA, CIA drive lines, index FLAG, DSKLEN/DSKBYTR/DSKSYNC/DSKDAT, per-drive multi-disk playlists with a swap key, and real 3.5" drives through FloppyBridge (DrawBridge / Greaseweazle / Supercard Pro). |
341343
| Hard disks | Gayle IDE (A600/A1200) and A4000 motherboard IDE; SCSI via the A2091 (Zorro II DMAC + WD33C93A), A4091 (Zorro III 53C710 with SCRIPTS), or A3000 Super DMAC; RDB HDFs, bare partition hardfiles, and host-directory volumes. |
342344
| Host filesystem | `[[filesys]]` mounts serve host directories live as AmigaDOS volumes (read/write, `.uaem` attribute sidecars, Latin-1 name mapping). |
343-
| Expansion | Zorro II/III autoconfig chain, TOML-described RAM boards, WASM plugin boards (registers/interrupts/DMA in a sandboxed module), A2065 Ethernet (Am7990 LANCE) with loopback, userspace NAT, and direct host-adapter bridge backends. |
345+
| Expansion | Zorro II/III autoconfig chain, TOML-described RAM boards, WASM plugin boards (registers/interrupts/DMA in a sandboxed module), A2065 Ethernet (Am7990 LANCE) with loopback, userspace NAT, and direct host-adapter bridge backends, and the bundled HostSocket board (`bsdsocket.library` backed by a host-side TCP/IP stack over the same backends). |
344346
| Agnus VPOSR / VHPOSR | Beam counters advanced per colour clock; PAL and NTSC timing (including NTSC long/short lines). |
345347
| Agnus Copper | Beam-scheduled OCS Copper with COP1/COP2 jumps, WAIT, SKIP, DMAEN/COPEN gating, and chip-bus grants. |
346348
| Agnus blitter | Scheduled per-slot engine: normal/line/fill modes, hardware per-word channel bus sequences (including the area-fill idle C slot), BBUSY/BZERO, BLTPRI "nasty" vs CPU starvation-yield arbitration, blit-done IRQ. |
170 KB
Binary file not shown.
1.94 KB
Binary file not shown.

copperline.example.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,33 @@ slow = "512K"
266266
# # copperline --list-net-interfaces
267267

268268

269+
# HostSocket: bsdsocket.library backed by a host-side TCP/IP stack -- socket
270+
# networking for guest applications with no guest TCP/IP stack to install or
271+
# boot (the library autoboots from the board's ROM). Same net backends as
272+
# [a2065], but the guest needs no IP configuration at all: "nat" gives
273+
# applications outbound internet, "loopback" gives deterministic self-talk
274+
# (127.0.0.1), "none" a dead wire. Don't fit this alongside a real guest
275+
# TCP/IP stack -- both would add a bsdsocket.library.
276+
# [hostsocket]
277+
# net = "nat"
278+
# interface = "en0" # required only for net = "bridge"
279+
# hostname = "amiga" # gethostname() return value (cosmetic)
280+
# address = "192.168.1.50/24" # interface address; net = "bridge" only -- the
281+
# # 10.0.2.15/24 default is NAT's own virtual
282+
# # address, meaningless on a real LAN. No DHCP,
283+
# # so pick a static address the same way you
284+
# # would for any other device on that network.
285+
# gateway = "192.168.1.1" # default gateway; net = "bridge" only, same
286+
# # reasoning as address above
287+
# gethostbyname() just works under net = "nat"/"bridge" with no further
288+
# config: it defaults to asking Copperline's own process to resolve via the
289+
# host OS resolver on a background thread (rejected under "loopback": it
290+
# would defeat that backend's whole point of byte-identical determinism).
291+
# Override only to target a *specific* DNS server instead of the host's:
292+
# resolver = "dns" # query dns_server directly instead of the host resolver
293+
# dns_server = "10.0.2.3" # only used when resolver = "dns"
294+
295+
269296
# RTG graphics card: high-resolution, high-colour screens via Picasso96.
270297
# Z3660 is fitted by default on any machine whose CPU has a 32-bit address bus
271298
# (stock A3000/A4000, or any profile given a 68020+ full-bus CPU). Picasso II

crates/hostsocket-plugin/Cargo.lock

Lines changed: 179 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[package]
2+
name = "hostsocket-plugin"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "Bundled Copperline WASM board: bsdsocket.library backed by an embedded smoltcp stack"
6+
license = "GPL-3.0-or-later"
7+
publish = false
8+
9+
[lib]
10+
# "cdylib" is what actually ships (the wasm32-unknown-unknown board). "rlib"
11+
# is added so `cargo test` (native target) can link a normal test harness
12+
# against this crate at all -- without it, the native test binary silently
13+
# exits (status 101, no output) before running anything, since a cdylib-only
14+
# artifact isn't something a native binary can link against as a library.
15+
crate-type = ["cdylib", "rlib"]
16+
17+
[dependencies]
18+
# default-features disabled: smoltcp's std feature pulls in libc-backed
19+
# device backends (raw sockets, tuntap) that don't exist on
20+
# wasm32-unknown-unknown -- we drive it purely through net_send/net_recv
21+
# instead. socket-udp backs sendto/recvfrom; socket-dns backs gethostbyname
22+
# (see src/lib.rs's module doc comment for why gethostbyaddr/reverse lookup
23+
# stays out even with this feature on). socket-icmp + auto-icmp-echo-reply
24+
# back SOCK_RAW/IPPROTO_ICMP support (do_socket's own comment): socket-icmp
25+
# is the userspace raw-ICMP socket type a guest ping implementation opens
26+
# and reads/writes directly; auto-icmp-echo-reply makes the *interface
27+
# itself* answer incoming echo requests automatically (the same thing a
28+
# real OS kernel's IP stack does, independent of any userspace ping socket)
29+
# -- without it, pinging the board's own INTERFACE_ADDR (or 127.0.0.1 under
30+
# net = "loopback", which bounces the request straight back to this same
31+
# interface) would never get a reply at all, since nothing else in this
32+
# plugin ever answers on the stack's behalf.
33+
smoltcp = { version = "0.13", default-features = false, features = [
34+
"alloc",
35+
"medium-ethernet",
36+
"proto-ipv4",
37+
"socket-tcp",
38+
"socket-udp",
39+
"socket-dns",
40+
"socket-icmp",
41+
"auto-icmp-echo-reply",
42+
] }
43+
44+
# The shipped artifact (assets/hostsocket/hostsocket_plugin.wasm) is built
45+
# with this profile; size matters because the module is embedded in the
46+
# copperline binary. Mirrors the standalone upstream repo's workspace
47+
# profile.
48+
[profile.release]
49+
opt-level = "z"
50+
lto = true
51+
panic = "abort"
52+
strip = true

crates/hostsocket-plugin/Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Builds the release wasm32 module and installs it as the committed artifact
2+
# assets/hostsocket/hostsocket_plugin.wasm -- the blob a plain cargo build of
3+
# the emulator embeds (rebuilding needs the wasm32-unknown-unknown rustup
4+
# target; nothing else in the repo does). Mirrors guest/hostsocket/Makefile,
5+
# which installs the companion stub ROM the same way: the committed artifact
6+
# is refreshed by this install step, never as a side effect of a build.
7+
8+
ARTIFACT = ../../assets/hostsocket/hostsocket_plugin.wasm
9+
10+
all:
11+
cargo build --release --locked --target wasm32-unknown-unknown
12+
cp target/wasm32-unknown-unknown/release/hostsocket_plugin.wasm $(ARTIFACT)
13+
14+
clean:
15+
cargo clean
16+
17+
.PHONY: all clean

0 commit comments

Comments
 (0)