ia64/xen-unstable

changeset 1129:6baeead2cccd

bitkeeper revision 1.749.1.2 (403e097cnc0BYoVqLwFH7-TpqyBF_w)

xc_evtchn.c:
new file
event_channel.h, event_channel.c, Xc.c, xc_private.h, xc.h:
Plumb event channels thru to Python wrapper.
author kaf24@scramble.cl.cam.ac.uk
date Thu Feb 26 14:58:04 2004 +0000 (2004-02-26)
parents 9ed81ff882d4
children acd0f2cab313
files .rootkeys tools/xc/lib/xc.h tools/xc/lib/xc_evtchn.c tools/xc/lib/xc_private.h tools/xc/py/Xc.c xen/common/event_channel.c xen/include/hypervisor-ifs/event_channel.h
line diff
     1.1 --- a/.rootkeys	Wed Feb 25 16:47:26 2004 +0000
     1.2 +++ b/.rootkeys	Thu Feb 26 14:58:04 2004 +0000
     1.3 @@ -74,6 +74,7 @@ 3fbba6dcrNxtygEcgJYAJJ1gCQqfsA tools/xc/
     1.4  3fbba6dbEVkVMX0JuDFzap9jeaucGA tools/xc/lib/xc_bvtsched.c
     1.5  3fbba6dbasJQV-MVElDC0DGSHMiL5w tools/xc/lib/xc_domain.c
     1.6  40278d99BLsfUv3qxv0I8C1sClZ0ow tools/xc/lib/xc_elf.h
     1.7 +403e0977Bjsm_e82pwvl9VvaJxh8Gg tools/xc/lib/xc_evtchn.c
     1.8  3fbba6dbNCU7U6nsMYiXzKkp3ztaJg tools/xc/lib/xc_linux_build.c
     1.9  3fbba6dbl267zZOAVHYLOdLCdhcZMw tools/xc/lib/xc_linux_restore.c
    1.10  3fbba6db7li3FJiABYtCmuGxOJxEGw tools/xc/lib/xc_linux_save.c
     2.1 --- a/tools/xc/lib/xc.h	Wed Feb 25 16:47:26 2004 +0000
     2.2 +++ b/tools/xc/lib/xc.h	Thu Feb 26 14:58:04 2004 +0000
     2.3 @@ -156,6 +156,27 @@ int xc_vbd_probe(int xc_handle,
     2.4                   unsigned int max_vbds,
     2.5                   xc_vbd_t *vbds);
     2.6  
     2.7 +#define DOMID_SELF              (~1ULL)
     2.8 +#define EVTCHNSTAT_closed       0  /* Chennel is not in use.              */
     2.9 +#define EVTCHNSTAT_disconnected 1  /* Channel is not connected to remote. */
    2.10 +#define EVTCHNSTAT_connected    2  /* Channel is connected to remote.     */
    2.11 +int xc_evtchn_open(int xc_handle,
    2.12 +                   u64 dom1,   /* may be DOMID_SELF */
    2.13 +                   u64 dom2,
    2.14 +                   int *port1,
    2.15 +                   int *port2);
    2.16 +int xc_evtchn_close(int xc_handle,
    2.17 +                    u64 dom,   /* may be DOMID_SELF */
    2.18 +                    int port);
    2.19 +int xc_evtchn_send(int xc_handle,
    2.20 +                   int local_port);
    2.21 +int xc_evtchn_status(int xc_handle,
    2.22 +                     u64 dom1, /* may be DOMID_SELF */
    2.23 +                     int port1,
    2.24 +                     u64 *dom2,
    2.25 +                     int *port2,
    2.26 +                     int *chn_status);
    2.27 +
    2.28  int xc_readconsolering(int xc_handle,
    2.29                         char *str, 
    2.30                         unsigned int max_chars, 
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/xc/lib/xc_evtchn.c	Thu Feb 26 14:58:04 2004 +0000
     3.3 @@ -0,0 +1,104 @@
     3.4 +/******************************************************************************
     3.5 + * xc_evtchn.c
     3.6 + * 
     3.7 + * API for manipulating and accessing inter-domain event channels.
     3.8 + * 
     3.9 + * Copyright (c) 2004, K A Fraser.
    3.10 + */
    3.11 +
    3.12 +#include "xc_private.h"
    3.13 +
    3.14 +static int do_evtchn_op(int xc_handle, evtchn_op_t *op)
    3.15 +{
    3.16 +    int ret = -1;
    3.17 +    privcmd_hypercall_t hypercall;
    3.18 +
    3.19 +    hypercall.op     = __HYPERVISOR_event_channel_op;
    3.20 +    hypercall.arg[0] = (unsigned long)op;
    3.21 +
    3.22 +    if ( mlock(op, sizeof(*op)) != 0 )
    3.23 +    {
    3.24 +        PERROR("Could not lock memory for Xen hypercall");
    3.25 +        goto out1;
    3.26 +    }
    3.27 +
    3.28 +    if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
    3.29 +        goto out2;
    3.30 +
    3.31 + out2: (void)munlock(op, sizeof(*op));
    3.32 + out1: return ret;
    3.33 +}
    3.34 +
    3.35 +int xc_evtchn_open(int xc_handle,
    3.36 +                   u64 dom1,
    3.37 +                   u64 dom2,
    3.38 +                   int *port1,
    3.39 +                   int *port2)
    3.40 +{
    3.41 +    evtchn_op_t op;
    3.42 +    int         rc;
    3.43 +
    3.44 +    op.cmd = EVTCHNOP_open;
    3.45 +    op.u.open.dom1 = (domid_t)dom1;
    3.46 +    op.u.open.dom2 = (domid_t)dom2;
    3.47 +   
    3.48 +    if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
    3.49 +    {
    3.50 +        if ( port1 != NULL )
    3.51 +            *port1 = op.u.open.port1;
    3.52 +        if ( port2 != NULL )
    3.53 +            *port2 = op.u.open.port2;
    3.54 +    }
    3.55 +    
    3.56 +    return rc;
    3.57 +}
    3.58 +
    3.59 +
    3.60 +int xc_evtchn_close(int xc_handle,
    3.61 +                    u64 dom,
    3.62 +                    int port)
    3.63 +{
    3.64 +    evtchn_op_t op;
    3.65 +    op.cmd = EVTCHNOP_close;
    3.66 +    op.u.close.dom  = (domid_t)dom;
    3.67 +    op.u.close.port = port;
    3.68 +    return do_evtchn_op(xc_handle, &op);
    3.69 +}
    3.70 +
    3.71 +
    3.72 +int xc_evtchn_send(int xc_handle,
    3.73 +                   int local_port)
    3.74 +{
    3.75 +    evtchn_op_t op;
    3.76 +    op.cmd = EVTCHNOP_send;
    3.77 +    op.u.send.local_port = local_port;
    3.78 +    return do_evtchn_op(xc_handle, &op);
    3.79 +}
    3.80 +
    3.81 +
    3.82 +int xc_evtchn_status(int xc_handle,
    3.83 +                     u64 dom1,
    3.84 +                     int port1,
    3.85 +                     u64 *dom2,
    3.86 +                     int *port2,
    3.87 +                     int *chn_status)
    3.88 +{
    3.89 +    evtchn_op_t op;
    3.90 +    int         rc;
    3.91 +
    3.92 +    op.cmd = EVTCHNOP_status;
    3.93 +    op.u.status.dom1  = (domid_t)dom1;
    3.94 +    op.u.status.port1 = port1;
    3.95 +   
    3.96 +    if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
    3.97 +    {
    3.98 +        if ( dom2 != NULL )
    3.99 +            *dom2 = (u64)op.u.status.dom2;
   3.100 +        if ( port2 != NULL )
   3.101 +            *port2 = op.u.status.port2;
   3.102 +        if ( chn_status != NULL )
   3.103 +            *chn_status = op.u.status.status;
   3.104 +    }
   3.105 +    
   3.106 +    return rc;
   3.107 +}
     4.1 --- a/tools/xc/lib/xc_private.h	Wed Feb 25 16:47:26 2004 +0000
     4.2 +++ b/tools/xc/lib/xc_private.h	Thu Feb 26 14:58:04 2004 +0000
     4.3 @@ -20,6 +20,7 @@
     4.4  #include <hypervisor-ifs/hypervisor-if.h>
     4.5  #include <hypervisor-ifs/dom0_ops.h>
     4.6  #include <hypervisor-ifs/vbd.h>
     4.7 +#include <hypervisor-ifs/event_channel.h>
     4.8  
     4.9  #define _PAGE_PRESENT   0x001
    4.10  #define _PAGE_RW        0x002
     5.1 --- a/tools/xc/py/Xc.c	Wed Feb 25 16:47:26 2004 +0000
     5.2 +++ b/tools/xc/py/Xc.c	Thu Feb 26 14:58:04 2004 +0000
     5.3 @@ -765,6 +765,133 @@ static PyObject *pyxc_vbd_probe(PyObject
     5.4      return list;
     5.5  }
     5.6  
     5.7 +static PyObject *pyxc_evtchn_open(PyObject *self,
     5.8 +                                  PyObject *args,
     5.9 +                                  PyObject *kwds)
    5.10 +{
    5.11 +    XcObject *xc = (XcObject *)self;
    5.12 +    PyObject *dict;
    5.13 +
    5.14 +    u64 dom1 = DOMID_SELF, dom2;
    5.15 +    int port1, port2, ret;
    5.16 +
    5.17 +    static char *kwd_list[] = { "dom2", "dom1", NULL };
    5.18 +
    5.19 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L|L", kwd_list, 
    5.20 +                                      &dom2, &dom1) )
    5.21 +    {
    5.22 +        DPRINTF("could not parse parameter list.");
    5.23 +        return NULL;
    5.24 +    }
    5.25 +
    5.26 +    ret = xc_evtchn_open(xc->xc_handle, dom1, dom2, &port1, &port2);
    5.27 +
    5.28 +    if ( ret < 0 )
    5.29 +        dict = Py_BuildValue("{}");
    5.30 +    else
    5.31 +        dict = Py_BuildValue("{s:i,s:i}", 
    5.32 +                             "port1", port1,
    5.33 +                             "port2", port2);
    5.34 +    
    5.35 +    return dict;
    5.36 +}
    5.37 +
    5.38 +static PyObject *pyxc_evtchn_close(PyObject *self,
    5.39 +                                   PyObject *args,
    5.40 +                                   PyObject *kwds)
    5.41 +{
    5.42 +    XcObject *xc = (XcObject *)self;
    5.43 +
    5.44 +    u64 dom = DOMID_SELF;
    5.45 +    int port, ret;
    5.46 +
    5.47 +    static char *kwd_list[] = { "port", "dom", NULL };
    5.48 +
    5.49 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|L", kwd_list, 
    5.50 +                                      &port, &dom) )
    5.51 +    {
    5.52 +        DPRINTF("could not parse parameter list.");
    5.53 +        return NULL;
    5.54 +    }
    5.55 +
    5.56 +    ret = xc_evtchn_close(xc->xc_handle, dom, port);
    5.57 +
    5.58 +    return PyInt_FromLong(ret);
    5.59 +}
    5.60 +
    5.61 +static PyObject *pyxc_evtchn_send(PyObject *self,
    5.62 +                                  PyObject *args,
    5.63 +                                  PyObject *kwds)
    5.64 +{
    5.65 +    XcObject *xc = (XcObject *)self;
    5.66 +
    5.67 +    int port, ret;
    5.68 +
    5.69 +    static char *kwd_list[] = { "port", NULL };
    5.70 +
    5.71 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &port) )
    5.72 +    {
    5.73 +        DPRINTF("could not parse parameter list.");
    5.74 +        return NULL;
    5.75 +    }
    5.76 +
    5.77 +    ret = xc_evtchn_send(xc->xc_handle, port);
    5.78 +
    5.79 +    return PyInt_FromLong(ret);
    5.80 +}
    5.81 +
    5.82 +static PyObject *pyxc_evtchn_status(PyObject *self,
    5.83 +                                    PyObject *args,
    5.84 +                                    PyObject *kwds)
    5.85 +{
    5.86 +    XcObject *xc = (XcObject *)self;
    5.87 +    PyObject *dict;
    5.88 +
    5.89 +    u64 dom1 = DOMID_SELF, dom2;
    5.90 +    int port1, port2, status, ret;
    5.91 +
    5.92 +    static char *kwd_list[] = { "port", "dom", NULL };
    5.93 +
    5.94 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|L", kwd_list, 
    5.95 +                                      &port1, &dom1) )
    5.96 +    {
    5.97 +        DPRINTF("could not parse parameter list.");
    5.98 +        return NULL;
    5.99 +    }
   5.100 +
   5.101 +    ret = xc_evtchn_status(xc->xc_handle, dom1, port1, &dom2, &port2, &status);
   5.102 +
   5.103 +    if ( ret < 0 )
   5.104 +    {
   5.105 +        dict = Py_BuildValue("{}");
   5.106 +    }
   5.107 +    else
   5.108 +    {
   5.109 +        switch ( status )
   5.110 +        {
   5.111 +        case EVTCHNSTAT_closed:
   5.112 +            dict = Py_BuildValue("{s:s}", 
   5.113 +                                 "status", "closed");
   5.114 +            break;
   5.115 +        case EVTCHNSTAT_disconnected:
   5.116 +            dict = Py_BuildValue("{s:s}", 
   5.117 +                                 "status", "disconnected");
   5.118 +            break;
   5.119 +        case EVTCHNSTAT_connected:
   5.120 +            dict = Py_BuildValue("{s:s,s:L,s:i}", 
   5.121 +                                 "status", "connected",
   5.122 +                                 "dom", dom2,
   5.123 +                                 "port", port2);
   5.124 +            break;
   5.125 +        default:
   5.126 +            dict = Py_BuildValue("{}");
   5.127 +            break;
   5.128 +        }
   5.129 +    }
   5.130 +    
   5.131 +    return dict;
   5.132 +}
   5.133 +
   5.134  static PyObject *pyxc_readconsolering(PyObject *self,
   5.135                                        PyObject *args,
   5.136                                        PyObject *kwds)
   5.137 @@ -1031,6 +1158,43 @@ static PyMethodDef pyxc_methods[] = {
   5.138        " writeable  [int]:  Bool - is this VBD writeable?\n"
   5.139        " nr_sectors [long]: Size of this VBD, in 512-byte sectors.\n" },
   5.140  
   5.141 +    { "evtchn_open", 
   5.142 +      (PyCFunction)pyxc_evtchn_open, 
   5.143 +      METH_VARARGS | METH_KEYWORDS, "\n"
   5.144 +      "Open an event channel between two domains.\n"
   5.145 +      " dom1 [long, SELF]: First domain to be connected.\n"
   5.146 +      " dom2 [long]:       Second domain to be connected.\n\n"
   5.147 +      "Returns: [dict] dictionary is empty on failure.\n"
   5.148 +      " port1 [int]: Port-id for endpoint at dom1.\n"
   5.149 +      " port2 [int]: Port-id for endpoint at dom2.\n" },
   5.150 +
   5.151 +    { "evtchn_close", 
   5.152 +      (PyCFunction)pyxc_evtchn_close, 
   5.153 +      METH_VARARGS | METH_KEYWORDS, "\n"
   5.154 +      "Close an event channel.\n"
   5.155 +      " dom  [long, SELF]: Dom-id of one endpoint of the channel.\n"
   5.156 +      " port [int]:        Port-id of one endpoint of the channel.\n\n"
   5.157 +      "Returns: [int] 0 on success; -1 on error.\n" },
   5.158 +
   5.159 +    { "evtchn_send", 
   5.160 +      (PyCFunction)pyxc_evtchn_send, 
   5.161 +      METH_VARARGS | METH_KEYWORDS, "\n"
   5.162 +      "Send an event along a locally-connected event channel.\n"
   5.163 +      " port [int]: Port-id of a local channel endpoint.\n\n"
   5.164 +      "Returns: [int] 0 on success; -1 on error.\n" },
   5.165 +
   5.166 +    { "evtchn_status", 
   5.167 +      (PyCFunction)pyxc_evtchn_status, 
   5.168 +      METH_VARARGS | METH_KEYWORDS, "\n"
   5.169 +      "Query the status of an event channel.\n"
   5.170 +      " dom  [long, SELF]: Dom-id of one endpoint of the channel.\n"
   5.171 +      " port [int]:        Port-id of one endpoint of the channel.\n\n"
   5.172 +      "Returns: [dict] dictionary is empty on failure.\n"
   5.173 +      " status [str]:  'closed', 'disconnected', or 'connected'.\n"
   5.174 +      "The following are also returned if 'status' is 'connected':\n"
   5.175 +      " dom  [long]: Port-id for endpoint at dom1.\n"
   5.176 +      " port [int]:  Port-id for endpoint at dom2.\n" },
   5.177 +
   5.178      { "readconsolering", 
   5.179        (PyCFunction)pyxc_readconsolering, 
   5.180        METH_VARARGS | METH_KEYWORDS, "\n"
     6.1 --- a/xen/common/event_channel.c	Wed Feb 25 16:47:26 2004 +0000
     6.2 +++ b/xen/common/event_channel.c	Thu Feb 26 14:58:04 2004 +0000
     6.3 @@ -83,156 +83,158 @@ static inline unsigned long set_event_di
     6.4  
     6.5  static long event_channel_open(evtchn_open_t *open)
     6.6  {
     6.7 -    struct task_struct *lp, *rp;
     6.8 -    int                 lport = 0, rport = 0;
     6.9 +    struct task_struct *p1, *p2;
    6.10 +    int                 port1 = 0, port2 = 0;
    6.11      unsigned long       cpu_mask;
    6.12 -    domid_t             ldom = open->local_dom, rdom = open->remote_dom;
    6.13 +    domid_t             dom1 = open->dom1, dom2 = open->dom2;
    6.14      long                rc = 0;
    6.15  
    6.16      if ( !IS_PRIV(current) )
    6.17          return -EPERM;
    6.18  
    6.19 -    /* 'local_dom' may be DOMID_SELF. 'remote_dom' cannot be.*/
    6.20 -    if ( ldom == DOMID_SELF )
    6.21 -        ldom = current->domain;
    6.22 +    /* 'dom1' may be DOMID_SELF. 'dom2' cannot be.*/
    6.23 +    if ( dom1 == DOMID_SELF )
    6.24 +        dom1 = current->domain;
    6.25 +    if ( dom2 == DOMID_SELF )
    6.26 +        return -EINVAL;
    6.27  
    6.28      /* Event channel must connect distinct domains. */
    6.29 -    if ( ldom == rdom )
    6.30 +    if ( dom1 == dom2 )
    6.31          return -EINVAL;
    6.32  
    6.33 -    if ( ((lp = find_domain_by_id(ldom)) == NULL) ||
    6.34 -         ((rp = find_domain_by_id(rdom)) == NULL) )
    6.35 +    if ( ((p1 = find_domain_by_id(dom1)) == NULL) ||
    6.36 +         ((p2 = find_domain_by_id(dom2)) == NULL) )
    6.37      {
    6.38 -        if ( lp != NULL )
    6.39 -            put_task_struct(lp);
    6.40 +        if ( p1 != NULL )
    6.41 +            put_task_struct(p1);
    6.42          return -ESRCH;
    6.43      }
    6.44  
    6.45      /* Avoid deadlock by first acquiring lock of domain with smaller id. */
    6.46 -    if ( ldom < rdom )
    6.47 +    if ( dom1 < dom2 )
    6.48      {
    6.49 -        spin_lock(&lp->event_channel_lock);
    6.50 -        spin_lock(&rp->event_channel_lock);
    6.51 +        spin_lock(&p1->event_channel_lock);
    6.52 +        spin_lock(&p2->event_channel_lock);
    6.53      }
    6.54      else
    6.55      {
    6.56 -        spin_lock(&rp->event_channel_lock);
    6.57 -        spin_lock(&lp->event_channel_lock);
    6.58 +        spin_lock(&p2->event_channel_lock);
    6.59 +        spin_lock(&p1->event_channel_lock);
    6.60      }
    6.61  
    6.62 -    if ( (lport = get_free_port(lp)) < 0 )
    6.63 +    if ( (port1 = get_free_port(p1)) < 0 )
    6.64      {
    6.65 -        rc = lport;
    6.66 +        rc = port1;
    6.67          goto out;
    6.68      }
    6.69  
    6.70 -    if ( (rport = get_free_port(rp)) < 0 )
    6.71 +    if ( (port2 = get_free_port(p2)) < 0 )
    6.72      {
    6.73 -        rc = rport;
    6.74 +        rc = port2;
    6.75          goto out;
    6.76      }
    6.77  
    6.78 -    lp->event_channel[lport].remote_dom  = rp;
    6.79 -    lp->event_channel[lport].remote_port = (u16)rport;
    6.80 -    lp->event_channel[lport].state       = ECS_CONNECTED;
    6.81 +    p1->event_channel[port1].remote_dom  = p2;
    6.82 +    p1->event_channel[port1].remote_port = (u16)port2;
    6.83 +    p1->event_channel[port1].state       = ECS_CONNECTED;
    6.84  
    6.85 -    rp->event_channel[rport].remote_dom  = lp;
    6.86 -    rp->event_channel[rport].remote_port = (u16)lport;
    6.87 -    rp->event_channel[rport].state       = ECS_CONNECTED;
    6.88 +    p2->event_channel[port2].remote_dom  = p1;
    6.89 +    p2->event_channel[port2].remote_port = (u16)port1;
    6.90 +    p2->event_channel[port2].state       = ECS_CONNECTED;
    6.91  
    6.92 -    cpu_mask  = set_event_pending(lp, lport);
    6.93 -    cpu_mask |= set_event_pending(rp, rport);
    6.94 +    cpu_mask  = set_event_pending(p1, port1);
    6.95 +    cpu_mask |= set_event_pending(p2, port2);
    6.96      guest_event_notify(cpu_mask);
    6.97      
    6.98   out:
    6.99 -    spin_unlock(&lp->event_channel_lock);
   6.100 -    spin_unlock(&rp->event_channel_lock);
   6.101 +    spin_unlock(&p1->event_channel_lock);
   6.102 +    spin_unlock(&p2->event_channel_lock);
   6.103      
   6.104 -    put_task_struct(lp);
   6.105 -    put_task_struct(rp);
   6.106 +    put_task_struct(p1);
   6.107 +    put_task_struct(p2);
   6.108  
   6.109 -    open->local_port  = lport;
   6.110 -    open->remote_port = rport;
   6.111 +    open->port1 = port1;
   6.112 +    open->port2 = port2;
   6.113  
   6.114      return rc;
   6.115  }
   6.116  
   6.117  
   6.118 -static long __event_channel_close(struct task_struct *lp, int lport)
   6.119 +static long __event_channel_close(struct task_struct *p1, int port1)
   6.120  {
   6.121 -    struct task_struct *rp = NULL;
   6.122 -    event_channel_t    *lchn, *rchn;
   6.123 -    int                 rport;
   6.124 +    struct task_struct *p2 = NULL;
   6.125 +    event_channel_t    *chn1, *chn2;
   6.126 +    int                 port2;
   6.127      unsigned long       cpu_mask;
   6.128      long                rc = 0;
   6.129  
   6.130   again:
   6.131 -    spin_lock(&lp->event_channel_lock);
   6.132 +    spin_lock(&p1->event_channel_lock);
   6.133  
   6.134 -    lchn = lp->event_channel;
   6.135 +    chn1 = p1->event_channel;
   6.136  
   6.137 -    if ( (lport < 0) || (lport >= lp->max_event_channel) || 
   6.138 -         (lchn[lport].state == ECS_FREE) )
   6.139 +    if ( (port1 < 0) || (port1 >= p1->max_event_channel) || 
   6.140 +         (chn1[port1].state == ECS_FREE) )
   6.141      {
   6.142          rc = -EINVAL;
   6.143          goto out;
   6.144      }
   6.145  
   6.146 -    if ( lchn[lport].state == ECS_CONNECTED )
   6.147 +    if ( chn1[port1].state == ECS_CONNECTED )
   6.148      {
   6.149 -        if ( rp == NULL )
   6.150 +        if ( p2 == NULL )
   6.151          {
   6.152 -            rp = lchn[lport].remote_dom;
   6.153 -            get_task_struct(rp);
   6.154 +            p2 = chn1[port1].remote_dom;
   6.155 +            get_task_struct(p2);
   6.156  
   6.157 -            if ( lp->domain < rp->domain )
   6.158 +            if ( p1->domain < p2->domain )
   6.159              {
   6.160 -                spin_lock(&rp->event_channel_lock);
   6.161 +                spin_lock(&p2->event_channel_lock);
   6.162              }
   6.163              else
   6.164              {
   6.165 -                spin_unlock(&lp->event_channel_lock);
   6.166 -                spin_lock(&rp->event_channel_lock);
   6.167 +                spin_unlock(&p1->event_channel_lock);
   6.168 +                spin_lock(&p2->event_channel_lock);
   6.169                  goto again;
   6.170              }
   6.171          }
   6.172 -        else if ( rp != lchn[lport].remote_dom )
   6.173 +        else if ( p2 != chn1[port1].remote_dom )
   6.174          {
   6.175              rc = -EINVAL;
   6.176              goto out;
   6.177          }
   6.178          
   6.179 -        rchn  = rp->event_channel;
   6.180 -        rport = lchn[lport].remote_port;
   6.181 +        chn2  = p2->event_channel;
   6.182 +        port2 = chn1[port1].remote_port;
   6.183  
   6.184 -        if ( rport >= rp->max_event_channel )
   6.185 +        if ( port2 >= p2->max_event_channel )
   6.186              BUG();
   6.187 -        if ( rchn[rport].state != ECS_CONNECTED )
   6.188 +        if ( chn2[port2].state != ECS_CONNECTED )
   6.189              BUG();
   6.190 -        if ( rchn[rport].remote_dom != lp )
   6.191 +        if ( chn2[port2].remote_dom != p1 )
   6.192              BUG();
   6.193  
   6.194 -        rchn[rport].state       = ECS_ZOMBIE;
   6.195 -        rchn[rport].remote_dom  = NULL;
   6.196 -        rchn[rport].remote_port = 0xFFFF;
   6.197 +        chn2[port2].state       = ECS_ZOMBIE;
   6.198 +        chn2[port2].remote_dom  = NULL;
   6.199 +        chn2[port2].remote_port = 0xFFFF;
   6.200  
   6.201 -        cpu_mask  = set_event_disc(lp, lport);
   6.202 -        cpu_mask |= set_event_disc(rp, rport);
   6.203 +        cpu_mask  = set_event_disc(p1, port1);
   6.204 +        cpu_mask |= set_event_disc(p2, port2);
   6.205          guest_event_notify(cpu_mask);
   6.206      }
   6.207  
   6.208 -    lchn[lport].state       = ECS_FREE;
   6.209 -    lchn[lport].remote_dom  = NULL;
   6.210 -    lchn[lport].remote_port = 0xFFFF;
   6.211 +    chn1[port1].state       = ECS_FREE;
   6.212 +    chn1[port1].remote_dom  = NULL;
   6.213 +    chn1[port1].remote_port = 0xFFFF;
   6.214      
   6.215   out:
   6.216 -    spin_unlock(&lp->event_channel_lock);
   6.217 -    put_task_struct(lp);
   6.218 +    spin_unlock(&p1->event_channel_lock);
   6.219 +    put_task_struct(p1);
   6.220  
   6.221 -    if ( rp != NULL )
   6.222 +    if ( p2 != NULL )
   6.223      {
   6.224 -        spin_unlock(&rp->event_channel_lock);
   6.225 -        put_task_struct(rp);
   6.226 +        spin_unlock(&p2->event_channel_lock);
   6.227 +        put_task_struct(p2);
   6.228      }
   6.229      
   6.230      return rc;
   6.231 @@ -241,22 +243,21 @@ static long __event_channel_close(struct
   6.232  
   6.233  static long event_channel_close(evtchn_close_t *close)
   6.234  {
   6.235 -    struct task_struct *lp;
   6.236 -    int                 lport = close->local_port;
   6.237 +    struct task_struct *p;
   6.238      long                rc;
   6.239 -    domid_t             ldom = close->local_dom;
   6.240 +    domid_t             dom = close->dom;
   6.241  
   6.242 -    if ( ldom == DOMID_SELF )
   6.243 -        ldom = current->domain;
   6.244 +    if ( dom == DOMID_SELF )
   6.245 +        dom = current->domain;
   6.246      else if ( !IS_PRIV(current) )
   6.247          return -EPERM;
   6.248  
   6.249 -    if ( (lp = find_domain_by_id(ldom)) == NULL )
   6.250 +    if ( (p = find_domain_by_id(dom)) == NULL )
   6.251          return -ESRCH;
   6.252  
   6.253 -    rc = __event_channel_close(lp, lport);
   6.254 +    rc = __event_channel_close(p, close->port);
   6.255  
   6.256 -    put_task_struct(lp);
   6.257 +    put_task_struct(p);
   6.258      return rc;
   6.259  }
   6.260  
   6.261 @@ -295,30 +296,30 @@ static long event_channel_send(int lport
   6.262  
   6.263  static long event_channel_status(evtchn_status_t *status)
   6.264  {
   6.265 -    struct task_struct *lp;
   6.266 -    domid_t             ldom = status->local_dom;
   6.267 -    int                 lport = status->local_port;
   6.268 -    event_channel_t    *lchn;
   6.269 +    struct task_struct *p;
   6.270 +    domid_t             dom = status->dom1;
   6.271 +    int                 port = status->port1;
   6.272 +    event_channel_t    *chn;
   6.273  
   6.274 -    if ( ldom == DOMID_SELF )
   6.275 -        ldom = current->domain;
   6.276 +    if ( dom == DOMID_SELF )
   6.277 +        dom = current->domain;
   6.278      else if ( !IS_PRIV(current) )
   6.279          return -EPERM;
   6.280  
   6.281 -    if ( (lp = find_domain_by_id(ldom)) == NULL )
   6.282 +    if ( (p = find_domain_by_id(dom)) == NULL )
   6.283          return -ESRCH;
   6.284  
   6.285 -    spin_lock(&lp->event_channel_lock);
   6.286 +    spin_lock(&p->event_channel_lock);
   6.287  
   6.288 -    lchn = lp->event_channel;
   6.289 +    chn = p->event_channel;
   6.290  
   6.291 -    if ( (lport < 0) || (lport >= lp->max_event_channel) )
   6.292 +    if ( (port < 0) || (port >= p->max_event_channel) )
   6.293      {
   6.294 -        spin_unlock(&lp->event_channel_lock);
   6.295 +        spin_unlock(&p->event_channel_lock);
   6.296          return -EINVAL;
   6.297      }
   6.298  
   6.299 -    switch ( lchn[lport].state )
   6.300 +    switch ( chn[port].state )
   6.301      {
   6.302      case ECS_FREE:
   6.303          status->status = EVTCHNSTAT_closed;
   6.304 @@ -328,14 +329,14 @@ static long event_channel_status(evtchn_
   6.305          break;
   6.306      case ECS_CONNECTED:
   6.307          status->status = EVTCHNSTAT_connected;
   6.308 -        status->remote_dom  = lchn[lport].remote_dom->domain;
   6.309 -        status->remote_port = lchn[lport].remote_port;
   6.310 +        status->dom2   = chn[port].remote_dom->domain;
   6.311 +        status->port2  = chn[port].remote_port;
   6.312          break;
   6.313      default:
   6.314          BUG();
   6.315      }
   6.316  
   6.317 -    spin_unlock(&lp->event_channel_lock);
   6.318 +    spin_unlock(&p->event_channel_lock);
   6.319      return 0;
   6.320  }
   6.321  
     7.1 --- a/xen/include/hypervisor-ifs/event_channel.h	Wed Feb 25 16:47:26 2004 +0000
     7.2 +++ b/xen/include/hypervisor-ifs/event_channel.h	Thu Feb 26 14:58:04 2004 +0000
     7.3 @@ -10,36 +10,35 @@
     7.4  #define __HYPERVISOR_IFS__EVENT_CHANNEL_H__
     7.5  
     7.6  /*
     7.7 - * EVTCHNOP_open: Open a communication channel between <local_dom> and
     7.8 - * <remote_dom>.
     7.9 + * EVTCHNOP_open: Open a communication channel between <dom1> and <dom2>.
    7.10   * NOTES:
    7.11 - *  1. <local_dom> may be specified as DOMID_SELF.
    7.12 + *  1. <dom1> may be specified as DOMID_SELF.
    7.13   *  2. Only a sufficiently-privileged domain may create an event channel.
    7.14 - *  3. <local_port> and <remote_port> are only supplied if the op succeeds.
    7.15 + *  3. <port1> and <port2> are only supplied if the op succeeds.
    7.16   */
    7.17  #define EVTCHNOP_open           0
    7.18  typedef struct evtchn_open
    7.19  {
    7.20      /* IN parameters. */
    7.21 -    domid_t local_dom, remote_dom;
    7.22 +    domid_t dom1, dom2;
    7.23      /* OUT parameters. */
    7.24 -    int     local_port, remote_port;
    7.25 +    int     port1, port2;
    7.26  } evtchn_open_t;
    7.27  
    7.28  /*
    7.29   * EVTCHNOP_close: Close the communication channel which has an endpoint at
    7.30 - * <local_dom, local_port>.
    7.31 + * <dom, port>.
    7.32   * NOTES:
    7.33 - *  1. <local_dom> may be specified as DOMID_SELF.
    7.34 + *  1. <dom> may be specified as DOMID_SELF.
    7.35   *  2. Only a sufficiently-privileged domain may close an event channel
    7.36 - *     for which <local_dom> is not DOMID_SELF.
    7.37 + *     for which <dom> is not DOMID_SELF.
    7.38   */
    7.39  #define EVTCHNOP_close          1
    7.40  typedef struct evtchn_close
    7.41  {
    7.42      /* IN parameters. */
    7.43 -    domid_t local_dom;
    7.44 -    int     local_port;
    7.45 +    domid_t dom;
    7.46 +    int     port;
    7.47      /* No OUT parameters. */
    7.48  } evtchn_close_t;
    7.49  
    7.50 @@ -57,22 +56,22 @@ typedef struct evtchn_send
    7.51  
    7.52  /*
    7.53   * EVTCHNOP_status: Get the current status of the communication channel which
    7.54 - * has an endpoint at <local_dom, local_port>.
    7.55 + * has an endpoint at <dom1, port1>.
    7.56   * NOTES:
    7.57 - *  1. <local_dom> may be specified as DOMID_SELF.
    7.58 + *  1. <dom1> may be specified as DOMID_SELF.
    7.59   *  2. Only a sufficiently-privileged domain may obtain the status of an event
    7.60 - *     channel for which <local_dom> is not DOMID_SELF.
    7.61 - *  3. <remote_dom, remote_port> is only supplied if status is 'connected'.
    7.62 + *     channel for which <dom1> is not DOMID_SELF.
    7.63 + *  3. <dom2, port2> is only supplied if status is 'connected'.
    7.64   */
    7.65  #define EVTCHNOP_status         3  /* Get status of <channel id>.         */
    7.66  typedef struct evtchn_status
    7.67  {
    7.68      /* IN parameters */
    7.69 -    domid_t local_dom;
    7.70 -    int     local_port;
    7.71 +    domid_t dom1;
    7.72 +    int     port1;
    7.73      /* OUT parameters */
    7.74 -    domid_t remote_dom;
    7.75 -    int     remote_port;
    7.76 +    domid_t dom2;
    7.77 +    int     port2;
    7.78  #define EVTCHNSTAT_closed       0  /* Chennel is not in use.              */
    7.79  #define EVTCHNSTAT_disconnected 1  /* Channel is not connected to remote. */
    7.80  #define EVTCHNSTAT_connected    2  /* Channel is connected to remote.     */