Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


updates to ATAPI packet command support
[palacios.git] / palacios / src / devices / atapi-types.h
1 /* 
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
11  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20
21 #ifndef __DEVICES_ATAPI_TYPES_H__
22 #define __DEVICES_ATAPI_TYPES_H__
23
24 #ifdef __V3VEE__
25
26 #include <palacios/vmm_types.h>
27
28 typedef enum {
29     ATAPI_SEN_NONE = 0, 
30     ATAPI_SEN_NOT_RDY = 2, 
31     ATAPI_SEN_ILL_REQ = 5,
32     ATAPI_SEN_UNIT_ATTNT = 6
33 } atapi_sense_key_t ;
34
35 typedef enum  {
36     ASC_INV_CMD_FIELD = 0x24,
37     ASC_MEDIA_NOT_PRESENT = 0x3a,
38     ASC_SAVE_PARAM_NOT_SUPPORTED = 0x39,    
39     ASC_LOG_BLK_OOR = 0x21                  /* LOGICAL BLOCK OUT OF RANGE */
40 } atapi_add_sense_code_t ; 
41
42 struct atapi_irq_flags {
43     uint8_t c_d    : 1; 
44     uint8_t io_dir : 1; 
45     uint8_t rel    : 1; 
46     uint8_t tag    : 5;
47 } __attribute__((packed));
48
49
50
51 struct atapi_sense_data {
52     union {
53         uint8_t buf[18];
54         struct {
55             uint8_t header;
56             uint8_t rsvd1;
57             uint8_t sense_key; // atapi_sense_key_t
58             uint8_t info[4];
59             uint8_t read_len; // num bytes past this point
60             uint8_t spec_info[4];
61             uint8_t asc;   // atapi_add_sense_code_t
62             uint8_t ascq; // ??
63             uint8_t fruc; // ??
64             uint8_t key_spec[3];
65         } __attribute__((packed));
66     } __attribute__((packed));
67 } __attribute__((packed));
68
69
70
71
72 struct atapi_read10_cmd {
73     uint8_t atapi_cmd;
74     uint8_t rel_addr       : 1;
75     uint8_t rsvd1          : 2;
76     uint8_t force_access   : 1; // can't use cache for data
77     uint8_t disable_pg_out : 1;
78     uint8_t lun            : 3;
79     uint32_t lba;
80     uint8_t rsvd2;
81     uint16_t xfer_len;
82     uint8_t ctrl;
83 } __attribute__((packed));
84
85
86 struct atapi_mode_sense_cmd {
87     uint8_t atapi_cmd;  // 0x5a
88     uint8_t rsvd1            : 3;
89     uint8_t disable_blk_desc : 1;
90     uint8_t long_lba_acc     : 1;
91     uint8_t lun              : 3;
92     uint8_t page_code        : 6;
93     uint8_t page_ctrl        : 2;
94     uint8_t sub_page_code;
95     uint8_t rsvd2[3];
96     uint16_t alloc_len;
97     uint8_t link             : 1;
98     uint8_t flag             : 1;
99     uint8_t naca             : 1;
100     uint8_t rsvd3            : 3;
101     uint8_t vendor_specific  : 2;
102 } __attribute__((packed));
103
104 struct atapi_mode_sense_hdr {
105     uint16_t mode_data_len;
106     uint8_t media_type_code;
107     uint8_t rsvd[2];
108     uint16_t blk_desc_len;
109 } __attribute__((packed));
110
111
112 struct atapi_rd_capacity_cmd {
113     uint8_t atapi_cmd;  // 0x25
114     uint8_t obsolete         : 1;
115     uint8_t rsvd1            : 4;
116     uint8_t lun              : 3;
117     uint32_t lba;
118     uint16_t rsvd2;
119     uint8_t pmi;
120     uint8_t rsvd3            : 7;
121     uint8_t link             : 1;
122     uint8_t flag             : 1;
123     uint8_t naca             : 1;
124     uint8_t rsvd4            : 3;
125     uint8_t vendor_spec      : 2;
126 } __attribute__((packed));
127
128
129 struct atapi_rd_capacity_resp {
130     uint32_t lba;
131     uint32_t block_len;
132 } __attribute__((packed));
133
134
135 struct atapi_rd_toc_cmd {
136     uint8_t atapi_cmd;  // 0x43
137     uint8_t rsvd1            : 1;
138     uint8_t msf              : 1;
139     uint8_t rsvd2            : 3;
140     uint8_t lun              : 3;
141     uint8_t format           : 4;
142     uint8_t rsvd3            : 4;
143     uint8_t rsvd4[3];
144     uint8_t track_num;
145     uint16_t alloc_len;
146     uint8_t link             : 1;
147     uint8_t flag             : 1;
148     uint8_t naca             : 1;
149     uint8_t rsvd5            : 3;
150     uint8_t vendor_specific  : 2;
151 } __attribute__((packed));
152
153 struct atapi_rd_toc_resp {
154     uint16_t data_len;
155     uint8_t first_track_num;
156     uint8_t last_track_num;
157     
158     struct {
159         uint8_t rsvd;
160         uint8_t ctrl         : 4;
161         uint8_t adr          : 4;
162         uint8_t track_num;
163         uint8_t rsvd2;
164         uint32_t start_addr;
165     } track_descs[0] __attribute__((packed)) ;
166
167 } __attribute__((packed));
168
169
170 struct atapi_error_recovery {
171     uint8_t page_code     : 6;
172     uint8_t rsvd          : 1;
173     uint8_t page_ctrl     : 1;
174     uint8_t page_len;
175     uint8_t dcr           : 1;
176     uint8_t dte           : 1;
177     uint8_t per           : 1;
178     uint8_t rsvd1         : 1;
179     uint8_t rc            : 1;
180     uint8_t tb            : 1;
181     uint8_t arre          : 1;
182     uint8_t awre          : 1;
183     uint8_t rd_retry_cnt;
184     uint8_t correct_spin;
185     uint8_t head_offset;
186     uint8_t data_strobe_offset;
187     uint8_t emcdr         : 2;
188     uint8_t rsvd2         : 6;
189     uint8_t wr_retry_cnt;
190     uint8_t rsvd3;
191     uint16_t recovery_time_limit;
192 } __attribute__((packed));
193
194
195 struct atapi_cdrom_caps {
196     uint8_t page_code     : 6;
197     uint8_t rsvd          : 1;
198     uint8_t page_ctrl     : 1;
199     uint8_t page_len;
200     uint8_t cdr_rd        : 1;
201     uint8_t cdrw_rd       : 1;
202     uint8_t mthd_2        : 1;
203     uint8_t dvdrom_rd     : 1;
204     uint8_t dvdr_rd       : 1;
205     uint8_t dvdram_rd     : 1;
206     uint8_t rsvd1         : 2;
207     uint8_t cdr_wr        : 1;
208     uint8_t cdrw_wr       : 1;
209     uint8_t tst_wr        : 1;
210     uint8_t rsvd2         : 1;
211     uint8_t dvdr_wr       : 1;
212     uint8_t dvdram_wr     : 1;
213     uint8_t rsvd3         : 2;
214     uint8_t audio_play    : 1;
215     uint8_t composite     : 1;
216     uint8_t digi_port1    : 1;
217     uint8_t digi_port2    : 1;
218     uint8_t mode2_form1   : 1;
219     uint8_t mode2_form2   : 1;
220     uint8_t multisession  : 1;
221     uint8_t BUF           : 1;
222     uint8_t cd_da         : 1;
223     uint8_t cdda_str_acc  : 1;
224     uint8_t rw_supported  : 1;
225     uint8_t rw_dc         : 1;
226     uint8_t c2_ptrs_supp  : 1;
227     uint8_t isrc          : 1;
228     uint8_t upc           : 1;
229     uint8_t rd_bar_cd_cap : 1;
230     uint8_t lock          : 1;
231     uint8_t lock_state    : 1;
232     uint8_t prevent_jmpr  : 1;
233     uint8_t eject         : 1;
234     uint8_t rsvd4         : 1;
235     uint8_t lmt           : 3;
236     uint8_t sep_vol       : 1;
237     uint8_t sep_chnl_mute : 1;
238     uint8_t sdp           : 1;
239     uint8_t sss           : 1;
240     uint8_t side_chg_cap  : 1;
241     uint8_t rw_in_lead_rd : 1;
242     uint8_t rsvd5         : 2;
243     uint16_t obsolete1;
244     uint16_t num_vols_supp;
245     uint16_t lun_buf_size; // in KBytes
246     uint16_t obsolete2;
247     uint8_t obsolete3;
248     uint8_t rsvd6         : 1;
249     uint8_t bckf          : 1;
250     uint8_t rck           : 1;
251     uint8_t lsbf          : 1;
252     uint8_t len           : 2;
253     uint8_t rsvd7         : 2;
254     uint16_t obsolete4[2];
255     uint16_t cp_mgmnt_rev_supp;
256     uint8_t rsvd8;
257     uint8_t rot_ctrl_sel  : 2;
258     uint8_t rsvd9         : 6;
259     uint16_t cur_wr_spd; // KBytes/sec
260     uint16_t num_lun_wr_spd_dsc_tbls;
261     // lun write speed descriptor tables
262 } __attribute__((packed));
263
264 #endif
265
266 #endif