2
0

xen-host-pci-device.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef XEN_HOST_PCI_DEVICE_H
  2. #define XEN_HOST_PCI_DEVICE_H
  3. #include "hw/pci/pci.h"
  4. enum {
  5. XEN_HOST_PCI_REGION_TYPE_IO = 1 << 1,
  6. XEN_HOST_PCI_REGION_TYPE_MEM = 1 << 2,
  7. XEN_HOST_PCI_REGION_TYPE_PREFETCH = 1 << 3,
  8. XEN_HOST_PCI_REGION_TYPE_MEM_64 = 1 << 4,
  9. };
  10. typedef struct XenHostPCIIORegion {
  11. pcibus_t base_addr;
  12. pcibus_t size;
  13. uint8_t type;
  14. uint8_t bus_flags; /* Bus-specific bits */
  15. } XenHostPCIIORegion;
  16. typedef struct XenHostPCIDevice {
  17. uint16_t domain;
  18. uint8_t bus;
  19. uint8_t dev;
  20. uint8_t func;
  21. uint16_t vendor_id;
  22. uint16_t device_id;
  23. uint32_t class_code;
  24. int irq;
  25. XenHostPCIIORegion io_regions[PCI_NUM_REGIONS - 1];
  26. XenHostPCIIORegion rom;
  27. bool is_virtfn;
  28. int config_fd;
  29. } XenHostPCIDevice;
  30. void xen_host_pci_device_get(XenHostPCIDevice *d, uint16_t domain,
  31. uint8_t bus, uint8_t dev, uint8_t func,
  32. Error **errp);
  33. void xen_host_pci_device_put(XenHostPCIDevice *pci_dev);
  34. bool xen_host_pci_device_closed(XenHostPCIDevice *d);
  35. int xen_host_pci_get_byte(XenHostPCIDevice *d, int pos, uint8_t *p);
  36. int xen_host_pci_get_word(XenHostPCIDevice *d, int pos, uint16_t *p);
  37. int xen_host_pci_get_long(XenHostPCIDevice *d, int pos, uint32_t *p);
  38. int xen_host_pci_get_block(XenHostPCIDevice *d, int pos, uint8_t *buf,
  39. int len);
  40. int xen_host_pci_set_byte(XenHostPCIDevice *d, int pos, uint8_t data);
  41. int xen_host_pci_set_word(XenHostPCIDevice *d, int pos, uint16_t data);
  42. int xen_host_pci_set_long(XenHostPCIDevice *d, int pos, uint32_t data);
  43. int xen_host_pci_set_block(XenHostPCIDevice *d, int pos, uint8_t *buf,
  44. int len);
  45. int xen_host_pci_find_ext_cap_offset(XenHostPCIDevice *s, uint32_t cap);
  46. #endif /* XEN_HOST_PCI_DEVICE_H */