7.2  CD-ROM I/O Control Codes

All public I/O control codes for drivers of CD-ROM devices use buffered I/O. Consequently, the input or output data for these requests is at Irp->AssociatedIrp.SystemBuffer.

Class drivers for SCSI CD-ROM devices handle additional public I/O control codes, along with those described in this section. See also Chapter 9 for more information about requirements for SCSI class drivers of mass-storage devices.

IOCTL_CDROM_GET_DRIVE_GEOMETRY

Operation

IOCTL_CDROM_GET_DRIVE_GEOMETRY returns information about the CDROM’s geometry (media type, number of cylinders, tracks per cylinder, sectors per track, and bytes per sector).

Input

Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location of the IRP indicates the size in bytes of the buffer, which must be >= sizeof(DISK_GEOMETRY).

Output

The driver returns the DISK_GEOMETRY-type information in the buffer at Irp->AssociatedIrp.SystemBuffer.

I/O Status Block

The Information field is set to the size in bytes of the returned data. The Status field is set to STATUS_SUCCESS or possibly to STATUS_UNRECOGNIZED_MEDIA, STATUS_INVALID_PARAMETER, STATUS_INFO_LENGTH_MISMATCH, or STATUS_BUFFER_TOO_SMALL.

IOCTL_CDROM_READ_TOC

Operation

Returns the table of contents of the media.

Input

Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location indicates the size in bytes of the buffer, which must be >= sizeof(CDROM_TOC).

Output

The driver returns the CDROM_TOC data in the buffer at Irp->AssociatedIrp.SystemBuffer.

I/O Status Block

The Information field is set to the number of bytes returned. The Status field is set to STATUS_SUCCESS or possibly to STATUS_BUFFER_TOO_SMALL, STATUS_NO_MEDIA_IN_DEVICE, STATUS_DEVICE_NOT_READY, STATUS_IO_TIMEOUT, STATUS_IO_DEVICE_ERROR, STATUS_DEVICE_BUSY, or STATUS_VERIFY_REQUIRED.

IOCTL_CDROM_GET_LAST_SESSION

Operation

The driver determines whether a disc is multisession. It compares the first and last session and the starting track of the last session. If the first session is the same as the last, the disc is not multisession. If the disc is multisession, the driver stores session block addresses in the table of contents.

Input

None

Output

None

I/O Status Block

The Information field is set to zero. The Status field is set to STATUS_SUCCESS or possibly to STATUS_INVALID_DEVICE_REQUEST, STATUS_DEVICE_BUSY, STATUS_DEVICE_NOT_READY, STATUS_IO_TIME_OUT, or STATUS_VERIFY_REQUIRED.

IOCTL_CDROM_CHECK_VERIFY

Operation

This IOCTL is replaced by IOCTL_STORAGE_CHECK_VERIFY. The only difference between the two IOCTLs is the base code.

IOCTL_STORAGE_CHECK_VERIFY

Operation

Determines whether the media has changed on a CD-ROM drive. (For more information about handling removable media, see the Kernel-Mode Driver Design Guide.)

Input

Optionally, Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location of the IRP indicates the size in bytes of a buffer, which must be >= sizeof(ULONG). This field is zero if the optional buffer is not specified.

Output

Optionally, Irp->AssociatedIrp.SystemBuffer points to a buffer to receive the media change count. The driver fills this buffer only if Parameters.DeviceIoControl.OutputBufferLength was nonzero and the return value is STATUS_SUCCESS. The media change count is a ULONG indicating how many times the media has changed since the driver started.

I/O Status Block

If the driver has no indication that the media has changed, the driver sets the Status field to STATUS_SUCCESS. In addition, if the optional media change buffer was specified, the driver returns the media change count in the buffer at Irp->AssociatedIrp.SystemBuffer and sets the Information field to sizeof(ULONG). If the optional media change buffer was not specified, the driver sets Information to zero.

If the driver detects that the media has changed and the volume is mounted (VPD_MOUNTED is set in the VPB), it must: set Information to zero, set Status to STATUS_VERIFY_REQUIRED, set the DO_VERIFY_VOLUME flag in the DeviceObject, and call IoCompleteRequest with the input IRP.

If the driver detects that the media has changed, but the volume is not mounted, the driver must not set the DO_VERIFY_VOLUME bit. The driver should set Status to STATUS_IO_DEVICE_ERROR, set Information to zero, and call IoCompleteRequest with the IRP.

If the driver detects an error such as STATUS_BUFFER_TOO_SMALL, STATUS_INSUFFICIENT_RESOURCES, or a device error, it sets Information to zero and sets the appropriate error value in the Status field.

IOCTL_CDROM_GET_CONTROL

Operation

The driver determines the current audio playback mode.

Input

Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location indicates the size in bytes of the buffer, which must be >= sizeof(CDROM_AUDIO_CONTROL).

Output

The driver returns the CDROM_AUDIO_CONTROL data in the buffer at Irp->AssociatedIrp.SystemBuffer.

I/O Status Block

The Information field is set to the number of bytes returned. The Status field is set to STATUS_SUCCESS or possibly to STATUS_BUFFER_TOO_SMALL, STATUS_DEVICE_NOT_READY, STATUS_IO_DEVICE_ERROR, STATUS_IO_TIMEOUT, STATUS_INSUFFICIENT_RESOURCES, STATUS_VERIFY_REQUIRED, or STATUS_INVALID_DEVICE_REQUEST.

IOCTL_CDROM_GET_VOLUME

Operation

The driver determines the current volume for each of its device’s audio ports.

Input

Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location indicates the size in bytes of the buffer, which must be >= sizeof(CDROM_VOLUME_CONTROL).

Output

The driver returns the CDROM_VOLUME_CONTROL data in the buffer at Irp->AssociatedIrp.SystemBuffer.

I/O Status Block

The Information field is set to sizeof(CDROM_VOLUME_CONTROL) when the Status field is set to STATUS_SUCCESS. Otherwise, the Information field is set to zero, and the Status field possibly can be set to STATUS_BUFFER_TOO_SMALL, STATUS_DEVICE_NOT_READY, STATUS_IO_DEVICE_ERROR, STATUS_VERIFY_REQUIRED, or STATUS_IO_TIMEOUT.

IOCTL_CDROM_SET_VOLUME

Operation

The driver resets the volume for its device’s audio ports.

Input

The buffer at Irp->AssociatedIrp.SystemBuffer contains the CDROM_VOLUME_CONTROL value(s) to be set. Parameters.DeviceIoControl.InputBufferLength in the I/O stack location indicates the size in bytes of the buffer, which must be >= sizeof(CDROM_VOLUME_CONTROL).

Output

None

I/O Status Block

The Information field is set to zero. The Status field is set to STATUS_SUCCESS or possibly to STATUS_BUFFER_TOO_SMALL, STATUS_DEVICE_NOT_READY, STATUS_IO_TIMEOUT, STATUS_IO_DEVICE_ERROR, STATUS_VERIFY_REQUIRED, or STATUS_INVALID_DEVICE_REQUEST.

IOCTL_CDROM_PLAY_AUDIO_MSF

Operation

Plays the specified range of the media.

Input

The buffer at Irp->AssociatedIrp.System buffer contains the starting and ending MSF values. Parameters.DeviceIoControl.InputBufferLength in the I/O stack location indicates the size in bytes of the buffer, which must be >= sizeof(CDROM_PLAY_AUDIO_MSF).

Output

None

I/O Status Block

The Information field is set to zero. The Status field is set to STATUS_SUCCESS or possibly to STATUS_INVALID_DEVICE_REQUEST, STATUS_BUFFER_TOO_SMALL, STATUS_DEVICE_NOT_READY, STATUS_IO_DEVICE_ERROR, STATUS_IO_TIME_OUT, or STATUS_VERIFY_REQUIRED.

IOCTL_CDROM_SEEK_AUDIO_MSF

Operation

Moves the heads to the specified MSF on the media.

Input

The buffer at Irp->AssociatedIrp.SystemBuffer contains the CDROM_SEEK_AUDIO_MSF specification. Parameters.DeviceIoControl.InputBufferLength indicates the size in bytes of the buffer.

Output

None

I/O Status Block

The Information field is set to zero. The Status field is set to STATUS_SUCCESS or possibly to STATUS_BUFFER_TOO_SMALL, STATUS_INVALID_DEVICE_REQUEST, STATUS_IO_DEVICE_ERROR, STATUS_NO_MEDIA_IN_DEVICE, STATUS_DEVICE_NOT_READY, STATUS_IO_TIME_OUT, or STATUS_VERIFY_REQUIRED.

IOCTL_CDROM_STOP_AUDIO

Operation

Ends audio play.

Input

None

Output

None

I/O Status Block

The Information field is set to zero. The Status field is set to STATUS_SUCCESS or possibly to STATUS_INVALID_DEVICE_REQUEST if audio is not currently playing, STATUS_IO_DEVICE_ERROR, STATUS_NO_MEDIA_IN_DEVICE, STATUS_DEVICE_NOT_READY, STATUS_IO_TIME_OUT, or STATUS_VERIFY_REQUIRED.

IOCTL_CDROM_PAUSE_AUDIO

Operation

Suspends audio play.

Input

None

Output

None

I/O Status Block

The Information field is set to zero. The Status field is set to STATUS_SUCCESS or possibly to STATUS_INVALID_DEVICE_REQUEST if audio is not currently playing, STATUS_IO_DEVICE_ERROR, STATUS_NO_MEDIA_IN_DEVICE, STATUS_DEVICE_NOT_READY, STATUS_IO_TIME_OUT, or STATUS_VERIFY_REQUIRED.

IOCTL_CDROM_RESUME_AUDIO

Operation

Resumes a suspended audio operation.

Input

None

Output

None

I/O Status Block

The Information field is set to zero. The Status field is set to STATUS_SUCCESS or possibly to STATUS_INVALID_DEVICE_REQUEST if audio is not currently suspended, STATUS_IO_DEVICE_ERROR, STATUS_NO_MEDIA_IN_DEVICE, STATUS_DEVICE_NOT_READY, STATUS_IO_TIME_OUT, or STATUS_VERIFY_REQUIRED.

IOCTL_CDROM_READ_Q_CHANNEL

Operation

Returns the current position, media catalog, and ISRC track data.

Input

Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location indicates the size in bytes of the buffer, which must be >= sizeof(SUB_Q_CHANNEL_DATA).

Output

The driver returns the SUB_Q_CHANNEL_DATA information in the buffer at Irp->AssociatedIrp.SystemBuffer.

I/O Status Block

The Information field is set to the number of bytes returned. The Status field is set to STATUS_SUCCESS or possibly to STATUS_BUFFER_TOO_SMALL, STATUS_IO_DEVICE_ERROR, STATUS_INSUFFICIENT_RESOURCES, STATUS_INVALID_DEVICE_REQUEST, STATUS_NO_MEDIA_IN_DEVICE, STATUS_DEVICE_NOT_READY, STATUS_IO_TIME_OUT, or STATUS_VERIFY_REQUIRED.

IOCTL_CDROM_FIND_NEW_DEVICES

Operation

This IOCTL is replaced by IOCTL_STORAGE_FIND_NEW_DEVICES. The only difference between the two IOCTLs is the base code.

IOCTL_STORAGE_FIND_NEW_DEVICES

Operation

Determines whether another device that the driver supports has just been connected to the I/O bus. If such a device is found, the driver sets up any necessary system objects and resources to handle I/O requests for its new device. It also initializes the device on receipt of this request dynamically: that is, without requiring the machine to be rebooted. Such a driver is assumed to support devices connected on a dynamically configurable I/O bus.

Input

None

Output

None

I/O Status Block

The Information field is set to zero. The Status field can be set to STATUS_SUCCESS or to any value returned by the driver’s (re)initialization code.

IOCTL_CDROM_RAW_READ

Operation

Reads data from the CD-ROM in raw mode.

Input

If the IOCTL is from user mode, Irp->AssociatedIrp.SystemBuffer contains a structure that specifies the starting disk offset, the sector count, and the track mode (XA or CDDA) for the read. Parameters.DeviceIoControl.InputBufferLength specifies the size in bytes of the structure, which must be >= sizeof(RAW_READ_INFO). Parameters.DeviceIoControl.OutputBufferLength specifies the size of the buffer to be read, which must be >= sizeof(SectorCount * RAW_SECTOR_SIZE).

If the IOCTL is from kernel mode, Parameters.DeviceIoControl.Type3InputBuffer contains a structure that specifies the starting disk offset, the sector count, and the track mode (XA or CDDA) for the read. Parameters.DeviceIoControl.OutputBufferLength specifies the size of the buffer to be read, which must be >= sizeof(SectorCount * RAW_SECTOR_SIZE).

Output

The driver writes the requested bytes directly (using DMA or PIO) to the buffer described by the MDL at Irp->MdlAddress.

I/O Status Block

If the read is successful, the driver sets Status to STATUS_SUCCESS and Information to the number of bytes transferred. If the read is not successful, the driver sets Information to zero and Status to possibly STATUS_INVALID_PARAMETER, STATUS_INSUFFICIENT_RESOURCES, or STATUS_INVALID_DEVICE_REQUEST.

IOCTL_CDROM_CLOSE_DOOR

Operation

None. This I/O control code has been replaced by IOCTL_DeviceType_LOAD_MEDIA, described in Chapter 9.