pci.h 1.8 KB

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