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