Skip to content

Architecture

Machine Lab has one central boundary: student C code is a normal process, while the host runtime owns the virtual devices.

text
student C process
  libmachinelab client
        | local protocol
        v
  machinelab runtime server
        |
        +-- bus and IRQ controller
        +-- virtual devices
        +-- headless or SDL/audio backend

That runtime/device boundary is deliberate:

  • student code cannot accidentally depend on SDL;
  • the same binary can run interactively or headlessly;
  • device behavior can be traced and tested;
  • crashes stay isolated at the process boundary;
  • host backends can evolve without changing lab code.

Student Surface

sdk/include/lcom/lcom.h is copied into generated workspaces as include/lcom/lcom.h.

It exposes:

  • initialization and console output;
  • 8/16/32-bit port I/O;
  • IRQ subscribe/unsubscribe and event waits;
  • virtual physical memory map/unmap;
  • VBE mode information, mode changes, and frame presentation.

It does not expose:

  • SDL types;
  • C++ runtime classes;
  • Minix IPC structures;
  • LCF callbacks;
  • host pointers.

Virtual Devices

DeviceStudent-visible conceptsHost outputs
i8254 PITcontrol words, divisors, read-back, IRQ0virtual ticks
i8042status/data ports, keyboard IRQ1, mouse IRQ12live/scripted input
RTC/CMOSregister selection, UIP, BCD/binary fieldslive or fixed time
VBEmode info, framebuffer mapping, pitch, presentSDL window or PPM
AC97-litePCM mapping, rate, byte count, controlsSDL, null, or WAV
UART16550DLAB, LCR/FCR/IER/LSR/MCR, IRQsloopback/local/paired cable

These are educational device models, not cycle-accurate emulations.

Determinism

Headless execution uses a virtual clock. Scripts inject input at virtual timestamps. RTC overrides, traces, screenshots, frame sequences, WAV files, and replay videos come from the same run.

SDL execution follows host time and live keyboard/mouse input, but the student program still talks to the same virtual devices.

Test Layers

  1. unit_tests: bus, controller, device, script, and core behavior.
  2. labN_solution: reference lab implementations through the runtime.
  3. tests/integration.sh: CLI, examples, artifacts, pairing, workspace setup, replay encoding, bundles, and docs-site contracts.
sh
devenv shell -- machinelab-test

Course/docs licensed CC BY 4.0. Code licensed MIT.