CP/M-386 – 运行于 386 保护模式下的 CP/M,源自 CP/M-68K
CP/M-386 – CP/M for 386 protected mode, derived from CP/M‑68K

原始链接: https://github.com/johnsonjh/cpm386

CP/M-386 是一个早期的操作系统项目,旨在 386 及更新的架构系统上运行 CP/M,要求至少 2MB 内存。该系统源自 CP/M-68K,支持 PC BIOS 或 UEFI(通过 CSM),并提供 VGA、PS/2 键盘、UART 串口以及标准 PC 硬件计时器的驱动程序。 该系统与传统的 CP/M 版本具有高度的源码兼容性,包括与 CP/M-68K 1.3 和 CP/M 2.2 完全一致,并对 CP/M-Plus 和 DOS-Plus 扩展提供了实质性支持。虽然它不包含多用户和多任务功能,但引入了针对现代特性的独特扩展,如直接视频访问和高分辨率计时。 开发人员可以使用 GCC(推荐)或 Clang 在大多数现代 Linux 发行版、NetBSD 和 FreeBSD 上构建该系统。该项目基于 MIT 许可证发布,并获得了 Digital Research 的继任者 DeviceLogics LLC 的明确授权,允许修改和分发 CP/M 技术。项目还提供了一套广泛的实用工具,涵盖从文件管理到图形演示等多种功能,用于测试和系统交互。

```Hacker News新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交登录CP/M-386 – 运行于 386 保护模式下的 CP/M,源自 CP/M-68K (github.com/johnsonjh)7 点,由 TMWNN 发布于 51 分钟前 | 隐藏 | 过往 | 收藏 | 讨论帮助 考虑申请 YC 2026 年秋季批次!申请截止日期为 7 月 27 日。 准则 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系方式 搜索: ```
相关文章

原文

CP/M‑386 is CP/M for 386 protected mode, derived from CP/M‑68K.



CP/M‑386 is currently in the very early development stages.

  • Compatible with 386 (and later systems) with 2MB (or more) memory.
  • Systems using either PC BIOS or UEFI (with CSM) are supported.
  • VGA, 8042 PS/2, 8250/16450/16550 UART, CMOS RTC, and 8253/8254 PIT are supported.

CP/M‑386 should be highly source‑compatible with other implementations:

System BDOS coverage
CP/M‑68K 1.3 100%
CP/M 2.2 100%
CP/M‑Plus 71%
DOS‑Plus 62%
MP/M 2.1 50%

The system currently reports BDOS 2.2 to applications.

  • The CP/M‑386 BDOS is at full parity with CP/M‑68K 1.3 and CP/M 2.2.
  • A large majority of the CP/M‑Plus (CP/M 3) BDOS is also supported.
  • More than 60% of the DOS‑Plus additions have been implemented.
  • Approximately half of the MP/M extensions have been completed.
    • The missing functionality is largely the multi‑user, multi‑tasking, message queuing, and process control calls that don't apply to a single‑user CP/M implementation.
  • Unique CP/M‑386‑specific BDOS extensions have been added to accommodate new features like direct video access, high‑resolution timing, PRNG, etc.

The following dependencies are required to compile CP/M‑386:

Be sure to use cpmtools version 2.23 or later. Older versions may appear to work but have several known bugs.

Building CP/M‑386 is supported on current releases of NetBSD and FreeBSD, and most recent Linux distributions.

The following are the minimum versions of Linux distributions that have been verified to build CP/M‑386 successfully: CentOS Stream 9, Fedora 36, Debian 12, Ubuntu 18.04 (with gcc-16 from ppa:ubuntu-toolchain-r/test), Ubuntu 22.04, Alpine 3.24, and OpenSUSE Leap 15.4.

  • GCC build (recommended):
    make -Orecurse -j "$(nproc 2> /dev/null || printf '%s' 1)"
    make test
  • Clang build:
    make -Orecurse -j "$(nproc 2> /dev/null || printf '%s' 1)" CC="clang"
  • It is recommended to use GCC as Clang‑compiled i386 code is larger.
  • Be sure to make clean if switching compilers or adjusting compiler flags.
  • 32‑bit support libraries are required to run the test suite (make test).
  • At the time of writing, FreeBSD is shipping non‑functional cpmtools2 packages with broken mkfs.cpm functionality. To successfully build on FreeBSD, you must rebuild cpmtools and ensure it is not linked with libdsk. If you receive a Disc rejected by driver error on FreeBSD from mkfs.cpm, your tools are broken and cannot be used to build CP/M‑386.

You can download pre‑compiled binaries above.

  • Multiboot kernel (recommended):
    qemu-system-i386 -m 2M -serial stdio -monitor none -kernel "cpm386.elf"
  • Floppy MBR loader:
    qemu-system-i386 -m 2M -serial stdio -monitor none -drive if=floppy,format=raw,file="floppy.img" -boot a
  • Use -nographic -display none -vga none to disable VGA video (and use only serial console).
  • Use -serial none to disable the serial UART (and use only VGA console).
Program Description
ACLOCKDV.386 aclock (VGA text console version)
ACLOCKVT.386 aclock (ANSI terminal version)
BIG.386 Multi‑extent loading test executable
CLEARTPA.386 Clears (zeros) and optionally verifies the TPA
CLS.386 Clear screen (BDOS 221)
DELAY.386 Delay test (BDOS 141)
DEMO.SUB SUBMIT demonstration
DUMPDIR.386 Directory entry dump utility (BDOS 17/18)
DUMPFCB.386 File control block dump utility (BDOS 15)
ENV.DAT Environment data file
FPARSE.386 F_PARSE test (BDOS 152)
GETSN.386 Display serial number (BDOS 107)
GFXTEST.386 Graphics and framebuffer demo (BDOS 229/230/231/233)
HD.386 Hex dump utility
HELLO.386 Hello world (the very first CP/M‑386 program!)
ILLEGAL.386 Ring‑3 protection and exception handler test
IOTEST.386 File I/O BDOS tests
JULIA.386 Draw a Julia set fractal (terminal version)
LRBC.386 Query and/or set Last Record Byte Count
LS.386 List files (with sizes)
MANDEL.386 Draw a Mandelbrot set fractal (terminal version)
ALVTST.386 Get Allocation Vector test (BDOS 27)
MEM.386 Memory map utility (BDOS 227/228)
MORE.386 UNIX more‑style pager
OD.386 Octal dump utility
PAUSE.386 Wait for keypress
PRINTENV.386 Print environment and system data
PRNG.386 PRNG test and demo utility (BDOS 253/254)
PROFILE.SUB SUBMIT script (automatically executed at boot)
RC.386 Return code test and query (BDOS 108)
README.TXT Sample text file
REBOOT.386 Reboot utility (BDOS 220)
RM.386 UNIX rm‑like interactive file deletion utility
SEROFF.386 Disable serial console (BDOS 223)
SERON.386 Enable serial console (BDOS 223)
STAT.386 STAT (A port of Zilog CP/M‑Z8000 STAT v1.0C 01/03/84)
SYNC.386 Synchronize disks (BDOS 48)
TEST211.386 Numeric format test (BDOS 211)
TEXTMODE.386 Query and set the console text mode (BDOS 229/230/231)
TICKS.386 High‑resolution timer tests (BDOS 225/226)
TOD.386 Get (and set) Time of Day clock (BDOS 104/105)
TOUCH.386 Create an empty file
TRUNCATE.386 File truncation utility (LRBC aware)
TRUNCTST.386 Truncation tests (BDOS 99)
TSEC.386 Get date and time (BDOS 155)
VER.386 Display OS version (BDOS 163)
VGAFONT.386 Load a text console font or restore the ROM font (BDOS 232)
VGAOFF.386 Disable VGA text console (BDOS 222)
VGAON.386 Enable VGA text console (BDOS 222)
VGATEXT.386 VGA text direct access demo (BDOS 224)
  • Do not open pull requests with large amounts of LLM‑generated code. These will be immediately rejected.
  • There is currently no AI‑generated code in the operating system at this time (though there are some AI tests, comments, and analysis), as the project is intended to be as much of a learning experience for me as it is a useful OS port.
  • Usage of AI (artificial intelligence) tools by contributors is currently permitted, subject to the same terms and conditions as the LLVM AI Tool Use Policy, but this permission may be withdrawn at any time and without notice.

See FUTURE.md.

Language Files Lines Blank Comment Code Complexity Bytes Uloc
C 65 31160 6146 4379 20635 4356 730364 10665
C Header 22 3054 551 1233 1270 13 111663 1558
Makefile 2 1570 300 201 1069 331 52823 773
Assembly 6 1351 235 266 850 1 31040 700
Markdown 2 478 58 0 420 0 21907 378
Linker Script 2 169 34 0 135 0 3923 82
YAML 1 80 6 15 59 0 3196 63
Total 100 37862 7330 6094 24438 4701 954916 14146
  • CP/M‑386 is distributed under the terms of the permissive MIT License.
  • Bryan W. Sparks of DRDOS, Inc. dba DeviceLogics LLC, successor in interest to Digital Research, Inc.’s CP/M assets, explicitly grants an unlimited authorization to use, distribute, modify, enhance, and otherwise make available CP/M technology, including the CP/M operating systems and their derivatives.
联系我们 contact @ memedata.com