ia64/xen-unstable

changeset 9596:e1152d55ea31

Add new interface for allocating reserved event-channel
ports to arbitrary Xen subsystems.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Apr 05 17:41:51 2006 +0100 (2006-04-05)
parents 68ef2efa929b
children 8f7aad20b4a5
files xen/common/event_channel.c xen/include/xen/event.h
line diff
     1.1 --- a/xen/common/event_channel.c	Wed Apr 05 17:15:34 2006 +0100
     1.2 +++ b/xen/common/event_channel.c	Wed Apr 05 17:41:51 2006 +0100
     1.3 @@ -46,6 +46,7 @@
     1.4          goto out;                                                   \
     1.5      } while ( 0 )
     1.6  
     1.7 +
     1.8  static int get_free_port(struct domain *d)
     1.9  {
    1.10      struct evtchn *chn;
    1.11 @@ -360,7 +361,7 @@ static long __evtchn_close(struct domain
    1.12              rc = -EINVAL;
    1.13              goto out;
    1.14          }
    1.15 -    
    1.16 +
    1.17          port2 = chn1->u.interdomain.remote_port;
    1.18          BUG_ON(!port_is_valid(d2, port2));
    1.19  
    1.20 @@ -438,6 +439,7 @@ long evtchn_send(unsigned int lport)
    1.21      return ret;
    1.22  }
    1.23  
    1.24 +
    1.25  void evtchn_set_pending(struct vcpu *v, int port)
    1.26  {
    1.27      struct domain *d = v->domain;
    1.28 @@ -471,6 +473,7 @@ void evtchn_set_pending(struct vcpu *v, 
    1.29      }
    1.30  }
    1.31  
    1.32 +
    1.33  void send_guest_virq(struct vcpu *v, int virq)
    1.34  {
    1.35      int port = v->virq_to_evtchn[virq];
    1.36 @@ -479,6 +482,7 @@ void send_guest_virq(struct vcpu *v, int
    1.37          evtchn_set_pending(v, port);
    1.38  }
    1.39  
    1.40 +
    1.41  void send_guest_pirq(struct domain *d, int pirq)
    1.42  {
    1.43      int port = d->pirq_to_evtchn[pirq];
    1.44 @@ -486,6 +490,7 @@ void send_guest_pirq(struct domain *d, i
    1.45      evtchn_set_pending(d->vcpu[chn->notify_vcpu_id], port);
    1.46  }
    1.47  
    1.48 +
    1.49  static long evtchn_status(evtchn_status_t *status)
    1.50  {
    1.51      struct domain   *d;
    1.52 @@ -550,6 +555,7 @@ static long evtchn_status(evtchn_status_
    1.53      return rc;
    1.54  }
    1.55  
    1.56 +
    1.57  long evtchn_bind_vcpu(unsigned int port, unsigned int vcpu_id)
    1.58  {
    1.59      struct domain *d = current->domain;
    1.60 @@ -585,6 +591,7 @@ long evtchn_bind_vcpu(unsigned int port,
    1.61      return rc;
    1.62  }
    1.63  
    1.64 +
    1.65  static long evtchn_unmask(evtchn_unmask_t *unmask)
    1.66  {
    1.67      struct domain *d = current->domain;
    1.68 @@ -620,6 +627,7 @@ static long evtchn_unmask(evtchn_unmask_
    1.69      return 0;
    1.70  }
    1.71  
    1.72 +
    1.73  long do_event_channel_op(GUEST_HANDLE(evtchn_op_t) uop)
    1.74  {
    1.75      long rc;
    1.76 @@ -694,6 +702,48 @@ long do_event_channel_op(GUEST_HANDLE(ev
    1.77  }
    1.78  
    1.79  
    1.80 +int evtchn_open_reserved_port(struct domain *d)
    1.81 +{
    1.82 +    struct evtchn *chn;
    1.83 +    int            port;
    1.84 +
    1.85 +    spin_lock(&d->evtchn_lock);
    1.86 +
    1.87 +    if ( (port = get_free_port(d)) >= 0 )
    1.88 +    {
    1.89 +        chn = evtchn_from_port(d, port);
    1.90 +        chn->state = ECS_RESERVED;
    1.91 +    }
    1.92 +
    1.93 +    spin_unlock(&d->evtchn_lock);
    1.94 +
    1.95 +    return port;
    1.96 +}
    1.97 +
    1.98 +
    1.99 +void evtchn_close_reserved_port(struct domain *d, int port)
   1.100 +{
   1.101 +    struct evtchn *chn;
   1.102 +
   1.103 +    spin_lock(&d->evtchn_lock);
   1.104 +
   1.105 +    BUG_ON(!port_is_valid(d, port));
   1.106 +
   1.107 +    chn = evtchn_from_port(d, port);
   1.108 +    chn->state          = ECS_FREE;
   1.109 +    chn->notify_vcpu_id = 0;
   1.110 +
   1.111 +    spin_unlock(&d->evtchn_lock);
   1.112 +}
   1.113 +
   1.114 +
   1.115 +void evtchn_notify_reserved_port(struct domain *d, int port)
   1.116 +{
   1.117 +    struct evtchn *chn = evtchn_from_port(d, port);
   1.118 +    evtchn_set_pending(d->vcpu[chn->notify_vcpu_id], port);
   1.119 +}
   1.120 +
   1.121 +
   1.122  int evtchn_init(struct domain *d)
   1.123  {
   1.124      spin_lock_init(&d->evtchn_lock);
     2.1 --- a/xen/include/xen/event.h	Wed Apr 05 17:15:34 2006 +0100
     2.2 +++ b/xen/include/xen/event.h	Wed Apr 05 17:41:51 2006 +0100
     2.3 @@ -45,4 +45,9 @@ extern long evtchn_send(unsigned int lpo
     2.4  /* Bind a local event-channel port to the specified VCPU. */
     2.5  extern long evtchn_bind_vcpu(unsigned int port, unsigned int vcpu_id);
     2.6  
     2.7 +/* Reserved event-channel ports for other Xen subsystems. */
     2.8 +int evtchn_open_reserved_port(struct domain *d);
     2.9 +void evtchn_close_reserved_port(struct domain *d, int port);
    2.10 +void evtchn_notify_reserved_port(struct domain *d, int port);
    2.11 +
    2.12  #endif /* __XEN_EVENT_H__ */