Rev 1301 | Rev 1324 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1301 | Rev 1302 | ||
---|---|---|---|
Line 10... | Line 10... | ||
10 | 10 | ||
11 | #include <string.h> |
11 | #include <string.h> |
12 | 12 | ||
13 | #include "internal.h" |
13 | #include "internal.h" |
14 | 14 | ||
15 | void |
- | |
16 | pci_generic_scan_bus(struct pci_access *a, byte *busmap, int bus) |
15 | void pci_generic_scan_bus(struct pci_access *a, byte * busmap, int bus) |
17 | { |
16 | { |
18 | int dev, multi, ht; |
17 | int dev, multi, ht; |
19 | struct pci_dev *t; |
18 | struct pci_dev *t; |
20 | 19 | ||
127 | #ifdef PCI_HAVE_64BIT_ADDRESS |
136 | #ifdef PCI_HAVE_64BIT_ADDRESS |
- | 137 | d->base_addr[i - 1] = |
|
128 | d->base_addr[i-1] = x | (((pciaddr_t) y) << 32); |
138 | x | (((pciaddr_t) y) << |
- | 139 | 32); |
|
129 | #else |
140 | #else |
130 | if (y) |
141 | if (y) |
- | 142 | a->warning |
|
131 | a->warning("%04x:%02x:%02x.%d 64-bit device address ignored.", d->domain, d->bus, d->dev, d->func); |
143 | ("%04x:%02x:%02x.%d 64-bit device address ignored.", |
- | 144 | d->domain, |
|
- | 145 | d->bus, |
|
- | 146 | d->dev, |
|
- | 147 | d->func); |
|
132 | else |
148 | else |
133 | d->base_addr[i-1] = x; |
149 | d->base_addr[i - |
- | 150 | 1] = |
|
- | 151 | x; |
|
134 | #endif |
152 | #endif |
135 | } |
153 | } |
- | 154 | } |
|
- | 155 | } |
|
136 | } |
156 | } |
137 | } |
- | |
138 | } |
157 | } |
139 | } |
- | |
140 | if (flags & PCI_FILL_ROM_BASE) |
158 | if (flags & PCI_FILL_ROM_BASE) { |
141 | { |
- | |
142 | int reg = 0; |
159 | int reg = 0; |
143 | d->rom_base_addr = 0; |
160 | d->rom_base_addr = 0; |
144 | switch (d->hdrtype) |
161 | switch (d->hdrtype) { |
145 | { |
- | |
146 | case PCI_HEADER_TYPE_NORMAL: |
162 | case PCI_HEADER_TYPE_NORMAL: |
147 | reg = PCI_ROM_ADDRESS; |
163 | reg = PCI_ROM_ADDRESS; |
148 | break; |
164 | break; |
149 | case PCI_HEADER_TYPE_BRIDGE: |
165 | case PCI_HEADER_TYPE_BRIDGE: |
150 | reg = PCI_ROM_ADDRESS1; |
166 | reg = PCI_ROM_ADDRESS1; |
151 | break; |
167 | break; |
152 | } |
168 | } |
153 | if (reg) |
169 | if (reg) { |
154 | { |
- | |
155 | u32 u = pci_read_long(d, reg); |
170 | u32 u = pci_read_long(d, reg); |
156 | if (u != 0xffffffff) |
171 | if (u != 0xffffffff) |
157 | d->rom_base_addr = u; |
172 | d->rom_base_addr = u; |
- | 173 | } |
|
158 | } |
174 | } |
159 | } |
- | |
160 | return flags & ~PCI_FILL_SIZES; |
175 | return flags & ~PCI_FILL_SIZES; |
161 | } |
176 | } |
162 | 177 | ||
163 | static int |
178 | static int |
164 | pci_generic_block_op(struct pci_dev *d, int pos, byte *buf, int len, |
179 | pci_generic_block_op(struct pci_dev *d, int pos, byte * buf, int len, |
165 | int (*r)(struct pci_dev *d, int pos, byte *buf, int len)) |
180 | int (*r) (struct pci_dev * d, int pos, byte * buf, |
- | 181 | int len)) |
|
166 | { |
182 | { |
167 | if ((pos & 1) && len >= 1) |
183 | if ((pos & 1) && len >= 1) { |
168 | { |
- | |
169 | if (!r(d, pos, buf, 1)) |
184 | if (!r(d, pos, buf, 1)) |
170 | return 0; |
185 | return 0; |
- | 186 | pos++; |
|
- | 187 | buf++; |
|
171 | pos++; buf++; len--; |
188 | len--; |
172 | } |
189 | } |
173 | if ((pos & 3) && len >= 2) |
190 | if ((pos & 3) && len >= 2) { |
174 | { |
- | |
175 | if (!r(d, pos, buf, 2)) |
191 | if (!r(d, pos, buf, 2)) |
176 | return 0; |
192 | return 0; |
- | 193 | pos += 2; |
|
- | 194 | buf += 2; |
|
177 | pos += 2; buf += 2; len -= 2; |
195 | len -= 2; |
178 | } |
196 | } |
179 | while (len >= 4) |
197 | while (len >= 4) { |
180 | { |
- | |
181 | if (!r(d, pos, buf, 4)) |
198 | if (!r(d, pos, buf, 4)) |
182 | return 0; |
199 | return 0; |
183 | pos += 4; buf += 4; len -= 4; |
200 | pos += 4; |
184 | } |
201 | buf += 4; |
185 | if (len >= 2) |
202 | len -= 4; |
- | 203 | } |
|
186 | { |
204 | if (len >= 2) { |
187 | if (!r(d, pos, buf, 2)) |
205 | if (!r(d, pos, buf, 2)) |
188 | return 0; |
206 | return 0; |
- | 207 | pos += 2; |
|
- | 208 | buf += 2; |
|
189 | pos += 2; buf += 2; len -= 2; |
209 | len -= 2; |
190 | } |
210 | } |
191 | if (len && !r(d, pos, buf, 1)) |
211 | if (len && !r(d, pos, buf, 1)) |
192 | return 0; |
212 | return 0; |
193 | return 1; |
213 | return 1; |
194 | } |
214 | } |
195 | 215 | ||
196 | int |
- | |
197 | pci_generic_block_read(struct pci_dev *d, int pos, byte *buf, int len) |
216 | int pci_generic_block_read(struct pci_dev *d, int pos, byte * buf, int len) |
198 | { |
217 | { |
199 | return pci_generic_block_op(d, pos, buf, len, d->access->methods->read); |
218 | return pci_generic_block_op(d, pos, buf, len, |
- | 219 | d->access->methods->read); |
|
200 | } |
220 | } |
201 | 221 | ||
202 | int |
- | |
203 | pci_generic_block_write(struct pci_dev *d, int pos, byte *buf, int len) |
222 | int pci_generic_block_write(struct pci_dev *d, int pos, byte * buf, int len) |
204 | { |
223 | { |
205 | return pci_generic_block_op(d, pos, buf, len, d->access->methods->write); |
224 | return pci_generic_block_op(d, pos, buf, len, |
- | 225 | d->access->methods->write); |
|
206 | } |
226 | } |