How does sectors, track are identified on disk and CD/DVD?

790 views Asked by At

I was writing some assembly BIOS code and in general we use interrupt to access disk functionality. We give commands like seek to this sector read bytes etc etc. but how does disk knows whether it is first sector and similarly how does cd/dvd identify sectors as cd/dvd are inserted in cd drive from random position. Is there any kind of identification number associated with sectors in those hardwares?

1

There are 1 answers

0
Peter Cordes On BEST ANSWER

Optical discs have one continuous spiral outward, and yes there's some intro area for the drive to find out the disc angle for the start of the first sector. A quick google didn't find specific details on how exactly it does this, but presumably some formatting / metadata outside the usable / user data.

Boundaries between sectors are marked by a synchronization code that's not used anywhere else (https://en.wikipedia.org/wiki/Track_(optical_disc)#Sector_structure). That description of Red Book audio sectors also applies to data CDs: a CD-ROM uses the same underlying framing as Red Book audio CDs, but with data inside that. (And another layer of error correction, giving 2048 error-corrected bytes of data per sector of 2352 bytes of first-level-error-corrected sector data.)

Tracks in an optical-disc sense are totally different from hard-drive / floppy "tracks". (Because there's only one spiral, not multiple rings of data). CD tracks are an arbitrary number of sectors, and track boundaries on audio CDs are normally placed at song boundaries.


Note that Cylinders / Heads aren't meaningful for optical discs. According to this answer, only the BIOS LBA read function works, (AH=42h), not the legacy CHS function (AH=02h). So the BIOS doesn't need to invent a fake CHS geometry to give access to the purely linear sectors.

Related: