Path: blob/master/include/xen/interface/io/kbdif.h
10818 views
/*1* kbdif.h -- Xen virtual keyboard/mouse2*3* Permission is hereby granted, free of charge, to any person obtaining a copy4* of this software and associated documentation files (the "Software"), to5* deal in the Software without restriction, including without limitation the6* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or7* sell copies of the Software, and to permit persons to whom the Software is8* furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE16* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING18* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER19* DEALINGS IN THE SOFTWARE.20*21* Copyright (C) 2005 Anthony Liguori <[email protected]>22* Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <[email protected]>23*/2425#ifndef __XEN_PUBLIC_IO_KBDIF_H__26#define __XEN_PUBLIC_IO_KBDIF_H__2728/* In events (backend -> frontend) */2930/*31* Frontends should ignore unknown in events.32*/3334/* Pointer movement event */35#define XENKBD_TYPE_MOTION 136/* Event type 2 currently not used */37/* Key event (includes pointer buttons) */38#define XENKBD_TYPE_KEY 339/*40* Pointer position event41* Capable backend sets feature-abs-pointer in xenstore.42* Frontend requests ot instead of XENKBD_TYPE_MOTION by setting43* request-abs-update in xenstore.44*/45#define XENKBD_TYPE_POS 44647struct xenkbd_motion {48uint8_t type; /* XENKBD_TYPE_MOTION */49int32_t rel_x; /* relative X motion */50int32_t rel_y; /* relative Y motion */51int32_t rel_z; /* relative Z motion (wheel) */52};5354struct xenkbd_key {55uint8_t type; /* XENKBD_TYPE_KEY */56uint8_t pressed; /* 1 if pressed; 0 otherwise */57uint32_t keycode; /* KEY_* from linux/input.h */58};5960struct xenkbd_position {61uint8_t type; /* XENKBD_TYPE_POS */62int32_t abs_x; /* absolute X position (in FB pixels) */63int32_t abs_y; /* absolute Y position (in FB pixels) */64int32_t rel_z; /* relative Z motion (wheel) */65};6667#define XENKBD_IN_EVENT_SIZE 406869union xenkbd_in_event {70uint8_t type;71struct xenkbd_motion motion;72struct xenkbd_key key;73struct xenkbd_position pos;74char pad[XENKBD_IN_EVENT_SIZE];75};7677/* Out events (frontend -> backend) */7879/*80* Out events may be sent only when requested by backend, and receipt81* of an unknown out event is an error.82* No out events currently defined.83*/8485#define XENKBD_OUT_EVENT_SIZE 408687union xenkbd_out_event {88uint8_t type;89char pad[XENKBD_OUT_EVENT_SIZE];90};9192/* shared page */9394#define XENKBD_IN_RING_SIZE 204895#define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE)96#define XENKBD_IN_RING_OFFS 102497#define XENKBD_IN_RING(page) \98((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS))99#define XENKBD_IN_RING_REF(page, idx) \100(XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN])101102#define XENKBD_OUT_RING_SIZE 1024103#define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE)104#define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE)105#define XENKBD_OUT_RING(page) \106((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS))107#define XENKBD_OUT_RING_REF(page, idx) \108(XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN])109110struct xenkbd_page {111uint32_t in_cons, in_prod;112uint32_t out_cons, out_prod;113};114115#endif116117118