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