2 * PCI Backend - Common data structures for overriding the configuration space
7 #ifndef __XEN_PCIBACK_CONF_SPACE_H__
8 #define __XEN_PCIBACK_CONF_SPACE_H__
10 #include <linux/list.h>
11 #include <linux/err.h>
13 /* conf_field_init can return an errno in a ptr with ERR_PTR() */
14 typedef void *(*conf_field_init) (struct pci_dev *dev, int offset);
15 typedef void (*conf_field_reset) (struct pci_dev *dev, int offset, void *data);
16 typedef void (*conf_field_free) (struct pci_dev *dev, int offset, void *data);
18 typedef int (*conf_dword_write) (struct pci_dev *dev, int offset, u32 value,
20 typedef int (*conf_word_write) (struct pci_dev *dev, int offset, u16 value,
22 typedef int (*conf_byte_write) (struct pci_dev *dev, int offset, u8 value,
24 typedef int (*conf_dword_read) (struct pci_dev *dev, int offset, u32 *value,
26 typedef int (*conf_word_read) (struct pci_dev *dev, int offset, u16 *value,
28 typedef int (*conf_byte_read) (struct pci_dev *dev, int offset, u8 *value,
31 /* These are the fields within the configuration space which we
32 * are interested in intercepting reads/writes to and changing their
40 conf_field_reset reset;
41 conf_field_free release;
42 void (*clean) (struct config_field *field);
45 conf_dword_write write;
49 conf_word_write write;
53 conf_byte_write write;
57 struct list_head list;
60 struct config_field_entry {
61 struct list_head list;
62 const struct config_field *field;
63 unsigned int base_offset;
67 extern bool xen_pcibk_permissive;
69 #define OFFSET(cfg_entry) ((cfg_entry)->base_offset+(cfg_entry)->field->offset)
71 /* Add fields to a device - the add_fields macro expects to get a pointer to
72 * the first entry in an array (of which the ending is marked by size==0)
74 int xen_pcibk_config_add_field_offset(struct pci_dev *dev,
75 const struct config_field *field,
78 static inline int xen_pcibk_config_add_field(struct pci_dev *dev,
79 const struct config_field *field)
81 return xen_pcibk_config_add_field_offset(dev, field, 0);
84 static inline int xen_pcibk_config_add_fields(struct pci_dev *dev,
85 const struct config_field *field)
88 for (i = 0; field[i].size != 0; i++) {
89 err = xen_pcibk_config_add_field(dev, &field[i]);
96 static inline int xen_pcibk_config_add_fields_offset(struct pci_dev *dev,
97 const struct config_field *field,
101 for (i = 0; field[i].size != 0; i++) {
102 err = xen_pcibk_config_add_field_offset(dev, &field[i], offset);
109 /* Read/Write the real configuration space */
110 int xen_pcibk_read_config_byte(struct pci_dev *dev, int offset, u8 *value,
112 int xen_pcibk_read_config_word(struct pci_dev *dev, int offset, u16 *value,
114 int xen_pcibk_read_config_dword(struct pci_dev *dev, int offset, u32 *value,
116 int xen_pcibk_write_config_byte(struct pci_dev *dev, int offset, u8 value,
118 int xen_pcibk_write_config_word(struct pci_dev *dev, int offset, u16 value,
120 int xen_pcibk_write_config_dword(struct pci_dev *dev, int offset, u32 value,
123 int xen_pcibk_config_capability_init(void);
125 int xen_pcibk_config_header_add_fields(struct pci_dev *dev);
126 int xen_pcibk_config_capability_add_fields(struct pci_dev *dev);
128 #endif /* __XEN_PCIBACK_CONF_SPACE_H__ */