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