HDCPM

From CPCWiki - THE Amstrad CPC encyclopedia!
Revision as of 02:06, 3 August 2022 by D kef (Talk | contribs)

Jump to: navigation, search

Hard Disk Boot loader for CP/M Plus
by Dimitris Kefalas <d_kef@yahoo.gr> - 2022
https://www.cpcwiki.eu/forum/applications/hdcpm-boot-and-run-cpm-plus-from-hard-disk/

Introduction

HDCPM is an Amstrad CPC application that enables your computer to boot and run CP/M Plus from a mass storage device. A maximum of four 8MB partitions or virtual disks can be used to make the vast amount of 32MB of data available to CP/M Plus.

It comes in the form of:

  • a standard background ROM that can be installed in any available ROM position.
  • a standard binary file that can be loaded from floppy or hard drive.


HDCPM has been developed with modern DOSs, that support the FAT file system, in mind. This means that CP/M can use the same hard disk with other DOSs.

The following configurations are possible with one hard disk:

  • One not partitioned, CP/M formatted hard disk. The whole hard disk is used by CP/M.
  • One to four CP/M formatted partitions. Every partition is accessed as a separate hard disk by CP/M.
  • One not partitioned FAT16 or FAT32 formatted hard disk. You can place one to four CP/M disk image files in the root directory. Every disk image file is accessed as a separate hard disk by CP/M.
  • One FAT16 or FAT32 and one to three CP/M formatted partitions. You can place one to four CP/M disk image files in the root directory of the FAT file system. Every disk image file is accessed as a separate hard disk by CP/M. CP/M disk images have priority over CP/M partitions so if you have three CP/M image files and three CP/M partitions then HDCPM will mount the three CP/M images and only the first CP/M partition. If the first partition on your hard disk is formatted to FAT16 or FAT32 then HDCPM expects to find the file CPMDSK01.IMG in the root directory. Failed to do so the system won't boot.
  • For interfaces that use SD card or USB flash drive as a mass storage device (M4 Board, USIfAC II or Symbiface III) the only supported configuration is one to four CP/M disk image files in the root directory of the FAT file system.

Currently only the master IDE device can be accessed by HDCPM. The slave device is available to be used by your favourite DOS.

HDCPM can also utilize the RTC found in the SYMBiFACE II in order to implement CP/M Plus BIOS function 26: TIME.

HDCPM is compatible with Dobbertin HD20 Harddisc and can be used together.

HDCPM has been developed with WinApe Z80 Assembler and was tested with WinApe, CPCemu, an Amstrad Plus 464 upgraded to 6128 and an Amstrad CPC 6128.
Although every effort has been made to ensure that HDCPM works properly, there is a chance of hard disk data corruption in case of a stray bug in the code. So make a backup of your hard disk before installing and trying out the ROM. I'll not be held responsible for any data loss or damage to your hard disk.

HDCPM distribution disk contains the following files:

  • HDCPM.ROM the ROM itself
  • HDCPM.BIN the executable binary file
  • HDMGR.COM Hard Disk Manager utility
  • RTC.COM RTC synchronization utility
  • MAKEIMG.BAS CP/M image file creation utility
  • MAKEIMG.BIN CP/M image file creation binary
  • MAKEIMG.EXE CP/M image file creation utility for SymbOS
  • HDCPM.DOC the User guide

HDCPM is free software. It can be used and distributed with no restrictions.

Prerequisites

  • Amstrad CPC/Plus computer capable of running CP/M Plus.
  • ROM box or other ROM expansion hardware if using the ROM.
  • Optionaly a FAT aware DOS like M4 ROM, USIfAC ROM, UniDOS, CubeMDOS etc if using the binary.
  • One of the following mass storage interfaces:
  • and a compatible storage device with enough free space to accommodate the desirable CP/M hard disk configuration.
  • Floppy disk drive for initialization of the file system.
  • CP/M Plus system disks for making the system bootable.
  • Optionally a SYMBiFACE II compatible RTC.

Restrictions

  • CP/M 2.2 or lower is not supported.
  • In case of a patched or non AMSTRAD CP/M Plus the BIOS, BDOS, SCB base addresses must be equal to the ones used by the official distribution of the AMSTRAD CP/M Plus.
  • Only the master IDE device is accessible by HDCPM.
  • The maximum number of hard disk partition/images supported is four.
  • Only primary partitions are supported.
  • If you want to use CP/M disk images then they must be stored in a FAT16 or FAT32 formatted disk or partition.
  • If the hard disk is partitioned then the CP/M disk images must be placed in the first partition of the disk.
  • The CP/M disk images must be placed in the root directory of the FAT file system.
  • The CP/M disk images must NOT be fragmented and must have the correct size.
  • The CP/M partitions must be big enough to accommodate your CP/M file system. Otherwise the file system on the hard disk WILL get corrupted.
  • Only storage devices with 512 bytes sector size are supported.
  • Only storage devices with LBA addressing are supported.
  • Date stamps of CP/M disk image files are not maintained.
  • In case a Dobbertin Harddisc is also used you can't change its drive letters (D, E, F, G) as they are hard coded in the Dobbertin driver. Use the HDMGR utility to assign other available drive letters to your IDE drive, images or partitions. If you use the same numbers for your IDE media then the corresponding HD20 partitions will be unavailable under CP/M.

How it works

Using the ROM:
Upon computer power-up the HDCPM ROM will be initialized and will inform you of the presence of a compatible interface and RTC. Two bytes of RAM will be reserved for storing the interface type and M4 Board ROM number (if found). The boot loader can be started by executing one of the following commands: |HDCPM (no TIME function support) or |HDCPMT (TIME function support)
Alternatively it can be started by holding down the Tab key (no TIME function support) or Shift+Tab (TIME function support), during power-up.

Using the binary:
HDCPM can be started by running the HDCPM.BIN file from floppy drive or mass storage.

HDCPM will then execute the following functions:

  • Search for a compatible mass storage interface.
  • Move the boot loader and the CP/M patcher to RAM.
  • Mount 1 to 4 CP/M image files and/or partitions and perform fragmentation and size test.
  • Read the boot sector of the 1st hard disk and learn about the DPB, presence and size of the .EMS file, the startup drive, the drive letters and the CP/M console colour scheme.
  • Read the .EMS file from the reserved track and store it in RAM just as the normal CP/M Plus boot loader does.
  • Move the top of TPA and transfer the hard disk driver, RTC driver (in case of |HDCPMT) and initialize the XDPH, DPB, ALV of the mounted hard disks to the memory area just below the normal BDOS base address. The newly inserted code will be handled by CP/M as if it was a normal RSX.
  • Patch the SCB in order to change the startup/default drive.
  • Patch the drive table records to reassign drive letters for floppy drives 1 and 2, hard disks 1,2,3,4 (if any) and ram drive if Dk'tronics or Dobbertin RAM disk driver is present.
  • Move the ALV of the Dk'tronics RAM disk if ZPM is detected.
  • Patch the CP/M console with the desired colour scheme.
  • Patch the system message.
  • Do a normal CP/M cold start.

Any CP/M 3.0 compatible system that loads the BDOS, BIOS, SCB to the default AMSTRAD CP/M addresses should work. HDCPM will be able (hopefully) to patch it on the fly.

CP/M Plus disk image files

A CP/M Plus disk image file is a raw binary image of a CP/M hard disk or partition. Its name must be in the form CPMDSK0x.IMG where x=1, 2, 3 or 4 in order to be recognized by HDCPM. The size of the file depends on the Disk Parameter Block of the virtual hard disk it represents and for the initial release of HDCPM it is fixed and equal to 1 reserved track * 256 sectors per track * 512 bytes per sector + 8MB data = 8519680 bytes. If possible create your CPMDSK01.IMG file in a modern computer and copy it in the root directory of your FAT formatted medium. You can use the free online hex editor hexed.it or any hex editor capable of creating binary files filled with a specific pattern.
In case of hexed.it select 'New file' fill in 'Size of the new file = 8519680' and 'Fill Pattern = 0xE5' and press apply. Save the file as CPMDSK01.IMG If you have a FAT capable DOS installed in your AMSTRAD you can use the provided MAKEIMG.BAS utility to create your image file. Keep in mind that it takes more than 1.5 hour for a 8MB image file to be created that way.
CP/M disk image files can be accessed by a modern computer with cpmtools. Use the command |HDDEF to see the record you must insert in the diskdefs file.

The HDCPM record for diskdefs is:

      diskdef hdcpm
         seclen 512
         tracks 65
         sectrk 256
         blocksize 8192
         maxdir 1024
         skew 0
         boottrk 1
         os 3
      end


HDCPM is not FAT aware. It utilizes code to search in the root directory of a FAT formatted medium in order to find the CP/M image files. Then it finds the LBA of the first sector of each file and passes it to the CP/M hard disk driver. The CP/M hard disk driver doesn't know anything about FAT or image files. It accesses the image file as if it was a real hard disk. It works on the sector level with LBA addressing so it expects the 'hard disk' to be a continuous block of sectors.
A CP/M image file can easily become fragmented during its creation, especially if the hard disk is nearly full. I advice you to create/copy your CP/M image files to your FAT formatted hard disk/partition while it is still empty. HDCPM will never fragment a CP/M image file.

HDCPM binary booting on M4 Board

CP/M Plus disk/partitions

You can also create one or more partitions in order to format them to CP/M file system and use them exclusively for CP/M. In such case you must make sure that the size of the partition is big enough to accommodate your file system.
HDCPM examines the hard disk's MBR upon start and finds the partition information. Then it finds the LBA of the first sector of each partition and passes it to the CP/M hard disk driver. The CP/M hard disk driver doesn't know anything about partitions. It accesses the partition as if it was a real hard disk.
HDCPM can't be used to partition your hard disk. In order to create partitions you must connect the hard disk to a modern computer and use its partitioning utility.
Use the command |HDDEF to find the exact length of the file system/partition. When you have created the partition use the HDMGR.COM utility in order to format it.
This configuration is only to be used with SYMBiFACE II or uIDE 16. USB flash disks and SD cards should not be partitioned as they will not be detected by their interface ROM.

HDCPM booting on uIDE-16

Installation

Using the ROM

  • Install the HDCPM ROM in a free ROM slot of your ROM box.
  • Plug in your SYMBiFACE II compatible IDE interface, uIDE 16, M4 Board or USIfAC II and attach the proper mass storage device.
  • Power on your Amstrad. You should see the ROM initialization message: CP/M+ Hard Disk boot loader v1.04 (S2). The type of interface found will be show inside the parentheses:
HDCPM ROM - SYMBiFACE II
HDCPM ROM - uIDE-16
HDCPM ROM - M4 Board
HDCPM ROM - USIfAC II
HDCPM ROM - Symbiface III

In case a RTC is detected you will also see the RTC initialization message and the current date and time: RTC found: 2021/01/01 12:01

  • Use your original CP/M Plus system disk set to Boot CP/M Plus.
  • Use the provided HDMGR.COM utility in order to format the disk image or partition and transfer the .EMS file to the reserved track. Change the start-up drive letter to that of your first CP/M hard disk.
  • Reset your AMSTRAD and boot CP/M from the hard disk with the command |HDCPM. The Boot loader will check your image file(s) against fragmentation and correct size and boot the system to the CP/M command prompt. If the first image file is fragmented or has the wrong length the system will not boot. All other image files will be ignored if found to be fragmented or have the wrong length.
  • In case you don't use CP/M image files just boot the system with |HDCPM or |HDCPMT
  • Copy the files from your CP/M system floppy disks to the first hard disk.
  • Copy any other needed application etc. to your CP/M hard disk(s).
  • You are ready to go.

Using the binary

  • Plug in your SYMBiFACE II compatible IDE interface, uIDE 16, M4 Board or USIfAC II and attach the proper mass storage device.
  • Use your original CP/M Plus system disk set to Boot CP/M Plus.
  • Use the provided HDMGR.COM utility in order to format the disk image or partition and transfer the .EMS file to the reserved track. Change the start-up drive letter to that of your first CP/M hard disk.
  • Reset your AMSTRAD and insert the HDCPM floppy disk. If using a FAT aware DOS you can copy HDCPM.BIN to your mass storage device.
  • You are ready to go.

ROM commands

HDCPM booting on USIfAC II
  • |HDCPM mounts the hard disks and boots CP/M Plus. If USIfAC II is used enable the USB disk with the |USB command first.
  • |HDCPMT works like |HDCPM but also utilizes the RTC.
  • |HDDPB shows the Disk Parameter Block.
  • |HDDEF shows the diskdefs entry for CP/M tools and the file system size.
  • |DATE displays the current date.
  • |TIME displays the current time. If M4 Board is used |DATE and |TIME will be redirected to M4 |TIME.

The HDCPM binary file

  • If USIfAC II is used, use your PC to copy HDCPM.BIN to your USB flash disk. Then insert it to your USIfAC II power up your Amstrad and enable the USB disk with the |USB command.
  • Execute the file from the floppy disk or from your mass storage device with RUN"HDCPM". HDCPM will detect your mass storage interface and you will see the initialization message: CP/M+ Hard Disk boot loader v1.04 Then it will mount any available hard disk images and boot CP/M Plus.
  • M4 Board and USIfAC II use their own FAT aware DOS so you can run HDCPM.BIN directly from their mass storage device. For all the other interfaces you will need to have a FAT aware DOS, like CubeMDOS or UniDOS, installed.

The MAKEIMG.BAS and MAKEIMG.EXE utilities

MAKEIMG.BAS

Although this utility should not be your first option, you can use it to make a new empty CP/M disk image file.
In case you decide to use it make sure you have a FAT aware DOS installed in your system. MAKEIMG makes use of the firmware calls CAS_OUT_OPEN, CAS_OUT_CLOSE and CAS_OUT_CHAR so your DOS must support them.
Copy the files MAKEIMG.BAS and MAKEIMG.BIN to the root directory of your FAT formatted hard disk and make it your current drive. Run the utility with RUN"MAKEIMG" and don't hold your breath!
Making an image file this way takes more than 1.5 hour for an 8MB file so literally... don't hold your breath.
Here is a small tutorial on how to setup and use a CP/M image file: https://youtu.be/GMWsRzNhQTM

MAKEIMG.EXE

This utility is a SymbOS application.
Use this utility to create your CP/M hard disk images from within SymbOS. It is a bit faster than its Basic counterpart. It takes between 25 and 60 (or more) minutes for your image file to be created, depending on the characteristics of your media. Disable your screen saver before using it in order to gain some speed.
MAKEIMG.EXE has been developed with Quigs for SymbOS.

MAKEIMG.EXE in action

The HDMGR.COM utility

This is the Hard Disk Manager utility.
You can use this utility to get information about your hard disk geometry, disk image files, partitions and boot sector. You have to use this utility to format a hard disk, disk image file or partition to CP/M format or manipulate the boot sector of the hard disk and/or transfer an .EMS system file to the reserved track of the hard disk.
The boot sector contains information about the CP/M disk drive letters, start-up drive and console colour scheme. All those properties can be changed with HDMGR.COM.
HDMGR will perform a fragmentation test of the discovered CP/M hard disk image files uppon execution.
You can't use this utility to re-partition your hard disk or make a new CP/M image file or manipulate a file system other than CP/M.
The HDMGR.COM utility is self explanatory. Just run it from the CP/M command prompt.

HDMGR main menu
HDMGR Hardware information
HDMGR CP/M disk image information
HDMGR Boot sector information
HDMGR Manage boot sector
HDMGR Transfer CP/M to disk

The RTC.COM utility

If you need the 470 bytes of RAM that the integrated RTC driver occupies then you can make use of the RTC.COM utility in order to keep CP/M date and time updated.
You can synchronize the date and time of CP/M Plus with the RTC by running RTC -G manually or via your PROFILE.SUB
You can also set your RTC to the current CP/M date and time by running RTC -S

Error messages

Hard disk errors

  • *** No mass storage found ***

No compatible mass storage interface can be found.

  • ERROR: DISK I/O

I/O error occurred during the last read/write operation. Your hard disk might be defect or the USB disk is not enabled.

  • ERROR: INVALID BOOT SECTOR

No FAT or CP/M boot sector was found in a not partitioned hard disk.

  • ERROR: INVALID FILE SYSTEM

The first partition in a partitioned hard disk is not a FAT or CP/M-80 one.

  • ERROR: INVALID SECTOR SIZE

The hard disk used has a sector size not equal to 512 bytes.

  • ERROR: CPMDSK01.IMG NOT FOUND

The CP/M image file named CPMDSK01.IMG can't be found in the FAT formatted hard disk or partition.

  • ERROR: CP/M SYSTEM FILE NOT FOUND

The .EMS CP/M system file can't be found in the system track of your CP/M partition or image file.

  • ERROR: CPMDSK01.IMG IS FRAGMENTED

The first CP/M image file is fragmented, the system won't mount it.

  • ERROR: CPMDSK01.IMG HAS WRONG LENGTH

The first CP/M image file has wrong length, the system won't mount it.

  • ERROR: CPMDSK01.IMG IS NOT FORMATTED

The first CP/M image file is not formatted to CP/M-80 format, the system won't mount it. Use the HDMGR.COM utility to format it.

  • ERROR: INCOMPATIBLE EMS FILE

The .EMS system file that was loaded from the system track is not compatible with HDCPM.

RTC errors

  • *** Battery depleted ***

The RTC battery is depleted. The RTC driver will continue to operate normally but the readings are not reliable. Replace the RTC battery.

Release info

Version Changes
v1.00 December 2021 Initial release
v1.01 January 2022 HDCPM.ROM, HDMGR.COM: code optimization.

HDCPM.ROM, HDMGR.COM: (bug fix) fragmented file detection was not working properly unless the file was CPMDSK01.IMG
HDCPM.ROM, HDMGR.COM: (bug fix) unformatted image file detection was not working properly. New error message added.
HDCPM.ROM: (bug fix) CP/M drive table wasn't patched properly.
HDCPM.ROM: (bug fix) initialization of floppy drive(s) was corrupted due to misplaced code.
HDCPM.ROM: added .EMS file compatibility check. New error message added.
HDCPM.ROM: added support for Dobbertin RAM disk driver.
HDCPM.ROM: added compatibility with Dobbertin HD20 Harddisc
MAKEIMG.EXE: added utility for creating an image file from within SYMBOS.
HDCPM.DOC: various additions and corrections.

v1.02 March 2022 HDCPM.ROM, HDMGR.COM: added support for M4 board.

HDCPM.ROM, HDMGR.COM: added support for uIDE-16 interface.
HDCPM.ROM, HDMGR.COM: code optimization.
HDCPM.ROM: (bug fix) the ROM was initialized even if no compatible interface was found.
HDCPM.ROM, HDMGR.COM: error message change.
HDCPM.ROM: option "F" has been removed. HDCPM will always do a disk fragmentation test during boot.
HDCPM.ROM: power up message changed in order to provide information about the type of the detected interface.
HDCPM.ROM: two bytes of RAM will be reserved by the ROM for storing the interface type and M4 ROM number.
HDCPM.DOC: various additions and corrections.

v1.03 April 2022 HDCPM.ROM, HDMGR.COM: added support for USIfAC II.

HDCPM.ROM: (bug fix) uIDE-16 detection was broken.
HDCPM.DOC: various additions and corrections.

v1.04 June 2022 HDCPM.ROM: code optimization.

HDCPM.DOC: various additions and corrections.
HDCPM.BIN: added executable binary file version of HDCPM.

v1.05 July 2022 HDCPM.ROM, HDCPM.BIN, HDMGR.COM: added support for Symbiface III

HDCPM.ROM, HDCPM.BIN: code optimization.
HDMGR.COM: Hardware info added for USIfAC II
HDMGR.COM: (bug fix) the 'Select boot file' menu was garbled if there were 8 or more .EMS files present.
HDCPM.DOC: various additions and corrections.

Downloads

  • HDCPM v1.05 (floppy disk image) - Contains the ROM file, the binary file the utilities and the manual.
  • CP/M disk images - CPMDSK01.IMG is bootable and contains all the files of the 3 CP/M Plus system disks. CPMDSK02.IMG is empty and can also be used as a template.

Videos