Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * BIOS32 and PCI BIOS handling. |
| 4 | */ |
| 5 | |
| 6 | #include <linux/pci.h> |
| 7 | #include <linux/init.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 8 | #include <linux/slab.h> |
Alexey Dobriyan | 129f694 | 2005-06-23 00:08:33 -0700 | [diff] [blame] | 9 | #include <linux/module.h> |
Rusty Russell | bd472c7 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 10 | #include <linux/uaccess.h> |
Ingo Molnar | 5520b7e | 2017-01-27 11:59:46 +0100 | [diff] [blame] | 11 | |
Jaswinder Singh Rajput | 8248771 | 2008-12-27 18:32:28 +0530 | [diff] [blame] | 12 | #include <asm/pci_x86.h> |
Ingo Molnar | 5520b7e | 2017-01-27 11:59:46 +0100 | [diff] [blame] | 13 | #include <asm/e820/types.h> |
Ingo Molnar | 1164dd0 | 2009-01-28 19:34:09 +0100 | [diff] [blame] | 14 | #include <asm/pci-functions.h> |
Laura Abbott | d116365 | 2017-05-08 15:58:11 -0700 | [diff] [blame] | 15 | #include <asm/set_memory.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
| 17 | /* BIOS32 signature: "_32_" */ |
| 18 | #define BIOS32_SIGNATURE (('_' << 0) + ('3' << 8) + ('2' << 16) + ('_' << 24)) |
| 19 | |
| 20 | /* PCI signature: "PCI " */ |
| 21 | #define PCI_SIGNATURE (('P' << 0) + ('C' << 8) + ('I' << 16) + (' ' << 24)) |
| 22 | |
| 23 | /* PCI service signature: "$PCI" */ |
| 24 | #define PCI_SERVICE (('$' << 0) + ('P' << 8) + ('C' << 16) + ('I' << 24)) |
| 25 | |
| 26 | /* PCI BIOS hardware mechanism flags */ |
| 27 | #define PCIBIOS_HW_TYPE1 0x01 |
| 28 | #define PCIBIOS_HW_TYPE2 0x02 |
| 29 | #define PCIBIOS_HW_TYPE1_SPEC 0x10 |
| 30 | #define PCIBIOS_HW_TYPE2_SPEC 0x20 |
| 31 | |
Matthieu Castet | 5bd5a45 | 2010-11-16 22:31:26 +0100 | [diff] [blame] | 32 | int pcibios_enabled; |
| 33 | |
| 34 | /* According to the BIOS specification at: |
| 35 | * http://members.datafast.net.au/dft0802/specs/bios21.pdf, we could |
| 36 | * restrict the x zone to some pages and make it ro. But this may be |
| 37 | * broken on some bios, complex to handle with static_protections. |
| 38 | * We could make the 0xe0000-0x100000 range rox, but this can break |
| 39 | * some ISA mapping. |
| 40 | * |
| 41 | * So we let's an rw and x hole when pcibios is used. This shouldn't |
| 42 | * happen for modern system with mmconfig, and if you don't want it |
| 43 | * you could disable pcibios... |
| 44 | */ |
| 45 | static inline void set_bios_x(void) |
| 46 | { |
| 47 | pcibios_enabled = 1; |
| 48 | set_memory_x(PAGE_OFFSET + BIOS_BEGIN, (BIOS_END - BIOS_BEGIN) >> PAGE_SHIFT); |
| 49 | if (__supported_pte_mask & _PAGE_NX) |
Vincent Legoll | 2b2154f | 2017-05-21 11:04:41 +0200 | [diff] [blame] | 50 | printk(KERN_INFO "PCI: PCI BIOS area is rw and x. Use pci=nobios if you want it NX.\n"); |
Matthieu Castet | 5bd5a45 | 2010-11-16 22:31:26 +0100 | [diff] [blame] | 51 | } |
| 52 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | /* |
| 54 | * This is the standard structure used to identify the entry point |
| 55 | * to the BIOS32 Service Directory, as documented in |
| 56 | * Standard BIOS 32-bit Service Directory Proposal |
| 57 | * Revision 0.4 May 24, 1993 |
| 58 | * Phoenix Technologies Ltd. |
| 59 | * Norwood, MA |
| 60 | * and the PCI BIOS specification. |
| 61 | */ |
| 62 | |
| 63 | union bios32 { |
| 64 | struct { |
| 65 | unsigned long signature; /* _32_ */ |
| 66 | unsigned long entry; /* 32 bit physical address */ |
| 67 | unsigned char revision; /* Revision level, 0 */ |
| 68 | unsigned char length; /* Length in paragraphs should be 01 */ |
| 69 | unsigned char checksum; /* All bytes must add up to zero */ |
| 70 | unsigned char reserved[5]; /* Must be zero */ |
| 71 | } fields; |
| 72 | char chars[16]; |
| 73 | }; |
| 74 | |
| 75 | /* |
| 76 | * Physical address of the service directory. I don't know if we're |
| 77 | * allowed to have more than one of these or not, so just in case |
| 78 | * we'll make pcibios_present() take a memory start parameter and store |
| 79 | * the array there. |
| 80 | */ |
| 81 | |
| 82 | static struct { |
| 83 | unsigned long address; |
| 84 | unsigned short segment; |
Mathias Krause | 615f775 | 2014-08-25 23:26:39 +0200 | [diff] [blame] | 85 | } bios32_indirect __initdata = { 0, __KERNEL_CS }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * Returns the entry point for the given service, NULL on error |
| 89 | */ |
| 90 | |
Mathias Krause | 615f775 | 2014-08-25 23:26:39 +0200 | [diff] [blame] | 91 | static unsigned long __init bios32_service(unsigned long service) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | { |
| 93 | unsigned char return_code; /* %al */ |
| 94 | unsigned long address; /* %ebx */ |
| 95 | unsigned long length; /* %ecx */ |
| 96 | unsigned long entry; /* %edx */ |
| 97 | unsigned long flags; |
| 98 | |
| 99 | local_irq_save(flags); |
| 100 | __asm__("lcall *(%%edi); cld" |
| 101 | : "=a" (return_code), |
| 102 | "=b" (address), |
| 103 | "=c" (length), |
| 104 | "=d" (entry) |
| 105 | : "0" (service), |
| 106 | "1" (0), |
| 107 | "D" (&bios32_indirect)); |
| 108 | local_irq_restore(flags); |
| 109 | |
| 110 | switch (return_code) { |
| 111 | case 0: |
| 112 | return address + entry; |
| 113 | case 0x80: /* Not present */ |
| 114 | printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service); |
| 115 | return 0; |
| 116 | default: /* Shouldn't happen */ |
| 117 | printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n", |
| 118 | service, return_code); |
| 119 | return 0; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | static struct { |
| 124 | unsigned long address; |
| 125 | unsigned short segment; |
Kees Cook | 404f6aa | 2016-08-08 16:29:06 -0700 | [diff] [blame] | 126 | } pci_indirect __ro_after_init = { |
| 127 | .address = 0, |
| 128 | .segment = __KERNEL_CS, |
| 129 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
Kees Cook | 404f6aa | 2016-08-08 16:29:06 -0700 | [diff] [blame] | 131 | static int pci_bios_present __ro_after_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
Mathias Krause | 615f775 | 2014-08-25 23:26:39 +0200 | [diff] [blame] | 133 | static int __init check_pcibios(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | { |
| 135 | u32 signature, eax, ebx, ecx; |
| 136 | u8 status, major_ver, minor_ver, hw_mech; |
| 137 | unsigned long flags, pcibios_entry; |
| 138 | |
| 139 | if ((pcibios_entry = bios32_service(PCI_SERVICE))) { |
| 140 | pci_indirect.address = pcibios_entry + PAGE_OFFSET; |
| 141 | |
| 142 | local_irq_save(flags); |
| 143 | __asm__( |
| 144 | "lcall *(%%edi); cld\n\t" |
| 145 | "jc 1f\n\t" |
| 146 | "xor %%ah, %%ah\n" |
| 147 | "1:" |
| 148 | : "=d" (signature), |
| 149 | "=a" (eax), |
| 150 | "=b" (ebx), |
| 151 | "=c" (ecx) |
| 152 | : "1" (PCIBIOS_PCI_BIOS_PRESENT), |
| 153 | "D" (&pci_indirect) |
| 154 | : "memory"); |
| 155 | local_irq_restore(flags); |
| 156 | |
| 157 | status = (eax >> 8) & 0xff; |
| 158 | hw_mech = eax & 0xff; |
| 159 | major_ver = (ebx >> 8) & 0xff; |
| 160 | minor_ver = ebx & 0xff; |
| 161 | if (pcibios_last_bus < 0) |
| 162 | pcibios_last_bus = ecx & 0xff; |
| 163 | DBG("PCI: BIOS probe returned s=%02x hw=%02x ver=%02x.%02x l=%02x\n", |
| 164 | status, hw_mech, major_ver, minor_ver, pcibios_last_bus); |
| 165 | if (status || signature != PCI_SIGNATURE) { |
| 166 | printk (KERN_ERR "PCI: BIOS BUG #%x[%08x] found\n", |
| 167 | status, signature); |
| 168 | return 0; |
| 169 | } |
| 170 | printk(KERN_INFO "PCI: PCI BIOS revision %x.%02x entry at 0x%lx, last bus=%d\n", |
| 171 | major_ver, minor_ver, pcibios_entry, pcibios_last_bus); |
| 172 | #ifdef CONFIG_PCI_DIRECT |
| 173 | if (!(hw_mech & PCIBIOS_HW_TYPE1)) |
| 174 | pci_probe &= ~PCI_PROBE_CONF1; |
| 175 | if (!(hw_mech & PCIBIOS_HW_TYPE2)) |
| 176 | pci_probe &= ~PCI_PROBE_CONF2; |
| 177 | #endif |
| 178 | return 1; |
| 179 | } |
| 180 | return 0; |
| 181 | } |
| 182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | static int pci_bios_read(unsigned int seg, unsigned int bus, |
| 184 | unsigned int devfn, int reg, int len, u32 *value) |
| 185 | { |
| 186 | unsigned long result = 0; |
| 187 | unsigned long flags; |
| 188 | unsigned long bx = (bus << 8) | devfn; |
Geliang Tang | 96ae646 | 2015-12-07 22:24:24 +0800 | [diff] [blame] | 189 | u16 number = 0, mask = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | |
Jan Beulich | db34a36 | 2011-07-22 08:13:05 +0100 | [diff] [blame] | 191 | WARN_ON(seg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | if (!value || (bus > 255) || (devfn > 255) || (reg > 255)) |
| 193 | return -EINVAL; |
| 194 | |
Thomas Gleixner | d19f61f | 2010-02-17 14:35:25 +0000 | [diff] [blame] | 195 | raw_spin_lock_irqsave(&pci_config_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | |
| 197 | switch (len) { |
| 198 | case 1: |
Geliang Tang | 96ae646 | 2015-12-07 22:24:24 +0800 | [diff] [blame] | 199 | number = PCIBIOS_READ_CONFIG_BYTE; |
| 200 | mask = 0xff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | break; |
| 202 | case 2: |
Geliang Tang | 96ae646 | 2015-12-07 22:24:24 +0800 | [diff] [blame] | 203 | number = PCIBIOS_READ_CONFIG_WORD; |
| 204 | mask = 0xffff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | break; |
| 206 | case 4: |
Geliang Tang | 96ae646 | 2015-12-07 22:24:24 +0800 | [diff] [blame] | 207 | number = PCIBIOS_READ_CONFIG_DWORD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | break; |
| 209 | } |
| 210 | |
Geliang Tang | 96ae646 | 2015-12-07 22:24:24 +0800 | [diff] [blame] | 211 | __asm__("lcall *(%%esi); cld\n\t" |
| 212 | "jc 1f\n\t" |
| 213 | "xor %%ah, %%ah\n" |
| 214 | "1:" |
| 215 | : "=c" (*value), |
| 216 | "=a" (result) |
| 217 | : "1" (number), |
| 218 | "b" (bx), |
| 219 | "D" ((long)reg), |
| 220 | "S" (&pci_indirect)); |
| 221 | /* |
| 222 | * Zero-extend the result beyond 8 or 16 bits, do not trust the |
| 223 | * BIOS having done it: |
| 224 | */ |
| 225 | if (mask) |
| 226 | *value &= mask; |
| 227 | |
Thomas Gleixner | d19f61f | 2010-02-17 14:35:25 +0000 | [diff] [blame] | 228 | raw_spin_unlock_irqrestore(&pci_config_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | |
| 230 | return (int)((result & 0xff00) >> 8); |
| 231 | } |
| 232 | |
| 233 | static int pci_bios_write(unsigned int seg, unsigned int bus, |
| 234 | unsigned int devfn, int reg, int len, u32 value) |
| 235 | { |
| 236 | unsigned long result = 0; |
| 237 | unsigned long flags; |
| 238 | unsigned long bx = (bus << 8) | devfn; |
Geliang Tang | 96ae646 | 2015-12-07 22:24:24 +0800 | [diff] [blame] | 239 | u16 number = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | |
Jan Beulich | db34a36 | 2011-07-22 08:13:05 +0100 | [diff] [blame] | 241 | WARN_ON(seg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | if ((bus > 255) || (devfn > 255) || (reg > 255)) |
| 243 | return -EINVAL; |
| 244 | |
Thomas Gleixner | d19f61f | 2010-02-17 14:35:25 +0000 | [diff] [blame] | 245 | raw_spin_lock_irqsave(&pci_config_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | |
| 247 | switch (len) { |
| 248 | case 1: |
Geliang Tang | 96ae646 | 2015-12-07 22:24:24 +0800 | [diff] [blame] | 249 | number = PCIBIOS_WRITE_CONFIG_BYTE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | break; |
| 251 | case 2: |
Geliang Tang | 96ae646 | 2015-12-07 22:24:24 +0800 | [diff] [blame] | 252 | number = PCIBIOS_WRITE_CONFIG_WORD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | break; |
| 254 | case 4: |
Geliang Tang | 96ae646 | 2015-12-07 22:24:24 +0800 | [diff] [blame] | 255 | number = PCIBIOS_WRITE_CONFIG_DWORD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | break; |
| 257 | } |
| 258 | |
Geliang Tang | 96ae646 | 2015-12-07 22:24:24 +0800 | [diff] [blame] | 259 | __asm__("lcall *(%%esi); cld\n\t" |
| 260 | "jc 1f\n\t" |
| 261 | "xor %%ah, %%ah\n" |
| 262 | "1:" |
| 263 | : "=a" (result) |
| 264 | : "0" (number), |
| 265 | "c" (value), |
| 266 | "b" (bx), |
| 267 | "D" ((long)reg), |
| 268 | "S" (&pci_indirect)); |
| 269 | |
Thomas Gleixner | d19f61f | 2010-02-17 14:35:25 +0000 | [diff] [blame] | 270 | raw_spin_unlock_irqrestore(&pci_config_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | |
| 272 | return (int)((result & 0xff00) >> 8); |
| 273 | } |
| 274 | |
| 275 | |
| 276 | /* |
| 277 | * Function table for BIOS32 access |
| 278 | */ |
| 279 | |
Jan Beulich | 72da0b0 | 2011-09-15 08:58:51 +0100 | [diff] [blame] | 280 | static const struct pci_raw_ops pci_bios_access = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | .read = pci_bios_read, |
| 282 | .write = pci_bios_write |
| 283 | }; |
| 284 | |
| 285 | /* |
| 286 | * Try to find PCI BIOS. |
| 287 | */ |
| 288 | |
Mathias Krause | 615f775 | 2014-08-25 23:26:39 +0200 | [diff] [blame] | 289 | static const struct pci_raw_ops *__init pci_find_bios(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | { |
| 291 | union bios32 *check; |
| 292 | unsigned char sum; |
| 293 | int i, length; |
| 294 | |
| 295 | /* |
| 296 | * Follow the standard procedure for locating the BIOS32 Service |
| 297 | * directory by scanning the permissible address range from |
| 298 | * 0xe0000 through 0xfffff for a valid BIOS32 structure. |
| 299 | */ |
| 300 | |
| 301 | for (check = (union bios32 *) __va(0xe0000); |
| 302 | check <= (union bios32 *) __va(0xffff0); |
| 303 | ++check) { |
Rusty Russell | bd472c7 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 304 | long sig; |
| 305 | if (probe_kernel_address(&check->fields.signature, sig)) |
| 306 | continue; |
| 307 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | if (check->fields.signature != BIOS32_SIGNATURE) |
| 309 | continue; |
| 310 | length = check->fields.length * 16; |
| 311 | if (!length) |
| 312 | continue; |
| 313 | sum = 0; |
| 314 | for (i = 0; i < length ; ++i) |
| 315 | sum += check->chars[i]; |
| 316 | if (sum != 0) |
| 317 | continue; |
| 318 | if (check->fields.revision != 0) { |
| 319 | printk("PCI: unsupported BIOS32 revision %d at 0x%p\n", |
| 320 | check->fields.revision, check); |
| 321 | continue; |
| 322 | } |
| 323 | DBG("PCI: BIOS32 Service Directory structure at 0x%p\n", check); |
| 324 | if (check->fields.entry >= 0x100000) { |
Rusty Russell | bd472c7 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 325 | printk("PCI: BIOS32 entry (0x%p) in high memory, " |
| 326 | "cannot use.\n", check); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | return NULL; |
| 328 | } else { |
| 329 | unsigned long bios32_entry = check->fields.entry; |
Rusty Russell | bd472c7 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 330 | DBG("PCI: BIOS32 Service Directory entry at 0x%lx\n", |
| 331 | bios32_entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | bios32_indirect.address = bios32_entry + PAGE_OFFSET; |
Matthieu Castet | 5bd5a45 | 2010-11-16 22:31:26 +0100 | [diff] [blame] | 333 | set_bios_x(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | if (check_pcibios()) |
| 335 | return &pci_bios_access; |
| 336 | } |
| 337 | break; /* Hopefully more than one BIOS32 cannot happen... */ |
| 338 | } |
| 339 | |
| 340 | return NULL; |
| 341 | } |
| 342 | |
| 343 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | * BIOS Functions for IRQ Routing |
| 345 | */ |
| 346 | |
| 347 | struct irq_routing_options { |
| 348 | u16 size; |
| 349 | struct irq_info *table; |
| 350 | u16 segment; |
| 351 | } __attribute__((packed)); |
| 352 | |
Ralf Baechle | 4dd5bb9 | 2007-08-23 19:45:49 +0100 | [diff] [blame] | 353 | struct irq_routing_table * pcibios_get_irq_routing_table(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | { |
| 355 | struct irq_routing_options opt; |
| 356 | struct irq_routing_table *rt = NULL; |
| 357 | int ret, map; |
| 358 | unsigned long page; |
| 359 | |
| 360 | if (!pci_bios_present) |
| 361 | return NULL; |
| 362 | page = __get_free_page(GFP_KERNEL); |
| 363 | if (!page) |
| 364 | return NULL; |
| 365 | opt.table = (struct irq_info *) page; |
| 366 | opt.size = PAGE_SIZE; |
| 367 | opt.segment = __KERNEL_DS; |
| 368 | |
| 369 | DBG("PCI: Fetching IRQ routing table... "); |
| 370 | __asm__("push %%es\n\t" |
| 371 | "push %%ds\n\t" |
| 372 | "pop %%es\n\t" |
| 373 | "lcall *(%%esi); cld\n\t" |
| 374 | "pop %%es\n\t" |
| 375 | "jc 1f\n\t" |
| 376 | "xor %%ah, %%ah\n" |
| 377 | "1:" |
| 378 | : "=a" (ret), |
| 379 | "=b" (map), |
| 380 | "=m" (opt) |
| 381 | : "0" (PCIBIOS_GET_ROUTING_OPTIONS), |
| 382 | "1" (0), |
| 383 | "D" ((long) &opt), |
| 384 | "S" (&pci_indirect), |
| 385 | "m" (opt) |
| 386 | : "memory"); |
| 387 | DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map); |
| 388 | if (ret & 0xff00) |
| 389 | printk(KERN_ERR "PCI: Error %02x when fetching IRQ routing table.\n", (ret >> 8) & 0xff); |
| 390 | else if (opt.size) { |
| 391 | rt = kmalloc(sizeof(struct irq_routing_table) + opt.size, GFP_KERNEL); |
| 392 | if (rt) { |
| 393 | memset(rt, 0, sizeof(struct irq_routing_table)); |
| 394 | rt->size = opt.size + sizeof(struct irq_routing_table); |
| 395 | rt->exclusive_irqs = map; |
| 396 | memcpy(rt->slots, (void *) page, opt.size); |
| 397 | printk(KERN_INFO "PCI: Using BIOS Interrupt Routing Table\n"); |
| 398 | } |
| 399 | } |
| 400 | free_page(page); |
| 401 | return rt; |
| 402 | } |
Alexey Dobriyan | 129f694 | 2005-06-23 00:08:33 -0700 | [diff] [blame] | 403 | EXPORT_SYMBOL(pcibios_get_irq_routing_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | |
| 405 | int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq) |
| 406 | { |
| 407 | int ret; |
| 408 | |
| 409 | __asm__("lcall *(%%esi); cld\n\t" |
| 410 | "jc 1f\n\t" |
| 411 | "xor %%ah, %%ah\n" |
| 412 | "1:" |
| 413 | : "=a" (ret) |
| 414 | : "0" (PCIBIOS_SET_PCI_HW_INT), |
| 415 | "b" ((dev->bus->number << 8) | dev->devfn), |
| 416 | "c" ((irq << 8) | (pin + 10)), |
| 417 | "S" (&pci_indirect)); |
| 418 | return !(ret & 0xff00); |
| 419 | } |
Alexey Dobriyan | 129f694 | 2005-06-23 00:08:33 -0700 | [diff] [blame] | 420 | EXPORT_SYMBOL(pcibios_set_irq_routing); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | |
Andi Kleen | 92c05fc | 2006-03-23 14:35:12 -0800 | [diff] [blame] | 422 | void __init pci_pcbios_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | { |
| 424 | if ((pci_probe & PCI_PROBE_BIOS) |
| 425 | && ((raw_pci_ops = pci_find_bios()))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | pci_bios_present = 1; |
| 427 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | } |
| 429 | |