- Update Xen patches to 3.3-rc5 and c/s 1157.
[linux-flexiantxendom0-3.2.10.git] / arch / x86 / pci / pcifront.c
1 /*
2  * PCI Frontend Stub - puts some "dummy" functions in to the Linux x86 PCI core
3  *                     to support the Xen PCI Frontend's operation
4  *
5  *   Author: Ryan Wilson <hap9@epoch.ncsc.mil>
6  */
7 #include <linux/init.h>
8 #include <linux/irq.h>
9 #include <linux/pci.h>
10 #include <asm/acpi.h>
11 #include <asm/pci_x86.h>
12 #include <xen/evtchn.h>
13
14 static int pcifront_enable_irq(struct pci_dev *dev)
15 {
16         u8 irq;
17         pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
18         if (!alloc_irq_and_cfg_at(irq, numa_node_id()))
19                 return -ENOMEM;
20         evtchn_register_pirq(irq);
21         dev->irq = irq;
22
23         return 0;
24 }
25
26 extern u8 pci_cache_line_size;
27
28 static int __init pcifront_x86_stub_init(void)
29 {
30         struct cpuinfo_x86 *c = &boot_cpu_data;
31
32         /* Only install our method if we haven't found real hardware already */
33         if (raw_pci_ops)
34                 return 0;
35
36         pr_info("PCI: setting up Xen PCI frontend stub\n");
37
38         /* Copied from arch/i386/pci/common.c */
39         pci_cache_line_size = 32 >> 2;
40         if (c->x86 >= 6 && c->x86_vendor == X86_VENDOR_AMD)
41                 pci_cache_line_size = 64 >> 2;  /* K7 & K8 */
42         else if (c->x86 > 6 && c->x86_vendor == X86_VENDOR_INTEL)
43                 pci_cache_line_size = 128 >> 2; /* P4 */
44
45         /* On x86, we need to disable the normal IRQ routing table and
46          * just ask the backend
47          */
48         pcibios_enable_irq = pcifront_enable_irq;
49         pcibios_disable_irq = NULL;
50
51 #ifdef CONFIG_ACPI
52         /* Keep ACPI out of the picture */
53         acpi_noirq = 1;
54 #endif
55
56         return 0;
57 }
58
59 arch_initcall(pcifront_x86_stub_init);