• Please review our updated Terms and Rules here

Kaypro doesn't store ALL of its CP/M in the reserved track

alank2

Veteran Member
Joined
Aug 3, 2016
Messages
2,255
Location
USA
I was analyzing all the downloadable disks on the web that I could find for my Kaypro 4/83 and I found something interesting. First the one says "KAYPRO II 64k CP/M vers 2.2" and the other says "KAYPRO IV 64k CP/M vers 2.2". They are virtually identical other than that difference and about 20 bytes at the end which could be configuration maybe.

The first track is reserved (10 sectors * 512 = 5120 bytes). Then if on a flat image, another 2048 bytes beginning at 0x1c00 is a continuation of CP/M. It is actually block 1 in the file system and is the 2K following the directory (64 entries * 32 bytes). I then noticed on some disks with files that they begin at "2" and not "1". Would they possibly have patched CP/M not to use block 1 as to keep this area from being overwritten? How does this work with tools like cpmtools? The kpiv diskdef seems unaware of this unless I'm not getting it.
 
Yes, I got a "fix" for this in the latest cpmtools. Basically, Kaypro reserved two full blocks for the directory, but only used the first 64 entries. The diskdef for the latest cpmtools version is:
Code:
diskdef
    seclen 512
    tracks 80
    sectrk 10
    blocksize 2048
    maxdir 64
    dirblks 2
    skew 0
    boottrk 1
    os 2.2
end

Note the new parameter "dirblks" that tells cpmtools to reserve two blocks even though only 64 entries are used.

In the CP/M DPB this is accomplished by having DPB.DRM=63 and DPB.ALV0=11000000B

and, yes, this all came after trashing several formerly-bootable Kaypro disk images by using cpmtools on them.
 
I had thought these got merged, but alas no action from Michael Moria, official owner of cpmtools http://www.moria.de/~michael/cpmtools/, or on pull request at https://github.com/lipro-cpm4l/cpmtools. You can take cpmtools-2.21 from github and either add the commit from my pull request or apply this patch (attached).

This commit/patch also fixes the Kaypro diskdefs, but does not change any other possible formats that might suffer from this (the only ones I know of are Kaypro).

If you're not fluent in git/github, let me know and I can make a tarball of the source for that commit. I only have Ubuntu 20.04 Linux on x86_64, so if you need binaries for a different platform we'll have to work something out.
 

Attachments

  • 0001-Fix-problem-where-Kaypro-disk-reserved-space-was-clo.patch.txt
    7.1 KB · Views: 2
I could use win32 binaries, but I don't want you to have to go through a lot of work. Will Michael eventually get it integrated?
 
I don't have any way to produce Windows binaries. I will push on the https://github.com/lipro-cpm4l/cpmtools (which is not Michael) pull request to get the integrated, but I don't believe that that repo is used to distribute binaries so someone with a Windows C development kit would need to do that (maybe cygwin is all that's needed?)
 
No worries - in the meantime I suppose I can just expand maxdir to take up the area, but never copy more than 64 files to it!
 
No worries - in the meantime I suppose I can just expand maxdir to take up the area, but never copy more than 64 files to it!

Yes, in theory. But you have to watch out for files that overflow the first directory entry, as each entry consumed by a file works toward that "64".
 
Still thinking about how to "workaround" this issue without having to recompile cpmtools. My other thought was to just create a directory entry that holds that block used. It could even be named CPM22.BIN or something.
 
Still thinking about how to "workaround" this issue without having to recompile cpmtools. My other thought was to just create a directory entry that holds that block used. It could even be named CPM22.BIN or something.

Yes, that's what I did for awhile with my simulator disk images before fixing cpmtools. It works best when creating new blank images, for existing images with files it is a bit trickier. But if you are manually "editing" the directory you can just create the entry and list the block(s) in the appropriate part of the entry. Keep in mind that DS disks use 2K block size and thus the reserved block is 01. For the SS disks (1K block size) it is blocks 02 03. Might just be easier to tell cpmtools that you are using 128 directory entries and just be cautious not to overflow 64.
 
I made a quick disk tool to convert disks or extract/import cp/m on them, so maybe I'll just add a "protectfile" option for it that adds a file that protects it. For DSDD it would only have to have one allocation block 01, but for SSDD it sounds like it would need two, for 02 and 03. I think 00/01 are still taken up by the directory. I suppose I could even put the protectfile in user 15 where no one is likely to find it.
 
Thanks for this patch. As a Kaypro owner, I had occasionally trashed a Kaypro cpm disk image but never investigated further.
 
Another issue I just found with cpmtools (this is the older version 2.21, so maybe it has been fixed since then), is that it outputs 0 byte files as 128 bytes of 0x00.
 
I'm not able to reproduce this issue with the cpmtools 2.23 that I am running with. I copy a zero-length Linux file into a CP/M image, and it shows up as "0k" and "0 recs". I then copy that file back to Linux and it is still zero-length.
 
Back
Top