Move acpi code out of rombios32.c; clean up use of fixed memory addresses.
[seabios.git] / src / pci.h
1 #ifndef __PCI_H
2 #define __PCI_H
3
4 #include "types.h" // u32
5
6 typedef struct PCIDevice {
7     u8 bus;
8     u8 devfn;
9 } PCIDevice;
10
11 static inline PCIDevice
12 pci_bd(u8 bus, u8 devfn)
13 {
14     struct PCIDevice d = {bus, devfn};
15     return d;
16 }
17
18 void pci_config_writel(PCIDevice d, u32 addr, u32 val);
19 void pci_config_writew(PCIDevice d, u32 addr, u16 val);
20 void pci_config_writeb(PCIDevice d, u32 addr, u8 val);
21 u32 pci_config_readl(PCIDevice d, u32 addr);
22 u16 pci_config_readw(PCIDevice d, u32 addr);
23 u8 pci_config_readb(PCIDevice d, u32 addr);
24
25 int pci_find_device(u16 vendid, u16 devid, int index, PCIDevice *dev);
26 int pci_find_class(u32 classid, int index, PCIDevice *dev);
27
28
29 /****************************************************************
30  * PCI definitions
31  ****************************************************************/
32
33 #define PCI_VENDOR_ID           0x00    /* 16 bits */
34 #define PCI_DEVICE_ID           0x02    /* 16 bits */
35 #define PCI_COMMAND             0x04    /* 16 bits */
36 #define  PCI_COMMAND_IO         0x1     /* Enable response in I/O space */
37 #define  PCI_COMMAND_MEMORY     0x2     /* Enable response in Memory space */
38 #define PCI_CLASS_DEVICE        0x0a    /* Device class */
39 #define PCI_INTERRUPT_LINE      0x3c    /* 8 bits */
40 #define PCI_INTERRUPT_PIN       0x3d    /* 8 bits */
41 #define PCI_MIN_GNT             0x3e    /* 8 bits */
42 #define PCI_MAX_LAT             0x3f    /* 8 bits */
43
44
45 /****************************************************************
46  * PIR table
47  ****************************************************************/
48
49 struct pir_header {
50     u32 signature;
51     u16 version;
52     u16 size;
53     u8 router_bus;
54     u8 router_devfunc;
55     u16 exclusive_irqs;
56     u32 compatible_devid;
57     u32 miniport_data;
58     u8 reserved[11];
59     u8 checksum;
60 } PACKED;
61
62 #define PIR_SIGNATURE 0x52495024 // $PIR
63
64 struct link_info {
65     u8 link;
66     u16 bitmap;
67 } PACKED;
68
69 struct pir_slot {
70     u8 bus;
71     u8 dev;
72     struct link_info links[4];
73     u8 slot_nr;
74     u8 reserved;
75 } PACKED;
76
77
78 #endif