From: Volker R. <vru...@us...> - 2002-07-30 06:25:59
|
Update of /cvsroot/bochs/bochs/iodev In directory usw-pr-cvs1:/tmp/cvs-serv19854 Modified Files: cdrom.cc Log Message: - implementation of the function READ TOC for cdrom image files Index: cdrom.cc =================================================================== RCS file: /cvsroot/bochs/bochs/iodev/cdrom.cc,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- cdrom.cc 29 Jul 2002 16:42:01 -0000 1.35 +++ cdrom.cc 30 Jul 2002 06:25:57 -0000 1.36 @@ -410,8 +410,59 @@ } if (using_file) { - BX_ERROR (("WARNING: read_toc on a file is not implemented, just returning length=1")); - *length = 1; + if ((start_track != 1) && (start_track != 0xaa)) + return false; + + buf[2] = 1; + buf[3] = 1; + + int len = 4; + if (start_track == 1) { + buf[len++] = 0; // Reserved + buf[len++] = 0x14; // ADR, control + buf[len++] = 1; // Track number + buf[len++] = 0; // Reserved + + // Start address + if (msf) { + buf[len++] = 0; // reserved + buf[len++] = 0; // minute + buf[len++] = 2; // second + buf[len++] = 0; // frame + } else { + buf[len++] = 0; + buf[len++] = 0; + buf[len++] = 0; + buf[len++] = 0; // logical sector 0 + } + } + + // Lead out track + buf[len++] = 0; // Reserved + buf[len++] = 0x16; // ADR, control + buf[len++] = 0xaa; // Track number + buf[len++] = 0; // Reserved + + uint32 blocks = capacity(); + + // Start address + if (msf) { + buf[len++] = 0; // reserved + buf[len++] = (uint8)(((blocks + 150) / 75) / 60); // minute + buf[len++] = (uint8)(((blocks + 150) / 75) % 60); // second + buf[len++] = (uint8)((blocks + 150) % 75); // frame; + } else { + buf[len++] = (blocks >> 24) & 0xff; + buf[len++] = (blocks >> 16) & 0xff; + buf[len++] = (blocks >> 8) & 0xff; + buf[len++] = (blocks >> 0) & 0xff; + } + + buf[0] = ((len-2) >> 8) & 0xff; + buf[1] = (len-2) & 0xff; + + *length = len; + return true; } // all these implementations below are the platform-dependent code required |