#!/bin/sh # Build the UDP frame-stream receiver (C + ROM-API thunks). # # harness/udpstream/build.sh # # .text at bit 0x018C0000, .bss at 0x01C00000 (both inside the firmware's large # free block), entry _start, no .cinit (the runtime's autoinit pass does not # run -- see harness/c-hello/README.md). set -eu ROOT=$(cd "$(dirname "$0")/../.." && pwd) DIR=$(cd "$(dirname "$0")" && pwd) WORK="$DIR/work" OUT="$DIR/build" IMG="$ROOT/tools/tms34010-sdk/1987-05 TMS34010 SDK/1987-11-06 TMS34010 Simulator-C Tools-ASM Tools.img" DOSBOX_CONF="$ROOT/harness/sdk-scratch/dosbox-bench.conf" TEXT=018C0000 BSS=01C00000 mkdir -p "$WORK" "$OUT" if [ ! -x "$WORK/GSPCG.EXE" ]; then mcopy -s -n -i "$IMG" "::/A2/*" "$WORK/" mcopy -s -n -i "$IMG" "::/C2/*" "$WORK/" fi cp "$DIR/udpstream.c" "$WORK/UDPSTRM.C" cp "$DIR/romapi.h" "$WORK/ROMAPI.H" cp "$DIR/entry.asm" "$WORK/ENTRY.ASM" { printf '%s\n' '-a' printf '%s\n' '-o UDPSTRM.out' printf '%s\n' '-m UDPSTRM.map' printf '%s\n' '-e _start' printf '%s\n' 'UDPSTRM.obj' printf '%s\n' 'ENTRY.obj' printf '%s\n' '-l RTS.LIB' printf '%s\n' 'MEMORY' printf '%s\n' '{' printf '%s\n' " prog: origin = ${TEXT}h, length = 20000h" printf '%s\n' " ram: origin = ${BSS}h, length = 40000h" printf '%s\n' '}' printf '%s\n' 'SECTIONS' printf '%s\n' '{' printf '%s\n' ' .text: {} > prog' printf '%s\n' ' .data: {} > prog' printf '%s\n' ' .cinit: {} > prog' printf '%s\n' ' .bss: {} > ram' printf '%s\n' '}' } > "$WORK/UDPSTRM.CMD" sed -i 's/$/\r/' "$WORK/UDPSTRM.CMD" rm -f "$WORK"/UDPSTRM.OBJ "$WORK"/UDPSTRM.OUT "$WORK"/UDPSTRM.LST \ "$WORK"/UDPSTRM.MAP "$WORK"/UDPSTRM.ASM "$WORK"/UDPSTRM.CPP \ "$WORK"/UDPSTRM.IF "$WORK"/ENTRY.OBJ "$WORK"/ENTRY.LST SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy \ timeout 240 dosbox -conf "$DOSBOX_CONF" -noprimaryconf -nolocalconf \ -c "mount c $WORK" -c "c:" \ -c "gspcpp UDPSTRM" \ -c "gspcc UDPSTRM" \ -c "gspcg UDPSTRM" \ -c "gspa UDPSTRM UDPSTRM.obj UDPSTRM.lst -l" \ -c "gspa ENTRY ENTRY.obj ENTRY.lst -l" \ -c "gsplnk UDPSTRM.cmd" \ -c "exit" -exit > "$WORK/dosbox.log" 2>&1 if [ ! -f "$WORK/UDPSTRM.OUT" ]; then echo "build.sh: GSPLNK produced no UDPSTRM.OUT" >&2 sed 's/\r$//' "$WORK/UDPSTRM.MAP" 2>/dev/null | tail -20 >&2 || true for f in UDPSTRM.LST ENTRY.LST; do sed 's/\r$//' "$WORK/$f" 2>/dev/null | grep -i 'error' | grep -vi 'no errors' >&2 || true done exit 1 fi for f in UDPSTRM.LST ENTRY.LST; do if sed 's/\r$//' "$WORK/$f" | grep -i 'error' | grep -qvi 'no errors'; then echo "build.sh: $f diagnostics:" >&2 sed 's/\r$//' "$WORK/$f" | grep -in 'error' | grep -vi 'no errors' >&2 exit 1 fi done cp "$WORK/UDPSTRM.OUT" "$OUT/udpstream.coff" sed 's/\r$//' "$WORK/UDPSTRM.MAP" > "$OUT/udpstream.map" sed 's/\r$//' "$WORK/UDPSTRM.LST" > "$OUT/udpstream.lst" sed 's/\r$//' "$WORK/ENTRY.LST" > "$OUT/entry.lst" echo "build.sh: $OUT/udpstream.coff ($(wc -c < "$OUT/udpstream.coff") bytes)" grep -E "ENTRY POINT|^\.(text|cinit|bss)" "$OUT/udpstream.map" | head -8