version 1.7.4.1, 2009/05/04 08:12:15 |
version 1.8, 2008/10/21 15:46:32 |
Line 34 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 34 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/null.h> |
#include <sys/null.h> |
#include <sys/errno.h> |
#include <sys/errno.h> |
|
#include <sys/malloc.h> |
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/proc.h> |
#include <sys/proc.h> |
#include <sys/systm.h> |
#include <sys/systm.h> |
|
|
#include <xen/xen.h> /* for xendomain_is_dom0() */ |
|
#include <xen/hypervisor.h> |
#include <xen/hypervisor.h> |
#include <xen/evtchn.h> |
#include <xen/evtchn.h> |
#include <xen/xenbus.h> |
#include <xen/xenbus.h> |
Line 133 xb_write(const void *data, unsigned len) |
|
Line 133 xb_write(const void *data, unsigned len) |
|
/* Read indexes, then verify. */ |
/* Read indexes, then verify. */ |
cons = intf->req_cons; |
cons = intf->req_cons; |
prod = intf->req_prod; |
prod = intf->req_prod; |
xen_rmb(); |
x86_lfence(); |
if (!check_indexes(cons, prod)) { |
if (!check_indexes(cons, prod)) { |
splx(s); |
splx(s); |
return EIO; |
return EIO; |
Line 150 xb_write(const void *data, unsigned len) |
|
Line 150 xb_write(const void *data, unsigned len) |
|
len -= avail; |
len -= avail; |
|
|
/* Other side must not see new header until data is there. */ |
/* Other side must not see new header until data is there. */ |
xen_rmb(); |
x86_lfence(); |
intf->req_prod += avail; |
intf->req_prod += avail; |
xen_rmb(); |
x86_lfence(); |
|
|
hypervisor_notify_via_evtchn(xen_start_info.store_evtchn); |
hypervisor_notify_via_evtchn(xen_start_info.store_evtchn); |
} |
} |
Line 179 xb_read(void *data, unsigned len) |
|
Line 179 xb_read(void *data, unsigned len) |
|
/* Read indexes, then verify. */ |
/* Read indexes, then verify. */ |
cons = intf->rsp_cons; |
cons = intf->rsp_cons; |
prod = intf->rsp_prod; |
prod = intf->rsp_prod; |
xen_rmb(); |
x86_lfence(); |
if (!check_indexes(cons, prod)) { |
if (!check_indexes(cons, prod)) { |
XENPRINTF(("xb_read EIO\n")); |
XENPRINTF(("xb_read EIO\n")); |
splx(s); |
splx(s); |
Line 193 xb_read(void *data, unsigned len) |
|
Line 193 xb_read(void *data, unsigned len) |
|
avail = len; |
avail = len; |
|
|
/* We must read header before we read data. */ |
/* We must read header before we read data. */ |
xen_rmb(); |
x86_lfence(); |
|
|
memcpy(data, src, avail); |
memcpy(data, src, avail); |
data = (char *)data + avail; |
data = (char *)data + avail; |
len -= avail; |
len -= avail; |
|
|
/* Other side must not see free space until we've copied out */ |
/* Other side must not see free space until we've copied out */ |
xen_rmb(); |
x86_lfence(); |
intf->rsp_cons += avail; |
intf->rsp_cons += avail; |
xen_rmb(); |
x86_lfence(); |
|
|
XENPRINTF(("Finished read of %i bytes (%i to go)\n", |
XENPRINTF(("Finished read of %i bytes (%i to go)\n", |
avail, len)); |
avail, len)); |
Line 214 xb_read(void *data, unsigned len) |
|
Line 214 xb_read(void *data, unsigned len) |
|
return 0; |
return 0; |
} |
} |
|
|
/* Set up interrupt handler of store event channel. */ |
/* Set up interrupt handler off store event channel. */ |
int |
int |
xb_init_comms(device_t dev) |
xb_init_comms(device_t dev) |
{ |
{ |
Line 226 xb_init_comms(device_t dev) |
|
Line 226 xb_init_comms(device_t dev) |
|
err = event_set_handler(xen_start_info.store_evtchn, wake_waiting, |
err = event_set_handler(xen_start_info.store_evtchn, wake_waiting, |
NULL, IPL_TTY, "xenbus"); |
NULL, IPL_TTY, "xenbus"); |
if (err) { |
if (err) { |
aprint_error_dev(dev, "request irq failed %i\n", err); |
printf("XENBUS request irq failed %i\n", err); |
return err; |
return err; |
} |
} |
xenbus_irq = xen_start_info.store_evtchn; |
xenbus_irq = xen_start_info.store_evtchn; |
aprint_verbose_dev(dev, "using event channel %d\n", xenbus_irq); |
printf("%s: using event channel %d\n", device_xname(dev), xenbus_irq); |
hypervisor_enable_event(xenbus_irq); |
hypervisor_enable_event(xenbus_irq); |
return 0; |
return 0; |
} |
} |