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)
 
 FILE_SECBOOT (PERMITTED)
 
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  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ 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 52 of file fbcon.c.

52  {
53  struct fbcon_colour_map *map = fbcon->map;
54  uint8_t red = ( rgb >> 16 );
55  uint8_t green = ( rgb >> 8 );
56  uint8_t blue = ( rgb >> 0 );
57  uint32_t mapped;
58 
59  mapped = ( ( ( red >> map->red_scale ) << map->red_lsb ) |
60  ( ( green >> map->green_scale ) << map->green_lsb ) |
61  ( ( blue >> map->blue_scale ) << map->blue_lsb ) );
62  return cpu_to_le32 ( mapped );
63 }
A frame buffer console.
Definition: fbcon.h:113
A frame buffer colour mapping.
Definition: fbcon.h:75
#define cpu_to_le32(value)
Definition: byteswap.h:108
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:184
struct fbcon_colour_map * map
Colour mapping.
Definition: fbcon.h:127

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 72 of file fbcon.c.

73  {
74  uint32_t rgb;
75 
76  /* Treat ansicol as 3-bit BGR with intensity 0xaa */
77  rgb = ( ( ( ansicol & ( 1 << 0 ) ) ? 0xaa0000 : 0 ) |
78  ( ( ansicol & ( 1 << 1 ) ) ? 0x00aa00 : 0 ) |
79  ( ( ansicol & ( 1 << 2 ) ) ? 0x0000aa : 0 ) );
80 
81  return fbcon_colour ( fbcon, rgb );
82 }
static uint32_t fbcon_colour(struct fbcon *fbcon, uint32_t rgb)
Calculate raw colour value.
Definition: fbcon.c:52
A frame buffer console.
Definition: fbcon.h:113
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 89 of file fbcon.c.

89  {
90 
91  /* Default to non-bold white foreground */
93  fbcon->bold = 0;
94 }
static uint32_t fbcon_ansi_colour(struct fbcon *fbcon, unsigned int ansicol)
Calculate ANSI font colour.
Definition: fbcon.c:72
uint32_t foreground
Text foreground raw colour.
Definition: fbcon.h:131
A frame buffer console.
Definition: fbcon.h:113
uint32_t bold
Bold colour modifier raw colour.
Definition: fbcon.h:135

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 101 of file fbcon.c.

101  {
102 
103  /* Default to transparent background */
105 }
A frame buffer console.
Definition: fbcon.h:113
uint32_t background
Text background raw colour.
Definition: fbcon.h:133
#define FBCON_TRANSPARENT
Transparent background magic colour (raw colour value)
Definition: fbcon.h:25

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 115 of file fbcon.c.

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

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 130 of file fbcon.c.

130  {
131  struct fbcon_text_cell *cell;
132  unsigned int xpos;
133 
134  /* Clear stored character array */
135  cell = fbcon_cell ( fbcon, 0, ypos );
136  for ( ; ypos < fbcon->character.height ; ypos++ ) {
137  for ( xpos = 0 ; xpos < fbcon->character.width ; xpos++ ) {
138  cell->foreground = fbcon->foreground;
139  cell->background = fbcon->background;
140  cell->character = ' ';
141  cell++;
142  }
143  }
144 }
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:53
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:121
A frame buffer text cell.
Definition: fbcon.h:91
uint32_t background
Background colour.
Definition: fbcon.h:95
uint32_t foreground
Text foreground raw colour.
Definition: fbcon.h:131
A frame buffer console.
Definition: fbcon.h:113
unsigned int character
Unicode character.
Definition: fbcon.h:97
uint32_t foreground
Foreground colour.
Definition: fbcon.h:93
static struct fbcon_text_cell * fbcon_cell(struct fbcon *fbcon, unsigned int xpos, unsigned int ypos)
Get character cell.
Definition: fbcon.c:115
uint32_t background
Text background raw colour.
Definition: fbcon.h:133
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:55

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 154 of file fbcon.c.

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

217  {
218  struct fbcon_text_cell *cell;
219  unsigned int xpos;
220  unsigned int ypos;
221 
222  /* Redraw characters */
223  cell = fbcon_cell ( fbcon, 0, 0 );
224  for ( ypos = 0 ; ypos < fbcon->character.height ; ypos++ ) {
225  for ( xpos = 0 ; xpos < fbcon->character.width ; xpos++ ) {
226  fbcon_draw ( fbcon, cell, xpos, ypos );
227  cell++;
228  }
229  }
230 }
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:154
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:53
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:121
A frame buffer text cell.
Definition: fbcon.h:91
A frame buffer console.
Definition: fbcon.h:113
static struct fbcon_text_cell * fbcon_cell(struct fbcon *fbcon, unsigned int xpos, unsigned int ypos)
Get character cell.
Definition: fbcon.c:115
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:55

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 237 of file fbcon.c.

237  {
238  const struct fbcon_text_cell *old;
239  struct fbcon_text_cell *new;
240  unsigned int xpos;
241  unsigned int ypos;
242  unsigned int character;
245 
246  /* Sanity check */
248 
249  /* Scroll up character array */
250  new = fbcon_cell ( fbcon, 0, 0 );
251  old = fbcon_cell ( fbcon, 0, 1 );
252  for ( ypos = 0 ; ypos < ( fbcon->character.height - 1 ) ; ypos++ ) {
253  for ( xpos = 0 ; xpos < fbcon->character.width ; xpos++ ) {
254  /* Redraw character (if changed) */
255  character = old->character;
256  foreground = old->foreground;
257  background = old->background;
258  if ( ( new->character != character ) ||
259  ( new->foreground != foreground ) ||
260  ( new->background != background ) ) {
261  new->character = character;
262  new->foreground = foreground;
263  new->background = background;
264  fbcon_draw ( fbcon, new, xpos, ypos );
265  }
266  new++;
267  old++;
268  }
269  }
270 
271  /* Clear bottom row */
272  fbcon_clear ( fbcon, ypos );
273  for ( xpos = 0 ; xpos < fbcon->character.width ; xpos++ )
274  fbcon_draw ( fbcon, new++, xpos, ypos );
275 
276  /* Update cursor position */
277  fbcon->ypos--;
278 }
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:154
unsigned int ypos
Text cursor Y position.
Definition: fbcon.h:139
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:53
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:121
int old
Definition: bitops.h:65
A frame buffer text cell.
Definition: fbcon.h:91
static void fbcon_clear(struct fbcon *fbcon, unsigned int ypos)
Clear rows of characters.
Definition: fbcon.c:130
uint32_t background
Background colour.
Definition: fbcon.h:95
A frame buffer console.
Definition: fbcon.h:113
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
unsigned int character
Unicode character.
Definition: fbcon.h:97
uint32_t foreground
Foreground colour.
Definition: fbcon.h:93
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:115
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:55

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 286 of file fbcon.c.

286  {
287  struct fbcon_text_cell *cell;
288  struct fbcon_text_cell cursor;
289 
290  cell = fbcon_cell ( fbcon, fbcon->xpos, fbcon->ypos );
291  if ( show_cursor ) {
292  cursor.background = fbcon->foreground;
293  cursor.foreground =
295  0 : fbcon->background );
296  cursor.character = cell->character;
297  cell = &cursor;
298  }
299  fbcon_draw ( fbcon, cell, fbcon->xpos, fbcon->ypos );
300 }
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:154
unsigned int ypos
Text cursor Y position.
Definition: fbcon.h:139
A frame buffer text cell.
Definition: fbcon.h:91
uint32_t foreground
Text foreground raw colour.
Definition: fbcon.h:131
A frame buffer console.
Definition: fbcon.h:113
unsigned int xpos
Text cursor X position.
Definition: fbcon.h:137
static struct fbcon_text_cell * fbcon_cell(struct fbcon *fbcon, unsigned int xpos, unsigned int ypos)
Get character cell.
Definition: fbcon.c:115
uint32_t background
Text background raw colour.
Definition: fbcon.h:133
#define FBCON_TRANSPARENT
Transparent background magic colour (raw colour value)
Definition: fbcon.h:25

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 310 of file fbcon.c.

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

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 333 of file fbcon.c.

335  {
336  struct fbcon *fbcon = container_of ( ctx, struct fbcon, ctx );
337 
338  /* We assume that we always clear the whole screen */
339  assert ( params[0] == ANSIESC_ED_ALL );
340 
341  /* Clear character array */
342  fbcon_clear ( fbcon, 0 );
343 
344  /* Redraw all characters */
345  fbcon_redraw ( fbcon );
346 
347  /* Reset cursor position */
348  fbcon->xpos = 0;
349  fbcon->ypos = 0;
351 }
unsigned int ypos
Text cursor Y position.
Definition: fbcon.h:139
static void fbcon_draw_cursor(struct fbcon *fbcon, int show_cursor)
Draw character at cursor position.
Definition: fbcon.c:286
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:130
#define ANSIESC_ED_ALL
Erase whole page.
Definition: ansiesc.h:116
A frame buffer console.
Definition: fbcon.h:113
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:36
unsigned int xpos
Text cursor X position.
Definition: fbcon.h:137
int show_cursor
Display cursor.
Definition: fbcon.h:149
static void fbcon_redraw(struct fbcon *fbcon)
Redraw all characters.
Definition: fbcon.c:217

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 360 of file fbcon.c.

361  {
362  struct fbcon *fbcon = container_of ( ctx, struct fbcon, ctx );
363  uint32_t *custom = NULL;
364  uint32_t rgb;
365  unsigned int end;
366  unsigned int i;
367  int aspect;
368 
369  for ( i = 0 ; i < count ; i++ ) {
370 
371  /* Process aspect */
372  aspect = params[i];
373  if ( aspect == 0 ) {
376  } else if ( aspect == 1 ) {
378  } else if ( aspect == 22 ) {
379  fbcon->bold = 0;
380  } else if ( ( aspect >= 30 ) && ( aspect <= 37 ) ) {
381  fbcon->foreground =
382  fbcon_ansi_colour ( fbcon, aspect - 30 );
383  } else if ( aspect == 38 ) {
384  custom = &fbcon->foreground;
385  } else if ( aspect == 39 ) {
387  } else if ( ( aspect >= 40 ) && ( aspect <= 47 ) ) {
388  fbcon->background =
389  fbcon_ansi_colour ( fbcon, aspect - 40 );
390  } else if ( aspect == 48 ) {
391  custom = &fbcon->background;
392  } else if ( aspect == 49 ) {
394  }
395 
396  /* Process custom RGB colour, if applicable
397  *
398  * We support the xterm-compatible
399  * "<ESC>[38;2;<red>;<green>;<blue>m" and
400  * "<ESC>[48;2;<red>;<green>;<blue>m" sequences.
401  */
402  if ( custom ) {
403  rgb = 0;
404  end = ( i + 5 );
405  for ( ; ( i < count ) && ( i < end ) ; i++ )
406  rgb = ( ( rgb << 8 ) | params[i] );
407  *custom = fbcon_colour ( fbcon, rgb );
408  custom = NULL;
409  }
410  }
411 }
#define FBCON_BOLD
Bold colour modifier (RGB value)
Definition: fbcon.h:22
static uint32_t fbcon_ansi_colour(struct fbcon *fbcon, unsigned int ansicol)
Calculate ANSI font colour.
Definition: fbcon.c:72
static uint32_t fbcon_colour(struct fbcon *fbcon, uint32_t rgb)
Calculate raw colour value.
Definition: fbcon.c:52
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
uint32_t foreground
Text foreground raw colour.
Definition: fbcon.h:131
A frame buffer console.
Definition: fbcon.h:113
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:36
static void fbcon_set_default_background(struct fbcon *fbcon)
Set default background colour.
Definition: fbcon.c:101
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:133
uint32_t end
Ending offset.
Definition: netvsc.h:18
uint32_t bold
Bold colour modifier raw colour.
Definition: fbcon.h:135
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
static void fbcon_set_default_foreground(struct fbcon *fbcon)
Set default foreground colour.
Definition: fbcon.c:89

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 420 of file fbcon.c.

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

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 436 of file fbcon.c.

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

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 461 of file fbcon.c.

461  {
462  struct fbcon_text_cell *cell;
463 
464  /* Intercept ANSI escape sequences */
466  if ( character < 0 )
467  return;
468 
469  /* Accumulate Unicode characters */
471  if ( character == 0 )
472  return;
473 
474  /* Handle control characters */
475  switch ( character ) {
476  case '\r':
477  fbcon_draw_cursor ( fbcon, 0 );
478  fbcon->xpos = 0;
479  break;
480  case '\n':
481  fbcon_draw_cursor ( fbcon, 0 );
482  fbcon->xpos = 0;
483  fbcon->ypos++;
484  break;
485  case '\b':
486  fbcon_draw_cursor ( fbcon, 0 );
487  if ( fbcon->xpos ) {
488  fbcon->xpos--;
489  } else if ( fbcon->ypos ) {
490  fbcon->xpos = ( fbcon->character.width - 1 );
491  fbcon->ypos--;
492  }
493  break;
494  default:
495  /* Print character at current cursor position */
496  cell = fbcon_cell ( fbcon, fbcon->xpos, fbcon->ypos );
497  cell->foreground = ( fbcon->foreground | fbcon->bold );
498  cell->background = fbcon->background;
499  cell->character = character;
500  fbcon_draw ( fbcon, cell, fbcon->xpos, fbcon->ypos );
501 
502  /* Advance cursor */
503  fbcon->xpos++;
504  if ( fbcon->xpos >= fbcon->character.width ) {
505  fbcon->xpos = 0;
506  fbcon->ypos++;
507  }
508  break;
509  }
510 
511  /* Scroll screen if necessary */
512  if ( fbcon->ypos >= fbcon->character.height )
513  fbcon_scroll ( fbcon );
514 
515  /* Show cursor */
517 }
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:154
unsigned int ypos
Text cursor Y position.
Definition: fbcon.h:139
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:53
static void fbcon_draw_cursor(struct fbcon *fbcon, int show_cursor)
Draw character at cursor position.
Definition: fbcon.c:286
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:121
struct ansiesc_context ctx
ANSI escape sequence context.
Definition: fbcon.h:141
A frame buffer text cell.
Definition: fbcon.h:91
int ansiesc_process(struct ansiesc_context *ctx, int c)
Process character that may be part of ANSI escape sequence.
Definition: ansiesc.c:75
static void fbcon_scroll(struct fbcon *fbcon)
Scroll screen.
Definition: fbcon.c:237
uint32_t background
Background colour.
Definition: fbcon.h:95
uint32_t foreground
Text foreground raw colour.
Definition: fbcon.h:131
A frame buffer console.
Definition: fbcon.h:113
unsigned int character
Unicode character.
Definition: fbcon.h:97
uint32_t foreground
Foreground colour.
Definition: fbcon.h:93
unsigned int xpos
Text cursor X position.
Definition: fbcon.h:137
static struct fbcon_text_cell * fbcon_cell(struct fbcon *fbcon, unsigned int xpos, unsigned int ypos)
Get character cell.
Definition: fbcon.c:115
uint32_t background
Text background raw colour.
Definition: fbcon.h:133
struct utf8_accumulator utf8
UTF-8 accumulator.
Definition: fbcon.h:143
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:55
unsigned int utf8_accumulate(struct utf8_accumulator *utf8, uint8_t byte)
Accumulate Unicode character from UTF-8 byte sequence.
Definition: utf8.c:44
uint32_t bold
Bold colour modifier raw colour.
Definition: fbcon.h:135
int show_cursor
Display cursor.
Definition: fbcon.h:149

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 526 of file fbcon.c.

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

605  {
606  int width;
607  int height;
608  unsigned int xgap;
609  unsigned int ygap;
610  unsigned int left;
611  unsigned int right;
612  unsigned int top;
613  unsigned int bottom;
614  int rc;
615 
616  /* Initialise data structure */
617  memset ( fbcon, 0, sizeof ( *fbcon ) );
618  fbcon->start = start;
619  fbcon->pixel = pixel;
620  assert ( pixel->len <= sizeof ( uint32_t ) );
621  fbcon->map = map;
622  fbcon->font = font;
624  fbcon->show_cursor = 1;
625 
626  /* Derive overall length */
627  fbcon->len = ( pixel->height * pixel->stride );
628  DBGC ( fbcon, "FBCON %p at [%08lx,%08lx)\n", fbcon,
629  virt_to_phys ( fbcon->start ),
630  ( virt_to_phys ( fbcon->start ) + fbcon->len ) );
631 
632  /* Calculate margin. If the actual screen size is larger than
633  * the requested screen size, then update the margins so that
634  * the margin remains relative to the requested screen size.
635  * (As an exception, if a zero margin was specified then treat
636  * this as meaning "expand to edge of actual screen".)
637  */
638  xgap = ( pixel->width - config->width );
639  ygap = ( pixel->height - config->height );
640  left = ( xgap / 2 );
641  right = ( xgap - left );
642  top = ( ygap / 2 );
643  bottom = ( ygap - top );
644  fbcon->margin.left = ( config->left + ( config->left ? left : 0 ) );
645  fbcon->margin.right = ( config->right + ( config->right ? right : 0 ) );
646  fbcon->margin.top = ( config->top + ( config->top ? top : 0 ) );
647  fbcon->margin.bottom =
648  ( config->bottom + ( config->bottom ? bottom : 0 ) );
649 
650  /* Expand margin to accommodate whole characters */
651  width = ( pixel->width - fbcon->margin.left - fbcon->margin.right );
652  height = ( pixel->height - fbcon->margin.top - fbcon->margin.bottom );
653  if ( ( width < FBCON_CHAR_WIDTH ) ||
654  ( height < ( ( int ) font->height ) ) ) {
655  DBGC ( fbcon, "FBCON %p has unusable character area "
656  "[%d-%d),[%d-%d)\n", fbcon, fbcon->margin.left,
657  ( pixel->width - fbcon->margin.right ),
658  fbcon->margin.top,
659  ( pixel->height - fbcon->margin.bottom ) );
660  rc = -EINVAL;
661  goto err_margin;
662  }
663  xgap = ( width % FBCON_CHAR_WIDTH );
664  ygap = ( height % font->height );
665  fbcon->margin.left += ( xgap / 2 );
666  fbcon->margin.top += ( ygap / 2 );
667  fbcon->margin.right += ( xgap - ( xgap / 2 ) );
668  fbcon->margin.bottom += ( ygap - ( ygap / 2 ) );
669  fbcon->indent = ( ( fbcon->margin.top * pixel->stride ) +
670  ( fbcon->margin.left * pixel->len ) );
671 
672  /* Derive character geometry from pixel geometry */
673  fbcon->character.width = ( width / FBCON_CHAR_WIDTH );
674  fbcon->character.height = ( height / font->height );
675  fbcon->character.len = ( pixel->len * FBCON_CHAR_WIDTH );
676  fbcon->character.stride = ( pixel->stride * font->height );
677  DBGC ( fbcon, "FBCON %p is pixel %dx%d, char %dx%d at "
678  "[%d-%d),[%d-%d)\n", fbcon, fbcon->pixel->width,
681  ( fbcon->pixel->width - fbcon->margin.right ),
682  fbcon->margin.top,
683  ( fbcon->pixel->height - fbcon->margin.bottom ) );
684 
685  /* Set default colours */
688 
689  /* Allocate and initialise stored character array */
692  sizeof ( fbcon->text.cells[0] ) );
693  if ( ! fbcon->text.cells ) {
694  rc = -ENOMEM;
695  goto err_text;
696  }
697  fbcon_clear ( fbcon, 0 );
698 
699  /* Set framebuffer to all black (including margins) */
700  memset ( fbcon->start, 0, fbcon->len );
701 
702  /* Generate pixel buffer from background image, if applicable */
703  if ( config->pixbuf &&
704  ( ( rc = fbcon_picture_init ( fbcon, config->pixbuf ) ) != 0 ) )
705  goto err_picture;
706 
707  /* Draw background picture (including margins), if applicable */
708  if ( fbcon->picture.start )
710 
711  /* Update console width and height */
713 
714  return 0;
715 
716  ufree ( fbcon->picture.start );
717  err_picture:
718  ufree ( fbcon->text.cells );
719  err_text:
720  err_margin:
721  return rc;
722 }
static void console_set_size(unsigned int width, unsigned int height)
Set console size.
Definition: console.h:202
static __always_inline void ufree(void *ptr)
Free external memory.
Definition: umalloc.h:68
unsigned int height
Character height (in pixels)
Definition: fbcon.h:36
#define EINVAL
Invalid argument.
Definition: errno.h:429
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static struct ansiesc_handler fbcon_ansiesc_handlers[]
ANSI escape sequence handlers.
Definition: fbcon.c:446
struct ansiesc_handler * handlers
Array of handlers.
Definition: ansiesc.h:80
unsigned int height
Height.
Definition: console.h:29
unsigned int bottom
Bottom margin.
Definition: fbcon.h:71
struct fbcon_font * font
Font definition.
Definition: fbcon.h:129
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:53
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:121
#define DBGC(...)
Definition: compiler.h:505
struct ansiesc_context ctx
ANSI escape sequence context.
Definition: fbcon.h:141
void * start
Start address.
Definition: fbcon.h:109
unsigned int width
Width.
Definition: console.h:27
static void fbcon_clear(struct fbcon *fbcon, unsigned int ypos)
Clear rows of characters.
Definition: fbcon.c:130
struct fbcon_geometry * pixel
Pixel geometry.
Definition: fbcon.h:119
unsigned int left
Left margin.
Definition: fbcon.h:65
uint32_t start
Starting offset.
Definition: netvsc.h:12
unsigned int bottom
Bottom margin.
Definition: console.h:39
#define ENOMEM
Not enough space.
Definition: errno.h:535
void * memcpy(void *dest, const void *src, size_t len) __nonnull
size_t len
Length of a single entity.
Definition: fbcon.h:57
A frame buffer console.
Definition: fbcon.h:113
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:101
unsigned int top
Top margin.
Definition: fbcon.h:69
struct fbcon_margin margin
Margin.
Definition: fbcon.h:123
unsigned int right
Right margin.
Definition: console.h:35
unsigned int uint32_t
Definition: stdint.h:12
#define FBCON_CHAR_WIDTH
Character width, in pixels.
Definition: fbcon.h:19
static int fbcon_picture_init(struct fbcon *fbcon, struct pixel_buffer *pixbuf)
Initialise background picture.
Definition: fbcon.c:526
struct fbcon_text_cell * cells
Stored text cells.
Definition: fbcon.h:103
struct fbcon_text text
Text array.
Definition: fbcon.h:145
size_t len
Length of one complete displayed screen.
Definition: fbcon.h:117
static __always_inline int struct dma_mapping * map
Definition: dma.h:184
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:55
struct pixel_buffer * pixbuf
Background picture, if any.
Definition: console.h:41
static __always_inline void * umalloc(size_t size)
Allocate external memory.
Definition: umalloc.h:57
unsigned int top
Top margin.
Definition: console.h:37
unsigned int right
Right margin.
Definition: fbcon.h:67
void * start
Start address.
Definition: fbcon.h:115
struct fbcon_picture picture
Background picture.
Definition: fbcon.h:147
size_t indent
Indent to first character (in bytes)
Definition: fbcon.h:125
struct fbcon_colour_map * map
Colour mapping.
Definition: fbcon.h:127
int show_cursor
Display cursor.
Definition: fbcon.h:149
static void fbcon_set_default_foreground(struct fbcon *fbcon)
Set default foreground colour.
Definition: fbcon.c:89
size_t stride
Stride (offset between vertically adjacent entities)
Definition: fbcon.h:59
unsigned int left
Left margin.
Definition: console.h:33
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 729 of file fbcon.c.

729  {
730 
731  ufree ( fbcon->text.cells );
732  ufree ( fbcon->picture.start );
733 }
static __always_inline void ufree(void *ptr)
Free external memory.
Definition: umalloc.h:68
void * start
Start address.
Definition: fbcon.h:109
A frame buffer console.
Definition: fbcon.h:113
struct fbcon_text_cell * cells
Stored text cells.
Definition: fbcon.h:103
struct fbcon_text text
Text array.
Definition: fbcon.h:145
struct fbcon_picture picture
Background picture.
Definition: fbcon.h:147

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:436
static void fbcon_handle_cup(struct ansiesc_context *ctx, unsigned int count __unused, int params[])
Handle ANSI CUP (cursor position)
Definition: fbcon.c:310
#define ANSIESC_ED
Erase in page.
Definition: ansiesc.h:107
#define ANSIESC_CUP
Cursor position.
Definition: ansiesc.h:104
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:333
static void fbcon_handle_sgr(struct ansiesc_context *ctx, unsigned int count, int params[])
Handle ANSI SGR (set graphics rendition)
Definition: fbcon.c:360
#define ANSIESC_SGR
Select graphic rendition.
Definition: ansiesc.h:119
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:420
#define ANSIESC_DECTCEM_RESET
Hide cursor.
Definition: ansiesc.h:132
#define ANSIESC_DECTCEM_SET
Show cursor.
Definition: ansiesc.h:129
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

ANSI escape sequence handlers.

Definition at line 446 of file fbcon.c.

Referenced by fbcon_init().