You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fbcon.h 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #ifndef _IPXE_FBCON_H
  2. #define _IPXE_FBCON_H
  3. /** @file
  4. *
  5. * Frame buffer console
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. #include <stdint.h>
  10. #include <ipxe/ansiesc.h>
  11. #include <ipxe/uaccess.h>
  12. struct pixel_buffer;
  13. /** Character width, in pixels */
  14. #define FBCON_CHAR_WIDTH 9
  15. /** Character height, in pixels */
  16. #define FBCON_CHAR_HEIGHT 16
  17. /** Bold colour modifier (RGB value) */
  18. #define FBCON_BOLD 0x555555
  19. /** Transparent background magic colour (raw colour value) */
  20. #define FBCON_TRANSPARENT 0xffffffff
  21. /** A font glyph */
  22. struct fbcon_font_glyph {
  23. /** Row bitmask */
  24. uint8_t bitmask[FBCON_CHAR_HEIGHT];
  25. } __attribute__ (( packed ));
  26. /** A font definition */
  27. struct fbcon_font {
  28. /** Character glyphs */
  29. userptr_t start;
  30. } __attribute__ (( packed ));
  31. /** A frame buffer geometry
  32. *
  33. * The geometry is defined in terms of "entities" (which can be either
  34. * pixels or characters).
  35. */
  36. struct fbcon_geometry {
  37. /** Width (number of entities per displayed row) */
  38. unsigned int width;
  39. /** Height (number of entities per displayed column) */
  40. unsigned int height;
  41. /** Length of a single entity */
  42. size_t len;
  43. /** Stride (offset between vertically adjacent entities) */
  44. size_t stride;
  45. };
  46. /** A frame buffer margin */
  47. struct fbcon_margin {
  48. /** Left margin */
  49. unsigned int left;
  50. /** Right margin */
  51. unsigned int right;
  52. /** Top margin */
  53. unsigned int top;
  54. /** Bottom margin */
  55. unsigned int bottom;
  56. };
  57. /** A frame buffer colour mapping */
  58. struct fbcon_colour_map {
  59. /** Red scale (right shift amount from 24-bit RGB) */
  60. uint8_t red_scale;
  61. /** Green scale (right shift amount from 24-bit RGB) */
  62. uint8_t green_scale;
  63. /** Blue scale (right shift amount from 24-bit RGB) */
  64. uint8_t blue_scale;
  65. /** Red LSB */
  66. uint8_t red_lsb;
  67. /** Green LSB */
  68. uint8_t green_lsb;
  69. /** Blue LSB */
  70. uint8_t blue_lsb;
  71. };
  72. /** A frame buffer text cell */
  73. struct fbcon_text_cell {
  74. /** Foreground colour */
  75. uint32_t foreground;
  76. /** Background colour */
  77. uint32_t background;
  78. /** Character */
  79. unsigned int character;
  80. };
  81. /** A frame buffer text array */
  82. struct fbcon_text {
  83. /** Stored text cells */
  84. userptr_t start;
  85. };
  86. /** A frame buffer background picture */
  87. struct fbcon_picture {
  88. /** Start address */
  89. userptr_t start;
  90. };
  91. /** A frame buffer console */
  92. struct fbcon {
  93. /** Start address */
  94. userptr_t start;
  95. /** Length of one complete displayed screen */
  96. size_t len;
  97. /** Pixel geometry */
  98. struct fbcon_geometry *pixel;
  99. /** Character geometry */
  100. struct fbcon_geometry character;
  101. /** Margin */
  102. struct fbcon_margin margin;
  103. /** Indent to first character (in bytes) */
  104. size_t indent;
  105. /** Colour mapping */
  106. struct fbcon_colour_map *map;
  107. /** Font definition */
  108. struct fbcon_font *font;
  109. /** Text foreground raw colour */
  110. uint32_t foreground;
  111. /** Text background raw colour */
  112. uint32_t background;
  113. /** Bold colour modifier raw colour */
  114. uint32_t bold;
  115. /** Text cursor X position */
  116. unsigned int xpos;
  117. /** Text cursor Y position */
  118. unsigned int ypos;
  119. /** ANSI escape sequence context */
  120. struct ansiesc_context ctx;
  121. /** Text array */
  122. struct fbcon_text text;
  123. /** Background picture */
  124. struct fbcon_picture picture;
  125. /** Display cursor */
  126. int show_cursor;
  127. };
  128. extern int fbcon_init ( struct fbcon *fbcon, userptr_t start,
  129. struct fbcon_geometry *pixel,
  130. struct fbcon_margin *margin,
  131. struct fbcon_colour_map *map,
  132. struct fbcon_font *font,
  133. struct pixel_buffer *pixbuf );
  134. extern void fbcon_fini ( struct fbcon *fbcon );
  135. extern void fbcon_putchar ( struct fbcon *fbcon, int character );
  136. #endif /* _IPXE_FBCON_H */