Skip to content

RunCPM: loopback TELNET console on 127.0.0.1:8677 - #1403

Open
peterkaczorowski wants to merge 3 commits into
FujiNetWIFI:masterfrom
peterkaczorowski:runcpm-telnet-on-cpmbase
Open

RunCPM: loopback TELNET console on 127.0.0.1:8677#1403
peterkaczorowski wants to merge 3 commits into
FujiNetWIFI:masterfrom
peterkaczorowski:runcpm-telnet-on-cpmbase

Conversation

@peterkaczorowski

Copy link
Copy Markdown
Contributor

Summary

Adds a second access path to the shared RunCPM core: a loopback TELNET
console
that the Atari reaches via N:TELNET://127.0.0.1:8677. Rebased onto
the cpmDevice + 6.9 stack.

Stacks on #1402 (engine 6.9 on cpmDevice), which stacks on #1401
(cpmDevice consolidation). Merge in order #1401#1402 → this.

What changed

  • lib/device/sio/vm_telnet.{cpp,h} — a loopback acceptor (binds
    127.0.0.1:8677 only) that bridges a TELNET client to the shared RunCPM core
    via two byte queues exposed as a runcpm_console_ops (the same console
    interface every transport uses, including the new getche).
  • src/main.cpp — the acceptor is started from fn_service_loop() after
    fnWiFi.start() has brought up the lwIP stack (starting earlier panicked in
    tcpip_send_msg_wait_sem() with an uninitialised mbox), and torn down in
    main() before static destruction so detached workers don't race the queue
    mutexes at exit.
  • The reset button can preempt an active session; the idle kbhit poll yields
    core 1 to avoid an ESP32 watchdog hang.

Build / test

  • Desktop ATARI links clean.
  • ESP32 fujinet-atari-v1: builds clean, RAM 36.6%, Flash 24.2%.
  • Verified on real FujiNet ESP32 (Atari): the Atari terminal connects over
    N:TELNET://127.0.0.1:8677 and runs a full CP/M session through the shared
    core.

All lib/device/*/cpm devices were near-identical and each embedded its own
copy of the RunCPM engine. Introduce a single lib/device/cpm base class
(cpmDevice, plus cpmQueueDevice for buses whose engine runs on its own task)
and a single shared engine TU (runcpm_core.cpp via runcpm_session.h). Per-bus
devices now override only four console-endpoint primitives.

Buses without a working CP/M console (rc2014, rs232) inherit a default
clean-exit endpoint instead of returning hardcoded values, so CP/M cold-boots
and exits cleanly everywhere. Fold N:CPM:// onto the same shared engine.

Built against the current RunCPM 5.8 (no engine version change).
Bumps the vendored RunCPM engine from 5.8 to 6.9 while keeping the
cpmDevice base-class architecture introduced in the previous commit.

The engine-side files are a matched set taken from upstream RunCPM 6.9:
ccp.h, cpm.h, cpu.h (+cpu_mhz.h, +debug.h), disk.h, console.h, host.h,
ram.h, resource.h and globals.h, plus the 6.9 single-core glue
(runcpm_core.cpp, runcpm_session.h, abstraction_fujinet_core.h, which
replaces abstraction_fujinet.h).

6.9's console interface adds a getche primitive (blocking read + echo)
and widens getch/getche/kbhit to int.  Rather than add a per-bus
override, cpmDevice synthesises getche generically (read endpoint byte,
mask to 7 bits, echo via putch) so no transport had to change: the SIO,
IWM, DriveWire, RS232 and RC2014 devices keep their existing ep_*
overrides untouched.  The N:CPM:// adapter (network-protocol/CPM.cpp),
which is not a cpmDevice, gets the same small getche shim.

Builds clean on desktop ATARI and APPLE (cpmQueueDevice path) and on the
ESP32 fujinet-atari-v1 target (RAM 36.6%, Flash 24.2%).
Add a second access path to the shared RunCPM core: a TELNET console
that the Atari reaches via the FujiNet N:TELNET://127.0.0.1:8677 device.
The acceptor binds to loopback only and is started from fn_service_loop()
after fnWiFi.start() has brought up the lwIP stack (starting it earlier
panicked in tcpip_send_msg_wait_sem() with an uninitialised mbox), and is
torn down in main() before static destruction so detached worker threads
do not race the queue mutexes at exit.  Also lets the reset button preempt
an active session and yields core 1 in the idle kbhit poll to avoid an
ESP32 watchdog hang.
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