1 /*++ BUILD Version: 0001 // Increment this if a change has global effects
3 Copyright (c) Microsoft Corporation. All rights reserved.
11 This module contains structures and definitions
12 associated with CDROM IOCTls.
36 // remove some level 4 warnings for this header file:
37 #pragma warning(disable:4200) // array[0]
38 #pragma warning(disable:4201) // nameless struct/unions
39 #pragma warning(disable:4214) // bit fields other than int
46 // NtDeviceIoControlFile IoControlCode values for this device.
48 // Warning: Remember that the low two bits of the code specify how the
49 // buffers are passed to the driver!
52 #define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM
54 #define IOCTL_CDROM_UNLOAD_DRIVER CTL_CODE(IOCTL_CDROM_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS)
57 // CDROM Audio Device Control Functions
60 #define IOCTL_CDROM_READ_TOC CTL_CODE(IOCTL_CDROM_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS)
61 #define IOCTL_CDROM_SEEK_AUDIO_MSF CTL_CODE(IOCTL_CDROM_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
62 #define IOCTL_CDROM_STOP_AUDIO CTL_CODE(IOCTL_CDROM_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS)
63 #define IOCTL_CDROM_PAUSE_AUDIO CTL_CODE(IOCTL_CDROM_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
64 #define IOCTL_CDROM_RESUME_AUDIO CTL_CODE(IOCTL_CDROM_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS)
65 #define IOCTL_CDROM_GET_VOLUME CTL_CODE(IOCTL_CDROM_BASE, 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS)
66 #define IOCTL_CDROM_PLAY_AUDIO_MSF CTL_CODE(IOCTL_CDROM_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS)
67 #define IOCTL_CDROM_SET_VOLUME CTL_CODE(IOCTL_CDROM_BASE, 0x000A, METHOD_BUFFERED, FILE_READ_ACCESS)
68 #define IOCTL_CDROM_READ_Q_CHANNEL CTL_CODE(IOCTL_CDROM_BASE, 0x000B, METHOD_BUFFERED, FILE_READ_ACCESS)
69 #define IOCTL_CDROM_GET_CONTROL CTL_CODE(IOCTL_CDROM_BASE, 0x000D, METHOD_BUFFERED, FILE_READ_ACCESS)
70 #define IOCTL_CDROM_GET_LAST_SESSION CTL_CODE(IOCTL_CDROM_BASE, 0x000E, METHOD_BUFFERED, FILE_READ_ACCESS)
71 #define IOCTL_CDROM_RAW_READ CTL_CODE(IOCTL_CDROM_BASE, 0x000F, METHOD_OUT_DIRECT, FILE_READ_ACCESS)
72 #define IOCTL_CDROM_DISK_TYPE CTL_CODE(IOCTL_CDROM_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
74 #define IOCTL_CDROM_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_CDROM_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS)
75 #define IOCTL_CDROM_GET_DRIVE_GEOMETRY_EX CTL_CODE(IOCTL_CDROM_BASE, 0x0014, METHOD_BUFFERED, FILE_READ_ACCESS)
77 #define IOCTL_CDROM_READ_TOC_EX CTL_CODE(IOCTL_CDROM_BASE, 0x0015, METHOD_BUFFERED, FILE_READ_ACCESS)
78 #define IOCTL_CDROM_GET_CONFIGURATION CTL_CODE(IOCTL_CDROM_BASE, 0x0016, METHOD_BUFFERED, FILE_READ_ACCESS)
83 // The following device control codes are common for all class drivers. The
84 // functions codes defined here must match all of the other class drivers.
86 // Warning: these codes will be replaced in the future with the IOCTL_STORAGE
87 // codes included below
90 #define IOCTL_CDROM_CHECK_VERIFY CTL_CODE(IOCTL_CDROM_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
91 #define IOCTL_CDROM_MEDIA_REMOVAL CTL_CODE(IOCTL_CDROM_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
92 #define IOCTL_CDROM_EJECT_MEDIA CTL_CODE(IOCTL_CDROM_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
93 #define IOCTL_CDROM_LOAD_MEDIA CTL_CODE(IOCTL_CDROM_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
94 #define IOCTL_CDROM_RESERVE CTL_CODE(IOCTL_CDROM_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
95 #define IOCTL_CDROM_RELEASE CTL_CODE(IOCTL_CDROM_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
96 #define IOCTL_CDROM_FIND_NEW_DEVICES CTL_CODE(IOCTL_CDROM_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
99 // The following file contains the IOCTL_STORAGE class ioctl definitions
102 #include "ntddstor.h"
107 // The following device control code is for the SIMBAD simulated bad
108 // sector facility. See SIMBAD.H in this directory for related structures.
111 #define IOCTL_CDROM_SIMBAD CTL_CODE(IOCTL_CDROM_BASE, 0x1003, METHOD_BUFFERED, FILE_READ_ACCESS)
114 // Maximum CD Rom size
117 #define MAXIMUM_NUMBER_TRACKS 100
118 #define MAXIMUM_CDROM_SIZE 804
119 #define MINIMUM_CDROM_READ_TOC_EX_SIZE 2 // two bytes min transferred
122 // READ_TOC_EX structure
124 typedef struct _CDROM_READ_TOC_EX
{
126 UCHAR Reserved1
: 3; // future expansion
129 UCHAR Reserved2
; // future expansion
130 UCHAR Reserved3
; // future expansion
131 } CDROM_READ_TOC_EX
, *PCDROM_READ_TOC_EX
;
133 #define CDROM_READ_TOC_EX_FORMAT_TOC 0x00
134 #define CDROM_READ_TOC_EX_FORMAT_SESSION 0x01
135 #define CDROM_READ_TOC_EX_FORMAT_FULL_TOC 0x02
136 #define CDROM_READ_TOC_EX_FORMAT_PMA 0x03
137 #define CDROM_READ_TOC_EX_FORMAT_ATIP 0x04
138 #define CDROM_READ_TOC_EX_FORMAT_CDTEXT 0x05
141 // CD ROM Table OF Contents (TOC)
142 // Format 0 - Get table of contents
145 typedef struct _TRACK_DATA
{
152 } TRACK_DATA
, *PTRACK_DATA
;
154 typedef struct _CDROM_TOC
{
160 UCHAR Length
[2]; // add two bytes for this field
168 TRACK_DATA TrackData
[MAXIMUM_NUMBER_TRACKS
];
169 } CDROM_TOC
, *PCDROM_TOC
;
171 #define CDROM_TOC_SIZE sizeof(CDROM_TOC)
174 // CD ROM Table OF Contents
175 // Format 1 - Session Information
178 typedef struct _CDROM_TOC_SESSION_DATA
{
184 UCHAR Length
[2]; // add two bytes for this field
185 UCHAR FirstCompleteSession
;
186 UCHAR LastCompleteSession
;
189 // One track, representing the first track
190 // of the last finished session
193 TRACK_DATA TrackData
[1];
195 } CDROM_TOC_SESSION_DATA
, *PCDROM_TOC_SESSION_DATA
;
199 // CD ROM Table OF Contents
200 // Format 2 - Full TOC
203 typedef struct _CDROM_TOC_FULL_TOC_DATA_BLOCK
{
212 } CDROM_TOC_FULL_TOC_DATA_BLOCK
, *PCDROM_TOC_FULL_TOC_DATA_BLOCK
;
214 typedef struct _CDROM_TOC_FULL_TOC_DATA
{
220 UCHAR Length
[2]; // add two bytes for this field
221 UCHAR FirstCompleteSession
;
222 UCHAR LastCompleteSession
;
225 // one to N descriptors included
228 CDROM_TOC_FULL_TOC_DATA_BLOCK Descriptors
[0];
230 } CDROM_TOC_FULL_TOC_DATA
, *PCDROM_TOC_FULL_TOC_DATA
;
233 // CD ROM Table OF Contents
234 // Format 3 - Program Memory Area
236 typedef struct _CDROM_TOC_PMA_DATA
{
242 UCHAR Length
[2]; // add two bytes for this field
247 // one to N descriptors included
250 CDROM_TOC_FULL_TOC_DATA_BLOCK Descriptors
[0];
252 } CDROM_TOC_PMA_DATA
, *PCDROM_TOC_PMA_DATA
;
255 // CD ROM Table OF Contents
256 // Format 4 - Absolute Time In Pregroove
259 typedef struct _CDROM_TOC_ATIP_DATA_BLOCK
{
261 UCHAR CdrwReferenceSpeed
: 3;
263 UCHAR WritePower
: 3;
266 UCHAR UnrestrictedUse
: 1;
271 UCHAR DiscSubType
: 3;
291 } CDROM_TOC_ATIP_DATA_BLOCK
, *PCDROM_TOC_ATIP_DATA_BLOCK
;
293 typedef struct _CDROM_TOC_ATIP_DATA
{
299 UCHAR Length
[2]; // add two bytes for this field
304 // zero? to N descriptors included.
307 CDROM_TOC_ATIP_DATA_BLOCK Descriptors
[0];
309 } CDROM_TOC_ATIP_DATA
, *PCDROM_TOC_ATIP_DATA
;
312 // CD ROM Table OF Contents
313 // Format 5 - CD Text Info
315 typedef struct _CDROM_TOC_CD_TEXT_DATA_BLOCK
{
317 UCHAR TrackNumber
: 7;
318 UCHAR ExtensionFlag
: 1; // should be zero!
319 UCHAR SequenceNumber
;
320 UCHAR CharacterPosition
: 4;
321 UCHAR BlockNumber
: 3;
328 } CDROM_TOC_CD_TEXT_DATA_BLOCK
, *PCDROM_TOC_CD_TEXT_DATA_BLOCK
;
330 typedef struct _CDROM_TOC_CD_TEXT_DATA
{
336 UCHAR Length
[2]; // add two bytes for this field
341 // the text info comes in discrete blocks of
342 // a heavily-overloaded structure
345 CDROM_TOC_CD_TEXT_DATA_BLOCK Descriptors
[0];
347 } CDROM_TOC_CD_TEXT_DATA
, *PCDROM_TOC_CD_TEXT_DATA
;
350 // These are the types used for PackType field in CDROM_TOC_CD_TEXT_DATA_BLOCK
351 // and also for requesting specific info from IOCTL_CDROM_READ_CD_TEXT
353 #define CDROM_CD_TEXT_PACK_ALBUM_NAME 0x80
354 #define CDROM_CD_TEXT_PACK_PERFORMER 0x81
355 #define CDROM_CD_TEXT_PACK_SONGWRITER 0x82
356 #define CDROM_CD_TEXT_PACK_COMPOSER 0x83
357 #define CDROM_CD_TEXT_PACK_ARRANGER 0x84
358 #define CDROM_CD_TEXT_PACK_MESSAGES 0x85
359 #define CDROM_CD_TEXT_PACK_DISC_ID 0x86
360 #define CDROM_CD_TEXT_PACK_GENRE 0x87
361 #define CDROM_CD_TEXT_PACK_TOC_INFO 0x88
362 #define CDROM_CD_TEXT_PACK_TOC_INFO2 0x89
363 // 0x8a - 0x8d are reserved....
364 #define CDROM_CD_TEXT_PACK_UPC_EAN 0x8e
365 #define CDROM_CD_TEXT_PACK_SIZE_INFO 0x8f
368 // Play audio starting at MSF and ending at MSF
371 typedef struct _CDROM_PLAY_AUDIO_MSF
{
378 } CDROM_PLAY_AUDIO_MSF
, *PCDROM_PLAY_AUDIO_MSF
;
384 typedef struct _CDROM_SEEK_AUDIO_MSF
{
388 } CDROM_SEEK_AUDIO_MSF
, *PCDROM_SEEK_AUDIO_MSF
;
392 // Flags for the disk type
395 typedef struct _CDROM_DISK_DATA
{
399 } CDROM_DISK_DATA
, *PCDROM_DISK_DATA
;
401 #define CDROM_DISK_AUDIO_TRACK (0x00000001)
402 #define CDROM_DISK_DATA_TRACK (0x00000002)
405 // CD ROM Data Mode Codes, used with IOCTL_CDROM_READ_Q_CHANNEL
408 #define IOCTL_CDROM_SUB_Q_CHANNEL 0x00
409 #define IOCTL_CDROM_CURRENT_POSITION 0x01
410 #define IOCTL_CDROM_MEDIA_CATALOG 0x02
411 #define IOCTL_CDROM_TRACK_ISRC 0x03
413 typedef struct _CDROM_SUB_Q_DATA_FORMAT
{
416 } CDROM_SUB_Q_DATA_FORMAT
, *PCDROM_SUB_Q_DATA_FORMAT
;
420 // CD ROM Sub-Q Channel Data Format
423 typedef struct _SUB_Q_HEADER
{
427 } SUB_Q_HEADER
, *PSUB_Q_HEADER
;
429 typedef struct _SUB_Q_CURRENT_POSITION
{
436 UCHAR AbsoluteAddress
[4];
437 UCHAR TrackRelativeAddress
[4];
438 } SUB_Q_CURRENT_POSITION
, *PSUB_Q_CURRENT_POSITION
;
440 typedef struct _SUB_Q_MEDIA_CATALOG_NUMBER
{
446 UCHAR MediaCatalog
[15];
447 } SUB_Q_MEDIA_CATALOG_NUMBER
, *PSUB_Q_MEDIA_CATALOG_NUMBER
;
449 typedef struct _SUB_Q_TRACK_ISRC
{
458 } SUB_Q_TRACK_ISRC
, *PSUB_Q_TRACK_ISRC
;
460 typedef union _SUB_Q_CHANNEL_DATA
{
461 SUB_Q_CURRENT_POSITION CurrentPosition
;
462 SUB_Q_MEDIA_CATALOG_NUMBER MediaCatalog
;
463 SUB_Q_TRACK_ISRC TrackIsrc
;
464 } SUB_Q_CHANNEL_DATA
, *PSUB_Q_CHANNEL_DATA
;
467 // Audio Status Codes
470 #define AUDIO_STATUS_NOT_SUPPORTED 0x00
471 #define AUDIO_STATUS_IN_PROGRESS 0x11
472 #define AUDIO_STATUS_PAUSED 0x12
473 #define AUDIO_STATUS_PLAY_COMPLETE 0x13
474 #define AUDIO_STATUS_PLAY_ERROR 0x14
475 #define AUDIO_STATUS_NO_STATUS 0x15
478 // ADR Sub-channel Q Field
481 #define ADR_NO_MODE_INFORMATION 0x0
482 #define ADR_ENCODES_CURRENT_POSITION 0x1
483 #define ADR_ENCODES_MEDIA_CATALOG 0x2
484 #define ADR_ENCODES_ISRC 0x3
487 // Sub-channel Q Control Bits
490 #define AUDIO_WITH_PREEMPHASIS 0x1
491 #define DIGITAL_COPY_PERMITTED 0x2
492 #define AUDIO_DATA_TRACK 0x4
493 #define TWO_FOUR_CHANNEL_AUDIO 0x8
496 // Get Audio control parameters
499 typedef struct _CDROM_AUDIO_CONTROL
{
501 USHORT LogicalBlocksPerSecond
;
502 } CDROM_AUDIO_CONTROL
, *PCDROM_AUDIO_CONTROL
;
505 // Volume control - Volume takes a value between 1 and 0xFF.
506 // SCSI-II CDROM audio suppports up to 4 audio ports with
507 // Independent volume control.
510 typedef struct _VOLUME_CONTROL
{
512 } VOLUME_CONTROL
, *PVOLUME_CONTROL
;
514 typedef enum _TRACK_MODE_TYPE
{
518 } TRACK_MODE_TYPE
, *PTRACK_MODE_TYPE
;
521 // Passed to cdrom to describe the raw read, ie. Mode 2, Form 2, CDDA...
524 typedef struct __RAW_READ_INFO
{
525 LARGE_INTEGER DiskOffset
;
527 TRACK_MODE_TYPE TrackMode
;
528 } RAW_READ_INFO
, *PRAW_READ_INFO
;
536 #pragma warning(pop) // un-sets any local warning changes
538 #pragma warning(default:4200) // array[0] is not a warning for this file
539 #pragma warning(default:4201) // nameless struct/unions
540 #pragma warning(default:4214) // bit fields other than int