2
0

xen-host-pci-device.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. /* different from the above in case of stubdomain */
  22. uint16_t local_domain;
  23. uint8_t local_bus;
  24. uint8_t local_dev;
  25. uint8_t local_func;
  26. uint16_t vendor_id;
  27. uint16_t device_id;
  28. uint32_t class_code;
  29. int irq;
  30. XenHostPCIIORegion io_regions[PCI_NUM_REGIONS - 1];
  31. XenHostPCIIORegion rom;
  32. bool is_virtfn;
  33. int config_fd;
  34. } XenHostPCIDevice;
  35. void xen_host_pci_device_get(XenHostPCIDevice *d, uint16_t domain,
  36. uint8_t bus, uint8_t dev, uint8_t func,
  37. Error **errp);
  38. void xen_host_pci_device_put(XenHostPCIDevice *pci_dev);
  39. bool xen_host_pci_device_closed(XenHostPCIDevice *d);
  40. int xen_host_pci_get_byte(XenHostPCIDevice *d, int pos, uint8_t *p);
  41. int xen_host_pci_get_word(XenHostPCIDevice *d, int pos, uint16_t *p);
  42. int xen_host_pci_get_long(XenHostPCIDevice *d, int pos, uint32_t *p);
  43. int xen_host_pci_get_block(XenHostPCIDevice *d, int pos, uint8_t *buf,
  44. int len);
  45. int xen_host_pci_set_byte(XenHostPCIDevice *d, int pos, uint8_t data);
  46. int xen_host_pci_set_word(XenHostPCIDevice *d, int pos, uint16_t data);
  47. int xen_host_pci_set_long(XenHostPCIDevice *d, int pos, uint32_t data);
  48. int xen_host_pci_set_block(XenHostPCIDevice *d, int pos, uint8_t *buf,
  49. int len);
  50. int xen_host_pci_find_ext_cap_offset(XenHostPCIDevice *s, uint32_t cap);
  51. #endif /* XEN_HOST_PCI_DEVICE_H */