42 lines
2.0 KiB
Python
42 lines
2.0 KiB
Python
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Run banked-memory transfers in the emulator on both CPUs at every RAM setting."""
|
|
import argparse
|
|
import os
|
|
import re
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tempfile
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("runtime", type=Path, help="staged guest toolchain containing libbank.a")
|
|
parser.add_argument("core", type=Path, help="current libVCCCore.a")
|
|
parser.add_argument("rom", type=Path, help="local CoCo 3 ROM")
|
|
args = parser.parse_args()
|
|
runtime = args.runtime.resolve(strict=True)
|
|
fixture = Path(__file__).resolve().parent
|
|
env = dict(os.environ, PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"])
|
|
with tempfile.TemporaryDirectory(prefix="vcc-banked-memory-") as work:
|
|
subprocess.run(["xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
|
|
"-I", fixture.parents[2] / "src", fixture / "run.cpp",
|
|
args.core.resolve(strict=True), "-o", "check"], cwd=work, check=True)
|
|
for optimization in ("-O0", "-O2"):
|
|
print("Checking", optimization, flush=True)
|
|
layouts = (("QUAL.BIN", ("--org=2800",)),
|
|
("SPLIT.BIN", ("--org=3800", "--data=2800")))
|
|
for binary, flags in layouts:
|
|
subprocess.run([runtime / "bin/cmoc", "--coco", optimization, "--intermediate", "-Werror",
|
|
*flags, "-o", binary, fixture / "qualification.c", "-lbank"],
|
|
cwd=work, env=env, check=True)
|
|
listing = (Path(work) / "QUAL.map").read_text()
|
|
symbol = re.search(r"^Symbol: _bank_open \(.+?\) = ([0-9A-F]+)$", listing, re.MULTILINE)
|
|
if not symbol:
|
|
raise RuntimeError("Missing bank_open in the linker map")
|
|
subprocess.run(["./check", args.rom.resolve(strict=True), "QUAL.BIN", symbol[1], "SPLIT.BIN"],
|
|
cwd=work, check=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|