2 * PCI Backend Common Data Structures & Function Declarations
4 * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
6 #ifndef __XEN_PCIBACK_H__
7 #define __XEN_PCIBACK_H__
10 #include <linux/interrupt.h>
11 #include <xen/xenbus.h>
12 #include <linux/list.h>
13 #include <linux/spinlock.h>
14 #include <linux/workqueue.h>
15 #include <asm/atomic.h>
16 #include <xen/interface/io/pciif.h>
18 struct pci_dev_entry {
19 struct list_head list;
23 #define _PDEVF_op_active (0)
24 #define PDEVF_op_active (1<<(_PDEVF_op_active))
26 struct pciback_device {
30 struct xenbus_device *xdev;
32 struct xenbus_watch be_watch;
37 struct vm_struct *sh_area;
38 struct xen_pci_sharedinfo *sh_info;
42 struct work_struct op_work;
45 struct pciback_dev_data {
46 struct list_head config_fields;
51 /* Get/Put PCI Devices that are hidden from the PCI Backend Domain */
52 struct pci_dev *pcistub_get_pci_dev_by_slot(struct pciback_device *pdev,
55 struct pci_dev *pcistub_get_pci_dev(struct pciback_device *pdev,
57 void pcistub_put_pci_dev(struct pci_dev *dev);
59 /* Ensure a device is turned off or reset */
60 void pciback_reset_device(struct pci_dev *pdev);
62 /* Access a virtual configuration space for a PCI device */
63 int pciback_config_init(void);
64 int pciback_config_init_dev(struct pci_dev *dev);
65 void pciback_config_free_dyn_fields(struct pci_dev *dev);
66 void pciback_config_reset_dev(struct pci_dev *dev);
67 void pciback_config_free_dev(struct pci_dev *dev);
68 int pciback_config_read(struct pci_dev *dev, int offset, int size,
70 int pciback_config_write(struct pci_dev *dev, int offset, int size, u32 value);
72 /* Handle requests for specific devices from the frontend */
73 typedef int (*publish_pci_root_cb) (struct pciback_device * pdev,
74 unsigned int domain, unsigned int bus);
75 int pciback_add_pci_dev(struct pciback_device *pdev, struct pci_dev *dev);
76 void pciback_release_pci_dev(struct pciback_device *pdev, struct pci_dev *dev);
77 struct pci_dev *pciback_get_pci_dev(struct pciback_device *pdev,
78 unsigned int domain, unsigned int bus,
80 int pciback_init_devices(struct pciback_device *pdev);
81 int pciback_publish_pci_roots(struct pciback_device *pdev,
82 publish_pci_root_cb cb);
83 void pciback_release_devices(struct pciback_device *pdev);
85 /* Handles events from front-end */
86 irqreturn_t pciback_handle_event(int irq, void *dev_id, struct pt_regs *regs);
87 void pciback_do_op(void *data);
89 int pciback_xenbus_register(void);
90 void pciback_xenbus_unregister(void);
92 extern int verbose_request;