4 #include <device/resource.h>
7 struct device_operations {
8 void (*read_resources)(struct device *dev);
9 void (*set_resources)(struct device *dev);
10 void (*init)(struct device *dev);
11 unsigned int (*scan_bus)(struct device *bus, unsigned int max);
15 #define MAX_RESOURCES 6
17 * There is one pci_dev structure for each slot-number/function-number
22 struct device *bus; /* bus this device is on */
23 struct device *children; /* devices behind this bridge */
24 struct device *sibling; /* next device on this bus */
25 struct device *next; /* chain of all devices */
27 unsigned int devfn; /* encoded device & function index */
28 unsigned short vendor;
29 unsigned short device;
30 unsigned int class; /* 3 bytes: (base,sub,prog-if) */
31 unsigned int hdr_type; /* PCI header type */
32 unsigned int master : 1; /* set if device is master capable */
34 unsigned char secondary; /* secondary bus number */
35 unsigned char subordinate; /* max subordinate bus number */
38 * In theory, the irq level can be read from configuration
39 * space and all would be fine. However, old PCI chips don't
40 * support these registers and return 0 instead. For example,
41 * the Vision864-P rev 0 chip can uses INTA, but returns 0 in
42 * the interrupt line and pin registers. pci_init()
43 * initializes this field with the value at PCI_INTERRUPT_LINE
44 * and it is the job of pcibios_fixup() to change it if
45 * necessary. The field must not be 0 unless the device
46 * cannot generate interrupts at all.
48 unsigned int irq; /* irq generated by this device */
50 /* Base registers for this device, can be adjusted by
51 * pcibios_fixup() as necessary.
53 struct resource resource[MAX_RESOURCES];
54 unsigned int resources;
55 unsigned long rom_address;
56 struct device_operations *ops;
60 extern struct device dev_root; /* root bus */
61 extern struct device *all_devices; /* list of all devices */
64 /* Generic device interface functions */
65 extern void dev_enumerate(void);
66 extern void dev_configure(void);
67 extern void dev_enable(void);
68 extern void dev_initialize(void);
70 /* Generic device helper functions */
71 void append_device(struct device *dev);
72 void compute_allocate_resource(struct device *bus, struct resource *bridge,
73 unsigned long type_mask, unsigned long type);
74 void assign_resources(struct device *bus);
75 void enumerate_static_device(void);
76 unsigned long device_memory_base;
79 /* Helper functions */
80 struct device *dev_find_device (unsigned int vendor, unsigned int device, struct device *from);
81 struct device *dev_find_class (unsigned int class, struct device *from);
82 struct device *dev_find_slot (unsigned int bus, unsigned int devfn);
84 /* Rounding for boundaries.
85 * Due to some chip bugs, go ahead and roung IO to 16
87 #define DEVICE_IO_ALIGN 16
88 #define DEVICE_MEM_ALIGN 4096