PDA

View Full Version : CP/M tools on a hard disk



JonB
February 28th, 2017, 08:50 AM
Hi

I noticed that the N8VEM SBC project distributes a disk image with tools to write files to it. These are cpmls and cpmcp, our old mates from the CPM tools package. The distribution also comes with a diskdefs file. There is one diskdef per partition on the N8VEM storage device (which I assume is a CF card or SD card).



# For N8VEM mass storage (4 raw partitions)
diskdef hd0
seclen 512
tracks 65
sectrk 256
blocksize 4096
maxdir 512
skew 1
boottrk 1
os 2.2
end

diskdef hd1
seclen 512
tracks 130
sectrk 256
blocksize 4096
maxdir 512
skew 1
boottrk 66
os 2.2
end

diskdef hd2
seclen 512
tracks 195
sectrk 256
blocksize 4096
maxdir 512
skew 1
boottrk 131
os 2.2
end

diskdef hd3
seclen 512
tracks 260
sectrk 256
blocksize 4096
maxdir 512
skew 1
boottrk 196
os 2.2
end

So, you have defs for HD0 to HD3 that address each of the drives on the image. So far, so good. Note how the values of tracks, boottrk increase with each disk. I presume this is related to the drive offset, but I don't understand why tracks gets bigger as I thought it was "number of tracks on the disk".

Now, I want to use this to access an image on the uIDE drive I am developing. The DBP for my disk format is:


; Block size = 4096 bytes
dpb: dw 128 ;SPT - sectors per track
db 5 ;BSH - block shift factor
db 31 ;BLM - block mask
db 1 ;EXM - Extent mask
dw 2039 ;DSM - Storage size (blocks - 1)
dw 511 ;DRM - Number of directory entries - 1
db 240 ;AL0 - 1 bit set per directory block
db 0 ;AL1 - "
dw 8000h;CKS - DIR check vector size 8000=CP/M 3 fixed disk
dw 1 ;OFF - Reserved tracks (for warm booting)
db 2 ;PSH - Phys sector shift (2 => 512 byte sectors)
db 3 ;PSM - Phys sector mask (3 => 512 byte sectors)


..and I have tried to access an image using this diskdef:


diskdef uide
seclen 512
tracks 512
sectrk 128
blocksize 4096
maxdir 512
skew 0
boottrk 1
os 2.2
end

As you might imagine, it doesn't work. cpmls returns all blanks for user 0: and garbage for the other users. It should return the directories for the first disk partition on the image, which has one reserved track, so the data begins at the second track. I have tried various combinations (skew=1, tracks=256, no "os 2.2", etc) but without success. The only thing is that the image was written using LBA and this could give a different addressing scheme to the normal disk/track/sector setup. To illustrate this, take a look at Grant Searle's excellent CP/M computer page here (http://searle.hostei.com/grant/Multicomp/cpm/fpgaCPM.html). Scroll down to the "Sector Addressing" section; this is how I am implementing LBA on the disk image.

So.. is it possible for CP/M tools to read my image? If so, what diskdefs might I use? And what parameters are available in the diskdefs file, and how is each used? I get the ones I have already listed, but are there others? I have searced using Google, but haven't found a good description of the diskdef parameters yet.

Thanks
JonB

ldkraemer
February 28th, 2017, 11:45 AM
JonB,
The cpmtools definition stanzas that I know about are:

diskdef title
seclen xxx #= Sectors xx,1024
tracks xx #= (Cylinders * Sides) = 80*2 = 160
sectrk xx #= Sectors 5,xxx
secbase 0
blocksize xxxx #= (128*(BLM+1)) = 2048
maxdir xxx #= (DRM+1) = 256
skew x #= may be 1 thru 6, or so
#
#offset 16384
#boottrk 0
#
boottrk x #= OFS = 2
os x.x #= 2.2, or 2, or 3
end

I've commented out the bootrk x and used an offset with bootrk 0, as shown above.


Larry

JonB
March 1st, 2017, 10:59 PM
Thanks Larry.

I had a play but no luck so far. Must be down to LBA mode in use when writing to the IDE device on the real hardware... I'm guessing the correlation between LBA and Cylinder/Track/Sector geometry isn't so straightforward!

Cheers
JonB

Oscar
March 2nd, 2017, 02:41 AM
Jon,


Hi
but I don't understand why tracks gets bigger as I thought it was "number of tracks on the disk".


The way it is set up, the number of tracks grows for each consecutive partition. But the number of boot tracks does, too. Leaving the same number of normal, non-reserved tracks. It is a crude way of offsetting the starting point of the partitions on the image.

Regards,

Oscar.

durgadas311
March 8th, 2017, 03:53 AM
I did a similar thing for partitioned harddisk images, but used "offset":


diskdef part0
seclen 512
tracks 625
sectrk 16
blocksize 2048
maxdir 512
skew 0
boottrk 2
offset 1536
os 2.2
end
diskdef part1
seclen 512
tracks 500
sectrk 16
blocksize 2048
maxdir 384
skew 0
boottrk 2
offset 5121536
os 2.2
end
diskdef part2
seclen 512
tracks 506
sectrk 16
blocksize 2048
maxdir 384
skew 0
boottrk 2
offset 9217536
os 2.2
end

The offset value is in bytes. In this case, the first 1536 bytes of the disk contain partition information (offset tables and DPBs) and some common boot code.