1 //----------------------------------------------------------------------
2 // This software is part of the OpenBeOS distribution and is covered
3 // by the OpenBeOS license.
5 // Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
6 //---------------------------------------------------------------------
12 SCSI-3 MMC support structures.
14 The protocols followed in this module are based on information
15 taken from the "SCSI-3 Multimedia Commands" draft, revision 10A.
17 The SCSI command of interest is "READ TOC/PMA/ATIP", command
20 The format of interest for said command is "Full TOC", format
30 #include <ByteOrder.h>
31 #include <KernelExport.h>
36 /*! \brief raw_device_command flags
38 This is the only combination of flags that works on my system. :-)
40 const uint8 kScsiFlags
= B_RAW_DEVICE_DATA_IN
41 | B_RAW_DEVICE_REPORT_RESIDUAL
42 | B_RAW_DEVICE_SHORT_READ_VALID
;
44 /*! \brief Timeout value used when making scsi commands
46 I'm honestly not sure what value to use here. It's currently
47 1 second because I got sick of waiting for the timeout while
48 figuring out how to get the commands to work.
50 const uint32 kScsiTimeout
= 1000000;
52 //! SCSI "READ TOC/PMA/ATIP" command struct
54 uint8 command
; //!< 0x43 == READ TOC/PMA/ATIP
56 msf
:1, //!< addressing format: 0 == LBA, 1 == MSF; try lba first, then msf if that fails
59 uint8 format
:4, //!< sub-command: 0x0 == "TOC", 0x1 == "Session Info", 0x2 == "Full TOC", ...
64 uint8 number
; //!< track/session number
65 uint16 length
; //!< length of data buffer passed in raw_device_command.data; BIG-ENDIAN!!!
66 uint8 control
; //!< control codes; 0x0 should be fine
67 } __attribute__((packed
)) scsi_table_of_contents_command
;
69 // Some of the possible "READ TOC/PMA/ATIP" formats
70 const uint8 kTableOfContentsFormat
= 0x00;
71 const uint8 kSessionFormat
= 0x01;
72 const uint8 kFullTableOfContentsFormat
= 0x02; //!< "READ TOC/PMA/ATIP" format of interest
74 /*! \brief Minutes:Seconds:Frames format address
76 - Each msf frame corresponds to one logical block.
77 - Each msf second corresponds to 75 msf frames
78 - Each msf minute corresponds to 60 msf seconds
79 - Logical block 0 is at msf address 00:02:00
88 #define CDROM_FRAMES_PER_SECOND (75)
89 #define CDROM_FRAMES_PER_MINUTE (CDROM_FRAMES_PER_SECOND*60)
91 /*! \brief Returns an initialized \c msf_address struct
96 make_msf_address(uint8 minutes
, uint8 seconds
, uint8 frames
)
100 result
.minutes
= minutes
;
101 result
.seconds
= seconds
;
102 result
.frames
= frames
;
106 /*! \brief Converts the given msf address to lba format
111 msf_to_lba(msf_address msf
)
113 return (CDROM_FRAMES_PER_MINUTE
* msf
.minutes
)
114 + (CDROM_FRAMES_PER_SECOND
* msf
.seconds
)
118 /*! \brief Header for data returned by all formats of SCSI
119 "READ TOC/PMA/ATIP" command.
122 uint16 length
; //!< Length of data in reply (not including these 2 bytes); BIG ENDIAN!!!
123 uint8 first
; //!< First track/session in reply
124 uint8 last
; //!< Last track/session in reply
125 } cdrom_table_of_contents_header
;
127 /*! \brief Type of entries returned by "READ TOC/PMA/ATIP" when called with format
128 \c kTableOfContentsFormat == 0x00
137 } cdrom_table_of_contents_entry
;
139 /*! \brief Type of entries returned by "READ TOC/PMA/ATIP" when called with format
140 \c kFullTableOfContentsFormat == 0x02
155 } cdrom_full_table_of_contents_entry
;
157 /*! \brief Bitflags for control entries
160 kControlDataTrack
= 0x4,
161 kControlCopyPermitted
= 0x2,
164 #endif // _SCSI_MMC_H