This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / xen / interface / io / kbdif.h
1 /*
2  * kbdif.h -- Xen virtual keyboard/mouse
3  *
4  * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com>
5  * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com>
6  *
7  *  This file is subject to the terms and conditions of the GNU General Public
8  *  License. See the file COPYING in the main directory of this archive for
9  *  more details.
10  */
11
12 #ifndef __XEN_PUBLIC_IO_KBDIF_H__
13 #define __XEN_PUBLIC_IO_KBDIF_H__
14
15 #include <asm/types.h>
16
17 /* In events (backend -> frontend) */
18
19 /*
20  * Frontends should ignore unknown in events.
21  */
22
23 /* Pointer movement event */
24 #define XENKBD_TYPE_MOTION  1
25 /* Event type 2 currently not used */
26 /* Key event (includes pointer buttons) */
27 #define XENKBD_TYPE_KEY     3
28 /*
29  * Pointer position event
30  * Capable backend sets feature-abs-pointer in xenstore.
31  * Frontend requests ot instead of XENKBD_TYPE_MOTION by setting
32  * request-abs-update in xenstore.
33  */
34 #define XENKBD_TYPE_POS     4
35
36 struct xenkbd_motion
37 {
38         __u8 type;         /* XENKBD_TYPE_MOTION */
39         __s32 rel_x;       /* relative X motion */
40         __s32 rel_y;       /* relative Y motion */
41 };
42
43 struct xenkbd_key
44 {
45         __u8 type;         /* XENKBD_TYPE_KEY */
46         __u8 pressed;      /* 1 if pressed; 0 otherwise */
47         __u32 keycode;     /* KEY_* from linux/input.h */
48 };
49
50 struct xenkbd_position
51 {
52         __u8 type;         /* XENKBD_TYPE_POS */
53         __s32 abs_x;       /* absolute X position (in FB pixels) */
54         __s32 abs_y;       /* absolute Y position (in FB pixels) */
55 };
56
57 #define XENKBD_IN_EVENT_SIZE 40
58
59 union xenkbd_in_event
60 {
61         __u8 type;
62         struct xenkbd_motion motion;
63         struct xenkbd_key key;
64         struct xenkbd_position pos;
65         char pad[XENKBD_IN_EVENT_SIZE];
66 };
67
68 /* Out events (frontend -> backend) */
69
70 /*
71  * Out events may be sent only when requested by backend, and receipt
72  * of an unknown out event is an error.
73  * No out events currently defined.
74  */
75
76 #define XENKBD_OUT_EVENT_SIZE 40
77
78 union xenkbd_out_event
79 {
80         __u8 type;
81         char pad[XENKBD_OUT_EVENT_SIZE];
82 };
83
84 /* shared page */
85
86 #define XENKBD_IN_RING_SIZE 2048
87 #define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE)
88 #define XENKBD_IN_RING_OFFS 1024
89 #define XENKBD_IN_RING(page) \
90     ((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS))
91 #define XENKBD_IN_RING_REF(page, idx) \
92     (XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN])
93
94 #define XENKBD_OUT_RING_SIZE 1024
95 #define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE)
96 #define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE)
97 #define XENKBD_OUT_RING(page) \
98     ((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS))
99 #define XENKBD_OUT_RING_REF(page, idx) \
100     (XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN])
101
102 struct xenkbd_page
103 {
104         __u32 in_cons, in_prod;
105         __u32 out_cons, out_prod;
106 };
107
108 #endif