home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft_Programmers_Library.7z / MPL / intel / cdrom.txt < prev    next >
Encoding:
Text File  |  2013-11-08  |  131.8 KB  |  2,763 lines

  1.  Microsoft MS-DOS CD-ROM Extensions 2.1
  2.  
  3.  Product Overview Version 2.10 Beta
  4.  
  5.  The Microsoft MS-DOS CD-ROM Extensions are an extension to the MS-DOS
  6.  operating system which permit reading CD-ROM disks which conform to both the
  7.  High Sierra May 28th format and the ISO-9660 version of the High Sierra
  8.  format. The CD-ROM disc appears just like a magnetic disk to the user and to
  9.  applications software, ensuring compatibility with current software.
  10.  Microsoft, as creator of the MS-DOS operating system, is able to ensure
  11.  compatibility with MS-DOS.
  12.  
  13.  
  14.  Product Components
  15.  
  16.  The complete product consists of a program supplied by Microsoft and of a
  17.  hardware-dependent device driver supplied by an OEM customer. The program
  18.  supplied by Microsoft is named MSCDEX.EXE. Technical documentation as well
  19.  as a sample driver are also supplied by Microsoft.
  20.  
  21.  
  22.  Technical Overview
  23.  
  24.  Characteristics
  25.  
  26.    ■ Requires MS-DOS 3.1 or higher or 4.0 (or PC-DOS 3.1 or higher or 4.0)
  27.    ■ Implements the High Sierra May 28th format and ISO-9660
  28.    ■ Requires a hardware-dependent device driver
  29.  
  30.  This product uses the Microsoft Networks interface to MS-DOS so it requires
  31.  MS-DOS version 3.1 or higher or 4.0.  MS-DOS 3.1 virtualizes the interface
  32.  to drives. The entire CD-ROM (potentially all 660 megabytes) will appear to
  33.  applications as a single MS-DOS drive letter. The extensions overcome the 32
  34.  megabyte disk size limitation in MS-DOS. The Microsoft MS-DOS CD-ROM
  35.  Extensions provide a high degree of compatibility with applications that
  36.  depend on MS-DOS standard interfaces. Applications can access files on the
  37.  CD-ROM just as they would on any disk.
  38.  
  39.  The program MSCDEX.EXE is an installable file system driver implemented as a
  40.  terminate and stay resident module. The user will load this program upon
  41.  booting the computer using AUTOEXEC.BAT. The hardware-dependent device
  42.  driver implements basic functions to read the CD-ROM disc and is loaded with
  43.  the MS-DOS CONFIG.SYS file.
  44.  
  45.  The Microsoft MS-DOS CD-ROM Extensions implement both the May 28th High
  46.  Sierra file format and the ISO-9660 version of that standard. All features
  47.  defined in May 28th proposal for Level 1 are implemented. In addition the
  48.  following are implemented:
  49.  
  50.  Features Beyond High Sierra Level 1
  51.  
  52.    ■  Support for Interleaved Files
  53.    ■  Support for 31 Character File Names when possible through truncation
  54.    ■  Support for Hidden Files
  55.    ■  Support for Access to VTOC
  56.    ■  Ignores Higher Level Files and Functions when present on the disk:
  57.       -  Associated Files
  58.       -  Protection Bits
  59.       -  Record Bits
  60.       -  File Version Numbers
  61.  
  62.    ■ Support for shift-JIS Kanji (Japanese character) filenames
  63.  
  64.  
  65.  Hardware-Dependent Device Driver
  66.  
  67.  This product requires a hardware-dependent device driver that interfaces to
  68.  a specific OEM drive or drives. A detailed specification for the device
  69.  driver as well as a sample driver are included. The driver implements the
  70.  basic functions of reading the CD-ROM and is installed using the DOS
  71.  CONFIG.SYS conventions. A minimum set of functions that allow reading the
  72.  CD-ROM disc are required to be in the device driver; there are optional
  73.  additional functions which provide increased performance when the CD-ROM
  74.  drive and controller can provide additional functions and these are
  75.  implemented in the driver. These functions are detailed in the Microsoft MS-
  76.  DOS CD-ROM Extensions Hardware-Dependent Device Driver Specification.
  77.  
  78.  The device driver is written by the OEM customer for the MS-DOS CD-ROM
  79.  Extensions. Development of the device driver is estimated to take
  80.  approximately 1-3 man-months. This estimate assumes an engineer experienced
  81.  in 8086 assembler programming and familiar with MS-DOS and the CD-ROM drive
  82.  hardware. If a previous device driver has already been written, less time
  83.  will probably be needed to implement the driver for the Microsoft MS-DOS CD-
  84.  ROM extensions. There are third party companies who will write the hardware-
  85.  dependent device drivers on a consulting basis.
  86.  
  87.  
  88.  Licensing the Microsoft MS-DOS CD-ROM Extensions
  89.  
  90.  Microsoft will license the MS-DOS CD-ROM Extensions to manufacturers and
  91.  marketers of CD-ROM disc drives. The license agreement will allow the use of
  92.  the product on a personal computer to which a licensed disc drive is
  93.  attached. Developers of CD-ROM disks will not need to acquire any license or
  94.  pay any royalty in order to develop or sell CD-ROM discs, and will not be
  95.  entitled to distribute the MS-DOS CD-ROM Extensions. The end user will
  96.  purchase the driver from drive manufacturer or marketer, not the CD-ROM disc
  97.  developer.
  98.  
  99.  The Microsoft MS-DOS CD-ROM Extensions will be delivered to licensees on a
  100.  5 1/4" MS-DOS diskette. Licensees are expected to distribute the Extensions
  101.  to their customers on a floppy diskette containing both MSCDEX.EXE and the
  102.  hardware-dependent device driver written by the licensee. The floppy would
  103.  be included in the package containing the CD-ROM drive.
  104.  
  105.  
  106.  Creating CD-ROM Disks in the High Sierra Format
  107.  
  108.  The Microsoft MS-DOS CD-ROM Extensions provides for reading CD-ROM discs in
  109.  the High Sierra/ISO-9660 format on MS-DOS computers. They do not create CD-
  110.  ROM disks in the High Sierra/ISO-9660 format. Microsoft does not manufacture
  111.  CD-ROM discs, nor provide pre-mastering services. Third party companies can
  112.  create CD-ROM discs in the High Sierra/ISO-9660 format and provide other
  113.  pre-mastering services. Microsoft can supply a list of companies providing
  114.  or planning to provide these services upon request.
  115.  
  116.  Software developers do not need the MS-DOS CD-ROM Extensions in order to
  117.  create either applications software which reads CD-ROM discs, or to create
  118.  CD-ROM discs. Once the software is ready and a disc has been pressed,
  119.  developers will want a copy of the Extensions for testing; however, they are
  120.  not needed in order to start development.
  121.  
  122.  Software developers need do nothing special for accessing CD-ROM discs; they
  123.  issue the same MS-DOS OPEN and READ calls as for opening any magnetic disks.
  124.  Programmers can develop CD-ROM applications using standard MS-DOS tools.
  125.  They need to be aware that they cannot create any temporary files or write
  126.  any files in either the directory or on the entire CD-ROM disc. Software
  127.  developers will want to minimize the number of seeks to the CD-ROM because
  128.  of the comparatively long seek times of CD-ROM drives.
  129.  
  130.  ████████████████████████████████████████████████████████████████████████████
  131.  
  132.  Hardware-Dependent Device Driver Specification
  133.  
  134.  Intent
  135.  
  136.  This document (Document Number: 000080010-100-O00-1186) describes the CD-ROM
  137.  hardware-dependent device driver and its interface with MSCDEX.EXE, the MS-
  138.  DOS CD-ROM Extensions resident program. Differences between CD-ROM drives
  139.  and hard- or floppy-disk drives account for the differences in this device
  140.  driver specification from the normal MS-DOS block and character device
  141.  driver specification. The chapters on device drivers in the MS-DOS
  142.  Programmer's Reference Manual (MS-PRM) provide more information.
  143.  
  144.  The MS-DOS operating system reads CONFIG.SYS and installs the device.
  145.  MSCDEX.EXE performs an open system call on the device driver name in order
  146.  to communicate with it and uses an IOCTL call to ask the device driver for
  147.  the address of its device header. From the device header address, MSCDEX.EXE
  148.  locates the device driver's interrupt and strategy routines. After that, all
  149.  requests the device driver receives come directly from MSCDEX.EXE, not MS-
  150.  DOS. To avoid reentrancy problems and allow MSCDEX to monitor all media
  151.  changes, all other applications that wish to communicate directly with CD-
  152.  ROM device drivers should do so through the Send Device Driver Request INT
  153.  2Fh function 10h. MSCDEX.EXE interfaces with MS-DOS so that normal requests
  154.  for I/O with files on a CD-ROM drive down to the MS-DOS INT 21h service
  155.  layer will work just as they would for a normal MS-DOS device.
  156.  
  157.  
  158.  Installation
  159.  
  160.  The device driver will be installed in the same way as any other device with
  161.  an entry in CONFIG.SYS. The syntax is:
  162.  
  163.    DEVICE=<filename> /D:<device_name> /N:<number of drives>
  164.  
  165.  The following are examples:
  166.  
  167.    DEVICE=HITACHI.SYS /D:MSCD001 /D:MSCD002
  168.    DEVICE=SONY.SYS    /D:MSCD003 /N:2
  169.  
  170.  The arguments will be the character device names that will be used on the
  171.  command line when starting MSCDEX.EXE so that it can find and communicate
  172.  with the device driver.
  173.  
  174.  A device driver may support one or more physical drives or logical disks.
  175.  This may be done by having multiple device headers in the device driver file
  176.  (in which case it will be necessary to have more than one device_name on the
  177.  command line - one for each device header; see the HITACHI.SYS example
  178.  above) or through the use of subunits. Each disk handled by a device driver
  179.  that supports multiple disks using subunits is addressed by the subunit
  180.  field of the request header when a request is made for that disk. A device
  181.  driver that supports more than one disk can share code and data instead of
  182.  requiring separate device drivers for each disk. A "jukebox" CD-ROM system
  183.  would be an example of a CD-ROM device that might wish to support more than
  184.  one drive or a disk pack using a single device driver.
  185.  
  186.  Device drivers that use multiple subunits should use the optional switch
  187.  /n:<number of drives> to say how many drives are present. If not present,
  188.  the default number of drives is 1. If the driver can tell how many drives
  189.  are installed without a command line switch, then this argument is not
  190.  necessary. Unless there are special considerations, it is better practice to
  191.  support multiple drives using subunits than to have multiple device headers
  192.  in the same device driver file.
  193.  
  194.  
  195.  Device Header
  196.  
  197.  The device header is an extension to what is described in the MS-PRM.
  198.  
  199.  DevHdr    DD   -1        ; Ptr to next driver in file or -1 if last driver
  200.            DW   ?         ; Device attributes
  201.            DW   ?         ; Device strategy entry point
  202.            DW   ?         ; Device interrupt entry point
  203.            DB   8 dup (?) ; Character device name field
  204.            DW   0         ; Reserved
  205.            DB   0         ; Drive letter
  206.            DB   ?         ; Number of units
  207.  
  208.  The following are the device attributes for MSCDEX.EXE device drivers:
  209.  
  210.    Bit 15         1       - Character device
  211.    Bit 14         1       - IOCTL supported
  212.    Bit 13         0       - Output 'till  busy
  213.    Bit 12         0       - Reserved
  214.    Bit 11         1       - OPEN/CLOSE/RM supported
  215.    Bit 10-4       0       - Reserved
  216.    Bit  3         0       - Dev is CLOCK
  217.    Bit  2         0       - Dev is NUL
  218.    Bit  1         0       - Dev is STO
  219.    Bit  0         0       - Dev is STI
  220.  
  221.  MSCDEX.EXE device drivers will be character devices that understand IOCTL
  222.  calls and handle OPEN/CLOSE/RM calls.
  223.  
  224.  The drive letter field is a read-only field for the device driver and is
  225.  initialized to 0. The field is for MSCDEX.EXE to use when it assigns the
  226.  device driver to a drive letter (A = 1, B = 2...Z = 26). It should never be
  227.  modified by the device driver. For drivers that support more than one unit,
  228.  the drive letter will indicate the first unit, and each successive unit is
  229.  assigned the next higher drive letter. For example, if the device driver has
  230.  four units defined (0-3), it requires four drive letters. The position of
  231.  the driver in the list of all drivers determines which units correspond to
  232.  which drive letters. If driver ALPHA is the first driver in the device list,
  233.  and it defines 4 units (0-3), they will be A, B, C, and D. If BETA is the
  234.  second driver and defines three units (0-2), they will be E, F, and G, and
  235.  so on. The theoretical limit to the number of drive letters is 63, but it
  236.  should be noted that the device installation code will not allow the
  237.  installation of a device if it would result in a drive letter > 'Z' (5Ah).
  238.  All block device drivers present in the standard resident BIOS will be
  239.  placed ahead of installable device drivers in the list.
  240.  
  241.  ───────────────────────────────────────────────────────────────────────────
  242.  NOTE:
  243.    It is important that one set lastdrive=<letter> in CONFIG.SYS
  244.    to accommodate the additional drive letters that CD-ROM device drivers
  245.    will require.
  246.  ───────────────────────────────────────────────────────────────────────────
  247.  
  248.  The number-of-units field is set by the device driver to the number of disks
  249.  that are supported. Normal character devices do not support more than one
  250.  unit and MS-DOS does not expect a character device to handle more than one
  251.  unit or have a nonzero subunit value in the request header. Since these
  252.  device drivers are not called by MS-DOS directly, this is not a problem.
  253.  Nonetheless, the number of units returned by the device driver in the
  254.  number-of-units field during the INIT call must be 0, since MS-DOS makes the
  255.  INIT call and does not expect a nonzero value for a character device.
  256.  MSCDEX.EXE will never see what is returned anyway, and relies on the number-
  257.  of-units field in the device header.
  258.  
  259.  Sample device header:
  260.  
  261.  HsgDrv    DD   -1             ; Pointer to next device
  262.            DW   0c800h         ; Device attributes
  263.            DW   STRATEGY       ; Pointer to device strategy routine
  264.            DW   DEVINT         ; Pointer to device interrupt routine
  265.            DB   'HSG-CD1 '     ; 8-byte character device name field
  266.            DW   0              ; Reserved (must be zero)
  267.            DB   0              ; Drive letter (must be zero)
  268.            DB   1              ; Number of units supported (one or more)
  269.  
  270.  As with other MS-DOS device drivers, the code originates at offset 0, not
  271.  100H. The first device header will be at offset 0 of the code segment. The
  272.  pointer to the next driver is a double word field (offset/segment) that is
  273.  the address of the next device driver in the list, or -1 if the device
  274.  header is the only one or the last in the list. The strategy and interrupt
  275.  entry points are word fields and must be offsets into the same segment as
  276.  the device header. The device driver is expected to overwrite the name(s) in
  277.  each of its one or more device headers with the <device_name> command line
  278.  arguments during its initialization.
  279.  
  280.  MSCDEX.EXE will call the device driver in the following manner:
  281.  
  282.    1.  MSCDEX.EXE makes a far call to the strategy entry.
  283.  
  284.    2.  MSCDEX.EXE passes device driver information in a request header to the
  285.        strategy routine.
  286.  
  287.    3.  MSCDEX.EXE makes a far call to the interrupt entry.
  288.  
  289.  
  290.  Request header
  291.  
  292.  MSCDEX.EXE will call the device's strategy routine with the address of a
  293.  request header in ES:BX. The format of the request header is the same as
  294.  what is described in the MS-PRM.
  295.  
  296.  ReqHdr    DB   ?         ; Length in bytes of request header
  297.            DB   ?         ; Subunit code for minor devices
  298.            DB   ?         ; Command code field
  299.            DW   ?         ; Status
  300.            DB   8 dup (?) ; Reserved
  301.  
  302.  Status
  303.  
  304.  The status word also has the same format as described in the MS-PRM. It is 0
  305.  on entry and is set by the device driver.
  306.  
  307.    Bit 15         - Error bit
  308.    Bit 14-10      - Reserved
  309.    Bit  9         - Busy
  310.    Bit  8         - Done
  311.    Bit  7-0       - Error code (bit 15 on)
  312.  
  313.  Bit 15, the error bit, is set by the device driver if an error is detected
  314.  or if an invalid request is made to the driver. The low 8 bits indicate the
  315.  error code.
  316.  
  317.  Bit 9, the busy bit, should be set by the device driver when the drive is in
  318.  audio play mode. Device drivers should fail all requests to the physical
  319.  device that require head movement when the device is playing and return the
  320.  request with this bit and the error bit set and an error code. Requests that
  321.  would not interrupt audio play may return without error but will also have
  322.  this bit set when the drive is in audio play mode. Play mode can be
  323.  terminated prematurely with a reset or STOP AUDIO request and a new request
  324.  can be made at that point. Monitoring this bit in each successive request,
  325.  an Audio Q-Channel Info IOCTL for example, will tell when play mode is
  326.  complete.
  327.  
  328.  Bit 8, the done bit, is set by the device driver when the operation is
  329.  finished.
  330.  
  331.  Error codes are the following:
  332.  
  333.    0  Write-protect violation
  334.    1  Unknown unit
  335.    2  Drive not ready
  336.    3  Unknown command
  337.    4  CRC error
  338.    5  Bad drive request structure length
  339.    6  Seek error
  340.    7  Unknown media
  341.    8  Sector not found
  342.    9  Printer out of paper
  343.    A  Write fault
  344.    B  Read fault
  345.    C  General failure
  346.    D  Reserved
  347.    E  Reserved
  348.    F  Invalid disk change
  349.  
  350.  Command Code Field
  351.  
  352.  The following values are valid command codes:
  353.  
  354.      0  INIT
  355.      1   MEDIA CHECK (block devices)
  356.      2   BUILD BPB (block devices)
  357.      3  IOCTL INPUT
  358.      4   INPUT (read)
  359.      5   NONDESTRUCTIVE INPUT NO WAIT
  360.      6   INPUT STATUS
  361.      7  INPUT FLUSH
  362.      8   OUTPUT (write)
  363.      9   OUTPUT WITH VERIFY
  364.     10   OUTPUT STATUS
  365.     11  OUTPUT FLUSH
  366.     12  IOCTL OUTPUT
  367.     13  DEVICE OPEN
  368.     14  DEVICE CLOSE
  369.     15   REMOVABLE MEDIA (block devices)
  370.     16   OUTPUT UNTIL BUSY
  371.    128  READ LONG                (NEW)
  372.    129   Reserved
  373.    130  READ LONG PREFETCH       (NEW)
  374.    131  SEEK                     (NEW)
  375.    132  PLAY AUDIO               (NEW)
  376.    133  STOP AUDIO               (NEW)
  377.    134  WRITE LONG               (NEW)
  378.    135  WRITE LONG VERIFY        (NEW)
  379.    136  RESUME AUDIO             (NEW)
  380.  
  381.  Unsupported or illegal commands will set the error bit and return the error
  382.  code for Unknown Command. This includes command codes 1, 2, 4, 5, 6, 8, 9,
  383.  10, 15, 16, and 129; and 11, 134 and 135 for systems that do not support
  384.  writing.
  385.  
  386.  If, in the time since the last request to that device driver unit, the media
  387.  has changed, the device driver will return the error code for invalid disk
  388.  change and set the error bit. MSCDEX.EXE will then decide whether to retry
  389.  the request or abort it.
  390.  
  391.  The minimal CD-ROM device driver will read cooked Mode 1 data sectors using
  392.  HSG addressing mode and return appropriate values for the IOCTL calls. Most
  393.  other features enhance performance or add useful capabilities.
  394.  
  395.  
  396.  INIT
  397.  
  398.  Command code = 0
  399.  ES:BX = INIT
  400.  
  401.  INIT      DB   13 dup (0); Request header
  402.            DB   0         ; Number of units (must be 0)
  403.            DD   ?         ; End address
  404.            DD   ?         ; Ptr to BPB array
  405.            DB   0         ; Block device number
  406.  
  407.  This call is made only once, when the device is installed. INIT and a single
  408.  IOCTL call for the device header address are the only device driver calls
  409.  that come directly from MS-DOS. Because the INIT function is called from MS-
  410.  DOS, the number of units returned is 0, as for normal MS-DOS character
  411.  devices. MSCDEX.EXE will get the number of units supported from the device
  412.  header.
  413.  
  414.  The device must return the END ADDRESS, which is a DWORD pointer to the end
  415.  of the portion of the device driver to remain resident. Code and data
  416.  following the pointer is used for initialization and then discarded. If
  417.  there are multiple device drivers in a single file, the ending address
  418.  returned by the last INIT call will be the one that MS-DOS uses, but it is
  419.  recommended that all the device drivers in the file return the same address.
  420.  The code to remain resident for all the devices in a single file should be
  421.  grouped together low in memory with the initialization code for all devices
  422.  following it in memory.
  423.  
  424.  The pointer to BPB array points to the character after the "=" on the line
  425.  in CONFIG.SYS that caused this device driver to be loaded. This data is
  426.  read-only and allows the device driver to scan the invocation line for
  427.  parameters. This line is terminated by a carriage return or a line feed.
  428.  During initialization, the device driver must set the device name field in
  429.  the device header to the argument provided on the invocation line in
  430.  CONFIG.SYS. The device driver must also check that the device_name command
  431.  line argument is a legal 8-character filename and pad it out to 8 characters
  432.  with spaces (20H) when copying it to the device name field.
  433.  
  434.  The block device number and number of units are both 0 for character
  435.  devices.
  436.  
  437.  
  438.  READ (IOCTL Input)
  439.  
  440.  Command code = 3
  441.  ES:BX = IOCTLI
  442.  
  443.  IOCTLI    DB   13 dup (0); Request header
  444.            DB   0         ; Media descriptor byte from BPB
  445.            DD   ?         ; Transfer address
  446.            DW   ?         ; Number of bytes to transfer
  447.            DW   0         ; Starting sector number
  448.            DD   0         ; DWORD ptr to requested vol ID if error 0FH
  449.  
  450.  The media descriptor byte, starting sector number, and volume ID fields are
  451.  all 0.
  452.  
  453.  The transfer address points to a control block that is used to communicate
  454.  with the device driver. The first byte of the control block determines the
  455.  request that is being made. If the command code is reserved or the function
  456.  not supported, then the device driver will return the error code for Unknown
  457.  Command. If, for some reason, the device driver is not able to process the
  458.  request at that time, it will return the error code for Drive Not Ready.
  459.  
  460.            Number of Bytes
  461.   Code       to Transfer                 Function
  462.  
  463.     0             5            Return Address of Device Header
  464.     1             6            Location of Head
  465.     2             ?            Reserved
  466.     3             ?            Error Statistics
  467.     4             9            Audio Channel Info
  468.     5           130            Read Drive Bytes
  469.     6             5            Device Status
  470.     7             4            Return Sector Size
  471.     8             5            Return Volume Size
  472.     9             2            Media Changed
  473.    10             7            Audio Disk Info
  474.    11             7            Audio Track Info
  475.    12            11            Audio Q-Channel Info
  476.    13            13            Audio Sub-Channel Info
  477.    14            11            UPC Code
  478.    15            11            Audio Status Info
  479.    16-255        ?             Reserved
  480.  
  481.  Return Address of Device Header
  482.  
  483.  Raddr     DB   0         ; Control block code
  484.            DD   ?         ; Address of device header
  485.  
  486.  The device driver will fill the 4-byte field with the address of its device
  487.  header. This is used by MSCDEX.EXE to locate the device driver's strategy
  488.  and interrupt routines.
  489.  
  490.  Location of Head
  491.  
  492.  LocHead   DB   1         ; Control block code
  493.            DB   ?         ; Addressing mode
  494.            DD   ?         ; Location of drive head
  495.  
  496.  The device driver will return a 4-byte address that indicates where the head
  497.  is located. The value will be interpreted based on the addressing mode. (See
  498.  function READ LONG for more information about addressing modes.)
  499.  
  500.  ───────────────────────────────────────────────────────────────────────────
  501.  NOTE:
  502.    The drive could provide this information by monitoring the Q-channel on
  503.    the disk.
  504.  ───────────────────────────────────────────────────────────────────────────
  505.  
  506.  Error Statistics
  507.  
  508.  ErrStat   DB   3         ; Control block code
  509.            DB   N dup (?) ; Error statistics
  510.  
  511.  The format of the Error Statistics is not yet defined.
  512.  
  513.  Audio Channel Info
  514.  
  515.  AudInfo   DB   4       ; Control block code
  516.            DB   ?       ; Input  channel (0, 1, 2, or 3) for output channel 0
  517.            DB   ?       ; Volume control (0 - 0xff) for output channel 0
  518.            DB   ?       ; Input  channel (0, 1, 2, or 3) for output channel 1
  519.            DB   ?       ; Volume control (0 - 0xff) for output channel 1
  520.            DB   ?       ; Input  channel (0, 1, 2, or 3) for output channel 2
  521.            DB   ?       ; Volume control (0 - 0xff) for output channel 2
  522.            DB   ?       ; Input  channel (0, 1, 2, or 3) for output channel 3
  523.            DB   ?       ; Volume control (0 - 0xff) for output channel 3
  524.  
  525.  This function returns the present settings of the audio channel control set
  526.  with the Audio Channel Control Ioctl Write function. The default settings
  527.  for the audio channel control are for each input channel to be assigned to
  528.  its corresponding output channel (0 to 0, 1 to 1, etc.) and for the volume
  529.  control on each channel is set at 0xff.
  530.  
  531.  Read Drive Bytes
  532.  
  533.  DrvBytes  DB   5          ; Control block code
  534.            DB   ?          ; Number bytes read
  535.            DB   128 dup (?); Read buffer
  536.  
  537.  Data returned from the CD-ROM drive itself can be read using this function.
  538.  The number-bytes-read field returns the length of the number of bytes read,
  539.  which will not exceed 128 per call. If more than this needs to be returned,
  540.  the call will be repeated until the number returned is 0.
  541.  
  542.  The function and content of these bytes are entirely device and device
  543.  driver dependent. This function is provided to allow access to device-
  544.  specific features that are not addressed under any other portion of the
  545.  device driver spec.
  546.  
  547.  Device Status
  548.  
  549.  DevStat   DB   6         ; Control block code
  550.            DD   ?         ; Device parameters
  551.  
  552.  The device driver will return a 32-bit value. Bit 0 is the least significant
  553.  bit. The bits are interpreted as follows:
  554.  
  555.    Bit 0     0    Door closed
  556.              1    Door open
  557.  
  558.    Bit 1     0    Door locked
  559.              1    Door unlocked
  560.  
  561.    Bit 2     0    Supports only cooked reading
  562.              1    Supports cooked and raw reading
  563.  
  564.    Bit 3     0    Read only
  565.              1    Read/write
  566.  
  567.    Bit 4     0    Data read only
  568.              1    Data read and plays audio/video tracks
  569.  
  570.    Bit 5     0    No interleaving
  571.              1    Supports interleaving
  572.  
  573.    Bit 6     0    Reserved
  574.  
  575.    Bit 7     0    No prefetching
  576.              1    Supports prefetching requests
  577.  
  578.    Bit 8     0    No audio channel manipulation
  579.              1    Supports audio channel manipulation
  580.  
  581.    Bit 9     0    Supports HSG addressing mode
  582.              1    Supports HSG and Red Book addressing modes
  583.  
  584.    Bit 10-31 0    Reserved (all 0)
  585.  
  586.  Return Sector Size
  587.  
  588.  SectSize  DB   7         ; Control block code
  589.            DB   ?         ; Read mode
  590.            DW   ?         ; Sector size
  591.  
  592.  The device driver will return the sector size of the device given the read
  593.  mode provided. In the case of CD-ROM, the value returned for cooked is 2048,
  594.  and the return value  for raw is 2352.
  595.  
  596.  Return Volume Size
  597.  
  598.  VolSize   DB   8         ; Control block code
  599.            DD   ?         ; Volume size
  600.  
  601.  The device driver will return the number of sectors on the device. The size
  602.  returned is the address of the lead-out track in the TOC converted to a
  603.  binary value according to FRAME + (SEC * 75) + (MIN * 60 * 75). A disc with
  604.  a lead out track starting at 31:14.63 would return a volume size of 140613.
  605.  The address of the lead-out track is assumed to point to the first sector
  606.  following the last addressable sector recorded on the disc.
  607.  
  608.  Media Changed
  609.  
  610.  MedChng   DB   9         ; Control block code
  611.            DB   ?         ; Media byte
  612.  
  613.  The normal media check function (command code 1) is not performed on
  614.  character devices and contains additional semantics that are not needed for
  615.  CD-ROM device drivers. This is why there is an IOCTL request for this
  616.  function.
  617.  
  618.  When the device driver receives a call to see if the media has changed on
  619.  that subunit, it will return one of the following values:
  620.  
  621.     1         Media not changed
  622.     0         Don't know if changed
  623.    -1 (0FFh)  Media changed
  624.  
  625.  If the driver can assure that the media has not been changed (through a
  626.  door-lock or other interlock mechanism), performance is enhanced because
  627.  MSCDEX.EXE does not need to reread the VTOC and invalidate in-memory buffers
  628.  for each directory access. For drives that do not report if the media has
  629.  changed, CD-ROM device drivers can utilize the same solution that has been
  630.  applied to floppy disks. In some floppy-disk device drivers, if the MEDIA
  631.  CHECK occurs within 2 seconds of a floppy-disk access, the driver reports
  632.  "Media not changed." It is highly recommended though that drives be able to
  633.  detect and report media changes.
  634.  
  635.  If the drive can enforce a door lock mechanism so that the device driver is
  636.  notified when the door lock has been unlocked or the device driver is
  637.  requested to do so by MSCDEX.EXE, then to improve performance, the driver
  638.  could return that the media has not changed without bothering to communicate
  639.  with the physical device.
  640.  
  641.  If the media has not been changed, MSCDEX.EXE will proceed with the disk
  642.  access. If the value returned is "Don't know," or "Media changed," then
  643.  MSCDEX.EXE will check to see if the disk has changed. It will  continue if
  644.  it has not, and reinitialize what it knows about the disk if it has.
  645.  
  646.  It is not necessary for the device driver to do anything for the volume ID
  647.  when the media has changed.
  648.  
  649.  Audio Disk Info
  650.  
  651.  DiskInfo  DB   10        ; Control block code
  652.            DB   ?         ; Lowest track number
  653.            DB   ?         ; Highest track number
  654.            DD   ?         ; Starting point of the lead-out track
  655.  
  656.  This function returns TOC (Table of Contents) information from the Q-Channel
  657.  in the lead-in track indicating what the first and last track numbers are
  658.  and the Red Book address for the lead-out track (PMIN/PSEC/PFRAME when POINT
  659.  = A2). The first and last track numbers are binary values and not BCD. It is
  660.  recommended that the information for Audio Disk Info and Audio Track Info
  661.  should be read by the drive when the disc is initialized and made accessible
  662.  to the driver so that when these functions are called, the drive or driver
  663.  do not have to interrupt audio play to read them from the TOC. If the TOC is
  664.  not made available to the driver and the driver must obtain the information
  665.  itself from the lead-in track, the driver should read and and attempt to
  666.  cache the disk and track information during the Audio Disk Info command and
  667.  invalidate this information only if the media changes.
  668.  
  669.  Audio Track Info
  670.  
  671.  TnoInfo   DB   11        ; Control block code
  672.            DB   ?         ; Track number
  673.            DD   ?         ; Starting point of the track
  674.            DB   ?         ; Track control information
  675.  
  676.  This function takes a binary track number, from within the range specified
  677.  by the lowest and highest track number given by the Audio Disk Info command,
  678.  and returns the Red Book address for the starting point of the track and the
  679.  track control information for that track. The track control information byte
  680.  corresponds to the byte in the TOC in the lead-in track containing the two
  681.  4-bit fields for CONTROL and ADR in the entry for that track. The CONTROL
  682.  information is in the most significant 4 bits and the ADR information is in
  683.  the lower 4 bits. The track control information is encoded as follows:
  684.  
  685.    00x00000  - 2 audio channels without pre-emphasis
  686.    00x10000  - 2 audio channels with pre-emphasis
  687.    10x00000  - 4 audio channels without pre-emphasis
  688.    10x10000  - 4 audio channels with pre-emphasis
  689.    01x00000  - data track
  690.    01x10000  - reserved
  691.    11xx0000  - reserved
  692.    xx0x0000  - digital copy prohibited
  693.    xx1x0000  - digital copy permitted
  694.  
  695.  Audio Q-Channel Info
  696.  
  697.  QInfo     DB   12        ; Control block code
  698.            DB   ?         ; CONTROL and ADR byte
  699.            DB   ?         ; Track number (TNO)
  700.            DB   ?         ; (POINT) or Index (X)
  701.                           ; Running time within a track
  702.            DB   ?         ; (MIN)
  703.            DB   ?         ; (SEC)
  704.            DB   ?         ; (FRAME)
  705.            DB   ?         ; (ZERO)
  706.                           ; Running time on the disk
  707.            DB   ?         ; (AMIN) or (PMIN)
  708.            DB   ?         ; (ASEC) or (PSEC)
  709.            DB   ?         ; (AFRAME) or (PFRAME)
  710.  
  711.  This function reads and returns the most up to date Q-channel address
  712.  presently available. It should not interrupt the present status of the drive
  713.  as one of its intended purposes is to monitor the location of the read head
  714.  while playing audio tracks. This function should return valid information
  715.  even when no audio tracks are being played and the head is stationary. The
  716.  fields returned correspond to the data that is stored in the Q-channel as
  717.  described in the Red Book. The values in MIN-SEC-FRAME, AMIN-ASEC-AFRAME and
  718.  PMIN-PSEC-PFRAME are converted by the driver from BCD to binary so that
  719.  minutes range from 0 to 59+, seconds from 0 to 59, and frames from 0 to 74.
  720.  The Control and ADR byte, TNO, and POINT/Index bytes are always passed
  721.  through as they appear on the disc and are not converted. If the drive
  722.  returns Q-channel information when ADR is not equal to 1, then when ADR is
  723.  not equal to 1 all ten bytes of information are passed through unmodified to
  724.  the caller.
  725.  
  726.  Audio Sub-Channel Info
  727.  
  728.  SubChanInfo DB   13        ; Control block code
  729.              DD   ?         ; Starting frame address
  730.              DD   ?         ; Transfer address
  731.              DD   ?         ; Number of sectors to read
  732.  
  733.  This function takes a Red Book address for a particular frame (also known as
  734.  a block or frame) and copies 96 bytes of sub-channel information per frame
  735.  for all the sectors that are requested sequentially at the transfer address
  736.  given. Each 96 bytes of information do not include the two sync patterns (S0
  737.  and S1) that head the subcoding block but only the the 96 bytes of subcoding
  738.  symbols each with one bit of information for the eight different channels
  739.  (P-W) that follow them. P is the MSB, W is the LSB of each byte.
  740.  
  741.  The caller is responsible for making sure that 96 *
  742.  Number_of_sectors_to_read bytes are available at the transfer address for
  743.  the device driver to store the results.
  744.  
  745.  Data definition and integrity restrictions for data received with this
  746.  command are interpreted according to the CD-ROM standard (Red and Yellow
  747.  Book).
  748.  
  749.  UPC Code
  750.  
  751.  UPCCode   DB   14        ; Control block code
  752.            DB   ?         ; CONTROL and ADR byte
  753.            DB   7 dup (?) ; UPC/EAN code
  754.                           ; (last 4 bits are zero; the low-order nibble of
  755.                           ; byte 7)
  756.            DB   ?         ; Zero
  757.            DB   ?         ; Aframe
  758.  
  759.  This function returns the UPC/EAN (Universal Product Code - BAR coding) for
  760.  the disc. This information is stored as a mode-2 (ADR=2) Q-channel entry.
  761.  The UPC code is 13 successive BCD digits (4 bits each) followed by 12 bits
  762.  of zero. The last byte is the continuation of FRAME in mode-1 though in the
  763.  lead-in track (TNO=0) this byte is zero. If the CONTROL/ADR byte is zero or
  764.  if the 13 digits of UPC code are all zero, then either no catalog number was
  765.  encoded on the disc or it was missed by the device driver. If the command is
  766.  not supported, then the driver will return an error code of Unknown Command.
  767.  If the command is supported but the disc does not have a UPC Code recorded,
  768.  then the driver will return an error code of Sector not Found.
  769.  
  770.  Audio Status Info
  771.  
  772.  AudStat DB   15        ; Control block code
  773.          DW   ?         ; Audio status bits
  774.                         ; Bit 0 is Audio Paused bit
  775.                         ; Bits 1-15 are reserved
  776.          DD   ?         ; Starting location of last Play or for next Resume
  777.          DD   ?         ; Ending location for last Play or for next Resume
  778.  
  779.  The Audio Paused bit and Starting and Ending locations are those referred to
  780.  in the RESUME command.
  781.  
  782.  
  783.  WRITE (IOCTL OUTPUT)
  784.  
  785.  Command code = 12
  786.  ES:BX = IOCTLO
  787.  
  788.  IOCTLO    DB   13 dup (0); Request header
  789.            DB   0         ; Media descriptor byte from BPB
  790.            DD   ?         ; Transfer address
  791.            DW   ?         ; Number of bytes to transfer
  792.            DW   0         ; Starting sector number
  793.            DD   0         ; DWORD ptr to requested vol ID if error 0FH
  794.  
  795.  The media descriptor byte, starting sector number, and volume ID fields are
  796.  all 0.
  797.  
  798.  The transfer address points to a control block that is used to communicate
  799.  with the device driver. The first byte of the control block determines the
  800.  request that is being made. The Length of Block is the number of bytes to
  801.  transfer.
  802.  
  803.         Length of
  804.  Code   Block            Function
  805.  
  806.    0      1              Eject Disk
  807.    1      2              Lock/Unlock Door
  808.    2      1              Reset Drive
  809.    3      9              Audio Channel Control
  810.    4      ?              Write Device Control String
  811.    5      1              Close Tray
  812.    6-255  ?              Reserved
  813.  
  814.  Eject Disk
  815.  
  816.  Eject          DB   0         ; Control block code
  817.  
  818.  The device driver will unlock the drive and eject the CD-ROM disk from the
  819.  drive unit. The door will report as being open until the user has inserted
  820.  a disk  into the drive unit and closed the door. The status bit for door
  821.  open can be monitored to determine when a disk has been reinserted.
  822.  
  823.  Lock/Unlock Door
  824.  
  825.  LockDoor  DB   1         ; Control block code
  826.            DB   ?         ; Lock function
  827.  
  828.  When this function is received, the device driver will ask the CD-ROM drive
  829.  to unlock or lock the door. If lock function is 0, the device driver will
  830.  unlock the door. If lock function is 1, it will lock the door.
  831.  
  832.  Reset Drive
  833.  
  834.  ResetDrv  DB   2         ; Control block code
  835.  
  836.  This function directs the device driver to reset and reinitialize the
  837.  drive.
  838.  
  839.  Audio Channel Control
  840.  
  841.  AudInfo   DB   3     ; Control block code
  842.            DB   ?     ; Input  channel (0, 1, 2, or 3) for output channel 0
  843.            DB   ?     ; Volume control (0 - 0xff) for output channel 0
  844.            DB   ?     ; Input  channel (0, 1, 2, or 3) for output channel 1
  845.            DB   ?     ; Volume control (0 - 0xff) for output channel 1
  846.            DB   ?     ; Input  channel (0, 1, 2, or 3) for output channel 2
  847.            DB   ?     ; Volume control (0 - 0xff) for output channel 2
  848.            DB   ?     ; Input  channel (0, 1, 2, or 3) for output channel 3
  849.            DB   ?     ; Volume control (0 - 0xff) for output channel 3
  850.  
  851.  This function is intended to provide playback control of audio information
  852.  on the disk. It allows input channels on the CD-ROM to be assigned to
  853.  specific output speaker connections. The purpose of this function is to
  854.  allow two independent channels to be recorded──in different languages for
  855.  example──and to play back only one of them at a time or to be able to
  856.  manipulate an audio signal so that the source appears to move──to make a
  857.  sound seem to move from left to right for example.
  858.  
  859.  Output channel 0 is the left channel, 1 is right, 2 is left prime, and 3 is
  860.  right prime. The Red Book specification allows for 4 audio channels. The two
  861.  "prime" channels (2 and 3) extend stereo to quadrophonic stereo.
  862.  
  863.  An audio volume setting of 0 means off. Drives that don't support 4 output
  864.  audio channels may ignore output to channels 2 and 3. Assignment of input
  865.  channels 2 and 3 to output channels 0 and 1 may be treated as though the
  866.  volume control for that channel is 0.
  867.  
  868.  Drives that do not support variable audio control will treat a setting of 0
  869.  as off and 1-0xff as on. Drives that support less than 256 volume settings
  870.  will do their best to break up the 256 settings among the settings they can
  871.  support. E.g. if there are 16 settings supported, then the first setting
  872.  will cover 0x01-0x10, the second 0x11-0x20...the sixteenth 0xf1-0xff. Drives
  873.  that can't play a single channel in both must play only that one channel and
  874.  try to suppress the other if possible. Drives that can't swap channels
  875.  should play the channel that was moved in its normal channel.
  876.  
  877.  Write Device Control String
  878.  
  879.  DrvBytes  DB   4         ; Control block code
  880.            DB   N dup (?) ; Write buffer
  881.  
  882.  This function is provided to allow programs to talk directly to the CD-ROM
  883.  drive. All remaining bytes are sent uninterpreted to the drive unit.
  884.  
  885.  The function and content of these bytes are entirely device and device
  886.  driver dependent. This function is provided to allow access to device-
  887.  specific features that are not addressed under any other portion of the
  888.  device driver spec.
  889.  
  890.  Close Tray
  891.  
  892.  CloseTray DB   5         ; Control block code
  893.  
  894.  This command is the logical complement to the Eject Disk command. This
  895.  command will instructs drives that can do so to close the door or tray.
  896.  
  897.  
  898.  READ LONG
  899.  
  900.  Command code = 128
  901.  ES:BX = ReadL
  902.  
  903.  ReadL     DB   13 dup (0); Request header
  904.            DB   ?         ; Addressing mode
  905.            DD   ?         ; Transfer address
  906.            DW   ?         ; Number of sectors to read
  907.            DD   ?         ; Starting sector number
  908.            DB   ?         ; Data read mode
  909.            DB   ?         ; Interleave size
  910.            DB   ?         ; Interleave skip factor
  911.  
  912.  The request block is different from a normal character device READ to
  913.  accommodate the larger size and different characteristics of CD-ROM
  914.  devices.
  915.  
  916.  The media descriptor byte, which has no meaning for character devices, is
  917.  now the addressing mode field. The following values are recognized
  918.  addressing modes:
  919.  
  920.    0      HSG addressing mode
  921.    1      Red Book addressing mode
  922.    2-255  Reserved
  923.  
  924.  The default addressing mode is the HSG addressing mode. Long (DWORD) address
  925.  values are treated as logical block numbers, as defined by the High Sierra
  926.  proposal. When Red Book addressing mode is on, all disk addresses are
  927.  interpreted as Minute/Second/Frame addresses, according to the Philips/Sony
  928.  Red Book standard. Each of these fields is 1 byte. The frame byte is the
  929.  least significant byte of the address field, the "second" byte the next most
  930.  significant, the minute byte the next, and the most significant byte of the
  931.  4-byte field is unused. These values are represented in binary rather than
  932.  in BCD format. For example, if we are referencing the sector addressed by
  933.  minute 36, second 24, frame 12, the hex long value for this would be
  934.  0x0024180C. The relationship between High Sierra sectors and Red Book frames
  935.  is described by the equation:
  936.  
  937.    Sector = Minute * 60 * 75 + Second * 75 + Frame - 150
  938.  
  939.  The byte/sector count field becomes the number of sectors to read and the
  940.  starting sector number expands from one word to two, which  means we can
  941.  address up to 4 giga-sectors (over 8 terabytes). The DWORD ptr for requested
  942.  volume ID is eliminated and MSCDEX.EXE will keep track of what volume is
  943.  needed.
  944.  
  945.  MSCDEX.EXE handles buffering requests, but performance may be improved if
  946.  the device driver reads ahead or uses a sector caching scheme, given the
  947.  slow seek times of CD-ROM drives. The operating system will use the prefetch
  948.  function when it can to give hints to the driver.
  949.  
  950.  The data read mode field will be one of the following:
  951.  
  952.    0      Cooked mode
  953.    1      Raw mode
  954.    2-255  Reserved
  955.  
  956.  Cooked mode is the default mode in which the hardware typically handles the
  957.  EDC/ECC and the device driver returns 2048 bytes of data per sector read.
  958.  When raw mode is set, the driver will return all 2352 bytes of user data,
  959.  including any EDC/ECC present independent of the actual sector mode (Mode 2
  960.  Form 1 vs. Mode 2 Form 2). User programs will have to consider this and
  961.  allow enough room for buffer space when reading in raw mode as each sector
  962.  returned will take up 2352 bytes of space. Drives that cannot return all
  963.  2352 bytes will return what they can and leave blank what they cannot. For
  964.  example, drives that can return all 2336 bytes except the 16 byte header
  965.  will leave a space in the first 16 bytes where the header would go so that
  966.  the sectors align on 2352 byte boundaries. Drivers should do what they can
  967.  to return as much of the user data per sector as possible.
  968.  
  969.  The two interleave parameters are for drivers that support interleaved
  970.  reading. If the driver does not support interleaving, these fields are both
  971.  ignored. If it does, interleave size is the number of consecutive logical
  972.  blocks or sectors that are stored sequentially, and the interleave skip
  973.  factor is the number of consecutive logical blocks or sectors that separate
  974.  portions of the interleaved file.
  975.  
  976.  
  977.  READ LONG PREFETCH
  978.  
  979.  Command code = 130
  980.  ES:BX = ReadLPre
  981.  
  982.  ReadLPre  DB   13 dup (0); Request header
  983.            DB   ?         ; Addressing mode
  984.            DD   0         ; Transfer address
  985.            DW   ?         ; Number of sectors to read
  986.            DD   ?         ; Starting sector number
  987.            DB   ?         ; Read mode
  988.            DB   ?         ; Interleave size
  989.            DB   ?         ; Interleave skip factor
  990.  
  991.  This function is similar in form to READ LONG, but control returns
  992.  immediately to the requesting process. The device driver is not obligated to
  993.  read in the requested sectors but can instead consider the request for these
  994.  sectors as hints from the operating system that they are likely to be
  995.  needed. It is recommended that at a minimum, the driver seek to the location
  996.  provided. The attribute in the device status for prefetching is used to
  997.  distinguish drivers that do more than just seek to the given location. The
  998.  requests are low priority and preemptible by other requests for service. A
  999.  READ LONG PREFETCH with 0 number of sectors to read should be treated as an
  1000.  advisory seek, and the driver can, if it is not busy, move the head to the
  1001.  starting sector. Since prefetching requests are advisory, there will be no
  1002.  functional difference between a device driver that supports prefetching from
  1003.  one that does not, except in terms of performance. The transfer address is
  1004.  not applicable for this call as the driver is not meant to transfer any data
  1005.  into the user address space.
  1006.  
  1007.  
  1008.  SEEK
  1009.  
  1010.  Command code = 131
  1011.  ES:BX = SeekReq
  1012.  
  1013.  SeekReq   DB   13 dup (0); Request header
  1014.            DB   ?         ; Addressing mode
  1015.            DD   0         ; Transfer address
  1016.            DW   0         ; Number of sectors to read
  1017.            DD   ?         ; Starting sector number
  1018.  
  1019.  Control returns immediately to the caller without blocking and waiting for
  1020.  the seek to be completed. The number of sectors to be read and the transfer
  1021.  address are ignored. SEEK is used to relocate the head in order to begin
  1022.  playing audio or video tracks, or in anticipation of reading in a particular
  1023.  region on the disk. Further requests for disk activity will wait until the
  1024.  given SEEK is completed. This seek is not advisory and the head must move to
  1025.  the desired location.
  1026.  
  1027.  
  1028.  PLAY AUDIO
  1029.  
  1030.  Command code = 132
  1031.  ES:BX = PlayReq
  1032.  
  1033.  PlayReq   DB   13 dup (0); Request header
  1034.            DB   ?         ; Addressing mode
  1035.            DD   ?         ; Starting sector number
  1036.            DD   ?         ; Number of sectors to read
  1037.  
  1038.  This function will cause the driver to play the selected audio tracks until
  1039.  the requested sectors have been exhausted or until play is interrupted with
  1040.  a AUDIO STOP request. Control returns immediately to the caller. Monitoring
  1041.  the busy bit in the status word will determine if the drive is presently
  1042.  playing audio and also when the play request is completed.
  1043.  
  1044.  
  1045.  STOP AUDIO
  1046.  
  1047.  Command code = 133
  1048.  ES:BX = StopPlayReq
  1049.  
  1050.  StopPlayReq    DB   13 dup (0)     ; Request header
  1051.  
  1052.  This function is included to interrupt the drive unit when it is currently
  1053.  in play mode. At the next stopping point it reaches, the drive will
  1054.  discontinue playing and process the next request. If the drive is not
  1055.  currently playing or does not support playing, this request is ignored.
  1056.  
  1057.  
  1058.  RESUME AUDIO
  1059.  
  1060.  Command code = 136
  1061.  ES:BX = ResumeReq
  1062.  
  1063.  ResumeReq DB   13 dup (0)     ; Request header
  1064.  
  1065.  This function is used to resume playing audio tracks when play has been
  1066.  interrupted with the STOP AUDIO command. Its behavior should correspond to
  1067.  the following:
  1068.  
  1069.    RESET, NEW DISC, PLAY/RESUME COMPLETED
  1070.         playing = FALSE;
  1071.         paused  = FALSE;
  1072.         last_startloc = 0;
  1073.         last_endloc   = 0;
  1074.  
  1075.    PLAY_AUDIO(startloc, endloc) {
  1076.         if (play(startloc, endloc) != SUCCESSFUL) {
  1077.              return error;
  1078.  
  1079.         playing = TRUE;
  1080.         paused = FALSE;
  1081.         last_startloc = startloc
  1082.         last_endloc = endloc
  1083.         return no error;
  1084.         }
  1085.  
  1086.    STOP_AUDIO() {
  1087.         if (playing) {
  1088.              last_startloc = present q-channel location
  1089.              playing = FALSE;
  1090.              paused = TRUE;
  1091.              if (stop() == SUCCESSFUL)
  1092.                   return no error;
  1093.              return error;
  1094.              }
  1095.         else {
  1096.              playing = FALSE;
  1097.              paused = FALSE;
  1098.              last_startloc = 0;
  1099.              last_endloc = 0;
  1100.              return no error;
  1101.              }
  1102.         }
  1103.  
  1104.    RESUME_AUDIO() {
  1105.         if (paused) {
  1106.              if (play(last_startloc, last_endloc) != SUCCESSFUL)
  1107.                   return error;
  1108.              playing = TRUE;
  1109.              paused = FALSE;
  1110.              return no error;
  1111.              }
  1112.         else
  1113.              return error;
  1114.  
  1115.  Note that the playing flag corresponds to the state that should be reported
  1116.  by the busy bit in the status word in the request header when the drive is
  1117.  in audio play mode. The paused flag corresponds to the Audio Paused bit and
  1118.  last_startloc and last_endloc correspond to the starting and ending location
  1119.  in the Audio Status Info IOCTL.
  1120.  
  1121.  
  1122.  WRITE LONG
  1123.  
  1124.  Command code = 134
  1125.  ES:BX = WriteL
  1126.  
  1127.  WriteL    DB   (dup 13 0); Request header
  1128.            DB   ?         ; Addressing mode
  1129.            DD   ?         ; Transfer address
  1130.            DW   ?         ; Number of sectors to write
  1131.            DD   ?         ; Starting sector number
  1132.            DB   ?         ; Write mode
  1133.            DB   ?         ; Interleave size
  1134.            DB   ?         ; Interleave skip factor
  1135.  
  1136.  The device will copy the data at the transfer address to the CD RAM device
  1137.  at the sector indicated. The media must be writable for this function to
  1138.  work. Data is written sector by sector, depending on the current write mode
  1139.  and the interleave parameters. The following values are recognized as valid
  1140.  write modes:
  1141.  
  1142.    0      Mode 0
  1143.    1      Mode 1
  1144.    2      Mode 2 Form 1
  1145.    3      Mode 2 Form 2
  1146.    4-255  Reserved
  1147.  
  1148.  Writing in Mode 1 is the default and must be supported. If the device driver
  1149.  supports the other modes, then they can be used. If Mode 0 is used, the
  1150.  transfer address is ignored and all sectors are written with zeroes. If the
  1151.  current write mode is Mode 1 or Mode 2 Form 1, each sector will consist of
  1152.  2048 bytes of data located sequentially at the transfer address. If the
  1153.  write mode is Mode 2 Form 2, the device driver will expect 2336 bytes of
  1154.  data per sector at the transfer address.
  1155.  
  1156.  
  1157.  WRITE LONG VERIFY
  1158.  
  1159.  Command code = 136
  1160.  ES:BX = WriteLV
  1161.  
  1162.  WriteLV   DB   (dup 13 0); Request header
  1163.            DB   ?         ; Addressing mode
  1164.            DD   ?         ; Transfer address
  1165.            DW   ?         ; Number of sectors to write
  1166.            DD   ?         ; Starting sector number
  1167.            DB   ?         ; Write mode
  1168.            DB   ?         ; Interleave size
  1169.            DB   ?         ; Interleave skip factor
  1170.  
  1171.  This function is identical to WRITE LONG, with the addition that the device
  1172.  driver is responsible for verifying the data written to the device.
  1173.  
  1174.  
  1175.  INPUT FLUSH
  1176.  
  1177.  Command code = 7
  1178.  ES:BX = FlushI
  1179.  
  1180.  FlushI         DB   13 dup (0)     ; Request header
  1181.  
  1182.  Requests that the device driver free all input buffers and clear any pending
  1183.  requests.
  1184.  
  1185.  
  1186.  OUTPUT FLUSH
  1187.  
  1188.  Command code = 11
  1189.  ES:BX = FlushO
  1190.  
  1191.  FlushO         DB   (dup 13 0)     ; Request header
  1192.  
  1193.  Requests that the device driver write all unwritten buffers to the disk.
  1194.  
  1195.  
  1196.  DEVICE OPEN
  1197.  DEVICE CLOSE
  1198.  
  1199.  Command code = 13,14
  1200.  ES:BX = DevOpen, DevClose
  1201.  
  1202.  DevOpen   DB   13 dup (0)     ; Request header
  1203.  
  1204.  Used by the device driver to monitor how many different callers are
  1205.  currently using the CD-ROM device driver. All new device drivers should
  1206.  support these calls even if nothing is done with the information.
  1207.  
  1208.  ████████████████████████████████████████████████████████████████████████████
  1209.  
  1210.  Function Requests Specification
  1211.  
  1212.  There is a need for access to features from the MSCDEX redirector that
  1213.  transend DOS capabilities. This proposal documents a means that the
  1214.  application can use to talk directly to MSCDEX to request information or set
  1215.  parameters that only MSCDEX can provide. This document outlines some of the
  1216.  features I think MSCDEX should support. Comments and suggestions are
  1217.  welcome.
  1218.  
  1219.  Access to these functions is provided through an INT 2Fh interface. AH
  1220.  contains 15h which is what MSCDEX will use to tell its requests from those
  1221.  of other INT 2Fh handlers. AL will contain the code of the function to be
  1222.  performed.
  1223.  
  1224.  Function Request Command Codes:
  1225.  
  1226.  Contents of AL   Function
  1227.  
  1228.  00h              Get Number of CD-ROM Drive Letters
  1229.  01h              Get CD-ROM Drive Device List
  1230.  02h              Get Copyright File Name
  1231.  03h              Get Abstract File Name
  1232.  04h              Get Bibliographic Doc File Name
  1233.  05h              Read VTOC
  1234.  06h              Turn Debugging On
  1235.  07h              Turn Debugging Off
  1236.  08h              Absolute Disk Read
  1237.  09h              Absolute Disk Write
  1238.  0Ah              Reserved
  1239.  0Bh             CD-ROM Drive Check
  1240.  0Ch             MSCDEX Version
  1241.  0Dh             Get CD-ROM Drive Letters
  1242.  0Eh             Get/Set Volume Descriptor Preference
  1243.  0Fh             Get Directory Entry
  1244.  10h             Send Device Request
  1245.  11h-0FFh         Reserved
  1246.  
  1247.  Get Number of CD-ROM Drive Letters
  1248.  
  1249.       AX   1500h
  1250.       BX   Number of CD-ROM drive letters used
  1251.       CX   Starting drive letter of CD-ROM drive letters (A=0, B=1, ...Z=25)
  1252.  
  1253.  MSCDEX will return the number of CD-ROM drive letters in BX and the starting
  1254.  drive letter in CX. The first CD-ROM device will be installed at the
  1255.  starting drive letter and subsequent drives will be assigned the next
  1256.  greater drive letter. A single device driver may be assigned to more than
  1257.  one drive letter, such as the case of a device driver that supports multiple
  1258.  units. MSCDEX keeps track of which sub-unit a particular drive letter is
  1259.  assigned to.
  1260.  
  1261.  ───────────────────────────────────────────────────────────────────────────
  1262.  NOTE:
  1263.    This function can be used to determine if MSCDEX is installed by setting
  1264.    BX to zero before executing INT 2Fh. MSCDEX is not installed if BX is
  1265.    still zero on return.
  1266.  ───────────────────────────────────────────────────────────────────────────
  1267.  
  1268.  Also, in a networking environment, one cannot assume that drive letters will
  1269.  always be assigned contiguously beginning with the starting drive letter.
  1270.  Use function Get CD-ROM drive letters instead.
  1271.  
  1272.  Get CD-ROM Drive Device List
  1273.  
  1274.       AX        1501h
  1275.       ES:BX     Transfer address; pointer to buffer to copy drive letter
  1276.                 device list
  1277.  
  1278.  The buffer must be large enough to hold the device list. By calling function
  1279.  Get Number of CD-ROM Drive Letters, one can find out the number of CD-ROM
  1280.  drive letters and the buffer size will be a multiple of that. This will be
  1281.  an absolute maximum of 26. Each drive letter device entry will consist of
  1282.  one byte for the sub-unit followed by 4 bytes for the address of the device
  1283.  header assigned to that drive letter. This byte for the sub-unit takes care
  1284.  of the problem of distinguishing which unit is assigned to which drive
  1285.  letter for device drivers that handle sub-units.
  1286.  
  1287.  For example: Suppose there are two installed CD-ROM device drivers, FOO,
  1288.  which supports 1 sub-unit, and BAR, which supports two sub-units, on a
  1289.  system with 2 floppy drives (A=0 and B=1) and a hard disk (C=2). Then asking
  1290.  for the number of CD-ROM drive letters will report that there are 3 drive
  1291.  letters used starting at drive letter D=3. ES:BX must point to a buffer that
  1292.  is at least 3 * 5 = 15 bytes long. The buffer will be filled as follows:
  1293.  
  1294.  ES:BX  = Buffer
  1295.  
  1296.  Buffer   DB   0                        ; sub-unit of FOO on drive letter D:
  1297.           DD   <far addr of FOO device header>
  1298.           DB   0                        ; sub-unit of BAR on drive letter E:
  1299.           DD   <far addr of BAR device header>
  1300.           DB   1                        ; sub-unit of BAR on drive letter F:
  1301.           DD   <far addr of BAR device header>
  1302.  
  1303.  Get Copyright File Name
  1304.  
  1305.       AX     1502h
  1306.       ES:BX  Transfer address; pointer to a 38 byte buffer
  1307.       CX     CD-ROM drive letter (A=0, B=1, ... Z=25)
  1308.  
  1309.  MSCDEX will copy the name of the copyright file in the VTOC for that drive
  1310.  letter into the buffer space provided. The copyright filename is presently
  1311.  restricted in the High Sierra proposal to 8.3 but we require 38 bytes here
  1312.  for the possibility at a later date of handling 31 character file names plus
  1313.  6 bytes for a ';' and 5 digit version number and 1 byte for a NULL at the
  1314.  end. Carry will be set if the drive letter is not a CD-ROM drive and
  1315.  error_invalid_drive (15) will be returned in AX.
  1316.  
  1317.  Get Abstract File Name
  1318.  
  1319.       AX     1503h
  1320.       ES:BX  Transfer address; pointer to a 38 byte buffer
  1321.       CX     CD-ROM drive letter (A=0, B=1, ... Z=25)
  1322.  
  1323.  MSCDEX will copy the name of the abstract file in the VTOC for that drive
  1324.  letter into the buffer space provided. The abstract filename is presently
  1325.  restricted in the High Sierra proposal to 8.3 but we require 38 bytes here
  1326.  for the possibility at a later date of handling 31 character file names plus
  1327.  6 bytes for a ';' and 5 digit version number and 1 byte for a NULL at the
  1328.  end. Carry will be set if the drive letter is not a CD-ROM drive and
  1329.  error_invalid_drive (15) will be returned in AX.
  1330.  
  1331.  Get Bibliographic Documentation File Name
  1332.  
  1333.       AX     1504h
  1334.       ES:BX  Transfer address; pointer to a 38 byte buffer
  1335.       CX     CD-ROM drive letter (A=0, B=1, ... Z=25)
  1336.  
  1337.  ───────────────────────────────────────────────────────────────────────────
  1338.  NOTE:
  1339.    This function is provided in advance of the ISO standard. For discs
  1340.    complying with the May 28th draft from the High Sierra Group, this
  1341.    function will return a null string as though the field is blank on the
  1342.    disc.
  1343.  ───────────────────────────────────────────────────────────────────────────
  1344.  
  1345.  MSCDEX will copy the name of the bibliographic documentation file in the
  1346.  VTOC for that drive letter into the buffer space provided. The bibliographic
  1347.  documentation filename is presently restricted in the High Sierra proposal
  1348.  to 8.3 but we require 38 bytes here for the possibility at a later date of
  1349.  handling 31 character file names plus 6 bytes for a ';' and 5 digit version
  1350.  number and 1 byte for a NULL at the end. Carry will be set if the drive
  1351.  letter is not a CD-ROM drive and error_invalid_drive (15) will be returned
  1352.  in AX.
  1353.  
  1354.  Read VTOC
  1355.  
  1356.       AX     1505h
  1357.       ES:BX  Transfer address; pointer to a 2048 byte buffer
  1358.       CX     CD-ROM Drive letter
  1359.       DX     Sector index
  1360.  
  1361.  This function is provided to scan the Volume Descriptors on a disc. A sector
  1362.  index of 0 will read the first volume descriptor, 1 reads the second, etc.
  1363.  If there is no error, then AX will return 1 if the volume descriptor read
  1364.  was the standard volume descriptor, 0FFh if it was the volume descriptor
  1365.  terminator and there are no more volume descriptors to be read, and 0 for
  1366.  all other types.
  1367.  
  1368.  If there is an error in processing the request, the Carry Flag will be set
  1369.  and AL will contain the MS-DOS error code. These will be either
  1370.  error_invalid_drive (15) or error_not_ready (21).
  1371.  
  1372.  Turn Debugging On
  1373.  
  1374.       AX     1506h
  1375.       BX     Debugging function to enable
  1376.  
  1377.  This is used for development and is reserved. It will be non-functional in
  1378.  the production version of MSCDEX.
  1379.  
  1380.  Turn Debugging Off
  1381.  
  1382.       AX     1507h
  1383.       BX     Debugging function to disable
  1384.  
  1385.  This is used for development and is reserved. It will be non-functional in
  1386.  the production version of MSCDEX.
  1387.  
  1388.  Absolute Disk Read
  1389.  
  1390.       AX     1508h
  1391.       ES:BX  Disk Transfer Address; pointer to a buffer to copy data to
  1392.       CX     CD-ROM Drive letter (A=0, B=1, ... Z=25)
  1393.       DX     Number of sectors to read
  1394.       SI:DI  Starting sector
  1395.  
  1396.  This function corresponds to INT 25h. It will be converted directly into a
  1397.  READ_LONG device driver request and sent to the correct device driver. There
  1398.  are no requirements for this call to pop flags as there are with INT 25h. SI
  1399.  holds the high word and DI the low word for the starting sector to begin
  1400.  reading from.
  1401.  
  1402.  If there is an error in processing the request, the Carry Flag will be set
  1403.  and AL will contain the MS-DOS error code. These will be either
  1404.  error_invalid_drive (15) or error_not_ready (21).
  1405.  
  1406.  Absolute Disk Write
  1407.  
  1408.       AX     1509h
  1409.       ES:BX  Disk Transfer Address; pointer to buffer to copy data from
  1410.       CX     CD-ROM Drive letter
  1411.       DX     Number of sectors to write
  1412.       SI:DI  Starting sector
  1413.  
  1414.  This function corresponds to INT 26h. It is not supported at this time and
  1415.  is reserved. It is intended to be used by authoring systems.
  1416.  
  1417.  CD-ROM Drive Check
  1418.  
  1419.       AX     150Bh
  1420.       BX     Signature word
  1421.       CX     CD-ROM Drive letter (A=0, B=1,...Z=25)
  1422.  
  1423.  This function returns whether or not a drive letter is a CD-ROM drive
  1424.  supported by MSCDEX. If the extensions are installed, BX will be set to
  1425.  ADADh. If the drive letter is supported by MSCDEX, then AX is set to a non-
  1426.  zero value. AX is set to zero if the drive is not supported. One must be
  1427.  sure to check the signature word to know that MSCDEX is installed and that
  1428.  AX has not been modified by another INT 2Fh handler.
  1429.  
  1430.  MSCDEX Version
  1431.  
  1432.       AX     150Ch
  1433.       BX     MSCDEX Version
  1434.  
  1435.  This function returns the version number of the CD-ROM Extensions installed
  1436.  on the system. BH contains the major version number and BL contains the
  1437.  minor version. Values returned are binary. For example, BX would contain
  1438.  0x020a for version 2.10. This function does not work on versions earlier
  1439.  than 2.00 so if BX is zero before and after this function is called, an
  1440.  earlier version of MSCDEX is installed.
  1441.  
  1442.  Get CD-ROM Drive Letters
  1443.  
  1444.       AX     150Dh
  1445.       ES:BX  Transfer address; pointer to buffer to copy drive letter
  1446.              device list
  1447.  
  1448.  The buffer must be large enough to hold a list of drive letters. The buffer
  1449.  size will be a multiple of the number of drives returned by the Get Number
  1450.  of CD-ROM Drive Letters function. There are a maximum of 26 drive letters.
  1451.  Each drive letter entry is a single byte (0=A:, 1=B: .. 25=Z:) that exactly
  1452.  corresponds each respective entry returned by the command Get CD-ROM Drive
  1453.  Device List. This command is included to allow applications to locate CD-ROM
  1454.  drives supported by MSCDEX. CD-ROM drive letters may sometimes be
  1455.  noncontiguous so this command is necessary.
  1456.  
  1457.  For example: Suppose there is an installed CD-ROM device driver FOO
  1458.  supporting 3 sub-units on a system with 2 floppy drives (A=0 and B=1), a
  1459.  hard disk (C=2) and a network drive (E=4). Note the network drive occupies
  1460.  one of the drive letters normally taken by a CD-ROM drive. MSCDEX assigns
  1461.  that CD-ROM drive to the next available drive letter. Asking for the number
  1462.  of CD-ROM drive letters reports there are 3 drive letters used starting at
  1463.  drive letter D=3. ES:BX must point to a buffer that is at least 3 bytes long
  1464.  and will be filled as follows:
  1465.  
  1466.  ES:BX   = Buffer
  1467.  
  1468.  Buffer  DB   3                   ; drive letter for CD-ROM (D=3)
  1469.          DB   5                   ; drive letter for CD-ROM (F=5)
  1470.          DB   6                   ; drive letter for CD-ROM (G=6)
  1471.  
  1472.  Get/Set Volume Descriptor Preference
  1473.  
  1474.       AX     150Eh
  1475.       BX     0 - Get Preference. 1 - Set Preference
  1476.       CX     CD-ROM Drive letter (A=0, B=1,...Z=25)
  1477.       DX     if BX = Get Preference
  1478.                      DX = 0
  1479.                      MSCDEX will return preference settings in DX
  1480.              if BX = Set Preference
  1481.                      DH = volume descriptor preference
  1482.                           1 - PVD - Primary Volume  Descriptor
  1483.                           2 - SVD - Supplementary Volume Descriptor
  1484.                      DL = Supplementary Volume Descriptor Preference
  1485.                            if DH = PVD
  1486.                                    DL = 0
  1487.                            if DH = SVD
  1488.                                    1 - shift-Kanji (an unregistered ISO coded
  1489.                                                     character set)
  1490.  
  1491.  Normally, MSCDEX will scan for the PVD (Primary Volume Descriptor) when
  1492.  initializing a CD-ROM. This behavior can be altered for each individual
  1493.  drive to scan for a SVD (Supplementary Volume Descriptor) instead. A CD-ROM
  1494.  drive set to scan for an SVD will use the PVD if there is no SVD present.
  1495.  There can be more than one SVD on a CD-ROM but at present, MSCDEX will only
  1496.  recognize SVDs for shift-Kanji CD-ROMs. Carry will be set, AX will be set to
  1497.  error_invalid_function (1) and DX will be set to 0 if the coded character
  1498.  set is not recognized.
  1499.  
  1500.  If BX contains Get_Preference, MSCDEX will report the present setting for
  1501.  that drive. If DX is still zero on return, that version of MSCDEX does not
  1502.  support this function or reading SVDs. Otherwise DX will contain the
  1503.  setting.
  1504.  
  1505.  If the drive letter is not a CD-ROM drive, carry will be set and
  1506.  error_invalid_drive (15) will be returned in AX. If BX is anything other
  1507.  than Get/Set_Preference, AX will be set to error_invalid_function (1) and
  1508.  carry will be set.
  1509.  
  1510.  Get Directory Entry
  1511.  
  1512.       AX     150Fh
  1513.       CX     CD-ROM Drive letter (A=0, B=1,...Z=25)
  1514.       ES:BX  Pointer to buffer with null-terminated path name
  1515.       SI:DI  Pointer to buffer to copy directory record information
  1516.       AX     0 is returned if the disc is High Sierra, 1 is returned if the
  1517.              disc is ISO-9660
  1518.  
  1519.  The pathname expected is a null-terminated string e.g. char far *path =
  1520.  "\\a\\b\\c.txt"; (note: the "\\" characters map to a single '\' character in
  1521.  C so this would be '\a\b\c.txt' if printed). The path must consist only of
  1522.  valid High Sierra or ISO-9660 filename characters and must not contain
  1523.  any wildcards nor may it include entries for '.' or '..'.
  1524.  
  1525.  The buffer to copy the directory record to can be a maximum of 255 bytes
  1526.  long including all system use information. The directory record is a direct
  1527.  copy from the directory file and it is up to the application to choose what
  1528.  fields to use.
  1529.  
  1530.  Carry will be set and an error code returned if there were problems with the
  1531.  request. The error codes will be error_invalid_drive (15) if the drive
  1532.  letter is incorrect, error_not_ready (21) if the disc didn't initialize
  1533.  correctly, error_file_not_found (2) if the file was not found and
  1534.  error_no_more_files (18) if the pattern fails to find a match or if mscdex
  1535.  failed to allocate buffers.
  1536.  
  1537.  The format of the directory record for High Sierra discs is:
  1538.  
  1539.       /* High Sierra directory entry structure */
  1540.  typedef struct hsg_dir_entry {
  1541.      uchar      len_dr;        /* length of this directory entry  */
  1542.      uchar      XAR_len;       /* length of XAR in LBN's          */
  1543.      ulong      loc_extentI;   /* LBN of data Intel format        */
  1544.      ulong      loc_extentM;   /* LBN of data Molorola format     */
  1545.      ulong      data_lenI;     /* length of file Intel format     */
  1546.      ulong      data_lenM;     /* length of file Motorola format  */
  1547.      uchar      record_time[6];/* date and time                   */
  1548.      uchar      file_flags_hsg;/* 8 flags                         */
  1549.      uchar      reserved;      /* reserved field                  */
  1550.      uchar      il_size;       /* interleave size                 */
  1551.      uchar      il_skip;       /* interleave skip factor          */
  1552.      ushort     VSSNI;         /* volume set sequence num Intel   */
  1553.      ushort     VSSNM;         /* volume set sequence num Motorola*/
  1554.      uchar      len_fi;        /* length of name                  */
  1555.      uchar      file_id[...];  /* variable length name upto 32 chars       */
  1556.      uchar      padding;       /* optional padding if file_id is odd length*/
  1557.      uchar      sys_data[...]  /* variable length system data              */
  1558.      } hsg_dir_entry;
  1559.  
  1560.  The format of the directory record for ISO-9660 discs is:
  1561.  
  1562.       /* ISO-9660 directory entry structure */
  1563.  typedef struct iso_dir_entry {
  1564.      uchar      len_dr;        /* length of this directory entry  */
  1565.      uchar      XAR_len;       /* length of XAR in LBN's          */
  1566.      ulong      loc_extentI;   /* LBN of data Intel format        */
  1567.      ulong      loc_extentM;   /* LBN of data Molorola format     */
  1568.      ulong      data_lenI;     /* length of file Intel format     */
  1569.      ulong      data_lenM;     /* length of file Motorola format  */
  1570.      uchar      record_time[7];/* date and time                   */
  1571.      uchar      file_flags_iso;/* 8 flags                         */
  1572.      uchar      il_size;       /* interleave size                 */
  1573.      uchar      il_skip;       /* interleave skip factor          */
  1574.      ushort     VSSNI;         /* volume set sequence num Intel   */
  1575.      ushort     VSSNM;         /* volume set sequence num Motorola*/
  1576.      uchar      len_fi;        /* length of name                  */
  1577.      uchar      file_id[...];  /* variable length name upto 32 chars       */
  1578.      uchar      padding;       /* optional padding if file_id is odd length*/
  1579.      uchar      sys_data[...]  /* variable length system data              */
  1580.      } iso_dir_entry;
  1581.  
  1582.  The difference between the two forms is the file flag byte moved to account
  1583.  for an additional byte of date and time used for a Greenwich mean time
  1584.  offset. See the May 28th draft of the High Sierra proposal or ISO-9660 for a
  1585.  more complete explanation of the fields. Note that the C structs above are
  1586.  not syntactically correct; C does not allow variable length arrays as struct
  1587.  elements.
  1588.  
  1589.  Send Device Driver Request
  1590.  
  1591.       AX     1510h
  1592.       CX     CD-ROM drive letter (A=0, B=1, ... Z=25)
  1593.       ES:BX  Address of CD-ROM device driver request header
  1594.  
  1595.  This function has been added to simplify communication with CD-ROM drivers
  1596.  and help prevent contention between applications that wish to communicate
  1597.  with the device driver. It is highly recommended that all applications
  1598.  communicate with device drivers through this function request. Applications
  1599.  using this function will not have to locate the device driver. The format of
  1600.  the request header is specified by the Microsoft MS-DOS CD-ROM Extensions
  1601.  Hardware-Dependent Device Driver Specification.
  1602.  
  1603.  ████████████████████████████████████████████████████████████████████████████
  1604.  
  1605.  Networking CD-ROMS
  1606.  
  1607.  Although it is possible to share CD-ROM drives on a local area network or
  1608.  LAN, it is not as easy as it should be. While MS-DOS provides a single,
  1609.  stable platform to develop a file system driver like the Microsoft CD-ROM
  1610.  Extensions, there are a wide variety of LANs and LAN server implementations
  1611.  that do not provide a stable platform for which a file system driver like
  1612.  MSCDEX could be provided. Because each LAN implementation takes a different
  1613.  approach for server support, the approach for CD-ROM support on a server
  1614.  depends on what LAN implementation is being used.
  1615.  
  1616.  This document should help clarify the present situation and help get you
  1617.  started.
  1618.  
  1619.  At present, there are several CD-ROM products that allow sharing of CD-ROM
  1620.  drives on a LAN. LAN support may range from very simple and inexpensive to
  1621.  not so simple and inexpensive. At present, there are three products
  1622.  presently available that offer some form of LAN support. These are:
  1623.  
  1624.    Microsoft      MSCDEX - The Microsoft CD-ROM Extensions
  1625.    Meridian Data  CD-NET
  1626.    Online         Opti-Net
  1627.  
  1628.  Choosing which product depends on your LAN and your needs.
  1629.  
  1630.  There are some LANs, such as Lantastic by Artisoft, that can share CD-ROM
  1631.  drives using any version of MSCDEX on a Lantastic server. This is possible
  1632.  because their servers run as an MS-DOS application and do I/O with standard
  1633.  MS-DOS INT 21 services. LAN servers like this, that do not make assumptions
  1634.  about the underlying media or try to bypass MS-DOS and do use standard MS-
  1635.  DOS INT 21 services to access the drive letter, will likely work with all
  1636.  versions of MSCDEX.
  1637.  
  1638.  There are several LAN products based on MS-NET or a similar LAN server model
  1639.  such as Ungermann-Bass or 3COM. Unfortunately, these products do not access
  1640.  files on the server using standard INT 21 calls and for several reasons due
  1641.  to assumptions inside MS-DOS about non-standard calls from the server, you
  1642.  cannot share CD-ROM drives on MS-NET based servers. Although the server
  1643.  seems to allow sharing of the CD-ROM drive letter, requests to the server
  1644.  from workstations do not work correctly.
  1645.  
  1646.  Fortunately, MSCDEX Version 2.10 has a command line switch (/S) that
  1647.  instructs MSCDEX to patch the in-memory image of MS-DOS during its
  1648.  initialization to fix these problems. By including this parameter on the
  1649.  MSCDEX command line, MSCDEX can be loaded before the network server software
  1650.  is started and the CD-ROM drive letters can then be shared by MS-NET based
  1651.  server software and workstations will see the correct behavior. This
  1652.  solution requires only that the server use MSCDEX Version 2.10 and no
  1653.  software or hardware changes to the workstation. Only the server runs MSCDEX
  1654.  or loads any CD-ROM related device drivers. To the workstation, the CD-ROM
  1655.  server drives are indistinguishable from other server drives.
  1656.  
  1657.  For LAN products that are not MS-NET based yet have NETBIOS support such as
  1658.  Novell or IBM PC-NET, both Optinet and Meridian Data have adapted the MSCDEX
  1659.  and CD-ROM Device Driver model to provide LAN CD-ROM support. Each
  1660.  workstation runs MSCDEX and a special CD-ROM device driver that accepts
  1661.  normal CD-ROM driver requests from MSCDEX and uses the NETBIOS to transmit
  1662.  the command to a network driver on a server that submits the request to a
  1663.  true CD-ROM device driver on the server and transmits the results back to
  1664.  the workstation pseudo CD-ROM driver which in turn responds to MSCDEX. So
  1665.  long as the workstation CD-ROM device driver responds appropriately, MSCDEX
  1666.  is unaware that the command has passed through the network to a server.
  1667.  Contact Meridian Data and Online for information for these networks as they
  1668.  can both describe their products and features best.
  1669.  
  1670.  Online offers one potential configuration for computer systems that do not
  1671.  wish to dedicate a machine to be a server. The workstation operates as above
  1672.  but instead of communicating the workstations driver request to a dedicated
  1673.  server process, another user's workstation running a special TSR version of
  1674.  their system can field the driver request, submit it to the CD-ROM driver,
  1675.  and respond to the requesting workstation. This allows a network of
  1676.  workstations to share the CD-ROM drives that each computer has connected to
  1677.  it at the same time all workstations are available to the users. This option
  1678.  does slow performance of the workstation when outside requests come in and
  1679.  does use up valuable memory for the TSR system code but for some this option
  1680.  may work.
  1681.  
  1682.  At present, there is no available version of the CD-ROM Extensions for OS/2
  1683.  although there is a way to access CD-ROM data in OS/2 on a network. Since
  1684.  from the outside, workstations cannot tell MS-DOS server drives that are
  1685.  shared CD-ROM drives using version 2.10 of MSCDEX from traditional block
  1686.  drives, even OS/2 machines can access the CD-ROM drive on the server.
  1687.  Although this does mean including an MS-DOS server on an OS/2 LAN, it does
  1688.  provide at least an interim way to access CD-ROM data under OS/2 at this
  1689.  time.
  1690.  
  1691.  ████████████████████████████████████████████████████████████████████████████
  1692.  
  1693.  Kanji Support
  1694.  
  1695.  The Kanji support in MSCDEX presently recognizes High Sierra CD-ROM discs
  1696.  with a coded character set that has bit 0 set to 1 in the volume flags
  1697.  indicating at least one escape sequence is not registered according to ISO
  1698.  2375, and has an escape sequence of three bytes in the coded character set
  1699.  for descriptor identifiers field of "$+:". This indicates that the character
  1700.  set is a private multi-byte G3 coded character set and identifies the disc
  1701.  as having shift-Kanji.
  1702.  
  1703.  In order to make MSCDEX scan for the SVD (Supplementary Volume Descriptor)
  1704.  instead of the PVD (Primary Volume Descriptor), there is a new command line
  1705.  argument /K. If this is present, MSCDEX will use the shift-Kanji SVD if it
  1706.  is present, otherwise it will use the PVD. All discs are required by ISO-
  1707.  9660 to have a PVD even if there is an SVD.
  1708.  
  1709.  In addition, there is an accompanying program SVD that can be used to change
  1710.  the default preference each CD-ROM drive has for scanning for a SVD or PVD.
  1711.  The syntax is:
  1712.  
  1713.    SVD [<drive letter>: <std  svd>]
  1714.  
  1715.  Running SVD with no arguments will report the current settings. Including a
  1716.  drive letter and either STD or SVD will change the preference for that drive
  1717.  from one to the other.
  1718.  
  1719.  ████████████████████████████████████████████████████████████████████████████
  1720.  
  1721.  CD-ROMifying Your Software
  1722.  
  1723.  CD-ROM is the first of what will probably be several alien file structures
  1724.  that will start appearing in the MS-DOS world primarily with the
  1725.  introduction of installable file systems under newer versions of DOS. The
  1726.  following will attempt to outline some guidelines for writing software that
  1727.  will help in porting your software to these new file systems and for CD-ROM
  1728.  specifically.
  1729.  
  1730.  
  1731.  Choice of Filename Characters
  1732.  
  1733.  On the first Microsoft Test CD-ROM disc, the Codeview demo failed because
  1734.  certain filename characters that were legal on MS-DOS were not allowed
  1735.  according to the High Sierra file format. When the software looked for file
  1736.  'S1.@@@', it wasn't found because the character '@' is illegal for High
  1737.  Sierra filenames and during High Sierra premastering, the file was renamed
  1738.  'S1'.
  1739.  
  1740.  Valid High Sierra filename characters are the letters 'A' through 'Z', the
  1741.  digits '0' through '9', and the underscore character '_'. All other
  1742.  characters are invalid. Note that the letters 'a' through 'z' are not
  1743.  included so that High Sierra file names are not case sensitive. Under DOS,
  1744.  filenames are mapped to upper case before they are looked up so this is
  1745.  typically not a problem. When choosing file name characters, keep in mind
  1746.  the restrictions of the file structure format and the operating systems your
  1747.  media may be targeted towards.
  1748.  
  1749.  
  1750.  Depth of Path
  1751.  
  1752.  The High Sierra format allows for pathnames to be up to 8 levels deep. It's
  1753.  possible to create a path on MS-DOS that is deeper than that but you won't
  1754.  be able to transfer it to a CD-ROM.
  1755.  
  1756.    \one\two\three\four\five\six\seven\eight\file.txt /* Ok */
  1757.    \one\two\three\four\five\six\seven\eight\nine\file.txt /* Illegal */
  1758.  
  1759.  
  1760.  Length of Path
  1761.  
  1762.  The High Sierra format allows for the entire pathname to be a maximum of 255
  1763.  characters. Since MS-DOS imposes a limit far lower than this, this should
  1764.  not present a problem. The MS-DOS call to connect to a sub-directory is
  1765.  limited to a directory string of 64 characters. The length of path
  1766.  restriction is more a concern for Xenix/Unix than MS-DOS.
  1767.  
  1768.  Amusingly enough, the MS-DOS call to create a sub-directory allows a
  1769.  directory string greater than 64 characters which allows you to create sub-
  1770.  directories that you cannot connect to.
  1771.  
  1772.  Unfortunately, a CD-ROM may potentially contain a pathname that is much
  1773.  larger than 64 characters long. This is not a concern here but is discussed
  1774.  in a related memo - "MS-DOSifying your CD-ROM". As a rule, try to keep the
  1775.  length of your longest path less than 64 characters and you should be pretty
  1776.  safe.
  1777.  
  1778.  
  1779.  Read-only
  1780.  
  1781.  Even though most people understand that CD-ROM discs are read-only, there's
  1782.  still a lot of software written by these same people that assumes the
  1783.  current disk is always writable. For example, the Microsoft Multiplan Demo
  1784.  assumes that it can create and write temporary files to the presently
  1785.  connected drive.
  1786.  
  1787.  In order to avoid this problem, try to provide another means of letting the
  1788.  user specify where temporary files can be created. Many applications check
  1789.  the environment for the variables TMP or TEMP which contain the pathname to
  1790.  use when creating temp files. Most people understand this convention now (or
  1791.  should anyway) and an added benefit will be the speed improvement that will
  1792.  be recognized if the temp directory is located on a ram-drive. If the
  1793.  environment variable is not set, then the application can fall back on the
  1794.  assumption that the media is writable or ask where temporary files should be
  1795.  kept.
  1796.  
  1797.  As a rule, for both temporary and permanent files, if a file creation error
  1798.  occurs, allow the user to re-specify the pathname used so that he can work
  1799.  around the error. The last thing that should happen is for work to be lost
  1800.  because the user was not allowed to store his output in a valid place.
  1801.  
  1802.  
  1803.  Non-DOS Formatted Disks
  1804.  
  1805.  Don't depend on the format of data on the disk. CD-ROM's do not have a FAT
  1806.  so don't even bother looking for one. Do not talk to any media at a physical
  1807.  level (reading/writing sectors) unless you expect to be media dependent
  1808.  (such as CHKDSK or FORMAT). MS-DOS INT 21h calls should provide everything
  1809.  you need to get at the file contents and attributes.
  1810.  
  1811.  
  1812.  Small Directories
  1813.  
  1814.  For performance reasons, try to keep directory sizes smaller than about 40
  1815.  or so. Much beyond this and directory files grow beyond one 2048 byte
  1816.  sector. Typically this is not a problem but if the number of sector buffers
  1817.  chosen when MSCDEX is started is small and the directory files are large,
  1818.  whatever software scanning the directory could potentially thrash badly if
  1819.  every time the directory is searched for the next entry it has to bring
  1820.  earlier directory sectors back into memory from the CD-ROM drive.
  1821.  
  1822.  For certain pathological programs, such as certain implementations of the
  1823.  Xenix utility find, the penalty is about 1 second per directory sector that
  1824.  you have to scan to get to the next entry. If the directory is large, say 8
  1825.  sectors, the time for FIND to scan that one directory could potentially take
  1826.  a half hour for something that would take less than a second if all the
  1827.  entries fit in the cache.
  1828.  
  1829.  The solution for this problem is to make sure that MSCDEX never throws out
  1830.  of the cache what it will need next. This is accomplished by growing the
  1831.  cache (very easy - simply change the parameter to MSCDEX) and to make sure
  1832.  that the largest object that goes through the cache will not clear it out.
  1833.  There is a balance between having too many directories and too many files in
  1834.  a few directories but the balance is heavily weighted towards many small to
  1835.  medium sized directories. Keep this in mind when laying out your files.
  1836.  
  1837.  Since the penalty for using a file in the lowest sub-directory instead of
  1838.  the root-directory is virtually nil and as more directories don't cost much,
  1839.  it's a good idea to break up large directories into several smaller ones.
  1840.  This will help avoid problems of flushing the disc sector cache. Try to keep
  1841.  related files close together both in location on the CD-ROM and in the same
  1842.  directories. Close proximity will reduce seek time when accessing related
  1843.  files at the same time and having them in the same directory will help
  1844.  prevent swapping out directory sectors.
  1845.  
  1846.  
  1847.  Updating CD-ROM Databases and Software
  1848.  
  1849.  Many people are interested in providing updates to files that are contained
  1850.  on a CD-ROM disc. They would like to create a directory on their hard disk
  1851.  with all updated files in them and have the CD-ROM Extensions look there
  1852.  first before searching the CD-ROM. Unfortunately, by the time the Extensions
  1853.  get the request, it is very difficult for it to look for updates on the hard
  1854.  disk so whatever alternative searching that is necessary will have to be
  1855.  done in the application software.
  1856.  
  1857.  For this reason, it's a good idea to have your path set so that it looks
  1858.  through directories on the hard disk first. Another good strategy is to copy
  1859.  executables to a directory on your hard disk so that they can be updated and
  1860.  will also start up faster. Also, have the application software itself search
  1861.  alternative hard disk directories for updates before it searches the CD-ROM.
  1862.  This way both software updates and updated or commonly used database files
  1863.  can be stored on a hard disk which will both speed performance and allow
  1864.  incremental updating.
  1865.  
  1866.  
  1867.  Search Strategies
  1868.  
  1869.  Try to avoid relying on the operating system to be part of your search
  1870.  strategy. If your database is broken up into a hierarchy and your order is
  1871.  imposed through the file structure by breaking up the database into many
  1872.  files in a tree, then accessing data in the database is typically going to
  1873.  require a lot of directory reading and searching.
  1874.  
  1875.  Usually the time involved in doing this on a hard disk is not large but on a
  1876.  CD-ROM, the search times can add up. Opening a file can be an expensive
  1877.  operation simply because the directory must be read before the file can be
  1878.  opened. At best, seeking to a location on the CD-ROM can take 10 msec or so;
  1879.  at worst, a seek can run to over a second on some older CD-ROM drives. Some
  1880.  newer drives have worst case seek of about half a second. Whenever this can
  1881.  be avoided you will save time. MSCDEX caches as many directory sectors as it
  1882.  can so that searching the most active directories is very quick but any
  1883.  operations that search multiple directories once through continually clears
  1884.  out the cache and renders it ineffective.
  1885.  
  1886.  The strategy used by Microsoft Bookshelf was to lump the entire database
  1887.  into a single file and structure the indexing so that searching used a
  1888.  minimum of seeks. Bookshelf uses packed b-trees with each node holding as
  1889.  many entries as will fit into a single sector and also cache in memory as
  1890.  much of the root of the tree as it can.
  1891.  
  1892.  Combining databases avoids the extra overhead of repeatedly opening and
  1893.  closing database files. Caching as much of the indexes in memory as possible
  1894.  allows searching of keywords to be completed typically with a single seek.
  1895.  
  1896.  In general, identify your software bottlenecks and through judicious use of
  1897.  faster storage media (either memory or hard disk) you can both have large
  1898.  storage and respectable performance.
  1899.  
  1900.  
  1901.  Portability
  1902.  
  1903.  One of the advantages of the High Sierra format is data interchangeability
  1904.  with other operating systems. One must take care to chose a subset of the
  1905.  range of High Sierra features that are presently supported across different
  1906.  operating systems to be sure you can read the disc in each of them. The
  1907.  lowest common denominator then (this list is not complete - see also what
  1908.  must be done to target MS-DOS) would need a logical block size of 512 bytes,
  1909.  both type L and M path tables and for all fields, single volume sets, at
  1910.  least one primary volume descriptor and terminator. Be aware that if one of
  1911.  your goals is data portability, you will have to do some additional research
  1912.  to see what restrictions on the High Sierra format other operating systems
  1913.  may impose.
  1914.  
  1915.  ████████████████████████████████████████████████████████████████████████████
  1916.  
  1917.  MS-DOSifying Your CD-ROM
  1918.  
  1919.  Most of the following caveats apply to the present version of the Microsoft
  1920.  CD-ROM Extensions. Future versions of the extensions are expected to support
  1921.  many of the features listed below that are at present best avoided. The
  1922.  behavior of the extensions with fields and records that are presently
  1923.  ignored may change at any time.
  1924.  
  1925.  Correctness
  1926.  
  1927.  Make sure that your disc is in valid High Sierra format. Nothing is
  1928.  guaranteed if your disc is not in valid format. Surprisingly enough, we have
  1929.  received several discs that have one or more illegally formatted data areas
  1930.  ranging from directories being sorted incorrectly, incorrect path table
  1931.  sizes, incorrect directory file sizes, directories missing from the path
  1932.  table, invalid directory names, etc. In almost every case, the Extensions
  1933.  will behave incorrectly and at worst, the system will crash.
  1934.  
  1935.  In addition to running validation software to verify the High Sierra image,
  1936.  one should also verify that the Extensions work with your CD-ROM disc and
  1937.  application software before distributing it. Unfortunately, it may not
  1938.  matter if your disc is correct and the Extensions are wrong if they don't
  1939.  work together. Please report any and all problems you think are in the
  1940.  Extensions to Microsoft so that they can be fixed.
  1941.  
  1942.  Pathtable and Directory Sizes
  1943.  
  1944.  This bears repeating because many people have gotten it wrong. Directory
  1945.  file sizes are always a multiple of the logical sector size - 2 kilobytes.
  1946.  Path table sizes are always the exact number of bytes that are contained in
  1947.  the path table which is typically not a multiple of 2k. You must not have
  1948.  blank directory sectors and the directory length must reflect the correct
  1949.  length of the directory file. The directory sectors always begin on a
  1950.  logical sector boundary.
  1951.  
  1952.  8.3 File Names
  1953.  
  1954.  MS-DOS cannot handle longer than 8.3 filenames. If the CD-ROM filename is
  1955.  longer than 8.3, then the filename will be truncated. If this happens, two
  1956.  files that are not unique within 8.3 characters will map to the same
  1957.  filename. For example:
  1958.  
  1959.    filename1.txt will appear as filename.txt
  1960.    filename2.txt will also appear as filename.txt
  1961.  
  1962.  Kanji filenames are also limited to 8.3 or 4.1 kanji characters. Only shift-
  1963.  kanji filenames are recognized at present. To get kanji, you must specify a
  1964.  supplementary volume descriptor indicating you have kanji filenames. Contact
  1965.  Microsoft to find out how this is done.
  1966.  
  1967.  Record Formats
  1968.  
  1969.  The extensions do not support any record formats so if the RECORD bit is set
  1970.  in the file flags byte in the directory entry for a file, it will be
  1971.  ignored.
  1972.  
  1973.  Interleaving
  1974.  
  1975.  In the present version, the Extensions do not support interleaving so if the
  1976.  Interleave size and Interleave factor are non-zero, the file will ignore
  1977.  these fields and return erroneous data.
  1978.  
  1979.  Multi-Extent Files
  1980.  
  1981.  Multi-extent files are not supported in the present version. Each extent of
  1982.  a multi-extent file will appear as a separate file with the same name.
  1983.  
  1984.  Multi-Volume
  1985.  
  1986.  Multi-volume disc sets are not supported in the present version. Directories
  1987.  that are located on another volume could potentially cause the Extensions to
  1988.  crash if searched and erroneous data will be returned for files that are
  1989.  located on another volume.
  1990.  
  1991.  Coded Character Sets
  1992.  
  1993.  Only one coded character set or supplementary volume descriptor is
  1994.  recognized in the latest version. This is for shift-Kanji.
  1995.  
  1996.  Version Numbers
  1997.  
  1998.  Version numbers are not supported by the Extensions. The Extensions will
  1999.  strip the version string off the end of the filename so that two identical
  2000.  filenames with different versions will appear to have the same name. There
  2001.  is no way to specifically ask for any but the first instance of that
  2002.  filename. Two files with the same name and different version numbers have
  2003.  the same accessing problem as two files with longer than 8.3 filenames that
  2004.  have been truncated to the same filename.
  2005.  
  2006.  Protection
  2007.  
  2008.  Protection bits are not used on MS-DOS. If the protection bit is set in the
  2009.  file flags byte in the directory entry for a file though, the file will not
  2010.  show up on any search or open even if the protection bits in the XAR are set
  2011.  to allow all access.
  2012.  
  2013.  No XAR Support
  2014.  
  2015.  At present, the Extensions ignore the contents of any XAR record.
  2016.  
  2017.  Motorola Format Tables
  2018.  
  2019.  The additional copies of the path table and any values in "Motorola" format
  2020.  (most significant bytes using the lowest address values) are ignored at
  2021.  present. MSCDEX only pays attention to "Intel" formatted values. They should
  2022.  be included though for portability sake.
  2023.  
  2024.  Multiple Copies of the Path Table
  2025.  
  2026.  The Extensions presently only read and use the first copy of the path table.
  2027.  Later versions may check to see that copies of the path table agree.
  2028.  
  2029.  Additional Volume Descriptor Records
  2030.  
  2031.  Boot records and Unspecified volume descriptors are ignored. The first
  2032.  standard volume descriptor found is the one that is used. Additional copies
  2033.  are ignored at present.
  2034.  
  2035.  File Flags
  2036.  
  2037.  The existence bit is treated the same as the hidden bit on MS-DOS. Some
  2038.  other operating systems may not handle the existence bit so you may not want
  2039.  to use it if you are targeting these systems. The directory bit for High
  2040.  Sierra is treated the same as the directory bit in MS-DOS. Files with the
  2041.  protection bit set are not found when searched for or opened.
  2042.  
  2043.  None of the remaining bits, (Associated/Record/Multi-extent/Reserved), are
  2044.  handled at present. Using files with these bits set will have undefined
  2045.  behavior.
  2046.  
  2047.  Unique Volume Identifiers
  2048.  
  2049.  It is highly recommended that the volume identifier be unique. The
  2050.  Extensions use the volume identifier to do volume tracking and to double-
  2051.  check to see if the disc has changed. The more chance that users will have
  2052.  two discs with the same volume identifier, the more chance that this will
  2053.  confuse the Extensions and lead it to believe that the disc has not changed
  2054.  when in fact it has.
  2055.  
  2056.  It is also highly recommended that application programs use the volume label
  2057.  to tell if the CD-ROM disc has changed. The volume label for a CD-ROM on MS-
  2058.  DOS is obtained from the volume identifier field in the primary volume
  2059.  descriptor. The call to get the volume label is very inexpensive to make
  2060.  once the CD-ROM has been initialized and will cause no disc I/O to be done
  2061.  unless the media has changed. This is the best way for an application to
  2062.  tell if the disc it wants to work with is in the drive. The application
  2063.  software should not communicate with the driver or drive to determine if the
  2064.  media has changed or the Extensions may not learn that the disc has changed
  2065.  and will not reinitialize what it knows about the new disc.
  2066.  
  2067.  Many Small Directories or A Few Large Directories
  2068.  
  2069.  As a rule, it is better to have many small directories that contain fewer
  2070.  files than one very large directory. The answer depends on your
  2071.  application's behavior because if you try very hard, you can thrash almost
  2072.  as badly with many small subdirectories as you can with one large
  2073.  subdirectory. Reading further will help explain.
  2074.  
  2075.  What makes the difference? For each file open, suppose you have 1000
  2076.  subdirectories with 40 files, on average you'll read about one sector per
  2077.  file open and scan 1/2 of it. On the other hand, you could have 1 directory
  2078.  with 4000 files. On average, each file open in this large directory (about
  2079.  100 sectors) will involve scanning about 50 sectors to open that one file.
  2080.  As long as it is very inexpensive to get to each directory through the
  2081.  pathtable, clearly it is much better to have many small directories.
  2082.  
  2083.  Further improvements can be made by grouping files that are related and will
  2084.  be opened together in each of these subdirectories so that as you open each
  2085.  successive file, the directory sector is very likely in the disc cache and
  2086.  this will help minimize hitting the CD-ROM disc.  Putting each file in a
  2087.  separate subdirectory is extreme and will cost you because you will never
  2088.  gain the benefits of locating the next file in a directory sector that has
  2089.  already been cached and you will needlessly enlarge the pathtable.
  2090.  
  2091.  There is a limit though to how many subdirectories you may want because if
  2092.  there are too many you may end up thrashing on the pathtable sectors. Each
  2093.  pathtable sector holds pointers to approximately 100 to 200 directory files
  2094.  depending on the directory name lengths. If you have a pathtable that is 10
  2095.  sectors long, you will want at least 10 sectors of memory buffers to hold
  2096.  the pathtable or you may risk re-reading sections of the pathtable on every
  2097.  file open which will be very costly.
  2098.  
  2099.  The most important point you can learn is that you can vastly improve your
  2100.  file open speed by making sure you have enough memory buffers. If you are
  2101.  repeatedly trying to scan a 10 sector directory file (approximately 400
  2102.  entries) and you only have 4 sectors in the sector cache, the cache is going
  2103.  to work against you because you will end up churning it to death. If you
  2104.  allocate 14 sectors for example (/M:14), then the whole directory file will
  2105.  find its way into the cache and you will stop hitting the disc. The
  2106.  difference in speed may be several orders of magnitude. A safe bet is to
  2107.  recommend reserving as many sectors are in the pathtable plus the number of
  2108.  sectors for the largest directory plus 2. The last two are reserved for data
  2109.  sectors and internal dynamic data. This formula is complicated with multiple
  2110.  drives because the buffers are not tied to specific drives and are shared
  2111.  and because not all drives are active at the same time.
  2112.  
  2113.  Another rule, do not rely on the file system to do your searching for you.
  2114.  If you are performance conscious, finding a chunk of data by looking for it
  2115.  with a file name through the file system is expensive if speed is a great
  2116.  concern. 99% of the time, locating data through the file system is fine
  2117.  because the cost is a single one time operation but if this is repeated
  2118.  often enough, it may pay to do some of the work yourself. What can be better
  2119.  is lump everything into one big file and cache your own hierarchy, indexing,
  2120.  binary trees, or whatever searching scheme you choose to use to get you to
  2121.  the data you need rather than asking for the file system to tell you where
  2122.  it is.
  2123.  
  2124.  ████████████████████████████████████████████████████████████████████████████
  2125.  
  2126.  Questions and Answers
  2127.  
  2128.  Q: Does the /V option to MSCDEX actually cause a message to be displayed? I
  2129.  can't make it do anything. I use:
  2130.  
  2131.    MSCDEX /D:CDDRV /V /M:8
  2132.  
  2133.  A: Yes, a series of statistics are displayed. MSCDEX uses INT 10 function
  2134.  0eH to write to the console so if for some reason you are trapping this or
  2135.  have software that captures this and doesn't display bios output to the
  2136.  screen the information will not appear. All screen output uses this function
  2137.  so if any output appears on the screen after loading MSCDEX, It is not clear
  2138.  why this additional information does not appear.
  2139.  
  2140.  Newer versions (2.0 and above) use the DOS write handle call for output
  2141.  which will fix problems of I/O redirection of this output.
  2142.  
  2143.  As it turned out, the machine that had this problem was not a strict IBM
  2144.  compatible machine and did not emulate a PC at the BIOS level. Consequently,
  2145.  the messages written with INT 10h were not displayed.
  2146.  
  2147.  Q: Is it normal for MSCDEX to hang the system if an error is returned by a
  2148.  driver's IOCTL function? Wouldn't an error message be better?
  2149.  
  2150.  A: The only ioctl calls sent to the driver in version 1.01 are to request
  2151.  the device header address and media check. Media check calls will never hang
  2152.  no matter what is returned so long as the driver returns. Illegal values may
  2153.  not do what you want but it won't hang. Request device header address may
  2154.  hang if the driver fails to set error conditions correctly as DOS expects
  2155.  them as DOS will return from my ioctl call without error. MSCDEX will then
  2156.  assume the bogus return values are correct and jump to a random location.
  2157.  
  2158.  Q: Does MSCDEX do anything that should preclude its working in a non-IBM-
  2159.  clone machine?
  2160.  
  2161.  A: Except for the INT 10 problem mentioned earlier, no. If you can identify
  2162.  any problems whatsoever, we would be happy to learn about it but as yet, we
  2163.  have heard of no other problems. If your machine runs MS-DOS version 3.X,
  2164.  it should be capable of running the extensions correctly. As for
  2165.  driver/drive-controller compatability problems, that may be another matter.
  2166.  We do not guarantee anything about these because we do not write the device
  2167.  drivers or design the hardware interface boards and cannot make any claims
  2168.  concerning them. It is up to the drive manufacturer or device driver writer
  2169.  to do this kind of compatability testing.
  2170.  
  2171.  Q: Based on what I read in the spec, I decided to support only HSG type
  2172.  addressing which seems to be allowed by the IOCTLI function #6 (Device
  2173.  Status). I return 4 bytes of 00h if that function is called. I would have
  2174.  thought that would be one of the first calls MSCDEX would make (after "Find
  2175.  Header") but so far it hasn't called the status function. How will MSCDEX
  2176.  know enough not to use Red Book addressing if it doesn't check status
  2177.  first?
  2178.  
  2179.  A: In version 1.01, ioctl function #6 is not called. This is not to say that
  2180.  in a future versions it will not (in fact it will). Since all device drivers
  2181.  must support some default functionality and as MSCDEX only uses the basic
  2182.  default now (only High Sierra addressing for example), it wasn't a problem
  2183.  that it didn't call this function to find out about non-default features
  2184.  that were supported.
  2185.  
  2186.  Some software is being written that controls audio on a CD-ROM that expects
  2187.  Red Book Addressing and checks the device status to see that it is
  2188.  supported. The conversion algorithms are fairly simple and code fragments
  2189.  are provided.
  2190.  
  2191.  Q: Can you provide more info on how the READ/WRITE device control string
  2192.  should work. Does the read device bytes command get information that was
  2193.  written by the write device control string?
  2194.  
  2195.  A: As of yet, no one to our knowledge has used this. There are a couple
  2196.  other features of which this can be said. Again, this is not to say that
  2197.  they won't be used at some later time.
  2198.  
  2199.  The purpose of these commands was to allow a standard way of delivering
  2200.  commands that were not specified in the CD-ROM device driver spec to the
  2201.  drive. For example, sending SCSI command strings and reading the responses
  2202.  from the drive. This function is deliberately open-ended and vague because
  2203.  it was intended to provide a catch-all mechanism for application programs to
  2204.  communicate requests or request data in ways that were not specified by the
  2205.  device driver spec. For application programs to use these functions they
  2206.  have to know the driver supports these functions and also how to communicate
  2207.  with that specific drive. The mechanism would let the driver do what it does
  2208.  best and worry about which ports and interrupts to use. This relieves the
  2209.  application program from these details and allow it to deal with controlling
  2210.  the device at a higher level.
  2211.  
  2212.  Right now, if the driver does not support these functions, it should
  2213.  return an error for Unknown Command. One could test whether these two
  2214.  function were supported this way.
  2215.  
  2216.  ───────────────────────────────────────────────────────────────────────────
  2217.  Note:
  2218.    If there are commands which you feel should be supported by the device
  2219.    driver specification, please communicate them to us and we will consider
  2220.    adding them if they are of sufficient general interest.
  2221.  ───────────────────────────────────────────────────────────────────────────
  2222.  
  2223.  Q: The version of MSCDEX I am using is 1.01 dated 3/20/87@11:06am and is
  2224.  marked Evaluation Copy. Is this any less functional than a "licensed" copy?
  2225.  
  2226.  A: No. There may be a few more bug fixes in the licensed copy that are not
  2227.  in the Evaluation copy but none that should prevent correct operation. If
  2228.  you do find any bugs, please let us know as we will fix any bugs in the
  2229.  software that are reported. Our policy is to try to reward users that report
  2230.  bugs with updates of the software that fix their problem.
  2231.  
  2232.  Q: Would it be possible for me to get a sample source file for a driver?
  2233.  
  2234.  A: Yes. Licensees are given source code to device drivers for:
  2235.  
  2236.       SONY    - complete
  2237.  
  2238.       HITACHI - missing two modules. These are owned by Hitachi so we
  2239.                 cannot supply them, though Hitachi will.
  2240.  
  2241.       PHILIPS - this driver communicates with the Philips CD-ROM driver
  2242.                 supplied by Philips.
  2243.  
  2244.  Q: How can an application access CD-ROM drives that are subunits of one
  2245.  driver? The IOCTL calls do not take an argument for subunit. MSCDEX seems to
  2246.  handle this OK since when I do a directory of each CD-ROM in turn it
  2247.  accesses the correct drive. I do not see any clean way for an application
  2248.  to, for example lock the door on CD-ROM drive G: which is the third drive
  2249.  handled by the driver.
  2250.  
  2251.  A: Requests all have a sub-unit field in the request header. Commands that
  2252.  one would expect to be directed to a specific drive, such as open door, are
  2253.  targeted at a particular drive through the use of the sub-unit field.
  2254.  
  2255.  Q: What is the current release version number of MSCDEX? The version I have
  2256.  is version 1.01 that is marked EVALUATION COPY. When can I get a final
  2257.  release version of it? Also will that final version include the changes to
  2258.  do all I/O through MSDOS (i.e. no INT 10h).
  2259.  
  2260.  A: The most recent released version is version 2.0. You can purchase this
  2261.  from a number of licensees including all drive manufacturers. An Extensions
  2262.  availability list is attached.
  2263.  
  2264.  Q: Why doesn't MSCDEX allow IOCTL access via the drive letter (i.e. DOS
  2265.  func. 44h subfunc. #4,5), as if the CD-ROM were a drive. I understand that
  2266.  the driver is not a block device, but this is being handled already in some
  2267.  way since you allow a user to perform file I/O to a CD-ROM making it appear
  2268.  to be a block device. It would seem that all that would be necessary to
  2269.  accomplish this is to intercept IOCTL calls in the same way that file access
  2270.  calls are being intercepted.
  2271.  
  2272.  A: MSCDEX doesn't presently hook int 21h, which is what this would involve.
  2273.  It's doubtful that this will change. It's not that much more difficult to
  2274.  open the file and send an IOCTL to the handle. File access calls are not
  2275.  caught at an INT 21h level but are caught from within DOS at another
  2276.  interface. CD-ROM drives are far more like network drives than traditional
  2277.  MS-DOS FAT file structure block drives and their drivers. For example, try
  2278.  to FORMAT a CD-ROM drive and you'll see. Part of all this prevents IOCTL's
  2279.  to the drive letter from being directed to the appropriate driver.
  2280.  
  2281.  Q: Why not allow access to the PLAY, STOP and SEEK functions via the INT 2Fh
  2282.  entry point as is allowed for READ LONG. This would be much simpler than
  2283.  requiring the application to locate the driver header and then find the
  2284.  STRATEGY entry point and create request control blocks etc. This is a lot of
  2285.  code to start the music playing!
  2286.  
  2287.  A: It's preferable to see MS-DOS provide extensions to the application
  2288.  program interface for audio/video control (new int 21h calls). The reason we
  2289.  haven't included play, etc. in the int 2Fh interface is to avoid loading
  2290.  down MSCDEX with additional functionality that most people don't use. Your
  2291.  suggestion would only move that code from the CD-playing program into
  2292.  MSCDEX. It makes your program smaller, but in the whole, doesn't buy much.
  2293.  As time goes on, this may change and some of the functionality may move into
  2294.  the int 2Fh interface.
  2295.  
  2296.  Q: Shouldn't the specification eliminate the need for the application to
  2297.  OPEN the driver by name, This is especially important in systems where the
  2298.  driver creates a new driver header for each CD-ROM drive. MSDOS allows so
  2299.  few file handles to be simultaneously open as it is that requiring
  2300.  applications to open even more is very bad.
  2301.  
  2302.  A: Simply close the driver handle after you have located the device header.
  2303.  You no longer need to communicate through DOS to control it, so free the
  2304.  handle and make it available for other programs to use. With version 2.10,
  2305.  it is no longer necessary to OPEN the device driver in order to communicate
  2306.  with it. Applications can communicate with the device driver using Send
  2307.  Device Driver Request.
  2308.  
  2309.  Q: Have you considered adding an addressing mode for the PLAY AUDIO function
  2310.  that would allow the application to specify the PLAY address by TNO instead
  2311.  of block number or min/sec/frame?
  2312.  
  2313.  A: This has been considered but has not been added to keep from complicating
  2314.  the device drivers unnecessarily. At the moment, most CD-ROM drives are used
  2315.  without audio so our intent was to put what was needed for audio support in
  2316.  the audio playing software. In addition, we chose to keep the interface
  2317.  simple to leave more latitude for changes to the OS/2 API that may include
  2318.  newer data types like audio and video. Nonetheless, this may be added in the
  2319.  future. In the meantime, audio playing software has the extra overhead of
  2320.  reading the audio table of contents and interpreting the tracks itself.
  2321.  
  2322.  Q: Why is there no CLOSE TRAY function in the driver spec? The CD-ROM drive
  2323.  we are using (Toshiba SCSI) has this capability but I see no way to use it
  2324.  via the extensions. Why allow the user to OPEN it without allowing him to
  2325.  close it?
  2326.  
  2327.  A: A close tray command has been added.
  2328.  
  2329.  Q: It seems that there should be bits in the Device Status word to indicate
  2330.  whether a driver supports Reading/Writing device control strings.
  2331.  
  2332.  A: Reading and writing device control strings was put it in as a catch-all
  2333.  for anything that was missed so that application programs could send
  2334.  specific commands through the device driver to the device if they understood
  2335.  the device and knew how to communicate to it. A manufacturers CD-ROM
  2336.  diagnostic program would be an example of a program that might choose to
  2337.  communicate with the drive in this way. If the driver does not support these
  2338.  functions, it should return an error. One can test whether these two
  2339.  function are supported by testing if the error returned is for Unknown
  2340.  Command.
  2341.  
  2342.  Q: In the spec, treatment of the BUSY bit in the status word with regard to
  2343.  the PLAY AUDIO function seems to assume only one CD-ROM drive. What happens
  2344.  when the user has two or more drives each of which want to be playing music?
  2345.  How does the application tell whether the desired drive is busy? It would
  2346.  seem better to use some of the bits in the upper word of Device Status to
  2347.  indicate BUSY for each drive. Perhaps allowing 8 or 16 drives.
  2348.  
  2349.  A: Requests all have sub-unit numbers associated with them. A request for
  2350.  service from one sub-unit may report that the drive is busy at the same time
  2351.  another sub-unit was not busy. The sub-unit field is used to distinguish
  2352.  requests between the drives supported by the driver. The busy bit serves as
  2353.  an indication of drive status for the sub-unit the request is for.
  2354.  
  2355.  Q: If a CD-ROM file is opened in write-only mode, no error occurs.
  2356.  
  2357.  A: True. The same happens on a floppy drive with a write-protect tab on it.
  2358.  If you do have a handle to a CD-ROM file in open_for_write mode, as soon as
  2359.  you attempt to write, you will get an error. The correct model is to
  2360.  duplicate the behavior of a file that has been set READ-ONLY. Read-only
  2361.  files return error_access_denied if you try to open them in open_for_write
  2362.  or open_for_both modes. MSCDEX has been changed to duplicate this behavior.
  2363.  
  2364.  Q: What other non-MSDOS calls are issued by MSCDEX besides INT 10h?
  2365.  
  2366.  A: INT 2Fh - dos callbacks
  2367.     INT 67h - expanded memory
  2368.     INT 10h - all INT 10h calls went away with version 2.00 which uses DOS
  2369.               write handle instead.
  2370.  
  2371.  Q: Why does MSCDEX do the READ LONG PREFETCH call after it has done a DEVICE
  2372.  CLOSE call? Is this intentional?
  2373.  
  2374.  A: MSCDEX version 1.X never issued device open or close. These were issued
  2375.  by DOS as part of driver initialization. MSCDEX version 2.00 now issues
  2376.  device open calls and will precede the prefetch call.
  2377.  
  2378.  Q: In the device driver spec, it says that if more than one unit is
  2379.  supported by the driver that this field should be set to the number of
  2380.  units. I suspect that this is wrong since this is not a block device. As far
  2381.  as I can see, this field should only ever be set to one since each unit will
  2382.  actually have its own header with its own unique name.
  2383.  
  2384.  A: CD-ROM device drivers are a hybrid of block and char device drivers and
  2385.  are not technically legal as one or the other. Block drivers make some
  2386.  assumptions about the media format that aren't meaningful for CD-ROM and
  2387.  don't have a read call that can deal with CD-ROM's large data space. They
  2388.  were made as char devices with some additional calls and rules. One of the
  2389.  changes that was made for CD-ROM device drivers was to allow multiple sub-
  2390.  units for the device so the treatment of this field is correct as specified
  2391.  even though CD-ROM device drivers are character device drivers.
  2392.  
  2393.  If one has more than one CD-ROM drive, one can approach supporting them
  2394.  from several ways. One could have separate device drivers for each drive and
  2395.  load one per drive, have a single driver with multiple device headers, or
  2396.  have a single driver with one device header that supports sub-units. This
  2397.  last method is borrowed from block drivers. For the case that the drives and
  2398.  drive commands are all the same, using sub-units will allow you to
  2399.  distinguish between which drive receives which command. The alternatives
  2400.  clutter things up with drivers or device headers. Sub-units may not be legal
  2401.  character device driver fields but conceptually, they're the right thing.
  2402.  Since CD-ROM device drivers could not be block drivers and had to be char
  2403.  device drivers, some liberties were taken with the specification to merge
  2404.  the best of both specifications.
  2405.  
  2406.  Q: Is there any support through MSCDEX for WRITE LONG? I have a need for
  2407.  this to support a CD mastering system. I would like to be able to treat a
  2408.  WORM drive as a CD-ROM and allow writing to the drive once to create a
  2409.  master and then be able to test it out by using it as CD-ROM to verify that
  2410.  our data has been correctly stored in "High Sierra" format.
  2411.  
  2412.  A: Such a call exists. It only serves to define a standard interface for CD-
  2413.  ROM device drivers that are running over re-writable media──such as a CD
  2414.  mastering system. It is in the latest copy of the driver spec released with
  2415.  version 2.00 of the CD-ROM Extensions.
  2416.  
  2417.  Q: How important is it that I should support RAW mode access in my driver?
  2418.  What would this typically be used for?
  2419.  
  2420.  A: Not important now. No drive presently support reading raw at the moment
  2421.  that we know of. Since drives and their command capabilities are hardware
  2422.  dependent, you would know based on the capabilities of your hardware if you
  2423.  wanted to support it. This function was added for completeness. A standard
  2424.  way was needed to define how to get at the 288 bytes of EDC/ECC if drives
  2425.  allowed access and to have an avenue prepared if people found useful
  2426.  applications that would not use EDC/ECC where they wanted the additional
  2427.  space (such as gracefully degrading low-fidelity audio or graphics). It will
  2428.  be useful for copying audio information or for audio systems that will want
  2429.  to be able to manipulate audio tracks. Many people have expressed interest
  2430.  in having this capability.
  2431.  
  2432.  Q: Driver spec page 13 (in the structure for the UPC Code function): "The
  2433.  UPC/EAN code (last 4 bits are zero)". Does this mean the low order or high
  2434.  order 4 bits?
  2435.  
  2436.  A: This is less ambiguous if you read Red Book under mode-2 of the Q-channel
  2437.  info. This is now clarified in the UPC Code call. It should be the low
  2438.  nibble of byte 7. Red Book specifies that MSB comes out first so the high
  2439.  nibble will contain the 13th nibble of the UPC code and the 14th nibble will
  2440.  be zero.
  2441.  
  2442.  Unfortunately, scanning for the UPC code is time consuming especially if
  2443.  it is done by the software. This is due to the design of the q-channel in
  2444.  Red Book. It's a pity because this could be a useful number to verify the
  2445.  correct disc has been inserted. Most CD-ROMs do not have a UPC code or have
  2446.  it zeroed out. The same seems to be true for CD-audio as well. We believe
  2447.  that CD-ROM drives should scan for the UPC code as they read the Table of
  2448.  Contents when initializing from power up or a new disc. If the hardware does
  2449.  not do this, the UPC code has to be scanned by polling the q-channel which
  2450.  may occasionally miss the UPC code.
  2451.  
  2452.  Q: It would be nice if the device driver spec included a list of what types
  2453.  of disk access functions would and would not work so that users could get an
  2454.  idea of what utilities and applications will and will not work with the
  2455.  extensions.
  2456.  
  2457.  A: The device driver specification describes just what is necessary for
  2458.  writing a CD-ROM device driver. The information you would like concerning
  2459.  things such as INT 25h/26h not supported as well as the behavior
  2460.  CHKDSK/FORMAT/etc belongs and is mentioned in the MSCDEX overview.
  2461.  
  2462.  Q: If I have a low priority request and if the system has time, can the
  2463.  prefetch request read into and transfer the data into a transfer address?
  2464.  
  2465.  A: We have looked at this for some time but the bottom line is that
  2466.  asynchronous I/O under DOS is virtually impossible to support in all cases.
  2467.  Because of this it is unlikely we will be implementing this or designing it
  2468.  into the device driver interface. There is no way for MSCDEX or the CD-ROM
  2469.  device driver to know that the transfer address is still valid because DOS
  2470.  never notifies MSCDEX or the device driver if the requesting process was
  2471.  been terminated. The request runs the risk of writing over another program.
  2472.  The best approach now is if the driver wants to, it can reserve internal
  2473.  buffer space for data from the disc and put prefetched data there. Then it
  2474.  can copy the data to the read transfer address once the read request finally
  2475.  arrives. Alternately, some of the caching or prefetching can reside in the
  2476.  CD-ROM controller or in the drive itself. True asynchronous reads will have
  2477.  to wait for OS/2.
  2478.  
  2479.  Q: Is there any status indication that the transfer has occurred? or some
  2480.  interaction with the read long command?
  2481.  
  2482.  A: There is no way to tell if a prefetch request was successful or the state
  2483.  of it. The prefetch simply provides a hint and the read request later is the
  2484.  request that finally expects delivery of the data.
  2485.  
  2486.  Q: Read (ioctl input) When audio is playing, can location of head move?
  2487.  
  2488.  A: I'm not entirely sure what you mean by this question but I will attempt
  2489.  to answer a couple different ways and hope I provide the information you
  2490.  need.
  2491.  
  2492.  While audio is playing, the head is moving on the CD. If the driver
  2493.  receives a command asking where the head is, the driver should ask the drive
  2494.  where the head is presently positioned and report that. So as audio is
  2495.  playing, an application program that is controlling the audio can monitor
  2496.  the progress of audio playback and can either synchronize actions with the
  2497.  audio or report the present location to the user. For example, a program to
  2498.  play audio discs would be able to report the present track number and time
  2499.  elapsed on the computer monitor much like a CD-audio player reports things
  2500.  on its LED display. If the driver is sent a command that requires the
  2501.  movement of the head or a change in the state of the machine (SEEK, READ,
  2502.  INITIALIZE, PLAY AUDIO etc.) then the audio will be interrupted so that the
  2503.  drive can perform the new request. If the drive receives a command for
  2504.  status or some other function that does not require the head to be moved or
  2505.  the state of the machine to change, then audio play should continue.
  2506.  
  2507.  Q: Are the parameters of Audio Disk Info and Audio Track Info BCD or
  2508.  binary?
  2509.  
  2510.  A: The parameters were vaguely specified in the device driver spec. The spec
  2511.  has been clarified. They are as follows:
  2512.  
  2513.    ■  Audio Disk Info
  2514.            binary    Lowest Track Number (1-99)
  2515.            binary    Highest Track Number (1-99)
  2516.            red book  Starting point of lead-out track
  2517.  
  2518.    ■  Audio Track Info
  2519.            binary    Track Number (1-99)
  2520.            red book  Starting point of track
  2521.            as is     Track control information
  2522.  
  2523.  The track control information is not a BCD or Binary number like the track
  2524.  number. The byte contents as it appears on the disc should be carried
  2525.  through unmodified by the driver and is interpreted according to the
  2526.  Philips/Sony Red Book standard.
  2527.  
  2528.  Q: Are the parameters for the Audio Q-channel info BCD or binary?
  2529.  
  2530.  A: The parameters are as follows:
  2531.  
  2532.    ■  Audio Q-Channel Info
  2533.            as is     Control and ADDR byte
  2534.            as is     Track Number
  2535.            as is     Point or Index (X)
  2536.  
  2537.            red book  MIN/SEC/FRAME
  2538.            zero      ZERO
  2539.            red book  AMIN/ASEC/AFRAME or PMIN/PSEC/PFRAME
  2540.  
  2541.  The notes on when to convert from BCD to red book addresses for
  2542.  MIN/SEC/FRAME, AMIN/ASEC/AFRAME and PMIN/PSEC/PFRAME is already fairly clear
  2543.  in the spec. The other fields are passed through as is from the disc. For
  2544.  additional information, see the two code samples AUDIO.C and AUDIO.ASM.
  2545.  
  2546.  Q: Must we support read sub-channel info and the read upc code?
  2547.  
  2548.  A: No. It is not necessary that these be supported. At the present time and
  2549.  in the forseeable future, MSCDEX will not be issuing these commands though
  2550.  some applications may wish to.
  2551.  
  2552.  Read Sub-Channel Information
  2553.  At the present time, nobody is using channels P or R through W. The read
  2554.  sub-channel command was added to provide a standard way to specify access to
  2555.  these channels in the event that they are used and to specify in one way or
  2556.  another access to all information on a CD-ROM. The error detection or
  2557.  correction for information in these channels is not as good as it is for
  2558.  data returned from READ commands.
  2559.  
  2560.  Read UPC Code
  2561.  This command is conceivably much more useful. It is advised that it be
  2562.  supported so that application software can exactly identify the CD-ROM in
  2563.  the drive. This may be a consideration for audio software that wishes to try
  2564.  to identify inserted audio discs (if the UPC code is present) or for
  2565.  software that is specifically tied to a version of a CD-ROM. Unfortunately,
  2566.  the standard does not specify a specific location for this information so
  2567.  that unless the hardware reads it on disc initialization as we recommend,
  2568.  the device driver must poll the q-channel and hope that it locates it. See
  2569.  also the sample code in AUDIO.ASM.
  2570.  
  2571.  Q: My driver seems to work ok except that whenever I connect to a sub-
  2572.  directory and do a directory, I am suddenly back in the root directory
  2573.  again. What's going wrong?
  2574.  
  2575.  A: What is most likely happening is the driver is returning an incorrect
  2576.  value for MEDIA CHECK and MSCDEX thinks that the disc is changing all the
  2577.  time. When this happens, MSCDEX rereads the volume descriptors and pathtable
  2578.  and reinitializes what it knows about the disc and changes the current
  2579.  working directory back to root as if the drawer had been opened, the disc
  2580.  removed, and then reinserted. This will be accompanied with a larger amount
  2581.  of disc activity than one would expect for a simple directory scan. Fixing
  2582.  the driver to return the correct value when asked for a media check will
  2583.  correct this behavior.
  2584.  
  2585.  Q: What is the best way for my application to know if the disc has changed
  2586.  since it was last accessed?
  2587.  
  2588.  A: Use the DOS function find first and look for the volume id. When the disc
  2589.  has been read and MSCDEX has already initialized the internal information it
  2590.  keeps for each disc, this is a relatively inexpensive operation. The
  2591.  information is in memory and the disc does not have to be touched, so
  2592.  checking the volume id is very quick. Only if the disc has been changed does
  2593.  the disc have to be touched. This operation takes considerably longer than
  2594.  if the disc was not changed but even so, this has to be done anyway because
  2595.  MSCDEX has to read and initialize what it knows about the new disc so it can
  2596.  report the volume id correctly so the application can know if the disc in
  2597.  the drive is the one that it is looking for.
  2598.  
  2599.  Q: When I do a directory, the first couple filenames are either duplicated
  2600.  or they are random characters. What might cause this?
  2601.  
  2602.  A: The problem comes from having the incorrect bytes in the file identifier
  2603.  field for the first two directory entries. The first directory entry in each
  2604.  directory file is supposed begin with a copy of the directory record for
  2605.  that directory file followed by a copy of the directory record for the
  2606.  parent directory (also known as '.' and '..' on Unix or MS-DOS). The
  2607.  filename or directory identifier is supposed to be 1 byte long
  2608.  
  2609.  Q: When I do a directory, the first couple filenames are either duplicated
  2610.  or they are random characters. What might cause this?
  2611.  
  2612.  A: The problem comes from having the incorrect bytes in the file identifier
  2613.  field for the first two directory entries. The first directory entry in each
  2614.  directory file is supposed begin with a copy of the directory record for
  2615.  that directory file followed by a copy of the directory record for the
  2616.  parent directory (also known as '.' and '..' on Unix or MS-DOS). The
  2617.  filename or directory identifier is supposed to be 1 byte long and the
  2618.  contents are supposed to be 0 for the first directory entry and 1 for the
  2619.  second directory entry. This is discussed in clause 6.8.2.2 of the ECMA
  2620.  standard or the ISO-9660 proposal. Several places on the disc in question,
  2621.  you have a 1 where there should be a 0 and in one directory, the file
  2622.  identifier consists of 0x8A which is why DIR in that directory begins with
  2623.  an "e". Incorrectly formatted discs will not be handled by the extensions
  2624.  correctly. This is why it is a good idea to test your disc image using
  2625.  MSCDEX before you press a disc to make sure your data is formatted correctly
  2626.  and as MSCDEX expects it.
  2627.  
  2628.  Q: I have a directory file that is 4Kb long but when I do a DIR in that
  2629.  directory, it is slower than usual and random filenames are printed out. I
  2630.  can tell by watching the device driver commands that MSCDEX is asking for
  2631.  sectors far beyond the end of the directory. I can see how this might
  2632.  account for the random filenames but why is it scanning so far?
  2633.  
  2634.  A: Problems such as this result from having with multi-sector directory
  2635.  files that include empty sectors in the directory file. The High Sierra
  2636.  specification does not allow you to have empty directory sectors at the end
  2637.  or to have gaps in the middle. The problem stems from the fact that your
  2638.  directory length is too long. For example, for the disc in question, the
  2639.  root directory begins at sector 28 and its length is 4096 bytes but the
  2640.  second sector is completely blank (all 0's). This confuses MSCDEX because it
  2641.  does not expect to see empty sectors.
  2642.  
  2643.  Because LEN_DR of what would be the first directory entry in sector 29 is
  2644.  0, MSCDEX thinks that there are no more entries in that sector. When it
  2645.  reaches the end of the entries in each sector, MSCDEX rounds its offset up
  2646.  to the start of the next sector:
  2647.  
  2648.    offset += (SECTOR_SIZE - 1);
  2649.    offset &= ~(SECTOR_SIZE - 1);
  2650.  
  2651.  Since the offset did not changed when scanning sector 29 (there were no
  2652.  entries in this sector to increment the offset) the above rounding algorithm
  2653.  does not change the offset (2048 in, 2048 out). This is why MSCDEX continues
  2654.  reading beyond the end of the directory file at sector 29 because the offset
  2655.  did not grow past the directory length. MSCDEX continues reading blank
  2656.  sectors (sectors 29 through 49 are all blank) until it reaches the first
  2657.  non-blank sector.
  2658.  
  2659.  It looks like what you are attempting to do is implement updatable High
  2660.  Sierra and you want to allocate the directory space ahead of time and fill
  2661.  it in later as needed. The format you are using though is not valid High
  2662.  Sierra and also incurs the cost of reading the blank directory sectors at
  2663.  the end of every directory. Instead, you should record the correct High
  2664.  Sierra directory length in the directory length field for that directory (in
  2665.  this case 2Kb). What remains is finding a place to store the value which
  2666.  tells how many blocks have been reserved for each directory file. There are
  2667.  a number of places this can be done, either in system/application use fields
  2668.  in the directory record, in an XAR, or in a separate file either inside or
  2669.  outside the High Sierra directory structure. The first is the easiest
  2670.  approach to take.
  2671.  
  2672.  Be aware thought that CDI may have plans to use the system use field in the
  2673.  directory record so you may want to investigate Philips' plans to make sure
  2674.  whatever scheme you use meshes well with what CDI has in mind. MSCDEX will
  2675.  ignore the system use or application use information recorded so you can
  2676.  store what you'd like in the form you like (ascii or binary). You may also
  2677.  want a final pass over the directory hierarchy before mastering to remove
  2678.  extraneous information from the directory record.
  2679.  
  2680.  Q: I noticed that Function Request 0 Get Number of CD-ROM Drive Letters may
  2681.  not always return unambiguous results. Suppose I start the network first and
  2682.  use one of the drive letters for a network drive (F:). When I start the
  2683.  Extensions, it will begin assigning drive letters after the last used drive
  2684.  letter (C: on my machine). If I have 4 CD-ROM drives on my system, they
  2685.  will be assigned drive letters D:, E:, G:, and H:. Function 0 returns 4 in
  2686.  BX for the number of CD-ROM drives and 3 in CX for drive letter D:
  2687.  correctly. But as you can see, the CD-ROM drives do not use contiguous drive
  2688.  letters so I cannot deduce from what this function returns that drive F: is
  2689.  not a CD-ROM drive.
  2690.  
  2691.  A: That is correct. This is why function 0Dh Get CD-ROM drive letters was
  2692.  added. To get an unambiguous list of CD-ROM drives, use this function or use
  2693.  function 0Bh CD-ROM Drive Check to tell if a drive letter is for a CD-ROM
  2694.  drive.
  2695.  
  2696.  Q: Is it possible to do an absolute read using the Extensions. I am trying
  2697.  to read mode 2 (uncooked) data using Function Request 8 Absolute Read. I use
  2698.  a normal device I/O to turn off error correction and perform a read but all
  2699.  I get back is 2048 bytes of data instead of the full 2356 bytes. Is there
  2700.  another way in Int 2F to get the data uncooked?
  2701.  
  2702.  A: Not at present. If you want to get at the data including error correction
  2703.  code, you will have to communicate directly with the device driver. The
  2704.  Extensions will provide the location of the device drivers if asked.
  2705.  
  2706.  Q: Is it possible to access a non-High Sierra disc with the Extensions using
  2707.  an absolute disc read?
  2708.  
  2709.  A: One can use either the extensions to read a non-High Sierra disc using
  2710.  INT 2Fh or one can communicate directly with the device driver to do this.
  2711.  The device driver itself makes no distinction between High Sierra and non-
  2712.  High Sierra discs so it can be used to read them although the burden of file
  2713.  system translation and reading then falls on the application talking to the
  2714.  driver. The INT 2Fh Absolute Read function simply packages the request to
  2715.  read and sends it directly to the driver and returns the result.
  2716.  
  2717.  Q: What we have done is, in AUTOEXEC.BAT, first loaded the MS-DOS CD-ROM
  2718.  extensions and then the MS-NET software. The error message is "Redirector
  2719.  already installed". The network software is then not loaded. We are using
  2720.  MS-NET 1.1 in an HP product called ThinLAN. Any hints as to what they should
  2721.  try next?
  2722.  
  2723.  A: MSCDEX is a CD-ROM "redirector". It hooks into DOS the same way the
  2724.  network redirector does to get requests for file access to files that are
  2725.  not on local hard/floppy disks. As far as DOS is concerned, CD-ROM drives
  2726.  look just like network drives. DOS passes all file accesses through the
  2727.  redirector interface to the network redirector which in turn sends file
  2728.  access requests out over the net. MSCDEX splices itself in front of the
  2729.  network redirector and takes requests belonging to CD-ROM drives and passes
  2730.  the rest to the network redirector.
  2731.  
  2732.  The problem is that the network redirector code assumes that there will only
  2733.  be one redirector installed (itself) whereas MSCDEX does not make this
  2734.  assumption. If the network redirector is installed after MSCDEX (before it
  2735.  in the interrupt chain), it will process all requests from DOS and never
  2736.  pass any CD-ROM requests through to MSCDEX. For this reason, MSCDEX has to
  2737.  be installed after the network redirector (before it in the interrupt chain)
  2738.  and so MSCDEX prevents the network redirector from installing afterwards to
  2739.  ensure this. Since you installed MSCDEX first, the network believes a
  2740.  redirector is already installed so it does not install itself which is what
  2741.  you are seeing. In order to install both, simply install your network
  2742.  software first and MSCDEX second and you're set.
  2743.  
  2744.  Q: CHKDSK, ASSIGN, and SUBST report that the CD-ROM is a network disc. Why
  2745.  is this?
  2746.  
  2747.  A: From the above explanation, you understand that to DOS, the CD-ROM drives
  2748.  look like network drives. The programs CHKDSK, ASSIGN, and SUBST check the
  2749.  same fields DOS does and think the same thing. There is no way to get around
  2750.  this.
  2751.  
  2752.  Q: RENAME gives error message "Duplicate file name or File not found"
  2753.  instead of something that makes sense such as "Access denied" or "Can't
  2754.  rename CD-ROM files".
  2755.  
  2756.  A: The error message is coming from the code for RENAME and not MSCDEX. The
  2757.  error condition is being returned correctly but the error code returned by
  2758.  version 1.01 is correct according to DOS documentation. The problem seems to
  2759.  be that there are two error codes for access denied - 5 and a special one 65
  2760.  which is error_net_access_denied which is returned by the network redirector
  2761.  when it has a problem. MSCDEX version 2.00 returns error code
  2762.  error_net_access_denied and so RENAME now reports "Access denied".
  2763.