2 * PCI defines and function prototypes
3 * Copyright 1994, Drew Eckhardt
4 * Copyright 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6 * For more information, please consult the following manuals (look at
7 * http://www.pcisig.com/ for how to get them):
9 * PCI BIOS Specification
10 * PCI Local Bus Specification
11 * PCI to PCI Bridge Specification
12 * PCI System Design Guide
19 #include <device/pci_def.h>
20 #include <device/resource.h>
21 #include <device/device.h>
22 #include <device/pci_ops.h>
23 #include <device/pci_rom.h>
25 /* Common pci operations without a standard interface */
26 struct pci_operations {
27 /* set the Subsystem IDs for the PCI device */
28 void (*set_subsystem)(device_t dev, unsigned vendor, unsigned device);
31 /* Common pci bus operations */
32 struct pci_bus_operations {
33 uint8_t (*read8) (struct bus *pbus, int bus, int devfn, int where);
34 uint16_t (*read16) (struct bus *pbus, int bus, int devfn, int where);
35 uint32_t (*read32) (struct bus *pbus, int bus, int devfn, int where);
36 void (*write8) (struct bus *pbus, int bus, int devfn, int where, uint8_t val);
37 void (*write16) (struct bus *pbus, int bus, int devfn, int where, uint16_t val);
38 void (*write32) (struct bus *pbus, int bus, int devfn, int where, uint32_t val);
42 const struct device_operations *ops;
43 unsigned short vendor;
44 unsigned short device;
47 #define __pci_driver __attribute__ ((used,__section__(".rodata.pci_driver")))
48 /** start of compile time generated pci driver array */
49 extern struct pci_driver pci_drivers[];
50 /** end of compile time generated pci driver array */
51 extern struct pci_driver epci_drivers[];
54 extern struct device_operations default_pci_ops_dev;
55 extern struct device_operations default_pci_ops_bus;
57 void pci_dev_read_resources(device_t dev);
58 void pci_bus_read_resources(device_t dev);
59 void pci_dev_set_resources(device_t dev);
60 void pci_dev_enable_resources(device_t dev);
61 void pci_bus_enable_resources(device_t dev);
62 void pci_bus_reset(struct bus *bus);
63 device_t pci_probe_dev(device_t dev, struct bus *bus, unsigned devfn);
64 unsigned int do_pci_scan_bridge(device_t bus, unsigned int max,
65 unsigned int (*do_scan_bus)(struct bus *bus,
66 unsigned min_devfn, unsigned max_devfn, unsigned int max));
67 unsigned int pci_scan_bridge(device_t bus, unsigned int max);
68 unsigned int pci_scan_bus(struct bus *bus, unsigned min_devfn, unsigned max_devfn, unsigned int max);
69 uint8_t pci_moving_config8(struct device *dev, unsigned reg);
70 uint16_t pci_moving_config16(struct device *dev, unsigned reg);
71 uint32_t pci_moving_config32(struct device *dev, unsigned reg);
72 unsigned pci_find_next_capability(device_t dev, unsigned cap, unsigned last);
73 unsigned pci_find_capability(device_t dev, unsigned cap);
74 struct resource *pci_get_resource(struct device *dev, unsigned long index);
75 void pci_dev_set_subsystem(device_t dev, unsigned vendor, unsigned device);
76 void pci_dev_init(struct device *dev);
78 void pci_assign_irqs(unsigned bus, unsigned slot,
79 const unsigned char pIntAtoD[4]);
81 #define PCI_IO_BRIDGE_ALIGN 4096
82 #define PCI_MEM_BRIDGE_ALIGN (1024*1024)
84 static inline const struct pci_operations *ops_pci(device_t dev)
86 const struct pci_operations *pops;
88 if (dev && dev->ops) {
89 pops = dev->ops->ops_pci;
94 static inline const struct pci_bus_operations *ops_pci_bus(struct bus *bus)
96 const struct pci_bus_operations *bops;
98 if (bus && bus->dev && bus->dev->ops) {
99 bops = bus->dev->ops->ops_pci_bus;
102 bops = pci_remember_direct();