kbdif.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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. /*
  28. *****************************************************************************
  29. * Feature and Parameter Negotiation
  30. *****************************************************************************
  31. *
  32. * The two halves of a para-virtual driver utilize nodes within
  33. * XenStore to communicate capabilities and to negotiate operating parameters.
  34. * This section enumerates these nodes which reside in the respective front and
  35. * backend portions of XenStore, following XenBus convention.
  36. *
  37. * All data in XenStore is stored as strings. Nodes specifying numeric
  38. * values are encoded in decimal. Integer value ranges listed below are
  39. * expressed as fixed sized integer types capable of storing the conversion
  40. * of a properly formated node string, without loss of information.
  41. *
  42. *****************************************************************************
  43. * Backend XenBus Nodes
  44. *****************************************************************************
  45. *
  46. *---------------------------- Features supported ----------------------------
  47. *
  48. * Capable backend advertises supported features by publishing
  49. * corresponding entries in XenStore and puts 1 as the value of the entry.
  50. * If a feature is not supported then 0 must be set or feature entry omitted.
  51. *
  52. * feature-disable-keyboard
  53. * Values: <uint>
  54. *
  55. * If there is no need to expose a virtual keyboard device by the
  56. * frontend then this must be set to 1.
  57. *
  58. * feature-disable-pointer
  59. * Values: <uint>
  60. *
  61. * If there is no need to expose a virtual pointer device by the
  62. * frontend then this must be set to 1.
  63. *
  64. * feature-abs-pointer
  65. * Values: <uint>
  66. *
  67. * Backends, which support reporting of absolute coordinates for pointer
  68. * device should set this to 1.
  69. *
  70. * feature-multi-touch
  71. * Values: <uint>
  72. *
  73. * Backends, which support reporting of multi-touch events
  74. * should set this to 1.
  75. *
  76. * feature-raw-pointer
  77. * Values: <uint>
  78. *
  79. * Backends, which support reporting raw (unscaled) absolute coordinates
  80. * for pointer devices should set this to 1. Raw (unscaled) values have
  81. * a range of [0, 0x7fff].
  82. *
  83. *----------------------- Device Instance Parameters ------------------------
  84. *
  85. * unique-id
  86. * Values: <string>
  87. *
  88. * After device instance initialization it is assigned a unique ID,
  89. * so every instance of the frontend can be identified by the backend
  90. * by this ID. This can be UUID or such.
  91. *
  92. *------------------------- Pointer Device Parameters ------------------------
  93. *
  94. * width
  95. * Values: <uint>
  96. *
  97. * Maximum X coordinate (width) to be used by the frontend
  98. * while reporting input events, pixels, [0; UINT32_MAX].
  99. *
  100. * height
  101. * Values: <uint>
  102. *
  103. * Maximum Y coordinate (height) to be used by the frontend
  104. * while reporting input events, pixels, [0; UINT32_MAX].
  105. *
  106. *----------------------- Multi-touch Device Parameters ----------------------
  107. *
  108. * multi-touch-num-contacts
  109. * Values: <uint>
  110. *
  111. * Number of simultaneous touches reported.
  112. *
  113. * multi-touch-width
  114. * Values: <uint>
  115. *
  116. * Width of the touch area to be used by the frontend
  117. * while reporting input events, pixels, [0; UINT32_MAX].
  118. *
  119. * multi-touch-height
  120. * Values: <uint>
  121. *
  122. * Height of the touch area to be used by the frontend
  123. * while reporting input events, pixels, [0; UINT32_MAX].
  124. *
  125. *****************************************************************************
  126. * Frontend XenBus Nodes
  127. *****************************************************************************
  128. *
  129. *------------------------------ Feature request -----------------------------
  130. *
  131. * Capable frontend requests features from backend via setting corresponding
  132. * entries to 1 in XenStore. Requests for features not advertised as supported
  133. * by the backend have no effect.
  134. *
  135. * request-abs-pointer
  136. * Values: <uint>
  137. *
  138. * Request backend to report absolute pointer coordinates
  139. * (XENKBD_TYPE_POS) instead of relative ones (XENKBD_TYPE_MOTION).
  140. *
  141. * request-multi-touch
  142. * Values: <uint>
  143. *
  144. * Request backend to report multi-touch events.
  145. *
  146. * request-raw-pointer
  147. * Values: <uint>
  148. *
  149. * Request backend to report raw unscaled absolute pointer coordinates.
  150. * This option is only valid if request-abs-pointer is also set.
  151. * Raw unscaled coordinates have the range [0, 0x7fff]
  152. *
  153. *----------------------- Request Transport Parameters -----------------------
  154. *
  155. * event-channel
  156. * Values: <uint>
  157. *
  158. * The identifier of the Xen event channel used to signal activity
  159. * in the ring buffer.
  160. *
  161. * page-gref
  162. * Values: <uint>
  163. *
  164. * The Xen grant reference granting permission for the backend to map
  165. * a sole page in a single page sized event ring buffer.
  166. *
  167. * page-ref
  168. * Values: <uint>
  169. *
  170. * OBSOLETE, not recommended for use.
  171. * PFN of the shared page.
  172. */
  173. /*
  174. * EVENT CODES.
  175. */
  176. #define XENKBD_TYPE_MOTION 1
  177. #define XENKBD_TYPE_RESERVED 2
  178. #define XENKBD_TYPE_KEY 3
  179. #define XENKBD_TYPE_POS 4
  180. #define XENKBD_TYPE_MTOUCH 5
  181. /* Multi-touch event sub-codes */
  182. #define XENKBD_MT_EV_DOWN 0
  183. #define XENKBD_MT_EV_UP 1
  184. #define XENKBD_MT_EV_MOTION 2
  185. #define XENKBD_MT_EV_SYN 3
  186. #define XENKBD_MT_EV_SHAPE 4
  187. #define XENKBD_MT_EV_ORIENT 5
  188. /*
  189. * CONSTANTS, XENSTORE FIELD AND PATH NAME STRINGS, HELPERS.
  190. */
  191. #define XENKBD_DRIVER_NAME "vkbd"
  192. #define XENKBD_FIELD_FEAT_DSBL_KEYBRD "feature-disable-keyboard"
  193. #define XENKBD_FIELD_FEAT_DSBL_POINTER "feature-disable-pointer"
  194. #define XENKBD_FIELD_FEAT_ABS_POINTER "feature-abs-pointer"
  195. #define XENKBD_FIELD_FEAT_RAW_POINTER "feature-raw-pointer"
  196. #define XENKBD_FIELD_FEAT_MTOUCH "feature-multi-touch"
  197. #define XENKBD_FIELD_REQ_ABS_POINTER "request-abs-pointer"
  198. #define XENKBD_FIELD_REQ_RAW_POINTER "request-raw-pointer"
  199. #define XENKBD_FIELD_REQ_MTOUCH "request-multi-touch"
  200. #define XENKBD_FIELD_RING_GREF "page-gref"
  201. #define XENKBD_FIELD_EVT_CHANNEL "event-channel"
  202. #define XENKBD_FIELD_WIDTH "width"
  203. #define XENKBD_FIELD_HEIGHT "height"
  204. #define XENKBD_FIELD_MT_WIDTH "multi-touch-width"
  205. #define XENKBD_FIELD_MT_HEIGHT "multi-touch-height"
  206. #define XENKBD_FIELD_MT_NUM_CONTACTS "multi-touch-num-contacts"
  207. #define XENKBD_FIELD_UNIQUE_ID "unique-id"
  208. /* OBSOLETE, not recommended for use */
  209. #define XENKBD_FIELD_RING_REF "page-ref"
  210. /*
  211. *****************************************************************************
  212. * Description of the protocol between frontend and backend driver.
  213. *****************************************************************************
  214. *
  215. * The two halves of a Para-virtual driver communicate with
  216. * each other using a shared page and an event channel.
  217. * Shared page contains a ring with event structures.
  218. *
  219. * All reserved fields in the structures below must be 0.
  220. *
  221. *****************************************************************************
  222. * Backend to frontend events
  223. *****************************************************************************
  224. *
  225. * Frontends should ignore unknown in events.
  226. * All event packets have the same length (40 octets)
  227. * All event packets have common header:
  228. *
  229. * 0 octet
  230. * +-----------------+
  231. * | type |
  232. * +-----------------+
  233. * type - uint8_t, event code, XENKBD_TYPE_???
  234. *
  235. *
  236. * Pointer relative movement event
  237. * 0 1 2 3 octet
  238. * +----------------+----------------+----------------+----------------+
  239. * | _TYPE_MOTION | reserved | 4
  240. * +----------------+----------------+----------------+----------------+
  241. * | rel_x | 8
  242. * +----------------+----------------+----------------+----------------+
  243. * | rel_y | 12
  244. * +----------------+----------------+----------------+----------------+
  245. * | rel_z | 16
  246. * +----------------+----------------+----------------+----------------+
  247. * | reserved | 20
  248. * +----------------+----------------+----------------+----------------+
  249. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  250. * +----------------+----------------+----------------+----------------+
  251. * | reserved | 40
  252. * +----------------+----------------+----------------+----------------+
  253. *
  254. * rel_x - int32_t, relative X motion
  255. * rel_y - int32_t, relative Y motion
  256. * rel_z - int32_t, relative Z motion (wheel)
  257. */
  258. struct xenkbd_motion {
  259. uint8_t type;
  260. int32_t rel_x;
  261. int32_t rel_y;
  262. int32_t rel_z;
  263. };
  264. /*
  265. * Key event (includes pointer buttons)
  266. * 0 1 2 3 octet
  267. * +----------------+----------------+----------------+----------------+
  268. * | _TYPE_KEY | pressed | reserved | 4
  269. * +----------------+----------------+----------------+----------------+
  270. * | keycode | 8
  271. * +----------------+----------------+----------------+----------------+
  272. * | reserved | 12
  273. * +----------------+----------------+----------------+----------------+
  274. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  275. * +----------------+----------------+----------------+----------------+
  276. * | reserved | 40
  277. * +----------------+----------------+----------------+----------------+
  278. *
  279. * pressed - uint8_t, 1 if pressed; 0 otherwise
  280. * keycode - uint32_t, KEY_* from linux/input.h
  281. */
  282. struct xenkbd_key {
  283. uint8_t type;
  284. uint8_t pressed;
  285. uint32_t keycode;
  286. };
  287. /*
  288. * Pointer absolute position event
  289. * 0 1 2 3 octet
  290. * +----------------+----------------+----------------+----------------+
  291. * | _TYPE_POS | reserved | 4
  292. * +----------------+----------------+----------------+----------------+
  293. * | abs_x | 8
  294. * +----------------+----------------+----------------+----------------+
  295. * | abs_y | 12
  296. * +----------------+----------------+----------------+----------------+
  297. * | rel_z | 16
  298. * +----------------+----------------+----------------+----------------+
  299. * | reserved | 20
  300. * +----------------+----------------+----------------+----------------+
  301. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  302. * +----------------+----------------+----------------+----------------+
  303. * | reserved | 40
  304. * +----------------+----------------+----------------+----------------+
  305. *
  306. * abs_x - int32_t, absolute X position (in FB pixels)
  307. * abs_y - int32_t, absolute Y position (in FB pixels)
  308. * rel_z - int32_t, relative Z motion (wheel)
  309. */
  310. struct xenkbd_position {
  311. uint8_t type;
  312. int32_t abs_x;
  313. int32_t abs_y;
  314. int32_t rel_z;
  315. };
  316. /*
  317. * Multi-touch event and its sub-types
  318. *
  319. * All multi-touch event packets have common header:
  320. *
  321. * 0 1 2 3 octet
  322. * +----------------+----------------+----------------+----------------+
  323. * | _TYPE_MTOUCH | event_type | contact_id | reserved | 4
  324. * +----------------+----------------+----------------+----------------+
  325. * | reserved | 8
  326. * +----------------+----------------+----------------+----------------+
  327. *
  328. * event_type - unt8_t, multi-touch event sub-type, XENKBD_MT_EV_???
  329. * contact_id - unt8_t, ID of the contact
  330. *
  331. * Touch interactions can consist of one or more contacts.
  332. * For each contact, a series of events is generated, starting
  333. * with a down event, followed by zero or more motion events,
  334. * and ending with an up event. Events relating to the same
  335. * contact point can be identified by the ID of the sequence: contact ID.
  336. * Contact ID may be reused after XENKBD_MT_EV_UP event and
  337. * is in the [0; XENKBD_FIELD_NUM_CONTACTS - 1] range.
  338. *
  339. * For further information please refer to documentation on Wayland [1],
  340. * Linux [2] and Windows [3] multi-touch support.
  341. *
  342. * [1] https://cgit.freedesktop.org/wayland/wayland/tree/protocol/wayland.xml
  343. * [2] https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.rst
  344. * [3] https://msdn.microsoft.com/en-us/library/jj151564(v=vs.85).aspx
  345. *
  346. *
  347. * Multi-touch down event - sent when a new touch is made: touch is assigned
  348. * a unique contact ID, sent with this and consequent events related
  349. * to this touch.
  350. * 0 1 2 3 octet
  351. * +----------------+----------------+----------------+----------------+
  352. * | _TYPE_MTOUCH | _MT_EV_DOWN | contact_id | reserved | 4
  353. * +----------------+----------------+----------------+----------------+
  354. * | reserved | 8
  355. * +----------------+----------------+----------------+----------------+
  356. * | abs_x | 12
  357. * +----------------+----------------+----------------+----------------+
  358. * | abs_y | 16
  359. * +----------------+----------------+----------------+----------------+
  360. * | reserved | 20
  361. * +----------------+----------------+----------------+----------------+
  362. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  363. * +----------------+----------------+----------------+----------------+
  364. * | reserved | 40
  365. * +----------------+----------------+----------------+----------------+
  366. *
  367. * abs_x - int32_t, absolute X position, in pixels
  368. * abs_y - int32_t, absolute Y position, in pixels
  369. *
  370. * Multi-touch contact release event
  371. * 0 1 2 3 octet
  372. * +----------------+----------------+----------------+----------------+
  373. * | _TYPE_MTOUCH | _MT_EV_UP | contact_id | reserved | 4
  374. * +----------------+----------------+----------------+----------------+
  375. * | reserved | 8
  376. * +----------------+----------------+----------------+----------------+
  377. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  378. * +----------------+----------------+----------------+----------------+
  379. * | reserved | 40
  380. * +----------------+----------------+----------------+----------------+
  381. *
  382. * Multi-touch motion event
  383. * 0 1 2 3 octet
  384. * +----------------+----------------+----------------+----------------+
  385. * | _TYPE_MTOUCH | _MT_EV_MOTION | contact_id | reserved | 4
  386. * +----------------+----------------+----------------+----------------+
  387. * | reserved | 8
  388. * +----------------+----------------+----------------+----------------+
  389. * | abs_x | 12
  390. * +----------------+----------------+----------------+----------------+
  391. * | abs_y | 16
  392. * +----------------+----------------+----------------+----------------+
  393. * | reserved | 20
  394. * +----------------+----------------+----------------+----------------+
  395. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  396. * +----------------+----------------+----------------+----------------+
  397. * | reserved | 40
  398. * +----------------+----------------+----------------+----------------+
  399. *
  400. * abs_x - int32_t, absolute X position, in pixels,
  401. * abs_y - int32_t, absolute Y position, in pixels,
  402. *
  403. * Multi-touch input synchronization event - shows end of a set of events
  404. * which logically belong together.
  405. * 0 1 2 3 octet
  406. * +----------------+----------------+----------------+----------------+
  407. * | _TYPE_MTOUCH | _MT_EV_SYN | contact_id | reserved | 4
  408. * +----------------+----------------+----------------+----------------+
  409. * | reserved | 8
  410. * +----------------+----------------+----------------+----------------+
  411. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  412. * +----------------+----------------+----------------+----------------+
  413. * | reserved | 40
  414. * +----------------+----------------+----------------+----------------+
  415. *
  416. * Multi-touch shape event - touch point's shape has changed its shape.
  417. * Shape is approximated by an ellipse through the major and minor axis
  418. * lengths: major is the longer diameter of the ellipse and minor is the
  419. * shorter one. Center of the ellipse is reported via
  420. * XENKBD_MT_EV_DOWN/XENKBD_MT_EV_MOTION events.
  421. * 0 1 2 3 octet
  422. * +----------------+----------------+----------------+----------------+
  423. * | _TYPE_MTOUCH | _MT_EV_SHAPE | contact_id | reserved | 4
  424. * +----------------+----------------+----------------+----------------+
  425. * | reserved | 8
  426. * +----------------+----------------+----------------+----------------+
  427. * | major | 12
  428. * +----------------+----------------+----------------+----------------+
  429. * | minor | 16
  430. * +----------------+----------------+----------------+----------------+
  431. * | reserved | 20
  432. * +----------------+----------------+----------------+----------------+
  433. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  434. * +----------------+----------------+----------------+----------------+
  435. * | reserved | 40
  436. * +----------------+----------------+----------------+----------------+
  437. *
  438. * major - unt32_t, length of the major axis, pixels
  439. * minor - unt32_t, length of the minor axis, pixels
  440. *
  441. * Multi-touch orientation event - touch point's shape has changed
  442. * its orientation: calculated as a clockwise angle between the major axis
  443. * of the ellipse and positive Y axis in degrees, [-180; +180].
  444. * 0 1 2 3 octet
  445. * +----------------+----------------+----------------+----------------+
  446. * | _TYPE_MTOUCH | _MT_EV_ORIENT | contact_id | reserved | 4
  447. * +----------------+----------------+----------------+----------------+
  448. * | reserved | 8
  449. * +----------------+----------------+----------------+----------------+
  450. * | orientation | reserved | 12
  451. * +----------------+----------------+----------------+----------------+
  452. * | reserved | 16
  453. * +----------------+----------------+----------------+----------------+
  454. * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
  455. * +----------------+----------------+----------------+----------------+
  456. * | reserved | 40
  457. * +----------------+----------------+----------------+----------------+
  458. *
  459. * orientation - int16_t, clockwise angle of the major axis
  460. */
  461. struct xenkbd_mtouch {
  462. uint8_t type; /* XENKBD_TYPE_MTOUCH */
  463. uint8_t event_type; /* XENKBD_MT_EV_??? */
  464. uint8_t contact_id;
  465. uint8_t reserved[5]; /* reserved for the future use */
  466. union {
  467. struct {
  468. int32_t abs_x; /* absolute X position, pixels */
  469. int32_t abs_y; /* absolute Y position, pixels */
  470. } pos;
  471. struct {
  472. uint32_t major; /* length of the major axis, pixels */
  473. uint32_t minor; /* length of the minor axis, pixels */
  474. } shape;
  475. int16_t orientation; /* clockwise angle of the major axis */
  476. } u;
  477. };
  478. #define XENKBD_IN_EVENT_SIZE 40
  479. union xenkbd_in_event {
  480. uint8_t type;
  481. struct xenkbd_motion motion;
  482. struct xenkbd_key key;
  483. struct xenkbd_position pos;
  484. struct xenkbd_mtouch mtouch;
  485. char pad[XENKBD_IN_EVENT_SIZE];
  486. };
  487. /*
  488. *****************************************************************************
  489. * Frontend to backend events
  490. *****************************************************************************
  491. *
  492. * Out events may be sent only when requested by backend, and receipt
  493. * of an unknown out event is an error.
  494. * No out events currently defined.
  495. * All event packets have the same length (40 octets)
  496. * All event packets have common header:
  497. * 0 octet
  498. * +-----------------+
  499. * | type |
  500. * +-----------------+
  501. * type - uint8_t, event code
  502. */
  503. #define XENKBD_OUT_EVENT_SIZE 40
  504. union xenkbd_out_event {
  505. uint8_t type;
  506. char pad[XENKBD_OUT_EVENT_SIZE];
  507. };
  508. /*
  509. *****************************************************************************
  510. * Shared page
  511. *****************************************************************************
  512. */
  513. #define XENKBD_IN_RING_SIZE 2048
  514. #define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE)
  515. #define XENKBD_IN_RING_OFFS 1024
  516. #define XENKBD_IN_RING(page) \
  517. ((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS))
  518. #define XENKBD_IN_RING_REF(page, idx) \
  519. (XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN])
  520. #define XENKBD_OUT_RING_SIZE 1024
  521. #define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE)
  522. #define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE)
  523. #define XENKBD_OUT_RING(page) \
  524. ((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS))
  525. #define XENKBD_OUT_RING_REF(page, idx) \
  526. (XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN])
  527. struct xenkbd_page {
  528. uint32_t in_cons, in_prod;
  529. uint32_t out_cons, out_prod;
  530. };
  531. #endif /* __XEN_PUBLIC_IO_KBDIF_H__ */