Symbolics XL1200 Emulator (emu/)
The emu/ subsystem is a from-scratch C11 (plus optional x86-64 Zen 4 AVX-512 assembly) implementation of the Symbolics XL1200 Lisp Machine workstation: 40-bit tagged Ivory Rev 4 CPU, W3x64 floating-point accelerator, Merlin-II VMEbus/memory controller, monochrome console framebuffer, WD33C93 SCSI-2 host adapter, Intel 82586 Ethernet, MK48T02 NVRAM/RTC, Signetics SCN68562 DUSCC dual serial UARTs (+ Intel 8237A DMAC), and an SDL3 + microui + s7 Scheme workstation shell.
Architecture Overview
ivory-xl1200 strictly separates the Host Shell (OS threads, SDL3 display, microui workbench, s7 Scheme runtime, file/socket/named-pipe I/O, snapshots, SLIRP/TAP networking) from the Hardware Core (libivory_core.so / libivory_core.dll) across the versioned C ABI (IVORY_CORE_ABI_VERSION = 4 in ivory_core_api.h). Core object files (core/*.o) carry zero writable static .data/.bss state so the hardware engine is hot-reloadable live via --core-so, the Debug -> Hot-Reload Core menu action, or the reload debug command.
In continuous interactive and --puppet execution, the Host Shell runs a strict 2-thread runtime (emu/src/main.c):
- Main Thread: owns SDL3 window/renderer, keyboard/mouse events,
microuiUI workbench overlays, native SDL3 file dialogs,s7Scheme config/REPL/action coroutine scheduler,debug_ctlIPC polling, and host serial polling. - Emulation Thread (
emu_thread): holdsEmuRuntime.state_muwhile stepping the CPU in bounded slices (IvoryCoreApi), wakes onEmuRuntime.wake_cvon input/debug events, and pauses cleanly whenctl_waiters > 0ordbg->pausedis set.
flowchart TD
subgraph Host["Host Shell Binary (ivory-xl1200 / ivory-xl1200.exe)"]
MAIN["main.c (CLI, 2-Thread EmuRuntime, Lifecycle)"]
SDL["sdl_console.c + keymap.c (SDL3 Console, LED Bezel, Y4M Rec)"]
UI["ui_workbench.c + vendor/microui (Top Menu Bar, 6 Floating Windows)"]
S7["emu_script.c + vendor/s7 (define-machine, Actions, call/cc Scheduler)"]
DBG["debug_ctl.c + emu_ipc.c + ivory_disasm.c + ivory_sym_walk.c (IPC & Symbolic Debug)"]
SNAP["snapshot.c (COW Checkpoints, Input Replay, Sparse .snap)"]
NETSER["eth_slirp.c / eth_tap_linux.c + serial_host.c (Host Backends)"]
LOAD["loader.c + fep_convert.c + core_loader.c (PROM/IFEP Load, ABI Loader)"]
end
ABI["Versioned ABI v4 Boundary (ivory_core_get_api -> IvoryCoreApi)"]
subgraph Core["Hot-Reloadable Hardware Core (libivory_core.so / libivory_core.dll)"]
CPU["cpu.c + cpu_decode.c (Ivory Rev 4 Loop, Stack Cache, Trap Engine)"]
ZEN["cpu_zen4_avx512.c + cpu_zen4_loop.S (AVX-512 Tagged Dispatch)"]
ISA["isa_stack.c, isa_arith.c, isa_lisp.c, isa_call.c, isa_sys.c, fpa_w3x64.c"]
MEM["mem.c (RAM, Boot PROM, VRAM, Zone 31, PHT, Watchpoints)"]
MERLIN["merlin.c + nvram_mk48t02.c + console_hw.c (Merlin-II Bus, RTC, VRAM/SLB)"]
SCSI["scsi_wd33c93.c + eth_82586.c (WD33C93 SCSI-2, Intel 82586 NIC)"]
end
MAIN --> SDL
MAIN --> UI
MAIN --> S7
MAIN --> DBG
MAIN --> SNAP
MAIN --> NETSER
MAIN --> LOAD
LOAD -->|dlopen / LoadLibrary| ABI
MAIN -->|IvoryCoreApi calls| ABI
ABI --> CPU
ABI --> MERLIN
CPU --> ZEN
CPU --> ISA
CPU --> MEM
MERLIN --> SCSI
MERLIN --> MEMDocumentation Index
Emulator Subsystem Guides
- Core CPU, ISA & Acceleration —
IvoryCpu,IvoryMem, instruction decode & execution, W3x64 FPA, PHT/Zone 31 paging, runtime ISA detection, Zen 4 AVX-512 assembly fast path, and the versionedlibivory_coreABI. - Peripherals, Buses & Host Backends — Merlin-II bus & interrupts, MK48T02 NVRAM/RTC, monochrome console hardware, WD33C93 SCSI-2 (disk/CD-ROM/tape + QCOW-style sparse overlay), Intel 82586 NIC + SLIRP/TAP/packet backends, Signetics SCN68562 DUSCC dual serial UARTs (+ Intel 8237A DMAC) & host
tcp-listen/tcp/pipe/filebridges, and IFEP/EPROM image conversion. - GUI, Scripting, Debug IPC & Snapshots — 2-thread host runtime (
emu_os.h,emu_io.h,emu_ipc.h), SDL3 console & LED strip,microuiworkbench windows & file dialogs,s7Scheme machine config & cooperativecall/ccscheduler, livedebug_ctlIPC, COW checkpoints, time-travel rewind/replay, and sparse.snappersistence.
Related Repository References
- Engineering Roadmap — Completed milestones and remaining priority-ordered next-phase plans (
audio-plan.md,networking-chaosnet-plan.md,memory-expansion-plan.md,vme-bus-plan.md,genera-pv.md,color-graphics-plan.md,platforms-and-ci-plan.md). - Clean-Room XL1200 Boot PROM & Overlays — Open-source
IFEP promJfirmware (prom/, 3s interruptible SCSI0..6boot menu, framebuffer console) andcustom-diag.flod. - Ivory Assembler & Disassembler — Portable ANSI CL
tools/ivasm/(SBCL/ECL/CLISP), canonical S-expression syntax shared withivory_disasm.c, and container formats. - Troubleshooting & Live Debug Guide — Beta-tester
Bug Dumpworkflow,scripts/xl1200-ctl.py,sample-symflamegraphs, and triage playbook. - Developer Guide — Master hardware/Genera bringup reference and reverse-engineering invariants.
- Hardware Reference — Hardware specification (
01through06+ivory_hw.h). - Keyboard Reference — Symbolics SLB scancodes and host keymap profiles.
- GUI, Scripting & Windows Plan — Completed implementation specification (Phase 1–4).
Module Inventory
Hardware Core (emu/src/ -> CORE_SRCS / CORE_ASM_OBJS)
| File | Role |
|---|---|
| cpu.c | CPU reset (ivory_cpu_reset to entry_vma, e.g., 0xF8007162 for IFEP promJ), interpreter step loop, stack cache, traps, hardware parity (sizeof(IvoryCpu) == 4096) |
| cpu_decode.c | 40-bit word / 18-bit halfword instruction decode, CDR-Jump & fullword call decoding |
| cpu_zen4_avx512.c | Runtime CPUID dispatch (avx512f/cd/vl/bw/dq/vbmi2), Zen 4 dispatch table & C slow-path bridge |
| cpu_zen4_loop.S | Native x86-64 SysV/Win64 AVX-512 fast-path dispatch loop (ISA_MODE=runtime|native, compiled when ASM_ENABLED=1) |
| asm_abi.h | Portable SysV AMD64 vs Windows x64 register calling-convention macros for cpu_zen4_loop.S |
| isa_stack.c | Stack/FP/LP/TOS push-pop, %instance-ref, car/cdr/rplaca/rplacd, block & array helpers |
| isa_arith.c | Fixnum/double arithmetic, ALU condition evaluations, bitfields (ldb/dpb), logical shifts |
| isa_lisp.c | Type predicates, equality (eq/eql), GC/forwarding checks, %allocate-* primitives |
| isa_call.c | StartCall (0o50..0o57), FinishCall*, Return*, lexical closures, generic/message dispatch |
| isa_sys.c | Internal register R/W (%register-*), PHT & map-cache instructions, %halt, traps, NMI (0o5101) |
| fpa_w3x64.c | Weitek W3x64 floating-point accelerator model & IEEE-754 single/double execution |
| mem.c | Physical RAM, Boot PROM (64 KW), Boot Comm Area, I/O SRAM, VRAM, PHT lookup, write watchpoints |
| merlin.c | Merlin-II motherboard registers, VMEbus I/O map, PIT/microsecond timers, interrupt controller, LEDs, idle detection |
| nvram_mk48t02.c | SGS-Thomson MK48T02 2 KiB battery-backed NVRAM/RTC, serial/ID EEPROM formatting, historical RTC offset |
| scsi_wd33c93.c | WD33C93 SBIC SCSI-2 controller, target backing (disk, ISO/raw CD-ROM, QIC/DAT tape), sparse COW write overlay |
| eth_82586.c | Intel 82586 LAN coprocessor DMA ring (SCP/ISCP/SCB/CB/RFA), TX/RX callbacks |
| console_hw.c | XL1200 1152x896 1-bit VRAM, mouse/cursor registers, SLB keyboard FIFO, dual serial UART TX/RX rings |
| core_api.c | ivory_core_get_api() table export (IVORY_CORE_ABI_VERSION = 4), zero static globals in core objects |
Host Shell & Utilities (emu/src/ -> SHELL_SRCS & CLI tools)
| File | Role |
|---|---|
| main.c | CLI parser (EmuCliConfig), 2-thread EmuRuntime coordinator, headless/step/puppet/GUI startup |
| core_loader.c | Dynamic shared-library loader (dlopen / LoadLibraryA) & ABI v4 validation for libivory_core |
| loader.c | 5-byte EPROM split/combined loader (115988 + 115989 or rom.dump), IFEP .fep/.flod installer |
| fep_convert.c | Dual-use IFEP/EPROM toolkit (fep_convert_lib.o + standalone ivory-fep-convert CLI): unpack, inspect, create, --extract/--inject, MacIvory raw/APM/HFS multi-volume conversion |
| sdl_console.c | SDL3 window/renderer, VRAM overscan crop (:trim / :full), passive LED bezel, mouse capture, async .y4m recorder |
| keymap.c | Multi-profile host-to-Symbolics SLB translator (9 built-in keyboard profiles, oneshot ASCII modifiers) |
| ui_workbench.c | microui top menu bar (28 px), 6 floating workbench windows (incl. 4-tab symbolic Debug & Snapshots & Video Recording), SDL3 native file dialogs, focus/capture arbitration |
| ivory_disasm.c | 40-bit Ivory Rev 4/4A disassembler (human and canonical Lisp S-expression output shared with tools/ivasm/) |
| ivory_sym_walk.c | Read-only Genera symbol, function-header, stack-backtrace, object-summary, and trap-context walker |
| bug_report.c | PKZIP + RFC 1951 DEFLATE single-button beta-tester diagnostic archiver (Bug Dump) with symbolic PC disasm & backtraces |
| emu_script.c | Embedded s7 Scheme runtime: (define-machine ...) parser, surgical config saver, (define-action ...), call/cc scheduler |
| debug_ctl.c | Line-oriented debug/puppet protocol (AF_UNIX / Named Pipe / TCP / --puppet), breakpoints, disasm/bt-sym/inspect/trap-info/sample-sym, screenshot dump |
| emu_ipc.c | Portable non-blocking local socket / Win32 Named Pipe (CreateNamedPipeA) / dual-stack TCP server |
| snapshot.c | COW 256-word dirty-page checkpoints (IvoryCheckpointStore), deterministic input log/replay, sparse .snap I/O |
| serial_host.c | Non-blocking host serial backends (none, tcp-listen:<[a]:port>, tcp:<[a]:port>, pipe:<name_or_path>, file:<path>) |
| eth_slirp.c | Userspace NAT networking backend (libslirp) with guest CIDR & host port-forwarding |
| eth_tap_linux.c | Linux TAP (IFF_TAP) / AF_PACKET (--eth-veth) raw L2 bridge (stubbed cleanly on non-Linux hosts) |
Headers (emu/include/) & Vendored Libraries (emu/vendor/)
| Path | Purpose |
|---|---|
| ivory_core_api.h | Versioned IvoryCoreApi function table (IVORY_CORE_ABI_VERSION = 4U) & IvoryCoreLoader |
| ivory_emu.h | Core struct definitions (IvoryCpu, IvoryMem, MerlinBoard, Xl1200Console, Wd33c93Scsi, Eth82586) |
| ivory_asm_offsets.h | Shared C / x86-64 ASM offsets verified via _Static_assert in cpu.c (IvoryCpu == 4096, MerlinBoard == 278528, IvoryAsmLoopCtx == 112) |
| ivory_hw.h | Shared XL1200/Merlin-II address, register, CSR, opcode, and DTP tag constants |
| ivory_fep_tools.h | Programmatic IFEP inspection/creation/extraction API consumed by fep_convert.c and emu_script.c |
| ivory_keymap.h | IvoryKeymapId enum (IVORY_KEYMAP_COUNT = 9), IvoryKeymapInfo, SLB key event emitter types |
| ivory_serial_host.h | Xl1200SerialHost backend configuration and polling API |
| ivory_script.h | EmuMachineConfig, EmuScriptAction, EmuScriptHost, and emu_script_* lifecycle/API |
| ivory_ui.h | XL1200_TOP_MENUBAR_HEIGHT (28), Xl1200UiOverlay hook struct, UiWorkbenchHost, UiWorkbenchTestState |
| ivory_disasm.h | 40-bit Ivory Rev 4/4A disassembler API (IVORY_DISASM_HUMAN, IVORY_DISASM_LISP) |
| ivory_sym_walk.h | Read-only Genera symbol/function/backtrace/object/trap inspection API |
| ivory_bug_report.h | IvoryBugReportParams, ivory_bug_report_default_filename(), ivory_bug_report_save_zip() |
| ivory_snapshot.h | IVORY_SNAP_MAGIC ("IVRY"), IvoryInputEvent, IvoryCheckpoint, IvoryCheckpointStore |
| emu_os.h | Cross-platform mutex, condvar, thread, monotonic ns timer, aligned alloc, mlock, dlopen/LoadLibraryA helpers |
| emu_io.h | Portable 64-bit fopen/fseek64/ftell64/ftruncate64, pread/pwrite (OVERLAPPED on Win32), atomic replace |
| emu_ipc.h | EmuEndpoint, EmuLocalServer, EmuTcpListener portable non-blocking server/client primitives |
| emu/vendor/s7/ | Embedded s7 Scheme 11.9 (0-BSD, MIT-compatible), compiled with -DWITH_MAIN=0 -DWITH_C_LOADER=0 -DDISABLE_DEPRECATED=1 + Win32 MinGW patch |
| emu/vendor/microui/ | Embedded rxi/microui v2.02 (MIT), immediate-mode UI rendered via SDL3 texture atlas |
Build, Packaging & CI Matrix
All emulator targets live in emu/Makefile and flake.nix. Build outputs go under emu/build/ (TARGET_OS=native) or emu/build-win/ (TARGET_OS=windows).
Native Linux Builds (emu/Makefile)
# Default build: emu/build/{ivory-xl1200,libivory_core.so,ivory-fep-convert} (ISA_MODE=runtime)
nix develop --command make -C emu -j all
# Force portable C11-only core (no x86-64 AVX-512 assembly fast path)
nix develop --command make -C emu -j all ISA_MODE=portable
# Force compile-time -march=native -mavx512* core
nix develop --command make -C emu -j all ISA_MODE=native
| Makefile Variable | Default | Options | Notes |
|---|---|---|---|
TARGET_OS | native | native, windows | Auto-switches compiler (cc/gcc vs x86_64-w64-mingw32-gcc), build/ vs build-win/, .so/.dll, Win32 libs, assembly SysV vs Win64 ABI |
ISA_MODE | runtime | runtime, portable, native | runtime compiles cpu_zen4_loop.S + cpu_zen4_avx512.c (-march=znver4) and checks CPUID at runtime; portable disables ASM |
SLIRP (pkg-config) | auto | pkg-config slirp | Auto-detected via $(PKG_CONFIG) --libs slirp; enables -DHAVE_LIBSLIRP=1 when libslirp + glib-2.0 are present |
Core ABI and hot-reload invariants are enforced at compile and load time:
- C11
_Static_assertchecks incpu.c,test_cpu_core.c, andtest_console.cverify ABI struct sizes (sizeof(IvoryCpu) == 4096U,sizeof(IvoryMem) == 32768U,sizeof(MerlinBoard) == 278528U,sizeof(IvoryDecodedSlot) == 8U,sizeof(IvoryAsmLoopCtx) == 112U) andoffsetofparity with ivory_asm_offsets.h. IvoryCoreApiruntime validation in core_loader.c checksabi_version == 4U,struct_size,cpu_size,mem_size, andboard_sizeondlopen/LoadLibraryAreload; core objects (core/*.o) must keep zero writable.data/.bssstate per emu/AGENTS.md.
Windows Cross-Compile & Wine 11 CI
The .#mingw Nix devShell (flake.nix) cross-compiles the full emulator (SDL3, libslirp, glib, s7, microui, Win64-ABI cpu_zen4_loop.S, Windows sockets/named pipes) and runs both unit tests and the Scheme E2E suite under Wine 11:
# Cross-compile ivory-xl1200.exe, libivory_core.dll, ivory-fep-convert.exe + bundled DLLs in emu/build-win/dist/
nix develop .#mingw --command make -C emu -j all dist-win TARGET_OS=windows
# Run all 14 Windows unit test executables under Wine
nix develop .#mingw --command make -C emu test-win TARGET_OS=windows
# Run the portable s7 Scheme E2E suite against build-win/ivory-xl1200.exe under Wine
nix develop .#mingw --command make -C emu test-e2e-win TARGET_OS=windows
dist-win assembles emu/build-win/dist/ containing ivory-xl1200.exe, libivory_core.dll, ivory-fep-convert.exe, xl1200.scm.example, and transitive runtime DLLs resolved via x86_64-w64-mingw32-objdump (SDL3.dll, libslirp*.dll, libglib-2.0*.dll, libwinpthread-1.dll, libgcc_s_seh-1.dll, etc.).
Nix Packages (flake.nix)
flake.nix scopes emuSrc to ./emu so documentation edits do not needlessly invalidate C builds:
nix build .#default— builds native Linuxivory-xl1200,libivory_core.so, andivory-fep-convert.nix build .#windows— builds the cross-compiled Windows distribution package containingbin/*.exeand DLLs.
Unit & End-to-End Test Matrix (ROM-Optional)
| Command | Scope | ROM Behavior |
|---|---|---|
make -C emu test | Runs all 16 C unit/integration test binaries (test_loader, test_mem, test_cpu_core, test_isa_ops, test_disasm, test_merlin, test_eth, test_console, test_keymap, test_fep_convert, test_debug_ctl, test_bug_report, test_snapshot_reload, test_s7_config, test_serial_host, test_ui_workbench) | Exit code 77 is counted as SKIP (test_rom_fixture.h) |
make -C emu test-e2e | Runs tests/test_e2e_puppet.sh and portable tests/e2e_suite.scm (headless + GUI --eval/--script, live AF_UNIX + TCP IPC, .snap, FEP tools) | Reports [SKIP] and exits 0 when ROM dumps are absent |
make -C emu test-win TARGET_OS=windows | Runs all 16 .exe unit tests under Wine (WINEDEBUG=-all) | Exit code 77 counted as SKIP |
make -C emu test-e2e-win TARGET_OS=windows | Runs tests/e2e_suite.scm under Wine against build-win/ivory-xl1200.exe | Reports SKIP and exits 0 when ROMs are absent |
ROM discovery for stock-PROM regression tests checks IVORY_FEP_ROM_DIR, then ../ivory-fep-roms/fep330 and ivory-fep-roms/fep330, preferring the authentic chip pair 115988-e.bin + 115989-e.bin and falling back to combined rom.dump (never bundled in the repository). For interactive booting without proprietary ROM dumps, build the included clean-room Boot PROM via make -C prom (docs/custom-boot-prom.md).
Quick Start
# 1. Build emulator, core shared library, IFEP tool, and clean-room Boot PROM
nix develop --command make -C emu -j all
nix develop --command make -C prom
# 2. Run GUI (starts powered off: select prom/build/custom-rom.dump in Machine Setup, then click Power On)
./emu/build/ivory-xl1200 --config emu/xl1200.scm.example
# 3. Boot directly with the clean-room Boot PROM (FEPFS disk or Genera 8.3 CD-ROM)
./emu/build/ivory-xl1200 --rom prom/build/custom-rom.dump --cdrom genera-8-3.iso --autostart
# 4. Optional: boot original Symbolics split FEP 3.30 ROMs if you have them
./emu/build/ivory-xl1200 --headless --rom path/to/115988-e.bin --rom-hi path/to/115989-e.bin
4. Attach interactively to a running emulator's live debug socket
./scripts/xl1200-ctl.sh --list ./scripts/xl1200-ctl.sh
- Intel 8237A —
intel_8237A_dmac.pdf - Intel 82586 —
intel_82586_lan_coprocessor.pdf(mirror) - Intel 82586 —
intel_82586_reference_manual_1983.pdf(mirror) - Signetics SCN68562 / SCN26562 —
signetics_1991_IC019_data_comm_SCN68562.pdf(mirror) - Mostek MK48T02 / ST M48T02 —
st_M48T02_MK48T02_timekeeper.pdf - Western Digital WD33C93A —
wd_WD33C93A_datasheet_and_appnotes_1990.pdf(mirror) - Western Digital WD33C93A —
wd_WD33C93A_scsi_datasheet.pdf(mirror) - Weitek WTL1164/1165 (W3x64 family) —
weitek_WTL1164_1165_64bit_ieee_1986.pdf(mirror) - Weitek WTL3132/3332 (W3x64 family) —
weitek_WTL3132_3332_fpdp_1988.pdf(mirror) - Weitek WTL3167 (W3x64 core) —
weitek_WTL3167_coprocessor_1988.pdf(mirror)