Deleted Added
full compact
blkfront.c (181643) blkfront.c (181805)
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>
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 $");
23__FBSDID("$FreeBSD: head/sys/dev/xen/blkfront/blkfront.c 181805 2008-08-17 23:33:33Z 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
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)
132static vm_paddr_t
133pfn_to_mfn(vm_paddr_t 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");
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;
244 printf("couldn't find virtual device");
245 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;
246 }
247
248 info = malloc(sizeof(*info), M_DEVBUF, M_NOWAIT|M_ZERO);
249 if (info == NULL) {
250 xenbus_dev_fatal(dev, ENOMEM, "allocating info structure");
251 return ENOMEM;
252 }
253

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

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

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

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

--- 169 unchanged lines hidden ---