ia64/xen-unstable

changeset 17790:49a0d28a16e0

minios: add a blkfront synchronous interface

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 05 13:03:31 2008 +0100 (2008-06-05)
parents 31a941632a5d
children 9593ceb1470d
files extras/mini-os/blkfront.c extras/mini-os/include/blkfront.h
line diff
     1.1 --- a/extras/mini-os/blkfront.c	Thu Jun 05 10:47:08 2008 +0100
     1.2 +++ b/extras/mini-os/blkfront.c	Thu Jun 05 13:03:31 2008 +0100
     1.3 @@ -323,14 +323,33 @@ void blkfront_aio(struct blkfront_aiocb 
     1.4      if(notify) notify_remote_via_evtchn(dev->evtchn);
     1.5  }
     1.6  
     1.7 -void blkfront_aio_write(struct blkfront_aiocb *aiocbp)
     1.8 +static void blkfront_aio_cb(struct blkfront_aiocb *aiocbp, int ret)
     1.9  {
    1.10 -    blkfront_aio(aiocbp, 1);
    1.11 +    aiocbp->data = (void*) 1;
    1.12  }
    1.13  
    1.14 -void blkfront_aio_read(struct blkfront_aiocb *aiocbp)
    1.15 +void blkfront_io(struct blkfront_aiocb *aiocbp, int write)
    1.16  {
    1.17 -    blkfront_aio(aiocbp, 0);
    1.18 +    unsigned long flags;
    1.19 +    ASSERT(!aiocbp->aio_cb);
    1.20 +    aiocbp->aio_cb = blkfront_aio_cb;
    1.21 +    blkfront_aio(aiocbp, write);
    1.22 +    aiocbp->data = NULL;
    1.23 +
    1.24 +    local_irq_save(flags);
    1.25 +    DEFINE_WAIT(w);
    1.26 +    while (1) {
    1.27 +	blkfront_aio_poll(aiocbp->aio_dev);
    1.28 +	if (aiocbp->data)
    1.29 +	    break;
    1.30 +
    1.31 +	add_waiter(w, blkfront_queue);
    1.32 +	local_irq_restore(flags);
    1.33 +	schedule();
    1.34 +	local_irq_save(flags);
    1.35 +    }
    1.36 +    remove_waiter(w);
    1.37 +    local_irq_restore(flags);
    1.38  }
    1.39  
    1.40  static void blkfront_push_operation(struct blkfront_dev *dev, uint8_t op, uint64_t id)
     2.1 --- a/extras/mini-os/include/blkfront.h	Thu Jun 05 10:47:08 2008 +0100
     2.2 +++ b/extras/mini-os/include/blkfront.h	Thu Jun 05 13:03:31 2008 +0100
     2.3 @@ -29,8 +29,11 @@ struct blkfront_dev *init_blkfront(char 
     2.4  int blkfront_open(struct blkfront_dev *dev);
     2.5  #endif
     2.6  void blkfront_aio(struct blkfront_aiocb *aiocbp, int write);
     2.7 -void blkfront_aio_read(struct blkfront_aiocb *aiocbp);
     2.8 -void blkfront_aio_write(struct blkfront_aiocb *aiocbp);
     2.9 +#define blkfront_aio_read(aiocbp) blkfront_aio(aiocbp, 0)
    2.10 +#define blkfront_aio_write(aiocbp) blkfront_aio(aiocbp, 1)
    2.11 +void blkfront_io(struct blkfront_aiocb *aiocbp, int write);
    2.12 +#define blkfront_read(aiocbp) blkfront_io(aiocbp, 0)
    2.13 +#define blkfront_write(aiocbp) blkfront_io(aiocbp, 1)
    2.14  void blkfront_aio_push_operation(struct blkfront_aiocb *aiocbp, uint8_t op);
    2.15  int blkfront_aio_poll(struct blkfront_dev *dev);
    2.16  void blkfront_sync(struct blkfront_dev *dev);