device_t / softc split

reviewed, tested and approved by bouyer
This commit is contained in:
cegger 2008-04-16 18:41:48 +00:00
parent 5c97fc53e8
commit af33bdeef3
16 changed files with 226 additions and 230 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_xennetvar.h,v 1.12 2007/11/22 16:16:57 bouyer Exp $ */
/* $NetBSD: if_xennetvar.h,v 1.13 2008/04/16 18:41:48 cegger Exp $ */
/*
*
@ -44,7 +44,7 @@ struct xennet_attach_args {
struct nfs_diskless;
int xennet_scan(struct device *, struct xennet_attach_args *, cfprint_t);
int xennet_scan(device_t, struct xennet_attach_args *, cfprint_t);
int xennet_bootstatic_callback(struct nfs_diskless *);
#endif /* _XEN_IF_XENNETVAR_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci_machdep.h,v 1.8 2008/04/14 13:38:03 cegger Exp $ */
/* $NetBSD: pci_machdep.h,v 1.9 2008/04/16 18:41:48 cegger Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@ -109,7 +109,7 @@ typedef struct xen_intr_handle pci_intr_handle_t;
/* functions provided to MI PCI */
struct pci_attach_args;
void pci_attach_hook(struct device *, struct device *,
void pci_attach_hook(device_t, device_t,
struct pcibus_attach_args *);
int pci_bus_maxdevs(pci_chipset_tag_t, int);
pcitag_t pci_make_tag(pci_chipset_tag_t, int, int, int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: xbdvar.h,v 1.10 2008/01/11 20:00:41 bouyer Exp $ */
/* $NetBSD: xbdvar.h,v 1.11 2008/04/16 18:41:48 cegger Exp $ */
/*
*
@ -38,7 +38,7 @@
#include <sys/simplelock.h>
struct xbd_softc {
struct device sc_dev; /* base device glue */
device_t sc_dev; /* base device glue */
struct dk_softc sc_dksc; /* generic disk interface */
unsigned long sc_xd_device; /* cookie identifying device */
struct dk_intf *sc_di; /* pseudo-disk interface */
@ -56,7 +56,7 @@ struct xbd_attach_args {
struct sysctlnode *xa_diskcookies;
};
int xbd_scan(struct device *, struct xbd_attach_args *, cfprint_t);
int xbd_scan(device_t, struct xbd_attach_args *, cfprint_t);
void xbd_suspend(void);
void xbd_resume(void);

View File

@ -1,4 +1,4 @@
/* $NetBSD: xenbus.h,v 1.8 2008/03/14 02:17:15 ichiro Exp $ */
/* $NetBSD: xenbus.h,v 1.9 2008/04/16 18:41:48 cegger Exp $ */
/******************************************************************************
* xenbus.h
*
@ -83,7 +83,7 @@ struct xenbus_device {
xenbusdev_type_t xbusd_type;
union {
struct {
struct device *f_dev;
device_t f_dev;
} f;
struct {
void *b_cookie; /* private to backend driver */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mainbus.c,v 1.3 2008/01/11 20:00:52 bouyer Exp $ */
/* $NetBSD: mainbus.c,v 1.4 2008/04/16 18:41:48 cegger Exp $ */
/* NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp */
/*
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.3 2008/01/11 20:00:52 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.4 2008/04/16 18:41:48 cegger Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -92,10 +92,10 @@ int mp_verbose = 0;
#endif /* defined(XEN3) && NPCI > 0 */
int mainbus_match(struct device *, struct cfdata *, void *);
void mainbus_attach(struct device *, struct device *, void *);
int mainbus_match(device_t, cfdata_t, void *);
void mainbus_attach(device_t, device_t, void *);
CFATTACH_DECL(mainbus, sizeof(struct device),
CFATTACH_DECL_NEW(mainbus, 0,
mainbus_match, mainbus_attach, NULL, NULL);
int mainbus_print(void *, const char *);
@ -115,10 +115,7 @@ union mainbus_attach_args {
* Probe for the mainbus; always succeeds.
*/
int
mainbus_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
mainbus_match(device_t parent, cfdata_t match, void *aux)
{
return 1;
@ -128,9 +125,7 @@ mainbus_match(parent, match, aux)
* Attach the mainbus.
*/
void
mainbus_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
mainbus_attach(device_t parent, device_t self, void *aux)
{
union mainbus_attach_args mba;
#if defined(DOM0OPS) && defined(XEN3)
@ -143,7 +138,8 @@ mainbus_attach(parent, self, aux)
#endif
#endif /* defined(DOM0OPS) && defined(XEN3) */
printf("\n");
aprint_naive("\n");
aprint_normal("\n");
#ifndef XEN3
memset(&mba.mba_caa, 0, sizeof(mba.mba_caa));
@ -162,7 +158,7 @@ mainbus_attach(parent, self, aux)
pci_mode = pci_mode_detect();
#ifdef PCI_BUS_FIXUP
pci_maxbus = pci_bus_fixup(NULL, 0);
aprint_debug("PCI bus max, after pci_bus_fixup: %i\n",
aprint_debug_dev(self, "PCI bus max, after pci_bus_fixup: %i\n",
pci_maxbus);
#ifdef PCI_ADDR_FIXUP
pciaddr.extent_port = NULL;
@ -215,9 +211,7 @@ mainbus_attach(parent, self, aux)
}
int
mainbus_print(aux, pnp)
void *aux;
const char *pnp;
mainbus_print(void *aux, const char *pnp)
{
union mainbus_attach_args *mba = aux;

View File

@ -1,4 +1,4 @@
/* $NetBSD: hypervisor.c,v 1.35 2008/04/14 13:38:03 cegger Exp $ */
/* $NetBSD: hypervisor.c,v 1.36 2008/04/16 18:41:48 cegger Exp $ */
/*
* Copyright (c) 2005 Manuel Bouyer.
@ -63,7 +63,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.35 2008/04/14 13:38:03 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.36 2008/04/16 18:41:48 cegger Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -149,10 +149,10 @@ __KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.35 2008/04/14 13:38:03 cegger Exp $
#include <xen/xbdvar.h>
#endif
int hypervisor_match(struct device *, struct cfdata *, void *);
void hypervisor_attach(struct device *, struct device *, void *);
int hypervisor_match(device_t, cfdata_t, void *);
void hypervisor_attach(device_t, device_t, void *);
CFATTACH_DECL(hypervisor, sizeof(struct device),
CFATTACH_DECL_NEW(hypervisor, 0,
hypervisor_match, hypervisor_attach, NULL, NULL);
static int hypervisor_print(void *, const char *);
@ -216,10 +216,7 @@ static struct sysmon_pswitch hysw_reboot = {
* Probe for the hypervisor; always succeeds.
*/
int
hypervisor_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
hypervisor_match(device_t parent, cfdata_t match, void *aux)
{
struct hypervisor_attach_args *haa = aux;
@ -232,9 +229,7 @@ hypervisor_match(parent, match, aux)
* Attach the hypervisor.
*/
void
hypervisor_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
hypervisor_attach(device_t parent, device_t self, void *aux)
{
#if NPCI >0
#ifndef XEN3
@ -390,9 +385,7 @@ hypervisor_attach(parent, self, aux)
}
static int
hypervisor_print(aux, parent)
void *aux;
const char *parent;
hypervisor_print(void *aux, const char *parent)
{
union hypervisor_attach_cookie *hac = aux;
@ -408,7 +401,7 @@ hypervisor_print(aux, parent)
kernfs_parentdir_t *kernxen_pkt;
void
xenkernfs_init()
xenkernfs_init(void)
{
kernfs_entry_t *dkt;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_xennet.c,v 1.56 2008/04/06 07:24:20 cegger Exp $ */
/* $NetBSD: if_xennet.c,v 1.57 2008/04/16 18:41:48 cegger Exp $ */
/*
*
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.56 2008/04/06 07:24:20 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.57 2008/04/16 18:41:48 cegger Exp $");
#include "opt_inet.h"
#include "opt_nfs_boot.h"
@ -136,7 +136,7 @@ union xennet_bufarray {
};
struct xennet_softc {
struct device sc_dev; /* base device glue */
device_t sc_dev; /* base device glue */
struct ethercom sc_ethercom; /* Ethernet common part */
int sc_ifno;
@ -176,8 +176,8 @@ struct xennet_softc {
#endif
};
int xennet_match (struct device *, struct cfdata *, void *);
void xennet_attach (struct device *, struct device *, void *);
int xennet_match (device_t, cfdata_t, void *);
void xennet_attach (device_t, device_t, void *);
static void xennet_ctrlif_rx(ctrl_msg_t *, unsigned long);
static int xennet_driver_count_connected(void);
static void xennet_driver_status_change(netif_fe_driver_status_t *);
@ -198,7 +198,7 @@ void xennet_start(struct ifnet *);
int xennet_ioctl(struct ifnet *ifp, u_long cmd, void *data);
void xennet_watchdog(struct ifnet *ifp);
CFATTACH_DECL(xennet_hypervisor, sizeof(struct xennet_softc),
CFATTACH_DECL_NEW(xennet_hypervisor, sizeof(struct xennet_softc),
xennet_match, xennet_attach, NULL, NULL);
#define RX_MAX_ENTRIES (NETIF_RX_RING_SIZE - 2)
@ -220,7 +220,7 @@ struct xennet_ctrl {
int xc_up;
cfprint_t xc_cfprint;
struct device *xc_parent;
device_t xc_parent;
};
static struct xennet_ctrl netctrl = { -1, 0, 0 };
@ -236,7 +236,7 @@ int in_autoconf = 0;
int
xennet_scan(struct device *self, struct xennet_attach_args *xneta,
xennet_scan(device_t self, struct xennet_attach_args *xneta,
cfprint_t print)
{
ctrl_msg_t cmsg;
@ -269,7 +269,7 @@ xennet_scan(struct device *self, struct xennet_attach_args *xneta,
}
int
xennet_match(struct device *parent, struct cfdata *match, void *aux)
xennet_match(device_t parent, cfdata_t match, void *aux)
{
struct xennet_attach_args *xa = (struct xennet_attach_args *)aux;
@ -279,20 +279,22 @@ xennet_match(struct device *parent, struct cfdata *match, void *aux)
}
void
xennet_attach(struct device *parent, struct device *self, void *aux)
xennet_attach(device_t parent, device_t self, void *aux)
{
struct xennet_attach_args *xneta = (struct xennet_attach_args *)aux;
struct xennet_softc *sc = (struct xennet_softc *)self;
struct xennet_softc *sc = device_private(self);
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
int idx;
extern int ifqmaxlen; /* XXX */
aprint_normal(": Xen Virtual Network Interface\n");
sc->sc_dev = self;
sc->sc_ifno = xneta->xa_handle;
/* Initialize ifnet structure. */
memcpy(ifp->if_xname, device_xname(&sc->sc_dev), IFNAMSIZ);
strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
ifp->if_softc = sc;
ifp->if_start = xennet_start;
ifp->if_ioctl = xennet_ioctl;
@ -322,7 +324,7 @@ xennet_attach(struct device *parent, struct device *self, void *aux)
static struct xennet_softc *
find_device(int handle)
{
struct device *dv;
device_t dv;
struct xennet_softc *xs = NULL;
TAILQ_FOREACH(dv, &alldevs, dv_list) {
@ -380,7 +382,7 @@ xennet_driver_status_change(netif_fe_driver_status_t *status)
static int
xennet_driver_count_connected(void)
{
struct device *dv;
device_t dv;
struct xennet_softc *xs = NULL;
netctrl.xc_interfaces = netctrl.xc_connected = 0;
@ -562,18 +564,18 @@ xennet_interface_status_change(netif_fe_interface_status_t *status)
panic(" xennet: can't establish soft interrupt");
sc->sc_evtchn = status->evtchn;
aprint_verbose_dev(&sc->sc_dev, "using event channel %d\n",
aprint_verbose_dev(sc->sc_dev, "using event channel %d\n",
sc->sc_evtchn);
event_set_handler(sc->sc_evtchn,
&xen_network_handler, sc, IPL_NET, device_xname(&sc->sc_dev));
&xen_network_handler, sc, IPL_NET, device_xname(sc->sc_dev));
hypervisor_enable_event(sc->sc_evtchn);
xennet_driver_count_connected();
aprint_normal_dev(&sc->sc_dev, "MAC address %s\n",
aprint_normal_dev(sc->sc_dev, "MAC address %s\n",
ether_sprintf(sc->sc_enaddr));
#if NRND > 0
rnd_attach_source(&sc->sc_rnd_source, device_xname(&sc->sc_dev),
rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dev),
RND_TYPE_NET, 0);
#endif
if (in_autoconf) {
@ -1010,7 +1012,7 @@ xennet_start(struct ifnet *ifp)
{
struct xennet_softc *sc = ifp->if_softc;
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_start()\n", device_xname(&sc->sc_dev)));
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_start()\n", device_xname(sc->sc_dev)));
#if NRND > 0
rnd_add_uint32(&sc->sc_rnd_source, sc->sc_tx->req_prod);
@ -1174,7 +1176,7 @@ xennet_softstart(void *arg)
splx(s);
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_start() done\n",
device_xname(&sc->sc_dev)));
device_xname(sc->sc_dev)));
}
int
@ -1190,14 +1192,14 @@ xennet_ioctl(struct ifnet *ifp, u_long cmd, void *data)
s = splnet();
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_ioctl()\n", device_xname(&sc->sc_dev)));
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_ioctl()\n", device_xname(sc->sc_dev)));
error = ether_ioctl(ifp, cmd, data);
if (error == ENETRESET)
error = 0;
splx(s);
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_ioctl() returning %d\n",
device_xname(&sc->sc_dev), error));
device_xname(sc->sc_dev), error));
return error;
}
@ -1207,7 +1209,7 @@ xennet_watchdog(struct ifnet *ifp)
{
struct xennet_softc *sc = ifp->if_softc;
printf("%s: xennet_watchdog\n", device_xname(&sc->sc_dev));
printf("%s: xennet_watchdog\n", device_xname(sc->sc_dev));
}
int
@ -1216,7 +1218,7 @@ xennet_init(struct ifnet *ifp)
struct xennet_softc *sc = ifp->if_softc;
int s = splnet();
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_init()\n", device_xname(&sc->sc_dev)));
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_init()\n", device_xname(sc->sc_dev)));
if (ifp->if_flags & IFF_UP) {
if ((ifp->if_flags & IFF_RUNNING) == 0)
@ -1243,7 +1245,7 @@ void
xennet_reset(struct xennet_softc *sc)
{
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_reset()\n", device_xname(&sc->sc_dev)));
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_reset()\n", device_xname(sc->sc_dev)));
}
#ifdef mediacode

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_xennet_xenbus.c,v 1.24 2008/04/06 07:24:20 cegger Exp $ */
/* $NetBSD: if_xennet_xenbus.c,v 1.25 2008/04/16 18:41:48 cegger Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.24 2008/04/06 07:24:20 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.25 2008/04/16 18:41:48 cegger Exp $");
#include "opt_xen.h"
#include "opt_nfs_boot.h"
@ -150,7 +150,7 @@ struct xennet_rxreq {
};
struct xennet_xenbus_softc {
struct device sc_dev;
device_t sc_dev;
struct ethercom sc_ethercom;
uint8_t sc_enaddr[6];
struct xenbus_device *sc_xbusd;
@ -185,9 +185,9 @@ struct xennet_xenbus_softc {
static multicall_entry_t rx_mcl[NET_RX_RING_SIZE+1];
static u_long xennet_pages[NET_RX_RING_SIZE];
static int xennet_xenbus_match(struct device *, struct cfdata *, void *);
static void xennet_xenbus_attach(struct device *, struct device *, void *);
static int xennet_xenbus_detach(struct device *, int);
static int xennet_xenbus_match(device_t, cfdata_t, void *);
static void xennet_xenbus_attach(device_t, device_t, void *);
static int xennet_xenbus_detach(device_t, int);
static void xennet_backend_changed(void *, XenbusState);
static int xennet_xenbus_resume(void *);
@ -208,11 +208,11 @@ static void xennet_start(struct ifnet *);
static int xennet_ioctl(struct ifnet *, u_long, void *);
static void xennet_watchdog(struct ifnet *);
CFATTACH_DECL(xennet_xenbus, sizeof(struct xennet_xenbus_softc),
CFATTACH_DECL_NEW(xennet_xenbus, sizeof(struct xennet_xenbus_softc),
xennet_xenbus_match, xennet_xenbus_attach, xennet_xenbus_detach, NULL);
static int
xennet_xenbus_match(struct device *parent, struct cfdata *match, void *aux)
xennet_xenbus_match(device_t parent, cfdata_t match, void *aux)
{
struct xenbusdev_attach_args *xa = aux;
@ -227,9 +227,9 @@ xennet_xenbus_match(struct device *parent, struct cfdata *match, void *aux)
}
static void
xennet_xenbus_attach(struct device *parent, struct device *self, void *aux)
xennet_xenbus_attach(device_t parent, device_t self, void *aux)
{
struct xennet_xenbus_softc *sc = (void *)self;
struct xennet_xenbus_softc *sc = device_private(self);
struct xenbusdev_attach_args *xa = aux;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
int err;
@ -244,12 +244,14 @@ xennet_xenbus_attach(struct device *parent, struct device *self, void *aux)
#endif
aprint_normal(": Xen Virtual Network Interface\n");
sc->sc_dev = self;
#ifdef XENNET_DEBUG
printf("path: %s\n", xa->xa_xbusd->xbusd_path);
snprintf(id_str, sizeof(id_str), "%d", xa->xa_id);
err = xenbus_directory(NULL, "device/vif", id_str, &dir_n, &dir);
if (err) {
aprint_error_dev(&sc->sc_dev, "xenbus_directory err %d\n", err);
aprint_error_dev(self, "xenbus_directory err %d\n", err);
} else {
printf("%s/\n", xa->xa_xbusd->xbusd_path);
for (i = 0; i < dir_n; i++) {
@ -257,7 +259,7 @@ xennet_xenbus_attach(struct device *parent, struct device *self, void *aux)
err = xenbus_read(NULL, xa->xa_xbusd->xbusd_path, dir[i],
NULL, &val);
if (err) {
aprint_error_dev(&sc->sc_dev, "xenbus_read err %d\n", err);
aprint_error_dev(self, "xenbus_read err %d\n", err);
} else {
printf(" = %s\n", val);
free(val, M_DEVBUF);
@ -294,31 +296,31 @@ xennet_xenbus_attach(struct device *parent, struct device *self, void *aux)
splx(s);
sc->sc_free_rxreql = i;
if (sc->sc_free_rxreql == 0) {
aprint_error_dev(&sc->sc_dev, "failed to allocate rx memory\n");
aprint_error_dev(self, "failed to allocate rx memory\n");
return;
}
/* read mac address */
err = xenbus_read(NULL, xa->xa_xbusd->xbusd_path, "mac", NULL, &val);
if (err) {
aprint_error_dev(&sc->sc_dev, "can't read mac address, err %d\n", err);
aprint_error_dev(self, "can't read mac address, err %d\n", err);
return;
}
/* read mac address */
for (i = 0, p = val; i < 6; i++) {
sc->sc_enaddr[i] = strtoul(p, &e, 16);
if ((e[0] == '\0' && i != 5) && e[0] != ':') {
aprint_error_dev(&sc->sc_dev, "%s is not a valid mac address\n", val);
aprint_error_dev(self, "%s is not a valid mac address\n", val);
free(val, M_DEVBUF);
return;
}
p = &e[1];
}
free(val, M_DEVBUF);
aprint_normal_dev(&sc->sc_dev, "MAC address %s\n",
aprint_normal_dev(self, "MAC address %s\n",
ether_sprintf(sc->sc_enaddr));
/* Initialize ifnet structure and attach interface */
memcpy(ifp->if_xname, device_xname(&sc->sc_dev), IFNAMSIZ);
strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
ifp->if_softc = sc;
ifp->if_start = xennet_start;
ifp->if_ioctl = xennet_ioctl;
@ -341,14 +343,14 @@ xennet_xenbus_attach(struct device *parent, struct device *self, void *aux)
}
static int
xennet_xenbus_detach(struct device *self, int flags)
xennet_xenbus_detach(device_t self, int flags)
{
struct xennet_xenbus_softc *sc = (void *)self;
struct xennet_xenbus_softc *sc = device_private(self);
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
int s0, s1;
RING_IDX i;
DPRINTF(("%s: xennet_xenbus_detach\n", device_xname(&sc->sc_dev)));
DPRINTF(("%s: xennet_xenbus_detach\n", device_xname(self)));
s0 = splnet();
xennet_stop(ifp, 1);
/* wait for pending TX to complete, and collect pending RX packets */
@ -384,7 +386,7 @@ xennet_xenbus_detach(struct device *self, int flags)
softint_disestablish(sc->sc_softintr);
event_remove_handler(sc->sc_evtchn, &xennet_handler, sc);
splx(s0);
DPRINTF(("%s: xennet_xenbus_detach done\n", device_xname(&sc->sc_dev)));
DPRINTF(("%s: xennet_xenbus_detach done\n", device_xname(self)));
return 0;
}
@ -427,10 +429,10 @@ xennet_xenbus_resume(void *p)
error = xenbus_alloc_evtchn(sc->sc_xbusd, &sc->sc_evtchn);
if (error)
return error;
aprint_verbose_dev(&sc->sc_dev, "using event channel %d\n",
aprint_verbose_dev(sc->sc_dev, "using event channel %d\n",
sc->sc_evtchn);
event_set_handler(sc->sc_evtchn, &xennet_handler, sc,
IPL_NET, device_xname(&sc->sc_dev));
IPL_NET, device_xname(sc->sc_dev));
again:
xbt = xenbus_transaction_start();
@ -479,8 +481,8 @@ abort_transaction:
static void xennet_backend_changed(void *arg, XenbusState new_state)
{
struct xennet_xenbus_softc *sc = arg;
DPRINTF(("%s: new backend state %d\n", device_xname(&sc->sc_dev), new_state));
struct xennet_xenbus_softc *sc = device_private((device_t)arg);
DPRINTF(("%s: new backend state %d\n", device_xname(sc->sc_dev), new_state));
switch (new_state) {
case XenbusStateInitialising:
@ -581,7 +583,7 @@ xennet_free_rx_buffer(struct xennet_xenbus_softc *sc)
int s = splbio();
DPRINTF(("%s: xennet_free_rx_buffer\n", device_xname(&sc->sc_dev)));
DPRINTF(("%s: xennet_free_rx_buffer\n", device_xname(sc->sc_dev)));
/* get back memory from RX ring */
for (i = 0; i < NET_RX_RING_SIZE; i++) {
struct xennet_rxreq *rxreq = &sc->sc_rxreqs[i];
@ -644,7 +646,7 @@ xennet_free_rx_buffer(struct xennet_xenbus_softc *sc)
}
splx(s);
DPRINTF(("%s: xennet_free_rx_buffer done\n", device_xname(&sc->sc_dev)));
DPRINTF(("%s: xennet_free_rx_buffer done\n", device_xname(sc->sc_dev)));
}
static void
@ -689,7 +691,7 @@ again:
RING_GET_RESPONSE(&sc->sc_tx_ring, i)->id);
if (__predict_false(xengnt_status(req->txreq_gntref))) {
printf("%s: grant still used by backend\n",
device_xname(&sc->sc_dev));
device_xname(sc->sc_dev));
sc->sc_tx_ring.rsp_cons = i;
goto end;
}
@ -871,7 +873,7 @@ xennet_start(struct ifnet *ifp)
{
struct xennet_xenbus_softc *sc = ifp->if_softc;
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_start()\n", device_xname(&sc->sc_dev)));
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_start()\n", device_xname(sc->sc_dev)));
#if NRND > 0
rnd_add_uint32(&sc->sc_rnd_source, sc->sc_tx_ring.req_prod_pvt);
@ -1073,7 +1075,7 @@ xennet_softstart(void *arg)
splx(s);
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_start() done\n",
device_xname(&sc->sc_dev)));
device_xname(sc->sc_dev)));
}
int
@ -1086,14 +1088,14 @@ xennet_ioctl(struct ifnet *ifp, u_long cmd, void *data)
s = splnet();
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_ioctl()\n", device_xname(&sc->sc_dev)));
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_ioctl()\n", device_xname(sc->sc_dev)));
error = ether_ioctl(ifp, cmd, data);
if (error == ENETRESET)
error = 0;
splx(s);
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_ioctl() returning %d\n",
device_xname(&sc->sc_dev), error));
device_xname(sc->sc_dev), error));
return error;
}
@ -1103,7 +1105,7 @@ xennet_watchdog(struct ifnet *ifp)
{
struct xennet_xenbus_softc *sc = ifp->if_softc;
printf("%s: xennet_watchdog\n", device_xname(&sc->sc_dev));
printf("%s: xennet_watchdog\n", device_xname(sc->sc_dev));
}
int
@ -1112,7 +1114,7 @@ xennet_init(struct ifnet *ifp)
struct xennet_xenbus_softc *sc = ifp->if_softc;
int s = splnet();
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_init()\n", device_xname(&sc->sc_dev)));
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_init()\n", device_xname(sc->sc_dev)));
if ((ifp->if_flags & IFF_RUNNING) == 0) {
sc->sc_rx_ring.sring->rsp_event =
@ -1144,7 +1146,7 @@ void
xennet_reset(struct xennet_xenbus_softc *sc)
{
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_reset()\n", device_xname(&sc->sc_dev)));
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_reset()\n", device_xname(sc->sc_dev)));
}
#if defined(NFS_BOOT_BOOTSTATIC)

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcib.c,v 1.4 2008/04/06 07:24:20 cegger Exp $ */
/* $NetBSD: pcib.c,v 1.5 2008/04/16 18:41:48 cegger Exp $ */
/* NetBSD pcib.c,v 1.35 2005/02/03 21:35:44 perry Exp */
/*-
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.4 2008/04/06 07:24:20 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.5 2008/04/16 18:41:48 cegger Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -56,16 +56,16 @@ __KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.4 2008/04/06 07:24:20 cegger Exp $");
#include "isa.h"
int pcibmatch(struct device *, struct cfdata *, void *);
void pcibattach(struct device *, struct device *, void *);
int pcibmatch(device_t, cfdata_t, void *);
void pcibattach(device_t, device_t, void *);
CFATTACH_DECL(pcib, sizeof(struct device),
CFATTACH_DECL_NEW(pcib, 0,
pcibmatch, pcibattach, NULL, NULL);
void pcib_callback(struct device *);
int
pcibmatch(struct device *parent, struct cfdata *match, void *aux)
pcibmatch(device_t parent, cfdata_t match, void *aux)
{
struct pci_attach_args *pa = aux;
@ -168,26 +168,26 @@ pcibmatch(struct device *parent, struct cfdata *match, void *aux)
}
void
pcibattach(struct device *parent, struct device *self, void *aux)
pcibattach(device_t parent, device_t self, void *aux)
{
struct pci_attach_args *pa = aux;
char devinfo[256];
printf("\n");
aprint_normal("\n");
/*
* Just print out a description and defer configuration
* until all PCI devices have been attached.
*/
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
printf("%s: %s (rev. 0x%02x)\n", device_xname(self), devinfo,
aprint_normal_dev(self, "%s (rev. 0x%02x)\n", devinfo,
PCI_REVISION(pa->pa_class));
config_defer(self, pcib_callback);
}
void
pcib_callback(struct device *self)
pcib_callback(device_t self)
{
struct isabus_attach_args iba;

View File

@ -1,4 +1,4 @@
/* $NetBSD: xbd.c,v 1.43 2008/04/06 07:24:20 cegger Exp $ */
/* $NetBSD: xbd.c,v 1.44 2008/04/16 18:41:48 cegger Exp $ */
/*
*
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.43 2008/04/06 07:24:20 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.44 2008/04/16 18:41:48 cegger Exp $");
#include "xbd_hypervisor.h"
#include "rnd.h"
@ -77,36 +77,36 @@ __KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.43 2008/04/06 07:24:20 cegger Exp $");
static void control_send(blkif_request_t *, blkif_response_t *);
static void send_interface_connect(void);
static void xbd_attach(struct device *, struct device *, void *);
static int xbd_detach(struct device *, int);
static void xbd_attach(device_t, device_t, void *);
static int xbd_detach(device_t, int);
#if NXBD_HYPERVISOR > 0
int xbd_match(struct device *, struct cfdata *, void *);
CFATTACH_DECL(xbd_hypervisor, sizeof(struct xbd_softc),
int xbd_match(device_t, cfdata_t, void *);
CFATTACH_DECL_NEW(xbd_hypervisor, sizeof(struct xbd_softc),
xbd_match, xbd_attach, xbd_detach, NULL);
extern struct cfdriver xbd_cd;
#endif
#if NWD > 0
int xbd_wd_match(struct device *, struct cfdata *, void *);
CFATTACH_DECL(wd_xen, sizeof(struct xbd_softc),
int xbd_wd_match(device_t, cfdata_t, void *);
CFATTACH_DECL_NEW(wd_xen, sizeof(struct xbd_softc),
xbd_wd_match, xbd_attach, xbd_detach, NULL);
extern struct cfdriver wd_cd;
#endif
#if NSD > 0
int xbd_sd_match(struct device *, struct cfdata *, void *);
CFATTACH_DECL(sd_xen, sizeof(struct xbd_softc),
int xbd_sd_match(device_t, cfdata_t, void *);
CFATTACH_DECL_NEW(sd_xen, sizeof(struct xbd_softc),
xbd_sd_match, xbd_attach, xbd_detach, NULL);
extern struct cfdriver sd_cd;
#endif
#if NCD > 0
int xbd_cd_match(struct device *, struct cfdata *, void *);
CFATTACH_DECL(cd_xen, sizeof(struct xbd_softc),
int xbd_cd_match(device_t, cfdata_t, void *);
CFATTACH_DECL_NEW(cd_xen, sizeof(struct xbd_softc),
xbd_cd_match, xbd_attach, xbd_detach, NULL);
extern struct cfdriver cd_cd;
@ -399,7 +399,7 @@ static blkif_response_t blkif_control_rsp;
struct xbd_ctrl {
cfprint_t xc_cfprint;
struct device *xc_parent;
device_t xc_parent;
};
static struct xbd_ctrl blkctrl;
@ -503,19 +503,19 @@ getxbd_softc(dev_t dev)
major(dev), unit));
#if NXBD_HYPERVISOR > 0
if (major(dev) == xbd_major)
return device_lookup(&xbd_cd, unit);
return device_lookup_private(&xbd_cd, unit);
#endif
#if NWD > 0
if (major(dev) == xbd_wd_major || major(dev) == xbd_wd_cdev_major)
return device_lookup(&wd_cd, unit);
return device_lookup_private(&wd_cd, unit);
#endif
#if NSD > 0
if (major(dev) == xbd_sd_major || major(dev) == xbd_sd_cdev_major)
return device_lookup(&sd_cd, unit);
return device_lookup_private(&sd_cd, unit);
#endif
#if NCD > 0
if (major(dev) == xbd_cd_major || major(dev) == xbd_cd_cdev_major)
return device_lookup(&cd_cd, unit);
return device_lookup_private(&cd_cd, unit);
#endif
return NULL;
}
@ -731,16 +731,16 @@ connect_interface(blkif_fe_interface_status_t *status)
return;
}
static struct device *
static device_t
find_device(vdisk_t *xd)
{
struct device *dv;
device_t dv;
struct xbd_softc *xs = NULL;
for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next) {
TAILQ_FOREACH(dv, &alldevs, dv_list) {
if (!device_is_a(dv, "xbd"))
continue;
xs = (struct xbd_softc *)dv;
xs = device_private(dv);
if (xd == NULL || xs->sc_xd_device == xd->device)
break;
}
@ -751,7 +751,7 @@ static void
vbd_update(void)
{
struct xbd_attach_args *xbda;
struct device *dev;
device_t dev;
vdisk_t *xd;
vdisk_t *vbd_info_update, *vbd_info_old;
int i, j, new_nr_vbds;
@ -936,7 +936,7 @@ xbd_ctrlif_rx(ctrl_msg_t *msg, unsigned long id)
#if 0
static void
enable_update_events(struct device *self)
enable_update_events(device_t self)
{
kthread_create(xbd_update_create_kthread, self);
@ -1042,7 +1042,7 @@ send_interface_connect(void)
int
xbd_scan(struct device *self, struct xbd_attach_args *mainbus_xbda,
xbd_scan(device_t self, struct xbd_attach_args *mainbus_xbda,
cfprint_t print)
{
struct xbdreq *xr;
@ -1092,7 +1092,7 @@ xbd_scan(struct device *self, struct xbd_attach_args *mainbus_xbda,
#if NXBD_HYPERVISOR > 0
int
xbd_match(struct device *parent, struct cfdata *match, void *aux)
xbd_match(device_t parent, cfdata_t match, void *aux)
{
struct xbd_attach_args *xa = (struct xbd_attach_args *)aux;
@ -1104,7 +1104,7 @@ xbd_match(struct device *parent, struct cfdata *match, void *aux)
#if NWD > 0
int
xbd_wd_match(struct device *parent, struct cfdata *match, void *aux)
xbd_wd_match(device_t parent, cfdata_t match, void *aux)
{
struct xbd_attach_args *xa = (struct xbd_attach_args *)aux;
@ -1116,7 +1116,7 @@ xbd_wd_match(struct device *parent, struct cfdata *match, void *aux)
#if NSD > 0
int
xbd_sd_match(struct device *parent, struct cfdata *match, void *aux)
xbd_sd_match(device_t parent, cfdata_t match, void *aux)
{
struct xbd_attach_args *xa = (struct xbd_attach_args *)aux;
@ -1128,7 +1128,7 @@ xbd_sd_match(struct device *parent, struct cfdata *match, void *aux)
#if NCD > 0
int
xbd_cd_match(struct device *parent, struct cfdata *match, void *aux)
xbd_cd_match(device_t parent, cfdata_t match, void *aux)
{
struct xbd_attach_args *xa = (struct xbd_attach_args *)aux;
@ -1139,28 +1139,30 @@ xbd_cd_match(struct device *parent, struct cfdata *match, void *aux)
#endif
static void
xbd_attach(struct device *parent, struct device *self, void *aux)
xbd_attach(device_t parent, device_t self, void *aux)
{
struct xbd_attach_args *xbda = (struct xbd_attach_args *)aux;
struct xbd_softc *xs = (struct xbd_softc *)self;
struct xbd_softc *xs = device_private(self);
aprint_normal(": Xen Virtual Block Device");
xs->sc_dev = self;
simple_lock_init(&xs->sc_slock);
dk_sc_init(&xs->sc_dksc, xs, device_xname(&xs->sc_dev));
disk_init(&xs->sc_dksc.sc_dkdev, device_xname(&xs->sc_dev), &xbddkdriver);
dk_sc_init(&xs->sc_dksc, xs, device_xname(self));
disk_init(&xs->sc_dksc.sc_dkdev, device_xname(self), &xbddkdriver);
xbdinit(xs, xbda->xa_xd, xbda->xa_dkintf);
#if NRND > 0
rnd_attach_source(&xs->sc_rnd_source, device_xname(&xs->sc_dev),
rnd_attach_source(&xs->sc_rnd_source, device_xname(self),
RND_TYPE_DISK, 0);
#endif
}
static int
xbd_detach(struct device *dv, int flags)
xbd_detach(device_t dv, int flags)
{
struct xbd_softc *xs = (struct xbd_softc *)dv;
struct xbd_softc *xs = device_private(dv);
int bmaj, cmaj, mn, i;
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: xbd_xenbus.c,v 1.25 2008/04/06 07:24:20 cegger Exp $ */
/* $NetBSD: xbd_xenbus.c,v 1.26 2008/04/16 18:41:48 cegger Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.25 2008/04/06 07:24:20 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.26 2008/04/16 18:41:48 cegger Exp $");
#include "opt_xen.h"
#include "rnd.h"
@ -86,7 +86,7 @@ struct xbd_req {
};
struct xbd_xenbus_softc {
struct device sc_dev;
device_t sc_dev;
struct dk_softc sc_dksc;
struct dk_intf *sc_di;
struct xenbus_device *sc_xbusd;
@ -119,9 +119,9 @@ static multicall_entry_t rq_mcl[XBD_RING_SIZE+1];
static paddr_t rq_pages[XBD_RING_SIZE];
#endif
static int xbd_xenbus_match(struct device *, struct cfdata *, void *);
static void xbd_xenbus_attach(struct device *, struct device *, void *);
static int xbd_xenbus_detach(struct device *, int);
static int xbd_xenbus_match(device_t, cfdata_t, void *);
static void xbd_xenbus_attach(device_t, device_t, void *);
static int xbd_xenbus_detach(device_t, int);
static int xbd_xenbus_resume(void *);
static int xbd_handler(void *);
@ -132,7 +132,7 @@ static void xbd_connect(struct xbd_xenbus_softc *);
static int xbd_map_align(struct xbd_req *);
static void xbd_unmap_align(struct xbd_req *);
CFATTACH_DECL(xbd_xenbus, sizeof(struct xbd_xenbus_softc),
CFATTACH_DECL_NEW(xbd_xenbus, sizeof(struct xbd_xenbus_softc),
xbd_xenbus_match, xbd_xenbus_attach, xbd_xenbus_detach, NULL);
dev_type_open(xbdopen);
@ -172,7 +172,7 @@ static struct dkdriver xbddkdriver = {
};
static int
xbd_xenbus_match(struct device *parent, struct cfdata *match, void *aux)
xbd_xenbus_match(device_t parent, cfdata_t match, void *aux)
{
struct xenbusdev_attach_args *xa = aux;
@ -187,9 +187,9 @@ xbd_xenbus_match(struct device *parent, struct cfdata *match, void *aux)
}
static void
xbd_xenbus_attach(struct device *parent, struct device *self, void *aux)
xbd_xenbus_attach(device_t parent, device_t self, void *aux)
{
struct xbd_xenbus_softc *sc = (void *)self;
struct xbd_xenbus_softc *sc = device_private(self);
struct xenbusdev_attach_args *xa = aux;
RING_IDX i;
#ifdef XBD_DEBUG
@ -201,12 +201,15 @@ xbd_xenbus_attach(struct device *parent, struct device *self, void *aux)
config_pending_incr();
printf(": Xen Virtual Block Device Interface\n");
sc->sc_dev = self;
#ifdef XBD_DEBUG
printf("path: %s\n", xa->xa_xbusd->xbusd_path);
snprintf(id_str, sizeof(id_str), "%d", xa->xa_id);
err = xenbus_directory(NULL, "device/vbd", id_str, &dir_n, &dir);
if (err) {
aprint_error_dev(&sc->sc_dev, "xenbus_directory err %d\n", err);
aprint_error_dev(self, "xenbus_directory err %d\n", err);
} else {
printf("%s/\n", xa->xa_xbusd->xbusd_path);
for (i = 0; i < dir_n; i++) {
@ -214,7 +217,7 @@ xbd_xenbus_attach(struct device *parent, struct device *self, void *aux)
err = xenbus_read(NULL, xa->xa_xbusd->xbusd_path, dir[i],
NULL, &val);
if (err) {
aprint_error_dev(&sc->sc_dev, "xenbus_read err %d\n", err);
aprint_error_dev(self, "xenbus_read err %d\n", err);
} else {
printf(" = %s\n", val);
free(val, M_DEVBUF);
@ -225,8 +228,8 @@ xbd_xenbus_attach(struct device *parent, struct device *self, void *aux)
sc->sc_xbusd = xa->xa_xbusd;
sc->sc_xbusd->xbusd_otherend_changed = xbd_backend_changed;
dk_sc_init(&sc->sc_dksc, sc, device_xname(&sc->sc_dev));
disk_init(&sc->sc_dksc.sc_dkdev, device_xname(&sc->sc_dev), &xbddkdriver);
dk_sc_init(&sc->sc_dksc, sc, device_xname(self));
disk_init(&sc->sc_dksc.sc_dkdev, device_xname(self), &xbddkdriver);
sc->sc_di = &dkintf_esdi;
/* initialize free requests list */
SLIST_INIT(&sc->sc_xbdreq_head);
@ -243,9 +246,9 @@ xbd_xenbus_attach(struct device *parent, struct device *self, void *aux)
}
static int
xbd_xenbus_detach(struct device *dev, int flags)
xbd_xenbus_detach(device_t dev, int flags)
{
struct xbd_xenbus_softc *sc = (void *)dev;
struct xbd_xenbus_softc *sc = device_private(dev);
int s, bmaj, cmaj, i, mn;
s = splbio();
DPRINTF(("%s: xbd_detach\n", device_xname(dev)));
@ -321,10 +324,10 @@ xbd_xenbus_resume(void *p)
error = xenbus_alloc_evtchn(sc->sc_xbusd, &sc->sc_evtchn);
if (error)
return error;
aprint_verbose_dev(&sc->sc_dev, "using event channel %d\n",
aprint_verbose_dev(sc->sc_dev, "using event channel %d\n",
sc->sc_evtchn);
event_set_handler(sc->sc_evtchn, &xbd_handler, sc,
IPL_BIO, device_xname(&sc->sc_dev));
IPL_BIO, device_xname(sc->sc_dev));
again:
xbt = xenbus_transaction_start();
@ -364,11 +367,11 @@ abort_transaction:
static void xbd_backend_changed(void *arg, XenbusState new_state)
{
struct xbd_xenbus_softc *sc = arg;
struct xbd_xenbus_softc *sc = device_private((device_t)arg);
struct dk_geom *pdg;
char buf[9];
int s;
DPRINTF(("%s: new backend state %d\n", device_xname(&sc->sc_dev), new_state));
DPRINTF(("%s: new backend state %d\n", device_xname(sc->sc_dev), new_state));
switch (new_state) {
case XenbusStateUnknown:
@ -420,7 +423,7 @@ static void xbd_backend_changed(void *arg, XenbusState new_state)
dk_getdisklabel(sc->sc_di, &sc->sc_dksc, 0 /* XXX ? */);
format_bytes(buf, sizeof(buf), sc->sc_sectors * sc->sc_secsize);
printf("%s: %s, %d bytes/sect x %" PRIu64 " sectors\n",
device_xname(&sc->sc_dev), buf, (int)pdg->pdg_secsize,
device_xname(sc->sc_dev), buf, (int)pdg->pdg_secsize,
sc->sc_xbdsize);
/* Discover wedges on this disk. */
dkwedge_discover(&sc->sc_dksc.sc_dkdev);
@ -443,24 +446,24 @@ xbd_connect(struct xbd_xenbus_softc *sc)
sc->sc_xbusd->xbusd_path, "virtual-device", &sc->sc_handle, 10);
if (err)
panic("%s: can't read number from %s/virtual-device\n",
device_xname(&sc->sc_dev), sc->sc_xbusd->xbusd_otherend);
device_xname(sc->sc_dev), sc->sc_xbusd->xbusd_otherend);
err = xenbus_read_ull(NULL,
sc->sc_xbusd->xbusd_otherend, "sectors", &sectors, 10);
if (err)
panic("%s: can't read number from %s/sectors\n",
device_xname(&sc->sc_dev), sc->sc_xbusd->xbusd_otherend);
device_xname(sc->sc_dev), sc->sc_xbusd->xbusd_otherend);
sc->sc_sectors = sectors;
err = xenbus_read_ul(NULL,
sc->sc_xbusd->xbusd_otherend, "info", &sc->sc_info, 10);
if (err)
panic("%s: can't read number from %s/info\n",
device_xname(&sc->sc_dev), sc->sc_xbusd->xbusd_otherend);
device_xname(sc->sc_dev), sc->sc_xbusd->xbusd_otherend);
err = xenbus_read_ul(NULL,
sc->sc_xbusd->xbusd_otherend, "sector-size", &sc->sc_secsize, 10);
if (err)
panic("%s: can't read number from %s/sector-size\n",
device_xname(&sc->sc_dev), sc->sc_xbusd->xbusd_otherend);
device_xname(sc->sc_dev), sc->sc_xbusd->xbusd_otherend);
xenbus_switch_state(sc->sc_xbusd, NULL, XenbusStateConnected);
}
@ -474,7 +477,7 @@ xbd_handler(void *arg)
int more_to_do;
int seg;
DPRINTF(("xbd_handler(%s)\n", device_xname(&sc->sc_dev)));
DPRINTF(("xbd_handler(%s)\n", device_xname(sc->sc_dev)));
if (__predict_false(sc->sc_backend_status != BLKIF_STATE_CONNECTED))
return 0;
@ -491,7 +494,7 @@ again:
if (__predict_false(
xengnt_status(xbdreq->req_gntref[seg]))) {
printf("%s: grant still used by backend\n",
device_xname(&sc->sc_dev));
device_xname(sc->sc_dev));
sc->sc_ring.rsp_cons = i;
xbdreq->req_nr_segments = seg + 1;
goto done;
@ -503,7 +506,7 @@ again:
if (rep->operation != BLKIF_OP_READ &&
rep->operation != BLKIF_OP_WRITE) {
printf("%s: bad operation %d from backend\n",
device_xname(&sc->sc_dev), rep->operation);
device_xname(sc->sc_dev), rep->operation);
bp->b_error = EIO;
bp->b_resid = bp->b_bcount;
goto next;
@ -538,9 +541,7 @@ xbdopen(dev_t dev, int flags, int fmt, struct lwp *l)
{
struct xbd_xenbus_softc *sc;
if (DISKUNIT(dev) > xbd_cd.cd_ndevs)
return (ENXIO);
sc = xbd_cd.cd_devs[DISKUNIT(dev)];
sc = device_lookup_private(&xbd_cd, DISKUNIT(dev));
if (sc == NULL)
return (ENXIO);
if ((flags & FWRITE) && (sc->sc_info & VDISK_READONLY))
@ -553,7 +554,9 @@ xbdopen(dev_t dev, int flags, int fmt, struct lwp *l)
int
xbdclose(dev_t dev, int flags, int fmt, struct lwp *l)
{
struct xbd_xenbus_softc *sc = xbd_cd.cd_devs[DISKUNIT(dev)];
struct xbd_xenbus_softc *sc;
sc = device_lookup_private(&xbd_cd, DISKUNIT(dev));
DPRINTF(("xbdclose(%d, %d)\n", dev, flags));
return dk_close(sc->sc_di, &sc->sc_dksc, dev, flags, fmt, l);
@ -562,7 +565,9 @@ xbdclose(dev_t dev, int flags, int fmt, struct lwp *l)
void
xbdstrategy(struct buf *bp)
{
struct xbd_xenbus_softc *sc = xbd_cd.cd_devs[DISKUNIT(bp->b_dev)];
struct xbd_xenbus_softc *sc;
sc = device_lookup_private(&xbd_cd, DISKUNIT(bp->b_dev));
DPRINTF(("xbdstrategy(%p): b_bcount = %ld\n", bp,
(long)bp->b_bcount));
@ -589,10 +594,8 @@ xbdsize(dev_t dev)
struct xbd_xenbus_softc *sc;
DPRINTF(("xbdsize(%d)\n", dev));
if (DISKUNIT(dev) > xbd_cd.cd_ndevs)
return (ENXIO);
sc = xbd_cd.cd_devs[DISKUNIT(dev)];
sc = device_lookup_private(&xbd_cd, DISKUNIT(dev));
if (sc == NULL || sc->sc_shutdown)
return -1;
return dk_size(sc->sc_di, &sc->sc_dksc, dev);
@ -601,7 +604,7 @@ xbdsize(dev_t dev)
int
xbdread(dev_t dev, struct uio *uio, int flags)
{
struct xbd_xenbus_softc *sc = xbd_cd.cd_devs[DISKUNIT(dev)];
struct xbd_xenbus_softc *sc = device_lookup_private(&xbd_cd, DISKUNIT(dev));
struct dk_softc *dksc = &sc->sc_dksc;
if ((dksc->sc_flags & DKF_INITED) == 0)
@ -612,7 +615,7 @@ xbdread(dev_t dev, struct uio *uio, int flags)
int
xbdwrite(dev_t dev, struct uio *uio, int flags)
{
struct xbd_xenbus_softc *sc = xbd_cd.cd_devs[DISKUNIT(dev)];
struct xbd_xenbus_softc *sc = device_lookup_private(&xbd_cd, DISKUNIT(dev));
struct dk_softc *dksc = &sc->sc_dksc;
if ((dksc->sc_flags & DKF_INITED) == 0)
@ -625,7 +628,7 @@ xbdwrite(dev_t dev, struct uio *uio, int flags)
int
xbdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
{
struct xbd_xenbus_softc *sc = xbd_cd.cd_devs[DISKUNIT(dev)];
struct xbd_xenbus_softc *sc = device_lookup_private(&xbd_cd, DISKUNIT(dev));
struct dk_softc *dksc;
int error;
struct disk *dk;
@ -650,7 +653,7 @@ xbdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
int
xbddump(dev_t dev, daddr_t blkno, void *va, size_t size)
{
struct xbd_xenbus_softc *sc = xbd_cd.cd_devs[DISKUNIT(dev)];
struct xbd_xenbus_softc *sc = device_lookup_private(&xbd_cd, DISKUNIT(dev));
if (DISKUNIT(dev) > xbd_cd.cd_ndevs)
return (ENXIO);
@ -666,7 +669,7 @@ xbddump(dev_t dev, daddr_t blkno, void *va, size_t size)
static int
xbdstart(struct dk_softc *dksc, struct buf *bp)
{
struct xbd_xenbus_softc *sc = xbd_cd.cd_devs[DISKUNIT(bp->b_dev)];
struct xbd_xenbus_softc *sc;
struct xbd_req *xbdreq;
blkif_request_t *req;
int ret = 0, runqueue = 1;
@ -678,7 +681,7 @@ xbdstart(struct dk_softc *dksc, struct buf *bp)
DPRINTF(("xbdstart(%p): b_bcount = %ld\n", bp, (long)bp->b_bcount));
sc = device_lookup_private(&xbd_cd, DISKUNIT(bp->b_dev));
if (sc == NULL || sc->sc_shutdown) {
bp->b_error = EIO;
goto err;

View File

@ -1,4 +1,4 @@
/* $NetBSD: xbdback.c,v 1.31 2008/03/22 14:21:56 ad Exp $ */
/* $NetBSD: xbdback.c,v 1.32 2008/04/16 18:41:48 cegger Exp $ */
/*
* Copyright (c) 2005 Manuel Bouyer.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xbdback.c,v 1.31 2008/03/22 14:21:56 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: xbdback.c,v 1.32 2008/04/16 18:41:48 cegger Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -263,7 +263,7 @@ static void xbdback_trampoline(struct xbdback_instance *, void *);
void
xbdback_init()
xbdback_init(void)
{
ctrl_msg_t cmsg;
blkif_be_driver_status_t st;

View File

@ -1,4 +1,4 @@
/* $NetBSD: xencons.c,v 1.26 2008/04/06 07:24:20 cegger Exp $ */
/* $NetBSD: xencons.c,v 1.27 2008/04/16 18:41:48 cegger Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@ -63,7 +63,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.26 2008/04/06 07:24:20 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.27 2008/04/16 18:41:48 cegger Exp $");
#include "opt_xen.h"
@ -108,14 +108,14 @@ static struct xencons_softc *xencons_console_device = NULL;
#define XENCONS_UNIT(x) (minor(x))
#define XENCONS_BURST 128
int xencons_match (struct device *, struct cfdata *, void *);
void xencons_attach (struct device *, struct device *, void *);
int xencons_intr (void *);
int xencons_match(device_t, cfdata_t, void *);
void xencons_attach(device_t, device_t, void *);
int xencons_intr(void *);
void xencons_tty_input(struct xencons_softc *, char*, int);
struct xencons_softc {
struct device sc_dev;
device_t sc_dev;
struct tty *sc_tty;
int polling;
#ifndef XEN3
@ -129,7 +129,7 @@ struct xencons_softc {
volatile struct xencons_interface *xencons_interface;
#endif
CFATTACH_DECL(xencons, sizeof(struct xencons_softc),
CFATTACH_DECL_NEW(xencons, sizeof(struct xencons_softc),
xencons_match, xencons_attach, NULL, NULL);
extern struct cfdriver xencons_cd;
@ -170,7 +170,7 @@ void xencons_start (struct tty *);
int xencons_param (struct tty *, struct termios *);
int
xencons_match(struct device *parent, struct cfdata *match, void *aux)
xencons_match(device_t parent, cfdata_t match, void *aux)
{
struct xencons_attach_args *xa = (struct xencons_attach_args *)aux;
@ -180,12 +180,13 @@ xencons_match(struct device *parent, struct cfdata *match, void *aux)
}
void
xencons_attach(struct device *parent, struct device *self, void *aux)
xencons_attach(device_t parent, device_t self, void *aux)
{
struct xencons_softc *sc = (void *)self;
struct xencons_softc *sc = device_private(self);
aprint_normal(": Xen Virtual Console Driver\n");
sc->sc_dev = self;
sc->sc_tty = ttymalloc();
tty_attach(sc->sc_tty);
sc->sc_tty->t_oproc = xencons_start;
@ -198,10 +199,10 @@ xencons_attach(struct device *parent, struct device *self, void *aux)
maj = cdevsw_lookup_major(&xencons_cdevsw);
/* There can be only one, but it can have any unit number. */
cn_tab->cn_dev = makedev(maj, device_unit(&sc->sc_dev));
cn_tab->cn_dev = makedev(maj, device_unit(self));
aprint_verbose_dev(&sc->sc_dev, "console major %d, unit %d\n",
maj, device_unit(&sc->sc_dev));
aprint_verbose_dev(self, "console major %d, unit %d\n",
maj, device_unit(self));
sc->sc_tty->t_dev = cn_tab->cn_dev;
@ -212,7 +213,7 @@ xencons_attach(struct device *parent, struct device *self, void *aux)
if (xen_start_info.flags & SIF_INITDOMAIN) {
int evtch = bind_virq_to_evtch(VIRQ_CONSOLE);
aprint_verbose_dev(&sc->sc_dev, "using event channel %d\n",
aprint_verbose_dev(self, "using event channel %d\n",
evtch);
if (event_set_handler(evtch, xencons_intr, sc,
IPL_TTY, "xencons") != 0)
@ -222,7 +223,7 @@ xencons_attach(struct device *parent, struct device *self, void *aux)
} else {
#ifdef XEN3
printf("%s: using event channel %d\n",
device_xname(&sc->sc_dev), xen_start_info.console_evtchn);
device_xname(self), xen_start_info.console_evtchn);
event_set_handler(xen_start_info.console_evtchn,
xencons_handler, sc, IPL_TTY, "xencons");
hypervisor_enable_event(xen_start_info.console_evtchn);
@ -240,10 +241,9 @@ int
xencons_open(dev_t dev, int flag, int mode, struct lwp *l)
{
struct xencons_softc *sc;
int unit = XENCONS_UNIT(dev);
struct tty *tp;
sc = device_lookup(&xencons_cd, unit);
sc = device_lookup_private(&xencons_cd, XENCONS_UNIT(dev));
if (sc == NULL)
return (ENXIO);
@ -271,7 +271,7 @@ xencons_open(dev_t dev, int flag, int mode, struct lwp *l)
int
xencons_close(dev_t dev, int flag, int mode, struct lwp *l)
{
struct xencons_softc *sc = device_lookup(&xencons_cd,
struct xencons_softc *sc = device_lookup_private(&xencons_cd,
XENCONS_UNIT(dev));
struct tty *tp = sc->sc_tty;
@ -288,7 +288,7 @@ xencons_close(dev_t dev, int flag, int mode, struct lwp *l)
int
xencons_read(dev_t dev, struct uio *uio, int flag)
{
struct xencons_softc *sc = device_lookup(&xencons_cd,
struct xencons_softc *sc = device_lookup_private(&xencons_cd,
XENCONS_UNIT(dev));
struct tty *tp = sc->sc_tty;
@ -298,7 +298,7 @@ xencons_read(dev_t dev, struct uio *uio, int flag)
int
xencons_write(dev_t dev, struct uio *uio, int flag)
{
struct xencons_softc *sc = device_lookup(&xencons_cd,
struct xencons_softc *sc = device_lookup_private(&xencons_cd,
XENCONS_UNIT(dev));
struct tty *tp = sc->sc_tty;
@ -308,7 +308,7 @@ xencons_write(dev_t dev, struct uio *uio, int flag)
int
xencons_poll(dev_t dev, int events, struct lwp *l)
{
struct xencons_softc *sc = device_lookup(&xencons_cd,
struct xencons_softc *sc = device_lookup_private(&xencons_cd,
XENCONS_UNIT(dev));
struct tty *tp = sc->sc_tty;
@ -318,7 +318,7 @@ xencons_poll(dev_t dev, int events, struct lwp *l)
struct tty *
xencons_tty(dev_t dev)
{
struct xencons_softc *sc = device_lookup(&xencons_cd,
struct xencons_softc *sc = device_lookup_private(&xencons_cd,
XENCONS_UNIT(dev));
struct tty *tp = sc->sc_tty;
@ -328,7 +328,7 @@ xencons_tty(dev_t dev)
int
xencons_ioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
{
struct xencons_softc *sc = device_lookup(&xencons_cd,
struct xencons_softc *sc = device_lookup_private(&xencons_cd,
XENCONS_UNIT(dev));
struct tty *tp = sc->sc_tty;
int error;
@ -498,7 +498,7 @@ xencons_rx(ctrl_msg_t *msg, unsigned long id)
// unsigned long flags;
struct xencons_softc *sc;
sc = device_lookup(&xencons_cd, XENCONS_UNIT(cn_tab->cn_dev));
sc = device_lookup_private(&xencons_cd, XENCONS_UNIT(cn_tab->cn_dev));
if (sc == NULL)
goto out2;

View File

@ -1,4 +1,4 @@
/* $NetBSD: xenbus_comms.c,v 1.6 2008/04/06 07:24:20 cegger Exp $ */
/* $NetBSD: xenbus_comms.c,v 1.7 2008/04/16 18:41:48 cegger Exp $ */
/******************************************************************************
* xenbus_comms.c
*
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xenbus_comms.c,v 1.6 2008/04/06 07:24:20 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: xenbus_comms.c,v 1.7 2008/04/16 18:41:48 cegger Exp $");
#include <sys/types.h>
#include <sys/null.h>
@ -217,7 +217,7 @@ xb_read(void *data, unsigned len)
/* Set up interrupt handler off store event channel. */
int
xb_init_comms(struct device *dev)
xb_init_comms(device_t dev)
{
int err;

View File

@ -1,4 +1,4 @@
/* $NetBSD: xenbus_comms.h,v 1.3 2006/04/09 21:39:42 bouyer Exp $ */
/* $NetBSD: xenbus_comms.h,v 1.4 2008/04/16 18:41:48 cegger Exp $ */
/*
* Private include for xenbus communications.
*
@ -31,7 +31,7 @@
void xenbus_kernfs_init(void);
int xs_init(void);
int xb_init_comms(struct device *dev);
int xb_init_comms(device_t dev);
/* Low level routines. */
int xb_write(const void *data, unsigned len);

View File

@ -1,4 +1,4 @@
/* $NetBSD: xenbus_probe.c,v 1.19 2008/04/06 07:24:20 cegger Exp $ */
/* $NetBSD: xenbus_probe.c,v 1.20 2008/04/16 18:41:48 cegger Exp $ */
/******************************************************************************
* Talks to Xen Store to figure out what devices we have.
*
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.19 2008/04/06 07:24:20 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.20 2008/04/16 18:41:48 cegger Exp $");
#if 0
#define DPRINTK(fmt, args...) \
@ -60,25 +60,25 @@ extern struct semaphore xenwatch_mutex;
#define streq(a, b) (strcmp((a), (b)) == 0)
static int xenbus_match(struct device *, struct cfdata *, void *);
static void xenbus_attach(struct device *, struct device *, void *);
static int xenbus_match(device_t, cfdata_t, void *);
static void xenbus_attach(device_t, device_t, void *);
static int xenbus_print(void *, const char *);
static void xenbus_probe_init(void *);
static struct xenbus_device *xenbus_lookup_device_path(const char *);
CFATTACH_DECL(xenbus, sizeof(struct device), xenbus_match, xenbus_attach,
CFATTACH_DECL_NEW(xenbus, 0, xenbus_match, xenbus_attach,
NULL, NULL);
struct device *xenbus_sc;
device_t xenbus_sc;
SLIST_HEAD(, xenbus_device) xenbus_device_list;
SLIST_HEAD(, xenbus_backend_driver) xenbus_backend_driver_list =
SLIST_HEAD_INITIALIZER(xenbus_backend_driver);
int
xenbus_match(struct device *parent, struct cfdata *match, void *aux)
xenbus_match(device_t parent, cfdata_t match, void *aux)
{
struct xenbus_attach_args *xa = (struct xenbus_attach_args *)aux;
@ -88,7 +88,7 @@ xenbus_match(struct device *parent, struct cfdata *match, void *aux)
}
static void
xenbus_attach(struct device *parent, struct device *self, void *aux)
xenbus_attach(device_t parent, device_t self, void *aux)
{
int err;
@ -556,7 +556,7 @@ xenbus_probe_init(void *unused)
}
/* register event handler */
xb_init_comms((struct device *)xenbus_sc);
xb_init_comms(xenbus_sc);
/* Initialize the interface to xenstore. */
err = xs_init();