Adding upstream version 3.53.
[syslinux-debian/hramrach.git] / com32 / include / sys / pci.h
blob3f9b0d9780600c477c2d5749ef6ed78fa70d3765
1 #ifndef _SYS_PCI_H
2 #define _SYS_PCI_H
4 #include <inttypes.h>
5 #include <sys/io.h>
7 #define MAX_PCI_DEVICES 32
8 #define MAX_PCI_BUSES 255
10 typedef uint32_t pciaddr_t;
12 /* a structure for extended pci information */
13 struct pci_dev_info {
14 char *vendor_name;
15 char *product_name;
16 char *linux_kernel_module;
19 /* a struct to represent a pci device */
20 struct pci_device {
21 uint16_t vendor;
22 uint16_t product;
23 uint16_t sub_vendor;
24 uint16_t sub_product;
25 uint8_t revision;
26 struct pci_dev_info *pci_dev_info;
29 struct pci_bus {
30 uint16_t id;
31 struct pci_device *pci_device[MAX_PCI_DEVICES];
32 uint8_t pci_device_count;
35 struct pci_device_list {
36 struct pci_device pci_device[MAX_PCI_DEVICES];
37 uint8_t count;
40 struct pci_bus_list {
41 struct pci_bus pci_bus[MAX_PCI_BUSES];
42 uint8_t count;
45 struct match {
46 struct match *next;
47 uint32_t did;
48 uint32_t did_mask;
49 uint32_t sid;
50 uint32_t sid_mask;
51 uint8_t rid_min, rid_max;
52 char *filename;
55 static inline pciaddr_t pci_mkaddr(uint32_t bus, uint32_t dev,
56 uint32_t func, uint32_t reg)
58 return 0x80000000 | ((bus & 0xff) << 16) | ((dev & 0x1f) << 11) |
59 ((func & 0x07) << 8) | (reg & 0xff);
62 enum pci_config_type {
63 PCI_CFG_NONE = -1, /* badness */
64 PCI_CFG_AUTO = 0, /* autodetect */
65 PCI_CFG_TYPE1 = 1,
66 PCI_CFG_TYPE2 = 2,
67 PCI_CFG_BIOS = 3,
70 enum pci_config_type pci_set_config_type(enum pci_config_type);
72 uint8_t pci_readb(pciaddr_t);
73 uint16_t pci_readw(pciaddr_t);
74 uint32_t pci_readl(pciaddr_t);
75 void pci_writeb(uint8_t, pciaddr_t);
76 void pci_writew(uint16_t, pciaddr_t);
77 void pci_writel(uint32_t, pciaddr_t);
79 extern int pci_scan(struct pci_bus_list *pci_bus_list, struct pci_device_list *pci_device_list);
80 extern struct match * find_pci_device(struct pci_device_list *pci_device_list, struct match *list);
81 extern void get_name_from_pci_ids(struct pci_device_list *pci_device_list);
82 extern void get_module_name_from_pci_ids(struct pci_device_list *pci_device_list);
83 #endif /* _SYS_PCI_H */