forked from arti/vt1200
dwt/loader: COFF loader places GSPLNK images and runs them via create_process
This commit is contained in:
1 parent
dcca6bee4d
commit
139d89a10c
42 files changed
+3822
No files matched your search
Executable
+105
@@ -0,0 +1,105 @@
|
||||
#!/bin/sh
|
||||
# Build a VT1200 payload/app with the 1987 TI TMS34010 SDK (GSPA/GSPLNK under
|
||||
# DOSBox), keeping the linked COFF so dwt/loader/coff.py can inspect it.
|
||||
#
|
||||
# dwt/loader/build.sh SOURCE.asm [TEXT_ORIGIN [DATA_ORIGIN [BSS_ORIGIN]]]
|
||||
#
|
||||
# Origins are BIT addresses (the TMS34010 and GSPLNK's SECTIONS origins are
|
||||
# bit addresses). With only TEXT_ORIGIN the linker command binds .text alone,
|
||||
# exactly like dwt/gui/build.sh. With DATA_ORIGIN/BSS_ORIGIN it binds all
|
||||
# three sections, which is what the marker app needs.
|
||||
#
|
||||
# Outputs, all under dwt/loader/build/:
|
||||
# <name>.bin the linked .text bytes (convenience; not a COFF)
|
||||
# <name>.coff the GSPLNK output, byte-for-byte (the loader's real input)
|
||||
# <name>.map the link map
|
||||
# <name>.lst the assembler listing (addresses in bits)
|
||||
#
|
||||
# ENTRY_SYM=<symbol> adds `-e <symbol>`; default is `_start` if the symbol
|
||||
# exists, otherwise no -e (GSPLNK then writes entry = 0).
|
||||
set -eu
|
||||
|
||||
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
|
||||
DIR=$(cd "$(dirname "$0")" && pwd)
|
||||
SRC=${1:?usage: build.sh SOURCE.asm [TEXT_ORIGIN [DATA_ORIGIN [BSS_ORIGIN]]]}
|
||||
TEXT=${2:-01800000}
|
||||
DATA=${3:-}
|
||||
BSS=${4:-}
|
||||
NAME=$(basename "$SRC" .asm)
|
||||
BASE=$(printf '%s' "$NAME" | tr 'a-z' 'A-Z')
|
||||
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"
|
||||
|
||||
mkdir -p "$WORK" "$OUT"
|
||||
|
||||
if [ ! -x "$WORK/GSPA.EXE" ]; then
|
||||
mcopy -s -n -i "$IMG" "::/A2/*" "$WORK/"
|
||||
mcopy -s -n -i "$IMG" "::/C2/*" "$WORK/"
|
||||
fi
|
||||
|
||||
cp "$SRC" "$WORK/$BASE.ASM"
|
||||
|
||||
# TI hex constants must begin with a decimal digit.
|
||||
tihex() {
|
||||
case "$1" in
|
||||
[0-9]*) printf '%s' "$1" ;;
|
||||
*) printf '0%s' "$1" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
TEXT=$(tihex "$TEXT")
|
||||
ENTRY=${ENTRY_SYM:-_start}
|
||||
|
||||
{
|
||||
printf '%s\n' '-a'
|
||||
printf '%s\n' '-o '"$BASE"'.out'
|
||||
printf '%s\n' '-m '"$BASE"'.map'
|
||||
[ -n "${ENTRY:-}" ] && printf '%s\n' '-e '"$ENTRY"
|
||||
printf '%s\n' "$BASE.obj"
|
||||
printf '%s\n' 'SECTIONS'
|
||||
printf '%s\n' '{'
|
||||
printf '%s\n' " .text ${TEXT}h: {}"
|
||||
if [ -n "$DATA" ]; then
|
||||
printf '%s\n' " .data $(tihex "$DATA")h: {}"
|
||||
fi
|
||||
if [ -n "$BSS" ]; then
|
||||
printf '%s\n' " .bss $(tihex "$BSS")h: {}"
|
||||
fi
|
||||
printf '%s\n' '}'
|
||||
} > "$WORK/$BASE.CMD"
|
||||
sed -i 's/$/\r/' "$WORK/$BASE.CMD"
|
||||
|
||||
rm -f "$WORK/$BASE.OBJ" "$WORK/$BASE.OUT" "$WORK/$BASE.LST" \
|
||||
"$WORK/$BASE.MAP" "$WORK/$BASE.HI" "$WORK/$BASE.LO"
|
||||
|
||||
SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy \
|
||||
timeout 180 dosbox -conf "$DOSBOX_CONF" -noprimaryconf -nolocalconf \
|
||||
-c "mount c $WORK" -c "c:" \
|
||||
-c "gspa $BASE $BASE.obj $BASE.lst -l" \
|
||||
-c "gsplnk $BASE.cmd" \
|
||||
-c "exit" -exit >/dev/null 2>&1
|
||||
|
||||
if [ ! -f "$WORK/$BASE.OUT" ]; then
|
||||
echo "build.sh: GSPLNK produced no $BASE.OUT" >&2
|
||||
sed 's/\r$//' "$WORK/$BASE.MAP" 2>/dev/null | tail -20 >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$WORK/$BASE.OBJ" ]; then
|
||||
echo "build.sh: GSPA produced no $BASE.OBJ" >&2
|
||||
grep -n '\*\*\*\*\*' "$WORK/$BASE.LST" >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
if grep -q '\*\*\*\*\*' "$WORK/$BASE.LST"; then
|
||||
echo "build.sh: assembler diagnostics:" >&2
|
||||
grep -n '\*\*\*\*\*' "$WORK/$BASE.LST" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp "$WORK/$BASE.OUT" "$OUT/$NAME.coff"
|
||||
cp "$WORK/$BASE.OBJ" "$OUT/$NAME.obj"
|
||||
sed 's/\r$//' "$WORK/$BASE.MAP" > "$OUT/$NAME.map"
|
||||
cp "$WORK/$BASE.LST" "$OUT/$NAME.lst"
|
||||
python3 "$ROOT/harness/hello-world/cofextract.py" "$WORK/$BASE.OUT" "$OUT/$NAME.bin"
|
||||
echo "build.sh: $OUT/$NAME.coff ($(wc -c < "$OUT/$NAME.coff") bytes); .bin $(wc -c < "$OUT/$NAME.bin") bytes at bit $TEXT"
|
||||
Reference in new issue
Block a user