- rename init_events() to events_init(), to better reflect netbsd semantics
- change unbind_[pv]irq_from_evtch() so that they now return the event channel the [PV]IRQ was bound to. It reflects the opposite behaviour of the bind_[pv]irq_to_evtch() functions. - remove xenbus_suspend() and xenbus_resume() prototypes, as they are not used anywhere else, and will conflict with the xenbus pmf(9) handlers. - make start_info aligned on a page boundary, as Xen expects it to be so. - mask event channel during xbd detach before removing its handler (can avoid spurious events). - add the "protocol" entry in xenstore during xbd initialization. Normally created during domU's boot by xentools, it is under domU's responsibility in all other cases (save/restore, hot plugging, etc.). - modifications to xs_init(), so that it can properly return an error. Reviewed by Christoph (cegger@).
This commit is contained in:
parent
15485d84a5
commit
4f26afe701
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: evtchn.h,v 1.16 2008/07/01 18:49:21 bouyer Exp $ */
|
/* $NetBSD: evtchn.h,v 1.17 2008/10/24 21:09:24 jym Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
extern struct evtsource *evtsource[];
|
extern struct evtsource *evtsource[];
|
||||||
|
|
||||||
void events_default_setup(void);
|
void events_default_setup(void);
|
||||||
void init_events(void);
|
void events_init(void);
|
||||||
unsigned int evtchn_do_event(int, struct intrframe *);
|
unsigned int evtchn_do_event(int, struct intrframe *);
|
||||||
void call_evtchn_do_event(int, struct intrframe *);
|
void call_evtchn_do_event(int, struct intrframe *);
|
||||||
void call_xenevt_event(int);
|
void call_xenevt_event(int);
|
||||||
|
@ -54,8 +54,8 @@ extern int xen_debug_handler(void *);
|
||||||
|
|
||||||
int bind_virq_to_evtch(int);
|
int bind_virq_to_evtch(int);
|
||||||
int bind_pirq_to_evtch(int);
|
int bind_pirq_to_evtch(int);
|
||||||
void unbind_pirq_from_evtch(int);
|
int unbind_pirq_from_evtch(int);
|
||||||
void unbind_virq_from_evtch(int);
|
int unbind_virq_from_evtch(int);
|
||||||
|
|
||||||
struct pintrhand {
|
struct pintrhand {
|
||||||
int pirq;
|
int pirq;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: xenbus.h,v 1.9 2008/04/16 18:41:48 cegger Exp $ */
|
/* $NetBSD: xenbus.h,v 1.10 2008/10/24 21:09:24 jym Exp $ */
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* xenbus.h
|
* xenbus.h
|
||||||
*
|
*
|
||||||
|
@ -159,10 +159,6 @@ void xs_resume(void);
|
||||||
/* Used by xenbus_dev to borrow kernel's store connection. */
|
/* Used by xenbus_dev to borrow kernel's store connection. */
|
||||||
int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void **);
|
int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void **);
|
||||||
|
|
||||||
/* Called from xen core code. */
|
|
||||||
void xenbus_suspend(void);
|
|
||||||
void xenbus_resume(void);
|
|
||||||
|
|
||||||
void xenbus_probe(void *);
|
void xenbus_probe(void *);
|
||||||
|
|
||||||
int xenbus_free_device(struct xenbus_device *);
|
int xenbus_free_device(struct xenbus_device *);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: x86_xpmap.c,v 1.10 2008/10/21 15:46:32 cegger Exp $ */
|
/* $NetBSD: x86_xpmap.c,v 1.11 2008/10/24 21:09:24 jym Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006 Mathieu Ropert <mro@adviseo.fr>
|
* Copyright (c) 2006 Mathieu Ropert <mro@adviseo.fr>
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.10 2008/10/21 15:46:32 cegger Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.11 2008/10/24 21:09:24 jym Exp $");
|
||||||
|
|
||||||
#include "opt_xen.h"
|
#include "opt_xen.h"
|
||||||
#include "opt_ddb.h"
|
#include "opt_ddb.h"
|
||||||
|
@ -123,7 +123,8 @@ static char XBUF[256];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
volatile shared_info_t *HYPERVISOR_shared_info;
|
volatile shared_info_t *HYPERVISOR_shared_info;
|
||||||
union start_info_union start_info_union;
|
/* Xen requires the start_info struct to be page aligned */
|
||||||
|
union start_info_union start_info_union __aligned(PAGE_SIZE);
|
||||||
unsigned long *xpmap_phys_to_machine_mapping;
|
unsigned long *xpmap_phys_to_machine_mapping;
|
||||||
|
|
||||||
void xen_failsafe_handler(void);
|
void xen_failsafe_handler(void);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: evtchn.c,v 1.38 2008/05/24 15:09:34 bouyer Exp $ */
|
/* $NetBSD: evtchn.c,v 1.39 2008/10/24 21:09:24 jym Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006 Manuel Bouyer.
|
* Copyright (c) 2006 Manuel Bouyer.
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.38 2008/05/24 15:09:34 bouyer Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.39 2008/10/24 21:09:24 jym Exp $");
|
||||||
|
|
||||||
#include "opt_xen.h"
|
#include "opt_xen.h"
|
||||||
#include "isa.h"
|
#include "isa.h"
|
||||||
|
@ -174,7 +174,7 @@ events_default_setup(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init_events(void)
|
events_init(void)
|
||||||
{
|
{
|
||||||
#ifndef XEN3
|
#ifndef XEN3
|
||||||
int evtch;
|
int evtch;
|
||||||
|
@ -346,7 +346,7 @@ bind_virq_to_evtch(int virq)
|
||||||
return evtchn;
|
return evtchn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
unbind_virq_from_evtch(int virq)
|
unbind_virq_from_evtch(int virq)
|
||||||
{
|
{
|
||||||
evtchn_op_t op;
|
evtchn_op_t op;
|
||||||
|
@ -370,6 +370,8 @@ unbind_virq_from_evtch(int virq)
|
||||||
|
|
||||||
simple_unlock(&irq_mapping_update_lock);
|
simple_unlock(&irq_mapping_update_lock);
|
||||||
splx(s);
|
splx(s);
|
||||||
|
|
||||||
|
return evtchn;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NPCI > 0 || NISA > 0
|
#if NPCI > 0 || NISA > 0
|
||||||
|
@ -409,7 +411,7 @@ bind_pirq_to_evtch(int pirq)
|
||||||
return evtchn;
|
return evtchn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
unbind_pirq_from_evtch(int pirq)
|
unbind_pirq_from_evtch(int pirq)
|
||||||
{
|
{
|
||||||
evtchn_op_t op;
|
evtchn_op_t op;
|
||||||
|
@ -433,6 +435,8 @@ unbind_pirq_from_evtch(int pirq)
|
||||||
|
|
||||||
simple_unlock(&irq_mapping_update_lock);
|
simple_unlock(&irq_mapping_update_lock);
|
||||||
splx(s);
|
splx(s);
|
||||||
|
|
||||||
|
return evtchn;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pintrhand *
|
struct pintrhand *
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: hypervisor.c,v 1.41 2008/10/24 18:02:58 jym Exp $ */
|
/* $NetBSD: hypervisor.c,v 1.42 2008/10/24 21:09:24 jym Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005 Manuel Bouyer.
|
* Copyright (c) 2005 Manuel Bouyer.
|
||||||
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.41 2008/10/24 18:02:58 jym Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.42 2008/10/24 21:09:24 jym Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -266,7 +266,7 @@ hypervisor_attach(device_t parent, device_t self, void *aux)
|
||||||
aprint_normal("\n");
|
aprint_normal("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
init_events();
|
events_init();
|
||||||
|
|
||||||
#if NXENBUS > 0
|
#if NXENBUS > 0
|
||||||
hac.hac_xenbus.xa_device = "xenbus";
|
hac.hac_xenbus.xa_device = "xenbus";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: xbd_xenbus.c,v 1.31 2008/10/24 18:02:58 jym Exp $ */
|
/* $NetBSD: xbd_xenbus.c,v 1.32 2008/10/24 21:09:24 jym Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006 Manuel Bouyer.
|
* Copyright (c) 2006 Manuel Bouyer.
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.31 2008/10/24 18:02:58 jym Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.32 2008/10/24 21:09:24 jym Exp $");
|
||||||
|
|
||||||
#include "opt_xen.h"
|
#include "opt_xen.h"
|
||||||
#include "rnd.h"
|
#include "rnd.h"
|
||||||
|
@ -57,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.31 2008/10/24 18:02:58 jym Exp $");
|
||||||
|
|
||||||
#include <xen/xen3-public/io/ring.h>
|
#include <xen/xen3-public/io/ring.h>
|
||||||
#include <xen/xen3-public/io/blkif.h>
|
#include <xen/xen3-public/io/blkif.h>
|
||||||
|
#include <xen/xen3-public/io/protocols.h>
|
||||||
|
|
||||||
#include <xen/granttables.h>
|
#include <xen/granttables.h>
|
||||||
#include <xen/xenbus.h>
|
#include <xen/xenbus.h>
|
||||||
|
@ -286,6 +287,7 @@ xbd_xenbus_detach(device_t dev, int flags)
|
||||||
disk_destroy(&sc->sc_dksc.sc_dkdev);
|
disk_destroy(&sc->sc_dksc.sc_dkdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hypervisor_mask_event(sc->sc_evtchn);
|
||||||
event_remove_handler(sc->sc_evtchn, &xbd_handler, sc);
|
event_remove_handler(sc->sc_evtchn, &xbd_handler, sc);
|
||||||
while (xengnt_status(sc->sc_ring_gntref)) {
|
while (xengnt_status(sc->sc_ring_gntref)) {
|
||||||
tsleep(xbd_xenbus_detach, PRIBIO, "xbd_ref", hz/2);
|
tsleep(xbd_xenbus_detach, PRIBIO, "xbd_ref", hz/2);
|
||||||
|
@ -346,6 +348,12 @@ again:
|
||||||
errmsg = "writing event channel";
|
errmsg = "writing event channel";
|
||||||
goto abort_transaction;
|
goto abort_transaction;
|
||||||
}
|
}
|
||||||
|
error = xenbus_printf(xbt, sc->sc_xbusd->xbusd_path,
|
||||||
|
"protocol", "%s", XEN_IO_PROTO_ABI_NATIVE);
|
||||||
|
if (error) {
|
||||||
|
errmsg = "writing protocol";
|
||||||
|
goto abort_transaction;
|
||||||
|
}
|
||||||
error = xenbus_switch_state(sc->sc_xbusd, xbt, XenbusStateInitialised);
|
error = xenbus_switch_state(sc->sc_xbusd, xbt, XenbusStateInitialised);
|
||||||
if (error) {
|
if (error) {
|
||||||
errmsg = "writing frontend XenbusStateInitialised";
|
errmsg = "writing frontend XenbusStateInitialised";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: xenbus_comms.h,v 1.4 2008/04/16 18:41:48 cegger Exp $ */
|
/* $NetBSD: xenbus_comms.h,v 1.5 2008/10/24 21:09:24 jym Exp $ */
|
||||||
/*
|
/*
|
||||||
* Private include for xenbus communications.
|
* Private include for xenbus communications.
|
||||||
*
|
*
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
#define _XENBUS_COMMS_H
|
#define _XENBUS_COMMS_H
|
||||||
|
|
||||||
void xenbus_kernfs_init(void);
|
void xenbus_kernfs_init(void);
|
||||||
int xs_init(void);
|
int xs_init(device_t dev);
|
||||||
int xb_init_comms(device_t dev);
|
int xb_init_comms(device_t dev);
|
||||||
|
|
||||||
/* Low level routines. */
|
/* Low level routines. */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: xenbus_probe.c,v 1.24 2008/10/21 21:55:44 cegger Exp $ */
|
/* $NetBSD: xenbus_probe.c,v 1.25 2008/10/24 21:09:24 jym Exp $ */
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Talks to Xen Store to figure out what devices we have.
|
* Talks to Xen Store to figure out what devices we have.
|
||||||
*
|
*
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.24 2008/10/21 21:55:44 cegger Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.25 2008/10/24 21:09:24 jym Exp $");
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define DPRINTK(fmt, args...) \
|
#define DPRINTK(fmt, args...) \
|
||||||
|
@ -566,7 +566,7 @@ xenbus_probe_init(void *unused)
|
||||||
xb_init_comms(xenbus_dev);
|
xb_init_comms(xenbus_dev);
|
||||||
|
|
||||||
/* Initialize the interface to xenstore. */
|
/* Initialize the interface to xenstore. */
|
||||||
err = xs_init();
|
err = xs_init(xenbus_dev);
|
||||||
if (err) {
|
if (err) {
|
||||||
aprint_error_dev(xenbus_dev,
|
aprint_error_dev(xenbus_dev,
|
||||||
"Error initializing xenstore comms: %i\n", err);
|
"Error initializing xenstore comms: %i\n", err);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: xenbus_xs.c,v 1.15 2008/10/24 18:02:58 jym Exp $ */
|
/* $NetBSD: xenbus_xs.c,v 1.16 2008/10/24 21:09:24 jym Exp $ */
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* xenbus_xs.c
|
* xenbus_xs.c
|
||||||
*
|
*
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: xenbus_xs.c,v 1.15 2008/10/24 18:02:58 jym Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: xenbus_xs.c,v 1.16 2008/10/24 21:09:24 jym Exp $");
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define DPRINTK(fmt, args...) \
|
#define DPRINTK(fmt, args...) \
|
||||||
|
@ -845,7 +845,7 @@ xenbus_thread(void *unused)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
xs_init(void)
|
xs_init(device_t dev)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -855,13 +855,17 @@ xs_init(void)
|
||||||
|
|
||||||
err = kthread_create(PRI_NONE, 0, NULL, xenwatch_thread,
|
err = kthread_create(PRI_NONE, 0, NULL, xenwatch_thread,
|
||||||
NULL, NULL, "xenwatch");
|
NULL, NULL, "xenwatch");
|
||||||
if (err)
|
if (err) {
|
||||||
printf("kthread_create(xenwatch): %d\n", err);
|
aprint_error_dev(dev, "kthread_create(xenwatch): %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
err = kthread_create(PRI_NONE, 0, NULL, xenbus_thread,
|
err = kthread_create(PRI_NONE, 0, NULL, xenbus_thread,
|
||||||
NULL, NULL, "xenbus");
|
NULL, NULL, "xenbus");
|
||||||
if (err)
|
if (err) {
|
||||||
printf("kthread_create(xenbus): %d\n", err);
|
aprint_error_dev(dev, "kthread_create(xenbus): %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue