ia64/xen-unstable

view tools/blktap/parallax/block-async.h @ 6552:a9873d384da4

Merge.
author adsharma@los-vmm.sc.intel.com
date Thu Aug 25 12:24:48 2005 -0700 (2005-08-25)
parents 112d44270733 f8acd354e129
children dfaf788ab18c
line source
1 /* block-async.h
2 *
3 * Asynchronous block wrappers for parallax.
4 */
6 #ifndef _BLOCKASYNC_H_
7 #define _BLOCKASYNC_H_
9 #include <assert.h>
10 #include <xenctrl.h>
11 #include "vdi.h"
13 struct io_ret
14 {
15 enum {IO_ADDR_T, IO_BLOCK_T, IO_INT_T} type;
16 union {
17 u64 a;
18 char *b;
19 int i;
20 } u;
21 };
23 typedef void (*io_cb_t)(struct io_ret r, void *param);
25 /* per-vdi lock structures to make sure requests run in a safe order. */
26 struct radix_wait {
27 enum {RLOCK, WLOCK} type;
28 io_cb_t cb;
29 void *param;
30 struct radix_wait *next;
31 };
33 struct radix_lock {
34 pthread_mutex_t lock;
35 int lines[1024];
36 struct radix_wait *waiters[1024];
37 enum {ANY, READ, STOP} state[1024];
38 };
39 void radix_lock_init(struct radix_lock *r);
41 void block_read(u64 addr, io_cb_t cb, void *param);
42 void block_write(u64 addr, char *block, io_cb_t cb, void *param);
43 void block_alloc(char *block, io_cb_t cb, void *param);
44 void block_rlock(struct radix_lock *r, int row, io_cb_t cb, void *param);
45 void block_wlock(struct radix_lock *r, int row, io_cb_t cb, void *param);
46 void block_runlock(struct radix_lock *r, int row, io_cb_t cb, void *param);
47 void block_wunlock(struct radix_lock *r, int row, io_cb_t cb, void *param);
48 void init_block_async(void);
50 static inline u64 IO_ADDR(struct io_ret r)
51 {
52 assert(r.type == IO_ADDR_T);
53 return r.u.a;
54 }
56 static inline char *IO_BLOCK(struct io_ret r)
57 {
58 assert(r.type == IO_BLOCK_T);
59 return r.u.b;
60 }
62 static inline int IO_INT(struct io_ret r)
63 {
64 assert(r.type == IO_INT_T);
65 return r.u.i;
66 }
69 #endif //_BLOCKASYNC_H_