Skip to content

RunCPM: upgrade to 6.9 and consolidate transports onto one shared core - #1391

Closed
peterkaczorowski wants to merge 2 commits into
FujiNetWIFI:masterfrom
peterkaczorowski:runcpm-6.9-update
Closed

RunCPM: upgrade to 6.9 and consolidate transports onto one shared core#1391
peterkaczorowski wants to merge 2 commits into
FujiNetWIFI:masterfrom
peterkaczorowski:runcpm-6.9-update

Conversation

@peterkaczorowski

Copy link
Copy Markdown
Contributor

Summary

Updates the vendored RunCPM engine to 6.9 and refactors all CP/M transports onto one shared stateless core.

The 6.9 bump and the core refactor are in the same PR by necessity: 6.9 has substantially more static global state than 6.5, and each CP/M transport TU (siocpm, drivewire, iwm, rc2014, rs232) carries its own private copy via internal linkage. Five copies of 6.9's larger state overflow the ESP32 DRAM .dram0.bss segment by ~58 KB and the firmware will not link. Consolidating to a single engine instance is the prerequisite that makes 6.9 fit.

What changed

  • runcpm_core.cpp is now the only TU that compiles the Z80/CP/M chain (external linkage). runcpm_session.h exposes runcpm_console_ops; abstraction_fujinet_core.h holds the shared disk/SD section.
  • The transports (siocpm, drivewire/cpm, iwm/cpm, rc2014cpm, rs232cpm, network-protocol/CPM) become thin console back-ends that plug into the shared core through runcpm_console_ops, guarded by a single-instance interlock.
  • A read-handle cache collapses RunCPM's per-128-byte-record open/seek/read/close on the SD card into one cached read-only handle shared by _sys_readseq/_sys_readrand.
  • Symbol-collision renames so the core TU can pull in bus headers on Apple/COCO targets: RunCPM Command struct → CcpCommand (collides with FujiNet class Command); CPM macro → handled in globals.h banner.

Test plan

  • ESP32 fujinet-atari-v1: ./build.sh -b links clean — RAM 36.8%, no dram0_0_seg overflow (vs. overflow-by-58 KB without the consolidation).
  • SIO 'G' CP/M and N:CPM:// regression on hardware.

This is PR 1 of 3 of a dependency stack that replaces #1371. Merge first; PRs 2 and 3 build on it.

🤖 Generated with Claude Code

peterkaczorowski and others added 2 commits June 28, 2026 21:12
Drop in the stock RunCPM 6.9 sources verbatim from upstream
MockbaTheBorg/RunCPM @ 8f1f8e9 for every file that exists 1:1 upstream:
cpm.h, ccp.h, disk.h, ram.h, globals.h, console.h, host.h, debug.h,
cpu_mhz.h, resource.h.

These are unmodified upstream files (each diffs to zero against the
upstream tree), so this commit is purely the library version bump and can
be reviewed in isolation. All FujiNet-specific fork patches, the single
cpu.h Z80 core, and the integration onto the shared stateless core are
applied separately in the following commit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Re-apply the FujiNet fork patches on top of the verbatim 6.9 drop and
consolidate all five bus transports (SIO, IWM/Apple, DriveWire/CoCo,
RC2014, RS232) onto one shared, stateless RunCPM engine.

6.9's larger static state replicated across five transport TUs overflows
the ESP32 .dram0.bss segment, so the per-transport copies are collapsed
into a single header-only core instance (runcpm_core.cpp +
runcpm_session.h). RUNCPM_DECL gives the vendored definitions internal
linkage so the core TU owns the one instance.

Fork deltas vs upstream 6.9:
- name-collision renames (Command->CcpCommand, CPM->CPM_VERSTR,
  DISK_H->CPM_DISK_H) so the headers can be pulled into a FujiNet TU
- DRAM trims (single 64K bank, RUNCPMDEBUG/RUNCPM_TRACE gating)
- printer routing for BDOS L_WRITE and ^L screen-clear translation
- abstraction_fujinet_core.h: the live host abstraction for the core

Remove the now-dead per-transport abstraction headers
(abstraction_fujinet.h, abstraction_fujinet_apple2.h,
abstraction_network_protocol.h) superseded by the shared core.
@peterkaczorowski peterkaczorowski changed the title RunCPM 6.9 + single shared stateless core RunCPM: upgrade to 6.9 and consolidate transports onto one shared core Jun 28, 2026
@peterkaczorowski

Copy link
Copy Markdown
Contributor Author

Thanks for the review @FozzTexx — both points addressed.

"Touching a lot more than just upgrading runcpm"

It unfortunately can't be a pure version bump. 6.9's larger static state, replicated across all five transport TUs (SIO, IWM, DriveWire, RC2014, RS232), overflows the ESP32 .dram0.bss segment by ~58 KB — it won't link. The fix is to stop compiling RunCPM five times: the transports now share a single stateless core (runcpm_core.cpp + runcpm_session.h) and each bus just provides a small console back-end. So the 6.9 upgrade and the shared-core consolidation are one inseparable change — you can't land 6.9 without it.

To make that reviewable I split the PR into two commits:

  1. Update vendored RunCPM to 6.9 (verbatim upstream) — a clean drop of the 10 stock upstream files, byte-for-byte identical to MockbaTheBorg/RunCPM @ 6.9. You can review this one in isolation by diffing against upstream; it should be empty.
  2. FujiNet: integrate RunCPM 6.9 onto a single shared core — all the FujiNet-specific work: the shared core, the linkage shim, the name-collision renames, and the transport back-ends. This is the commit to actually review.

"Walls of comments"

Stripped them throughout — the integration commit is now net -1137 lines. I also deleted three abstraction headers that the shared-core refactor made dead code.

Build stays green at 36.8% RAM (fujinet-atari-v1). The two stacked PRs (#1392 telnet console, #1393 bar commands) are rebased on top of this.

@peterkaczorowski

Copy link
Copy Markdown
Contributor Author

Superseded by a cleaner split: #1401 (consolidate bus CP/M devices onto a shared cpmDevice base, on the current 5.8 engine) followed by #1402 (engine bump 5.8 → 6.9 on that base). Closing in favour of those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant