aboutsummaryrefslogtreecommitdiffstats
path: root/xenolinux-2.4.25-sparse/arch
diff options
context:
space:
mode:
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2004-03-12 15:47:50 +0000
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2004-03-12 15:47:50 +0000
commitb561b39a00f588fc9eea6cba438e92ae90170e7c (patch)
tree510222a1a040be3c8d600e3fb6fd1534b35036fe /xenolinux-2.4.25-sparse/arch
parentb0b22e49bcb71d4d52625489574ba9ac60e95f07 (diff)
downloadxen-b561b39a00f588fc9eea6cba438e92ae90170e7c.tar.gz
xen-b561b39a00f588fc9eea6cba438e92ae90170e7c.tar.bz2
xen-b561b39a00f588fc9eea6cba438e92ae90170e7c.zip
bitkeeper revision 1.789 (4051dba62id7XBLQIfBX2kqtjQJzfQ)
physirq.c, pci-pc.c, pci-irq.c, pci-i386.h, pci-i386.c, pci-dma.c, physdev.h: new file Many files: Second half of Rolf's IO patch.
Diffstat (limited to 'xenolinux-2.4.25-sparse/arch')
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/config.in6
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/defconfig2
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/drivers/block/xl_block.c6
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/drivers/console/console.c3
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/drivers/evtchn/xl_evtchn.c6
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/drivers/network/network.c8
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/kernel/Makefile6
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/kernel/hypervisor.c39
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-dma.c37
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-i386.c410
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-i386.h71
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-irq.c90
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-pc.c364
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/kernel/physirq.c156
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/kernel/setup.c4
-rw-r--r--xenolinux-2.4.25-sparse/arch/xeno/kernel/time.c4
16 files changed, 1178 insertions, 34 deletions
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/config.in b/xenolinux-2.4.25-sparse/arch/xeno/config.in
index 57e339165b..39e821556a 100644
--- a/xenolinux-2.4.25-sparse/arch/xeno/config.in
+++ b/xenolinux-2.4.25-sparse/arch/xeno/config.in
@@ -104,6 +104,12 @@ comment 'General setup'
bool 'Networking support' CONFIG_NET
+bool 'PCI support' CONFIG_PCI
+if [ "$CONFIG_PCI" = "y" ]; then
+ tristate ' 3c590/3c900 series (592/595/597) "Vortex/Boomerang" support' CONFIG_VORTEX
+fi
+source drivers/pci/Config.in
+
bool 'System V IPC' CONFIG_SYSVIPC
bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT
bool 'Sysctl support' CONFIG_SYSCTL
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/defconfig b/xenolinux-2.4.25-sparse/arch/xeno/defconfig
index 33dcb7f653..b7bedbcf3d 100644
--- a/xenolinux-2.4.25-sparse/arch/xeno/defconfig
+++ b/xenolinux-2.4.25-sparse/arch/xeno/defconfig
@@ -55,6 +55,8 @@ CONFIG_NOHIGHMEM=y
# General setup
#
CONFIG_NET=y
+# CONFIG_PCI is not set
+# CONFIG_PCI_NAMES is not set
CONFIG_SYSVIPC=y
# CONFIG_BSD_PROCESS_ACCT is not set
CONFIG_SYSCTL=y
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/drivers/block/xl_block.c b/xenolinux-2.4.25-sparse/arch/xeno/drivers/block/xl_block.c
index a91ed32a74..dac8c2665f 100644
--- a/xenolinux-2.4.25-sparse/arch/xeno/drivers/block/xl_block.c
+++ b/xenolinux-2.4.25-sparse/arch/xeno/drivers/block/xl_block.c
@@ -18,9 +18,9 @@
typedef unsigned char byte; /* from linux/ide.h */
-#define XLBLK_RESPONSE_IRQ _EVENT_BLKDEV
-#define XLBLK_UPDATE_IRQ _EVENT_VBD_UPD
-#define DEBUG_IRQ _EVENT_DEBUG
+#define XLBLK_RESPONSE_IRQ HYPEREVENT_IRQ(_EVENT_BLKDEV)
+#define XLBLK_UPDATE_IRQ HYPEREVENT_IRQ(_EVENT_VBD_UPD)
+#define DEBUG_IRQ HYPEREVENT_IRQ(_EVENT_DEBUG)
#define STATE_ACTIVE 0
#define STATE_SUSPENDED 1
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/drivers/console/console.c b/xenolinux-2.4.25-sparse/arch/xeno/drivers/console/console.c
index 2e18d72854..367b9b4f0e 100644
--- a/xenolinux-2.4.25-sparse/arch/xeno/drivers/console/console.c
+++ b/xenolinux-2.4.25-sparse/arch/xeno/drivers/console/console.c
@@ -446,7 +446,8 @@ int __init xeno_con_init(void)
}
else
{
- request_irq(_EVENT_CONSOLE, control_irq, 0, "console", NULL);
+ request_irq(HYPEREVENT_IRQ(_EVENT_CONSOLE),
+ control_irq, 0, "console", NULL);
control_irq(0, NULL, NULL); /* kickstart the console */
}
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/drivers/evtchn/xl_evtchn.c b/xenolinux-2.4.25-sparse/arch/xeno/drivers/evtchn/xl_evtchn.c
index f060562529..f642d082cd 100644
--- a/xenolinux-2.4.25-sparse/arch/xeno/drivers/evtchn/xl_evtchn.c
+++ b/xenolinux-2.4.25-sparse/arch/xeno/drivers/evtchn/xl_evtchn.c
@@ -21,6 +21,7 @@
#include <linux/devfs_fs_kernel.h>
#include <linux/stat.h>
#include <linux/poll.h>
+#include <linux/irq.h>
#include <asm/evtchn.h>
/* NB. This must be shared amongst drivers if more things go in /dev/xen */
@@ -454,7 +455,8 @@ static int __init init_module(void)
/* (DEVFS) automatically destroy the symlink with its destination. */
devfs_auto_unregister(evtchn_miscdev.devfs_handle, symlink_handle);
- err = request_irq(_EVENT_EVTCHN, evtchn_interrupt, 0, "evtchn", NULL);
+ err = request_irq(HYPEREVENT_IRQ(_EVENT_EVTCHN),
+ evtchn_interrupt, 0, "evtchn", NULL);
if ( err != 0 )
{
printk(KERN_ALERT "Could not allocate evtchn receive interrupt\n");
@@ -471,7 +473,7 @@ static int __init init_module(void)
static void cleanup_module(void)
{
- free_irq(_EVENT_EVTCHN, NULL);
+ free_irq(HYPEREVENT_IRQ(_EVENT_EVTCHN), NULL);
misc_deregister(&evtchn_miscdev);
}
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/drivers/network/network.c b/xenolinux-2.4.25-sparse/arch/xeno/drivers/network/network.c
index 95b4c45501..512f6530a5 100644
--- a/xenolinux-2.4.25-sparse/arch/xeno/drivers/network/network.c
+++ b/xenolinux-2.4.25-sparse/arch/xeno/drivers/network/network.c
@@ -25,8 +25,6 @@
#include <net/sock.h>
#include <net/pkt_sched.h>
-#define NET_IRQ _EVENT_NET
-
#define RX_BUF_SIZE ((PAGE_SIZE/2)+1) /* Fool the slab allocator :-) */
static void network_interrupt(int irq, void *dev_id, struct pt_regs *ptregs);
@@ -546,7 +544,7 @@ static int __init init_module(void)
if ( start_info.flags & SIF_INITDOMAIN )
(void)register_inetaddr_notifier(&notifier_inetdev);
- err = request_irq(NET_IRQ, network_interrupt,
+ err = request_irq(HYPEREVENT_IRQ(_EVENT_NET), network_interrupt,
SA_SAMPLE_RANDOM, "network", NULL);
if ( err )
{
@@ -554,8 +552,8 @@ static int __init init_module(void)
goto fail;
}
- err = request_irq(_EVENT_DEBUG, dbg_network_int, SA_SHIRQ, "net_dbg",
- &dbg_network_int);
+ err = request_irq(HYPEREVENT_IRQ(_EVENT_DEBUG), dbg_network_int,
+ SA_SHIRQ, "net_dbg", &dbg_network_int);
if ( err )
printk(KERN_WARNING "Non-fatal error -- no debug interrupt\n");
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/kernel/Makefile b/xenolinux-2.4.25-sparse/arch/xeno/kernel/Makefile
index a43a615e2f..10fc43e742 100644
--- a/xenolinux-2.4.25-sparse/arch/xeno/kernel/Makefile
+++ b/xenolinux-2.4.25-sparse/arch/xeno/kernel/Makefile
@@ -10,6 +10,10 @@ export-objs := i386_ksyms.o
obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \
ptrace.o ioport.o ldt.o setup.o time.o sys_i386.o \
- i386_ksyms.o i387.o hypervisor.o
+ i386_ksyms.o i387.o hypervisor.o physirq.o pci-dma.o
+
+ifdef CONFIG_PCI
+obj-y += pci-i386.o pci-pc.o pci-irq.o
+endif
include $(TOPDIR)/Rules.make
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/kernel/hypervisor.c b/xenolinux-2.4.25-sparse/arch/xeno/kernel/hypervisor.c
index 8e7e144137..64a3590362 100644
--- a/xenolinux-2.4.25-sparse/arch/xeno/kernel/hypervisor.c
+++ b/xenolinux-2.4.25-sparse/arch/xeno/kernel/hypervisor.c
@@ -37,13 +37,14 @@ void do_hypervisor_callback(struct pt_regs *regs)
" sub $4,%%esp ;"
" jmp 2f ;"
"1: btrl %%eax,%0 ;" /* clear bit */
+ " add %2,%%eax ;"
" mov %%eax,(%%esp) ;"
" call do_IRQ ;" /* do_IRQ(event) */
"2: bsfl %0,%%eax ;" /* %eax == bit # */
" jnz 1b ;"
" add $8,%%esp ;"
/* we use %ebx because it is callee-saved */
- : : "b" (events), "r" (regs)
+ : : "b" (events), "r" (regs), "i" (HYPEREVENT_IRQ_BASE)
/* clobbered by callback function calls */
: "eax", "ecx", "edx", "memory" );
@@ -54,41 +55,40 @@ void do_hypervisor_callback(struct pt_regs *regs)
while ( shared->events );
}
-
-
/*
* Define interface to generic handling in irq.c
*/
static void shutdown_hypervisor_event(unsigned int irq)
{
- clear_bit(irq, &event_mask);
- clear_bit(irq, &HYPERVISOR_shared_info->events_mask);
+ clear_bit(HYPEREVENT_FROM_IRQ(irq), &event_mask);
+ clear_bit(HYPEREVENT_FROM_IRQ(irq), &HYPERVISOR_shared_info->events_mask);
}
static void enable_hypervisor_event(unsigned int irq)
{
- set_bit(irq, &event_mask);
- set_bit(irq, &HYPERVISOR_shared_info->events_mask);
- if ( test_bit(EVENTS_MASTER_ENABLE_BIT,
+ set_bit(HYPEREVENT_FROM_IRQ(irq), &event_mask);
+ set_bit(HYPEREVENT_FROM_IRQ(irq), &HYPERVISOR_shared_info->events_mask);
+ if ( test_bit(EVENTS_MASTER_ENABLE_BIT,
&HYPERVISOR_shared_info->events_mask) )
do_hypervisor_callback(NULL);
}
static void disable_hypervisor_event(unsigned int irq)
{
- clear_bit(irq, &event_mask);
- clear_bit(irq, &HYPERVISOR_shared_info->events_mask);
+ clear_bit(HYPEREVENT_FROM_IRQ(irq), &event_mask);
+ clear_bit(HYPEREVENT_FROM_IRQ(irq), &HYPERVISOR_shared_info->events_mask);
}
static void ack_hypervisor_event(unsigned int irq)
{
- if ( !(event_mask & (1<<irq)) )
+ int ev = HYPEREVENT_FROM_IRQ(irq);
+ if ( !(event_mask & (1<<ev)) )
{
- printk("Unexpected hypervisor event %d\n", irq);
+ printk("Unexpected hypervisor event %d\n", ev);
atomic_inc(&irq_err_count);
}
- set_bit(irq, &HYPERVISOR_shared_info->events_mask);
+ set_bit(ev, &HYPERVISOR_shared_info->events_mask);
}
static unsigned int startup_hypervisor_event(unsigned int irq)
@@ -116,11 +116,14 @@ void __init init_IRQ(void)
{
int i;
- for ( i = 0; i < NR_IRQS; i++ )
+ for ( i = 0; i < NR_HYPEREVENT_IRQS; i++ )
{
- irq_desc[i].status = IRQ_DISABLED;
- irq_desc[i].action = 0;
- irq_desc[i].depth = 1;
- irq_desc[i].handler = &hypervisor_irq_type;
+ irq_desc[i + HYPEREVENT_IRQ_BASE].status = IRQ_DISABLED;
+ irq_desc[i + HYPEREVENT_IRQ_BASE].action = 0;
+ irq_desc[i + HYPEREVENT_IRQ_BASE].depth = 1;
+ irq_desc[i + HYPEREVENT_IRQ_BASE].handler = &hypervisor_irq_type;
}
+
+ /* Also initialise the physical IRQ handlers. */
+ physirq_init();
}
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-dma.c b/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-dma.c
new file mode 100644
index 0000000000..dd8842719e
--- /dev/null
+++ b/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-dma.c
@@ -0,0 +1,37 @@
+/*
+ * Dynamic DMA mapping support.
+ *
+ * On i386 there is no hardware dynamic DMA address translation,
+ * so consistent alloc/free are merely page allocation/freeing.
+ * The rest of the dynamic DMA mapping interface is implemented
+ * in asm/pci.h.
+ */
+
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/pci.h>
+#include <asm/io.h>
+
+void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
+ dma_addr_t *dma_handle)
+{
+ void *ret;
+ int gfp = GFP_ATOMIC;
+
+ if (hwdev == NULL || ((u32)hwdev->dma_mask < 0xffffffff))
+ gfp |= GFP_DMA;
+ ret = (void *)__get_free_pages(gfp, get_order(size));
+
+ if (ret != NULL) {
+ memset(ret, 0, size);
+ *dma_handle = virt_to_bus(ret);
+ }
+ return ret;
+}
+
+void pci_free_consistent(struct pci_dev *hwdev, size_t size,
+ void *vaddr, dma_addr_t dma_handle)
+{
+ free_pages((unsigned long)vaddr, get_order(size));
+}
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-i386.c b/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-i386.c
new file mode 100644
index 0000000000..96dcdde6b3
--- /dev/null
+++ b/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-i386.c
@@ -0,0 +1,410 @@
+/*
+ * Low-Level PCI Access for i386 machines
+ *
+ * Copyright 1993, 1994 Drew Eckhardt
+ * Visionary Computing
+ * (Unix and Linux consulting and custom programming)
+ * Drew@Colorado.EDU
+ * +1 (303) 786-7975
+ *
+ * Drew's work was sponsored by:
+ * iX Multiuser Multitasking Magazine
+ * Hannover, Germany
+ * hm@ix.de
+ *
+ * Copyright 1997--2000 Martin Mares <mj@ucw.cz>
+ *
+ * For more information, please consult the following manuals (look at
+ * http://www.pcisig.com/ for how to get them):
+ *
+ * PCI BIOS Specification
+ * PCI Local Bus Specification
+ * PCI to PCI Bridge Specification
+ * PCI System Design Guide
+ *
+ *
+ * CHANGELOG :
+ * Jun 17, 1994 : Modified to accommodate the broken pre-PCI BIOS SPECIFICATION
+ * Revision 2.0 present on <thys@dennis.ee.up.ac.za>'s ASUS mainboard.
+ *
+ * Jan 5, 1995 : Modified to probe PCI hardware at boot time by Frederic
+ * Potter, potter@cao-vlsi.ibp.fr
+ *
+ * Jan 10, 1995 : Modified to store the information about configured pci
+ * devices into a list, which can be accessed via /proc/pci by
+ * Curtis Varner, cvarner@cs.ucr.edu
+ *
+ * Jan 12, 1995 : CPU-PCI bridge optimization support by Frederic Potter.
+ * Alpha version. Intel & UMC chipset support only.
+ *
+ * Apr 16, 1995 : Source merge with the DEC Alpha PCI support. Most of the code
+ * moved to drivers/pci/pci.c.
+ *
+ * Dec 7, 1996 : Added support for direct configuration access of boards
+ * with Intel compatible access schemes (tsbogend@alpha.franken.de)
+ *
+ * Feb 3, 1997 : Set internal functions to static, save/restore flags
+ * avoid dead locks reading broken PCI BIOS, werner@suse.de
+ *
+ * Apr 26, 1997 : Fixed case when there is BIOS32, but not PCI BIOS
+ * (mj@atrey.karlin.mff.cuni.cz)
+ *
+ * May 7, 1997 : Added some missing cli()'s. [mj]
+ *
+ * Jun 20, 1997 : Corrected problems in "conf1" type accesses.
+ * (paubert@iram.es)
+ *
+ * Aug 2, 1997 : Split to PCI BIOS handling and direct PCI access parts
+ * and cleaned it up... Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ *
+ * Feb 6, 1998 : No longer using BIOS to find devices and device classes. [mj]
+ *
+ * May 1, 1998 : Support for peer host bridges. [mj]
+ *
+ * Jun 19, 1998 : Changed to use spinlocks, so that PCI configuration space
+ * can be accessed from interrupts even on SMP systems. [mj]
+ *
+ * August 1998 : Better support for peer host bridges and more paranoid
+ * checks for direct hardware access. Ugh, this file starts to look as
+ * a large gallery of common hardware bug workarounds (watch the comments)
+ * -- the PCI specs themselves are sane, but most implementors should be
+ * hit hard with \hammer scaled \magstep5. [mj]
+ *
+ * Jan 23, 1999 : More improvements to peer host bridge logic. i450NX fixup. [mj]
+ *
+ * Feb 8, 1999 : Added UM8886BF I/O address fixup. [mj]
+ *
+ * August 1999 : New resource management and configuration access stuff. [mj]
+ *
+ * Sep 19, 1999 : Use PCI IRQ routing tables for detection of peer host bridges.
+ * Based on ideas by Chris Frantz and David Hinds. [mj]
+ *
+ * Sep 28, 1999 : Handle unreported/unassigned IRQs. Thanks to Shuu Yamaguchi
+ * for a lot of patience during testing. [mj]
+ *
+ * Oct 8, 1999 : Split to pci-i386.c, pci-pc.c and pci-visws.c. [mj]
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/errno.h>
+
+#include "pci-i386.h"
+
+void
+pcibios_update_resource(struct pci_dev *dev, struct resource *root,
+ struct resource *res, int resource)
+{
+ u32 new, check;
+ int reg;
+
+ new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
+ if (resource < 6) {
+ reg = PCI_BASE_ADDRESS_0 + 4*resource;
+ } else if (resource == PCI_ROM_RESOURCE) {
+ res->flags |= PCI_ROM_ADDRESS_ENABLE;
+ new |= PCI_ROM_ADDRESS_ENABLE;
+ reg = dev->rom_base_reg;
+ } else {
+ /* Somebody might have asked allocation of a non-standard resource */
+ return;
+ }
+
+ pci_write_config_dword(dev, reg, new);
+ pci_read_config_dword(dev, reg, &check);
+ if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
+ printk(KERN_ERR "PCI: Error while updating region "
+ "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
+ new, check);
+ }
+}
+
+/*
+ * We need to avoid collisions with `mirrored' VGA ports
+ * and other strange ISA hardware, so we always want the
+ * addresses to be allocated in the 0x000-0x0ff region
+ * modulo 0x400.
+ *
+ * Why? Because some silly external IO cards only decode
+ * the low 10 bits of the IO address. The 0x00-0xff region
+ * is reserved for motherboard devices that decode all 16
+ * bits, so it's ok to allocate at, say, 0x2800-0x28ff,
+ * but we want to try to avoid allocating at 0x2900-0x2bff
+ * which might have be mirrored at 0x0100-0x03ff..
+ */
+void
+pcibios_align_resource(void *data, struct resource *res,
+ unsigned long size, unsigned long align)
+{
+ if (res->flags & IORESOURCE_IO) {
+ unsigned long start = res->start;
+
+ if (start & 0x300) {
+ start = (start + 0x3ff) & ~0x3ff;
+ res->start = start;
+ }
+ }
+}
+
+
+/*
+ * Handle resources of PCI devices. If the world were perfect, we could
+ * just allocate all the resource regions and do nothing more. It isn't.
+ * On the other hand, we cannot just re-allocate all devices, as it would
+ * require us to know lots of host bridge internals. So we attempt to
+ * keep as much of the original configuration as possible, but tweak it
+ * when it's found to be wrong.
+ *
+ * Known BIOS problems we have to work around:
+ * - I/O or memory regions not configured
+ * - regions configured, but not enabled in the command register
+ * - bogus I/O addresses above 64K used
+ * - expansion ROMs left enabled (this may sound harmless, but given
+ * the fact the PCI specs explicitly allow address decoders to be
+ * shared between expansion ROMs and other resource regions, it's
+ * at least dangerous)
+ *
+ * Our solution:
+ * (1) Allocate resources for all buses behind PCI-to-PCI bridges.
+ * This gives us fixed barriers on where we can allocate.
+ * (2) Allocate resources for all enabled devices. If there is
+ * a collision, just mark the resource as unallocated. Also
+ * disable expansion ROMs during this step.
+ * (3) Try to allocate resources for disabled devices. If the
+ * resources were assigned correctly, everything goes well,
+ * if they weren't, they won't disturb allocation of other
+ * resources.
+ * (4) Assign new addresses to resources which were either
+ * not configured at all or misconfigured. If explicitly
+ * requested by the user, configure expansion ROM address
+ * as well.
+ */
+
+static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
+{
+ struct list_head *ln;
+ struct pci_bus *bus;
+ struct pci_dev *dev;
+ int idx;
+ struct resource *r, *pr;
+
+ /* Depth-First Search on bus tree */
+ for (ln=bus_list->next; ln != bus_list; ln=ln->next) {
+ bus = pci_bus_b(ln);
+ if ((dev = bus->self)) {
+ printk("alloc bus res: %s\n", dev->slot_name);
+ for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
+ r = &dev->resource[idx];
+ if (!r->start)
+ {
+ printk(" res1: 0x%08lx-0x%08lx f=%lx\n",
+ r->start, r->end, r->flags);
+
+ continue;
+ }
+ pr = pci_find_parent_resource(dev, r);
+ if (!pr || request_resource(pr, r) < 0)
+ printk(KERN_ERR "PCI: Cannot allocate resource region %d "
+ "of bridge %s (%p)\n", idx, dev->slot_name, pr);
+ printk(" res2: %08lx-%08lx f=%lx\n",
+ r->start, r->end, r->flags);
+ }
+ }
+ pcibios_allocate_bus_resources(&bus->children);
+ }
+}
+
+static void __init pcibios_allocate_resources(int pass)
+{
+ struct pci_dev *dev;
+ int idx, disabled;
+ u16 command;
+ struct resource *r, *pr;
+
+ pci_for_each_dev(dev) {
+ pci_read_config_word(dev, PCI_COMMAND, &command);
+ for(idx = 0; idx < 6; idx++) {
+ r = &dev->resource[idx];
+ if (r->parent) /* Already allocated */
+ continue;
+ if (!r->start) /* Address not assigned at all */
+ continue;
+ if (r->flags & IORESOURCE_IO)
+ disabled = !(command & PCI_COMMAND_IO);
+ else
+ disabled = !(command & PCI_COMMAND_MEMORY);
+ if (pass == disabled) {
+ printk("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d) (%s)\n",
+ r->start, r->end, r->flags, disabled, pass, dev->slot_name);
+ pr = pci_find_parent_resource(dev, r);
+ if (!pr || request_resource(pr, r) < 0) {
+ printk(KERN_ERR "PCI: Cannot allocate resource region %d"
+ " of device %s (%p)\n", idx, dev->slot_name, pr);
+ /* We'll assign a new address later */
+ r->end -= r->start;
+ r->start = 0;
+ }
+ }
+ }
+ if (!pass) {
+ r = &dev->resource[PCI_ROM_RESOURCE];
+ if (r->flags & PCI_ROM_ADDRESS_ENABLE) {
+ /* Turn the ROM off, leave the resource region, but keep it unregistered. */
+ u32 reg;
+ printk("PCI: Switching off ROM of %s\n", dev->slot_name);
+ r->flags &= ~PCI_ROM_ADDRESS_ENABLE;
+ pci_read_config_dword(dev, dev->rom_base_reg, &reg);
+ pci_write_config_dword(dev, dev->rom_base_reg, reg & ~PCI_ROM_ADDRESS_ENABLE);
+ }
+ }
+ }
+}
+
+static void __init pcibios_assign_resources(void)
+{
+ struct pci_dev *dev;
+ int idx;
+ struct resource *r;
+
+ pci_for_each_dev(dev) {
+ int class = dev->class >> 8;
+
+ /* Don't touch classless devices and host bridges */
+ if (!class || class == PCI_CLASS_BRIDGE_HOST)
+ continue;
+
+ for(idx=0; idx<6; idx++) {
+ r = &dev->resource[idx];
+
+ /*
+ * Don't touch IDE controllers and I/O ports of video cards!
+ */
+ if ((class == PCI_CLASS_STORAGE_IDE && idx < 4) ||
+ (class == PCI_CLASS_DISPLAY_VGA && (r->flags & IORESOURCE_IO)))
+ continue;
+
+ /*
+ * We shall assign a new address to this resource, either because
+ * the BIOS forgot to do so or because we have decided the old
+ * address was unusable for some reason.
+ */
+ if (!r->start && r->end)
+ pci_assign_resource(dev, idx);
+ }
+
+ if (pci_probe & PCI_ASSIGN_ROMS) {
+ r = &dev->resource[PCI_ROM_RESOURCE];
+ r->end -= r->start;
+ r->start = 0;
+ if (r->end)
+ pci_assign_resource(dev, PCI_ROM_RESOURCE);
+ }
+ }
+}
+
+void __init pcibios_set_cacheline_size(void)
+{
+ struct cpuinfo_x86 *c = &boot_cpu_data;
+
+ pci_cache_line_size = 32 >> 2;
+ if (c->x86 >= 6 && c->x86_vendor == X86_VENDOR_AMD)
+ pci_cache_line_size = 64 >> 2; /* K7 & K8 */
+ else if (c->x86 > 6 && c->x86_vendor == X86_VENDOR_INTEL)
+ pci_cache_line_size = 128 >> 2; /* P4 */
+}
+
+void __init pcibios_resource_survey(void)
+{
+ DBG("PCI: Allocating resources\n");
+ pcibios_allocate_bus_resources(&pci_root_buses);
+ pcibios_allocate_resources(0);
+ pcibios_allocate_resources(1);
+ pcibios_assign_resources();
+}
+
+int pcibios_enable_resources(struct pci_dev *dev, int mask)
+{
+ u16 cmd, old_cmd;
+ int idx;
+ struct resource *r;
+
+ pci_read_config_word(dev, PCI_COMMAND, &cmd);
+ old_cmd = cmd;
+ for(idx=0; idx<6; idx++) {
+ /* Only set up the requested stuff */
+ if (!(mask & (1<<idx)))
+ continue;
+
+ r = &dev->resource[idx];
+ if (!r->start && r->end) {
+ printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", dev->slot_name);
+ return -EINVAL;
+ }
+ if (r->flags & IORESOURCE_IO)
+ cmd |= PCI_COMMAND_IO;
+ if (r->flags & IORESOURCE_MEM)
+ cmd |= PCI_COMMAND_MEMORY;
+ }
+ if (dev->resource[PCI_ROM_RESOURCE].start)
+ cmd |= PCI_COMMAND_MEMORY;
+ if (cmd != old_cmd) {
+ printk("PCI: Enabling device %s (%04x -> %04x)\n", dev->slot_name, old_cmd, cmd);
+ pci_write_config_word(dev, PCI_COMMAND, cmd);
+ }
+ return 0;
+}
+
+/*
+ * If we set up a device for bus mastering, we need to check the latency
+ * timer as certain crappy BIOSes forget to set it properly.
+ */
+unsigned int pcibios_max_latency = 255;
+
+void pcibios_set_master(struct pci_dev *dev)
+{
+ u8 lat;
+ pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
+ if (lat < 16)
+ lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
+ else if (lat > pcibios_max_latency)
+ lat = pcibios_max_latency;
+ else
+ return;
+ printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n", dev->slot_name, lat);
+ pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
+}
+
+int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
+ enum pci_mmap_state mmap_state, int write_combine)
+{
+ unsigned long prot;
+
+ /* I/O space cannot be accessed via normal processor loads and
+ * stores on this platform.
+ */
+ if (mmap_state == pci_mmap_io)
+ return -EINVAL;
+
+ /* Leave vm_pgoff as-is, the PCI space address is the physical
+ * address on this platform.
+ */
+ vma->vm_flags |= (VM_SHM | VM_LOCKED | VM_IO);
+
+ prot = pgprot_val(vma->vm_page_prot);
+ if (boot_cpu_data.x86 > 3)
+ prot |= _PAGE_PCD | _PAGE_PWT;
+ vma->vm_page_prot = __pgprot(prot);
+
+ /* Write-combine setting is ignored, it is changed via the mtrr
+ * interfaces on this platform.
+ */
+ if (remap_page_range(vma->vm_start, vma->vm_pgoff << PAGE_SHIFT,
+ vma->vm_end - vma->vm_start,
+ vma->vm_page_prot))
+ return -EAGAIN;
+
+ return 0;
+}
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-i386.h b/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-i386.h
new file mode 100644
index 0000000000..fe70b10166
--- /dev/null
+++ b/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-i386.h
@@ -0,0 +1,71 @@
+/*
+ * Low-Level PCI Access for i386 machines.
+ *
+ * (c) 1999 Martin Mares <mj@ucw.cz>
+ */
+
+#undef DEBUG
+
+#ifdef DEBUG
+#define DBG(x...) printk(x)
+#else
+#define DBG(x...)
+#endif
+
+#define PCI_PROBE_BIOS 0x0001
+#define PCI_PROBE_CONF1 0x0002
+#define PCI_PROBE_CONF2 0x0004
+#define PCI_NO_SORT 0x0100
+#define PCI_BIOS_SORT 0x0200
+#define PCI_NO_CHECKS 0x0400
+#define PCI_ASSIGN_ROMS 0x1000
+#define PCI_BIOS_IRQ_SCAN 0x2000
+#define PCI_ASSIGN_ALL_BUSSES 0x4000
+
+extern unsigned int pci_probe;
+
+/* pci-i386.c */
+
+extern unsigned int pcibios_max_latency;
+extern u8 pci_cache_line_size;
+
+void pcibios_resource_survey(void);
+void pcibios_set_cacheline_size(void);
+int pcibios_enable_resources(struct pci_dev *, int);
+
+/* pci-pc.c */
+
+extern int pcibios_last_bus;
+extern struct pci_bus *pci_root_bus;
+extern struct pci_ops *pci_root_ops;
+
+/* pci-irq.c */
+
+struct irq_info {
+ u8 bus, devfn; /* Bus, device and function */
+ struct {
+ u8 link; /* IRQ line ID, chipset dependent, 0=not routed */
+ u16 bitmap; /* Available IRQs */
+ } __attribute__((packed)) irq[4];
+ u8 slot; /* Slot number, 0=onboard */
+ u8 rfu;
+} __attribute__((packed));
+
+struct irq_routing_table {
+ u32 signature; /* PIRQ_SIGNATURE should be here */
+ u16 version; /* PIRQ_VERSION */
+ u16 size; /* Table size in bytes */
+ u8 rtr_bus, rtr_devfn; /* Where the interrupt router lies */
+ u16 exclusive_irqs; /* IRQs devoted exclusively to PCI usage */
+ u16 rtr_vendor, rtr_device; /* Vendor and device ID of interrupt router */
+ u32 miniport_data; /* Crap */
+ u8 rfu[11];
+ u8 checksum; /* Modulo 256 checksum must give zero */
+ struct irq_info slots[0];
+} __attribute__((packed));
+
+extern unsigned int pcibios_irq_mask;
+
+void pcibios_irq_init(void);
+void pcibios_fixup_irqs(void);
+void pcibios_enable_irq(struct pci_dev *dev);
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-irq.c b/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-irq.c
new file mode 100644
index 0000000000..f530244f6a
--- /dev/null
+++ b/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-irq.c
@@ -0,0 +1,90 @@
+/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
+ ****************************************************************************
+ * (C) 2004 - Rolf Neugebauer - Intel Research Cambridge
+ ****************************************************************************
+ *
+ * File: phys_dev.c
+ * Author: Rolf Neugebauer (rolf.neugebauer@intel.com)
+ * Date: Mar 2004
+ *
+ * Description: XenoLinux wrappers for PCI interrupt handling.
+ * very simple since someone else is doing all the hard bits
+ */
+
+
+/*
+ * Low-Level PCI Support for PC -- Routing of Interrupts
+ *
+ * (c) 1999--2000 Martin Mares <mj@ucw.cz>
+ */
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+
+#include "pci-i386.h"
+
+#include <asm/hypervisor-ifs/physdev.h>
+
+unsigned int pcibios_irq_mask = 0xfff8;
+
+void eisa_set_level_irq(unsigned int irq)
+{
+ /* dummy */
+}
+
+void __init pcibios_irq_init(void)
+{
+ printk("PCI: IRQ init\n");
+}
+
+void __init pcibios_fixup_irqs(void)
+{
+ struct pci_dev *dev;
+ physdev_op_t op;
+ int ret;
+
+
+ printk("PCI: IRQ fixup\n");
+ pci_for_each_dev(dev) {
+
+ op.cmd = PHYSDEVOP_FIND_IRQ;
+ op.u.find_irq.seg = 0;
+ op.u.find_irq.bus = dev->bus->number;
+ op.u.find_irq.dev = PCI_SLOT(dev->devfn);
+ op.u.find_irq.func = PCI_FUNC(dev->devfn);
+
+ if ( (ret = HYPERVISOR_physdev_op(&op)) != 0 )
+ {
+ printk(KERN_ALERT "pci find irq error\n");
+ return;
+ }
+
+ dev->irq = op.u.find_irq.irq;
+ printk(KERN_INFO "PCI IRQ: [%02x:%02x:%02x] -> %d\n",
+ dev->bus->number, PCI_SLOT(dev->devfn),
+ PCI_FUNC(dev->devfn), dev->irq);
+ }
+ return;
+}
+
+void pcibios_penalize_isa_irq(int irq)
+{
+ /* dummy */
+}
+
+void pcibios_enable_irq(struct pci_dev *dev)
+{
+ u8 pin;
+
+ pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
+
+ if (pin && !dev->irq) {
+ printk(KERN_WARNING "PCI: No IRQ known for interrupt pin %c of "
+ "device %s.\n", 'A' + pin - 1, dev->slot_name);
+ }
+}
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-pc.c b/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-pc.c
new file mode 100644
index 0000000000..afe6e4d494
--- /dev/null
+++ b/xenolinux-2.4.25-sparse/arch/xeno/kernel/pci-pc.c
@@ -0,0 +1,364 @@
+/*
+ * Low-Level PCI Support for PC
+ *
+ * (c) 1999--2000 Martin Mares <mj@ucw.cz>
+ *
+ * adjusted to use Xen's interface by Rolf Neugebauer
+ */
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+
+#include <asm/segment.h>
+#include <asm/io.h>
+
+#include <asm/hypervisor-ifs/hypervisor-if.h>
+#include <asm/hypervisor-ifs/physdev.h>
+
+#include "pci-i386.h"
+
+int pcibios_last_bus = -1;
+struct pci_bus *pci_root_bus = NULL;
+struct pci_ops *pci_root_ops = NULL;
+
+int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value) = NULL;
+int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value) = NULL;
+
+static int pci_using_acpi_prt = 0;
+
+/*
+ * This interrupt-safe spinlock protects all accesses to PCI
+ * configuration space.
+ */
+static spinlock_t pci_config_lock = SPIN_LOCK_UNLOCKED;
+
+unsigned int pci_probe = PCI_PROBE_BIOS;
+
+/*
+ * Functions for accessing PCI configuration space with type 1 accesses
+ */
+
+static int pci_confx_read (int seg, int bus, int dev, int fn, int reg,
+ int len, u32 *value)
+{
+ int ret;
+ physdev_op_t op;
+
+ if (bus > 255 || dev > 31 || fn > 7 || reg > 255)
+ return -EINVAL;
+
+ op.cmd = PHYSDEVOP_CFGREG_READ;
+ op.u.cfg_read.seg = seg;
+ op.u.cfg_read.bus = bus;
+ op.u.cfg_read.dev = dev;
+ op.u.cfg_read.func = fn;
+ op.u.cfg_read.reg = reg;
+ op.u.cfg_read.len = len;
+
+ if ( (ret = HYPERVISOR_physdev_op(&op)) != 0 )
+ {
+ //printk(KERN_ALERT "pci config read error\n");
+ return ret;
+ }
+
+ *value = op.u.cfg_read.value;
+
+ return 0;
+}
+
+static int pci_confx_write (int seg, int bus, int dev, int fn, int reg,
+ int len, u32 value)
+{
+ int ret;
+ physdev_op_t op;
+
+ if ((bus > 255 || dev > 31 || fn > 7 || reg > 255))
+ return -EINVAL;
+
+ op.cmd = PHYSDEVOP_CFGREG_WRITE;
+ op.u.cfg_write.seg = seg;
+ op.u.cfg_write.bus = bus;
+ op.u.cfg_write.dev = dev;
+ op.u.cfg_write.func = fn;
+ op.u.cfg_write.reg = reg;
+ op.u.cfg_write.len = len;
+ op.u.cfg_write.value = value;
+
+ if ( (ret = HYPERVISOR_physdev_op(&op)) != 0 )
+ {
+ //printk(KERN_ALERT "pci config write error\n");
+ return ret;
+ }
+ return 0;
+}
+
+
+static int pci_confx_read_config_byte(struct pci_dev *dev, int where, u8 *value)
+{
+ int result;
+ u32 data;
+
+ result = pci_confx_read(0, dev->bus->number, PCI_SLOT(dev->devfn),
+ PCI_FUNC(dev->devfn), where, 1, &data);
+
+ *value = (u8)data;
+
+ return result;
+}
+
+static int pci_confx_read_config_word(struct pci_dev *dev, int where, u16 *value)
+{
+ int result;
+ u32 data;
+
+ result = pci_confx_read(0, dev->bus->number, PCI_SLOT(dev->devfn),
+ PCI_FUNC(dev->devfn), where, 2, &data);
+
+ *value = (u16)data;
+
+ return result;
+}
+
+static int pci_confx_read_config_dword(struct pci_dev *dev, int where, u32 *value)
+{
+ return pci_confx_read(0, dev->bus->number, PCI_SLOT(dev->devfn),
+ PCI_FUNC(dev->devfn), where, 4, value);
+}
+
+static int pci_confx_write_config_byte(struct pci_dev *dev, int where, u8 value)
+{
+ return pci_confx_write(0, dev->bus->number, PCI_SLOT(dev->devfn),
+ PCI_FUNC(dev->devfn), where, 1, value);
+}
+
+static int pci_confx_write_config_word(struct pci_dev *dev, int where, u16 value)
+{
+ return pci_confx_write(0, dev->bus->number, PCI_SLOT(dev->devfn),
+ PCI_FUNC(dev->devfn), where, 2, value);
+}
+
+static int pci_confx_write_config_dword(struct pci_dev *dev, int where, u32 value)
+{
+ return pci_confx_write(0, dev->bus->number, PCI_SLOT(dev->devfn),
+ PCI_FUNC(dev->devfn), where, 4, value);
+}
+
+static struct pci_ops pci_direct_confx = {
+ pci_confx_read_config_byte,
+ pci_confx_read_config_word,
+ pci_confx_read_config_dword,
+ pci_confx_write_config_byte,
+ pci_confx_write_config_word,
+ pci_confx_write_config_dword
+};
+
+
+
+static struct pci_ops * __devinit pci_check_xen(void)
+{
+ unsigned long flags;
+
+ __save_flags(flags); __cli();
+
+ printk(KERN_INFO "PCI: Using Xen interface\n");
+
+ __restore_flags(flags);
+
+ return &pci_direct_confx;
+}
+
+struct pci_fixup pcibios_fixups[] = { {0}};
+
+
+struct irq_routing_table * __devinit pcibios_get_irq_routing_table(void)
+{
+ return NULL;
+}
+
+int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
+{
+ return 0;
+}
+
+/*
+ * Several buggy motherboards address only 16 devices and mirror
+ * them to next 16 IDs. We try to detect this `feature' on all
+ * primary buses (those containing host bridges as they are
+ * expected to be unique) and remove the ghost devices.
+ */
+
+static void __devinit pcibios_fixup_ghosts(struct pci_bus *b)
+{
+ struct list_head *ln, *mn;
+ struct pci_dev *d, *e;
+ int mirror = PCI_DEVFN(16,0);
+ int seen_host_bridge = 0;
+ int i;
+
+ DBG("PCI: Scanning for ghost devices on bus %d\n", b->number);
+ for (ln=b->devices.next; ln != &b->devices; ln=ln->next) {
+ d = pci_dev_b(ln);
+ if ((d->class >> 8) == PCI_CLASS_BRIDGE_HOST)
+ seen_host_bridge++;
+ for (mn=ln->next; mn != &b->devices; mn=mn->next) {
+ e = pci_dev_b(mn);
+ if (e->devfn != d->devfn + mirror ||
+ e->vendor != d->vendor ||
+ e->device != d->device ||
+ e->class != d->class)
+ continue;
+ for(i=0; i<PCI_NUM_RESOURCES; i++)
+ if (e->resource[i].start != d->resource[i].start ||
+ e->resource[i].end != d->resource[i].end ||
+ e->resource[i].flags != d->resource[i].flags)
+ continue;
+ break;
+ }
+ if (mn == &b->devices)
+ return;
+ }
+ if (!seen_host_bridge)
+ return;
+ printk(KERN_WARNING "PCI: Ignoring ghost devices on bus %02x\n", b->number);
+
+ ln = &b->devices;
+ while (ln->next != &b->devices) {
+ d = pci_dev_b(ln->next);
+ if (d->devfn >= mirror) {
+ list_del(&d->global_list);
+ list_del(&d->bus_list);
+ kfree(d);
+ } else
+ ln = ln->next;
+ }
+}
+
+/*
+ * Discover remaining PCI buses in case there are peer host bridges.
+ * We use the number of last PCI bus provided by the PCI BIOS.
+ */
+static void __devinit pcibios_fixup_peer_bridges(void)
+{
+ int n;
+ struct pci_bus bus;
+ struct pci_dev dev;
+ u16 l;
+
+ if (pcibios_last_bus <= 0 || pcibios_last_bus >= 0xff)
+ return;
+ DBG("PCI: Peer bridge fixup\n");
+ for (n=0; n <= pcibios_last_bus; n++) {
+ if (pci_bus_exists(&pci_root_buses, n))
+ continue;
+ bus.number = n;
+ bus.ops = pci_root_ops;
+ dev.bus = &bus;
+ for(dev.devfn=0; dev.devfn<256; dev.devfn += 8)
+ if (!pci_read_config_word(&dev, PCI_VENDOR_ID, &l) &&
+ l != 0x0000 && l != 0xffff) {
+ DBG("Found device at %02x:%02x [%04x]\n", n, dev.devfn, l);
+ printk(KERN_INFO "PCI: Discovered peer bus %02x\n", n);
+ pci_scan_bus(n, pci_root_ops, NULL);
+ break;
+ }
+ }
+}
+
+
+/*
+ * Called after each bus is probed, but before its children
+ * are examined.
+ */
+
+void __devinit pcibios_fixup_bus(struct pci_bus *b)
+{
+ pcibios_fixup_ghosts(b);
+ pci_read_bridge_bases(b);
+ return;
+}
+
+struct pci_bus * __devinit pcibios_scan_root(int busnum)
+{
+ struct list_head *list;
+ struct pci_bus *bus;
+
+ list_for_each(list, &pci_root_buses) {
+ bus = pci_bus_b(list);
+ if (bus->number == busnum) {
+ /* Already scanned */
+ return bus;
+ }
+ }
+
+ printk("PCI: Probing PCI hardware (bus %02x)\n", busnum);
+
+ return pci_scan_bus(busnum, pci_root_ops, NULL);
+}
+
+void __devinit pcibios_config_init(void)
+{
+ /*
+ * Try all known PCI access methods. Note that we support using
+ * both PCI BIOS and direct access, with a preference for direct.
+ */
+
+ pci_root_ops = pci_check_xen();
+ pci_config_read = pci_confx_read;
+ pci_config_write = pci_confx_write;
+
+ return;
+}
+
+void __init pcibios_init(void)
+{
+ if (!pci_root_ops)
+ pcibios_config_init();
+ if (!pci_root_ops) {
+ printk(KERN_WARNING "PCI: System does not support PCI\n");
+ return;
+ }
+
+ pcibios_set_cacheline_size();
+
+ printk(KERN_INFO "PCI: Probing PCI hardware\n");
+
+ if (!pci_using_acpi_prt) {
+ pci_root_bus = pcibios_scan_root(0);
+ pcibios_irq_init();
+ pcibios_fixup_peer_bridges();
+ pcibios_fixup_irqs();
+ }
+
+ pcibios_resource_survey();
+}
+
+char * __devinit pcibios_setup(char *str)
+{
+ if (!strcmp(str, "off")) {
+ pci_probe = 0;
+ return NULL;
+ }
+ return NULL;
+}
+
+unsigned int pcibios_assign_all_busses(void)
+{
+ return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0;
+}
+
+int pcibios_enable_device(struct pci_dev *dev, int mask)
+{
+ int err;
+
+ if ((err = pcibios_enable_resources(dev, mask)) < 0)
+ return err;
+
+ pcibios_enable_irq(dev);
+
+ return 0;
+}
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/kernel/physirq.c b/xenolinux-2.4.25-sparse/arch/xeno/kernel/physirq.c
new file mode 100644
index 0000000000..3a6083b24e
--- /dev/null
+++ b/xenolinux-2.4.25-sparse/arch/xeno/kernel/physirq.c
@@ -0,0 +1,156 @@
+/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
+ ****************************************************************************
+ * (C) 2004 - Rolf Neugebauer - Intel Research Cambridge
+ ****************************************************************************
+ *
+ * File: physirq.c
+ * Author: Rolf Neugebauer (rolf.neugebauer@intel.com)
+ * Date: Mar 2004
+ *
+ * Description: guests may receive virtual interrupts directly
+ * corresponding to physical interrupts. these virtual
+ * interrupts require special handling provided
+ * by the virq irq type.
+ */
+
+
+#include <linux/config.h>
+#include <asm/atomic.h>
+#include <asm/irq.h>
+#include <asm/hypervisor.h>
+#include <asm/system.h>
+
+#include <linux/irq.h>
+#include <linux/sched.h>
+
+#include <asm/hypervisor-ifs/hypervisor-if.h>
+#include <asm/hypervisor-ifs/physdev.h>
+
+static void physirq_interrupt(int irq, void *unused, struct pt_regs *ptregs);
+
+static int setup_event_handler = 0;
+
+static unsigned int startup_physirq_event(unsigned int irq)
+{
+ physdev_op_t op;
+ int err;
+
+ printk("startup_physirq_event %d\n", irq);
+
+ /*
+ * install a interrupt handler for physirq event when called thefirst tim
+ */
+ if ( !setup_event_handler )
+ {
+ printk("startup_physirq_event %d: setup event handler\n", irq);
+ /* set up a event handler to demux virtualised physical interrupts */
+ err = request_irq(HYPEREVENT_IRQ(_EVENT_PHYSIRQ), physirq_interrupt,
+ SA_SAMPLE_RANDOM, "physirq", NULL);
+ if ( err )
+ {
+ printk(KERN_WARNING "Could not allocate physirq interrupt\n");
+ return err;
+ }
+ setup_event_handler = 1;
+ }
+
+ /*
+ * request the irq from hypervisor
+ */
+ op.cmd = PHYSDEVOP_REQUEST_IRQ;
+ op.u.request_irq.irq = irq;
+ if ( (err = HYPERVISOR_physdev_op(&op)) != 0 )
+ {
+ printk(KERN_ALERT "could not get IRQ %d from Xen\n", irq);
+ return err;
+ }
+ return 0;
+}
+
+static void shutdown_physirq_event(unsigned int irq)
+{
+
+ /* call xen to free IRQ */
+
+}
+
+
+static void enable_physirq_event(unsigned int irq)
+{
+ /* XXX just enable all interrupts for now */
+}
+
+static void disable_physirq_event(unsigned int irq)
+{
+ /* XXX just disable all interrupts for now */
+}
+
+static void ack_physirq_event(unsigned int irq)
+{
+ /* clear bit */
+ if ( irq <= 0 || irq >= 32 )
+ {
+ printk("wrong irq %d\n", irq);
+ }
+
+ clear_bit(irq, &HYPERVISOR_shared_info->physirq_pend);
+}
+
+static void end_physirq_event(unsigned int irq)
+{
+ int err;
+ physdev_op_t op;
+ /* call hypervisor */
+ op.cmd = PHYSDEVOP_FINISHED_IRQ;
+ op.u.finished_irq.irq = irq;
+ if ( (err = HYPERVISOR_physdev_op(&op)) != 0 )
+ {
+ printk(KERN_ALERT "could not finish IRQ %d\n", irq);
+ return;
+ }
+ return;
+}
+
+static struct hw_interrupt_type physirq_irq_type = {
+ "physical-irq",
+ startup_physirq_event,
+ shutdown_physirq_event,
+ enable_physirq_event,
+ disable_physirq_event,
+ ack_physirq_event,
+ end_physirq_event,
+ NULL
+};
+
+
+/*
+ * this interrupt handler demuxes the virt phys event and the virt phys
+ * bitmask and calls the interrupt handlers for virtualised physical interrupts
+ */
+static void physirq_interrupt(int irq, void *unused, struct pt_regs *ptregs)
+{
+#if 0
+ unsigned long flags;
+ int virq;
+ local_irq_save(flags);
+ do_IRQ(virq);
+ local_irq_restore(flags);
+#endif
+}
+
+
+void __init physirq_init(void)
+{
+ int i;
+
+ printk("Initialise irq handlers [%d-%d] for physical interrupts.\n",
+ PHYS_IRQ_BASE, PHYS_IRQ_BASE+NR_PHYS_IRQS-1);
+
+ for ( i = 0; i < NR_PHYS_IRQS; i++ )
+ {
+ irq_desc[i + PHYS_IRQ_BASE].status = IRQ_DISABLED;
+ irq_desc[i + PHYS_IRQ_BASE].action = 0;
+ irq_desc[i + PHYS_IRQ_BASE].depth = 1;
+ irq_desc[i + PHYS_IRQ_BASE].handler = &physirq_irq_type;
+ }
+}
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/kernel/setup.c b/xenolinux-2.4.25-sparse/arch/xeno/kernel/setup.c
index 762a9946ae..c593bddec7 100644
--- a/xenolinux-2.4.25-sparse/arch/xeno/kernel/setup.c
+++ b/xenolinux-2.4.25-sparse/arch/xeno/kernel/setup.c
@@ -1124,7 +1124,7 @@ static void die_irq(int irq, void *unused, struct pt_regs *regs)
static int __init setup_die_event(void)
{
- (void)request_irq(_EVENT_DIE, die_irq, 0, "die", NULL);
+ (void)request_irq(HYPEREVENT_IRQ(_EVENT_DIE), die_irq, 0, "die", NULL);
return 0;
}
@@ -1249,7 +1249,7 @@ static void stop_irq(int irq, void *unused, struct pt_regs *regs)
static int __init setup_stop_event(void)
{
- (void)request_irq(_EVENT_STOP, stop_irq, 0, "stop", NULL);
+ (void)request_irq(HYPEREVENT_IRQ(_EVENT_STOP), stop_irq, 0, "stop", NULL);
return 0;
}
diff --git a/xenolinux-2.4.25-sparse/arch/xeno/kernel/time.c b/xenolinux-2.4.25-sparse/arch/xeno/kernel/time.c
index 0d41748c82..574ba786b4 100644
--- a/xenolinux-2.4.25-sparse/arch/xeno/kernel/time.c
+++ b/xenolinux-2.4.25-sparse/arch/xeno/kernel/time.c
@@ -623,9 +623,9 @@ void __init time_init(void)
__get_time_values_from_xen();
processed_system_time = shadow_system_time;
- (void)setup_irq(TIMER_IRQ, &irq_timer);
+ (void)setup_irq(HYPEREVENT_IRQ(_EVENT_TIMER), &irq_timer);
- (void)setup_irq(_EVENT_DEBUG, &dbg_time);
+ (void)setup_irq(HYPEREVENT_IRQ(_EVENT_DEBUG), &dbg_time);
rdtscll(alarm);