iPXE
fbcon.h
Go to the documentation of this file.
00001 #ifndef _IPXE_FBCON_H
00002 #define _IPXE_FBCON_H
00003 
00004 /** @file
00005  *
00006  * Frame buffer console
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/ansiesc.h>
00014 #include <ipxe/uaccess.h>
00015 #include <ipxe/console.h>
00016 
00017 /** Character width, in pixels */
00018 #define FBCON_CHAR_WIDTH 9
00019 
00020 /** Bold colour modifier (RGB value) */
00021 #define FBCON_BOLD 0x555555
00022 
00023 /** Transparent background magic colour (raw colour value) */
00024 #define FBCON_TRANSPARENT 0xffffffff
00025 
00026 /** A font glyph */
00027 struct fbcon_font_glyph {
00028         /** Row bitmask */
00029         uint8_t bitmask[0];
00030 };
00031 
00032 /** A font definition */
00033 struct fbcon_font {
00034         /** Character height (in pixels) */
00035         unsigned int height;
00036         /**
00037          * Get character glyph
00038          *
00039          * @v character         Character
00040          * @v glyph             Character glyph to fill in
00041          */
00042         void ( * glyph ) ( unsigned int character, uint8_t *glyph );
00043 };
00044 
00045 /** A frame buffer geometry
00046  *
00047  * The geometry is defined in terms of "entities" (which can be either
00048  * pixels or characters).
00049  */
00050 struct fbcon_geometry {
00051         /** Width (number of entities per displayed row) */
00052         unsigned int width;
00053         /** Height (number of entities per displayed column) */
00054         unsigned int height;
00055         /** Length of a single entity */
00056         size_t len;
00057         /** Stride (offset between vertically adjacent entities) */
00058         size_t stride;
00059 };
00060 
00061 /** A frame buffer margin */
00062 struct fbcon_margin {
00063         /** Left margin */
00064         unsigned int left;
00065         /** Right margin */
00066         unsigned int right;
00067         /** Top margin */
00068         unsigned int top;
00069         /** Bottom margin */
00070         unsigned int bottom;
00071 };
00072 
00073 /** A frame buffer colour mapping */
00074 struct fbcon_colour_map {
00075         /** Red scale (right shift amount from 24-bit RGB) */
00076         uint8_t red_scale;
00077         /** Green scale (right shift amount from 24-bit RGB) */
00078         uint8_t green_scale;
00079         /** Blue scale (right shift amount from 24-bit RGB) */
00080         uint8_t blue_scale;
00081         /** Red LSB */
00082         uint8_t red_lsb;
00083         /** Green LSB */
00084         uint8_t green_lsb;
00085         /** Blue LSB */
00086         uint8_t blue_lsb;
00087 };
00088 
00089 /** A frame buffer text cell */
00090 struct fbcon_text_cell {
00091         /** Foreground colour */
00092         uint32_t foreground;
00093         /** Background colour */
00094         uint32_t background;
00095         /** Character */
00096         unsigned int character;
00097 };
00098 
00099 /** A frame buffer text array */
00100 struct fbcon_text {
00101         /** Stored text cells */
00102         userptr_t start;
00103 };
00104 
00105 /** A frame buffer background picture */
00106 struct fbcon_picture {
00107         /** Start address */
00108         userptr_t start;
00109 };
00110 
00111 /** A frame buffer console */
00112 struct fbcon {
00113         /** Start address */
00114         userptr_t start;
00115         /** Length of one complete displayed screen */
00116         size_t len;
00117         /** Pixel geometry */
00118         struct fbcon_geometry *pixel;
00119         /** Character geometry */
00120         struct fbcon_geometry character;
00121         /** Margin */
00122         struct fbcon_margin margin;
00123         /** Indent to first character (in bytes) */
00124         size_t indent;
00125         /** Colour mapping */
00126         struct fbcon_colour_map *map;
00127         /** Font definition */
00128         struct fbcon_font *font;
00129         /** Text foreground raw colour */
00130         uint32_t foreground;
00131         /** Text background raw colour */
00132         uint32_t background;
00133         /** Bold colour modifier raw colour */
00134         uint32_t bold;
00135         /** Text cursor X position */
00136         unsigned int xpos;
00137         /** Text cursor Y position */
00138         unsigned int ypos;
00139         /** ANSI escape sequence context */
00140         struct ansiesc_context ctx;
00141         /** Text array */
00142         struct fbcon_text text;
00143         /** Background picture */
00144         struct fbcon_picture picture;
00145         /** Display cursor */
00146         int show_cursor;
00147 };
00148 
00149 extern int fbcon_init ( struct fbcon *fbcon, userptr_t start,
00150                         struct fbcon_geometry *pixel,
00151                         struct fbcon_colour_map *map,
00152                         struct fbcon_font *font,
00153                         struct console_configuration *config );
00154 extern void fbcon_fini ( struct fbcon *fbcon );
00155 extern void fbcon_putchar ( struct fbcon *fbcon, int character );
00156 
00157 #endif /* _IPXE_FBCON_H */