This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / linux / xenkbd.h
1 /*
2  * linux/include/linux/xenkbd.h -- Xen virtual keyboard/mouse
3  *
4  * Copyright (C) 2005
5  *
6  *      Anthony Liguori <aliguori@us.ibm.com>
7  *
8  *  This file is subject to the terms and conditions of the GNU General Public
9  *  License. See the file COPYING in the main directory of this archive for
10  *  more details.
11  */
12
13 #ifndef _LINUX_XENKBD_H
14 #define _LINUX_XENKBD_H
15
16 #include <asm/types.h>
17
18 /* in events */
19
20 #define XENKBD_IN_EVENT_SIZE 40
21
22 #define XENKBD_TYPE_MOTION  1     /* mouse movement event */
23 #define XENKBD_TYPE_BUTTON  2     /* mouse button event */
24 #define XENKBD_TYPE_KEY     3     /* keyboard event */
25
26 struct xenkbd_motion
27 {
28         __u8 type;         /* XENKBD_TYPE_MOTION */
29         __s16 rel_x;       /* relative X motion */
30         __s16 rel_y;       /* relative Y motion */
31 };
32
33 struct xenkbd_button
34 {
35         __u8 type;         /* XENKBD_TYPE_BUTTON */
36         __u8 pressed;      /* 1 if pressed; 0 otherwise */
37         __u8 button;       /* the button (0, 1, 2 is right, middle, left) */
38 };
39
40 struct xenkbd_key
41 {
42         __u8 type;         /* XENKBD_TYPE_KEY */
43         __u8 pressed;      /* 1 if pressed; 0 otherwise */
44         __u16 keycode;     /* KEY_* from linux/input.h */
45 };
46
47 union xenkbd_in_event
48 {
49         __u8 type;
50         struct xenkbd_motion motion;
51         struct xenkbd_button button;
52         struct xenkbd_key key;
53         char _[XENKBD_IN_EVENT_SIZE];
54 };
55
56 /* out events */
57
58 #define XENKBD_OUT_EVENT_SIZE 40
59
60 union xenkbd_out_event
61 {
62         __u8 type;
63         char _[XENKBD_OUT_EVENT_SIZE];
64 };
65
66 /* shared page */
67
68 #define XENKBD_IN_RING_SIZE 2048
69 #define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE)
70 #define XENKBD_IN_RING_OFFS 1024
71 #define XENKBD_IN_RING(page) \
72     ((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS))
73 #define XENKBD_IN_RING_REF(page, idx) \
74     (XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN])
75
76 #define XENKBD_OUT_RING_SIZE 1024
77 #define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE)
78 #define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE)
79 #define XENKBD_OUT_RING(page) \
80     ((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS))
81 #define XENKBD_OUT_RING_REF(page, idx) \
82     (XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN])
83
84 struct xenkbd_info
85 {
86         __u32 in_cons, in_prod;
87         __u32 out_cons, out_prod;
88 };
89
90 void xenkbd_resume(void);
91
92 #endif