cem@intelca.UUCP (Chuck McManis) (05/01/84)
This has probably been asked before however, I am writing a BIOS for CP/M. I have 2 DSDD drives that will read technically 4 formats : SS/SD - Definitly need this one. SS/DD - Would be nice (cheap disks) DS/SD - Sort of redundant DS/DD - Main Format. Now, I want to use all of the above formats on each physical drive as well as logical drive. The questions are : a.) How do I switch formats ? Do I overwrite the Parameter Block or do I somehow change pointers to it. b.) When is a change of formats allowed and when is it an error ? For instance, when I read a disk, I first try the last format used, if that fails I try double density, if that works I read it in. On warmboot this is obviously not an error since one has no idea what format disk has been put in the drive, but if you have previously read a disk with one format and now it is another (like dir b: many times while swapping in disks to find the right one.) how do you know when it is an error ? Does anyone have a source for information, or an example BIOS, where such a thing is implemented? I would just like to see how it is done. Note: I have a book written by Andy Johnson-Laird called The Programmers CP/M Handbook. This book is an *excellent* text and a must for anyone considering playing around with a BIOS or CP/M internals. It is published by Osborne-McGraw-Hill and I got a copy at Crown books here in No. Calif. Thanks for any help you can offer, --Chuck
simard@loral.UUCP (05/10/84)
A note of caution re my last discussion: if SELDSK checks for disk type (?S/?D), it should do so only when there is a real chance the disk has been changed. Many programs rapidly bounce from one logical disk to another (I have been known to assemble long source files from one disk for source, another for object and still another for listing). The number of unneccessary type checks in this case would be staggering.
simard@loral.UUCP (Ray Simard) (05/10/84)
The disk parameter block (DPB) whose address is returned ih the HL pair when SELDSK is called contains a pointer to the disk parameter header which defines the characteristics of the current drive which are to apply to all further calls to SECTRAN, SETSEC (indirectly), READ and WRITE, until SELDSK is called again. As long as the DPH/DPB data agree with the disk currently accessed, CP/M will be happy. The only error indications that the BIOS returns to the BDOS (main body of CPM) is success (A=0) or failure (A<>0) from READ or WRITE, or that SELDSK was asked to select an invalid logical drive (HL returned = 0). If you can determine what kind of disk is installed in a physical drive dynamically, the check should be placed in SELDSK. The pointer in the DPB to the appropriate DPH would then be set by SELDSK to reflect the outcome of the check as well as set up the driver for the disk controller as appropriate. If that is not possible, then you might want to implement multiple logical drives for each physical drive (for example, if your system has two physical drives, A: and B: could be SS/SD, C: and D: could be the same drives, but SS/DD, etc.). The operator would select the drive according to the type of disk installed. Note: I am referring to DPB's and DPH's from memory. I may have them reversed. What I refer to as DPB is the 16-byte block unique to each logical drive, containing pointers to the applicable DPH, sector translation table, allocation and check vectors, and whose address is returned by SELDSK. The DPH in the above is the data set defining the size, reserved tracks, block size, etc., and which may be shared by numerous logical drives. Ray Simard Loral Instrumentation, San Diego, CA.