ia64/xen-unstable

view tools/blktap/blktaplib.h @ 6435:b4b3f6be5226

merge?
author cl349@firebug.cl.cam.ac.uk
date Thu Aug 25 17:27:49 2005 +0000 (2005-08-25)
parents 0610add7c3fe 6e899a3840b2
children 8799d14bef77 9312a3e8a6f8
line source
1 /* blktaplib.h
2 *
3 * userland accessors to the block tap.
4 *
5 */
7 #ifndef __BLKTAPLIB_H__
8 #define __BLKTAPLIB_H__
10 #include <xenctrl.h>
11 #include <sys/user.h>
12 #include <xen/xen.h>
13 #include <xen/io/blkif.h>
14 #include <xen/io/ring.h>
15 #include <xen/io/domain_controller.h>
17 /* /dev/xen/blktap resides at device number major=10, minor=202 */
18 #define BLKTAP_MINOR 202
20 /* size of the extra VMA area to map in attached pages. */
21 #define BLKTAP_VMA_PAGES BLKIF_RING_SIZE
23 /* blktap IOCTLs: */
24 #define BLKTAP_IOCTL_KICK_FE 1
25 #define BLKTAP_IOCTL_KICK_BE 2
26 #define BLKTAP_IOCTL_SETMODE 3
27 #define BLKTAP_IOCTL_PRINT_IDXS 100
29 /* blktap switching modes: (Set with BLKTAP_IOCTL_SETMODE) */
30 #define BLKTAP_MODE_PASSTHROUGH 0x00000000 /* default */
31 #define BLKTAP_MODE_INTERCEPT_FE 0x00000001
32 #define BLKTAP_MODE_INTERCEPT_BE 0x00000002
33 #define BLKTAP_MODE_COPY_FE 0x00000004
34 #define BLKTAP_MODE_COPY_BE 0x00000008
35 #define BLKTAP_MODE_COPY_FE_PAGES 0x00000010
36 #define BLKTAP_MODE_COPY_BE_PAGES 0x00000020
38 #define BLKTAP_MODE_INTERPOSE \
39 (BLKTAP_MODE_INTERCEPT_FE | BLKTAP_MODE_INTERCEPT_BE)
41 #define BLKTAP_MODE_COPY_BOTH \
42 (BLKTAP_MODE_COPY_FE | BLKTAP_MODE_COPY_BE)
44 #define BLKTAP_MODE_COPY_BOTH_PAGES \
45 (BLKTAP_MODE_COPY_FE_PAGES | BLKTAP_MODE_COPY_BE_PAGES)
47 static inline int BLKTAP_MODE_VALID(unsigned long arg)
48 {
49 return (
50 ( arg == BLKTAP_MODE_PASSTHROUGH ) ||
51 ( arg == BLKTAP_MODE_INTERCEPT_FE ) ||
52 ( arg == BLKTAP_MODE_INTERCEPT_BE ) ||
53 ( arg == BLKTAP_MODE_INTERPOSE ) ||
54 ( (arg & ~BLKTAP_MODE_COPY_FE_PAGES) == BLKTAP_MODE_COPY_FE ) ||
55 ( (arg & ~BLKTAP_MODE_COPY_BE_PAGES) == BLKTAP_MODE_COPY_BE ) ||
56 ( (arg & ~BLKTAP_MODE_COPY_BOTH_PAGES) == BLKTAP_MODE_COPY_BOTH )
57 );
58 }
60 /* Return values for handling messages in hooks. */
61 #define BLKTAP_PASS 0 /* Keep passing this request as normal. */
62 #define BLKTAP_RESPOND 1 /* Request is now a reply. Return it. */
63 #define BLKTAP_STOLEN 2 /* Hook has stolen request. */
65 #define domid_t unsigned short
67 inline unsigned int ID_TO_IDX(unsigned long id);
68 inline domid_t ID_TO_DOM(unsigned long id);
70 void blktap_register_ctrl_hook(char *name, int (*ch)(control_msg_t *));
71 void blktap_register_request_hook(char *name, int (*rh)(blkif_request_t *));
72 void blktap_register_response_hook(char *name, int (*rh)(blkif_response_t *));
73 void blktap_inject_response(blkif_response_t *);
74 int blktap_attach_poll(int fd, short events, int (*func)(int));
75 void blktap_detach_poll(int fd);
76 int blktap_listen(void);
78 /* Accessing attached data page mappings */
79 #define MMAP_PAGES_PER_REQUEST \
80 (BLKIF_MAX_SEGMENTS_PER_REQUEST + 1)
81 #define MMAP_VADDR(_req,_seg) \
82 (mmap_vstart + \
83 ((_req) * MMAP_PAGES_PER_REQUEST * PAGE_SIZE) + \
84 ((_seg) * PAGE_SIZE))
86 extern unsigned long mmap_vstart;
89 /* Defines that are only used by library clients */
91 #ifndef __COMPILING_BLKTAP_LIB
93 static char *blkif_op_name[] = {
94 [BLKIF_OP_READ] = "READ",
95 [BLKIF_OP_WRITE] = "WRITE",
96 [BLKIF_OP_PROBE] = "PROBE",
97 };
99 #endif /* __COMPILING_BLKTAP_LIB */
101 #endif /* __BLKTAPLIB_H__ */