debuggers.hg

view linux-2.6.11-xen-sparse/arch/xen/i386/pci/irq.c @ 4621:c75e32dc585e

bitkeeper revision 1.1331 (42662daawcgGfsYXrl37riGl22RhdA)

[PATCH] [PATCH 1/2] i386 whitespace cleanup in Linux sparse tree

Eliminate extraneous whitespace changes in i386 portion of Linux
sparse patch.

Signed-off-by: Chris Wright <chrisw@osdl.org>
author chrisw@osdl.org[kaf24]
date Wed Apr 20 10:23:38 2005 +0000 (2005-04-20)
parents a01199a95070
children c9edf0896f07 f23e5c9c3f1b 65b28c74cec2
line source
1 /*
2 * Low-Level PCI Support for PC -- Routing of Interrupts
3 *
4 * (c) 1999--2000 Martin Mares <mj@ucw.cz>
5 */
7 #include <linux/config.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/pci.h>
11 #include <linux/init.h>
12 #include <linux/slab.h>
13 #include <linux/interrupt.h>
14 #include <linux/irq.h>
15 #include <asm/io.h>
16 #include <asm/smp.h>
17 #include <asm/io_apic.h>
18 #include <asm/hw_irq.h>
19 #include <linux/acpi.h>
21 #include "pci.h"
23 #include <asm-xen/xen-public/xen.h>
24 #include <asm-xen/xen-public/physdev.h>
26 static int pirq_enable_irq(struct pci_dev *dev);
28 /*
29 * Never use: 0, 1, 2 (timer, keyboard, and cascade)
30 * Avoid using: 13, 14 and 15 (FP error and IDE).
31 * Penalize: 3, 4, 6, 7, 12 (known ISA uses: serial, floppy, parallel and mouse)
32 */
33 unsigned int pcibios_irq_mask = 0xfff8;
35 static int pirq_penalty[16] = {
36 1000000, 1000000, 1000000, 1000, 1000, 0, 1000, 1000,
37 0, 0, 0, 0, 1000, 100000, 100000, 100000
38 };
40 int (*pcibios_enable_irq)(struct pci_dev *dev) = NULL;
43 static int __init pcibios_irq_init(void)
44 {
45 int bus;
46 physdev_op_t op;
48 DBG("PCI: IRQ init\n");
50 if (pcibios_enable_irq || raw_pci_ops == NULL)
51 return 0;
53 op.cmd = PHYSDEVOP_PCI_PROBE_ROOT_BUSES;
54 if (HYPERVISOR_physdev_op(&op) != 0) {
55 printk(KERN_WARNING "PCI: System does not support PCI\n");
56 return 0;
57 }
59 printk(KERN_INFO "PCI: Probing PCI hardware\n");
60 for (bus = 0; bus < 256; bus++)
61 if (test_bit(bus, (unsigned long *)
62 &op.u.pci_probe_root_buses.busmask[0]))
63 (void)pcibios_scan_root(bus);
65 pcibios_enable_irq = pirq_enable_irq;
67 return 0;
68 }
70 subsys_initcall(pcibios_irq_init);
73 static void pirq_penalize_isa_irq(int irq)
74 {
75 /*
76 * If any ISAPnP device reports an IRQ in its list of possible
77 * IRQ's, we try to avoid assigning it to PCI devices.
78 */
79 if (irq < 16)
80 pirq_penalty[irq] += 100;
81 }
83 void pcibios_penalize_isa_irq(int irq)
84 {
85 #ifdef CONFIG_ACPI_PCI
86 if (!acpi_noirq)
87 acpi_penalize_isa_irq(irq);
88 else
89 #endif
90 pirq_penalize_isa_irq(irq);
91 }
93 static int pirq_enable_irq(struct pci_dev *dev)
94 {
95 int err;
96 u8 pin;
97 physdev_op_t op;
99 /* Inform Xen that we are going to use this device. */
100 op.cmd = PHYSDEVOP_PCI_INITIALISE_DEVICE;
101 op.u.pci_initialise_device.bus = dev->bus->number;
102 op.u.pci_initialise_device.dev = PCI_SLOT(dev->devfn);
103 op.u.pci_initialise_device.func = PCI_FUNC(dev->devfn);
104 if ( (err = HYPERVISOR_physdev_op(&op)) != 0 )
105 return err;
107 /* Now we can bind to the very final IRQ line. */
108 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &pin);
109 dev->irq = pin;
111 /* Sanity-check that an interrupt-producing device is routed
112 * to an IRQ. */
113 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
114 if (pin != 0) {
115 if (dev->irq != 0)
116 printk(KERN_INFO "PCI: Obtained IRQ %d for device %s\n",
117 dev->irq, dev->slot_name);
118 else
119 printk(KERN_WARNING "PCI: No IRQ known for interrupt "
120 "pin %c of device %s.\n", 'A' + pin - 1,
121 dev->slot_name);
122 }
124 return 0;
125 }
127 int pci_vector_resources(int last, int nr_released)
128 {
129 int count = nr_released;
131 int next = last;
132 int offset = (last % 8);
134 while (next < FIRST_SYSTEM_VECTOR) {
135 next += 8;
136 #ifdef CONFIG_X86_64
137 if (next == IA32_SYSCALL_VECTOR)
138 continue;
139 #else
140 if (next == SYSCALL_VECTOR)
141 continue;
142 #endif
143 count++;
144 if (next >= FIRST_SYSTEM_VECTOR) {
145 if (offset%8) {
146 next = FIRST_DEVICE_VECTOR + offset;
147 offset++;
148 continue;
149 }
150 count--;
151 }
152 }
154 return count;
155 }