ia64/xen-unstable

changeset 1237:8b5451a42056

bitkeeper revision 1.829 (4064473cafXxoOK98baBKebIaWblgA)

Merge tetris.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into tetris.cl.cam.ac.uk:/auto/groups/xeno/users/iap10/xeno-clone/xeno.bk
author iap10@tetris.cl.cam.ac.uk
date Fri Mar 26 15:07:40 2004 +0000 (2004-03-26)
parents bf4b11f253d4 b651279526f3
children b9ab14271453
files .rootkeys tools/xentrace/Makefile xen/common/event_channel.c xen/common/physdev.c xen/include/hypervisor-ifs/dom0_ops.h xen/include/hypervisor-ifs/event_channel.h xen/include/hypervisor-ifs/physdev.h xenolinux-2.4.25-sparse/arch/xen/kernel/Makefile xenolinux-2.4.25-sparse/arch/xen/kernel/evtchn.c xenolinux-2.4.25-sparse/arch/xen/kernel/physirq.c xenolinux-2.4.25-sparse/include/asm-xen/irq.h
line diff
     1.1 --- a/.rootkeys	Fri Mar 26 11:03:15 2004 +0000
     1.2 +++ b/.rootkeys	Fri Mar 26 15:07:40 2004 +0000
     1.3 @@ -641,7 +641,6 @@ 4051db89iiHs38tWGkoW_RukNyaBHw xenolinux
     1.4  4051db8dJYX86ZCLA-WfTW2dAyrehw xenolinux-2.4.25-sparse/arch/xen/kernel/pci-i386.h
     1.5  4051db91BenvDZEMZxQCGkQyJYoG5w xenolinux-2.4.25-sparse/arch/xen/kernel/pci-irq.c
     1.6  4051db95N9N99FjsRwi49YKUNHWI8A xenolinux-2.4.25-sparse/arch/xen/kernel/pci-pc.c
     1.7 -4051db99fbdTHgCpjywPCp7vjLCe7Q xenolinux-2.4.25-sparse/arch/xen/kernel/physirq.c
     1.8  3e5a4e65IGt3WwQDNiL4h-gYWgNTWQ xenolinux-2.4.25-sparse/arch/xen/kernel/process.c
     1.9  3e5a4e66tR-qJMLj3MppcKqmvuI2XQ xenolinux-2.4.25-sparse/arch/xen/kernel/setup.c
    1.10  3e5a4e66fWSTagLGU2P8BGFGRjhDiw xenolinux-2.4.25-sparse/arch/xen/kernel/signal.c
     2.1 --- a/tools/xentrace/Makefile	Fri Mar 26 11:03:15 2004 +0000
     2.2 +++ b/tools/xentrace/Makefile	Fri Mar 26 15:07:40 2004 +0000
     2.3 @@ -7,7 +7,8 @@ CFLAGS  += -I../../xenolinux-sparse/incl
     2.4  HDRS     = $(wildcard *.h)
     2.5  OBJS     = $(patsubst %.c,%.o,$(wildcard *.c))
     2.6  
     2.7 -BIN      = xentrace xentrace_cpusplit xentrace_format
     2.8 +BIN      = xentrace
     2.9 +SCRIPTS  = xentrace_cpusplit xentrace_format
    2.10  MAN1     = $(wildcard *.1)
    2.11  MAN8     = $(wildcard *.8)
    2.12  
    2.13 @@ -17,7 +18,7 @@ install: all
    2.14  	mkdir -p $(prefix)/usr/bin
    2.15  	mkdir -p $(prefix)/usr/man/man1
    2.16  	mkdir -p $(prefix)/usr/man/man8
    2.17 -	install -m0755 $(BIN) $(prefix)/usr/bin
    2.18 +	install -m0755 $(BIN) $(SCRIPTS) $(prefix)/usr/bin
    2.19  	install -m0644 $(MAN1) $(prefix)/usr/man/man1
    2.20  	install -m0644 $(MAN8) $(prefix)/usr/man/man8
    2.21  
     3.1 --- a/xen/common/event_channel.c	Fri Mar 26 11:03:15 2004 +0000
     3.2 +++ b/xen/common/event_channel.c	Fri Mar 26 15:07:40 2004 +0000
     3.3 @@ -146,7 +146,7 @@ static long evtchn_bind_virq(evtchn_bind
     3.4      int virq = bind->virq;
     3.5      int port;
     3.6  
     3.7 -    if ( virq >= NR_VIRQS )
     3.8 +    if ( virq >= ARRAY_SIZE(p->virq_to_evtchn) )
     3.9          return -EINVAL;
    3.10  
    3.11      spin_lock(&p->event_channel_lock);
    3.12 @@ -177,6 +177,37 @@ static long evtchn_bind_virq(evtchn_bind
    3.13  }
    3.14  
    3.15  
    3.16 +static long evtchn_bind_pirq(evtchn_bind_pirq_t *bind)
    3.17 +{
    3.18 +    struct task_struct *p = current;
    3.19 +    int pirq = bind->pirq;
    3.20 +    int port;
    3.21 +
    3.22 +    if ( pirq >= ARRAY_SIZE(p->pirq_to_evtchn) )
    3.23 +        return -EINVAL;
    3.24 +
    3.25 +    spin_lock(&p->event_channel_lock);
    3.26 +
    3.27 +    if ( ((port = p->pirq_to_evtchn[pirq]) != 0) ||
    3.28 +         ((port = get_free_port(p)) < 0) )
    3.29 +        goto out;
    3.30 +
    3.31 +    p->event_channel[port].state  = ECS_PIRQ;
    3.32 +    p->event_channel[port].u.pirq = pirq;
    3.33 +
    3.34 +    p->pirq_to_evtchn[pirq] = port;
    3.35 +
    3.36 + out:
    3.37 +    spin_unlock(&p->event_channel_lock);
    3.38 +
    3.39 +    if ( port < 0 )
    3.40 +        return port;
    3.41 +
    3.42 +    bind->port = port;
    3.43 +    return 0;
    3.44 +}
    3.45 +
    3.46 +
    3.47  static long __evtchn_close(struct task_struct *p1, int port1)
    3.48  {
    3.49      struct task_struct *p2 = NULL;
    3.50 @@ -396,13 +427,19 @@ long do_event_channel_op(evtchn_op_t *uo
    3.51      {
    3.52      case EVTCHNOP_bind_interdomain:
    3.53          rc = evtchn_bind_interdomain(&op.u.bind_interdomain);
    3.54 -        if ( copy_to_user(uop, &op, sizeof(op)) != 0 )
    3.55 +        if ( (rc == 0) && (copy_to_user(uop, &op, sizeof(op)) != 0) )
    3.56              rc = -EFAULT; /* Cleaning up here would be a mess! */
    3.57          break;
    3.58  
    3.59      case EVTCHNOP_bind_virq:
    3.60          rc = evtchn_bind_virq(&op.u.bind_virq);
    3.61 -        if ( copy_to_user(uop, &op, sizeof(op)) != 0 )
    3.62 +        if ( (rc == 0) && (copy_to_user(uop, &op, sizeof(op)) != 0) )
    3.63 +            rc = -EFAULT; /* Cleaning up here would be a mess! */
    3.64 +        break;
    3.65 +
    3.66 +    case EVTCHNOP_bind_pirq:
    3.67 +        rc = evtchn_bind_pirq(&op.u.bind_pirq);
    3.68 +        if ( (rc == 0) && (copy_to_user(uop, &op, sizeof(op)) != 0) )
    3.69              rc = -EFAULT; /* Cleaning up here would be a mess! */
    3.70          break;
    3.71  
    3.72 @@ -416,7 +453,7 @@ long do_event_channel_op(evtchn_op_t *uo
    3.73  
    3.74      case EVTCHNOP_status:
    3.75          rc = evtchn_status(&op.u.status);
    3.76 -        if ( copy_to_user(uop, &op, sizeof(op)) != 0 )
    3.77 +        if ( (rc == 0) && (copy_to_user(uop, &op, sizeof(op)) != 0) )
    3.78              rc = -EFAULT;
    3.79          break;
    3.80  
     4.1 --- a/xen/common/physdev.c	Fri Mar 26 11:03:15 2004 +0000
     4.2 +++ b/xen/common/physdev.c	Fri Mar 26 15:07:40 2004 +0000
     4.3 @@ -601,7 +601,7 @@ static void end_virt_irq (unsigned int i
     4.4   * - shared interrupts are not allowed for now
     4.5   * - we change the hw_irq handler to something else
     4.6   */
     4.7 -static long pci_request_irq(int irq)
     4.8 +static long pirq_request(int irq)
     4.9  {
    4.10      int err;
    4.11      phys_dev_t *pdev = NULL, *t;
    4.12 @@ -685,7 +685,7 @@ static long pci_request_irq(int irq)
    4.13      return 0;
    4.14  }
    4.15  
    4.16 -static long pci_free_irq(int irq)
    4.17 +long pirq_free(int irq)
    4.18  {
    4.19      phys_dev_t *pdev;
    4.20  
    4.21 @@ -719,55 +719,12 @@ static long pci_free_irq(int irq)
    4.22      return 0;
    4.23  }
    4.24  
    4.25 -static long pci_enable_irq(int irq)
    4.26 -{
    4.27 -    /* XXX not sure we need this */
    4.28 -    /* guest can enable phys_irq event for now */
    4.29 -    return 0;
    4.30 -}
    4.31 -
    4.32 -static long pci_disable_irq(int irq)
    4.33 -{
    4.34 -    /* XXX not sure we need this */
    4.35 -    /* guest can disable phys_irq event for now */
    4.36 -    return 0;
    4.37 -}
    4.38 -
    4.39 -static long pci_finished_irq(int irq)
    4.40 +static long pci_unmask_irq(void)
    4.41  {
    4.42 -    phys_dev_t *pdev;
    4.43 -    
    4.44 -    if ( !(pdev = irqs[irq]) )
    4.45 -    {
    4.46 -        printk("finished_irq called for unregistered irq %d\n", irq);
    4.47 -        return -EINVAL;
    4.48 -    }
    4.49 -   
    4.50 -    if ( pdev->owner != current )
    4.51 -    {
    4.52 -        printk("finished_irq called dom not owning irq %d\n", irq);
    4.53 -        return -EPERM;
    4.54 -    }
    4.55 -
    4.56 -    if ( !test_bit(ST_IRQ_DELIVERED, &pdev->state) )
    4.57 -    {
    4.58 -        printk("finished_irq called for undelivered irq %d\n", irq);
    4.59 -        return -EINVAL;
    4.60 -    }
    4.61 -
    4.62 -#if 0 /* XXX KAF: do we need this? */
    4.63 -    if ( test_bit(irq, &current->shared_info->physirq_pend) )
    4.64 -    {
    4.65 -        printk("finished_irq called for un-acknowleged irq %d\n", irq);        
    4.66 -        return -EINVAL;
    4.67 -    }
    4.68 +#if 0
    4.69 +    clear_bit(ST_IRQ_DELIVERED, &pdev->state);
    4.70 +    pdev->orig_handler->end(irq);
    4.71  #endif
    4.72 -
    4.73 -    clear_bit(ST_IRQ_DELIVERED, &pdev->state);
    4.74 -
    4.75 -    /* call original end handler */
    4.76 -    pdev->orig_handler->end(irq);
    4.77 -
    4.78      return 0;
    4.79  }
    4.80  
    4.81 @@ -786,43 +743,27 @@ long do_physdev_op(physdev_op_t *uop)
    4.82      switch ( op.cmd )
    4.83      {
    4.84      case PHYSDEVOP_CFGREG_READ:
    4.85 -        ret = pci_cfgreg_read (op.u.cfg_read.seg, op.u.cfg_read.bus,
    4.86 -                               op.u.cfg_read.dev, op.u.cfg_read.func,
    4.87 -                               op.u.cfg_read.reg, op.u.cfg_read.len,
    4.88 -                               &op.u.cfg_read.value);
    4.89 +        ret = pci_cfgreg_read(op.u.cfg_read.seg, op.u.cfg_read.bus,
    4.90 +                              op.u.cfg_read.dev, op.u.cfg_read.func,
    4.91 +                              op.u.cfg_read.reg, op.u.cfg_read.len,
    4.92 +                              &op.u.cfg_read.value);
    4.93          break;
    4.94  
    4.95      case PHYSDEVOP_CFGREG_WRITE:
    4.96 -        ret = pci_cfgreg_write (op.u.cfg_write.seg, op.u.cfg_write.bus,
    4.97 -                                op.u.cfg_write.dev, op.u.cfg_write.func,
    4.98 -                                op.u.cfg_write.reg, op.u.cfg_write.len,
    4.99 -                                op.u.cfg_write.value);
   4.100 +        ret = pci_cfgreg_write(op.u.cfg_write.seg, op.u.cfg_write.bus,
   4.101 +                               op.u.cfg_write.dev, op.u.cfg_write.func,
   4.102 +                               op.u.cfg_write.reg, op.u.cfg_write.len,
   4.103 +                               op.u.cfg_write.value);
   4.104          break;
   4.105  
   4.106      case PHYSDEVOP_FIND_IRQ:
   4.107 -        ret = pci_find_irq (op.u.find_irq.seg, op.u.find_irq.bus,
   4.108 -                            op.u.find_irq.dev, op.u.find_irq.func,
   4.109 -                            &op.u.find_irq.irq);
   4.110 -        break;
   4.111 -
   4.112 -    case PHYSDEVOP_REQUEST_IRQ:
   4.113 -        ret = pci_request_irq (op.u.request_irq.irq);
   4.114 +        ret = pci_find_irq(op.u.find_irq.seg, op.u.find_irq.bus,
   4.115 +                           op.u.find_irq.dev, op.u.find_irq.func,
   4.116 +                           &op.u.find_irq.irq);
   4.117          break;
   4.118  
   4.119 -    case PHYSDEVOP_FREE_IRQ:
   4.120 -        ret = pci_free_irq (op.u.free_irq.irq);
   4.121 -        break;
   4.122 -
   4.123 -    case PHYSDEVOP_ENABLE_IRQ:
   4.124 -        ret = pci_enable_irq (op.u.enable_irq.irq);
   4.125 -        break;
   4.126 -
   4.127 -    case PHYSDEVOP_DISABLE_IRQ:
   4.128 -        ret = pci_disable_irq (op.u.disable_irq.irq);
   4.129 -        break;
   4.130 -
   4.131 -    case PHYSDEVOP_FINISHED_IRQ:
   4.132 -        ret = pci_finished_irq (op.u.finished_irq.irq);
   4.133 +    case PHYSDEVOP_UNMASK_IRQ:
   4.134 +        ret = pci_unmask_irq();
   4.135          break;
   4.136  
   4.137      default:
     5.1 --- a/xen/include/hypervisor-ifs/dom0_ops.h	Fri Mar 26 11:03:15 2004 +0000
     5.2 +++ b/xen/include/hypervisor-ifs/dom0_ops.h	Fri Mar 26 15:07:40 2004 +0000
     5.3 @@ -18,7 +18,7 @@
     5.4   * This makes sure that old versions of dom0 tools will stop working in a
     5.5   * well-defined way (rather than crashing the machine, for instance).
     5.6   */
     5.7 -#define DOM0_INTERFACE_VERSION   0xAAAA0009
     5.8 +#define DOM0_INTERFACE_VERSION   0xAAAA000A
     5.9  
    5.10  #define MAX_CMD_LEN       256
    5.11  #define MAX_DOMAIN_NAME    16
     6.1 --- a/xen/include/hypervisor-ifs/event_channel.h	Fri Mar 26 11:03:15 2004 +0000
     6.2 +++ b/xen/include/hypervisor-ifs/event_channel.h	Fri Mar 26 15:07:40 2004 +0000
     6.3 @@ -30,7 +30,7 @@ typedef struct evtchn_bind_interdomain
     6.4   * NOTES:
     6.5   *  1. A virtual IRQ may be bound to at most one event channel per domain.
     6.6   */
     6.7 -#define EVTCHNOP_bind_virq    1
     6.8 +#define EVTCHNOP_bind_virq        1
     6.9  typedef struct evtchn_bind_virq
    6.10  {
    6.11      /* IN parameters. */
    6.12 @@ -40,6 +40,21 @@ typedef struct evtchn_bind_virq
    6.13  } evtchn_bind_virq_t;
    6.14  
    6.15  /*
    6.16 + * EVTCHNOP_bind_pirq: Bind a local event channel to IRQ <irq>.
    6.17 + * NOTES:
    6.18 + *  1. A physical IRQ may be bound to at most one event channel per domain.
    6.19 + *  2. Only a sufficiently-privileged domain may bind to a physical IRQ.
    6.20 + */
    6.21 +#define EVTCHNOP_bind_pirq        2
    6.22 +typedef struct evtchn_bind_pirq
    6.23 +{
    6.24 +    /* IN parameters. */
    6.25 +    int pirq;
    6.26 +    /* OUT parameters. */
    6.27 +    int port;
    6.28 +} evtchn_bind_pirq_t;
    6.29 +
    6.30 +/*
    6.31   * EVTCHNOP_close: Close the communication channel which has an endpoint at
    6.32   * <dom, port>.
    6.33   * NOTES:
    6.34 @@ -47,7 +62,7 @@ typedef struct evtchn_bind_virq
    6.35   *  2. Only a sufficiently-privileged domain may close an event channel
    6.36   *     for which <dom> is not DOMID_SELF.
    6.37   */
    6.38 -#define EVTCHNOP_close            2
    6.39 +#define EVTCHNOP_close            3
    6.40  typedef struct evtchn_close
    6.41  {
    6.42      /* IN parameters. */
    6.43 @@ -60,7 +75,7 @@ typedef struct evtchn_close
    6.44   * EVTCHNOP_send: Send an event to the remote end of the channel whose local
    6.45   * endpoint is <DOMID_SELF, local_port>.
    6.46   */
    6.47 -#define EVTCHNOP_send             3
    6.48 +#define EVTCHNOP_send             4
    6.49  typedef struct evtchn_send
    6.50  {
    6.51      /* IN parameters. */
    6.52 @@ -76,7 +91,7 @@ typedef struct evtchn_send
    6.53   *  2. Only a sufficiently-privileged domain may obtain the status of an event
    6.54   *     channel for which <dom> is not DOMID_SELF.
    6.55   */
    6.56 -#define EVTCHNOP_status           4
    6.57 +#define EVTCHNOP_status           5
    6.58  typedef struct evtchn_status
    6.59  {
    6.60      /* IN parameters */
    6.61 @@ -86,8 +101,8 @@ typedef struct evtchn_status
    6.62  #define EVTCHNSTAT_closed       0  /* Chennel is not in use.                 */
    6.63  #define EVTCHNSTAT_unbound      1  /* Channel is not bound to a source.      */
    6.64  #define EVTCHNSTAT_interdomain  2  /* Channel is connected to remote domain. */
    6.65 -#define EVTCHNSTAT_pirq     3      /* Channel is bound to a phys IRQ line.   */
    6.66 -#define EVTCHNSTAT_virq     4      /* Channel is bound to a virtual IRQ line */
    6.67 +#define EVTCHNSTAT_pirq         3  /* Channel is bound to a phys IRQ line.   */
    6.68 +#define EVTCHNSTAT_virq         4  /* Channel is bound to a virtual IRQ line */
    6.69      int     status;
    6.70      union {
    6.71          int __none;    /* EVTCHNSTAT_closed, EVTCHNSTAT_unbound */
    6.72 @@ -106,6 +121,7 @@ typedef struct evtchn_op
    6.73      union {
    6.74          evtchn_bind_interdomain_t bind_interdomain;
    6.75          evtchn_bind_virq_t        bind_virq;
    6.76 +        evtchn_bind_pirq_t        bind_pirq;
    6.77          evtchn_close_t            close;
    6.78          evtchn_send_t             send;
    6.79          evtchn_status_t           status;
     7.1 --- a/xen/include/hypervisor-ifs/physdev.h	Fri Mar 26 11:03:15 2004 +0000
     7.2 +++ b/xen/include/hypervisor-ifs/physdev.h	Fri Mar 26 15:07:40 2004 +0000
     7.3 @@ -19,11 +19,7 @@
     7.4  #define PHYSDEVOP_CFGREG_READ   0
     7.5  #define PHYSDEVOP_CFGREG_WRITE  1
     7.6  #define PHYSDEVOP_FIND_IRQ      2
     7.7 -#define PHYSDEVOP_REQUEST_IRQ   3
     7.8 -#define PHYSDEVOP_FREE_IRQ      4
     7.9 -#define PHYSDEVOP_ENABLE_IRQ    5
    7.10 -#define PHYSDEVOP_DISABLE_IRQ   6
    7.11 -#define PHYSDEVOP_FINISHED_IRQ  7
    7.12 +#define PHYSDEVOP_UNMASK_IRQ    3
    7.13  
    7.14  /* read pci config */
    7.15  typedef struct physdevop_cfgreg_read_st
    7.16 @@ -32,8 +28,8 @@ typedef struct physdevop_cfgreg_read_st
    7.17      int bus;        /* IN */
    7.18      int dev;        /* IN */
    7.19      int func;       /* IN */
    7.20 -    int reg;        /* IN  */
    7.21 -    int len;        /* IN  */
    7.22 +    int reg;        /* IN */
    7.23 +    int len;        /* IN */
    7.24      u32 value;      /* OUT */
    7.25  } physdevop_cfgreg_read_t;
    7.26  
    7.27 @@ -59,36 +55,6 @@ typedef struct physdevop_find_irq_st
    7.28      u32 irq;      /* OUT */
    7.29  } physdevop_find_irq_t;
    7.30  
    7.31 -/* request physical IRQ to be routed to guest */
    7.32 -typedef struct physdevop_request_irq_st
    7.33 -{
    7.34 -    u32 irq;      /* IN */
    7.35 -} physdevop_request_irq_t;
    7.36 -
    7.37 -/* stop routing physical interrupts to guest */
    7.38 -typedef struct physdevop_free_irq_st
    7.39 -{
    7.40 -    u32 irq;      /* IN */
    7.41 -} physdevop_free_irq_t;
    7.42 -
    7.43 -/* enable IRQ for the caller  */
    7.44 -typedef struct physdevop_enable_irq_st
    7.45 -{
    7.46 -    u32 irq;      /* IN */
    7.47 -} physdevop_enable_irq_t;
    7.48 -
    7.49 -/* disable interrupts */
    7.50 -typedef struct physdevop_disable_irq_st
    7.51 -{
    7.52 -    u32 irq;      /* IN */
    7.53 -} physdevop_disable_irq_t;
    7.54 -
    7.55 -typedef struct physdevop_finished_irq_st
    7.56 -{
    7.57 -    u32 irq;      /* IN */
    7.58 -} physdevop_finished_irq_t;
    7.59 -
    7.60 -
    7.61  typedef struct _physdev_op_st 
    7.62  {
    7.63      unsigned long cmd;
    7.64 @@ -99,11 +65,6 @@ typedef struct _physdev_op_st
    7.65          physdevop_cfgreg_read_t  cfg_read;
    7.66          physdevop_cfgreg_write_t cfg_write;
    7.67          physdevop_find_irq_t     find_irq;
    7.68 -        physdevop_request_irq_t  request_irq;
    7.69 -        physdevop_free_irq_t     free_irq;
    7.70 -        physdevop_enable_irq_t   enable_irq;
    7.71 -        physdevop_disable_irq_t  disable_irq;
    7.72 -        physdevop_finished_irq_t finished_irq;
    7.73      } u;
    7.74  } physdev_op_t;
    7.75  
     8.1 --- a/xenolinux-2.4.25-sparse/arch/xen/kernel/Makefile	Fri Mar 26 11:03:15 2004 +0000
     8.2 +++ b/xenolinux-2.4.25-sparse/arch/xen/kernel/Makefile	Fri Mar 26 15:07:40 2004 +0000
     8.3 @@ -10,7 +10,7 @@ export-objs     := i386_ksyms.o
     8.4  
     8.5  obj-y	:= process.o semaphore.o signal.o entry.o traps.o irq.o  \
     8.6  		ptrace.o ioport.o ldt.o setup.o time.o sys_i386.o \
     8.7 -		i386_ksyms.o i387.o evtchn.o physirq.o pci-dma.o
     8.8 +		i386_ksyms.o i387.o evtchn.o pci-dma.o
     8.9  
    8.10  ifdef CONFIG_PCI
    8.11  obj-y	+= pci-i386.o pci-pc.o pci-irq.o
     9.1 --- a/xenolinux-2.4.25-sparse/arch/xen/kernel/evtchn.c	Fri Mar 26 11:03:15 2004 +0000
     9.2 +++ b/xenolinux-2.4.25-sparse/arch/xen/kernel/evtchn.c	Fri Mar 26 15:07:40 2004 +0000
     9.3 @@ -17,20 +17,23 @@
     9.4  #include <asm/synch_bitops.h>
     9.5  #include <asm/hypervisor.h>
     9.6  #include <asm/hypervisor-ifs/event_channel.h>
     9.7 -
     9.8 -/* Dynamic IRQ <-> event-channel mappings. */
     9.9 -static int evtchn_to_dynirq[1024];
    9.10 -static int dynirq_to_evtchn[NR_IRQS];
    9.11 -
    9.12 -/* Dynamic IRQ <-> VIRQ mapping. */
    9.13 -static int virq_to_dynirq[NR_VIRQS];
    9.14 +#include <asm/hypervisor-ifs/physdev.h>
    9.15  
    9.16  /*
    9.17 - * Reference counts for bindings to dynamic IRQs.
    9.18 - * NB. This array is referenced with respect to DYNIRQ_BASE!
    9.19 + * This lock protects updates to the following mapping and reference-count
    9.20 + * arrays. The lock does not need to be acquired to read the mapping tables.
    9.21   */
    9.22 -static int dynirq_bindcount[NR_DYNIRQS];
    9.23 -static spinlock_t dynirq_lock;
    9.24 +static spinlock_t irq_mapping_update_lock;
    9.25 +
    9.26 +/* IRQ <-> event-channel mappings. */
    9.27 +static int evtchn_to_irq[NR_EVENT_CHANNELS];
    9.28 +static int irq_to_evtchn[NR_IRQS];
    9.29 +
    9.30 +/* IRQ <-> VIRQ mapping. */
    9.31 +static int virq_to_irq[NR_VIRQS];
    9.32 +
    9.33 +/* Reference counts for bindings to IRQs. */
    9.34 +static int irq_bindcount[NR_IRQS];
    9.35  
    9.36  /* Upcall to generic IRQ layer. */
    9.37  extern asmlinkage unsigned int do_IRQ(int irq, struct pt_regs *regs);
    9.38 @@ -39,7 +42,7 @@ static void evtchn_handle_normal(shared_
    9.39  {
    9.40      unsigned long l1, l2;
    9.41      unsigned int  l1i, l2i, port;
    9.42 -    int           dynirq;
    9.43 +    int           irq;
    9.44  
    9.45      l1 = xchg(&s->evtchn_pending_sel, 0);
    9.46      while ( (l1i = ffs(l1)) != 0 )
    9.47 @@ -54,8 +57,8 @@ static void evtchn_handle_normal(shared_
    9.48              l2 &= ~(1 << l2i);
    9.49              
    9.50              port = (l1i << 5) + l2i;
    9.51 -            if ( (dynirq = evtchn_to_dynirq[port]) != -1 )
    9.52 -                do_IRQ(dynirq + DYNIRQ_BASE, regs);
    9.53 +            if ( (irq = evtchn_to_irq[port]) != -1 )
    9.54 +                do_IRQ(irq, regs);
    9.55              else
    9.56                  evtchn_device_upcall(port, 0);
    9.57          }
    9.58 @@ -66,7 +69,7 @@ static void evtchn_handle_exceptions(sha
    9.59  {
    9.60      unsigned long l1, l2;
    9.61      unsigned int  l1i, l2i, port;
    9.62 -    int           dynirq;
    9.63 +    int           irq;
    9.64  
    9.65      l1 = xchg(&s->evtchn_exception_sel, 0);
    9.66      while ( (l1i = ffs(l1)) != 0 )
    9.67 @@ -81,10 +84,9 @@ static void evtchn_handle_exceptions(sha
    9.68              l2 &= ~(1 << l2i);
    9.69              
    9.70              port = (l1i << 5) + l2i;
    9.71 -            if ( (dynirq = evtchn_to_dynirq[port]) != -1 )
    9.72 +            if ( (irq = evtchn_to_irq[port]) != -1 )
    9.73              {
    9.74 -                printk(KERN_ALERT "Error on IRQ line %d!\n", 
    9.75 -                       dynirq + DYNIRQ_BASE);
    9.76 +                printk(KERN_ALERT "Error on IRQ line %d!\n", irq);
    9.77                  synch_clear_bit(port, &s->evtchn_exception[0]);
    9.78              }
    9.79              else
    9.80 @@ -112,28 +114,28 @@ void evtchn_do_upcall(struct pt_regs *re
    9.81  }
    9.82  
    9.83  
    9.84 -static int find_unbound_dynirq(void)
    9.85 +static int find_unbound_irq(void)
    9.86  {
    9.87 -    int i;
    9.88 +    int irq;
    9.89  
    9.90 -    for ( i = 0; i < NR_DYNIRQS; i++ )
    9.91 -        if ( dynirq_bindcount[i] == 0 )
    9.92 +    for ( irq = 0; irq < NR_IRQS; irq++ )
    9.93 +        if ( irq_bindcount[irq] == 0 )
    9.94              break;
    9.95  
    9.96 -    if ( i == NR_DYNIRQS )
    9.97 +    if ( irq == NR_IRQS )
    9.98          BUG();
    9.99  
   9.100 -    return i;
   9.101 +    return irq;
   9.102  }
   9.103  
   9.104  int bind_virq_to_irq(int virq)
   9.105  {
   9.106      evtchn_op_t op;
   9.107 -    int evtchn, dynirq;
   9.108 +    int evtchn, irq;
   9.109  
   9.110 -    spin_lock(&dynirq_lock);
   9.111 +    spin_lock(&irq_mapping_update_lock);
   9.112  
   9.113 -    if ( (dynirq = virq_to_dynirq[virq]) == -1 )
   9.114 +    if ( (irq = virq_to_irq[virq]) == -1 )
   9.115      {
   9.116          op.cmd              = EVTCHNOP_bind_virq;
   9.117          op.u.bind_virq.virq = virq;
   9.118 @@ -141,29 +143,29 @@ int bind_virq_to_irq(int virq)
   9.119              BUG();
   9.120          evtchn = op.u.bind_virq.port;
   9.121  
   9.122 -        dynirq = find_unbound_dynirq();
   9.123 -        evtchn_to_dynirq[evtchn] = dynirq;
   9.124 -        dynirq_to_evtchn[dynirq] = evtchn;
   9.125 +        irq = find_unbound_irq();
   9.126 +        evtchn_to_irq[evtchn] = irq;
   9.127 +        irq_to_evtchn[irq]    = evtchn;
   9.128  
   9.129 -        virq_to_dynirq[virq] = dynirq;
   9.130 +        virq_to_irq[virq] = irq;
   9.131      }
   9.132  
   9.133 -    dynirq_bindcount[dynirq]++;
   9.134 +    irq_bindcount[irq]++;
   9.135  
   9.136 -    spin_unlock(&dynirq_lock);
   9.137 +    spin_unlock(&irq_mapping_update_lock);
   9.138      
   9.139 -    return dynirq + DYNIRQ_BASE;
   9.140 +    return irq;
   9.141  }
   9.142  
   9.143  void unbind_virq_from_irq(int virq)
   9.144  {
   9.145      evtchn_op_t op;
   9.146 -    int dynirq = virq_to_dynirq[virq];
   9.147 -    int evtchn = dynirq_to_evtchn[dynirq];
   9.148 +    int irq    = virq_to_irq[virq];
   9.149 +    int evtchn = irq_to_evtchn[irq];
   9.150  
   9.151 -    spin_lock(&dynirq_lock);
   9.152 +    spin_lock(&irq_mapping_update_lock);
   9.153  
   9.154 -    if ( --dynirq_bindcount[dynirq] == 0 )
   9.155 +    if ( --irq_bindcount[irq] == 0 )
   9.156      {
   9.157          op.cmd          = EVTCHNOP_close;
   9.158          op.u.close.dom  = DOMID_SELF;
   9.159 @@ -171,47 +173,47 @@ void unbind_virq_from_irq(int virq)
   9.160          if ( HYPERVISOR_event_channel_op(&op) != 0 )
   9.161              BUG();
   9.162  
   9.163 -        evtchn_to_dynirq[evtchn] = -1;
   9.164 -        dynirq_to_evtchn[dynirq] = -1;
   9.165 -        virq_to_dynirq[virq]     = -1;
   9.166 +        evtchn_to_irq[evtchn] = -1;
   9.167 +        irq_to_evtchn[irq]    = -1;
   9.168 +        virq_to_irq[virq]     = -1;
   9.169      }
   9.170  
   9.171 -    spin_unlock(&dynirq_lock);
   9.172 +    spin_unlock(&irq_mapping_update_lock);
   9.173  }
   9.174  
   9.175  int bind_evtchn_to_irq(int evtchn)
   9.176  {
   9.177 -    int dynirq;
   9.178 +    int irq;
   9.179  
   9.180 -    spin_lock(&dynirq_lock);
   9.181 +    spin_lock(&irq_mapping_update_lock);
   9.182  
   9.183 -    if ( (dynirq = evtchn_to_dynirq[evtchn]) == -1 )
   9.184 +    if ( (irq = evtchn_to_irq[evtchn]) == -1 )
   9.185      {
   9.186 -        dynirq = find_unbound_dynirq();
   9.187 -        evtchn_to_dynirq[evtchn] = dynirq;
   9.188 -        dynirq_to_evtchn[dynirq] = evtchn;
   9.189 +        irq = find_unbound_irq();
   9.190 +        evtchn_to_irq[evtchn] = irq;
   9.191 +        irq_to_evtchn[irq]    = evtchn;
   9.192      }
   9.193  
   9.194 -    dynirq_bindcount[dynirq]++;
   9.195 +    irq_bindcount[irq]++;
   9.196  
   9.197 -    spin_unlock(&dynirq_lock);
   9.198 +    spin_unlock(&irq_mapping_update_lock);
   9.199      
   9.200 -    return dynirq + DYNIRQ_BASE;
   9.201 +    return irq;
   9.202  }
   9.203  
   9.204  void unbind_evtchn_from_irq(int evtchn)
   9.205  {
   9.206 -    int dynirq = evtchn_to_dynirq[evtchn];
   9.207 +    int irq = evtchn_to_irq[evtchn];
   9.208  
   9.209 -    spin_lock(&dynirq_lock);
   9.210 +    spin_lock(&irq_mapping_update_lock);
   9.211  
   9.212 -    if ( --dynirq_bindcount[dynirq] == 0 )
   9.213 +    if ( --irq_bindcount[irq] == 0 )
   9.214      {
   9.215 -        evtchn_to_dynirq[evtchn] = -1;
   9.216 -        dynirq_to_evtchn[dynirq] = -1;
   9.217 +        evtchn_to_irq[evtchn] = -1;
   9.218 +        irq_to_evtchn[irq]    = -1;
   9.219      }
   9.220  
   9.221 -    spin_unlock(&dynirq_lock);
   9.222 +    spin_unlock(&irq_mapping_update_lock);
   9.223  }
   9.224  
   9.225  
   9.226 @@ -221,41 +223,35 @@ void unbind_evtchn_from_irq(int evtchn)
   9.227  
   9.228  static unsigned int startup_dynirq(unsigned int irq)
   9.229  {
   9.230 -    int dynirq = irq - DYNIRQ_BASE;
   9.231 -    unmask_evtchn(dynirq_to_evtchn[dynirq]);
   9.232 +    unmask_evtchn(irq_to_evtchn[irq]);
   9.233      return 0;
   9.234  }
   9.235  
   9.236  static void shutdown_dynirq(unsigned int irq)
   9.237  {
   9.238 -    int dynirq = irq - DYNIRQ_BASE;
   9.239 -    mask_evtchn(dynirq_to_evtchn[dynirq]);
   9.240 +    mask_evtchn(irq_to_evtchn[irq]);
   9.241  }
   9.242  
   9.243  static void enable_dynirq(unsigned int irq)
   9.244  {
   9.245 -    int dynirq = irq - DYNIRQ_BASE;
   9.246 -    unmask_evtchn(dynirq_to_evtchn[dynirq]);
   9.247 +    unmask_evtchn(irq_to_evtchn[irq]);
   9.248  }
   9.249  
   9.250  static void disable_dynirq(unsigned int irq)
   9.251  {
   9.252 -    int dynirq = irq - DYNIRQ_BASE;
   9.253 -    mask_evtchn(dynirq_to_evtchn[dynirq]);
   9.254 +    mask_evtchn(irq_to_evtchn[irq]);
   9.255  }
   9.256  
   9.257  static void ack_dynirq(unsigned int irq)
   9.258  {
   9.259 -    int dynirq = irq - DYNIRQ_BASE;
   9.260 -    mask_evtchn(dynirq_to_evtchn[dynirq]);
   9.261 -    clear_evtchn(dynirq_to_evtchn[dynirq]);
   9.262 +    mask_evtchn(irq_to_evtchn[irq]);
   9.263 +    clear_evtchn(irq_to_evtchn[irq]);
   9.264  }
   9.265  
   9.266  static void end_dynirq(unsigned int irq)
   9.267  {
   9.268 -    int dynirq = irq - DYNIRQ_BASE;
   9.269      if ( !(irq_desc[irq].status & IRQ_DISABLED) )
   9.270 -        unmask_evtchn(dynirq_to_evtchn[dynirq]);
   9.271 +        unmask_evtchn(irq_to_evtchn[irq]);
   9.272  }
   9.273  
   9.274  static struct hw_interrupt_type dynirq_type = {
   9.275 @@ -269,6 +265,87 @@ static struct hw_interrupt_type dynirq_t
   9.276      NULL
   9.277  };
   9.278  
   9.279 +static inline void pirq_unmask_notify(int pirq)
   9.280 +{
   9.281 +    physdev_op_t op;
   9.282 +    op.cmd = PHYSDEVOP_UNMASK_IRQ;
   9.283 +    (void)HYPERVISOR_physdev_op(&op);
   9.284 +}
   9.285 +
   9.286 +static unsigned int startup_pirq(unsigned int irq)
   9.287 +{
   9.288 +    evtchn_op_t op;
   9.289 +    int evtchn;
   9.290 +
   9.291 +    op.cmd              = EVTCHNOP_bind_pirq;
   9.292 +    op.u.bind_pirq.pirq = irq;
   9.293 +    if ( HYPERVISOR_event_channel_op(&op) != 0 )
   9.294 +        BUG();
   9.295 +    evtchn = op.u.bind_virq.port;
   9.296 +
   9.297 +    evtchn_to_irq[evtchn] = irq;
   9.298 +    irq_to_evtchn[irq]    = evtchn;
   9.299 +
   9.300 +    unmask_evtchn(evtchn);
   9.301 +    pirq_unmask_notify(irq_to_pirq(irq));
   9.302 +
   9.303 +    return 0;
   9.304 +}
   9.305 +
   9.306 +static void shutdown_pirq(unsigned int irq)
   9.307 +{
   9.308 +    evtchn_op_t op;
   9.309 +    int evtchn = irq_to_evtchn[irq];
   9.310 +
   9.311 +    mask_evtchn(evtchn);
   9.312 +
   9.313 +    op.cmd          = EVTCHNOP_close;
   9.314 +    op.u.close.dom  = DOMID_SELF;
   9.315 +    op.u.close.port = evtchn;
   9.316 +    if ( HYPERVISOR_event_channel_op(&op) != 0 )
   9.317 +        BUG();
   9.318 +
   9.319 +    evtchn_to_irq[evtchn] = -1;
   9.320 +    irq_to_evtchn[irq]    = -1;
   9.321 +}
   9.322 +
   9.323 +static void enable_pirq(unsigned int irq)
   9.324 +{
   9.325 +    unmask_evtchn(irq_to_evtchn[irq]);
   9.326 +    pirq_unmask_notify(irq_to_pirq(irq));
   9.327 +}
   9.328 +
   9.329 +static void disable_pirq(unsigned int irq)
   9.330 +{
   9.331 +    mask_evtchn(irq_to_evtchn[irq]);
   9.332 +}
   9.333 +
   9.334 +static void ack_pirq(unsigned int irq)
   9.335 +{
   9.336 +    mask_evtchn(irq_to_evtchn[irq]);
   9.337 +    clear_evtchn(irq_to_evtchn[irq]);
   9.338 +}
   9.339 +
   9.340 +static void end_pirq(unsigned int irq)
   9.341 +{
   9.342 +    if ( !(irq_desc[irq].status & IRQ_DISABLED) )
   9.343 +    {
   9.344 +        unmask_evtchn(irq_to_evtchn[irq]);
   9.345 +        pirq_unmask_notify(irq_to_pirq(irq));
   9.346 +    }
   9.347 +}
   9.348 +
   9.349 +static struct hw_interrupt_type pirq_type = {
   9.350 +    "Phys-irq",
   9.351 +    startup_pirq,
   9.352 +    shutdown_pirq,
   9.353 +    enable_pirq,
   9.354 +    disable_pirq,
   9.355 +    ack_pirq,
   9.356 +    end_pirq,
   9.357 +    NULL
   9.358 +};
   9.359 +
   9.360  static void error_interrupt(int irq, void *dev_id, struct pt_regs *regs)
   9.361  {
   9.362      printk(KERN_ALERT "unexpected VIRQ_ERROR trap to vector %d\n", irq);
   9.363 @@ -287,32 +364,41 @@ void __init init_IRQ(void)
   9.364  {
   9.365      int i;
   9.366  
   9.367 +    spin_lock_init(&irq_mapping_update_lock);
   9.368 +
   9.369 +    /* No VIRQ -> IRQ mappings. */
   9.370      for ( i = 0; i < NR_VIRQS; i++ )
   9.371 -        virq_to_dynirq[i] = -1;
   9.372 +        virq_to_irq[i] = -1;
   9.373  
   9.374 -    for ( i = 0; i < 1024; i++ )
   9.375 -        evtchn_to_dynirq[i] = -1;
   9.376 +    /* No event-channel -> IRQ mappings. */
   9.377 +    for ( i = 0; i < NR_EVENT_CHANNELS; i++ )
   9.378 +        evtchn_to_irq[i] = -1;
   9.379 +
   9.380 +    /* No IRQ -> event-channel mappings. */
   9.381 +    for ( i = 0; i < NR_IRQS; i++ )
   9.382 +        irq_to_evtchn[i] = -1;
   9.383  
   9.384      for ( i = 0; i < NR_DYNIRQS; i++ )
   9.385      {
   9.386 -        dynirq_to_evtchn[i] = -1;
   9.387 -        dynirq_bindcount[i] = 0;
   9.388 +        /* Dynamic IRQ space is currently unbound. Zero the refcnts. */
   9.389 +        irq_bindcount[dynirq_to_irq(i)] = 0;
   9.390 +
   9.391 +        irq_desc[dynirq_to_irq(i)].status  = IRQ_DISABLED;
   9.392 +        irq_desc[dynirq_to_irq(i)].action  = 0;
   9.393 +        irq_desc[dynirq_to_irq(i)].depth   = 1;
   9.394 +        irq_desc[dynirq_to_irq(i)].handler = &dynirq_type;
   9.395      }
   9.396  
   9.397 -    spin_lock_init(&dynirq_lock);
   9.398 -
   9.399 -    for ( i = 0; i < NR_DYNIRQS; i++ )
   9.400 +    for ( i = 0; i < NR_PIRQS; i++ )
   9.401      {
   9.402 -        irq_desc[i + DYNIRQ_BASE].status  = IRQ_DISABLED;
   9.403 -        irq_desc[i + DYNIRQ_BASE].action  = 0;
   9.404 -        irq_desc[i + DYNIRQ_BASE].depth   = 1;
   9.405 -        irq_desc[i + DYNIRQ_BASE].handler = &dynirq_type;
   9.406 +        /* Phys IRQ space is statically bound (1:1 mapping). Nail refcnts. */
   9.407 +        irq_bindcount[pirq_to_irq(i)] = 1;
   9.408 +
   9.409 +        irq_desc[pirq_to_irq(i)].status  = IRQ_DISABLED;
   9.410 +        irq_desc[pirq_to_irq(i)].action  = 0;
   9.411 +        irq_desc[pirq_to_irq(i)].depth   = 1;
   9.412 +        irq_desc[pirq_to_irq(i)].handler = &pirq_type;
   9.413      }
   9.414  
   9.415      (void)setup_irq(bind_virq_to_irq(VIRQ_ERROR), &error_action);
   9.416 -    
   9.417 -#ifdef CONFIG_PCI
   9.418 -    /* Also initialise the physical IRQ handlers. */
   9.419 -    physirq_init();
   9.420 -#endif
   9.421  }
    10.1 --- a/xenolinux-2.4.25-sparse/arch/xen/kernel/physirq.c	Fri Mar 26 11:03:15 2004 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,175 +0,0 @@
    10.4 -/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
    10.5 - ****************************************************************************
    10.6 - * (C) 2004 - Rolf Neugebauer - Intel Research Cambridge
    10.7 - ****************************************************************************
    10.8 - *
    10.9 - *        File: physirq.c
   10.10 - *      Author: Rolf Neugebauer (rolf.neugebauer@intel.com)
   10.11 - *        Date: Mar 2004
   10.12 - * 
   10.13 - * Description: guests may receive virtual interrupts directly 
   10.14 - *              corresponding to physical interrupts. these virtual
   10.15 - *              interrupts require special handling provided 
   10.16 - *              by the virq irq type.
   10.17 - */
   10.18 -
   10.19 -#ifdef CONFIG_PCI
   10.20 -
   10.21 -#include <linux/config.h>
   10.22 -#include <asm/atomic.h>
   10.23 -#include <asm/irq.h>
   10.24 -#include <asm/hypervisor.h>
   10.25 -#include <asm/system.h>
   10.26 -
   10.27 -#include <linux/irq.h>
   10.28 -#include <linux/sched.h>
   10.29 -
   10.30 -#include <asm/hypervisor-ifs/hypervisor-if.h>
   10.31 -#include <asm/hypervisor-ifs/physdev.h>
   10.32 -
   10.33 -static void physirq_interrupt(int irq, void *unused, struct pt_regs *ptregs);
   10.34 -
   10.35 -static int setup_event_handler = 0;
   10.36 -
   10.37 -static unsigned int startup_physirq_event(unsigned int irq)
   10.38 -{
   10.39 -    physdev_op_t op;
   10.40 -    int err;
   10.41 -
   10.42 -    printk("startup_physirq_event %d\n", irq);
   10.43 -
   10.44 -    /*
   10.45 -     * install a interrupt handler for physirq event when called first time
   10.46 -     * we actually are never executing the handler as _EVENT_PHYSIRQ is 
   10.47 -     * handled specially in hypervisor.c But we need to enable the event etc.
   10.48 -     */
   10.49 -    if ( !setup_event_handler )
   10.50 -    {
   10.51 -        printk("startup_physirq_event %d: setup event handler\n", irq);
   10.52 -        /* set up a event handler to demux virtualised physical interrupts */
   10.53 -        err = request_irq(IRQ_FROM_XEN_VIRQ(VIRQ_PHYSIRQ), physirq_interrupt, 
   10.54 -                          SA_SAMPLE_RANDOM, "physirq", NULL);
   10.55 -        if ( err )
   10.56 -        {
   10.57 -            printk(KERN_WARNING "Could not allocate physirq interrupt\n");
   10.58 -            return err;
   10.59 -        }
   10.60 -        setup_event_handler = 1;
   10.61 -    }
   10.62 -
   10.63 -    /*
   10.64 -     * request the irq from hypervisor
   10.65 -     */
   10.66 -    op.cmd = PHYSDEVOP_REQUEST_IRQ;
   10.67 -    op.u.request_irq.irq   = irq;
   10.68 -    if ( (err = HYPERVISOR_physdev_op(&op)) != 0 )
   10.69 -    {
   10.70 -        printk(KERN_ALERT "could not get IRQ %d from Xen\n", irq);
   10.71 -        return err;
   10.72 -    }
   10.73 -    return 0;
   10.74 -}
   10.75 -/*
   10.76 - * This is a dummy interrupt handler.
   10.77 - * It should never be called. events for physical interrupts are handled
   10.78 - * differently in hypervisor.c
   10.79 - */
   10.80 -static void physirq_interrupt(int irq, void *unused, struct pt_regs *ptregs)
   10.81 -{
   10.82 -    printk("XXX This should never be called!");
   10.83 -}
   10.84 -
   10.85 -
   10.86 -/*
   10.87 - * IRQ is not needed anymore.
   10.88 - */
   10.89 -static void shutdown_physirq_event(unsigned int irq)
   10.90 -{
   10.91 -    physdev_op_t op;
   10.92 -    int err;
   10.93 -
   10.94 -    printk("shutdown_phys_irq called.");
   10.95 -
   10.96 -    /*
   10.97 -     * tell hypervisor
   10.98 -     */
   10.99 -    op.cmd = PHYSDEVOP_FREE_IRQ;
  10.100 -    op.u.free_irq.irq   = irq;
  10.101 -    if ( (err = HYPERVISOR_physdev_op(&op)) != 0 )
  10.102 -    {
  10.103 -        printk(KERN_ALERT "could not free IRQ %d\n", irq);
  10.104 -        return;
  10.105 -    }
  10.106 -    return;
  10.107 -}
  10.108 -
  10.109 -
  10.110 -static void enable_physirq_event(unsigned int irq)
  10.111 -{
  10.112 -    /* XXX just enable all phys interrupts for now */
  10.113 -    enable_irq(IRQ_FROM_XEN_VIRQ(VIRQ_PHYSIRQ));
  10.114 -}
  10.115 -
  10.116 -static void disable_physirq_event(unsigned int irq)
  10.117 -{
  10.118 -    /* XXX just disable all phys interrupts for now */
  10.119 -    disable_irq(IRQ_FROM_XEN_VIRQ(VIRQ_PHYSIRQ));
  10.120 -}
  10.121 -
  10.122 -static void ack_physirq_event(unsigned int irq)
  10.123 -{
  10.124 -    /* clear bit */
  10.125 -    if ( irq <= 0 || irq >= 32 )
  10.126 -    {
  10.127 -        printk("wrong irq %d\n", irq);
  10.128 -    }
  10.129 -
  10.130 -    clear_bit(irq, &HYPERVISOR_shared_info->physirq_pend);
  10.131 -}
  10.132 -
  10.133 -static void end_physirq_event(unsigned int irq)
  10.134 -{
  10.135 -    int err;
  10.136 -    physdev_op_t op;
  10.137 -
  10.138 -    /* call hypervisor */
  10.139 -    op.cmd = PHYSDEVOP_FINISHED_IRQ;
  10.140 -    op.u.finished_irq.irq   = irq;
  10.141 -    if ( (err = HYPERVISOR_physdev_op(&op)) != 0 )
  10.142 -    {
  10.143 -        printk(KERN_ALERT "could not finish IRQ %d\n", irq);
  10.144 -        return;
  10.145 -    }
  10.146 -    return;
  10.147 -}
  10.148 -
  10.149 -static struct hw_interrupt_type physirq_irq_type = {
  10.150 -    "physical-irq",
  10.151 -    startup_physirq_event,
  10.152 -    shutdown_physirq_event,
  10.153 -    enable_physirq_event,
  10.154 -    disable_physirq_event,
  10.155 -    ack_physirq_event,
  10.156 -    end_physirq_event,
  10.157 -    NULL
  10.158 -};
  10.159 -
  10.160 -
  10.161 -
  10.162 -void __init physirq_init(void)
  10.163 -{
  10.164 -    int i;
  10.165 -
  10.166 -    printk("Initialise irq handlers [%d-%d] for physical interrupts.\n",
  10.167 -           PHYS_IRQ_BASE, PHYS_IRQ_BASE+NR_PHYS_IRQS-1);
  10.168 -
  10.169 -    for ( i = 0; i < NR_PHYS_IRQS; i++ )
  10.170 -    {
  10.171 -        irq_desc[i + PHYS_IRQ_BASE].status  = IRQ_DISABLED;
  10.172 -        irq_desc[i + PHYS_IRQ_BASE].action  = 0;
  10.173 -        irq_desc[i + PHYS_IRQ_BASE].depth   = 1;
  10.174 -        irq_desc[i + PHYS_IRQ_BASE].handler = &physirq_irq_type;
  10.175 -    }
  10.176 -}
  10.177 -
  10.178 -#endif
    11.1 --- a/xenolinux-2.4.25-sparse/include/asm-xen/irq.h	Fri Mar 26 11:03:15 2004 +0000
    11.2 +++ b/xenolinux-2.4.25-sparse/include/asm-xen/irq.h	Fri Mar 26 15:07:40 2004 +0000
    11.3 @@ -32,7 +32,11 @@
    11.4  
    11.5  #define NR_IRQS   (NR_PIRQS + NR_DYNIRQS)
    11.6  
    11.7 -extern void physirq_init(void);
    11.8 +#define pirq_to_irq(_x)   ((_x) + PIRQ_BASE)
    11.9 +#define irq_to_pirq(_x)   ((_x) - PIRQ_BASE)
   11.10 +
   11.11 +#define dynirq_to_irq(_x) ((_x) + DYNIRQ_BASE)
   11.12 +#define irq_to_dynirq(_x) ((_x) - DYNIRQ_BASE)
   11.13  
   11.14  /* Dynamic binding of event channels and VIRQ sources to Linux IRQ space. */
   11.15  extern int  bind_virq_to_irq(int virq);
   11.16 @@ -40,14 +44,13 @@ extern void unbind_virq_from_irq(int vir
   11.17  extern int  bind_evtchn_to_irq(int evtchn);
   11.18  extern void unbind_evtchn_from_irq(int evtchn);
   11.19  
   11.20 -#define irq_cannonicalize(_irq) (_irq)
   11.21 +static __inline__ int irq_cannonicalize(int irq)
   11.22 +{
   11.23 +    return (irq == 2) ? 9 : irq;
   11.24 +}
   11.25  
   11.26  extern void disable_irq(unsigned int);
   11.27  extern void disable_irq_nosync(unsigned int);
   11.28  extern void enable_irq(unsigned int);
   11.29  
   11.30 -#ifdef CONFIG_X86_LOCAL_APIC
   11.31 -#define ARCH_HAS_NMI_WATCHDOG		/* See include/linux/nmi.h */
   11.32 -#endif
   11.33 -
   11.34  #endif /* _ASM_IRQ_H */