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.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
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.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21 #ifndef __DEVICES_IDE_TYPES_H__
22 #define __DEVICES_IDE_TYPES_H__
26 #include <palacios/vmm_types.h>
29 struct ide_error_reg {
33 uint_t addr_mark_nf : 1;
39 uint_t data_error : 1;
41 } __attribute__((packed));
42 } __attribute__((packed));
43 } __attribute__((packed));
47 struct ide_drive_head_reg {
56 } __attribute__((packed));
57 } __attribute__((packed));
58 } __attribute__((packed));
62 struct ide_status_reg {
70 uint_t seek_complete : 1;
71 uint_t write_fault : 1;
74 } __attribute__((packed));
75 } __attribute__((packed));
76 } __attribute__((packed));
84 uint_t irq_disable : 1;
85 uint_t soft_reset : 1;
87 } __attribute__((packed));
88 } __attribute__((packed));
89 } __attribute__((packed));
92 struct ide_features_reg {
95 uint8_t dma; // 1 == DMA, 0 = PIO
96 } __attribute__((packed));
97 } __attribute__((packed));
100 struct ide_dma_cmd_reg {
108 } __attribute__((packed));
109 } __attribute__((packed));
110 } __attribute__((packed));
114 struct ide_dma_status_reg {
122 uint8_t prd_int_status : 1;
123 } __attribute__((packed));
124 } __attribute__((packed));
125 } __attribute__((packed));
131 uint8_t end_of_table : 1;
132 } __attribute__((packed));
136 typedef enum {IDE_CTRL_NOT_SPECIFIED,
137 IDE_CTRL_SINGLE_PORT,
139 IDE_CTRL_DUAL_PORT_CACHE} ide_controller_type;
141 struct ide_drive_id {
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;
164 uint16_t num_cylinders;
172 uint16_t bytes_per_track;
174 uint16_t bytes_per_sector;
176 uint16_t sectors_per_track;
182 uint8_t phase_lock_bytes;
186 uint16_t num_vendor_wds;
189 uint8_t serial_num[20]; // right aligned, padded with 0x20
192 uint16_t controller_type;
195 uint16_t buffer_size; // in 512 byte chunks
198 uint16_t num_ecc_bytes;
201 uint8_t firmware_rev[8]; // space padded
204 uint8_t model_num[40]; // space padded
207 uint16_t rw_multiples;
214 uint8_t dma_enable : 1;
215 uint8_t lba_enable : 1;
217 uint8_t IORDYsup : 1;
225 uint16_t min_PIO_cycle; // 0=slow, 1=medium, 2=fast
227 uint16_t min_DMA_cycle; // 0=slow, 1=medium, 2=fast
230 uint16_t field_valid; // 2: ultra_ok word 88
231 // 1: eide_ok words 64-70
232 // 0: cur_ok words 54-58
238 uint16_t cur_sectors;
240 uint16_t cur_capacity0;
242 uint16_t cur_capacity1;
245 uint8_t cur_mult_sect_cnt;
246 uint8_t mult_sect_valid; // bit0==0: valid
249 uint32_t lba_capacity;
257 uint16_t eide_pio_modes; // 0: (mode 3), 1: (mode 4)
259 uint16_t eide_dma_min; /* min mword dma cycle time (ns) */
261 uint16_t eide_dma_time; /* recommended mword dma cycle time (ns) */
263 uint16_t eide_pio; /* min cycle time (ns), no IORDY */
265 uint16_t eide_pio_iordy; /* min cycle time (ns), with IORDY */
271 uint16_t queue_depth;
277 uint16_t major_rev_num;
279 uint16_t minor_rev_num;
281 uint16_t cmd_set_1; /* 15: Obsolete
286 * 10: Host Protected Area
288 * 8: SERVICE Interrupt
289 * 7: Release Interrupt
293 * 3: Power Management Feature Set
294 * 2: Removable Feature Set
295 * 1: Security Feature Set
300 uint16_t cmd_set_2; /* 15: Shall be ZERO
302 * 13: FLUSH CACHE EXT
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
314 * 1: READ/WRITE DMA QUEUED
315 * 0: Download MicroCode
319 uint16_t cfsse; /* cmd set-feature supported extensions
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
332 uint16_t cfs_enable_1; /* command set-feature enabled
338 * 10: Host Protected Area
340 * 8: SERVICE Interrupt
341 * 7: Release Interrupt
345 * 3: Power Management Feature Set
346 * 2: Removable Feature Set
347 * 1: Security Feature Set
348 * 0: SMART Feature Set
351 uint16_t cfs_enable_2; /* command set-feature enabled
354 * 13: FLUSH CACHE EXT
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
366 * 1: READ/WRITE DMA QUEUED
367 * 0: Download MicroCode
370 uint16_t csf_default; /* command set-feature default
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
384 uint16_t trs_euc; /* time required for security erase */
386 uint16_t trs_Euc; /* time required for enhanced erase */
388 uint16_t cur_apm_values; /* current APM values */
390 uint16_t mprc; /* master password revision code */
392 uint16_t hw_config; /* hardware config (word 93)
400 uint16_t msrqs; /* min stream request size */
402 uint16_t sxfert; /* stream transfer time */
404 uint16_t sal; /* stream access latency */
406 uint32_t spg; /* stream performance granularity */
408 uint64_t lba_capacity_2; /* 48-bit total number of sectors */
415 uint16_t feature_set; // Removable Media Notification
418 uint16_t dlf; /* device lock function
420 * 8 security level 1:max 0:high
430 uint16_t csfo; /* current set features options
447 uint16_t cur_media_ser_num[30];
451 uint16_t integrity; /* 15:8 Checksum
456 } __attribute__((packed));
457 } __attribute__((packed));
458 } __attribute__((packed));
461 #endif // ! __V3VEE__