2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #define CDROM_REQUEST_SENSE 0x03
26 #define CDROM_INQUIRY 0x12
27 #define CDROM_START_STOP 0x1B
28 #define CDROM_LOCK 0x1E
29 #define CDROM_READ_CAPACITY 0x25
30 #define CDROM_READ 0xA8
32 #define CDROM_BUFSIZE DEVFS_BUFSIZE
37 #define CDROM_TYPE 0x05
60 } __attribute__ ((packed
)) dfl
;
67 } __attribute__ ((packed
)) ext
;
73 struct cdrom_inquiry_data
{
77 unsigned ansi_version
:3;
78 unsigned ecma_version
:3;
79 unsigned iso_version
:2;
80 unsigned response_type
:4;
81 unsigned atapi_version
:4;
82 uint8_t additional_length
;
86 uint16_t product_rev_level
;
87 } __attribute__ ((packed
));
89 struct cdrom_read_capacity_data
{
92 } __attribute__ ((packed
));
94 struct cdrom_request_sense_data
{
95 unsigned error_code
:7;
97 uint8_t segment_number
;
102 uint16_t information
;
103 uint8_t additionaL_sense_length
;
104 uint16_t command_specific_information
;
105 uint8_t additional_sense_code
;
106 uint8_t additional_sense_code_qualifier
;
107 uint8_t field_replacable_unit_code
;
108 unsigned sense_key_specific
:15;
109 unsigned sense_key_valid
:1;
110 uint8_t additional_sense_bytes
[0];
111 } __attribute__ ((packed
));
113 struct cdrom_request_sense_data
*cdrom_request_sense(struct cdrom_device
*dev
);
114 int cdrom_inquiry(struct cdrom_device
*dev
);
115 int cdrom_start(struct cdrom_device
*dev
,int start
,int load
);
116 int cdrom_lock(struct cdrom_device
*dev
,int lock
);
117 int cdrom_read_capacity(struct cdrom_device
*dev
);
118 void *cdrom_read(struct cdrom_device
*dev
,size_t first_block
,size_t block_count
);
119 struct cdrom_device
*cdrom_device_create(const char *name
);
120 void cdrom_device_destroy(struct cdrom_device
*dev
);
121 int cdrom_buf_init();
123 static inline int cdrom_load(struct cdrom_device
*dev
,int load
) {
124 return cdrom_start(dev
,dev
->started
,load
);
127 static inline uint32_t bei(uint32_t v
) {
133 static inline uint16_t bes(uint16_t v
) {