kbdif.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * kbdif.h -- Xen virtual keyboard/mouse
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to
  6. * deal in the Software without restriction, including without limitation the
  7. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. * sell copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. *
  22. * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com>
  23. * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com>
  24. */
  25. #ifndef __XEN_PUBLIC_IO_KBDIF_H__
  26. #define __XEN_PUBLIC_IO_KBDIF_H__
  27. /* In events (backend -> frontend) */
  28. /*
  29. * Frontends should ignore unknown in events.
  30. */
  31. /* Pointer movement event */
  32. #define XENKBD_TYPE_MOTION 1
  33. /* Event type 2 currently not used */
  34. /* Key event (includes pointer buttons) */
  35. #define XENKBD_TYPE_KEY 3
  36. /*
  37. * Pointer position event
  38. * Capable backend sets feature-abs-pointer in xenstore.
  39. * Frontend requests ot instead of XENKBD_TYPE_MOTION by setting
  40. * request-abs-update in xenstore.
  41. */
  42. #define XENKBD_TYPE_POS 4
  43. struct xenkbd_motion {
  44. uint8_t type; /* XENKBD_TYPE_MOTION */
  45. int32_t rel_x; /* relative X motion */
  46. int32_t rel_y; /* relative Y motion */
  47. int32_t rel_z; /* relative Z motion (wheel) */
  48. };
  49. struct xenkbd_key {
  50. uint8_t type; /* XENKBD_TYPE_KEY */
  51. uint8_t pressed; /* 1 if pressed; 0 otherwise */
  52. uint32_t keycode; /* KEY_* from linux/input.h */
  53. };
  54. struct xenkbd_position {
  55. uint8_t type; /* XENKBD_TYPE_POS */
  56. int32_t abs_x; /* absolute X position (in FB pixels) */
  57. int32_t abs_y; /* absolute Y position (in FB pixels) */
  58. int32_t rel_z; /* relative Z motion (wheel) */
  59. };
  60. #define XENKBD_IN_EVENT_SIZE 40
  61. union xenkbd_in_event {
  62. uint8_t type;
  63. struct xenkbd_motion motion;
  64. struct xenkbd_key key;
  65. struct xenkbd_position pos;
  66. char pad[XENKBD_IN_EVENT_SIZE];
  67. };
  68. /* Out events (frontend -> backend) */
  69. /*
  70. * Out events may be sent only when requested by backend, and receipt
  71. * of an unknown out event is an error.
  72. * No out events currently defined.
  73. */
  74. #define XENKBD_OUT_EVENT_SIZE 40
  75. union xenkbd_out_event {
  76. uint8_t type;
  77. char pad[XENKBD_OUT_EVENT_SIZE];
  78. };
  79. /* shared page */
  80. #define XENKBD_IN_RING_SIZE 2048
  81. #define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE)
  82. #define XENKBD_IN_RING_OFFS 1024
  83. #define XENKBD_IN_RING(page) \
  84. ((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS))
  85. #define XENKBD_IN_RING_REF(page, idx) \
  86. (XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN])
  87. #define XENKBD_OUT_RING_SIZE 1024
  88. #define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE)
  89. #define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE)
  90. #define XENKBD_OUT_RING(page) \
  91. ((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS))
  92. #define XENKBD_OUT_RING_REF(page, idx) \
  93. (XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN])
  94. struct xenkbd_page {
  95. uint32_t in_cons, in_prod;
  96. uint32_t out_cons, out_prod;
  97. };
  98. #endif