18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _XEN_PLATFORM_PCI_H
38c2ecf20Sopenharmony_ci#define _XEN_PLATFORM_PCI_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#define XEN_IOPORT_MAGIC_VAL 0x49d2
68c2ecf20Sopenharmony_ci#define XEN_IOPORT_LINUX_PRODNUM 0x0003
78c2ecf20Sopenharmony_ci#define XEN_IOPORT_LINUX_DRVVER  0x0001
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define XEN_IOPORT_BASE 0x10
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define XEN_IOPORT_PLATFLAGS	(XEN_IOPORT_BASE + 0) /* 1 byte access (R/W) */
128c2ecf20Sopenharmony_ci#define XEN_IOPORT_MAGIC	(XEN_IOPORT_BASE + 0) /* 2 byte access (R) */
138c2ecf20Sopenharmony_ci#define XEN_IOPORT_UNPLUG	(XEN_IOPORT_BASE + 0) /* 2 byte access (W) */
148c2ecf20Sopenharmony_ci#define XEN_IOPORT_DRVVER	(XEN_IOPORT_BASE + 0) /* 4 byte access (W) */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#define XEN_IOPORT_SYSLOG	(XEN_IOPORT_BASE + 2) /* 1 byte access (W) */
178c2ecf20Sopenharmony_ci#define XEN_IOPORT_PROTOVER	(XEN_IOPORT_BASE + 2) /* 1 byte access (R) */
188c2ecf20Sopenharmony_ci#define XEN_IOPORT_PRODNUM	(XEN_IOPORT_BASE + 2) /* 2 byte access (W) */
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define XEN_UNPLUG_ALL_IDE_DISKS	(1<<0)
218c2ecf20Sopenharmony_ci#define XEN_UNPLUG_ALL_NICS		(1<<1)
228c2ecf20Sopenharmony_ci#define XEN_UNPLUG_AUX_IDE_DISKS	(1<<2)
238c2ecf20Sopenharmony_ci#define XEN_UNPLUG_ALL			(XEN_UNPLUG_ALL_IDE_DISKS|\
248c2ecf20Sopenharmony_ci					 XEN_UNPLUG_ALL_NICS|\
258c2ecf20Sopenharmony_ci					 XEN_UNPLUG_AUX_IDE_DISKS)
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define XEN_UNPLUG_UNNECESSARY 		(1<<16)
288c2ecf20Sopenharmony_ci#define XEN_UNPLUG_NEVER	 		(1<<17)
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistatic inline int xen_must_unplug_nics(void) {
318c2ecf20Sopenharmony_ci#if (defined(CONFIG_XEN_NETDEV_FRONTEND) || \
328c2ecf20Sopenharmony_ci		defined(CONFIG_XEN_NETDEV_FRONTEND_MODULE)) && \
338c2ecf20Sopenharmony_ci		defined(CONFIG_XEN_PVHVM)
348c2ecf20Sopenharmony_ci        return 1;
358c2ecf20Sopenharmony_ci#else
368c2ecf20Sopenharmony_ci        return 0;
378c2ecf20Sopenharmony_ci#endif
388c2ecf20Sopenharmony_ci}
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistatic inline int xen_must_unplug_disks(void) {
418c2ecf20Sopenharmony_ci#if (defined(CONFIG_XEN_BLKDEV_FRONTEND) || \
428c2ecf20Sopenharmony_ci		defined(CONFIG_XEN_BLKDEV_FRONTEND_MODULE)) && \
438c2ecf20Sopenharmony_ci		defined(CONFIG_XEN_PVHVM)
448c2ecf20Sopenharmony_ci        return 1;
458c2ecf20Sopenharmony_ci#else
468c2ecf20Sopenharmony_ci        return 0;
478c2ecf20Sopenharmony_ci#endif
488c2ecf20Sopenharmony_ci}
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#if defined(CONFIG_XEN_PVHVM)
518c2ecf20Sopenharmony_ciextern bool xen_has_pv_devices(void);
528c2ecf20Sopenharmony_ciextern bool xen_has_pv_disk_devices(void);
538c2ecf20Sopenharmony_ciextern bool xen_has_pv_nic_devices(void);
548c2ecf20Sopenharmony_ciextern bool xen_has_pv_and_legacy_disk_devices(void);
558c2ecf20Sopenharmony_ci#else
568c2ecf20Sopenharmony_cistatic inline bool xen_has_pv_devices(void)
578c2ecf20Sopenharmony_ci{
588c2ecf20Sopenharmony_ci	return IS_ENABLED(CONFIG_XEN);
598c2ecf20Sopenharmony_ci}
608c2ecf20Sopenharmony_cistatic inline bool xen_has_pv_disk_devices(void)
618c2ecf20Sopenharmony_ci{
628c2ecf20Sopenharmony_ci	return IS_ENABLED(CONFIG_XEN);
638c2ecf20Sopenharmony_ci}
648c2ecf20Sopenharmony_cistatic inline bool xen_has_pv_nic_devices(void)
658c2ecf20Sopenharmony_ci{
668c2ecf20Sopenharmony_ci	return IS_ENABLED(CONFIG_XEN);
678c2ecf20Sopenharmony_ci}
688c2ecf20Sopenharmony_cistatic inline bool xen_has_pv_and_legacy_disk_devices(void)
698c2ecf20Sopenharmony_ci{
708c2ecf20Sopenharmony_ci	return false;
718c2ecf20Sopenharmony_ci}
728c2ecf20Sopenharmony_ci#endif
738c2ecf20Sopenharmony_ci#endif /* _XEN_PLATFORM_PCI_H */
74