fbif.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * fbif.h -- Xen virtual frame buffer device
  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_FBIF_H__
  26. #define __XEN_PUBLIC_IO_FBIF_H__
  27. /* Out events (frontend -> backend) */
  28. /*
  29. * Out events may be sent only when requested by backend, and receipt
  30. * of an unknown out event is an error.
  31. */
  32. /* Event type 1 currently not used */
  33. /*
  34. * Framebuffer update notification event
  35. * Capable frontend sets feature-update in xenstore.
  36. * Backend requests it by setting request-update in xenstore.
  37. */
  38. #define XENFB_TYPE_UPDATE 2
  39. struct xenfb_update {
  40. uint8_t type; /* XENFB_TYPE_UPDATE */
  41. int32_t x; /* source x */
  42. int32_t y; /* source y */
  43. int32_t width; /* rect width */
  44. int32_t height; /* rect height */
  45. };
  46. #define XENFB_OUT_EVENT_SIZE 40
  47. union xenfb_out_event {
  48. uint8_t type;
  49. struct xenfb_update update;
  50. char pad[XENFB_OUT_EVENT_SIZE];
  51. };
  52. /* In events (backend -> frontend) */
  53. /*
  54. * Frontends should ignore unknown in events.
  55. * No in events currently defined.
  56. */
  57. #define XENFB_IN_EVENT_SIZE 40
  58. union xenfb_in_event {
  59. uint8_t type;
  60. char pad[XENFB_IN_EVENT_SIZE];
  61. };
  62. /* shared page */
  63. #define XENFB_IN_RING_SIZE 1024
  64. #define XENFB_IN_RING_LEN (XENFB_IN_RING_SIZE / XENFB_IN_EVENT_SIZE)
  65. #define XENFB_IN_RING_OFFS 1024
  66. #define XENFB_IN_RING(page) \
  67. ((union xenfb_in_event *)((char *)(page) + XENFB_IN_RING_OFFS))
  68. #define XENFB_IN_RING_REF(page, idx) \
  69. (XENFB_IN_RING((page))[(idx) % XENFB_IN_RING_LEN])
  70. #define XENFB_OUT_RING_SIZE 2048
  71. #define XENFB_OUT_RING_LEN (XENFB_OUT_RING_SIZE / XENFB_OUT_EVENT_SIZE)
  72. #define XENFB_OUT_RING_OFFS (XENFB_IN_RING_OFFS + XENFB_IN_RING_SIZE)
  73. #define XENFB_OUT_RING(page) \
  74. ((union xenfb_out_event *)((char *)(page) + XENFB_OUT_RING_OFFS))
  75. #define XENFB_OUT_RING_REF(page, idx) \
  76. (XENFB_OUT_RING((page))[(idx) % XENFB_OUT_RING_LEN])
  77. struct xenfb_page {
  78. uint32_t in_cons, in_prod;
  79. uint32_t out_cons, out_prod;
  80. int32_t width; /* width of the framebuffer (in pixels) */
  81. int32_t height; /* height of the framebuffer (in pixels) */
  82. uint32_t line_length; /* length of a row of pixels (in bytes) */
  83. uint32_t mem_length; /* length of the framebuffer (in bytes) */
  84. uint8_t depth; /* depth of a pixel (in bits) */
  85. /*
  86. * Framebuffer page directory
  87. *
  88. * Each directory page holds PAGE_SIZE / sizeof(*pd)
  89. * framebuffer pages, and can thus map up to PAGE_SIZE *
  90. * PAGE_SIZE / sizeof(*pd) bytes. With PAGE_SIZE == 4096 and
  91. * sizeof(unsigned long) == 4, that's 4 Megs. Two directory
  92. * pages should be enough for a while.
  93. */
  94. unsigned long pd[2];
  95. };
  96. /*
  97. * Wart: xenkbd needs to know resolution. Put it here until a better
  98. * solution is found, but don't leak it to the backend.
  99. */
  100. #ifdef __KERNEL__
  101. #define XENFB_WIDTH 800
  102. #define XENFB_HEIGHT 600
  103. #define XENFB_DEPTH 32
  104. #endif
  105. #endif