cdrom TOC

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
h0bby1
Member
Member
Posts: 240
Joined: Wed Aug 21, 2013 7:08 am

cdrom TOC

Post by h0bby1 »

i'm finally implementing ata/atapi drivers from this http://www.ata-atapi.com/atadrvr.html

It seem to work , i'm trying to read the toc of the cdrom, it seem to work and the values seem to be valid, but i don't know what they mean.

I have read some docs, i couldn't find that much information on google, there are information about the structure of the toc, and how value should be interpreted but not how to use them.

Apparently, there are first 3 toc entry with a point field = '0xA1,0xA2,0xA3', they don't seem to correspond to track information

Then there is a toc entry with a point value of '1', it's track number entry seem to be valid, it's a 3 byte value in big endian with value 0x0x200, but i don't know what it mean

The value seem to be what is expected from it from the doc i have, but it doesn't seem to be a sector number, as the iso doesn't have 512 sectors, it cannot be a byte ofset because there is no data on the cdrom before sector 64 ( 128k ofset) , so i don't understand how i'm supposed to use this value

I didn't find any good documentation that say how multi session or mixed cd should be handled, and how to exactly interpret the toc to get the informations about the different tracks and session of a cdrom
h0bby1
Member
Member
Posts: 240
Joined: Wed Aug 21, 2013 7:08 am

Re: cdrom TOC

Post by h0bby1 »

ok i got it now.

The 3 bytes values is not a 24 bit integer, but a 3 bytes MSF address ! MSF = minute second fraction, in binary decimal encoding, and is used as the format to specify cd rom addresses, even for data mode !

6.2 block addressing (MSF, LSN, LBA)

A track is broken up into a number of 2352-byte blocks which we sometimes call sectors or frames. Whereas tracks may have a gap between them, a block or sector does not. (In libcdio the block size constant is defined using CDIO_CD_FRAMESIZE_RAW).

A Compact Disc has a limit on the number of blocks or sectors. This values is defined by constant CDIO_CD_MAX_LSN in `cdio/sector.h'.

One can addressing a block in one of three formats. The oldest format is by it's minute/second/frame number, also referred to as MSF and written in time-like format MM:SS:FF (e.g. 30:01:40). It is best suited in audio (Red Book) applications. In libcdio, the type msf_t can be used to declare variables to hold such values. Minute, second and frame values are one byte and stored BCD notation.(4) There are libcdio conversion routines cdio_from_bcd8() and cdio_to_bcd8() to convert the minute, second, and frame values into or out of integers. If you want to print a field in a BCD-encoded MSF, one can use the format specifier %x (not %d) and things will come out right.
https://www.kernel.org/doc/Documentatio ... /cdrom.txt

#define CD_SECS 60 /* seconds per minute */
#define CD_FRAMES 75 /* frames per second */
#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */

lba = (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET;

so the MSF 00:02:00 would give

m=0;
s=2;
f=0;

(0*60+2)*75+00-150 => 0 !

which is normal as it's a single track cdrom that start at 0 !
Post Reply