iPXE
Functions | Variables
fbcon.c File Reference

Frame buffer console. More...

#include <string.h>
#include <errno.h>
#include <assert.h>
#include <byteswap.h>
#include <ipxe/ansiesc.h>
#include <ipxe/image.h>
#include <ipxe/pixbuf.h>
#include <ipxe/uaccess.h>
#include <ipxe/umalloc.h>
#include <ipxe/console.h>
#include <ipxe/fbcon.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static uint32_t fbcon_colour (struct fbcon *fbcon, uint32_t rgb)
 Calculate raw colour value. More...
 
static uint32_t fbcon_ansi_colour (struct fbcon *fbcon, unsigned int ansicol)
 Calculate ANSI font colour. More...
 
static void fbcon_set_default_foreground (struct fbcon *fbcon)
 Set default foreground colour. More...
 
static void fbcon_set_default_background (struct fbcon *fbcon)
 Set default background colour. More...
 
static struct fbcon_text_cellfbcon_cell (struct fbcon *fbcon, unsigned int xpos, unsigned int ypos)
 Get character cell. More...
 
static void fbcon_clear (struct fbcon *fbcon, unsigned int ypos)
 Clear rows of characters. More...
 
static void fbcon_draw (struct fbcon *fbcon, struct fbcon_text_cell *cell, unsigned int xpos, unsigned int ypos)
 Draw character at specified position. More...
 
static void fbcon_redraw (struct fbcon *fbcon)
 Redraw all characters. More...
 
static void fbcon_scroll (struct fbcon *fbcon)
 Scroll screen. More...
 
static void fbcon_draw_cursor (struct fbcon *fbcon, int show_cursor)
 Draw character at cursor position. More...
 
static void fbcon_handle_cup (struct ansiesc_context *ctx, unsigned int count __unused, int params[])
 Handle ANSI CUP (cursor position) More...
 
static void fbcon_handle_ed (struct ansiesc_context *ctx, unsigned int count __unused, int params[] __unused)
 Handle ANSI ED (erase in page) More...
 
static void fbcon_handle_sgr (struct ansiesc_context *ctx, unsigned int count, int params[])
 Handle ANSI SGR (set graphics rendition) More...
 
static void fbcon_handle_dectcem_set (struct ansiesc_context *ctx, unsigned int count __unused, int params[] __unused)
 Handle ANSI DECTCEM set (show cursor) More...
 
static void fbcon_handle_dectcem_reset (struct ansiesc_context *ctx, unsigned int count __unused, int params[] __unused)
 Handle ANSI DECTCEM reset (hide cursor) More...
 
void fbcon_putchar (struct fbcon *fbcon, int character)
 Print a character to current cursor position. More...
 
static int fbcon_picture_init (struct fbcon *fbcon, struct pixel_buffer *pixbuf)
 Initialise background picture. More...
 
int fbcon_init (struct fbcon *fbcon, void *start, struct fbcon_geometry *pixel, struct fbcon_colour_map *map, struct fbcon_font *font, struct console_configuration *config)
 Initialise frame buffer console. More...
 
void fbcon_fini (struct fbcon *fbcon)
 Finalise frame buffer console. More...
 

Variables

static struct ansiesc_handler fbcon_ansiesc_handlers []
 ANSI escape sequence handlers. More...
 

Detailed Description

Frame buffer console.

Definition in file fbcon.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ fbcon_colour()

static uint32_t fbcon_colour ( struct fbcon fbcon,
uint32_t  rgb 
)
static

Calculate raw colour value.

Parameters
fbconFrame buffer console
rgb24-bit RGB value
Return values
rawRaw colour

Definition at line 51 of file fbcon.c.

51  {
52  struct fbcon_colour_map *map = fbcon->map;
53  uint8_t red = ( rgb >> 16 );
54  uint8_t green = ( rgb >> 8 );
55  uint8_t blue = ( rgb >> 0 );
56  uint32_t mapped;
57 
58  mapped = ( ( ( red >> map->red_scale ) << map->red_lsb ) |
59  ( ( green >> map->green_scale ) << map->green_lsb ) |
60  ( ( blue >> map->blue_scale ) << map->blue_lsb ) );
61  return cpu_to_le32 ( mapped );
62 }
A frame buffer console.
Definition: fbcon.h:112
A frame buffer colour mapping.
Definition: fbcon.h:74
#define cpu_to_le32(value)
Definition: byteswap.h:107
unsigned char uint8_t
Definition: stdint.h:10
unsigned int uint32_t
Definition: stdint.h:12
static __always_inline int struct dma_mapping * map
Definition: dma.h:183
struct fbcon_colour_map * map
Colour mapping.
Definition: fbcon.h:126

References cpu_to_le32, fbcon::map, and map.

Referenced by fbcon_ansi_colour(), fbcon_handle_sgr(), and fbcon_picture_init().

◆ fbcon_ansi_colour()

static uint32_t fbcon_ansi_colour ( struct fbcon fbcon,
unsigned int  ansicol 
)
static

Calculate ANSI font colour.

Parameters
fbconFrame buffer console
ansicolANSI colour value (0-based)
Return values
colourRaw colour

Definition at line 71 of file fbcon.c.

72  {
73  uint32_t rgb;
74 
75  /* Treat ansicol as 3-bit BGR with intensity 0xaa */
76  rgb = ( ( ( ansicol & ( 1 << 0 ) ) ? 0xaa0000 : 0 ) |
77  ( ( ansicol & ( 1 << 1 ) ) ? 0x00aa00 : 0 ) |
78  ( ( ansicol & ( 1 << 2 ) ) ? 0x0000aa : 0 ) );
79 
80  return fbcon_colour ( fbcon, rgb );
81 }
static uint32_t fbcon_colour(struct fbcon *fbcon, uint32_t rgb)
Calculate raw colour value.
Definition: fbcon.c:51
A frame buffer console.
Definition: fbcon.h:112
unsigned int uint32_t
Definition: stdint.h:12

References fbcon_colour().

Referenced by fbcon_handle_sgr(), and fbcon_set_default_foreground().

◆ fbcon_set_default_foreground()

static void fbcon_set_default_foreground ( struct fbcon fbcon)
static

Set default foreground colour.

Parameters
fbconFrame buffer console

Definition at line 88 of file fbcon.c.

88  {
89 
90  /* Default to non-bold white foreground */
92  fbcon->bold = 0;
93 }
static uint32_t fbcon_ansi_colour(struct fbcon *fbcon, unsigned int ansicol)
Calculate ANSI font colour.
Definition: fbcon.c:71
uint32_t foreground
Text foreground raw colour.
Definition: fbcon.h:130
A frame buffer console.
Definition: fbcon.h:112
uint32_t bold
Bold colour modifier raw colour.
Definition: fbcon.h:134

References fbcon::bold, fbcon_ansi_colour(), and fbcon::foreground.

Referenced by fbcon_handle_sgr(), and fbcon_init().

◆ fbcon_set_default_background()

static void fbcon_set_default_background ( struct fbcon fbcon)
static

Set default background colour.

Parameters
fbconFrame buffer console

Definition at line 100 of file fbcon.c.

100  {
101 
102  /* Default to transparent background */
104 }
A frame buffer console.
Definition: fbcon.h:112
uint32_t background
Text background raw colour.
Definition: fbcon.h:132
#define FBCON_TRANSPARENT
Transparent background magic colour (raw colour value)
Definition: fbcon.h:24

References fbcon::background, and FBCON_TRANSPARENT.

Referenced by fbcon_handle_sgr(), and fbcon_init().

◆ fbcon_cell()

static struct fbcon_text_cell* fbcon_cell ( struct fbcon fbcon,
unsigned int  xpos,
unsigned int  ypos 
)
inlinestatic

Get character cell.

Parameters
fbconFrame buffer console
xposX position
yposY position
Return values
cellText cell

Definition at line 114 of file fbcon.c.

116  {
117  unsigned int index;
118 
119  index = ( ( ypos * fbcon->character.width ) + xpos );
120  return &fbcon->text.cells[index];
121 }
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:52
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:120
long index
Definition: bigint.h:62
A frame buffer console.
Definition: fbcon.h:112
struct fbcon_text_cell * cells
Stored text cells.
Definition: fbcon.h:102
struct fbcon_text text
Text array.
Definition: fbcon.h:144

References fbcon_text::cells, fbcon::character, index, fbcon::text, and fbcon_geometry::width.

Referenced by fbcon_clear(), fbcon_draw_cursor(), fbcon_putchar(), fbcon_redraw(), and fbcon_scroll().

◆ fbcon_clear()

static void fbcon_clear ( struct fbcon fbcon,
unsigned int  ypos 
)
static

Clear rows of characters.

Parameters
fbconFrame buffer console
yposStarting Y position

Definition at line 129 of file fbcon.c.

129  {
130  struct fbcon_text_cell *cell;
131  unsigned int xpos;
132 
133  /* Clear stored character array */
134  cell = fbcon_cell ( fbcon, 0, ypos );
135  for ( ; ypos < fbcon->character.height ; ypos++ ) {
136  for ( xpos = 0 ; xpos < fbcon->character.width ; xpos++ ) {
137  cell->foreground = fbcon->foreground;
138  cell->background = fbcon->background;
139  cell->character = ' ';
140  cell++;
141  }
142  }
143 }
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:52
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:120
A frame buffer text cell.
Definition: fbcon.h:90
uint32_t background
Background colour.
Definition: fbcon.h:94
uint32_t foreground
Text foreground raw colour.
Definition: fbcon.h:130
A frame buffer console.
Definition: fbcon.h:112
unsigned int character
Unicode character.
Definition: fbcon.h:96
uint32_t foreground
Foreground colour.
Definition: fbcon.h:92
static struct fbcon_text_cell * fbcon_cell(struct fbcon *fbcon, unsigned int xpos, unsigned int ypos)
Get character cell.
Definition: fbcon.c:114
uint32_t background
Text background raw colour.
Definition: fbcon.h:132
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54

References fbcon_text_cell::background, fbcon::background, fbcon_text_cell::character, fbcon::character, fbcon_cell(), fbcon_text_cell::foreground, fbcon::foreground, fbcon_geometry::height, and fbcon_geometry::width.

Referenced by fbcon_handle_ed(), fbcon_init(), and fbcon_scroll().

◆ fbcon_draw()

static void fbcon_draw ( struct fbcon fbcon,
struct fbcon_text_cell cell,
unsigned int  xpos,
unsigned int  ypos 
)
static

Draw character at specified position.

Parameters
fbconFrame buffer console
cellText cell
xposX position
yposY position

Definition at line 153 of file fbcon.c.

154  {
155  const uint8_t *glyph;
156  size_t offset;
157  size_t pixel_len;
158  size_t skip_len;
159  unsigned int row;
160  unsigned int column;
161  uint8_t bitmask;
162  int transparent;
163  const void *src;
164 
165  /* Get font character */
166  glyph = fbcon->font->glyph ( cell->character );
167 
168  /* Calculate pixel geometry */
169  offset = ( fbcon->indent +
170  ( ypos * fbcon->character.stride ) +
171  ( xpos * fbcon->character.len ) );
172  pixel_len = fbcon->pixel->len;
173  skip_len = ( fbcon->pixel->stride - fbcon->character.len );
174 
175  /* Check for transparent background colour */
176  transparent = ( cell->background == FBCON_TRANSPARENT );
177 
178  /* Draw character rows */
179  for ( row = 0 ; row < fbcon->font->height ; row++ ) {
180 
181  /* Draw background picture, if applicable */
182  if ( transparent ) {
183  if ( fbcon->picture.start ) {
184  memcpy ( ( fbcon->start + offset ),
185  ( fbcon->picture.start + offset ),
186  fbcon->character.len );
187  } else {
188  memset ( ( fbcon->start + offset ), 0,
189  fbcon->character.len );
190  }
191  }
192 
193  /* Draw character row */
194  for ( column = FBCON_CHAR_WIDTH, bitmask = glyph[row] ;
195  column ; column--, bitmask <<= 1, offset += pixel_len ) {
196  if ( bitmask & 0x80 ) {
197  src = &cell->foreground;
198  } else if ( ! transparent ) {
199  src = &cell->background;
200  } else {
201  continue;
202  }
203  memcpy ( ( fbcon->start + offset ), src, pixel_len );
204  }
205 
206  /* Move to next row */
207  offset += skip_len;
208  }
209 }
unsigned int height
Character height (in pixels)
Definition: fbcon.h:35
struct fbcon_font * font
Font definition.
Definition: fbcon.h:128
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:120
void * start
Start address.
Definition: fbcon.h:108
struct fbcon_geometry * pixel
Pixel geometry.
Definition: fbcon.h:118
uint32_t background
Background colour.
Definition: fbcon.h:94
void * memcpy(void *dest, const void *src, size_t len) __nonnull
size_t len
Length of a single entity.
Definition: fbcon.h:56
A frame buffer console.
Definition: fbcon.h:112
static const void * src
Definition: string.h:47
unsigned int character
Unicode character.
Definition: fbcon.h:96
uint32_t foreground
Foreground colour.
Definition: fbcon.h:92
unsigned char uint8_t
Definition: stdint.h:10
#define FBCON_CHAR_WIDTH
Character width, in pixels.
Definition: fbcon.h:18
#define FBCON_TRANSPARENT
Transparent background magic colour (raw colour value)
Definition: fbcon.h:24
const uint8_t *(* glyph)(unsigned int character)
Get character glyph.
Definition: fbcon.h:42
void * start
Start address.
Definition: fbcon.h:114
struct fbcon_picture picture
Background picture.
Definition: fbcon.h:146
size_t indent
Indent to first character (in bytes)
Definition: fbcon.h:124
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
size_t stride
Stride (offset between vertically adjacent entities)
Definition: fbcon.h:58
void * memset(void *dest, int character, size_t len) __nonnull

References fbcon_text_cell::background, fbcon_text_cell::character, fbcon::character, FBCON_CHAR_WIDTH, FBCON_TRANSPARENT, fbcon::font, fbcon_text_cell::foreground, fbcon_font::glyph, fbcon_font::height, fbcon::indent, fbcon_geometry::len, memcpy(), memset(), offset, fbcon::picture, fbcon::pixel, src, fbcon_picture::start, fbcon::start, and fbcon_geometry::stride.

Referenced by fbcon_draw_cursor(), fbcon_putchar(), fbcon_redraw(), and fbcon_scroll().

◆ fbcon_redraw()

static void fbcon_redraw ( struct fbcon fbcon)
static

Redraw all characters.

Parameters
fbconFrame buffer console

Definition at line 216 of file fbcon.c.

216  {
217  struct fbcon_text_cell *cell;
218  unsigned int xpos;
219  unsigned int ypos;
220 
221  /* Redraw characters */
222  cell = fbcon_cell ( fbcon, 0, 0 );
223  for ( ypos = 0 ; ypos < fbcon->character.height ; ypos++ ) {
224  for ( xpos = 0 ; xpos < fbcon->character.width ; xpos++ ) {
225  fbcon_draw ( fbcon, cell, xpos, ypos );
226  cell++;
227  }
228  }
229 }
static void fbcon_draw(struct fbcon *fbcon, struct fbcon_text_cell *cell, unsigned int xpos, unsigned int ypos)
Draw character at specified position.
Definition: fbcon.c:153
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:52
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:120
A frame buffer text cell.
Definition: fbcon.h:90
A frame buffer console.
Definition: fbcon.h:112
static struct fbcon_text_cell * fbcon_cell(struct fbcon *fbcon, unsigned int xpos, unsigned int ypos)
Get character cell.
Definition: fbcon.c:114
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54

References fbcon::character, fbcon_cell(), fbcon_draw(), fbcon_geometry::height, and fbcon_geometry::width.

Referenced by fbcon_handle_ed().

◆ fbcon_scroll()

static void fbcon_scroll ( struct fbcon fbcon)
static

Scroll screen.

Parameters
fbconFrame buffer console

Definition at line 236 of file fbcon.c.

236  {
237  const struct fbcon_text_cell *old;
238  struct fbcon_text_cell *new;
239  unsigned int xpos;
240  unsigned int ypos;
241  unsigned int character;
244 
245  /* Sanity check */
247 
248  /* Scroll up character array */
249  new = fbcon_cell ( fbcon, 0, 0 );
250  old = fbcon_cell ( fbcon, 0, 1 );
251  for ( ypos = 0 ; ypos < ( fbcon->character.height - 1 ) ; ypos++ ) {
252  for ( xpos = 0 ; xpos < fbcon->character.width ; xpos++ ) {
253  /* Redraw character (if changed) */
254  character = old->character;
255  foreground = old->foreground;
256  background = old->background;
257  if ( ( new->character != character ) ||
258  ( new->foreground != foreground ) ||
259  ( new->background != background ) ) {
260  new->character = character;
261  new->foreground = foreground;
262  new->background = background;
263  fbcon_draw ( fbcon, new, xpos, ypos );
264  }
265  new++;
266  old++;
267  }
268  }
269 
270  /* Clear bottom row */
271  fbcon_clear ( fbcon, ypos );
272  for ( xpos = 0 ; xpos < fbcon->character.width ; xpos++ )
273  fbcon_draw ( fbcon, new++, xpos, ypos );
274 
275  /* Update cursor position */
276  fbcon->ypos--;
277 }
static void fbcon_draw(struct fbcon *fbcon, struct fbcon_text_cell *cell, unsigned int xpos, unsigned int ypos)
Draw character at specified position.
Definition: fbcon.c:153
unsigned int ypos
Text cursor Y position.
Definition: fbcon.h:138
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:52
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:120
int old
Definition: bitops.h:64
A frame buffer text cell.
Definition: fbcon.h:90
static void fbcon_clear(struct fbcon *fbcon, unsigned int ypos)
Clear rows of characters.
Definition: fbcon.c:129
uint32_t background
Background colour.
Definition: fbcon.h:94
A frame buffer console.
Definition: fbcon.h:112
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
unsigned int character
Unicode character.
Definition: fbcon.h:96
uint32_t foreground
Foreground colour.
Definition: fbcon.h:92
unsigned int uint32_t
Definition: stdint.h:12
static struct fbcon_text_cell * fbcon_cell(struct fbcon *fbcon, unsigned int xpos, unsigned int ypos)
Get character cell.
Definition: fbcon.c:114
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54

References assert(), fbcon_text_cell::background, fbcon_text_cell::character, fbcon::character, fbcon_cell(), fbcon_clear(), fbcon_draw(), fbcon_text_cell::foreground, fbcon_geometry::height, old, fbcon_geometry::width, and fbcon::ypos.

Referenced by fbcon_putchar().

◆ fbcon_draw_cursor()

static void fbcon_draw_cursor ( struct fbcon fbcon,
int  show_cursor 
)
static

Draw character at cursor position.

Parameters
fbconFrame buffer console
show_cursorShow cursor

Definition at line 285 of file fbcon.c.

285  {
286  struct fbcon_text_cell *cell;
287  struct fbcon_text_cell cursor;
288 
289  cell = fbcon_cell ( fbcon, fbcon->xpos, fbcon->ypos );
290  if ( show_cursor ) {
291  cursor.background = fbcon->foreground;
292  cursor.foreground =
294  0 : fbcon->background );
295  cursor.character = cell->character;
296  cell = &cursor;
297  }
298  fbcon_draw ( fbcon, cell, fbcon->xpos, fbcon->ypos );
299 }
static void fbcon_draw(struct fbcon *fbcon, struct fbcon_text_cell *cell, unsigned int xpos, unsigned int ypos)
Draw character at specified position.
Definition: fbcon.c:153
unsigned int ypos
Text cursor Y position.
Definition: fbcon.h:138
A frame buffer text cell.
Definition: fbcon.h:90
uint32_t foreground
Text foreground raw colour.
Definition: fbcon.h:130
A frame buffer console.
Definition: fbcon.h:112
unsigned int xpos
Text cursor X position.
Definition: fbcon.h:136
static struct fbcon_text_cell * fbcon_cell(struct fbcon *fbcon, unsigned int xpos, unsigned int ypos)
Get character cell.
Definition: fbcon.c:114
uint32_t background
Text background raw colour.
Definition: fbcon.h:132
#define FBCON_TRANSPARENT
Transparent background magic colour (raw colour value)
Definition: fbcon.h:24

References fbcon_text_cell::background, fbcon::background, fbcon_text_cell::character, fbcon_cell(), fbcon_draw(), FBCON_TRANSPARENT, fbcon_text_cell::foreground, fbcon::foreground, fbcon::xpos, and fbcon::ypos.

Referenced by fbcon_handle_cup(), fbcon_handle_dectcem_reset(), fbcon_handle_dectcem_set(), fbcon_handle_ed(), and fbcon_putchar().

◆ fbcon_handle_cup()

static void fbcon_handle_cup ( struct ansiesc_context ctx,
unsigned int count  __unused,
int  params[] 
)
static

Handle ANSI CUP (cursor position)

Parameters
ctxANSI escape sequence context
countParameter count
params[0]Row (1 is top)
params[1]Column (1 is left)

Definition at line 309 of file fbcon.c.

310  {
311  struct fbcon *fbcon = container_of ( ctx, struct fbcon, ctx );
312  int cx = ( params[1] - 1 );
313  int cy = ( params[0] - 1 );
314 
315  fbcon_draw_cursor ( fbcon, 0 );
316  fbcon->xpos = cx;
317  if ( fbcon->xpos >= fbcon->character.width )
318  fbcon->xpos = 0;
319  fbcon->ypos = cy;
320  if ( fbcon->ypos >= fbcon->character.height )
321  fbcon->ypos = 0;
323 }
unsigned int ypos
Text cursor Y position.
Definition: fbcon.h:138
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:52
static void fbcon_draw_cursor(struct fbcon *fbcon, int show_cursor)
Draw character at cursor position.
Definition: fbcon.c:285
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:120
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
uint16_t cx
Definition: registers.h:51
A frame buffer console.
Definition: fbcon.h:112
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
unsigned int xpos
Text cursor X position.
Definition: fbcon.h:136
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54
int show_cursor
Display cursor.
Definition: fbcon.h:148

References fbcon::character, container_of, ctx, cx, fbcon_draw_cursor(), fbcon_geometry::height, fbcon::show_cursor, fbcon_geometry::width, fbcon::xpos, and fbcon::ypos.

◆ fbcon_handle_ed()

static void fbcon_handle_ed ( struct ansiesc_context ctx,
unsigned int count  __unused,
int params []  __unused 
)
static

Handle ANSI ED (erase in page)

Parameters
ctxANSI escape sequence context
countParameter count
params[0]Region to erase

Definition at line 332 of file fbcon.c.

334  {
335  struct fbcon *fbcon = container_of ( ctx, struct fbcon, ctx );
336 
337  /* We assume that we always clear the whole screen */
338  assert ( params[0] == ANSIESC_ED_ALL );
339 
340  /* Clear character array */
341  fbcon_clear ( fbcon, 0 );
342 
343  /* Redraw all characters */
344  fbcon_redraw ( fbcon );
345 
346  /* Reset cursor position */
347  fbcon->xpos = 0;
348  fbcon->ypos = 0;
350 }
unsigned int ypos
Text cursor Y position.
Definition: fbcon.h:138
static void fbcon_draw_cursor(struct fbcon *fbcon, int show_cursor)
Draw character at cursor position.
Definition: fbcon.c:285
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
static void fbcon_clear(struct fbcon *fbcon, unsigned int ypos)
Clear rows of characters.
Definition: fbcon.c:129
#define ANSIESC_ED_ALL
Erase whole page.
Definition: ansiesc.h:115
A frame buffer console.
Definition: fbcon.h:112
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
unsigned int xpos
Text cursor X position.
Definition: fbcon.h:136
int show_cursor
Display cursor.
Definition: fbcon.h:148
static void fbcon_redraw(struct fbcon *fbcon)
Redraw all characters.
Definition: fbcon.c:216

References ANSIESC_ED_ALL, assert(), container_of, ctx, fbcon_clear(), fbcon_draw_cursor(), fbcon_redraw(), fbcon::show_cursor, fbcon::xpos, and fbcon::ypos.

◆ fbcon_handle_sgr()

static void fbcon_handle_sgr ( struct ansiesc_context ctx,
unsigned int  count,
int  params[] 
)
static

Handle ANSI SGR (set graphics rendition)

Parameters
ctxANSI escape sequence context
countParameter count
paramsList of graphic rendition aspects

Definition at line 359 of file fbcon.c.

360  {
361  struct fbcon *fbcon = container_of ( ctx, struct fbcon, ctx );
362  uint32_t *custom = NULL;
363  uint32_t rgb;
364  unsigned int end;
365  unsigned int i;
366  int aspect;
367 
368  for ( i = 0 ; i < count ; i++ ) {
369 
370  /* Process aspect */
371  aspect = params[i];
372  if ( aspect == 0 ) {
375  } else if ( aspect == 1 ) {
377  } else if ( aspect == 22 ) {
378  fbcon->bold = 0;
379  } else if ( ( aspect >= 30 ) && ( aspect <= 37 ) ) {
380  fbcon->foreground =
381  fbcon_ansi_colour ( fbcon, aspect - 30 );
382  } else if ( aspect == 38 ) {
383  custom = &fbcon->foreground;
384  } else if ( aspect == 39 ) {
386  } else if ( ( aspect >= 40 ) && ( aspect <= 47 ) ) {
387  fbcon->background =
388  fbcon_ansi_colour ( fbcon, aspect - 40 );
389  } else if ( aspect == 48 ) {
390  custom = &fbcon->background;
391  } else if ( aspect == 49 ) {
393  }
394 
395  /* Process custom RGB colour, if applicable
396  *
397  * We support the xterm-compatible
398  * "<ESC>[38;2;<red>;<green>;<blue>m" and
399  * "<ESC>[48;2;<red>;<green>;<blue>m" sequences.
400  */
401  if ( custom ) {
402  rgb = 0;
403  end = ( i + 5 );
404  for ( ; ( i < count ) && ( i < end ) ; i++ )
405  rgb = ( ( rgb << 8 ) | params[i] );
406  *custom = fbcon_colour ( fbcon, rgb );
407  custom = NULL;
408  }
409  }
410 }
#define FBCON_BOLD
Bold colour modifier (RGB value)
Definition: fbcon.h:21
static uint32_t fbcon_ansi_colour(struct fbcon *fbcon, unsigned int ansicol)
Calculate ANSI font colour.
Definition: fbcon.c:71
static uint32_t fbcon_colour(struct fbcon *fbcon, uint32_t rgb)
Calculate raw colour value.
Definition: fbcon.c:51
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
uint32_t foreground
Text foreground raw colour.
Definition: fbcon.h:130
A frame buffer console.
Definition: fbcon.h:112
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static void fbcon_set_default_background(struct fbcon *fbcon)
Set default background colour.
Definition: fbcon.c:100
static unsigned int count
Number of entries.
Definition: dwmac.h:225
unsigned int uint32_t
Definition: stdint.h:12
uint32_t background
Text background raw colour.
Definition: fbcon.h:132
uint32_t end
Ending offset.
Definition: netvsc.h:18
uint32_t bold
Bold colour modifier raw colour.
Definition: fbcon.h:134
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static void fbcon_set_default_foreground(struct fbcon *fbcon)
Set default foreground colour.
Definition: fbcon.c:88

References fbcon::background, fbcon::bold, container_of, count, ctx, end, fbcon_ansi_colour(), FBCON_BOLD, fbcon_colour(), fbcon_set_default_background(), fbcon_set_default_foreground(), fbcon::foreground, and NULL.

◆ fbcon_handle_dectcem_set()

static void fbcon_handle_dectcem_set ( struct ansiesc_context ctx,
unsigned int count  __unused,
int params []  __unused 
)
static

Handle ANSI DECTCEM set (show cursor)

Parameters
ctxANSI escape sequence context
countParameter count
paramsList of graphic rendition aspects

Definition at line 419 of file fbcon.c.

421  {
422  struct fbcon *fbcon = container_of ( ctx, struct fbcon, ctx );
423 
424  fbcon->show_cursor = 1;
425  fbcon_draw_cursor ( fbcon, 1 );
426 }
static void fbcon_draw_cursor(struct fbcon *fbcon, int show_cursor)
Draw character at cursor position.
Definition: fbcon.c:285
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
A frame buffer console.
Definition: fbcon.h:112
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
int show_cursor
Display cursor.
Definition: fbcon.h:148

References container_of, ctx, fbcon_draw_cursor(), and fbcon::show_cursor.

◆ fbcon_handle_dectcem_reset()

static void fbcon_handle_dectcem_reset ( struct ansiesc_context ctx,
unsigned int count  __unused,
int params []  __unused 
)
static

Handle ANSI DECTCEM reset (hide cursor)

Parameters
ctxANSI escape sequence context
countParameter count
paramsList of graphic rendition aspects

Definition at line 435 of file fbcon.c.

437  {
438  struct fbcon *fbcon = container_of ( ctx, struct fbcon, ctx );
439 
440  fbcon->show_cursor = 0;
441  fbcon_draw_cursor ( fbcon, 0 );
442 }
static void fbcon_draw_cursor(struct fbcon *fbcon, int show_cursor)
Draw character at cursor position.
Definition: fbcon.c:285
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
A frame buffer console.
Definition: fbcon.h:112
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
int show_cursor
Display cursor.
Definition: fbcon.h:148

References container_of, ctx, fbcon_draw_cursor(), and fbcon::show_cursor.

◆ fbcon_putchar()

void fbcon_putchar ( struct fbcon fbcon,
int  character 
)

Print a character to current cursor position.

Parameters
fbconFrame buffer console
characterCharacter

Definition at line 460 of file fbcon.c.

460  {
461  struct fbcon_text_cell *cell;
462 
463  /* Intercept ANSI escape sequences */
465  if ( character < 0 )
466  return;
467 
468  /* Accumulate Unicode characters */
470  if ( character == 0 )
471  return;
472 
473  /* Handle control characters */
474  switch ( character ) {
475  case '\r':
476  fbcon_draw_cursor ( fbcon, 0 );
477  fbcon->xpos = 0;
478  break;
479  case '\n':
480  fbcon_draw_cursor ( fbcon, 0 );
481  fbcon->xpos = 0;
482  fbcon->ypos++;
483  break;
484  case '\b':
485  fbcon_draw_cursor ( fbcon, 0 );
486  if ( fbcon->xpos ) {
487  fbcon->xpos--;
488  } else if ( fbcon->ypos ) {
489  fbcon->xpos = ( fbcon->character.width - 1 );
490  fbcon->ypos--;
491  }
492  break;
493  default:
494  /* Print character at current cursor position */
495  cell = fbcon_cell ( fbcon, fbcon->xpos, fbcon->ypos );
496  cell->foreground = ( fbcon->foreground | fbcon->bold );
497  cell->background = fbcon->background;
498  cell->character = character;
499  fbcon_draw ( fbcon, cell, fbcon->xpos, fbcon->ypos );
500 
501  /* Advance cursor */
502  fbcon->xpos++;
503  if ( fbcon->xpos >= fbcon->character.width ) {
504  fbcon->xpos = 0;
505  fbcon->ypos++;
506  }
507  break;
508  }
509 
510  /* Scroll screen if necessary */
511  if ( fbcon->ypos >= fbcon->character.height )
512  fbcon_scroll ( fbcon );
513 
514  /* Show cursor */
516 }
static void fbcon_draw(struct fbcon *fbcon, struct fbcon_text_cell *cell, unsigned int xpos, unsigned int ypos)
Draw character at specified position.
Definition: fbcon.c:153
unsigned int ypos
Text cursor Y position.
Definition: fbcon.h:138
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:52
static void fbcon_draw_cursor(struct fbcon *fbcon, int show_cursor)
Draw character at cursor position.
Definition: fbcon.c:285
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:120
struct ansiesc_context ctx
ANSI escape sequence context.
Definition: fbcon.h:140
A frame buffer text cell.
Definition: fbcon.h:90
int ansiesc_process(struct ansiesc_context *ctx, int c)
Process character that may be part of ANSI escape sequence.
Definition: ansiesc.c:74
static void fbcon_scroll(struct fbcon *fbcon)
Scroll screen.
Definition: fbcon.c:236
uint32_t background
Background colour.
Definition: fbcon.h:94
uint32_t foreground
Text foreground raw colour.
Definition: fbcon.h:130
A frame buffer console.
Definition: fbcon.h:112
unsigned int character
Unicode character.
Definition: fbcon.h:96
uint32_t foreground
Foreground colour.
Definition: fbcon.h:92
unsigned int xpos
Text cursor X position.
Definition: fbcon.h:136
static struct fbcon_text_cell * fbcon_cell(struct fbcon *fbcon, unsigned int xpos, unsigned int ypos)
Get character cell.
Definition: fbcon.c:114
uint32_t background
Text background raw colour.
Definition: fbcon.h:132
struct utf8_accumulator utf8
UTF-8 accumulator.
Definition: fbcon.h:142
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54
unsigned int utf8_accumulate(struct utf8_accumulator *utf8, uint8_t byte)
Accumulate Unicode character from UTF-8 byte sequence.
Definition: utf8.c:43
uint32_t bold
Bold colour modifier raw colour.
Definition: fbcon.h:134
int show_cursor
Display cursor.
Definition: fbcon.h:148

References ansiesc_process(), fbcon_text_cell::background, fbcon::background, fbcon::bold, fbcon_text_cell::character, fbcon::character, fbcon::ctx, fbcon_cell(), fbcon_draw(), fbcon_draw_cursor(), fbcon_scroll(), fbcon_text_cell::foreground, fbcon::foreground, fbcon_geometry::height, fbcon::show_cursor, fbcon::utf8, utf8_accumulate(), fbcon_geometry::width, fbcon::xpos, and fbcon::ypos.

Referenced by efifb_putchar(), and vesafb_putchar().

◆ fbcon_picture_init()

static int fbcon_picture_init ( struct fbcon fbcon,
struct pixel_buffer pixbuf 
)
static

Initialise background picture.

Parameters
fbconFrame buffer console
pixbufBackground picture
Return values
rcReturn status code

Definition at line 525 of file fbcon.c.

526  {
527  struct fbcon_geometry *pixel = fbcon->pixel;
528  struct fbcon_picture *picture = &fbcon->picture;
529  size_t len;
530  size_t indent;
531  size_t offset;
532  const uint32_t *rgb;
533  uint32_t raw;
534  unsigned int x;
535  unsigned int y;
536  unsigned int width;
537  unsigned int height;
538  int xgap;
539  int ygap;
540  int rc;
541 
542  /* Allocate buffer */
543  len = ( pixel->height * pixel->stride );
544  picture->start = umalloc ( len );
545  if ( ! picture->start ) {
546  DBGC ( fbcon, "FBCON %p could not allocate %zd bytes for "
547  "picture\n", fbcon, len );
548  rc = -ENOMEM;
549  goto err_umalloc;
550  }
551 
552  /* Centre picture on console */
553  xgap = ( ( ( int ) ( pixel->width - pixbuf->width ) ) / 2 );
554  ygap = ( ( ( int ) ( pixel->height - pixbuf->height ) ) / 2 );
555  indent = ( ( ( ( ygap >= 0 ) ? ygap : 0 ) * pixel->stride ) +
556  ( ( ( xgap >= 0 ) ? xgap : 0 ) * pixel->len ) );
557  width = pixbuf->width;
558  if ( width > pixel->width )
559  width = pixel->width;
560  height = pixbuf->height;
561  if ( height > pixel->height )
562  height = pixel->height;
563  DBGC ( fbcon, "FBCON %p picture is pixel %dx%d at [%d,%d),[%d,%d)\n",
564  fbcon, width, height, xgap, ( xgap + pixbuf->width ), ygap,
565  ( ygap + pixbuf->height ) );
566 
567  /* Convert to frame buffer raw format */
568  memset ( picture->start, 0, len );
569  for ( y = 0 ; y < height ; y++ ) {
570  offset = ( indent + ( y * pixel->stride ) );
571  rgb = pixbuf_pixel ( pixbuf, ( ( xgap < 0 ) ? -xgap : 0 ),
572  ( ( ( ygap < 0 ) ? -ygap : 0 ) + y ) );
573  for ( x = 0 ; x < width ; x++ ) {
574  raw = fbcon_colour ( fbcon, *rgb );
575  memcpy ( ( picture->start + offset ), &raw,
576  pixel->len );
577  offset += pixel->len;
578  rgb++;
579  }
580  }
581 
582  return 0;
583 
584  ufree ( picture->start );
585  err_umalloc:
586  return rc;
587 }
static __always_inline void ufree(void *ptr)
Free external memory.
Definition: umalloc.h:67
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A frame buffer geometry.
Definition: fbcon.h:50
unsigned int height
Height.
Definition: pixbuf.h:22
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:52
#define DBGC(...)
Definition: compiler.h:505
void * start
Start address.
Definition: fbcon.h:108
static unsigned int x
Definition: pixbuf.h:62
static uint32_t fbcon_colour(struct fbcon *fbcon, uint32_t rgb)
Calculate raw colour value.
Definition: fbcon.c:51
struct fbcon_geometry * pixel
Pixel geometry.
Definition: fbcon.h:118
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
A frame buffer background picture.
Definition: fbcon.h:106
size_t len
Length of a single entity.
Definition: fbcon.h:56
A frame buffer console.
Definition: fbcon.h:112
ring len
Length.
Definition: dwmac.h:231
unsigned int uint32_t
Definition: stdint.h:12
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54
static __always_inline void * umalloc(size_t size)
Allocate external memory.
Definition: umalloc.h:56
static unsigned int unsigned int y
Definition: pixbuf.h:62
__be32 raw[7]
Definition: CIB_PRM.h:28
struct fbcon_picture picture
Background picture.
Definition: fbcon.h:146
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
size_t stride
Stride (offset between vertically adjacent entities)
Definition: fbcon.h:58
unsigned int width
Width.
Definition: pixbuf.h:20
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, ENOMEM, fbcon_colour(), pixel_buffer::height, fbcon_geometry::height, fbcon_geometry::len, len, memcpy(), memset(), offset, fbcon::picture, fbcon::pixel, raw, rc, fbcon_picture::start, fbcon_geometry::stride, ufree(), umalloc(), pixel_buffer::width, fbcon_geometry::width, x, and y.

Referenced by fbcon_init().

◆ fbcon_init()

int fbcon_init ( struct fbcon fbcon,
void *  start,
struct fbcon_geometry pixel,
struct fbcon_colour_map map,
struct fbcon_font font,
struct console_configuration config 
)

Initialise frame buffer console.

Parameters
fbconFrame buffer console
startStart address
pixelPixel geometry
mapColour mapping
fontFont definition
configConsole configuration
Return values
rcReturn status code

Definition at line 600 of file fbcon.c.

604  {
605  int width;
606  int height;
607  unsigned int xgap;
608  unsigned int ygap;
609  unsigned int left;
610  unsigned int right;
611  unsigned int top;
612  unsigned int bottom;
613  int rc;
614 
615  /* Initialise data structure */
616  memset ( fbcon, 0, sizeof ( *fbcon ) );
617  fbcon->start = start;
618  fbcon->pixel = pixel;
619  assert ( pixel->len <= sizeof ( uint32_t ) );
620  fbcon->map = map;
621  fbcon->font = font;
623  fbcon->show_cursor = 1;
624 
625  /* Derive overall length */
626  fbcon->len = ( pixel->height * pixel->stride );
627  DBGC ( fbcon, "FBCON %p at [%08lx,%08lx)\n", fbcon,
628  virt_to_phys ( fbcon->start ),
629  ( virt_to_phys ( fbcon->start ) + fbcon->len ) );
630 
631  /* Calculate margin. If the actual screen size is larger than
632  * the requested screen size, then update the margins so that
633  * the margin remains relative to the requested screen size.
634  * (As an exception, if a zero margin was specified then treat
635  * this as meaning "expand to edge of actual screen".)
636  */
637  xgap = ( pixel->width - config->width );
638  ygap = ( pixel->height - config->height );
639  left = ( xgap / 2 );
640  right = ( xgap - left );
641  top = ( ygap / 2 );
642  bottom = ( ygap - top );
643  fbcon->margin.left = ( config->left + ( config->left ? left : 0 ) );
644  fbcon->margin.right = ( config->right + ( config->right ? right : 0 ) );
645  fbcon->margin.top = ( config->top + ( config->top ? top : 0 ) );
646  fbcon->margin.bottom =
647  ( config->bottom + ( config->bottom ? bottom : 0 ) );
648 
649  /* Expand margin to accommodate whole characters */
650  width = ( pixel->width - fbcon->margin.left - fbcon->margin.right );
651  height = ( pixel->height - fbcon->margin.top - fbcon->margin.bottom );
652  if ( ( width < FBCON_CHAR_WIDTH ) ||
653  ( height < ( ( int ) font->height ) ) ) {
654  DBGC ( fbcon, "FBCON %p has unusable character area "
655  "[%d-%d),[%d-%d)\n", fbcon, fbcon->margin.left,
656  ( pixel->width - fbcon->margin.right ),
657  fbcon->margin.top,
658  ( pixel->height - fbcon->margin.bottom ) );
659  rc = -EINVAL;
660  goto err_margin;
661  }
662  xgap = ( width % FBCON_CHAR_WIDTH );
663  ygap = ( height % font->height );
664  fbcon->margin.left += ( xgap / 2 );
665  fbcon->margin.top += ( ygap / 2 );
666  fbcon->margin.right += ( xgap - ( xgap / 2 ) );
667  fbcon->margin.bottom += ( ygap - ( ygap / 2 ) );
668  fbcon->indent = ( ( fbcon->margin.top * pixel->stride ) +
669  ( fbcon->margin.left * pixel->len ) );
670 
671  /* Derive character geometry from pixel geometry */
672  fbcon->character.width = ( width / FBCON_CHAR_WIDTH );
673  fbcon->character.height = ( height / font->height );
674  fbcon->character.len = ( pixel->len * FBCON_CHAR_WIDTH );
675  fbcon->character.stride = ( pixel->stride * font->height );
676  DBGC ( fbcon, "FBCON %p is pixel %dx%d, char %dx%d at "
677  "[%d-%d),[%d-%d)\n", fbcon, fbcon->pixel->width,
680  ( fbcon->pixel->width - fbcon->margin.right ),
681  fbcon->margin.top,
682  ( fbcon->pixel->height - fbcon->margin.bottom ) );
683 
684  /* Set default colours */
687 
688  /* Allocate and initialise stored character array */
691  sizeof ( fbcon->text.cells[0] ) );
692  if ( ! fbcon->text.cells ) {
693  rc = -ENOMEM;
694  goto err_text;
695  }
696  fbcon_clear ( fbcon, 0 );
697 
698  /* Set framebuffer to all black (including margins) */
699  memset ( fbcon->start, 0, fbcon->len );
700 
701  /* Generate pixel buffer from background image, if applicable */
702  if ( config->pixbuf &&
703  ( ( rc = fbcon_picture_init ( fbcon, config->pixbuf ) ) != 0 ) )
704  goto err_picture;
705 
706  /* Draw background picture (including margins), if applicable */
707  if ( fbcon->picture.start )
709 
710  /* Update console width and height */
712 
713  return 0;
714 
715  ufree ( fbcon->picture.start );
716  err_picture:
717  ufree ( fbcon->text.cells );
718  err_text:
719  err_margin:
720  return rc;
721 }
static void console_set_size(unsigned int width, unsigned int height)
Set console size.
Definition: console.h:201
static __always_inline void ufree(void *ptr)
Free external memory.
Definition: umalloc.h:67
unsigned int height
Character height (in pixels)
Definition: fbcon.h:35
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static struct ansiesc_handler fbcon_ansiesc_handlers[]
ANSI escape sequence handlers.
Definition: fbcon.c:445
struct ansiesc_handler * handlers
Array of handlers.
Definition: ansiesc.h:79
unsigned int height
Height.
Definition: console.h:28
unsigned int bottom
Bottom margin.
Definition: fbcon.h:70
struct fbcon_font * font
Font definition.
Definition: fbcon.h:128
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:52
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:120
#define DBGC(...)
Definition: compiler.h:505
struct ansiesc_context ctx
ANSI escape sequence context.
Definition: fbcon.h:140
void * start
Start address.
Definition: fbcon.h:108
unsigned int width
Width.
Definition: console.h:26
static void fbcon_clear(struct fbcon *fbcon, unsigned int ypos)
Clear rows of characters.
Definition: fbcon.c:129
struct fbcon_geometry * pixel
Pixel geometry.
Definition: fbcon.h:118
unsigned int left
Left margin.
Definition: fbcon.h:64
uint32_t start
Starting offset.
Definition: netvsc.h:12
unsigned int bottom
Bottom margin.
Definition: console.h:38
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
size_t len
Length of a single entity.
Definition: fbcon.h:56
A frame buffer console.
Definition: fbcon.h:112
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void fbcon_set_default_background(struct fbcon *fbcon)
Set default background colour.
Definition: fbcon.c:100
unsigned int top
Top margin.
Definition: fbcon.h:68
struct fbcon_margin margin
Margin.
Definition: fbcon.h:122
unsigned int right
Right margin.
Definition: console.h:34
unsigned int uint32_t
Definition: stdint.h:12
#define FBCON_CHAR_WIDTH
Character width, in pixels.
Definition: fbcon.h:18
static int fbcon_picture_init(struct fbcon *fbcon, struct pixel_buffer *pixbuf)
Initialise background picture.
Definition: fbcon.c:525
struct fbcon_text_cell * cells
Stored text cells.
Definition: fbcon.h:102
struct fbcon_text text
Text array.
Definition: fbcon.h:144
size_t len
Length of one complete displayed screen.
Definition: fbcon.h:116
static __always_inline int struct dma_mapping * map
Definition: dma.h:183
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54
struct pixel_buffer * pixbuf
Background picture, if any.
Definition: console.h:40
static __always_inline void * umalloc(size_t size)
Allocate external memory.
Definition: umalloc.h:56
unsigned int top
Top margin.
Definition: console.h:36
unsigned int right
Right margin.
Definition: fbcon.h:66
void * start
Start address.
Definition: fbcon.h:114
struct fbcon_picture picture
Background picture.
Definition: fbcon.h:146
size_t indent
Indent to first character (in bytes)
Definition: fbcon.h:124
struct fbcon_colour_map * map
Colour mapping.
Definition: fbcon.h:126
int show_cursor
Display cursor.
Definition: fbcon.h:148
static void fbcon_set_default_foreground(struct fbcon *fbcon)
Set default foreground colour.
Definition: fbcon.c:88
size_t stride
Stride (offset between vertically adjacent entities)
Definition: fbcon.h:58
unsigned int left
Left margin.
Definition: console.h:32
void * memset(void *dest, int character, size_t len) __nonnull

References assert(), console_configuration::bottom, fbcon_margin::bottom, fbcon_text::cells, fbcon::character, console_set_size(), fbcon::ctx, DBGC, EINVAL, ENOMEM, fbcon_ansiesc_handlers, FBCON_CHAR_WIDTH, fbcon_clear(), fbcon_picture_init(), fbcon_set_default_background(), fbcon_set_default_foreground(), fbcon::font, ansiesc_context::handlers, console_configuration::height, fbcon_font::height, fbcon_geometry::height, fbcon::indent, console_configuration::left, fbcon_margin::left, fbcon_geometry::len, fbcon::len, fbcon::map, map, fbcon::margin, memcpy(), memset(), fbcon::picture, console_configuration::pixbuf, fbcon::pixel, rc, console_configuration::right, fbcon_margin::right, fbcon::show_cursor, start, fbcon_picture::start, fbcon::start, fbcon_geometry::stride, fbcon::text, console_configuration::top, fbcon_margin::top, ufree(), umalloc(), console_configuration::width, and fbcon_geometry::width.

Referenced by efifb_init(), and vesafb_init().

◆ fbcon_fini()

void fbcon_fini ( struct fbcon fbcon)

Finalise frame buffer console.

Parameters
fbconFrame buffer console

Definition at line 728 of file fbcon.c.

728  {
729 
730  ufree ( fbcon->text.cells );
731  ufree ( fbcon->picture.start );
732 }
static __always_inline void ufree(void *ptr)
Free external memory.
Definition: umalloc.h:67
void * start
Start address.
Definition: fbcon.h:108
A frame buffer console.
Definition: fbcon.h:112
struct fbcon_text_cell * cells
Stored text cells.
Definition: fbcon.h:102
struct fbcon_text text
Text array.
Definition: fbcon.h:144
struct fbcon_picture picture
Background picture.
Definition: fbcon.h:146

References fbcon_text::cells, fbcon::picture, fbcon_picture::start, fbcon::text, and ufree().

Referenced by efifb_fini(), efifb_init(), vesafb_fini(), and vesafb_init().

Variable Documentation

◆ fbcon_ansiesc_handlers

struct ansiesc_handler fbcon_ansiesc_handlers[]
static
Initial value:
= {
{ 0, NULL }
}
static void fbcon_handle_dectcem_reset(struct ansiesc_context *ctx, unsigned int count __unused, int params[] __unused)
Handle ANSI DECTCEM reset (hide cursor)
Definition: fbcon.c:435
static void fbcon_handle_cup(struct ansiesc_context *ctx, unsigned int count __unused, int params[])
Handle ANSI CUP (cursor position)
Definition: fbcon.c:309
#define ANSIESC_ED
Erase in page.
Definition: ansiesc.h:106
#define ANSIESC_CUP
Cursor position.
Definition: ansiesc.h:103
static void fbcon_handle_ed(struct ansiesc_context *ctx, unsigned int count __unused, int params[] __unused)
Handle ANSI ED (erase in page)
Definition: fbcon.c:332
static void fbcon_handle_sgr(struct ansiesc_context *ctx, unsigned int count, int params[])
Handle ANSI SGR (set graphics rendition)
Definition: fbcon.c:359
#define ANSIESC_SGR
Select graphic rendition.
Definition: ansiesc.h:118
static void fbcon_handle_dectcem_set(struct ansiesc_context *ctx, unsigned int count __unused, int params[] __unused)
Handle ANSI DECTCEM set (show cursor)
Definition: fbcon.c:419
#define ANSIESC_DECTCEM_RESET
Hide cursor.
Definition: ansiesc.h:131
#define ANSIESC_DECTCEM_SET
Show cursor.
Definition: ansiesc.h:128
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

ANSI escape sequence handlers.

Definition at line 445 of file fbcon.c.

Referenced by fbcon_init().