--------------------------------- LDos V1(3) for AMOS1.3 and above. LDos is (C) Niklas Sjöberg 1992 --------------------------------- PART FIVE - Device Commands --------------------------- Ldevice Open - Open a device for use. Only one device may be open at the same time. S=Ldevice Open("name",UNIT,FLAGS) where name is the devicename, like "trackdisk.device". UNIT is the unit number, 0 for Dh0: and Df0:, 1 for Dh1: and Df1: etc. FLAGS may be set to zero, if you're a non "pro-devicer".. A is zero if successful, non zero if the device couldn't be opened. Ldevice Close - Close the device opened by Ldevice Open. Ldevice Close Ldevice - Send a command to the currently open device. A=Ldevice(COMMAND,BUFFER,LENGTH,OFFSET) where BUFFER is a pointer to where data is to be fetched or put. LENGTH is the number of bytes you wish to read or write. OFFSET is where you wish to read or write. A is the parameter returned from the device (IO_ACTUAL) and may mean different things for different devices/commands (see below). If a read or write operation took place A will contain the number of bytes actually read or written. COMMAND is one of the following (for standard devices, for specialdevices like trackdisk, serial etc. see documentation or C= includefiles): # Description - ------------ 0 Invalid. (Does it do anything?) 1 Reset. Act as newly re-started. 2 Read 3 Write 4 Update (write all buffers) 5 Clear all buffers. 6 Stop all i/o 7 Restart after stop. 8 Flush, abort all queue The trackdisk.device has some special commands : (Remember about trackdisk : ALL buffers must be in CHIP. ALL offsets and lengths must be a multiple of 512. Offsets are always given in bytes, fx. Root-block is 880*512) Command # & Description ----------------------- 2 Read, buffer MUST be in CHIP-mem! 3 Write, buffer MUST be in CHIP-mem! 4 Update, write the (internal) buffer to disk. (You can also force this by reading another track.) 5 Clear the (internal) buffer and thus force the device to read the next block from disk, even though it may have been in the buffer (used to make sure no other process have done anything to the disk via hardware-programming without updating the buffer or if the buffer was trashed). 9 Turn motor OFF (set LENGTH to 0) or ON (LENGTH=1) 10 Seek, move head to OFFSET, but doesn't perform any read to ensure it hit the right block. 11 Format tracks. LENGTH must be 22*512(*2) bytes. (You can use format instead of write if you wish to copy to an unformatted disk) 12 Remove interrupt. Only for pro's. Do not use. 13 Return the number of diskchanges. 14 Determine if a disk is inserted. (255 = No disk in drive) 15 Determine if a disk is writeprotected. (0 it not) 16 RawRead, only for pro's. Do not use. 17 RawWrite - " " - Do not use 18 Determine drivetype. (1 = 3.5", 2=5.25") 19 Determine number of tracks. 20 Change interrupt. Only for pro's. Do not use. 21 Remove change interrupt. Only for pro's. Do not use. 22 Determine last command. Those commands marked "Only for pro's" should NOT be used from Ldos because of many things, to complicated and off-topic to explain here! Extended devicecommands are not supported by Ldos (so please use LSerial.LIB and not Ldevice to perform serial I/O). Ldevice Error - Determine if any (and if so which) error occurred during the last operation. A=Ldevice Error where A can be IF trackdisk is used : ## Description -- ----------- 0 "Operation Successful." 20 "Unknown Error." 21 "No Sector Header Present." 22 "Invalid Sector Header." 23 "Invalid Sector ID." 24 "Incorrect Header Checksum." 25 "Incorrect Sector Checksum." 26 "Not Enough Sectors Available." 27 "Illegal Sector Header." 28 "Disk Is Writeprotected." 29 "Disk Was Changed." 30 "Track Not Found." 31 "Not Enough Memory." 32 "Illegal Sector Number." 33 "Illegal Drive Type." 34 "Drive In Use." 35 "Reset Phase!!" *- Lchk Data - Calculate the checksum of a data-block. *- CHK=Lchk Data(ADR) *- where *- ADR points to a buffer containing the datablock (512 bytes). *- CHK will contain the checksum itself. *- Lchk Boot - Calculate the checksum of the bootblocks. *- CHK=Lchk Boot(ADR) *- where *- See above. *- A word about checksums : *- As you already may have guessed the bootchecksum isn't *- calculated in the same way as the checksum of other blocks *- (Udir,Data,Root etc. etc.) so you must not use Lchk Data for the *- bootblock and Lchk Boot for datablocks. Also notice that the *- bootblock actually consists of TWO blocks (which always are *- reserved on the disk) and ADR should thus point to the TWO first *- blocks of the disk when calculating this checksum. The new *- filesystem (FFS) doesn't use checksums for datablocks anymore *- since FFS uses the full 512 bytes for data (SFS uses only 488). *- To alter the checksum on a SFS disk simply call Lchk xxxx to *- obtain the new (and valid) checksum, if it is the bootblocks, *- Loke this value into the second longword, if it is a datablock *- (or other, except bitmap) longword 6 should be changed. In other *- words, for boot : Loke ADR+4,CHKSUM and for other blocks : Loke *- ADR+20,CHKSUM. CONTINUED IN NEXT ARTICLE.