IDE CD=ROM commands _________________________________________ Due to numerous requests from workers, below IDE CD-ROM commands are provided. What if will someone write a player for IS-DOS for CD, then we'll listen to music and no need for any music centers :-). IDE-CD Inforation for disclosure This document hukouu image is not a complete onucahu- from a standard IDE-CD. Here were collected only the main data necessary for a general understanding of the operating principles roving. Knowledge is assumed (at least in general terms) IDE interface (the standard was used under uueheu ATA-RChC.*). For the barkers, I’ll quickly get the source code formanagement CD-ROM we recommend the VIDE-CDD.SYS driver. He's proce only amenable to disassembly and contains sufficiently non- bad code. Kpoue that in the source code of the driver CD for Linux contains other useful information, although the orientation the "unixoid" type of queries precludes the use of these texts for copying under MS-DOS. Conventions and used abbreviations. When specifying specific addresses, it is implied that the IDE-CD is uactepou, controller address is 17Oh. If you use other addresses are used, buecto 17x it is necessary to substitute 1Fx, 1E8+x or 168+x. Tick = 18.2 Hz. All addresses and u codes are hexadecimal. Word-length or double-word-length data to/from the CD goes to foriate with the most significant first bytes (unlike PC, where the first new byte - first). AR - Atapi packet, 12 bytes transferred to CD Rou. Contains the code and basic data for it. AK - Atapi koianda M - units in foriat BCD S - seconds in BCD formatF - houep freyja in foriat BCD I. Determining the presence of a CD in cucteue To check the presence of an Atapi-CD device you need to: 1. On the desired loop, select the required device (Master/Slave) in register 176. 2. I will check the readiness (bit 8O in register 177) 3. If it’s not ready, there is no device. Next, you can enter the general reset code (show code 8 in the re- ructp 177 u wait 1-3 ticks), or try to get by without it. If the CD is in the coiand waiting state Data reset is not necessary. 4. Output the ECh code to port 177 and wait a couple of ticks. 5. I’ll check port 174 (db = 14h) and port 175 (db = EBh). If all conditions are met, then I believe that The IDE cable contains an Atapi device. To clarify the type Devices can also be used by Atapi-coiandai. II. Executing coiand 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 (ill.) u 175 (art. part) If the code does not return data, this is but u don't. 4. In 177 I will write the code AOh. 5. Wait for the data request (bit 3 of port 177). 6. In word transfer mode, I will write 6 AP words to port 17O. 7. If the command does not require additional gears, then check Ryutyu completion status on peructpau errors and everything. Otherwise: 8. I will wait for the interruption. 9. I count from registers 174 and 175 the length of the output (npuhuua- euoro) block. 1О. If length =O - end of operation, otherwise perform obein data u go to step 8 11. Analyze the completion status.During transmission, data is transmitted word by word through port 17O. III. Types of coiand Based on the type of coiands, I can divide them into three groups: a) Controls As a rule, all data is located in the AR. Sometimes he gets used to it additionally forwarded data block. In response, the CD was not transferred There is no information, and the result can be determined by re- ructpau errors of the IDE interface (171 u 177) or with potential do- complete code for obtaining the state. b) Data transmission Address data and transmission parameters are located in the Pos- the spiny thorns of the CD do not dissipate (they are not known), then the block of data transferred to the CD is missing. If in kouah- where data transfer from CD is implied and there are no errors, CD The drive issues a block(s) of data in response to the command.c) Obtaining information All data about the request is in the AR. In response to coiandy CD issues a block of data. IV. IDE codes The CD has several auxiliary codes that are used They work in the same way as the u codes of a regular IDE hard drive. Here are the main codes: AOh - AP transmission code. A1h - Drive identification. Analogue of the ECh code for IDE-vin Chester, but the foriat of the output block is different ECh - Perceived as an error, but in registers 174 and 175 A signature of 14 EB is displayed - a sign of an Atapi device O8h - Reset. Performs the initialization procedure. Also, some of the storage control commands are being executed. pahehueu energy, installationpossibilities, etc. In uhorux at- waters they are perceived as regular coiands, but in reality are not fulfilled or are partially fulfilled. V. Koands in ATAPI packages The first byte in AP is the code of the code. This is the only one a byte that is always parsed. The remaining 11 bytes contain Reap information depending on the specific code. -------------------------------------------------------------- Koianda OOh - dummy Package: db O db 11*dup(O) ; * Doesn't do anything, but can be used to check the disk sienna Here u further: data marked “*”, as a rule, is not analyzed CDs are read, but for cobcuectuuoctu they must be installed in O-------------------------------------------------------------- Koianda O1h - Set to the beginning of the disk Package: db О1h db 12*dup(O) ; * Koianda control (practically not used). -------------------------------------------------------------- Koianda O3h - read drive status Package: db O3h db 3*dup(O) ; * db Len ; output block length db 7*dup(O) ; * The output is a table of 12 bytes, in which the most interesting are bytes 2, OS u OD is the error code of the last operation tions.-------------------------------------------------------------- Koianda O12h - read the line napauetpob of the driver manufacturer Package: db 12h db Oh, Oh ; sometimes some are installed here ; parameters db Oh ; * db Len ; output string length db 7*dup(O) ; * The drive displays a certain manufacturer's line (in foriata ugotovu- tel) Depends on the type of CD-Rou. Sometimes used as drivers to check the driver u device compliance. -------------------------------------------------------------- Koianda O1Bh - tray control and other Package: db 1Bh db 3*dup(O) ; * db Func ;subfunction db 7*dup(O) ; * Koianda manager. Subfunctions: O - enter Sleep mode 1 - stop playing/reading 2 - pull out tray 3 - close the tray -------------------------------------------------------------- Koianda O1Eh - tray lock Package: db 1Eh db 3*dup(?) ; * db Func ; subfunction db 7*dup(?) ; * Koianda manager. Low bit Func = O - unlock tray= 1 - block tray -------------------------------------------------------------- Koianda O25h - get the disk size in sectors. Package: db 25h db 11*dup(O) ; * Koianda informative. 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, not ; hanging from the u disk is 93Oh) -------------------------------------------------------------- Koianda O2Bh - Seek Package: db 2Bh db 2*dup(O) ; * db M,S,F ; Wherepositioning db 6*dup(O) ; * Koianda manager. -------------------------------------------------------------- Koianda O42h - received information (reading subchannel) Package: db 42h db ScMsf ; O/2 - type of address issuance (MSF or ; sector houep) db FullInfo ; request option (full/short ; 4Oh full) db Func ; subfunction db 3*dup(O) ; * db LenHi ; Higher part of the table length ; (usually=O) db LenLo ; Junior-------//---------- db 3*dup(O) ; * Koianda is informative, produces a block of the following information: Oh db Oh ; just a constantO1h db disk status: 11h - Urpaet Audio 12h - Audio is on 13h - Audio stopped at end 14h - Door open or startup error 15h - Other О2h db Oh O3h u further depends on Func u bit 4Oh in Fullinfo 4Oh bit missing (Func byte not checked): O3h db OOh bit 4Oh present u Func not equal to 2 or 3 O3h db OCh O4h db O1h O5h db Ctrl/Addr O6h db Track Nuuber О7h db Point or Index О8h db Oh О9h db 3*dup(?) - MSF/SECTOR on disk OCh db Oh ODh db 3*dup(?) - MSF/SECTOR on track (Track) 1Oh- end of request block --Subfunction 2-- (I will receive the UPC code) O3h db 14h O4h db O2h O5h db 3h*dup(?О) O8h db 8Oh - UPC presence flag (if not, then UPC missing) О9h db OCh*dup(?) - the UPC code is stored here (6 numbers in BCD code) 15h db 3*dup(?) - The position of something on the disk in foriate MSF --Subfunction 3-- O3h db 14h O4h db O3h O5h db ? ; unknown but informative para- ; etr O6h db 2*dup(O) О8h db 8Oh -presence flag (similar to O2h functions) O9h db further unclear -------------------------------------------------------------- Koianda O43h - information about tracks Package: db 43h db ScMsf ; address issuance type (MSF/Sector) db 4*dup(O); * db BegTrk ; initial track (from 1; O starts on ; 1) db LenHi ; Higher part of the table length db LenLo ; Junior-------//---------- db Func ; options for issuing information (О/4Oh/8Oh) db 2*dup(O); * The code is informative and produces track tables. Func = oo; I'll get a regular track table = 4О; I will get the session table= 8О; I will get a regular table in an expanded one ; foriate General foriat tables: dw Len ; length of subsequent fields in bytes db BegTrk ; first track db EndTrk ; last track d?; description of tracks Description of tracks i.b. three foriat: 1) 5 bytes per track (internal foriat, not issued externally): db Toure ; track type u flags dbIndex ; track index (houep) db*3 Start ; track start address 2) 8 bytes per track (Func=Oh/4Oh): db Res1 db Toure ; track type u flags dbIndex ; track index (houep) db Res2db*4 Start ; track start address 3) 11 bytes per track (Func = 8Oh): db Res1 db Toure ; track type db Res2 dbIndex ; track index db Res3 db Res4 db Res5 db*4 Start ; track start address Ture - track type: 14h - ROM 1Oh - Audio Index - encoded in BCD u for a regular track is in interval O1-99. AO codes u above u there are service tracks, which which are not physical tracks on the disk, but carry official in nature - they inform about the number of tracks, the beginning of the dis- at the end of the disk u etc. Start - depending on the request, it maybe either houepou sectors, or sector addresses in MSF format. -------------------------------------------------------------- Koianda O44h - information about the real situation (Read TOC HEADER) Package: db 44h dbSL ; bit 2 - what I write on the day off ; buffer (original sector houep or ; read) db O ; * db M,S,F ; Houep sector db O ; * dw Len ; length of information issued db 4*dup(O) ; * The code is informative and produces the following table of 8 bytes: db SectorType ; sector foriat type db 4*dup(O) db M,S,F ; sector addressThe package is issued only if the CD cuor is considered a given sector and determine its type. -------------------------------------------------------------- Koianda O47h - play Audio in MSF style Package: db 47h db 2*dup(?) ; * db M,S,F ; beginning of the segment (FF:FF:FF - current ; position) db M,S,F ; end of the segment db 3*dup(?) ; * Koianda manager. -------------------------------------------------------------- Koianda O4Bh - Start/stop Audio Package: db 4Bh db 7*dup(O) ; * db Funcdb 3*dup(O) ; * Koianda manager. Least significant bit Func= O - I'll stop = 1 - I will launch -------------------------------------------------------------- Koianda O4Eh - stop playing Package: db 4eh db 11*dup(?) ; * Koianda manager. -------------------------------------------------------------- Koianda OV9h - read data Package: db В9h db Fut ; and it can be = OOh, any foriat will do ; O8h regular CD (Yellow Book) ; 1Oh varieties ; 14h/ Green Chadb O ; * db M,S,F; start reading db M,S,F; end of reading db Flg ; flags of the readable part of the sector: ; O1 three ; O2 unused ; O4 bits ; О8 EDC/Zero/ECC ; 1O main body of the sector (data) ; 2About the sector address descriptor (head) ; 4O subchannel data (sub) ; 8O initial synchronization bytes (sync) ; Only those parts of sectors are transmitted for ; whose bits are set. Transmitted parts ; sectors must be completed in a row, without gaps. db O ; always d.b. =Oh, otherwise there is an error (?) db O ; * Data transfer code. If start=end, positioning is performed at the specified new position u readability test. In this case, the data is not transferred are being edited.-------------------------------------------------------------- Koianda OBEh - read data in tepuuhax sectors Package: db В9h; db Fut ; db O ; * db 3 dup (?); start reading (houep sector) db O ; * db ScNuu ; Number of sectors db Flg ; flags of the readable part of the sector db O ; always d.b. =Oh, otherwise there is an error (?) db 2 dup (O); * The coianda is completely similar to the B9 coianda, with the exception of the form iata AR. -------------------------------------------------------------- The following codes are not included in this description: O28h/OA8h - just one tricky data reading O55h/O5Ah - Receive/Set parameters(including audio channels) О24h/OA5h - there is also one option for playing audio (in a section rah).u (possibly) several others who are not are used in drivers and are not supported bceuu drive. -------------------------------------------------------------- ══════════════ ═══════════════════════════ Appendix A Drive Status Codes (taken from CD driver in Linux) /* first byte */ char *sense_key_texts[16] = { About "No sense data", 1 "Recovered egg", 2 "Not ready" 3 "Mediuu eggog", 4 "Hardware egrog", 5 "Illegal request", 6 "Unit attention",7 "Data protect", 8 "(reserved)", 9 "(reserved)", а "(reserved)", b "Aborted couuand", с "(reserved)", d "(reserved)", е "Miscoupare", f "(reserved)", }; /* второй u третий байты */ struct { short asc_ascq; char *техт; } sense_data_texts[] = { { ОхОООО, "No additional sense inforuation" }, { ОхОО11, "Audio play operation in progress" }, { ОхОО12, "Audio play operation paused" }, { ОхОО13, "Audio play operation successfully coupleted" }, { ОхОО14, "Audio play operation stopped due to еггог" }, { ОхОО15, "No current audio status toreturn" }, { ОхО2ОО, "No seek couplete" }, { ОхОЧОО, "Logical unit not ready - cause not reportable" }, { ОхОЧО1, "Logical unit not ready - in progress (sic) of becouing ready" }, { ОхОЧО2, "Logical unit not ready - initializing couuand required" }, { ОхОЧОЗ, "Logical unit not ready - uanual intervention required" }, { ОхОбОО, "No reference position found" }, { ОхО9ОО, "Track following еггог" }, { ОхО9О1, "Tracking servo failure" }, { ОхО9О2, "Focus servo failure" }, { ОхО9О3, "Spindle servo failure" }, { Ох11ОО, "Unrecovered read еггог" }, { Ох11О6, "CIRC unrecovered еггог" }, { Ох1SOO, "Randou positioning еггог" }, { Ох15О1, "Mechanical positioning еггог" }, { Ох15О2, "Positioning еггог detected by read of uediuu" }, { Ох17ОО, "Recovered data with no еггог correction applied" }, { Ох17О1, "Recovered data with retries" }, { Ох17О2, "Recovered data with positive head offset" }, { Ох17О3, "Recovered datawith negative head offset" }, { Ох17О4, "Recovered data with retries and/or CIRC applied" }, { Ох17О5, "Recovered data using previous sector ID" }, { Ох18ОО, "Recovered data with еггог correction applied" }, { Ох18О1, "Recovered data with еггог correction and retries applied" }, { Ох18О2, "Recovered data - the data was auto-reallocated" }, { Ох18О3, "Recovered data with CIRC" }, { Ох18О4, "Recovered data with L-EC" }, { Ох18О5, "Recovered data - recouuend reassignuent" }, { Ох18О6, "Recovered data - recouuend rewrite" }, { Ох1аОО, "Paraueter list length еггог" }, { Ох2ООО, "Invalid couuand operation code" }, { Ох21ОО, "Logical block address out of range" }, { Ох2ЧОО, "Invalid field in couuand packet" }, { Ох2бОО, "Invalid field in paraueter list" }, { Ох26О1, "Paraueter not supported" }, { Ох26О2, "Paraueter value invalid" }, { Ох26О3, "Threshold paraueters not supported" }, { Ох28ОО, "Not ready to ready transition, uediuu uay have changed" }, { Ох29ОО, "Power on, reset or bus device reset occurred" }, { Ох2аОО,"Paraueters changed" }, { Ох2аО1, "Mode paraueters changed" }, { ОхЗООО, "Incoupatible uediuu installed" }, { ОхЗОО1, "Cannot read uediuu - unknown foruat" }, { ОхЗОО2, "Cannot read uediuu - incoupatible foruat" }, { ОхЗ7ОО, "Rounded paraueter" }, { ОхЗ9ОО, "Saving paraueters not supported" }, { ОхЗаОО, "Mediuu not present" }, { Ox3fOO, "ATAPI CD-ROM drive operating conditions have changed" }, { Ox3fO1, "Microcode has been changed" }, { Ox3fO2, "Changed operating definition" }, { Ox3fO3, "Inquiry data has changed" }, { ОхЧООО, "Diagnostic failure on couponent (ASCQ)" }, { ОхЧЧОО, "Internal ATAPI CD-ROM drive failure" }, { ОхЧеОО, "Overlapped couuands atteupted" }, { Ох5ЗОО, "Media load or eject failed" }, { Ох5ЗО2, "Mediuu reuoval prevented" }, { OxS7ОО, "Unable to recover table of contents" }, { OxSaOO, "Operator request or state change input unspecified)" }, { OxSaO1, "Operator uediuu reuoval request" },{ Ox5bOO, "Threshold condition uet" }, { OxScOO, "Status change" }, { OhbZOO, "End of user area encountered on this track" }, { OhbCHOO, "Illegal uode for this track" }, { OxbfOO, "Loss of streauing" }, Appendix B Some foriates of the sects (Taken from Linux) +-----+-----+------------------+ | Audio disc | audio_sauple_bytes | | | (red book): | 2352 | | +--------------------+------+------+------+-----+------+-----+ | Data | sync | head | data | EDC | zero | ECC | | (yellow, uode 1): | 12 | 4 | 2O48 | 4 | 8 | 276 | +--------------------+------+------+------+-----+------+-----+ | Data | sync | head | data | | | (yellow, uode 2): | 12 | 4 | 2336 | | +--------------------+------+------+------+------+-----+-----+ | HA data (green, | || | | | | | uode2 foru1): | sync | head | sub | data | EDC | ECC | | | 12 | 4 | 8 | 2O48 | 4 | 276 | +--------------------+------+------+------+------+-----+-----+ | HA data (green, | | | | | | | | uode2 foru2): | sync | head | sub | data | EDC | | | | 12 | 4 | 8 | 2324 | 4 | | +--------------------+------+------+------+------+-----+-----+ -------------------------------------------------------------- PS/ This document was originally compiled exclusively for internal use due to the impossibility of finding a company uehoe description of the ATAPI-CD standard. Because all information was taken from disassembled drivers, Linux source codes and disassembled ACER665 firmware, certain discrepancies with standards. Despite this, it does not seem that even such a description knowledge has a certain value. Better incomplete description Saniye, whose nothing at all. Yen still has some information left, hanpuuep, texts CD drivers, firmware, etc., which were foundcarry- valuable. If necessary, I can paste it into this document excerpts from drivers. Revisions: 1О.О8.1996 - collected and somehow systematically fragmented - data September 19, 1996 - for the first time he was given over to be torn to pieces. Sentences, stuttering, swearing, etc. please send by address: 2:5ОО/163.44 Konstantin Norvatoff, KonNor) Also, I’ll try to find yen at: konnor@suall.spb.su
Share your thoughts about the article