# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1212667411 -3600
# Node ID 49a0d28a16e0d64c901b5d0f45f0e804de21b985
# Parent 31a941632a5db6ea91325a13d875e714918ac428
minios: add a blkfront synchronous interface
Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
---
extras/mini-os/blkfront.c | 35 +++++++++++++++++++++++++++--------
extras/mini-os/include/blkfront.h | 7 +++++--
2 files changed, 32 insertions(+), 10 deletions(-)
diff -r 31a941632a5d -r 49a0d28a16e0 extras/mini-os/blkfront.c
--- a/extras/mini-os/blkfront.c Thu Jun 05 10:47:08 2008 +0100
+++ b/extras/mini-os/blkfront.c Thu Jun 05 13:03:31 2008 +0100
@@ -323,14 +323,33 @@ void blkfront_aio(struct blkfront_aiocb
if(notify) notify_remote_via_evtchn(dev->evtchn);
}
-void blkfront_aio_write(struct blkfront_aiocb *aiocbp)
-{
- blkfront_aio(aiocbp, 1);
-}
-
-void blkfront_aio_read(struct blkfront_aiocb *aiocbp)
-{
- blkfront_aio(aiocbp, 0);
+static void blkfront_aio_cb(struct blkfront_aiocb *aiocbp, int ret)
+{
+ aiocbp->data = (void*) 1;
+}
+
+void blkfront_io(struct blkfront_aiocb *aiocbp, int write)
+{
+ unsigned long flags;
+ ASSERT(!aiocbp->aio_cb);
+ aiocbp->aio_cb = blkfront_aio_cb;
+ blkfront_aio(aiocbp, write);
+ aiocbp->data = NULL;
+
+ local_irq_save(flags);
+ DEFINE_WAIT(w);
+ while (1) {
+ blkfront_aio_poll(aiocbp->aio_dev);
+ if (aiocbp->data)
+ break;
+
+ add_waiter(w, blkfront_queue);
+ local_irq_restore(flags);
+ schedule();
+ local_irq_save(flags);
+ }
+ remove_waiter(w);
+ local_irq_restore(flags);
}
static void blkfront_push_operation(struct blkfront_dev *dev, uint8_t op,
uint64_t id)
diff -r 31a941632a5d -r 49a0d28a16e0 extras/mini-os/include/blkfront.h
--- a/extras/mini-os/include/blkfront.h Thu Jun 05 10:47:08 2008 +0100
+++ b/extras/mini-os/include/blkfront.h Thu Jun 05 13:03:31 2008 +0100
@@ -29,8 +29,11 @@ int blkfront_open(struct blkfront_dev *d
int blkfront_open(struct blkfront_dev *dev);
#endif
void blkfront_aio(struct blkfront_aiocb *aiocbp, int write);
-void blkfront_aio_read(struct blkfront_aiocb *aiocbp);
-void blkfront_aio_write(struct blkfront_aiocb *aiocbp);
+#define blkfront_aio_read(aiocbp) blkfront_aio(aiocbp, 0)
+#define blkfront_aio_write(aiocbp) blkfront_aio(aiocbp, 1)
+void blkfront_io(struct blkfront_aiocb *aiocbp, int write);
+#define blkfront_read(aiocbp) blkfront_io(aiocbp, 0)
+#define blkfront_write(aiocbp) blkfront_io(aiocbp, 1)
void blkfront_aio_push_operation(struct blkfront_aiocb *aiocbp, uint8_t op);
int blkfront_aio_poll(struct blkfront_dev *dev);
void blkfront_sync(struct blkfront_dev *dev);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|