C-Net Week #23
31 июля 2002

Iron - CDROM into your home: Documentation ATAPI (IDE) CD-ROM

<b>Iron</b> - CDROM into your home: Documentation ATAPI (IDE) CD-ROM
CDROM into your home ...

Once I connected to the
its spec PC-claves,
PC-mouse, and HDD, I was
interesting, but whether
connected to a spectrum CDROM? In
Basically it is possible of course:)
Connector that after all IDE-standard.
But the problem is that
Controller at me from the master
Nemo: (and as soon as I
pull up the train to his
samsung x24 it so soon and
ofigel: (stops responding
generally to any buttons ... That
Well there he drove controller
by Nemo, I do not understand
: (But here's something kind of Old
management CDROM'om in general and in
particular, I found on the Internet.
Perhaps it will seem to someone
interesting.

ATAPI (IDE) CD information for
meditation Constantine
Norvatov (C) 1997

This document in no way
is not a complete description
Standard ATAPI-CD. Here
were collected only basic
data necessary for the general
understanding of the principles
functioning.
Assumed knowledge (at least
in general) IDE-interface
(Standard went under the name
ATA-R4C .*).

For those wishing to quickly get
source control
CD-ROM can recommend
Driver VIDE-CDD.SYS. It is easier
all amenable
disassembling and contains
pretty good code. Except
addition, the source code
Driver CD for Linux
contains much useful
information, although orientation
"Yuniksoidny" type queries
prevents the use of these
texts to compile a
MS-DOS.

Agreement and used
reduction.

When referring to specific
Address is understood that
CD is a master address
Controller - 170h. If you have
used other addresses
instead of 17x to
substitute 1Fx, 1E8 + x or
168 + x.

Tic = 18.2 Hz.

Data length in word or
dword to / from CD go to
format co higher than the first
byte (in contrast to the PC, where
the first byte - the younger).

AP - Atapi packet, 12 bytes
transferred to the CD-Rom.
Contain the command and key
data for it.

WARNING: there may be
c device package length
16 bytes. However, the vast
Most drivers do not
analyze and do not support
this format. To determine
packet size used
ATA-team A1h.

AK-Atapi team
M - minutes
S - second
F - frame number (1 / 75 sec)

Frequently used bits
Status Register (177h):
BSY - Bit 80h
DRQ - Bit 08h
CHK - Bit 01h

I. Determination of the CD
system

To verify the presence of
Atapi-CD unit
should:

1. To select the right loop
the desired device
(Master / Slave) in register
176h.
2. Check the BSY
3. If the device is not busy.

Then you can give the command
total discharge (output code 8 in
register 177h and wait for 3.1
tick), or try to
do without it. If the CD
is in
normal expectations of the team
discharge does not necessarily give.

3. In the ports 174h and 175h
write something that differs
from 14EBh.
4. In the port 177h to bring the team
ECh and wait a couple of ticks.
5. Check port 174h (DB =
14h) and port 175h (gb = EBh).
It should be borne in mind that
registers should be
error is set (177h -
51h, 171h - 04h). This
normal.

If all conditions are met, the
we can assume that
IDE-loop is present Atapi
device. To clarify the type of
devices can be
use already
Atapi-teams.

This algorithm can
only apply
When certain that
CD had not acted
commands. Otherwise, the bit
BSY can be installed.
If necessary, check
status register can be
mitigated by only checking
the presence of the ATA device
recorded in the registers.

II. Executing commands

To perform the necessary AK
(Work without interruption):
1. Select the appropriate
device (Master / Slave) in
Port 176h
2. Wait ready (BSY and
DRQ = 0). Drivers waiting to
10-20 seconds. If readiness
No - you can try
reset the drive.
3. Set the desired
block size in the registers 174h
(Jr.) and 175h (Art. part) If
command does not return data
it can not do. For
DMA-shnyh exchanges at this moment
need to install other
registers.
4. In 177h write command
A0h. In response to this device
can set BSY to time
Preparing for AP.
5. Wait for data requirements
(DRQ = 1, BSY = 0). (Usually a wait
no need - the drive exhibits
requirement immediately). In this case,
register 172h two least significant bits
must have a value of 01.
6. In the forward if
write to port 170h 6 words
AP.
7. Wait ready
(BSY = 0). (Depending on
command type and other
circumstances, the drive can
execute a command in a time of
thousandths of a second before
tens of seconds (If,
for example, difficult to read
sector of the disk).
8. Check the DRQ bit and if he
installed, then read from
registers 174h and 175h length
Telegram.
9. If length = 0 or bit DRQh
in the 177h is not set - n. 11,
another to exchange data
port 170h. In this case two
least significant bits of register 172h
may take the value of 00
(When transferring data to a CD) or
02 (when receiving data from the CD).
10.If a team has not finished
return (bits BSY = 1),
repeat with n 7.
11.Posle command completion
two least significant bits of register 172
usually take the value 03,
that means a willingness drive
to the issuance of exit status
team. It is possible
analyze results
command finishes (registers
177h and 171h). When errors
You can use the
ATAPI-function 03h to
more detailed
information.

III. Types of teams

On modes of exchange team
can be divided into three groups:

a) Office

As a rule, all data
are in AP. In some
commands used
additionally sent
data block. The result can be
determined by the error register
(171h and 177h) or by
additional team
receiving state.

b) Data

Address data and parameters
transfer are in AP
Since the CD writers are not
considered (to me they do not
known), then the data block,
transferred to the CD,
absent. If a team
involves the transmission of
data from the CD and no errors, CD
Drive shows in response to
command unit (s) of data.

c) Obtaining information

All data requests are
in AP. In response to the command CD
gives a block of data.

IV. ATA commands

I have several CD
support teams
are executed in the same way
As usual the team
IDE-HDD. At the same time
destination registers equal
with nazacheniem on ATA.

Here are the basic commands:

A0h - Team transmission AP.

A1h - Identification of the drive.
Analogue of the team for ECh
IDE-HDD, but the format
output block the other (described
in Appendix C).

ECh - perceived as
error, but in the registers 174h and
175h set signature
14EBh - sign Atapi
device.

08h - Programming reset.
Performs the boot
initialization.

Also, can be performed
Some commands
energy conservation, installation
opportunities, etc. In many
drives they are perceived
as a valid command, but
not actually performed or
partially fulfilled.

V. Teams in the ATAPI-packages

The first byte in the AP is
command code. This
single byte, which
always analyzed.
The remaining 11 bytes contain
information depending on
specific command.

-----------------------------
Command 00h - Dummy,
checks readiness

Package:

        db 0

        11 db * dup (0) *

Does nothing, can
used to test changes
Disk

NOTES:

1) First Team after the change
disc will be rejected with code
error "Media Change".
2) Here and further: data
marked with "*" as a rule,
not analyzed the CD, but for
compatibility should be
set to 0.

----------------------------- Command 01h - Set
head on the top of the disc

Package:

        db 01h

        12 db * dup (0) *

Management Team
(Hardly used).

----------------------------- Command 03h - read status
drive

Package:

        db 03h

        db 3 * dup (0) *

        db Len; length

               output block

        db 7 * dup (0) *

At the output table of 12h bytes
in which the most interesting
are the bytes 2, 0C and 0D -
is three bytes of the error code
the last operation.

----------------------------- Team 012h - read a string
parameters of the manufacturer of drive

Package:

        db 12h

        db 0h, 0h; sometimes

   Here we establish some

                     parameters

        db 0h; *

        db Len; length

               output string

        db 7 * dup (0) *

Drive shows some row
manufacturer (in the format
manufacturer) Depends on the type of
CD-Rom. Sometimes used in
drivers to test
appropriate drivers and
device.

The structure of output block:
0 db 1Fh - device type (CD

            = 5) E0h - for the CD =
1 db 7Fh - = 0 (for Joint. With
 SCSI-1) 80h - supported

              removable media
2 db 0 - Version ISO, ECMA, and

                         ANSI.
3 db 0 - for compatibility with

                        SCSI-2
4 db? - The length of the remaining

                         block
5 db 2 dup (?) - Reserve
7 db 0 - for compatibility with

                        SCSI-2
8 db 8 dup (?) - Line

      manufacturer (there is

                      'ATAPI')
10h db 10h dup (?) - Name

                     Product
20h db 4 dup (?) - Audit

Text boxes form a single
strings separated by spaces.

----------------------------- Team 01Bh - Management
Trey and stuff

Package:

  db 1Bh

  db 3 * dup (0) *

  db Func; subfunction

  db 7 * dup (0) *

Management team.

Subfunctions:
0-enter Sleep mode
1-stop proigryv. / reading
2 to push the tray
3-close tray

----------------------------- Team 01Eh - lock tray

Package:

  db 1Eh

  db 3 * dup (?); *

  db Func; subfunction

  db 7 * dup (?); *

Management team.

Low bit Func
0 - unlock tray
= 1 - block tray

----------------------------- Team 025h - get the size of
disc inserted in the sectors.

Package:

  db 25h

  11 db * dup (0) *

Team information.

User response
transferred to a block of 8 bytes:


  dd Sectors; number

     sectors on the current drive

  dd SectSize; size

       sector (as a rule, not
depends on the disc and is equal to 930h)

----------------------------- Team 02Bh - Seek

Package:

  db 2Bh

  db 2 * dup (0) *

  db M, S, F; to

             positioned

  db 6 * dup (0) *

Management team.

-----------------------------
Team 042h - Mixed
information (read subchannel)

Package:

  db 42h

  db ScMsf; 0/2-tip

  addresses the issue (number of sectors

                      or MSF)

  db FullInfo; version

      query (full / short -

                      bits 40h)

  db Func; subfunction

  (Only for full search)

  db 3 * dup (0) *

  dw Length; length of the table

  db 3 * dup (0) *

Command information, issues
unit the following information:

00h dw state of play

                        Audio:

00h - unknown or not

                supported
11h - Playing Audio
12h - Audio stands
13h - Audio stopped on

                         end
14h - open a door or a mistake

                       run
15h - Miscellaneous

02h dw length of follow-up

               Data (0 - no)

04h and then present at the
40h in the presence of bits and FullInfo
depend on Func

Func is not equal to 2 or 3

04h db 01h (data format

                subchannel = 1)
05h db Ctrl / Addr
06h db TrackNumber
07h db Point or Index
08h db 0
09h db 3 * dup (?) -MSF/SECTOR On

                         CD
0Ch db 0
0Dh db 3 * dup (?) -MSF/SECTOR On

                       track

Subfunction 2
(Get a UPC code)

04h db 02h (data format

                subchannel = 2)
05h db 3h * dup (?)
08h db 80h-check the availability of UPC
(If not, then the UPC is missing)
09h db 0Ch * dup (?) - Here
stored UPC code (6 digits in the BCD

                         code)
15h db 3 * dup (?) - Situation
something on the disk in a format MSF

Subfunction 3
(Get the ISRC code)

04h db 03h (data format

                subchannel = 2)
05h db Ctrl / Addr
06h db TrackNumber-not always

                 used.
07h db?
08h db 80h-box presence

      (Similar function 02h)
09h db on record ISRC

-----------------------------
Team 043h - about

           tracks (READ TOC)

Package:

  db 43h

  db ScMsf; 0 / 2 type of issue
Address (number of sectors or MSF)

  db 4 * dup (0) *

  db BegTrk; initial

    track (1, 0 is replaced

                         1)

  dw Length; length of the table

  db Func; options issue

        information (0/40h/80h)

  db 2 * dup (0) *

Command information, issues
table tracks. Maximum
length table 8 * 64h +4 bytes or
64h (100.) Lanes.

Func
= 00h; get a regular table
tracks
= 40h; get a table sessions
= 80h; get a regular table
in a larger format

The general format of the table:


  dw Len; length

    subsequent fields in bytes

  db BegTrk; first track

  db EndTrk; last

                       track

  d? <track_Def>; description

                       tracks

Description of track
MB three formats:

1) 5 bytes per track
(Internal format, outside of
CD is not given):

 db Ctrl / Addr; type of track and

                         Flags
 db Index; index tracks

                       (Number)
 db * 3 Start; starting address

                       Track

2) 8 bytes per track
(Func = 0h/40h):


  db?

  db Ctrl / Addr; type of track

                       and flags

  db TrackNumber; room

                       Track

  db?

  db * 4 Start; starting address

                       Track

3) 11 bytes per track (Func =
80h):


  db Res1

  db Ctrl / Addr; type of track

  db Res2

  db Index; index tracks

  db Res3

  db Res4

  db Res5

  db * 4 Start; starting address

                       Track

Ctrl / Addr - the type of track (that is,
that in MSCDEX, but
rearranged tetrads):

Ctrl (younger tetrad
individual bits):

01 - a pre-emphasis
02 - allowed to copy
04 - Track Data
08 - 4 channel (instead of 2)

Addr (older tetrad and codes):

0-no subchannel
1-encoded in the subchannels
position
2-in subchannels coded UPC
3-encoded in the subchannels ISRC
Others - reserved

The most common codes:

14h - ROM
10h - audio

Index - encoded in BCD and
normal track is
range 01-99. Codes A0 and
above have a special
value, they are not matched against a
physical tracks on the disc,
and the nature of the business are -
informed about the number of lanes,
beginning of the disk drive and the end
etc.

Start - depending on the
query can be either
sector number or address
sector in the format of MSF.

----------------------------- Team 044h - about
actual labels of
(Read HEADER)

Package:

 db 44h
 db SL; bit 2 - that

   write to the output buffer

   (The original number of sectors or

                    believe)
 db 0; *
 db M, S, F; Number sector
 db 0; *
 dw Len; length issued

                     informa
 db 3 * dup (0) *

Command information, issues
the following table of 8 bytes:

 db SectorType; type of format

           sector (data mode)
 db 4 * dup (0)
 db M, S, F; sector address

The package is only granted
if the CD could be considered
given sector and to identify
its type.

-----------------------------
Team 045h - play
audio in terms of blocks (length
- A word)

Package:

 db 45h
 db 0; *
 dd StartBlock; block start

     play (-1 - a tech.

                   Provisions)
 db?
 dw Length; number of blocks
 db 3 * dup (); *

Management team.

-----------------------------
Team 047h - play
audio style MSF

Package:

 db 47h
 db 2 * dup (?); *
 db M, S, F; top

   interval (FF: FF: FF - current

                      position)
 db M, S, F; end of the segment
 db 3 * dup (?); *

Management team.

-----------------------------
Team 04Bh - Start / stop
audio

Package:

 db 4Bh
 db 7 * dup (0) *
 db Func
 db 3 * dup (0) *

Management team.

Low bit Func
= 0 - stop
= 1 - start

-----------------------------
Team 04Eh - stop
playback

Package:

 db 4eh
 11 db * dup (?); *

Management team.

-----------------------------
Team 055h - install
parameters

Package:

 db 55h
 db? , 1-bit store

                   in the NVRAM (?)
 db Page; required

           page options
 db 4 dup (?)
 dw Length; length of the table
 db 3 * dup (0) *

Team management, codes and
page format is described in
command 5Ah.

-----------------------------
Team 05Ah - get
parameters

Package:

 db 5Ah
 db?
 db Page-defines the required

    parameters, consists of two

                bit fields:

3Fh - page number you want
parameters:
01h - Correction Options
Error
0Dh - general parameters
0Eh - Audio Control
2Ah - device parameters
(Read only)
3Fh - All pages

C0 - bits of the type required
Pages:
00 - current value
01 - changed values
10 - default
11 - stored value

 db 4 dup (?)
 dw Length; length of the table
 db 3 * dup (0) *

Command information, issues
the corresponding page
parameters.

General heading:

00h dw length of the entire unit

           (Without the first word)
02h db Drive status
03h db 5 dup (?);

Header of each page:

08h db Number of pages

                       query
The page length 09h db

Page 01-fix errors

0Ah db parameter correction

                        Error
0Bh db meter repeats reading

Page 0D - general parameters

0Ah db?
0Bh db multiplier timer does not

                    aktivnosti
0Ch dw number of S units per M

  one format MSF (60)
0Eh dw F number of units in S

  one format MSF (75)

Page 0E - audio options

0Ah db? option does not fix. but

                    changes
0Bh db 2 dup (?)
0Dh db? LBA = 0 is always equal to

   sector number, Senior bits

        indicates the correctness

               the next field
0Eh dw 0 Number of logical

          blocks per second for
 playing. (Usually not

                 used)
10h db ml. tetrad - bits

      output port of channel 0
11h db volume of channel 0
12h db ml. tetrad - bits

      output port of channel 1
13h db volume of channel 1
14h db ml. tetrad - bits

      output port of channel 2
15h db volume of channel 2
16h db ml. tetrad - bits

      Output Port Channel 3
17h db volume channel 3

Page 2Ah - options
device (read only);
bits of the presence / absence
Functions

0Ch db 01h-play audio

       02h-composite audio /

                   video stream

       04h-Digital out to

                        port 1

       08h-Digital out to

                        port 2

       10h-read sectors

                 Mode 2 Form 1

       20h-read sectors

                 Mode 2 Form 2

       40h-Reading

        Multi Disc

       80h -?

0Dh db 01h - Reading RedBook

         through the command Read-CD

       02h - Reading RedBook

        "With accurate stream"

       04h - Reading subchannel

       08h - Support

        deinterlivinga data

                    subchannel

       10h - Support

           "C2 error pointers"

       20h - Support for reading

                          ISRC

       40h - Support for reading

                           UPC

       80h -?

0Eh db 01h-lock carrier

       02h-read status

                    lock

       04h-Disk prevent jumper

                       present

       08h-team release

                      Media

       10h-?

       E0h-Loader Type:

            0 - Caddy

            1 - Tray

            2 - Pop-Up

            3 - Reserved

            4 - changer with

       individually replaceable

                       Disk

            5 - Cartridge

            6 - Reserved

            7 - Reserved

0Fh db 01h-Split

           Control channels

       02h-Split

             channel switcher

       04h-Info

                 a disc

       08h
       10h
       20h
       40h
       80h
10h dw Maximum speed

           sharing, in kilobytes
13h db Number of gradations

         Volume
14h dw buffer size in

                    kilobytes
16h dw current rate of exchange

- Can sometimes be absent
18h db?
19h db 01h - Digital out on

     Front / recession signal BCKF

       02h - LRCK indicates

            Left / right channel

       04h - data format

                       LSB / MSB

       08h

       10h BCKs: 0 - 32

       20h | 1 - 16

       40h / 2 - 24

                  3 - 24 (I ^ 2S)

       80h -?

The length of each of the pages may
be different. Here we describe
only those fields that
more or less standard. If
requested all pages
(Code 3Fh), then the output unit
will be one
common header and
consistently placed
pages with their
headings.

-----------------------------
Team 0A5h - play
audio in terms of blocks

Package:


  db A5h

  db 0; *

  dd StartBlock; block start

    play | -1 c current

                     position

  dd Length; number of blocks

  db 2 * dup (?); *

Management team.

-----------------------------
Team 0B9h - read data

Package:

 db B9h;
 db Fmt; can be = 00h

          fit any format

        ; 08h ordinary CD-ROM

                (Yellow Book)

        ; 10h species

        ; 14h / Green XA
 db 0; *
 db M, S, F; start reading
 db M, S, F; the end of reading
 db Flg; flags readable

                pieces of the sector:


         ; 01h three

         ; 02h unused

         ; 04h bit (?)

         ; 08h EDC / Zero / ECC

         ; 10h main body

                sector (data)

         ; 20h descriptor

         sector addresses (head)

         ; 40h data

               subchannel (sub)

         ; 80h initial

            sinhrobayty (sync)

         ; Transmitted only
those parts of the sectors for which

         ; Set bits.

    Transmitted part of the Sector

        should go straight, without

                     Pass
 db 0; always gb = 0

              otherwise error (?)
 db 0; *

The command transfer data. If
start = end, is
positioning to the specified
position and test readability.
In this case, the data is not
transmitted.

-----------------------------
Team 0BEh - read data
terms of sectors

Package:

 db BEh;
 db Fmt;
 dd Sec; start reading

         (Spanish only 24-bit
 db 0; *
 dw ScNum; number of sectors
 db Flg; flags readable

     pieces of the sector (as in B9h)
 db 0; always gb = 0, otherwise

                    error (?)
 db 0; *

The team is completely analogous
team B9, except
assignment addresses the Reading
in terms of sectors.

==============================

Note b42 (b-reeze) In
annex to cweek, you can
find examples of writing instruction
in C for the PC, as well as a number of
documents, which were both
annex to the present. (Not
included in the number itself because
of formatting
text)

==============================

P.S. Initially, this document
was composed exclusively for the
internal use by
reason can not be found
The standard corporate
for ATAPI-CD. Since the entire
Information was taken from
disassembled
driver source
Linux, otdizassemblirovannoy
Firmware ACER665, a well of
description of SCSI-packages and
standard ATAPI, it is quite
, certain
discrepancies with the standard (in
whose existence I did not
sure). Despite this, I
it seems that even this
description is
a certain value.

In this description was not hit
team special reading
data (028h/0A8h) - I
there are no clear data on its work,
as well as several others,
are not used in
drivers and are not supported
all actuators. This applies
teams potrekovaya
playing Audio-CD, teams
in multi-disc CD changer
drives, etc. I
remained something else which
information, such as text
CD-drivers, firmware, etc.
which were considered
irrelevant or unduly
cumbersome. If necessary,
can be inserted into the document
excerpts from the driver.

For fans of "detailed
descriptions "can recommend
Standard SCSI-2 (X3T9.2). There
there are a large number of
interesting information, but
substantial amount (more than 20 thousand
lines, or about 1.7 Mb),
some differences from the SCSI
ATAPI and "littered"
unnecessary details complicate
obtaining the necessary information.

If you need more
detailed examination of
exchange process (exchange of
DMA, overlapping command and
etc.) can read standard
for ATAPI devices (X3T10).
However, the description of the specific CD
command is not there (there are
reference to the SCSI).

Suggestions, comments and curses
etc. Please send
at 2:5030 / 163.44
Constantine Norvatov
(Konstantin Norvatoff, KonNor)
Also, you can try to find
me at:
konnor@small.spb.su

==============================

Note2: b42 (b-reeze)
By the time of writing this
article, I still managed to
CDROM connected to the controller
NEMO together with the HDD. And the HDD,
as the master disk, and CDROM as
slave. Just would like to
clarification about the teams in
examples of packages for
Management CDROM. Record Type
db 3 * dup (0) means that the code
# 00 should be repeated 3 times.

I hope this article will help
deal with management
CDROM and soon we
obtain valuable work with
CD on the ZX.




Other articles:

Nastalgiya - memories of the creation of C-Net Week.

News - A new version of EWS, was SHIT 2001, came a few paragraph numbers, the new newspaper KAP KAR Bird "and" ZaRulem Printed Word ", the newspaper KrNews # 15 and Insanity # 10, new sound map DMA USC, ZX-Spectrum slowly dies, the idea of modular game about Dizzy.

Party - the story of a new generation Belursuskogo demopati Twillight 2001; rules, the team competitions.

Iron - CDROM into your home: Documentation ATAPI (IDE) CD-ROM

Games - cheats in the game HAMON IV: return to home from deathmanland.

ZXNet - SMONT shares its experience in working in C-NET (Belarussian part of the ZX Net).

Epilogue - There will be beer - will cweek!


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
drop of solder - The decision PROBLEMS 1.2MB drive.
A Tangled Web - Schedule KVAZAR BBS.

В этот день...   21 November