1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 #define PCIBIOS_ADDR_FIXUP 0x001
34 #define PCIBIOS_BUS_FIXUP 0x002
35 #define PCIBIOS_INTR_FIXUP 0x004
36 #define PCIBIOS_INTR_GUESS 0x008
37 #define PCIBIOS_VERBOSE 0x010
38 #define PCIBIOS_INTRDEBUG 0x020
39 #define PCIBIOS_FIXUP_FORCE 0x040
40
41
42
43
44 #define PCIBIOS_SUCCESS 0x00
45 #define PCIBIOS_SERVICE_NOT_PRESENT 0x80
46 #define PCIBIOS_FUNCTION_NOT_SUPPORTED 0x81
47 #define PCIBIOS_BAD_VENDOR_ID 0x83
48 #define PCIBIOS_DEVICE_NOT_FOUND 0x86
49 #define PCIBIOS_BAD_REGISTER_NUMBER 0x87
50 #define PCIBIOS_SET_FAILED 0x88
51 #define PCIBIOS_BUFFER_TOO_SMALL 0x89
52
53 struct pcibios_softc {
54 struct device sc_dev;
55
56 int max_bus;
57
58
59 struct extent *extent_mem;
60 struct extent *extent_port;
61 bus_addr_t mem_alloc_start;
62 bus_addr_t port_alloc_start;
63 int nbogus;
64 };
65
66
67
68
69
70
71
72
73 struct pcibios_linkmap {
74 u_int8_t link;
75 u_int16_t bitmap;
76 } __packed;
77
78 struct pcibios_intr_routing {
79 u_int8_t bus;
80 u_int8_t device;
81 struct pcibios_linkmap linkmap[4];
82 u_int8_t slot;
83 u_int8_t reserved;
84 } __packed;
85
86
87
88
89
90
91 struct pcibios_pir_header {
92 u_int32_t signature;
93 u_int16_t version;
94 u_int16_t tablesize;
95 u_int8_t router_bus;
96 u_int8_t router_devfunc;
97 u_int16_t exclusive_irq;
98 u_int32_t compat_router;
99 u_int32_t miniport;
100 u_int8_t reserved[11];
101 u_int8_t checksum;
102 } __packed;
103
104 #define PIR_DEVFUNC_DEVICE(devfunc) (((devfunc) >> 3) & 0x1f)
105 #define PIR_DEVFUNC_FUNCTION(devfunc) ((devfunc) & 7)
106 #define PIR_DEVFUNC_COMPOSE(dev,func) ((((dev) &0x1f) << 3) | ((func) & 7))
107
108 void pcibios_init(void);
109
110 extern struct pcibios_pir_header pcibios_pir_header;
111 extern struct pcibios_intr_routing *pcibios_pir_table;
112 extern int pcibios_pir_table_nentries;
113
114 extern int pcibios_flags;
115
116 typedef void *pciintr_icu_handle_t;
117
118 struct pciintr_icu {
119 int (*pi_getclink)(pciintr_icu_handle_t, int, int *);
120 int (*pi_get_intr)(pciintr_icu_handle_t, int, int *);
121 int (*pi_set_intr)(pciintr_icu_handle_t, int, int);
122 int (*pi_get_trigger)(pciintr_icu_handle_t, int, int *);
123 int (*pi_set_trigger)(pciintr_icu_handle_t, int, int);
124 };
125
126 typedef const struct pciintr_icu *pciintr_icu_tag_t;
127
128 #define pciintr_icu_getclink(t, h, link, pirqp) \
129 (*(t)->pi_getclink)((h), (link), (pirqp))
130 #define pciintr_icu_get_intr(t, h, pirq, irqp) \
131 (*(t)->pi_get_intr)((h), (pirq), (irqp))
132 #define pciintr_icu_set_intr(t, h, pirq, irq) \
133 (*(t)->pi_set_intr)((h), (pirq), (irq))
134 #define pciintr_icu_get_trigger(t, h, irq, triggerp) \
135 (*(t)->pi_get_trigger)((h), (irq), (triggerp))
136 #define pciintr_icu_set_trigger(t, h, irq, trigger) \
137 (*(t)->pi_set_trigger)((h), (irq), (trigger))
138
139 #define PCIBIOS_PRINTV(arg) \
140 do { \
141 if (pcibios_flags & PCIBIOS_VERBOSE) \
142 printf arg; \
143 } while (0)
144
145 #define PCIADDR_SEARCH_IO 0
146 #define PCIADDR_SEARCH_MEM 1
147 struct extent *pciaddr_search(int, bus_addr_t *, bus_size_t);
148
149 #define PCI_INT_VIA_ISA 0x20000000
150
151 int pci_intr_fixup(struct pcibios_softc *, pci_chipset_tag_t, bus_space_tag_t);
152 int pci_bus_fixup(pci_chipset_tag_t, int);
153 void pci_addr_fixup(struct pcibios_softc *, pci_chipset_tag_t, int);
154 void pci_device_foreach(struct pcibios_softc *, pci_chipset_tag_t, int,
155 void (*)(struct pcibios_softc *, pci_chipset_tag_t, pcitag_t));
156 int pci_intr_header_fixup(pci_chipset_tag_t, pcitag_t, pci_intr_handle_t *);
157 int pci_intr_route_link(pci_chipset_tag_t, pci_intr_handle_t *);
158 int pci_intr_post_fixup(void);
159
160
161
162
163 int piix_init(pci_chipset_tag_t, bus_space_tag_t, pcitag_t,
164 pciintr_icu_tag_t *, pciintr_icu_handle_t *);
165 int opti82c558_init(pci_chipset_tag_t, bus_space_tag_t, pcitag_t,
166 pciintr_icu_tag_t *, pciintr_icu_handle_t *);
167 int opti82c700_init(pci_chipset_tag_t, bus_space_tag_t, pcitag_t,
168 pciintr_icu_tag_t *, pciintr_icu_handle_t *);
169 int via82c586_init(pci_chipset_tag_t, bus_space_tag_t, pcitag_t,
170 pciintr_icu_tag_t *, pciintr_icu_handle_t *);
171 int via8231_init(pci_chipset_tag_t, bus_space_tag_t, pcitag_t,
172 pciintr_icu_tag_t *, pciintr_icu_handle_t *);
173 int sis85c503_init(pci_chipset_tag_t, bus_space_tag_t, pcitag_t,
174 pciintr_icu_tag_t *, pciintr_icu_handle_t *);
175 int amd756_init(pci_chipset_tag_t, bus_space_tag_t, pcitag_t,
176 pciintr_icu_tag_t *, pciintr_icu_handle_t *);
177 int ali1543_init(pci_chipset_tag_t, bus_space_tag_t, pcitag_t,
178 pciintr_icu_tag_t *, pciintr_icu_handle_t *);
179 int osb4_init(pci_chipset_tag_t, bus_space_tag_t, pcitag_t,
180 pciintr_icu_tag_t *, pciintr_icu_handle_t *);
181