Deleted Added
sdiff udiff text old ( 181643 ) new ( 181805 )
full compact
1/*-
2 * All rights reserved.
3 *
4 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
5 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
8 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL

--- 6 unchanged lines hidden (view full) ---

15 *
16 */
17
18/*
19 * XenoBSD block device driver
20 */
21
22#include <sys/cdefs.h>
23__FBSDID("$FreeBSD: head/sys/dev/xen/blkfront/blkfront.c 181643 2008-08-12 20:01:57Z kmacy $");
24
25#include <sys/param.h>
26#include <sys/systm.h>
27#include <sys/malloc.h>
28#include <sys/kernel.h>
29#include <vm/vm.h>
30#include <vm/pmap.h>
31

--- 92 unchanged lines hidden (view full) ---

124/* XXX move to xb_vbd.c when VBD update support is added */
125#define MAX_VBDS 64
126
127#define XBD_SECTOR_SIZE 512 /* XXX: assume for now */
128#define XBD_SECTOR_SHFT 9
129
130static struct mtx blkif_io_lock;
131
132static unsigned long
133pfn_to_mfn(unsigned long pfn)
134{
135 return (phystomach(pfn << PAGE_SHIFT) >> PAGE_SHIFT);
136}
137
138
139int
140xlvbd_add(blkif_sector_t capacity, int unit, uint16_t vdisk_info, uint16_t sector_size,
141 struct blkfront_info *info)

--- 94 unchanged lines hidden (view full) ---

236 int err, vdevice, i;
237 struct blkfront_info *info;
238
239 /* FIXME: Use dynamic device id if this is not set. */
240 err = xenbus_scanf(XBT_NIL, dev->nodename,
241 "virtual-device", "%i", &vdevice);
242 if (err != 1) {
243 xenbus_dev_fatal(dev, err, "reading virtual-device");
244 return err;
245 }
246
247 info = malloc(sizeof(*info), M_DEVBUF, M_NOWAIT|M_ZERO);
248 if (info == NULL) {
249 xenbus_dev_fatal(dev, ENOMEM, "allocating info structure");
250 return ENOMEM;
251 }
252

--- 402 unchanged lines hidden (view full) ---

655 * id: for guest use only.
656 * operation: BLKIF_OP_{READ,WRITE,PROBE}
657 * buffer: buffer to read/write into. this should be a
658 * virtual address in the guest os.
659 */
660static int blkif_queue_request(struct bio *bp)
661{
662 caddr_t alignbuf;
663 unsigned long buffer_ma;
664 blkif_request_t *ring_req;
665 unsigned long id;
666 unsigned int fsect, lsect;
667 struct xb_softc *sc = (struct xb_softc *)bp->bio_disk->d_drv1;
668 struct blkfront_info *info = sc->xb_info;
669 int ref;
670
671 if (unlikely(sc->xb_info->connected != BLKIF_STATE_CONNECTED))
672 return 1;
673
674 if (gnttab_alloc_grant_references(

--- 161 unchanged lines hidden (view full) ---

836
837 /* free the copy buffer */
838 if (bp->bio_driver1) {
839 free(bp->bio_driver1, M_DEVBUF);
840 bp->bio_driver1 = NULL;
841 }
842
843 if ( unlikely(bret->status != BLKIF_RSP_OKAY) ) {
844 XENPRINTF("Bad return from blkdev data request: %x\n",
845 bret->status);
846 bp->bio_flags |= BIO_ERROR;
847 }
848
849 sc = (struct xb_softc *)bp->bio_disk->d_drv1;
850
851 if (bp->bio_flags & BIO_ERROR)
852 bp->bio_error = EIO;

--- 169 unchanged lines hidden ---