Date: Wed, 2 Jul 2025 02:43:30 -0500 (CDT) Subject: Re: Getting back on TRK00 So, I'm trying to get set up to play with multiple physical units on the GIDE board, primary/secondary (master/slave although that concept doesn't really apply). Turns out, I've been using perhaps the _worst_ possible disk for my development work. The Conner CP-342 earns a big, fat "U" (an F-U if you will) in the "Works and plays well with others." category. It is so bad that some Western Digital IDE disks of that era had a special extra jumper _just_ to handle the case where a Conner CP-342 was installed as the master/primary drive. In fairness, I did have the drive set to "single" as per the only config data I found. Setting it to "Master" changed nothing. Accesses to the device attached as the secondary unit was either garbage or garbled. Setting the CP-342 to slave/secondary seems to work like a charm and with a SanDisk CF card as primary in an IDE-CF adapter, both units are visible and appear to return the correct data. So, I needed to boot from the secondary unit. One thing I learned is that I need to make the ide boot code in the ROM more robust. It needs a power-up delay for the first time it tries to access an IDE disk. It also needs to be more selective about just jumping to any old sector it happens to load from a hard disk. The CF card has a standard DOS MBR on it, so it went nuts and corrupted the RAM copy of the ROM code to the point it required a power-cycle to straighten out the FDC again. I got out my boot floppies which boot the 62K system and run the GBIOS62.COM loader as a turnkey command--specifically the version that leave the floppies as drive A:-D: and the IDE disk as drives E:-I:. I patched the file to use "Bx" for the secondary unit instead of "Ax" for the primary unit for the SDH byte sent to the Task File registers. There was a moment where things still didn't work because I forgot that there are 2 places to patch, one in Select Array that is used by SELDSK: and the other that gets used during disk access for the actual SDH value to OR in to the "disk" (head) value. Once I got that straightened out, I could access the disk and make the same patch to one of the "disks" on the hard disk. When the machine boots, I drop to the Monitor right away, condition the location where the IDE boot code checks for the next "disk" to try so it contains a value for the head on the secondary unit to boot. It passes this to the boot sector code in A so the rest of the system (with the patched BIOS) is loaded from the same "disk". Preliminary tests indicate that IDE disks work just fine as secondary units with no primary attached. This will be important as I need to keep the CP-342 operational while investigating other devices. I've been reading the source code for the work Armin Diehl did for his Prof80 ECB Z80 system with his implementation of the GIDE interface and CP/M3. I can see some similarities between what I did and what CP/M3 does. I'm thinking I should implement his "MBR"-style boot sector even if I don't use that arrangement just yet. The signature string alone would be a better guard against executing random data than a simple test whether the first byte is "E5" and jumping to the code if not. ----- Date: Fri, 4 Jul 2025 02:47:34 -0500 (CDT) Subject: Re: Getting back on TRK00 On Tue, 1 Jul 2025, John D. Baker wrote: > I've been reading the source code for the work Armin Diehl did for his > Prof80 ECB Z80 system with his implementation of the GIDE interface and > CP/M3. I can see some similarities between what I did and what CP/M3 > does. I'm thinking I should implement his "MBR"-style boot sector even > if I don't use that arrangement just yet. The signature string alone > would be a better guard against executing random data than a simple test > whether the first byte is "E5" and jumping to the code if not. So I can't pick just one thing to work on. Sometimes I hack on the ROM code, then switch off to the HD boot sector, then some of the support utilities. I have updated the various utilities I wrote in C to accept a unit number (0 or 1 for primary or secondary) along with their other usual arguments. I got the ID and DUMP utilities done and learned a few new tricks. Just now, I updated the ZERO utility--perhaps misnamed since it writes "E5h" to every byte of the disk (or portion thereof as selected by command-line arguments). I've implemented a hybrid version of Armin Diehl's MBR-esque boot sector and partition table. With the disk geometry information encapsulated in the boot sector itself, I should be able to dispense with the SECID_NF tricks since I don't have to incur that error at all. There's lots of room for activities. It's a hybrid in that, for compatibility with my current scheme, it claims the disk has only 1 head and it incorporates the "paritition boot record" as well (contains DPB for that partition). I got to thinking that it would be convenient to be able to call ROM routines from the boot sector, so I rearranged the ROM code to have a jump table similar to the BIOS. It's mostly the console routines that are implemented. Anything else jumps to the Monitor. The hybrid MBR-esque boot sector seems to work in test mode. I need to update the IDEGEN utility to deal with multiple physcial units so I can write a system image with the new boot sector to the secondary unit. Then I can run the ROM code in test mode. ----- Date: Sun, 6 Jul 2025 17:54:20 -0500 (CDT) Subject: Re: Getting back on TRK00 On Fri, 4 Jul 2025, John D. Baker wrote: > I've implemented a hybrid version of Armin Diehl's MBR-esque boot sector > and partition table. With the disk geometry information encapsulated > in the boot sector itself, I should be able to dispense with the SECID_NF > tricks since I don't have to incur that error at all. There's lots of > room for activities. It's a hybrid in that, for compatibility with my > current scheme, it claims the disk has only 1 head and it incorporates > the "paritition boot record" as well (contains DPB for that partition). I finally got that working, at least in test mode. It's the first time I've used the multi-sector read capability by setting the Sector Count register to a value greater than 1. Telling it the drive has only 1 head makes it work for the current arrangement. Some experiments confirm that a multi-sector operation proceeds in cylinder-major order. I need to update my IDEGEN utility to request a unit number along with the head (for legacy support). Maybe I'll just call them partition numbers. Maybe another query for partition by head or partition by cylinder. If there's a partition table on the disk already, it can read data from it. If not, there'll need to be some override or read the partition table from the boot sector in the system image (if it was loaded from a file). I should look at Armin Diehl's 'fdisk' utility and either convert it from Pascal to C or figure out if I have a copy of Turbo Pascal anywhere that I can get onto the Davidge. I know it's on my Apple CP/M systems, but I can't physically access them right now. The test-mode ROM is starting to get tight on space even after tightening the message strings a bit more. I've got it alternating between primary and secondary units on each retry and if it's the first access it's supposed to wait 10 seconds before accessing the disk and it now sends a RESTORE (or HOME or RECALIBRATE depending on who you ask) before doing anything else (important for drives with stepper-motor head positioners). I say _supposed_ to wait 10 seconds, but it seems more like 120 (or more, I haven't actually timed it) before it accesses the disk. ----- Date: Thu, 10 Jul 2025 20:50:41 -0500 (CDT) Subject: Re: Getting back on TRK00 Anxious to get my hybrid MBR-esque/PBR boot sector on the disk, I just h4xx0r3d a simple program to write Cylinder 0, Sector 1, of a given head right in DDTZ just above where I'd loaded the boot sector from 100,2ff. That got the bootsector installed. I saved it as INSTBOOT.DDT. I'll write a proper "installboot" utility eventually. Then I turned back to the next generation of the ROM code. I found my bug that was making the spin-up delay take so long. I branched back to the wrong label so instead of reloading B with the cpu scale factor, it was looping the whole 256 times. I also added polling the DRV_RDY bit (bit 6) in the status register so when the drive(s) report(s) ready, the loop will exit early. My empirical "feels like 1 second" delay values were not far off. I ultimately counted up all the T-states in the loops plus call, return, branch taken/not taken, etc. My "feels like" delay for about 50ms was 8000 (decimal), the calculated value is 7692, a 4% error. My cpu scale factor of 20 turned into a scale factor of 26, but since that didn't divide evenly for a 6MHz machine, I dropped it to 24, for errors of 23% and 17%, respectively. I recently deciphered several more bytes in the CBIOS which turn out to be head-load delays for 8-inch and 5-inch disks, head-settling time and motor-on delays. They were just the number of milliseconds and their calibrated delay loop uses a value of 40 times the CPU speed in MHz for the scale factor (MSB of loop counter). The idea of making ROM routines available to the boot sector code or early BIOS boot routines got scaled back quite a bit when I realized that code below 0100h would be overwritten when the BIOS takes over, so instead of a jump table at 0000, I have an array of function pointers at 0100h for ROM versions of CONST, CONIN, CONOUT, a printstring routine, and the 50ms delay routine. Some things I realized were single-use only, so just folded them into the code inline rather than make a subroutine. That saved the call/return overhead both in size and time. In particular, doing discrete comparisons for the signature string "CPM" in the boot sector was shorter than calling the "strncmp" routine and eliminated the need to keep a copy of the string in ROM. New ROM is running now so I can think about how to migrate the BIOS extension to the new scheme. The bootsector (and most of the ROM code) will still be resident and unaltered when the BOOT routine(s) are running, so my loader can install values in the BIOS. I think it will work something like this: If the partition starts in Cylinder 0 and the disk is claimed to have only 1 head, the first N partitions are on each of the first N heads. Otherwise, the partitions start at a cylinder > 0 and start with head 0, sector 1 of that cylinder. The hybrid MBR/PBR contains the DPB for a partition. So, resident data for each disk will need to be something like: Unit (0/1, primary/secondary) (w/head for legacy system) Start cylinder DPB[unit][num] Unit data will be something like: Heads Sectors/track DPB0 DPB1 I figure only have 2 DPBs per unit, one to handle as many maximum-size partitions as will fit and the other to handle a smaller partition to fit any remaining space. I'll probably only support 4 hard-disk resident disks as I'll need space for more data and code to support the new arrangements. I figure on cold boot, all disk slots will be initialized from the first 4 partitions on the unit from which the system booted. As a first approximation, I'll probably come up with a utility to switch out disk partitions. The common read/write code w/sector deblocking will need to determine which head a sector is on. Probably encode that as the MSB of SEKHST and HSTSEC. Everything else is 16-bit, but the host sector numbers will eventually reduce to 8 bits. I've already done some rearrangement so I can point HL at the first HST* item and walk up the bytes, plugging them into the various Task File registers more-or-less in order (might need to go back and see if I can use register-indirect addressing and whether that will save space over "ld a,(hl) ! out (iRgFoo),a" So, I was hoping to use 22DISK to transfer data between the Davidge and DOS/UNIX, but I discovered that it operates the FDC in the Dell Optiplex 110 at 300kbps instead of 250kbps, even if I tell the BIOS the drive is 360K 5.25". To work around this, I format a disk with 22DISK for the Davidge format, image it with IMD, then turn around and re-write the disk from the image, doing 300K->250K conversion. Then I can read the disk in the Davidge. I'll need to check if doing the opposite conversion will produce a disk originated on the Davidge that 22DISK can read. I was hoping to produce a disk image with IMD that was bootable, but writing the disk from an image results in track0 sector 18 (single- density 128 bytes) being bad on the Davidge. ----- Date: Sun, 13 Jul 2025 15:30:50 -0500 (CDT) Subject: Re: Getting back on TRK00 Taking a break from IDE hacking a bit, I've been working on how to add to the rather sparse information there is on the Davidge DSB-4/6. There are photos and ROM images on bitsavers and a couple of videos on YouTube of running the "1538A.BIN" ROM image under MAME, but that's it. I probably have the most complete collection of Davidge material there is and it needs to get out to the rest of the world. I assembled what I consider a "minimum viable boot floppy" that will work on 3.5" or 80-track (300RPM) 5.25" disks. It boots a 64K plain CP/M and contains all the materials needed to write a BIOS plus a couple of nice utilities. I've copied the files to *NIX so I can make a zip archive of them (LBR would be more traditional but anyone handling these files will likely be starting with some type of unzip utility on a PC, whether DOS, windoze, or some flavor of *NIX so it wouldn't be fair to introduce another "bootstrap" problem.) So then I needed to see about reading disks produced on the Davidge on a PC. Decades ago, I actually registered 22NICE and 22DISK from Sydex. I even created some custom disk definitions so I could read HD5.25" disks written with the SVA ZVX4 8-inch floppy controller in my Apple //e. I had all the formatting and DPB information from my disassembly of the FD-4000 BIOS, so it was no problem to whip up definitions for the Davidge (I've since learned that the Davidge uses the same 5.25-inch (3.5-inch) disk formats as CCS although mine are 80-track versions rather than 35- or 40-track.) Meanwhile, I came across something that purported to let me regenerate a complete relocatable CP/M with a custom BIOS attached. It was, however some file with an ".IMD" suffix. That led me down another path of learning about Dave Dunfield's IMageDisk utility. The file I had was the result of using IMageDisk (IMD.EXE) to analyze and capture the data from an SSSD 8-inch floppy disk. I don't have space to get out my 8-inch drives nor to hook them up to anything, but I did have the 1.44MB 3.5" drive in the Dell Optiplex GX-110 I was using. As long as I used a proper HD floppy that could handle the data rate, the fact that it spins at 300 RPM vs 360RPM shouldn't really matter. And it didn't. I wrote the image to the disk and was able to read it with 22DISK's "A1" disk definition for SSSD 8-inch disks. Sweet! It then occurred to me that this could be a way to archive the Davidge boot floppy so anyone who got the IMD file could re-generate bootable media for their DSB-4/6. I set everything up and packed as much information into the comment field of the IMD file as I could. The imaging operation went off without a hitch. But that was about the end of it. 22DISK couldn't read the 3.5-inch boot floppy and the Davidge couldn't boot from a disk written by IMD from the image file I'd just created (although the data area was intact). I left things at that for a while then I decided to see what was going on. I'd re-read the documentation in the Davidge manual about 'FDCOPY', that it does a track-by-track read of the source then a track-format and write of the destination. If the same drive were both source and destination, it would read-format-write over the disk, "freshening" it up. I tried this with the floppy written from the IMD image. The only failures were the last sector (18, SD) on each side of track 00. Whatever the boot sector encountered when it hit that sector (side 0 only for boot tracks), it doesn't even seem to have tried to start over because the floppy IN USE light has gone out. Then I turned to try and figure out why 22DISK can't read the Davidge disks and conversely why the Davidge can't read disks written by 22DISK. I used my disk definition for DD 256-byte sectors, 80 tracks to format a disk with the "CFMT.EXE" utility, then I imaged that disk with IMD. For some reason, when told to use the "LOW" data rate, 22DISK was choosing 300kbps rather than 250kbps. I even set the machine's BIOS to tell it the drive was a 360K 5.25-inch disk, it still used 300kpbs when reading or writing a DD 3.5-inch disk. Then I used IMD to write another disk from the "minimal system disk" image I'd made and told it to perform 250k->300k conversion. When the disk was finished, 22DISK could read it. Then I wrote the files I recovered from the 8-inch image to the disk formatted for Davidge at 300kbps, imaged it, and re-wrote it using 300k->250k conversion. Then the Davidge could read the disk. I wonder if my version of 22DISK is just old enough to not understand the 3 data rates needed. I checked a disk formatted for DOS 720K and IMD reported it as being written at 250kbps like it's supposed to be. 300kbps is perfect if I'm using a HD5.25 drive but there isn't one installed in this machine. While there is a drive bay available for one, I don't have space to get the machine out and install one. I need to build a break-out board that lets me assign any drive-select to any drive without having to fiddle with the drives themselves. If the 3.5-inch drive won't boot, maybe the 5.25-inch drive will, but I have to disassemble everything to change jumpers. And possibly also a companion board/cable at the drive so I can use the more recent drives that are fixed at DS1 only. I'd whip up a cable to let me put a 1.44MB drive on the 8-inch drive port, but even if I remember where all my connectors are, I can't get to them. More recently, while shuffling through the 5.25-inch disks I have for the Davidge (and re-formatting a bunch of random reclaimed disks), I ran across one I'd labelled as the "ZMP v1.5 Install Disk". Sure enough, it had the customized overlay source for the Davidge--but it wasn't the most recent. The sources I found all implement the 256-byte FIFO w/RTS/CTS flow control, but none of them used interrupt-driven receive and I most definitely have interrupt-driven receive--at least on SIO 1B and 2B, but not on SIO 2A. Davidge arranged for all ports to be wired as DCE when using a straight- through ribbon cable with an IDC 2x13 connector on one end and an IDC DB-25 connector on the other--except port 2A which is wired as DTE and is the designated modem port (it has the highest interrupt priority of all the serial ports). When I put the Davidge in the Leading Edge case, I wired ports 2A, 2B (also called SIOC and SIOD in PORTDEF.LIB) both as DTE with PC-style DE-9 connectors. Why I don't have interrupt-driven receive for that port I can't really remember but it must have to do with the fact that the IVL register and "status-affects vector" control bit only exist in channel B of the Z80 SIO. While the IVL register can be read back, WR1 (w/"status-affects- vector" bit) is write-only, I was hestiant to write to a register of a port I wasn't using. Since then, I've been doing a crude disassembly of the interrupt-capable executables so I can re-constitute the custom overlay sources and add interrupt-driven receive to the copy of ZMP that operates SIO 2A. ----- Date: Thu, 17 Jul 2025 21:14:03 -0500 (CDT) Subject: Re: Getting back on TRK00 On Sun, 13 Jul 2025, John D. Baker wrote: > Since then, I've been doing a crude disassembly > of the interrupt-capable executables so I can re-constitute the custom > overlay sources and add interrupt-driven receive to the copy of ZMP that > operates SIO 2A. And, thanks to recent work by Wayne Hortensius, I was able to read the actual source code for ZMP itself so I could learn how and, more impor- tantly, _when_ various functions were called. I was also concerned that there was an entry for the ISR in the ZMP overlay jump table--the main program shouldn't have any knowledge of that. grepping the sources showed that it was likely just a placeholder to aid debugging. After looking at the calling sequence of the overlay routines, I was confident to use the "invec:" and "deinvec:" entry points to initialise and de- initialise the interrupt vector for the SIO (overlay the space that would normally be used for CTC02 since it's the baud-rate generator for SIO1B (aka SIOB) and thus will never interrupt). I removed a couple of DI/EI pairs that were superfluous and that had a noticable improvement in performance. The only thing my overlays do that's out of the ordinary is that I hijack the initial jump at 0100h so I can steal 261 bytes for my FIFO, head and tail indices and a BDOS redirection jump before continuing with ZMP. Otherwise, ZMP will take all of TPA up to the start of BDOS for itself. Since I now knew the order in which the routines in my overlay would be called, I could eliminate a bunch of stuff. My "steal" routine originally went on to initialize the interrupt vector and set the UART default speed and operating mode (data/parity/stop). The interrupt- vector (de-)initialisation was moved to the areas ZMP already provided and none of the other stuff (other than stealing space) was needed. The only odd thing is that when you change port speeds the first time, you have to also explicitly set the mode, even if its the same, otherwise nothing will be received. Even more odd because it's just calling the same "init:" routine for both speed and mode changes. Otherwise, it works a treat. ZMP only supports up to 76800bps, the baud- rate generators can't do that. They can do 115200bps, so that's what I have the 76800bps entry set. 710bps is a strange speed, but it's one that ZMP supports. A time constant of 162 in counter mode generates that with only 0.16% error. After that, it was just a few EQUate changes to regenerate interrupt-driven-receive overlays for each of SIOB and SIOD (SIO1B, SIO2B) as well. Easing back into IDE-related stuff, I updated my chainloading floppy boot sector to check for the "CPM" signature string and do the same unit-bit flipping and head incrementing as the ROM code. I plan to see if I can get the floppy-disk HD boot sector to do the multi-sector reads that the new HD boot sector does. Then I need to tackle IDEGEN again so it can read/write from/to the secondary unit. Then I can start testing BIOS mods to migrate to the new partitioning strategy. It seems that the Davidge ROM loading the floppy-disk boot sector over itself at 0080h is a result of them mimicing CCS. The CCS FDC ROM loads the boot sector at 0080h. And, as I mentioned before, all of the floppy formats the Davidge supports are identical to those used by CCS. Since I have a CCS S-100 system, I should dig it out and play with it as well. Somewhere I have 5 bare GIDE boards that need building up (and see if any of the salvaged GALs I have can be reprogrammed). ----- [to be continued...]