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