platform_pci.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _XEN_PLATFORM_PCI_H
  3. #define _XEN_PLATFORM_PCI_H
  4. #define XEN_IOPORT_MAGIC_VAL 0x49d2
  5. #define XEN_IOPORT_LINUX_PRODNUM 0x0003
  6. #define XEN_IOPORT_LINUX_DRVVER 0x0001
  7. #define XEN_IOPORT_BASE 0x10
  8. #define XEN_IOPORT_PLATFLAGS (XEN_IOPORT_BASE + 0) /* 1 byte access (R/W) */
  9. #define XEN_IOPORT_MAGIC (XEN_IOPORT_BASE + 0) /* 2 byte access (R) */
  10. #define XEN_IOPORT_UNPLUG (XEN_IOPORT_BASE + 0) /* 2 byte access (W) */
  11. #define XEN_IOPORT_DRVVER (XEN_IOPORT_BASE + 0) /* 4 byte access (W) */
  12. #define XEN_IOPORT_SYSLOG (XEN_IOPORT_BASE + 2) /* 1 byte access (W) */
  13. #define XEN_IOPORT_PROTOVER (XEN_IOPORT_BASE + 2) /* 1 byte access (R) */
  14. #define XEN_IOPORT_PRODNUM (XEN_IOPORT_BASE + 2) /* 2 byte access (W) */
  15. #define XEN_UNPLUG_ALL_IDE_DISKS (1<<0)
  16. #define XEN_UNPLUG_ALL_NICS (1<<1)
  17. #define XEN_UNPLUG_AUX_IDE_DISKS (1<<2)
  18. #define XEN_UNPLUG_ALL (XEN_UNPLUG_ALL_IDE_DISKS|\
  19. XEN_UNPLUG_ALL_NICS|\
  20. XEN_UNPLUG_AUX_IDE_DISKS)
  21. #define XEN_UNPLUG_UNNECESSARY (1<<16)
  22. #define XEN_UNPLUG_NEVER (1<<17)
  23. static inline int xen_must_unplug_nics(void) {
  24. #if (defined(CONFIG_XEN_NETDEV_FRONTEND) || \
  25. defined(CONFIG_XEN_NETDEV_FRONTEND_MODULE)) && \
  26. defined(CONFIG_XEN_PVHVM)
  27. return 1;
  28. #else
  29. return 0;
  30. #endif
  31. }
  32. static inline int xen_must_unplug_disks(void) {
  33. #if (defined(CONFIG_XEN_BLKDEV_FRONTEND) || \
  34. defined(CONFIG_XEN_BLKDEV_FRONTEND_MODULE)) && \
  35. defined(CONFIG_XEN_PVHVM)
  36. return 1;
  37. #else
  38. return 0;
  39. #endif
  40. }
  41. #if defined(CONFIG_XEN_PVHVM)
  42. extern bool xen_has_pv_devices(void);
  43. extern bool xen_has_pv_disk_devices(void);
  44. extern bool xen_has_pv_nic_devices(void);
  45. extern bool xen_has_pv_and_legacy_disk_devices(void);
  46. #else
  47. static inline bool xen_has_pv_devices(void)
  48. {
  49. return IS_ENABLED(CONFIG_XEN);
  50. }
  51. static inline bool xen_has_pv_disk_devices(void)
  52. {
  53. return IS_ENABLED(CONFIG_XEN);
  54. }
  55. static inline bool xen_has_pv_nic_devices(void)
  56. {
  57. return IS_ENABLED(CONFIG_XEN);
  58. }
  59. static inline bool xen_has_pv_and_legacy_disk_devices(void)
  60. {
  61. return false;
  62. }
  63. #endif
  64. #endif /* _XEN_PLATFORM_PCI_H */