kbdif.h revision 181624
1181624Skmacy/* 2181624Skmacy * kbdif.h -- Xen virtual keyboard/mouse 3181624Skmacy * 4181624Skmacy * Permission is hereby granted, free of charge, to any person obtaining a copy 5181624Skmacy * of this software and associated documentation files (the "Software"), to 6181624Skmacy * deal in the Software without restriction, including without limitation the 7181624Skmacy * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8181624Skmacy * sell copies of the Software, and to permit persons to whom the Software is 9181624Skmacy * furnished to do so, subject to the following conditions: 10181624Skmacy * 11181624Skmacy * The above copyright notice and this permission notice shall be included in 12181624Skmacy * all copies or substantial portions of the Software. 13181624Skmacy * 14181624Skmacy * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15181624Skmacy * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16181624Skmacy * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17181624Skmacy * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18181624Skmacy * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19181624Skmacy * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20181624Skmacy * DEALINGS IN THE SOFTWARE. 21181624Skmacy * 22181624Skmacy * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com> 23181624Skmacy * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com> 24181624Skmacy */ 25181624Skmacy 26181624Skmacy#ifndef __XEN_PUBLIC_IO_KBDIF_H__ 27181624Skmacy#define __XEN_PUBLIC_IO_KBDIF_H__ 28181624Skmacy 29181624Skmacy/* In events (backend -> frontend) */ 30181624Skmacy 31181624Skmacy/* 32181624Skmacy * Frontends should ignore unknown in events. 33181624Skmacy */ 34181624Skmacy 35181624Skmacy/* Pointer movement event */ 36181624Skmacy#define XENKBD_TYPE_MOTION 1 37181624Skmacy/* Event type 2 currently not used */ 38181624Skmacy/* Key event (includes pointer buttons) */ 39181624Skmacy#define XENKBD_TYPE_KEY 3 40181624Skmacy/* 41181624Skmacy * Pointer position event 42181624Skmacy * Capable backend sets feature-abs-pointer in xenstore. 43181624Skmacy * Frontend requests ot instead of XENKBD_TYPE_MOTION by setting 44181624Skmacy * request-abs-update in xenstore. 45181624Skmacy */ 46181624Skmacy#define XENKBD_TYPE_POS 4 47181624Skmacy 48181624Skmacystruct xenkbd_motion 49181624Skmacy{ 50181624Skmacy uint8_t type; /* XENKBD_TYPE_MOTION */ 51181624Skmacy int32_t rel_x; /* relative X motion */ 52181624Skmacy int32_t rel_y; /* relative Y motion */ 53181624Skmacy}; 54181624Skmacy 55181624Skmacystruct xenkbd_key 56181624Skmacy{ 57181624Skmacy uint8_t type; /* XENKBD_TYPE_KEY */ 58181624Skmacy uint8_t pressed; /* 1 if pressed; 0 otherwise */ 59181624Skmacy uint32_t keycode; /* KEY_* from linux/input.h */ 60181624Skmacy}; 61181624Skmacy 62181624Skmacystruct xenkbd_position 63181624Skmacy{ 64181624Skmacy uint8_t type; /* XENKBD_TYPE_POS */ 65181624Skmacy int32_t abs_x; /* absolute X position (in FB pixels) */ 66181624Skmacy int32_t abs_y; /* absolute Y position (in FB pixels) */ 67181624Skmacy}; 68181624Skmacy 69181624Skmacy#define XENKBD_IN_EVENT_SIZE 40 70181624Skmacy 71181624Skmacyunion xenkbd_in_event 72181624Skmacy{ 73181624Skmacy uint8_t type; 74181624Skmacy struct xenkbd_motion motion; 75181624Skmacy struct xenkbd_key key; 76181624Skmacy struct xenkbd_position pos; 77181624Skmacy char pad[XENKBD_IN_EVENT_SIZE]; 78181624Skmacy}; 79181624Skmacy 80181624Skmacy/* Out events (frontend -> backend) */ 81181624Skmacy 82181624Skmacy/* 83181624Skmacy * Out events may be sent only when requested by backend, and receipt 84181624Skmacy * of an unknown out event is an error. 85181624Skmacy * No out events currently defined. 86181624Skmacy */ 87181624Skmacy 88181624Skmacy#define XENKBD_OUT_EVENT_SIZE 40 89181624Skmacy 90181624Skmacyunion xenkbd_out_event 91181624Skmacy{ 92181624Skmacy uint8_t type; 93181624Skmacy char pad[XENKBD_OUT_EVENT_SIZE]; 94181624Skmacy}; 95181624Skmacy 96181624Skmacy/* shared page */ 97181624Skmacy 98181624Skmacy#define XENKBD_IN_RING_SIZE 2048 99181624Skmacy#define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE) 100181624Skmacy#define XENKBD_IN_RING_OFFS 1024 101181624Skmacy#define XENKBD_IN_RING(page) \ 102181624Skmacy ((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS)) 103181624Skmacy#define XENKBD_IN_RING_REF(page, idx) \ 104181624Skmacy (XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN]) 105181624Skmacy 106181624Skmacy#define XENKBD_OUT_RING_SIZE 1024 107181624Skmacy#define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE) 108181624Skmacy#define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE) 109181624Skmacy#define XENKBD_OUT_RING(page) \ 110181624Skmacy ((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS)) 111181624Skmacy#define XENKBD_OUT_RING_REF(page, idx) \ 112181624Skmacy (XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN]) 113181624Skmacy 114181624Skmacystruct xenkbd_page 115181624Skmacy{ 116181624Skmacy uint32_t in_cons, in_prod; 117181624Skmacy uint32_t out_cons, out_prod; 118181624Skmacy}; 119181624Skmacy 120181624Skmacy#endif 121181624Skmacy 122181624Skmacy/* 123181624Skmacy * Local variables: 124181624Skmacy * mode: C 125181624Skmacy * c-set-style: "BSD" 126181624Skmacy * c-basic-offset: 4 127181624Skmacy * tab-width: 4 128181624Skmacy * indent-tabs-mode: nil 129181624Skmacy * End: 130181624Skmacy */ 131