Publish VCC Plus OSS source distribution for 3.6.2 build 60

This commit is contained in:
Brian Holman committed 2026-11-13 00:14:03 -07:00
commit c652a5276d
1192 files changed
+272368

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
# SPDX-License-Identifier: GPL-3.0-or-later
"""Build and run the C SDC interface against disposable cards on both guest CPUs."""
import argparse
import hashlib
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
def contents(card):
return {p.relative_to(card): hashlib.sha256(p.read_bytes()).digest()
for p in card.rglob("*") if p.is_file()}
def main():
parser = argparse.ArgumentParser(description=__doc__)
for name in ("runtime", "core", "roms"):
parser.add_argument(name, type=Path)
args = parser.parse_args()
runtime, core, roms = [p.resolve(strict=True) for p in (args.runtime, args.core, args.roms)]
fixture = Path(__file__).resolve().parent
root = fixture.parents[2]
env = dict(os.environ, VCC_CMOC_COMPAT="1", PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"])
with tempfile.TemporaryDirectory(prefix="vcc-sdc-sdk-") as temp:
work = Path(temp)
def run(*cmd):
subprocess.run(cmd, cwd=work, env=env, check=True)
card = work / "card"
survey = card / "SURVEY"
survey.mkdir(parents=True)
# More than one hardware directory page. An additional pattern matches
# exactly 16 entries, requiring an empty final block to detect the end.
group = card / "GROUP"
group.mkdir()
(group / "CHILD").mkdir()
for i in range(17):
extension = "TXT" if i < 16 else "BIN"
(group / f"A{i:02}.{extension}").write_bytes(bytes(i + 1))
(group / "A00.TXT").chmod(0o444)
(card / "BAD.DSK").write_bytes(b"bad geometry")
(card / "startup.cfg").write_text("0=BOOT.DSK\n", encoding="ascii")
blank = root / "docs/manuals/software-storage-and-peripherals/media/BLANK.DSK"
for image, name, data in ((card / "BOOT.DSK", "BOOTMAP.DAT", b"B"),
(survey / "EARTH.DSK", "ROVER.DAT", b"E"),
(survey / "MARS.DSK", "ROVER.DAT", b"M")):
shutil.copyfile(blank, image)
(work / name).write_bytes(data)
run(runtime / "bin/writecocofile", "--binary", image, name)
# The M: firmware command also mounts disk sets when given a directory.
# The C API promises a named image even if a directory has a .DSK suffix.
(card / "BUNDLE.DSK").mkdir()
shutil.copyfile(blank, card / "BUNDLE.DSK/DISK1.DSK")
initial = contents(card)
run("xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
"-I", root / "src", fixture / "run.cpp", core, "-o", "run")
for opt in ("-O0", "-O2"):
run(runtime / "bin/cmoc", "--coco", opt, "-Werror", "--org=2800", "-o", "SDCTEST.BIN",
fixture / "qualification.c", "-lsdc", "-lvcccompat", "-ldecbfile")
run("./run", roms, card / "BOOT.DSK", "SDCTEST.BIN")
if contents(card) != initial:
raise AssertionError(f"{opt}: card content changed")
print(f"PASS {opt}: both guest CPUs, original card and floppy bytes verified", flush=True)
if __name__ == "__main__":
main()
+167
View File
@@ -0,0 +1,167 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// A real guest client. The host constructs the card and checks it again afterwards.
#include <cmoc.h>
#include <coco.h>
#include <stdio.h>
#include <vcc/sdc.h>
#define CHECK(x) do { if (!(x)) { printf("FAIL LINE %u\n", (unsigned)__LINE__); return 1; } } while (0)
static SdcEntry entry;
static char overlong[256];
static asm byte irqMask(void)
{
asm {
tfr cc,b
andb #$50
}
}
// Called only between guest operations; preserve every CC bit except IRQ/FIRQ.
static asm void setIrqMask(byte mask)
{
asm {
tfr cc,b
andb #$af
orb 3,s
tfr b,cc
}
}
static int checkMasks(void)
{
static const byte masks[] = { 0, 0x10, 0x40, 0x50 };
byte original = irqMask();
byte i, entered, returned, status;
for (i = 0; i < sizeof(masks); ++i) {
setIrqMask(masks[i]);
entered = irqMask();
status = sdc_probe();
returned = irqMask();
setIrqMask(original);
CHECK(entered == masks[i] && returned == entered && status == SDC_OK);
}
return 0;
}
static int listing(void)
{
unsigned char i, result, index, seen[17], parent = 0, child = 0;
memset(seen, 0, sizeof(seen));
CHECK(sdc_list_begin("/GROUP/*") == SDC_OK);
while ((result = sdc_list_next(&entry)) == SDC_OK) {
if (!strcmp(entry.name, "..")) {
CHECK(entry.attributes & SDC_DIRECTORY);
++parent;
} else if (!strcmp(entry.name, "CHILD")) {
CHECK(entry.attributes & SDC_DIRECTORY);
++child;
} else {
CHECK(strlen(entry.name) == 7 && entry.name[0] == 'A');
index = (entry.name[1] - '0') * 10 + entry.name[2] - '0';
CHECK(index < 17 && !seen[index] && !(entry.attributes & SDC_DIRECTORY));
seen[index] = 1;
CHECK(entry.size == (unsigned long)(index + 1));
CHECK(!!(entry.attributes & SDC_READ_ONLY) == (index == 0));
}
}
CHECK(result == SDC_END && parent == 1 && child == 1);
for (i = 0; i < 17; ++i) CHECK(seen[i]);
CHECK(sdc_list_next(&entry) == SDC_END);
CHECK(sdc_list_begin("/group/*.txt") == SDC_OK);
for (i = 0; i < 16; ++i) CHECK(sdc_list_next(&entry) == SDC_OK);
CHECK(sdc_list_next(&entry) == SDC_END);
CHECK(sdc_list_begin("/GROUP/*.XYZ") == SDC_OK);
CHECK(sdc_list_next(&entry) == SDC_END);
CHECK(sdc_list_begin(NULL) == SDC_OK);
CHECK(sdc_list_next(&entry) == SDC_OK);
// Starting a second enumeration replaces the first.
CHECK(sdc_list_begin("/SURVEY/MARS.DSK") == SDC_OK);
CHECK(sdc_list_next(&entry) == SDC_OK && !strcmp(entry.name, "MARS.DSK"));
CHECK(entry.size == 161280UL && sdc_list_next(&entry) == SDC_END);
return 0;
}
static int readByte(const char *path, int expected)
{
FILE *f = fopen(path, "rb");
CHECK(f && fgetc(f) == expected && fgetc(f) == EOF && feof(f));
CHECK(fclose(f) == 0);
return 0;
}
static int mounts(byte protectedCard)
{
byte *driveOneFAT = (byte *)(0x0800 + 74);
CHECK(sdc_mounted(0, &entry) == SDC_OK && !strcmp(entry.name, "BOOT.DSK"));
CHECK(entry.size == 161280UL && !!(entry.attributes & SDC_READ_ONLY) == protectedCard);
CHECK(sdc_mounted(1, &entry) == SDC_NOT_FOUND);
CHECK(sdc_mount(1, "/survey/earth.dsk") == SDC_OK);
CHECK(sdc_mounted(1, &entry) == SDC_OK && !strcmp(entry.name, "EARTH.DSK"));
CHECK(!readByte("ROVER.DAT:1", 'E'));
CHECK(sdc_mount(1, "/SURVEY/UNKNOWN.DSK") == SDC_NOT_FOUND);
CHECK(sdc_mount(1, "/BAD.DSK") == SDC_INVALID);
CHECK(sdc_mount(1, "/BUNDLE.DSK") == SDC_INVALID);
CHECK(sdc_mount(1, "/SURVEY/MAR*.DSK") == SDC_INVALID);
CHECK(sdc_mount(1, "/SURVEY/MAR") == SDC_INVALID);
CHECK(sdc_mount(1, "/BOOT.DSK") == SDC_IN_USE);
CHECK(sdc_mount(1, "") == SDC_INVALID);
CHECK(sdc_mount(1, NULL) == SDC_INVALID);
CHECK(sdc_mount(2, "/SURVEY/MARS.DSK") == SDC_INVALID);
CHECK(sdc_mounted(2, &entry) == SDC_INVALID);
memset(overlong, 'A', sizeof(overlong) - 1);
CHECK(sdc_mount(1, overlong) == SDC_INVALID);
CHECK(sdc_mounted(1, &entry) == SDC_OK && !strcmp(entry.name, "EARTH.DSK"));
CHECK(!readByte("ROVER.DAT:1", 'E'));
// Independently exercise both DOS cache guards in guest memory.
CHECK(!driveOneFAT[0] && !driveOneFAT[1]);
driveOneFAT[0] = 1;
CHECK(sdc_mount(1, "/SURVEY/MARS.DSK") == SDC_IN_USE);
driveOneFAT[0] = 0;
driveOneFAT[1] = 1;
CHECK(sdc_mount(1, "/SURVEY/MARS.DSK") == SDC_IN_USE);
driveOneFAT[1] = 0;
CHECK(!readByte("ROVER.DAT:1", 'E'));
CHECK(sdc_mount(1, "/SURVEY/MARS.DSK") == SDC_OK);
CHECK(sdc_mounted(1, &entry) == SDC_OK && !strcmp(entry.name, "MARS.DSK"));
CHECK(!readByte("ROVER.DAT:1", 'M') && !readByte("BOOTMAP.DAT:0", 'B'));
return 0;
}
static int unavailable(void)
{
CHECK(sdc_probe() == SDC_UNAVAILABLE);
CHECK(sdc_list_begin("*") == SDC_UNAVAILABLE);
CHECK(sdc_mounted(0, &entry) == SDC_UNAVAILABLE);
CHECK(sdc_mount(0, "/SURVEY/MARS.DSK") == SDC_UNAVAILABLE);
return 0;
}
int main(void)
{
unsigned char choice;
cls(1);
printf("SELECT SDC TEST\n");
choice = waitkey(0);
if (choice == 'T') {
CHECK(sdc_probe() == SDC_TIMEOUT); // Waiting for idle.
CHECK(sdc_mounted(0, &entry) == SDC_TIMEOUT); // Waiting for data.
CHECK(sdc_probe() == SDC_OK);
CHECK(!readByte("BOOTMAP.DAT:0", 'B'));
} else if (choice == 'S' || choice == 'W') {
CHECK(sdc_probe() == SDC_OK);
CHECK(!readByte("BOOTMAP.DAT:0", 'B')); // DOS uses the next sector exactly as requested.
if (checkMasks() || listing() || mounts(choice == 'S')) return 1;
} else {
CHECK(choice == 'F');
if (unavailable()) return 1;
}
printf("SDC CHECKS PASSED\n");
return 0;
}
+108
View File
@@ -0,0 +1,108 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "../basic-disk-session.h"
using namespace BasicDiskTests;
static void start(Session& guest, const fs::path& binary, char selection)
{
guest.launch(binary);
guest.until("SELECT SDC TEST");
guest.type(std::string(1, selection));
guest.until("SDC CHECKS PASSED");
}
static void available(const fs::path& roms, const fs::path& disk, Processor cpu,
const fs::path& binary, bool protect)
{
Session guest(roms, disk, cpu, Profile::sdc);
guest.sdc->setWriteProtected(protect);
start(guest, binary, protect ? 'S' : 'W');
const auto state = guest.sdc->snapshot();
require(state.currentDirectory == "/" && state.drives[0].name == "/BOOT.DSK" &&
state.drives[1].name == "/SURVEY/MARS.DSK", "Wrong final SDC mount or current directory");
require(state.drives[1].reads > 0 && !state.drives[1].writes, "Unexpected SDC activity");
guest.verifyReturn();
// SDC-DOS must still be able to take over the controller from the SDK.
guest.type("DIR 1\r");
guest.until("ROVER");
guest.type("DIR 0\r");
guest.until("BOOTMAP");
guest.verifyMedia();
}
static void unavailable(const fs::path& roms, const fs::path& disk, Processor cpu,
const fs::path& binary, bool split)
{
Session guest(roms, disk, cpu, split ? Profile::sdc : Profile::fd);
if (split) {
// The ROM still identifies as SDC while all controller I/O goes to a real FD-502.
guest.floppy = std::make_shared<Fd502Device>(readFile(roms / "disk11.rom"));
guest.floppy->mount(0, DiskImage::load(guest.original));
guest.machine.cartridges().configure({nullptr, nullptr, nullptr, guest.floppy, guest.sdc}, true, 4);
guest.machine.cartridges().writePort(0x7f, 0x32);
}
const auto before = guest.floppy->snapshot();
const auto reads = guest.floppy->readEvents(0);
start(guest, binary, 'F');
const auto after = guest.floppy->snapshot();
require(after.drive == before.drive && after.track == before.track && after.sector == before.sector &&
after.motor == before.motor && before.head == after.head && guest.floppy->readEvents(0) == reads,
"SDC probing touched the FD-502");
const auto& bus = guest.machine.cartridges();
require(bus.romSlot() == 4 && bus.ioSlot() == (split ? 3 : 4), "Guest changed MPI routing");
if (split) guest.machine.cartridges().writePort(0x7f, 0x33);
guest.verifyReturn();
guest.verifyMedia();
}
// Inject a stuck BUSY bit into two otherwise genuine SDC-DOS transactions.
// Leaving command mode permits the next transaction to proceed normally.
class BusyController final : public CartridgeDevice {
public:
explicit BusyController(SDCDevice& device) : sdc(device) {}
unsigned remaining = 2;
void reset() override { sdc.reset(); }
void horizontalSync(DeviceHost& host) override { sdc.horizontalSync(host); }
std::uint8_t readMemory(std::uint16_t address) const override { return sdc.readMemory(address); }
std::uint8_t readPort(std::uint8_t port, DeviceHost& host) override {
return stall && port == 0x48 ? 1 : sdc.readPort(port, host);
}
void writePort(std::uint8_t port, std::uint8_t value, DeviceHost& host) override {
if (port == 0x48 && remaining) stall = true;
if (port == 0x40 && value == 0 && stall) { stall = false; --remaining; }
sdc.writePort(port, value, host);
}
private:
SDCDevice& sdc;
bool stall = false;
};
static void timeout(const fs::path& roms, const fs::path& disk, Processor cpu, const fs::path& binary)
{
Session guest(roms, disk, cpu, Profile::sdc);
auto fault = std::make_shared<BusyController>(*guest.sdc);
guest.machine.cartridges().configure({nullptr, nullptr, nullptr, nullptr, fault}, true, 4);
start(guest, binary, 'T');
require(fault->remaining == 0, "Both timed-out commands must release the controller");
guest.verifyReturn();
guest.verifyMedia();
}
int main(int argc, char** argv)
{
try {
require(argc == 4, "Usage: run ROMS DISK BIN");
for (auto cpu : {Processor::MC6809, Processor::HD6309}) {
available(argv[1], argv[2], cpu, argv[3], true);
available(argv[1], argv[2], cpu, argv[3], false);
unavailable(argv[1], argv[2], cpu, argv[3], false);
unavailable(argv[1], argv[2], cpu, argv[3], true);
timeout(argv[1], argv[2], cpu, argv[3]);
std::cout << "PASS " << (cpu == Processor::MC6809 ? "6809" : "6309")
<< " SDC-DOS, FD-502, split MPI, stuck BUSY recovery and Disk BASIC reads\n";
}
} catch (const std::exception& error) {
std::cerr << error.what() << std::endl;
return 1;
}
}