]> git.proxmox.com Git - mirror_qemu.git/blob - include/hw/ide/pci.h
cmd646: Move PCI IDE specific functions to ide/pci.c
[mirror_qemu.git] / include / hw / ide / pci.h
1 #ifndef HW_IDE_PCI_H
2 #define HW_IDE_PCI_H
3
4 #include "hw/ide/internal.h"
5
6 #define BM_STATUS_DMAING 0x01
7 #define BM_STATUS_ERROR 0x02
8 #define BM_STATUS_INT 0x04
9
10 #define BM_CMD_START 0x01
11 #define BM_CMD_READ 0x08
12
13 typedef struct BMDMAState {
14 IDEDMA dma;
15 uint8_t cmd;
16 uint8_t status;
17 uint32_t addr;
18
19 IDEBus *bus;
20 /* current transfer state */
21 uint32_t cur_addr;
22 uint32_t cur_prd_last;
23 uint32_t cur_prd_addr;
24 uint32_t cur_prd_len;
25 BlockCompletionFunc *dma_cb;
26 MemoryRegion addr_ioport;
27 MemoryRegion extra_io;
28 qemu_irq irq;
29
30 /* Bit 0-2 and 7: BM status register
31 * Bit 3-6: bus->error_status */
32 uint8_t migration_compat_status;
33 uint8_t migration_retry_unit;
34 int64_t migration_retry_sector_num;
35 uint32_t migration_retry_nsector;
36
37 struct PCIIDEState *pci_dev;
38 } BMDMAState;
39
40 typedef struct CMD646BAR {
41 MemoryRegion cmd;
42 MemoryRegion data;
43 } CMD646BAR;
44
45 #define TYPE_PCI_IDE "pci-ide"
46 #define PCI_IDE(obj) OBJECT_CHECK(PCIIDEState, (obj), TYPE_PCI_IDE)
47
48 typedef struct PCIIDEState {
49 /*< private >*/
50 PCIDevice parent_obj;
51 /*< public >*/
52
53 IDEBus bus[2];
54 BMDMAState bmdma[2];
55 uint32_t secondary; /* used only for cmd646 */
56 MemoryRegion bmdma_bar;
57 CMD646BAR cmd646_bar[2]; /* used only for cmd646 */
58 } PCIIDEState;
59
60
61 static inline IDEState *bmdma_active_if(BMDMAState *bmdma)
62 {
63 assert(bmdma->bus->retry_unit != (uint8_t)-1);
64 return bmdma->bus->ifs + bmdma->bus->retry_unit;
65 }
66
67
68 void bmdma_init(IDEBus *bus, BMDMAState *bm, PCIIDEState *d);
69 void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val);
70 extern MemoryRegionOps bmdma_addr_ioport_ops;
71 void pci_ide_create_devs(PCIDevice *dev, DriveInfo **hd_table);
72
73 extern const VMStateDescription vmstate_ide_pci;
74 extern const MemoryRegionOps pci_ide_cmd_le_ops;
75 extern const MemoryRegionOps pci_ide_data_le_ops;
76 #endif