{"id":16164714,"url":"https://github.com/johnsonjh/cpm-m3","last_synced_at":"2025-03-18T23:30:33.950Z","repository":{"id":52851672,"uuid":"353202075","full_name":"johnsonjh/cpm-m3","owner":"johnsonjh","description":"cpm-m3: CP/M-M3 is a port of CP/M-68K to the ARM Cortex-M3 by Roger Ivie","archived":false,"fork":false,"pushed_at":"2022-03-19T21:02:23.000Z","size":607,"stargazers_count":15,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T12:47:00.940Z","etag":null,"topics":["68000","arm","cortex-m3","cp-m","cpm","cpm-68000","cpm-68k","cpm-arm","cpm-m3","cpm68k","m3"],"latest_commit_sha":null,"homepage":"https://github.com/johnsonjh/cpm-m3","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnsonjh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2021-03-31T02:35:48.000Z","updated_at":"2024-12-28T23:29:39.000Z","dependencies_parsed_at":"2022-08-23T00:00:48.495Z","dependency_job_id":null,"html_url":"https://github.com/johnsonjh/cpm-m3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonjh%2Fcpm-m3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonjh%2Fcpm-m3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonjh%2Fcpm-m3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonjh%2Fcpm-m3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnsonjh","download_url":"https://codeload.github.com/johnsonjh/cpm-m3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955432,"owners_count":20374369,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["68000","arm","cortex-m3","cp-m","cpm","cpm-68000","cpm-68k","cpm-arm","cpm-m3","cpm68k","m3"],"created_at":"2024-10-10T02:47:31.076Z","updated_at":"2025-03-18T23:30:33.472Z","avatar_url":"https://github.com/johnsonjh.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CP/M-M3\n\n## Summary\n\nThis is a port of **CP/M-68K** to the **ARM Cortex-M3**, specifically, the\n_LM3S9D92_. It builds under Windows. It is not quite ready for prime time in\nthat there are few applications and no documentation.\n\n## Overview\n\nCurrently, the only supported hardware is the _LM3S9D92_ microcontroller.\nPersonally, I run it on an _EK-LM3S9D92_ development kit. Among other things,\nthe microcontroller includes a **Cortex-M3** processor, 512K of flash, 96K of\nRAM, and a UART; other resources are not currently used by the system.\n\n### Disk\n\nThe internal flash is used as a disk; essentially, **CP/M-M3** considers the\nmicrocontroller to have a built-in 512K floppy. The disk is organized around 4K\ntracks, matching the erase block size of the flash. Well, technically, the flash\nhas 1K erase block, but there are enough interactions between the blocks that it\nis easier to consider it as having a 4K erase block. The erase block is managed\nby having a track cache; the cache is flushed (erasing and reprogramming the\nflash block) at warm boot or when a disk write requires a different track to be\ncached.\n\nThe first 8 tracks (32KB) are reserved to hold the operating system. At boot\ntime, the processor enters the bootstrap in the reserved area. The bootstrap\ncopies the system in RAM and jumps to it, just like a normal system would.\n\n### RAM\n\nThe _TPA_ resides in the first 64K of RAM, with the upper 32K reserved to hold\nthe system. The base page lives at the bottom of the _TPA_ and occupies the\ntraditional 256 bytes. The entry point of a transient program is passed a\npointer to the base page; the program should use this pointer instead of a\npriori knowledge of the base page location to allow the program to be easily\nmigrated to other **CP/M-M3** systems with a different memory layout.\n\nThe _BDOS_ is called through a function pointer located in the base page. The\ncurrent system does not provide a mechanism to call the system via a _TRAP_\ninstruction. A typical \"hello world!\" program looks something like this:\n\n```text\n#include \"cpm.h\"\nvoid Entry( cpm_basepage_t *BasePage )\n{\n  BasePage-\u003ebdos( 9, (unsigned int)\"hello world!\\r\\n$\" );\n  return;\n}\n```\n\n_DISCLAIMER: Off-the-cuff code; I haven't run it!_\n\nThe stack is placed at the top of the _TPA_ and grows downward in the usual\nmanner. System calls execute on the transient program's stack.\n\n### Executable Program Format\n\nExecutables are a simple memory image like a **CP/M-80** ._COM_ file. Unlike a\n._COM_ file, they are expected to begin with a 16-byte header containing:\n\n- A reserved 32-bit longword intended to hold a branch around the header.\n- A 32-bit longword containing a magic number that identifies the processor\n  architecture for which the program is intended. For **CP/M-M3**, this magic\n  number is _0x0000334d_ (i.e., the string \"_M3_\").\n- A 32-bit longword containing the address at which the program expects to be\n  loaded; that is, the base address of the _TPA_ plus 256 (for the base page).\n  For the _LM3S9D92_ port, this longword is expected to contain _0x20000100_.\n- A 32-bit longword containing a function pointer that refers to the program's\n  entry point.\n\n**NOTE:** The ._bss_ section is typically omitted by a C compiler. Since it is\nnot included in the memory image, it is not initialized by **CP/M-M3.** The\nprogram will need to make its own arrangements to initialize the ._bss_ section,\nif that is necessary.\n\n## Building the system\n\nThe system builds on Windows.\n\nYou'll need the following:\n\n- Visual Studio for the host tools. I seem to be using Visual Studio\n  Express 2013.\n- Code Sourcery for the target programs. I'm using Sourcery CodeBench Lite for\n  ARM EABI, version 2013.11-24.\n\nThe system is built by executing the `build.bat` command procedure in the\ndistribution directory in a command window that has executed the `vcvarsall.bat`\n(or whatever they're calling it this week) command procedure that prepares the\nenvironment for command-line usage of the Visual Studio tools.\n\nIf all goes well, the following items are placed in the build directory:\n\n- `cpm.bin`, the operating system image.\n- `dim.exe`, a Windows program that allows manipulation of the disk image (where\n  \"disk image\" means the image to be programmed into the microcontroller's\n  flash).\n- `ed.com`, the venerable _ED_ editor from **CP/M-8K**, recompiled for\n  **CP/M-M3**.\n- `oops.com`, a program that sets the registers to known values and causes an\n  exception, used to verify that exception handling is working.\n- `pip.com`, _PIP_ from **CP/M-8K** compiled for **CP/M-M3**.\n- `stat.com`, _STAT_ from **CP/M-68K** compiled for **CP/M-M3**.\n\nThe disk image manipulator, `dim.exe`, is a captive version of **CP/M-68K**\nbuilt to run as an application under Windows. It manipulates the file\n`romdisk.img`, which is the binary image that needs to be burned into the\nmicrocontroller's flash. If the image does not exist, it is created.\n\nThe _CCP_ of `dim.exe` has been extended to have a few custom commands:\n\n- `PUTSYS` copies the operating system image from a named host file to the\n  reserved tracks in the disk image.\n- `IMPORT` copies a named host file into the disk image.\n- `EXPORT` copies a named file from the disk image to a host file.\n- `EXIT` leaves `dim`, writing the disk image to `romdisk.img`.\n\n## Running the system\n\nYou need something that has:\n\n- An _LM3S9D92_ microcontroller.\n- A means of attaching UART 0 to some sort of terminal (or terminal emulator)\n  running at 115,200 baud.\n- A means of burning `romdisk.img` into the microcontroller's internal flash.\n\nI use the _EK-LM3S9D92_ development kit. This kit includes a program called _LM\nFlash Programmer_ that allows an image to be burned, regardless of the size\nlimits of the included evaluation toolset.\n\n## Conclusion\n\nSadly, the _LM3S9D92_ processor has gone into \"_not_ _recommended_ _for_ _new_\n_designs_\" status, which probably makes the dev kits hard to come by.\n\n- _Roger Ivie_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsonjh%2Fcpm-m3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnsonjh%2Fcpm-m3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsonjh%2Fcpm-m3/lists"}