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.


3ae99662f64e460cc2a6675e1c58d8d2c1fe0d9e
[palacios.git] / palacios / src / devices / ide-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_IDE_TYPES_H__
22 #define __DEVICES_IDE_TYPES_H__
23
24 #ifdef __V3VEE__
25
26 #include <palacios/vmm_types.h>
27
28
29 struct ide_error_reg {
30     union {
31         uint8_t val;
32         struct {
33             uint_t addr_mark_nf     : 1;
34             uint_t track0_nf        : 1;
35             uint_t abort            : 1;
36             uint_t rsvd0            : 1;
37             uint_t ID_nf            : 1;
38             uint_t rsvd1            : 1;
39             uint_t data_error       : 1;
40             uint_t bad_block        : 1;
41         } __attribute__((packed));
42     } __attribute__((packed));
43 } __attribute__((packed));
44
45
46
47 struct ide_drive_head_reg {
48     union {
49         uint8_t val;
50         struct {
51             uint_t head_num      : 4;
52             uint_t drive_sel     : 1;
53             uint_t rsvd1         : 1;
54             uint_t lba_mode      : 1;
55             uint_t rsvd2         : 1;
56         } __attribute__((packed));
57     } __attribute__((packed));
58 } __attribute__((packed));
59
60
61
62 struct ide_status_reg {
63     union {
64         uint8_t val;
65         struct {
66             uint_t error         : 1;
67             uint_t index         : 1;
68             uint_t corrected     : 1;
69             uint_t data_req      : 1;
70             uint_t seek_complete : 1;
71             uint_t write_fault   : 1;
72             uint_t ready         : 1;
73             uint_t busy          : 1;
74         } __attribute__((packed));
75     } __attribute__((packed));
76 } __attribute__((packed));
77
78
79 struct ide_ctrl_reg {
80     union {
81         uint8_t val;
82         struct {
83             uint_t rsvd0        : 1;
84             uint_t irq_disable   : 1;
85             uint_t soft_reset   : 1;
86             uint_t rsvd1        : 5;
87         } __attribute__((packed));
88     } __attribute__((packed));
89 } __attribute__((packed));
90
91
92 struct ide_features_reg {
93     union {
94         uint8_t val;
95         uint8_t dma; // 1 == DMA, 0 = PIO
96     } __attribute__((packed));
97 } __attribute__((packed));
98
99
100 struct ide_dma_cmd_reg {
101     union {
102         uint8_t val;
103         struct {
104             uint8_t start : 1;
105             uint8_t rsvd1 : 2;
106             uint8_t read  : 1;
107             uint8_t rsvd2 : 4;
108         } __attribute__((packed));
109     } __attribute__((packed));
110 } __attribute__((packed));
111
112
113
114 struct ide_dma_status_reg {
115     union {
116         uint8_t val;
117         struct {
118             uint8_t active  : 1;
119             uint8_t err     : 1;
120             uint8_t int_gen : 1;
121             uint8_t rsvd1   : 4;
122             uint8_t prd_int_status : 1;
123         } __attribute__((packed));
124     } __attribute__((packed));
125 } __attribute__((packed));
126
127 struct ide_dma_prd {
128     uint32_t base_addr;
129     uint16_t size;
130     uint16_t rsvd           : 15;
131     uint8_t end_of_table    : 1;
132 } __attribute__((packed));
133
134
135
136 typedef enum {IDE_CTRL_NOT_SPECIFIED, 
137               IDE_CTRL_SINGLE_PORT, 
138               IDE_CTRL_DUAL_PORT, 
139               IDE_CTRL_DUAL_PORT_CACHE} ide_controller_type;
140
141 struct ide_drive_id {
142     union {
143         uint16_t buf[256];
144         struct {
145             // 0
146             uint_t rsvd1           : 1;
147             uint_t hard_sectors    : 1;
148             uint_t no_soft_sectors : 1;
149             uint_t no_mfm_enc      : 1;
150             uint_t head_switch_time : 1;
151             uint_t spnd_mot_ctrl   : 1;
152             uint_t fixed_drive     : 1;
153             uint_t removable_media : 1;
154             uint_t disk_speed1     : 1;
155             uint_t disk_speed2     : 1;
156             uint_t disk_speed3     : 1;
157             uint_t rpm_tolerance   : 1;
158             uint_t data_strobe_offset : 1;
159             uint_t track_offset_option : 1;
160             uint_t fmt_speed_tol   : 1;
161             uint_t cdrom_flag      : 1;
162
163             // 1
164             uint16_t num_cylinders;
165
166             // 2
167             uint16_t rsvd2;
168             
169             // 3
170             uint16_t num_heads;
171             // 4
172             uint16_t bytes_per_track;
173             // 5
174             uint16_t bytes_per_sector;
175             // 6
176             uint16_t sectors_per_track;
177
178             // 7
179             uint16_t sector_gap;
180             
181             // 8
182             uint8_t phase_lock_bytes;
183             uint8_t rsvd3;
184
185             // 9
186             uint16_t num_vendor_wds;
187             
188             // 10
189             uint8_t serial_num[20]; // right aligned, padded with 0x20
190             
191             // 20
192             uint16_t controller_type;
193
194             // 21
195             uint16_t buffer_size; // in 512 byte chunks
196             
197             // 22
198             uint16_t num_ecc_bytes;
199
200             // 23
201             uint8_t firmware_rev[8]; // space padded
202
203             // 27
204             uint8_t model_num[40]; // space padded
205             
206             // 47
207             uint16_t rw_multiples;
208
209             // 48
210             uint16_t dword_io;
211
212             // 49
213             uint8_t rsvd4;
214             uint8_t dma_enable : 1;
215             uint8_t lba_enable : 1;
216             uint8_t IORDYsw    : 1;
217             uint8_t IORDYsup   : 1;
218             uint8_t rsvd5      : 4;
219
220             
221             // 50
222             uint16_t rsvd6;
223             
224             // 51
225             uint16_t min_PIO_cycle; // 0=slow, 1=medium, 2=fast
226             // 52
227             uint16_t min_DMA_cycle; // 0=slow, 1=medium, 2=fast
228
229             // 53
230             uint16_t field_valid; //  2:        ultra_ok        word  88
231                                   //  1:        eide_ok         words 64-70
232                                   //  0:        cur_ok          words 54-58
233             // 54
234             uint16_t cur_cyls;
235             // 55 
236             uint16_t cur_heads;
237             // 56
238             uint16_t cur_sectors;
239             // 57
240             uint16_t cur_capacity0;
241             // 58
242             uint16_t cur_capacity1;
243
244             // 59
245             uint8_t cur_mult_sect_cnt;
246             uint8_t mult_sect_valid; // bit0==0: valid
247
248             // 60
249             uint32_t lba_capacity;
250
251             // 62
252             uint16_t dma_lword;
253             // 63
254             uint16_t dma_mword;
255
256             // 64
257             uint16_t eide_pio_modes; // 0: (mode 3), 1: (mode 4)
258             // 65
259             uint16_t eide_dma_min; /* min mword dma cycle time (ns) */
260             // 66 
261             uint16_t eide_dma_time; /* recommended mword dma cycle time (ns) */
262             // 67
263             uint16_t eide_pio; /* min cycle time (ns), no IORDY  */
264             // 68
265             uint16_t eide_pio_iordy; /* min cycle time (ns), with IORDY */
266
267             // 69
268             uint16_t rsvd7[6];
269
270             // 75
271             uint16_t queue_depth;
272
273             // 76
274             uint16_t rsvd8[4];
275
276             // 80
277             uint16_t major_rev_num;
278             // 81
279             uint16_t minor_rev_num;
280             // 82
281             uint16_t cmd_set_1; /*  15: Obsolete
282                                  * 14:  NOP command
283                                  * 13:  READ_BUFFER
284                                  * 12:  WRITE_BUFFER
285                                  * 11:  Obsolete
286                                  * 10:  Host Protected Area
287                                  *  9:  DEVICE Reset
288                                  *  8:  SERVICE Interrupt
289                                  *  7:  Release Interrupt
290                                  *  6:  look-ahead
291                                  *  5:  write cache
292                                  *  4:  PACKET Command
293                                  *  3:  Power Management Feature Set
294                                  *  2:  Removable Feature Set
295                                  *  1:  Security Feature Set
296                                  *  0:  S
297                                  */
298
299             // 83
300             uint16_t cmd_set_2; /*  15: Shall be ZERO
301                                  * 14:  Shall be ONE
302                                  * 13:  FLUSH CACHE EXT
303                                  * 12:  FLUSH CACHE
304                                  * 11:  Device Configuration Overlay
305                                  * 10:  48-bit Address Feature Set
306                                  *  9:  Automatic Acoustic Management
307                                  *  8:  SET MAX security
308                                  *  7:  reserved 1407DT PARTIES
309                                  *  6:  SetF sub-command Power-Up
310                                  *  5:  Power-Up in Standby Feature Set
311                                  *  4:  Removable Media Notification
312                                  *  3:  APM Feature Set
313                                  *  2:  CFA Feature Set
314                                  *  1:  READ/WRITE DMA QUEUED
315                                  *  0:  Download MicroCode
316                                  */
317
318             // 84
319             uint16_t cfsse;     /*  cmd set-feature supported extensions
320                                  * 15:  Shall be ZERO
321                                  * 14:  Shall be ONE
322                                  * 13:6 reserved
323                                  *  5:  General Purpose Logging
324                                  *  4:  Streaming Feature Set
325                                  *  3:  Media Card Pass Through
326                                  *  2:  Media Serial Number Valid
327                                  *  1:  SMART selt-test supported
328                                  *  0:  SMART error logging
329                                  */
330
331             // 85
332             uint16_t cfs_enable_1;      /* command set-feature enabled
333                                          * 15:  Obsolete
334                                          * 14:  NOP command
335                                          * 13:  READ_BUFFER
336                                          * 12:  WRITE_BUFFER
337                                          * 11:  Obsolete
338                                          * 10:  Host Protected Area
339                                          *  9:  DEVICE Reset
340                                          *  8:  SERVICE Interrupt
341                                          *  7:  Release Interrupt
342                                          *  6:  look-ahead
343                                          *  5:  write cache
344                                          *  4:  PACKET Command
345                                          *  3:  Power Management Feature Set
346                                          *  2:  Removable Feature Set
347                                          *  1:  Security Feature Set
348                                          *  0:  SMART Feature Set
349                                          */
350             // 86
351             uint16_t cfs_enable_2;      /* command set-feature enabled
352                                          * 15:  Shall be ZERO
353                                          * 14:  Shall be ONE
354                                          * 13:  FLUSH CACHE EXT
355                                          * 12:  FLUSH CACHE
356                                          * 11:  Device Configuration Overlay
357                                          * 10:  48-bit Address Feature Set
358                                          *  9:  Automatic Acoustic Management
359                                          *  8:  SET MAX security
360                                          *  7:  reserved 1407DT PARTIES
361                                          *  6:  SetF sub-command Power-Up
362                                          *  5:  Power-Up in Standby Feature Set
363                                          *  4:  Removable Media Notification
364                                          *  3:  APM Feature Set
365                                          *  2:  CFA Feature Set
366                                          *  1:  READ/WRITE DMA QUEUED
367                                          *  0:  Download MicroCode
368                                          */
369             // 87
370             uint16_t csf_default;       /* command set-feature default
371                                          * 15:  Shall be ZERO
372                                          * 14:  Shall be ONE
373                                          * 13:6 reserved
374                                          *  5:  General Purpose Logging enabled
375                                          *  4:  Valid CONFIGURE STREAM executed
376                                          *  3:  Media Card Pass Through enabled
377                                          *  2:  Media Serial Number Valid
378                                          *  1:  SMART selt-test supported
379                                          *  0:  SMART error logging
380                                          */
381             // 88
382             uint16_t dma_ultra; 
383             // 89
384             uint16_t trs_euc;           /* time required for security erase */
385             // 90
386             uint16_t trs_Euc;           /* time required for enhanced erase */
387             // 91
388             uint16_t cur_apm_values;    /* current APM values */
389             // 92
390             uint16_t mprc;              /* master password revision code */
391             // 93
392             uint16_t hw_config;         /* hardware config (word 93)
393                                          * 15:  Shall be ZERO
394                                          * 14:  Shall be ONE
395                                          *  0:  Shall be ONE
396                                          */
397             // 94
398             uint16_t acoustic;
399             // 95
400             uint16_t msrqs;             /* min stream request size */
401             // 96
402             uint16_t sxfert;            /* stream transfer time */
403             // 97
404             uint16_t sal;               /* stream access latency */
405             // 98
406             uint32_t spg;               /* stream performance granularity */
407             // 100
408             uint64_t lba_capacity_2; /* 48-bit total number of sectors */
409             // 104
410             uint16_t rsvd9[22];
411
412             // 126
413             uint16_t last_lun;
414             // 127
415             uint16_t feature_set; //  Removable Media Notification
416
417             // 128
418             uint16_t dlf; /* device lock function
419                            * 15:9       reserved
420                            *  8 security level 1:max 0:high
421                            *  7:6       reserved
422                            *  5 enhanced erase
423                            *  4 expire
424                            *  3 frozen
425                            *  2 locked
426                            *  1 en/disabled
427                            *  0 capability
428                            */
429             // 129
430             uint16_t csfo; /* current set features options
431                             * 15:4      reserved
432                             *  3:       auto reassign
433                             *  2:       reverting
434                             *  1:       read-look-ahead
435                             *  0:       write cache
436                             */
437             
438             // 130
439             uint16_t rsvd10[30];
440             
441             // 160
442             uint16_t cfa_power;
443
444             // 161 
445             uint16_t cfa[15];
446             // 176
447             uint16_t cur_media_ser_num[30];
448             // 206
449             uint16_t rsvd11[49];
450             // 255
451             uint16_t integrity; /* 15:8 Checksum
452                                  *  7:0 Signature
453                                  */
454             
455
456         } __attribute__((packed));
457     } __attribute__((packed));
458 } __attribute__((packed));
459
460
461 #endif // ! __V3VEE__
462
463 #endif