version 1.6.4.3, 2016/07/09 20:25:04 |
version 1.6.4.4, 2016/10/05 20:55:43 |
Line 32 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 32 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <sys/systm.h> |
#include <sys/systm.h> |
#include <sys/kernel.h> |
#include <sys/kernel.h> |
#include <sys/buf.h> |
#include <sys/buf.h> |
|
#include <sys/bufq.h> |
#include <sys/bus.h> |
#include <sys/bus.h> |
#include <sys/device.h> |
#include <sys/device.h> |
#include <sys/disk.h> |
#include <sys/disk.h> |
#include <sys/mutex.h> |
#include <sys/mutex.h> |
|
#include <sys/module.h> |
|
|
#include <dev/pci/pcidevs.h> |
#include <dev/pci/pcidevs.h> |
#include <dev/pci/pcireg.h> |
#include <dev/pci/pcireg.h> |
Line 45 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 47 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <dev/pci/virtioreg.h> |
#include <dev/pci/virtioreg.h> |
#include <dev/pci/virtiovar.h> |
#include <dev/pci/virtiovar.h> |
|
|
|
#include "ioconf.h" |
|
|
/* |
/* |
* ld_virtioreg: |
* ld_virtioreg: |
*/ |
*/ |
Line 67 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 71 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#define VIRTIO_BLK_F_SCSI (1<<7) |
#define VIRTIO_BLK_F_SCSI (1<<7) |
#define VIRTIO_BLK_F_FLUSH (1<<9) |
#define VIRTIO_BLK_F_FLUSH (1<<9) |
|
|
/* |
/* |
* Each block request uses at least two segments - one for the header |
* Each block request uses at least two segments - one for the header |
* and one for the status. |
* and one for the status. |
*/ |
*/ |
#define VIRTIO_BLK_MIN_SEGMENTS 2 |
#define VIRTIO_BLK_MIN_SEGMENTS 2 |
|
|
#define VIRTIO_BLK_FLAG_BITS \ |
#define VIRTIO_BLK_FLAG_BITS \ |
Line 350 ld_virtio_attach(device_t parent, device |
|
Line 354 ld_virtio_attach(device_t parent, device |
|
ld->sc_start = ld_virtio_start; |
ld->sc_start = ld_virtio_start; |
|
|
ld->sc_flags = LDF_ENABLED; |
ld->sc_flags = LDF_ENABLED; |
ldattach(ld); |
ldattach(ld, BUFQ_DISK_DEFAULT_STRAT); |
|
|
return; |
return; |
|
|
Line 509 ld_virtio_dump(struct ld_softc *ld, void |
|
Line 513 ld_virtio_dump(struct ld_softc *ld, void |
|
if (r != 0) |
if (r != 0) |
return r; |
return r; |
|
|
r = virtio_enqueue_reserve(vsc, vq, slot, vr->vr_payload->dm_nsegs + |
r = virtio_enqueue_reserve(vsc, vq, slot, vr->vr_payload->dm_nsegs + |
VIRTIO_BLK_MIN_SEGMENTS); |
VIRTIO_BLK_MIN_SEGMENTS); |
if (r != 0) { |
if (r != 0) { |
bus_dmamap_unload(vsc->sc_dmat, vr->vr_payload); |
bus_dmamap_unload(vsc->sc_dmat, vr->vr_payload); |
Line 554 ld_virtio_dump(struct ld_softc *ld, void |
|
Line 558 ld_virtio_dump(struct ld_softc *ld, void |
|
} else |
} else |
break; |
break; |
} |
} |
|
|
bus_dmamap_sync(vsc->sc_dmat, vr->vr_cmdsts, |
bus_dmamap_sync(vsc->sc_dmat, vr->vr_cmdsts, |
0, sizeof(struct virtio_blk_req_hdr), |
0, sizeof(struct virtio_blk_req_hdr), |
BUS_DMASYNC_POSTWRITE); |
BUS_DMASYNC_POSTWRITE); |
Line 603 ld_virtio_detach(device_t self, int flag |
|
Line 607 ld_virtio_detach(device_t self, int flag |
|
|
|
return 0; |
return 0; |
} |
} |
|
|
|
MODULE(MODULE_CLASS_DRIVER, ld_virtio, "ld,virtio"); |
|
|
|
#ifdef _MODULE |
|
/* |
|
* XXX Don't allow ioconf.c to redefine the "struct cfdriver ld_cd" |
|
* XXX it will be defined in the common-code module |
|
*/ |
|
#undef CFDRIVER_DECL |
|
#define CFDRIVER_DECL(name, class, attr) |
|
#include "ioconf.c" |
|
#endif |
|
|
|
static int |
|
ld_virtio_modcmd(modcmd_t cmd, void *opaque) |
|
{ |
|
#ifdef _MODULE |
|
/* |
|
* We ignore the cfdriver_vec[] that ioconf provides, since |
|
* the cfdrivers are attached already. |
|
*/ |
|
static struct cfdriver * const no_cfdriver_vec[] = { NULL }; |
|
#endif |
|
int error = 0; |
|
|
|
#ifdef _MODULE |
|
switch (cmd) { |
|
case MODULE_CMD_INIT: |
|
error = config_init_component(no_cfdriver_vec, |
|
cfattach_ioconf_ld_virtio, cfdata_ioconf_ld_virtio); |
|
break; |
|
case MODULE_CMD_FINI: |
|
error = config_fini_component(no_cfdriver_vec, |
|
cfattach_ioconf_ld_virtio, cfdata_ioconf_ld_virtio); |
|
break; |
|
default: |
|
error = ENOTTY; |
|
break; |
|
} |
|
#endif |
|
|
|
return error; |
|
} |