cdrom 1/3

ZXNet echo conference «hardware.zx»

From Boris Sokol To All 13 November 1999

Hello, All! (file: cd1.txt)───────────── IDE-CD Food for thought This document is in no way a complete description of the standard IDE-CD. Only the basic data necessary for general understanding of operating principles. Knowledge is assumed (at least in general outline) IDE interface (the standard went under the name ATA-R4C.*). For those who want to quickly get the source code for managing the CD-ROM, I can recommend the VIDE-CDD.SYS driver. It is the easiest to disassembly and contains fairly good code. In addition, The source code for the Linux driver CD contains a lot of useful information. information, although the focus on the “Unixoid” type of requests hinders using these texts for compilation under MS-DOS. Conventions and abbreviations used. When specifying specific addresses, it is assumed that the IDE-CD is master, controller address - 170h. If you use other addresses, instead of 17x you need to substitute 1Fx, 1E8+x or 168+x. Tick ​​= 18.2 hertz. All addresses and codes are hexadecimal. Word-length or double-word-length data to/from CDs comes in the format with the most significant first byte (unlike PC, where the first byte is the least significant).AP - Atapi package, 12 bytes transferred to CD-Rom. Contain the team and basic data for it. AK - Atapi team M - minutes in BCD format S - seconds in BCD format F - frame number in BCD format I. Determining the presence of a CD in the system To check the presence of an Atapi-CD device you must: 1. On the desired loop, select the required device (Master/Slave) in register 176. 2. Check readiness (bit 80 in register 177) 3. If it’s not ready, there is no device. Next, you can give a general reset command (output code 8 into register 177 and wait 1-3 ticks), or try to do without it. If The CD is in a state of waiting for the reset command; do not give necessarily. 4. Output the ECh command to port 177 and wait a couple of ticks. 5. Check port 174 (db = 14h) and port 175 (db = EBh). If all conditions are met, then we can assume that the IDE cable There is an Atapi device. To clarify the device type, you can use Atapi commands. II. Executing commands To perform AK you need: 1. Select the appropriate device (Master/Slave) 2. Wait until ready (at port 177) 3. Set the desired block size in registers 174 (ml.)and 175 (art. part) If the command does not return data, it can be and don't do it. 4. In 177 write the command A0h. 5. Wait for the data request (at 177). 6. In word transfer mode, write 6 AP words to port 170. 7. If the command does not require additional transmissions, then check completion status by error registers and that's it. Otherwise: 8. Wait for the interrupt. 9. Read from registers 174 and 175 the length of the issued (received) block. 10. If length =0 - end of operation, otherwise perform data exchange and go to step 8 11. Analyze completion status. When transmitting, data is transferred word by word through port 170. III. Types of commands By type, teams can be divided into three groups: a) Management Typically, all data is in the AP. Sometimes an additional transmitted block of data is used. In response, the CD does not transmit any information, but the result can be determined from the error registers IDE interface (171 and 177) or using additional command to get the state. b) Data transfer Address data and transmission parameters are located in the APSince CD burners are not considered (I am not aware of them), then the data block transferred to the CD is missing. If the command involves transferring data from the CD and no errors, the CD drive issues a block (blocks) in response to the command data. c) Obtaining information All request data is in the AP. In response to the command CD issues a block of data. IV. IDE commands The CD has several auxiliary commands that are executed the same as the commands of a regular IDE hard drive. Here are the basic commands: A0h - AP transfer command. A1h - Drive identification. Similar to the ECh command for an IDE hard drive, but output block format is different ECh - Treated as an error, but in registers 174 and 175 is installed signature 14 EB - sign of Atapi device 08h - Reset. Performs the initialization procedure. Also, some save management commands can be executed energy, setting capabilities, etc. In many drives they are perceived as correct commands, but are not actually executed or are partially executed. V. Commands in ATAPI packages The first byte in the AP is the command code. This is the only byte thatalways analyzed. The remaining 11 bytes contain information depending from a specific team. Team 00h is a dummy Package: db 0 db 11*dup(0) ; * Doesn't do anything, can be used to check disk change Here and below: data marked with “*”, as a rule, is not analyzed by CD, but must be set to 0 for compatibility Command 01h - Set to the beginning of the disk Package: db 01h db 12*dup(0) ; * Control command (practically not used). Command 03h - read drive status Package: db 03h db 3*dup(0) ; * db Len ; output block length db 7*dup(0) ; * The output is a table of 12h bytes, in which the most interesting are bytes 2, 0С and 0D are the error code of the last operation. Command 012h - read the driver manufacturer parameter line Package: db 12h db 0h,0h ; sometimes some parameters are set here db 0h ; * db Len ; output string length db 7*dup(0) ; * The drive produces a certain manufacturer string (in manufacturer format) Depends on the CD-Rom type. Sometimes used in drivers for checking driver and device matching. Command 01Bh - tray management and more Package: db 1Bh db 3*dup(0) ; *db Func ; subfunction db 7*dup(0) ; * Management team. Subfunctions: 0 - enter Sleep mode 1 - stop playing/reading 2 - pull out tray 3 - close tray Command 01Eh - tray lock Package: db 1Eh db 3*dup(?) ; * db Func ; subfunction db 7*dup(?) ; * Management team. Low bit Func= 0 - unlock tray = 1 - block tray Command 025h - get disk size in sectors. Package: db 25h db 11*dup(0) ; * Information team. The user receives a block of 8 bytes in response: ddSectors ; number of sectors on the current disk dd SectSize ; sector size (as a rule, does not depend ; from the disk and is equal to 930h) Team 02Bh - Seek Package: db 2Bh db 2*dup(0) ; * db M,S,F ; where to position yourself db 6*dup(0) ; * Management team. Command 042h - mixed information (read subchannel) Package: db 42h db ScMsf ; 0/2 - type of address issuance (MSF or sector number) dbFullInfo; request option (full/short - 4 db Func ; subfunction db 3*dup(0); *db LenHi ; High part of table length db LenLo ; Junior-------//---------- db 3*dup(0); * (file: cd1.txt)───────────── Boris.