xref: /qemu/hw/ide/ide-internal.h (revision 88804180fd705d3c4f3dd50e0b9bd7b70c5db0ef)
1 #ifndef HW_IDE_INTERNAL_H
2 #define HW_IDE_INTERNAL_H
3 
4 /*
5  * QEMU IDE Emulation -- internal header file
6  * only files in hw/ide/ are supposed to include this file.
7  * non-internal declarations are in hw/ide.h
8  */
9 #include <hw/ide.h>
10 
11 /* debug IDE devices */
12 //#define DEBUG_IDE
13 //#define DEBUG_IDE_ATAPI
14 //#define DEBUG_AIO
15 #define USE_DMA_CDROM
16 
17 typedef struct IDEBus IDEBus;
18 typedef struct IDEState IDEState;
19 typedef struct BMDMAState BMDMAState;
20 
21 /* debug IDE devices */
22 //#define DEBUG_IDE
23 //#define DEBUG_IDE_ATAPI
24 //#define DEBUG_AIO
25 #define USE_DMA_CDROM
26 
27 /* Bits of HD_STATUS */
28 #define ERR_STAT		0x01
29 #define INDEX_STAT		0x02
30 #define ECC_STAT		0x04	/* Corrected error */
31 #define DRQ_STAT		0x08
32 #define SEEK_STAT		0x10
33 #define SRV_STAT		0x10
34 #define WRERR_STAT		0x20
35 #define READY_STAT		0x40
36 #define BUSY_STAT		0x80
37 
38 /* Bits for HD_ERROR */
39 #define MARK_ERR		0x01	/* Bad address mark */
40 #define TRK0_ERR		0x02	/* couldn't find track 0 */
41 #define ABRT_ERR		0x04	/* Command aborted */
42 #define MCR_ERR			0x08	/* media change request */
43 #define ID_ERR			0x10	/* ID field not found */
44 #define MC_ERR			0x20	/* media changed */
45 #define ECC_ERR			0x40	/* Uncorrectable ECC error */
46 #define BBD_ERR			0x80	/* pre-EIDE meaning:  block marked bad */
47 #define ICRC_ERR		0x80	/* new meaning:  CRC error during transfer */
48 
49 /* Bits of HD_NSECTOR */
50 #define CD			0x01
51 #define IO			0x02
52 #define REL			0x04
53 #define TAG_MASK		0xf8
54 
55 #define IDE_CMD_RESET           0x04
56 #define IDE_CMD_DISABLE_IRQ     0x02
57 
58 /* ATA/ATAPI Commands pre T13 Spec */
59 #define WIN_NOP				0x00
60 /*
61  *	0x01->0x02 Reserved
62  */
63 #define CFA_REQ_EXT_ERROR_CODE		0x03 /* CFA Request Extended Error Code */
64 /*
65  *	0x04->0x07 Reserved
66  */
67 #define WIN_SRST			0x08 /* ATAPI soft reset command */
68 #define WIN_DEVICE_RESET		0x08
69 /*
70  *	0x09->0x0F Reserved
71  */
72 #define WIN_RECAL			0x10
73 #define WIN_RESTORE			WIN_RECAL
74 /*
75  *	0x10->0x1F Reserved
76  */
77 #define WIN_READ			0x20 /* 28-Bit */
78 #define WIN_READ_ONCE			0x21 /* 28-Bit without retries */
79 #define WIN_READ_LONG			0x22 /* 28-Bit */
80 #define WIN_READ_LONG_ONCE		0x23 /* 28-Bit without retries */
81 #define WIN_READ_EXT			0x24 /* 48-Bit */
82 #define WIN_READDMA_EXT			0x25 /* 48-Bit */
83 #define WIN_READDMA_QUEUED_EXT		0x26 /* 48-Bit */
84 #define WIN_READ_NATIVE_MAX_EXT		0x27 /* 48-Bit */
85 /*
86  *	0x28
87  */
88 #define WIN_MULTREAD_EXT		0x29 /* 48-Bit */
89 /*
90  *	0x2A->0x2F Reserved
91  */
92 #define WIN_WRITE			0x30 /* 28-Bit */
93 #define WIN_WRITE_ONCE			0x31 /* 28-Bit without retries */
94 #define WIN_WRITE_LONG			0x32 /* 28-Bit */
95 #define WIN_WRITE_LONG_ONCE		0x33 /* 28-Bit without retries */
96 #define WIN_WRITE_EXT			0x34 /* 48-Bit */
97 #define WIN_WRITEDMA_EXT		0x35 /* 48-Bit */
98 #define WIN_WRITEDMA_QUEUED_EXT		0x36 /* 48-Bit */
99 #define WIN_SET_MAX_EXT			0x37 /* 48-Bit */
100 #define CFA_WRITE_SECT_WO_ERASE		0x38 /* CFA Write Sectors without erase */
101 #define WIN_MULTWRITE_EXT		0x39 /* 48-Bit */
102 /*
103  *	0x3A->0x3B Reserved
104  */
105 #define WIN_WRITE_VERIFY		0x3C /* 28-Bit */
106 /*
107  *	0x3D->0x3F Reserved
108  */
109 #define WIN_VERIFY			0x40 /* 28-Bit - Read Verify Sectors */
110 #define WIN_VERIFY_ONCE			0x41 /* 28-Bit - without retries */
111 #define WIN_VERIFY_EXT			0x42 /* 48-Bit */
112 /*
113  *	0x43->0x4F Reserved
114  */
115 #define WIN_FORMAT			0x50
116 /*
117  *	0x51->0x5F Reserved
118  */
119 #define WIN_INIT			0x60
120 /*
121  *	0x61->0x5F Reserved
122  */
123 #define WIN_SEEK			0x70 /* 0x70-0x7F Reserved */
124 #define CFA_TRANSLATE_SECTOR		0x87 /* CFA Translate Sector */
125 #define WIN_DIAGNOSE			0x90
126 #define WIN_SPECIFY			0x91 /* set drive geometry translation */
127 #define WIN_DOWNLOAD_MICROCODE		0x92
128 #define WIN_STANDBYNOW2			0x94
129 #define CFA_IDLEIMMEDIATE		0x95 /* force drive to become "ready" */
130 #define WIN_STANDBY2			0x96
131 #define WIN_SETIDLE2			0x97
132 #define WIN_CHECKPOWERMODE2		0x98
133 #define WIN_SLEEPNOW2			0x99
134 /*
135  *	0x9A VENDOR
136  */
137 #define WIN_PACKETCMD			0xA0 /* Send a packet command. */
138 #define WIN_PIDENTIFY			0xA1 /* identify ATAPI device	*/
139 #define WIN_QUEUED_SERVICE		0xA2
140 #define WIN_SMART			0xB0 /* self-monitoring and reporting */
141 #define CFA_ACCESS_METADATA_STORAGE	0xB8
142 #define CFA_ERASE_SECTORS       	0xC0 /* microdrives implement as NOP */
143 #define WIN_MULTREAD			0xC4 /* read sectors using multiple mode*/
144 #define WIN_MULTWRITE			0xC5 /* write sectors using multiple mode */
145 #define WIN_SETMULT			0xC6 /* enable/disable multiple mode */
146 #define WIN_READDMA_QUEUED		0xC7 /* read sectors using Queued DMA transfers */
147 #define WIN_READDMA			0xC8 /* read sectors using DMA transfers */
148 #define WIN_READDMA_ONCE		0xC9 /* 28-Bit - without retries */
149 #define WIN_WRITEDMA			0xCA /* write sectors using DMA transfers */
150 #define WIN_WRITEDMA_ONCE		0xCB /* 28-Bit - without retries */
151 #define WIN_WRITEDMA_QUEUED		0xCC /* write sectors using Queued DMA transfers */
152 #define CFA_WRITE_MULTI_WO_ERASE	0xCD /* CFA Write multiple without erase */
153 #define WIN_GETMEDIASTATUS		0xDA
154 #define WIN_ACKMEDIACHANGE		0xDB /* ATA-1, ATA-2 vendor */
155 #define WIN_POSTBOOT			0xDC
156 #define WIN_PREBOOT			0xDD
157 #define WIN_DOORLOCK			0xDE /* lock door on removable drives */
158 #define WIN_DOORUNLOCK			0xDF /* unlock door on removable drives */
159 #define WIN_STANDBYNOW1			0xE0
160 #define WIN_IDLEIMMEDIATE		0xE1 /* force drive to become "ready" */
161 #define WIN_STANDBY             	0xE2 /* Set device in Standby Mode */
162 #define WIN_SETIDLE1			0xE3
163 #define WIN_READ_BUFFER			0xE4 /* force read only 1 sector */
164 #define WIN_CHECKPOWERMODE1		0xE5
165 #define WIN_SLEEPNOW1			0xE6
166 #define WIN_FLUSH_CACHE			0xE7
167 #define WIN_WRITE_BUFFER		0xE8 /* force write only 1 sector */
168 #define WIN_WRITE_SAME			0xE9 /* read ata-2 to use */
169 	/* SET_FEATURES 0x22 or 0xDD */
170 #define WIN_FLUSH_CACHE_EXT		0xEA /* 48-Bit */
171 #define WIN_IDENTIFY			0xEC /* ask drive to identify itself	*/
172 #define WIN_MEDIAEJECT			0xED
173 #define WIN_IDENTIFY_DMA		0xEE /* same as WIN_IDENTIFY, but DMA */
174 #define WIN_SETFEATURES			0xEF /* set special drive features */
175 #define EXABYTE_ENABLE_NEST		0xF0
176 #define IBM_SENSE_CONDITION		0xF0 /* measure disk temperature */
177 #define WIN_SECURITY_SET_PASS		0xF1
178 #define WIN_SECURITY_UNLOCK		0xF2
179 #define WIN_SECURITY_ERASE_PREPARE	0xF3
180 #define WIN_SECURITY_ERASE_UNIT		0xF4
181 #define WIN_SECURITY_FREEZE_LOCK	0xF5
182 #define CFA_WEAR_LEVEL			0xF5 /* microdrives implement as NOP */
183 #define WIN_SECURITY_DISABLE		0xF6
184 #define WIN_READ_NATIVE_MAX		0xF8 /* return the native maximum address */
185 #define WIN_SET_MAX			0xF9
186 #define DISABLE_SEAGATE			0xFB
187 
188 /* set to 1 set disable mult support */
189 #define MAX_MULT_SECTORS 16
190 
191 #define IDE_DMA_BUF_SECTORS 256
192 
193 #if (IDE_DMA_BUF_SECTORS < MAX_MULT_SECTORS)
194 #error "IDE_DMA_BUF_SECTORS must be bigger or equal to MAX_MULT_SECTORS"
195 #endif
196 
197 /* ATAPI defines */
198 
199 #define ATAPI_PACKET_SIZE 12
200 
201 /* The generic packet command opcodes for CD/DVD Logical Units,
202  * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
203 #define GPCMD_BLANK			    0xa1
204 #define GPCMD_CLOSE_TRACK		    0x5b
205 #define GPCMD_FLUSH_CACHE		    0x35
206 #define GPCMD_FORMAT_UNIT		    0x04
207 #define GPCMD_GET_CONFIGURATION		    0x46
208 #define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a
209 #define GPCMD_GET_PERFORMANCE		    0xac
210 #define GPCMD_INQUIRY			    0x12
211 #define GPCMD_LOAD_UNLOAD		    0xa6
212 #define GPCMD_MECHANISM_STATUS		    0xbd
213 #define GPCMD_MODE_SELECT_10		    0x55
214 #define GPCMD_MODE_SENSE_10		    0x5a
215 #define GPCMD_PAUSE_RESUME		    0x4b
216 #define GPCMD_PLAY_AUDIO_10		    0x45
217 #define GPCMD_PLAY_AUDIO_MSF		    0x47
218 #define GPCMD_PLAY_AUDIO_TI		    0x48
219 #define GPCMD_PLAY_CD			    0xbc
220 #define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL  0x1e
221 #define GPCMD_READ_10			    0x28
222 #define GPCMD_READ_12			    0xa8
223 #define GPCMD_READ_CDVD_CAPACITY	    0x25
224 #define GPCMD_READ_CD			    0xbe
225 #define GPCMD_READ_CD_MSF		    0xb9
226 #define GPCMD_READ_DISC_INFO		    0x51
227 #define GPCMD_READ_DVD_STRUCTURE	    0xad
228 #define GPCMD_READ_FORMAT_CAPACITIES	    0x23
229 #define GPCMD_READ_HEADER		    0x44
230 #define GPCMD_READ_TRACK_RZONE_INFO	    0x52
231 #define GPCMD_READ_SUBCHANNEL		    0x42
232 #define GPCMD_READ_TOC_PMA_ATIP		    0x43
233 #define GPCMD_REPAIR_RZONE_TRACK	    0x58
234 #define GPCMD_REPORT_KEY		    0xa4
235 #define GPCMD_REQUEST_SENSE		    0x03
236 #define GPCMD_RESERVE_RZONE_TRACK	    0x53
237 #define GPCMD_SCAN			    0xba
238 #define GPCMD_SEEK			    0x2b
239 #define GPCMD_SEND_DVD_STRUCTURE	    0xad
240 #define GPCMD_SEND_EVENT		    0xa2
241 #define GPCMD_SEND_KEY			    0xa3
242 #define GPCMD_SEND_OPC			    0x54
243 #define GPCMD_SET_READ_AHEAD		    0xa7
244 #define GPCMD_SET_STREAMING		    0xb6
245 #define GPCMD_START_STOP_UNIT		    0x1b
246 #define GPCMD_STOP_PLAY_SCAN		    0x4e
247 #define GPCMD_TEST_UNIT_READY		    0x00
248 #define GPCMD_VERIFY_10			    0x2f
249 #define GPCMD_WRITE_10			    0x2a
250 #define GPCMD_WRITE_AND_VERIFY_10	    0x2e
251 /* This is listed as optional in ATAPI 2.6, but is (curiously)
252  * missing from Mt. Fuji, Table 57.  It _is_ mentioned in Mt. Fuji
253  * Table 377 as an MMC command for SCSi devices though...  Most ATAPI
254  * drives support it. */
255 #define GPCMD_SET_SPEED			    0xbb
256 /* This seems to be a SCSI specific CD-ROM opcode
257  * to play data at track/index */
258 #define GPCMD_PLAYAUDIO_TI		    0x48
259 /*
260  * From MS Media Status Notification Support Specification. For
261  * older drives only.
262  */
263 #define GPCMD_GET_MEDIA_STATUS		    0xda
264 #define GPCMD_MODE_SENSE_6		    0x1a
265 
266 /* Mode page codes for mode sense/set */
267 #define GPMODE_R_W_ERROR_PAGE		0x01
268 #define GPMODE_WRITE_PARMS_PAGE		0x05
269 #define GPMODE_AUDIO_CTL_PAGE		0x0e
270 #define GPMODE_POWER_PAGE		0x1a
271 #define GPMODE_FAULT_FAIL_PAGE		0x1c
272 #define GPMODE_TO_PROTECT_PAGE		0x1d
273 #define GPMODE_CAPABILITIES_PAGE	0x2a
274 #define GPMODE_ALL_PAGES		0x3f
275 /* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor
276  * of MODE_SENSE_POWER_PAGE */
277 #define GPMODE_CDROM_PAGE		0x0d
278 
279 /*
280  * Based on values from <linux/cdrom.h> but extending CD_MINS
281  * to the maximum common size allowed by the Orange's Book ATIP
282  *
283  * 90 and 99 min CDs are also available but using them as the
284  * upper limit reduces the effectiveness of the heuristic to
285  * detect DVDs burned to less than 25% of their maximum capacity
286  */
287 
288 /* Some generally useful CD-ROM information */
289 #define CD_MINS                       80 /* max. minutes per CD */
290 #define CD_SECS                       60 /* seconds per minute */
291 #define CD_FRAMES                     75 /* frames per second */
292 #define CD_FRAMESIZE                2048 /* bytes per frame, "cooked" mode */
293 #define CD_MAX_BYTES       (CD_MINS * CD_SECS * CD_FRAMES * CD_FRAMESIZE)
294 #define CD_MAX_SECTORS     (CD_MAX_BYTES / 512)
295 
296 /*
297  * The MMC values are not IDE specific and might need to be moved
298  * to a common header if they are also needed for the SCSI emulation
299  */
300 
301 /* Profile list from MMC-6 revision 1 table 91 */
302 #define MMC_PROFILE_NONE                0x0000
303 #define MMC_PROFILE_CD_ROM              0x0008
304 #define MMC_PROFILE_CD_R                0x0009
305 #define MMC_PROFILE_CD_RW               0x000A
306 #define MMC_PROFILE_DVD_ROM             0x0010
307 #define MMC_PROFILE_DVD_R_SR            0x0011
308 #define MMC_PROFILE_DVD_RAM             0x0012
309 #define MMC_PROFILE_DVD_RW_RO           0x0013
310 #define MMC_PROFILE_DVD_RW_SR           0x0014
311 #define MMC_PROFILE_DVD_R_DL_SR         0x0015
312 #define MMC_PROFILE_DVD_R_DL_JR         0x0016
313 #define MMC_PROFILE_DVD_RW_DL           0x0017
314 #define MMC_PROFILE_DVD_DDR             0x0018
315 #define MMC_PROFILE_DVD_PLUS_RW         0x001A
316 #define MMC_PROFILE_DVD_PLUS_R          0x001B
317 #define MMC_PROFILE_DVD_PLUS_RW_DL      0x002A
318 #define MMC_PROFILE_DVD_PLUS_R_DL       0x002B
319 #define MMC_PROFILE_BD_ROM              0x0040
320 #define MMC_PROFILE_BD_R_SRM            0x0041
321 #define MMC_PROFILE_BD_R_RRM            0x0042
322 #define MMC_PROFILE_BD_RE               0x0043
323 #define MMC_PROFILE_HDDVD_ROM           0x0050
324 #define MMC_PROFILE_HDDVD_R             0x0051
325 #define MMC_PROFILE_HDDVD_RAM           0x0052
326 #define MMC_PROFILE_HDDVD_RW            0x0053
327 #define MMC_PROFILE_HDDVD_R_DL          0x0058
328 #define MMC_PROFILE_HDDVD_RW_DL         0x005A
329 #define MMC_PROFILE_INVALID             0xFFFF
330 
331 #define ATAPI_INT_REASON_CD             0x01 /* 0 = data transfer */
332 #define ATAPI_INT_REASON_IO             0x02 /* 1 = transfer to the host */
333 #define ATAPI_INT_REASON_REL            0x04
334 #define ATAPI_INT_REASON_TAG            0xf8
335 
336 /* same constants as bochs */
337 #define ASC_ILLEGAL_OPCODE                   0x20
338 #define ASC_LOGICAL_BLOCK_OOR                0x21
339 #define ASC_INV_FIELD_IN_CMD_PACKET          0x24
340 #define ASC_MEDIUM_MAY_HAVE_CHANGED          0x28
341 #define ASC_INCOMPATIBLE_FORMAT              0x30
342 #define ASC_MEDIUM_NOT_PRESENT               0x3a
343 #define ASC_SAVING_PARAMETERS_NOT_SUPPORTED  0x39
344 #define ASC_MEDIA_REMOVAL_PREVENTED          0x53
345 
346 #define CFA_NO_ERROR            0x00
347 #define CFA_MISC_ERROR          0x09
348 #define CFA_INVALID_COMMAND     0x20
349 #define CFA_INVALID_ADDRESS     0x21
350 #define CFA_ADDRESS_OVERFLOW    0x2f
351 
352 #define SENSE_NONE            0
353 #define SENSE_NOT_READY       2
354 #define SENSE_ILLEGAL_REQUEST 5
355 #define SENSE_UNIT_ATTENTION  6
356 
357 #define SMART_READ_DATA       0xd0
358 #define SMART_READ_THRESH     0xd1
359 #define SMART_ATTR_AUTOSAVE   0xd2
360 #define SMART_SAVE_ATTR       0xd3
361 #define SMART_EXECUTE_OFFLINE 0xd4
362 #define SMART_READ_LOG        0xd5
363 #define SMART_WRITE_LOG       0xd6
364 #define SMART_ENABLE          0xd8
365 #define SMART_DISABLE         0xd9
366 #define SMART_STATUS          0xda
367 
368 typedef void EndTransferFunc(IDEState *);
369 
370 /* NOTE: IDEState represents in fact one drive */
371 struct IDEState {
372     IDEBus *bus;
373     uint8_t unit;
374     /* ide config */
375     int is_cdrom;
376     int is_cf;
377     int cylinders, heads, sectors;
378     int64_t nb_sectors;
379     int mult_sectors;
380     int identify_set;
381     uint16_t identify_data[256];
382     int drive_serial;
383     char drive_serial_str[21];
384     /* ide regs */
385     uint8_t feature;
386     uint8_t error;
387     uint32_t nsector;
388     uint8_t sector;
389     uint8_t lcyl;
390     uint8_t hcyl;
391     /* other part of tf for lba48 support */
392     uint8_t hob_feature;
393     uint8_t hob_nsector;
394     uint8_t hob_sector;
395     uint8_t hob_lcyl;
396     uint8_t hob_hcyl;
397 
398     uint8_t select;
399     uint8_t status;
400 
401     /* set for lba48 access */
402     uint8_t lba48;
403     BlockDriverState *bs;
404     /* ATAPI specific */
405     uint8_t sense_key;
406     uint8_t asc;
407     uint8_t cdrom_changed;
408     int packet_transfer_size;
409     int elementary_transfer_size;
410     int io_buffer_index;
411     int lba;
412     int cd_sector_size;
413     int atapi_dma; /* true if dma is requested for the packet cmd */
414     /* ATA DMA state */
415     int io_buffer_size;
416     QEMUSGList sg;
417     /* PIO transfer handling */
418     int req_nb_sectors; /* number of sectors per interrupt */
419     EndTransferFunc *end_transfer_func;
420     uint8_t *data_ptr;
421     uint8_t *data_end;
422     uint8_t *io_buffer;
423     QEMUTimer *sector_write_timer; /* only used for win2k install hack */
424     uint32_t irq_count; /* counts IRQs when using win2k install hack */
425     /* CF-ATA extended error */
426     uint8_t ext_error;
427     /* CF-ATA metadata storage */
428     uint32_t mdata_size;
429     uint8_t *mdata_storage;
430     int media_changed;
431     /* for pmac */
432     int is_read;
433     /* SMART */
434     uint8_t smart_enabled;
435     uint8_t smart_autosave;
436     int smart_errors;
437     uint8_t smart_selftest_count;
438     uint8_t *smart_selftest_data;
439 };
440 
441 struct IDEBus {
442     BusState qbus;
443     BMDMAState *bmdma;
444     IDEState ifs[2];
445     uint8_t unit;
446     uint8_t cmd;
447     qemu_irq irq;
448 };
449 
450 #define BM_STATUS_DMAING 0x01
451 #define BM_STATUS_ERROR  0x02
452 #define BM_STATUS_INT    0x04
453 #define BM_STATUS_DMA_RETRY  0x08
454 #define BM_STATUS_PIO_RETRY  0x10
455 
456 #define BM_CMD_START     0x01
457 #define BM_CMD_READ      0x08
458 
459 struct BMDMAState {
460     uint8_t cmd;
461     uint8_t status;
462     uint32_t addr;
463 
464     struct PCIIDEState *pci_dev;
465     IDEBus *bus;
466     /* current transfer state */
467     uint32_t cur_addr;
468     uint32_t cur_prd_last;
469     uint32_t cur_prd_addr;
470     uint32_t cur_prd_len;
471     uint8_t unit;
472     BlockDriverCompletionFunc *dma_cb;
473     BlockDriverAIOCB *aiocb;
474     struct iovec iov;
475     QEMUIOVector qiov;
476     int64_t sector_num;
477     uint32_t nsector;
478     QEMUBH *bh;
479 };
480 
481 static inline IDEState *idebus_active_if(IDEBus *bus)
482 {
483     return bus->ifs + bus->unit;
484 }
485 
486 static inline IDEState *bmdma_active_if(BMDMAState *bmdma)
487 {
488     assert(bmdma->unit != (uint8_t)-1);
489     return bmdma->bus->ifs + bmdma->unit;
490 }
491 
492 static inline void ide_set_irq(IDEBus *bus)
493 {
494     BMDMAState *bm = bus->bmdma;
495     if (!(bus->cmd & IDE_CMD_DISABLE_IRQ)) {
496         if (bm) {
497             bm->status |= BM_STATUS_INT;
498         }
499         qemu_irq_raise(bus->irq);
500     }
501 }
502 
503 /* ide.c */
504 void ide_save(QEMUFile* f, IDEState *s);
505 void ide_load(QEMUFile* f, IDEState *s, int version_id);
506 void idebus_save(QEMUFile* f, IDEBus *bus);
507 void idebus_load(QEMUFile* f, IDEBus *bus, int version_id);
508 
509 void ide_reset(IDEState *s);
510 int64_t ide_get_sector(IDEState *s);
511 void ide_set_sector(IDEState *s, int64_t sector_num);
512 
513 void ide_dma_cancel(BMDMAState *bm);
514 void ide_dma_restart_cb(void *opaque, int running, int reason);
515 void ide_dma_error(IDEState *s);
516 
517 void ide_atapi_cmd_ok(IDEState *s);
518 void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc);
519 void ide_atapi_io_error(IDEState *s, int ret);
520 
521 void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val);
522 uint32_t ide_ioport_read(void *opaque, uint32_t addr1);
523 uint32_t ide_status_read(void *opaque, uint32_t addr);
524 void ide_cmd_write(void *opaque, uint32_t addr, uint32_t val);
525 void ide_data_writew(void *opaque, uint32_t addr, uint32_t val);
526 uint32_t ide_data_readw(void *opaque, uint32_t addr);
527 void ide_data_writel(void *opaque, uint32_t addr, uint32_t val);
528 uint32_t ide_data_readl(void *opaque, uint32_t addr);
529 
530 void ide_init_drive(IDEState *s, DriveInfo *dinfo);
531 void ide_init2(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1,
532                qemu_irq irq);
533 void ide_init_ioport(IDEBus *bus, int iobase, int iobase2);
534 
535 #endif /* HW_IDE_INTERNAL_H */
536