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/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 void fbcon_clear (struct fbcon *fbcon, unsigned int ypos)
 Clear rows of characters. More...
 
static void fbcon_store (struct fbcon *fbcon, struct fbcon_text_cell *cell, unsigned int xpos, unsigned int ypos)
 Store character at specified position. 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, userptr_t 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 50 of file fbcon.c.

50  {
51  struct fbcon_colour_map *map = fbcon->map;
52  uint8_t red = ( rgb >> 16 );
53  uint8_t green = ( rgb >> 8 );
54  uint8_t blue = ( rgb >> 0 );
55  uint32_t mapped;
56 
57  mapped = ( ( ( red >> map->red_scale ) << map->red_lsb ) |
58  ( ( green >> map->green_scale ) << map->green_lsb ) |
59  ( ( blue >> map->blue_scale ) << map->blue_lsb ) );
60  return cpu_to_le32 ( mapped );
61 }
uint8_t green_lsb
Green LSB.
Definition: fbcon.h:84
uint8_t red_lsb
Red LSB.
Definition: fbcon.h:82
uint8_t red_scale
Red scale (right shift amount from 24-bit RGB)
Definition: fbcon.h:76
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
uint8_t green_scale
Green scale (right shift amount from 24-bit RGB)
Definition: fbcon.h:78
unsigned char uint8_t
Definition: stdint.h:10
unsigned int uint32_t
Definition: stdint.h:12
uint8_t blue_scale
Blue scale (right shift amount from 24-bit RGB)
Definition: fbcon.h:80
uint8_t blue_lsb
Blue LSB.
Definition: fbcon.h:86
struct fbcon_colour_map * map
Colour mapping.
Definition: fbcon.h:126

References fbcon_colour_map::blue_lsb, fbcon_colour_map::blue_scale, cpu_to_le32, fbcon_colour_map::green_lsb, fbcon_colour_map::green_scale, fbcon::map, fbcon_colour_map::red_lsb, and fbcon_colour_map::red_scale.

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

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

87  {
88 
89  /* Default to non-bold white foreground */
91  fbcon->bold = 0;
92 }
static uint32_t fbcon_ansi_colour(struct fbcon *fbcon, unsigned int ansicol)
Calculate ANSI font colour.
Definition: fbcon.c:70
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 99 of file fbcon.c.

99  {
100 
101  /* Default to transparent background */
103 }
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_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 111 of file fbcon.c.

111  {
112  struct fbcon_text_cell cell = {
114  .background = fbcon->background,
115  .character = ' ',
116  };
117  size_t offset;
118  unsigned int xpos;
119 
120  /* Clear stored character array */
121  for ( ; ypos < fbcon->character.height ; ypos++ ) {
122  offset = ( ypos * fbcon->character.width * sizeof ( cell ) );
123  for ( xpos = 0 ; xpos < fbcon->character.width ; xpos++ ) {
124  copy_to_user ( fbcon->text.start, offset, &cell,
125  sizeof ( cell ) );
126  offset += sizeof ( cell );
127  }
128  }
129 }
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 foreground
Text foreground raw colour.
Definition: fbcon.h:130
A frame buffer console.
Definition: fbcon.h:112
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
userptr_t start
Stored text cells.
Definition: fbcon.h:102
uint32_t foreground
Foreground colour.
Definition: fbcon.h:92
static __always_inline void copy_to_user(userptr_t dest, off_t dest_off, const void *src, size_t len)
Copy data to user buffer.
Definition: uaccess.h:324
uint32_t background
Text background raw colour.
Definition: fbcon.h:132
struct fbcon_text text
Text array.
Definition: fbcon.h:142
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54

References fbcon::background, fbcon::character, copy_to_user(), fbcon_text_cell::foreground, fbcon::foreground, fbcon_geometry::height, offset, fbcon_text::start, fbcon::text, and fbcon_geometry::width.

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

◆ fbcon_store()

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

Store character at specified position.

Parameters
fbconFrame buffer console
cellText cell
xposX position
yposY position

Definition at line 139 of file fbcon.c.

140  {
141  size_t offset;
142 
143  /* Store cell */
144  offset = ( ( ( ypos * fbcon->character.width ) + xpos ) *
145  sizeof ( *cell ) );
146  copy_to_user ( fbcon->text.start, offset, cell, sizeof ( *cell ) );
147 }
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 console.
Definition: fbcon.h:112
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
userptr_t start
Stored text cells.
Definition: fbcon.h:102
static __always_inline void copy_to_user(userptr_t dest, off_t dest_off, const void *src, size_t len)
Copy data to user buffer.
Definition: uaccess.h:324
struct fbcon_text text
Text array.
Definition: fbcon.h:142

References fbcon::character, copy_to_user(), offset, fbcon_text::start, fbcon::text, and fbcon_geometry::width.

Referenced by fbcon_putchar().

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

158  {
159  uint8_t glyph[fbcon->font->height];
160  size_t offset;
161  size_t pixel_len;
162  size_t skip_len;
163  unsigned int row;
164  unsigned int column;
165  uint8_t bitmask;
166  int transparent;
167  void *src;
168 
169  /* Get font character */
170  fbcon->font->glyph ( cell->character, glyph );
171 
172  /* Calculate pixel geometry */
173  offset = ( fbcon->indent +
174  ( ypos * fbcon->character.stride ) +
175  ( xpos * fbcon->character.len ) );
176  pixel_len = fbcon->pixel->len;
177  skip_len = ( fbcon->pixel->stride - fbcon->character.len );
178 
179  /* Check for transparent background colour */
180  transparent = ( cell->background == FBCON_TRANSPARENT );
181 
182  /* Draw character rows */
183  for ( row = 0 ; row < fbcon->font->height ; row++ ) {
184 
185  /* Draw background picture, if applicable */
186  if ( transparent ) {
187  if ( fbcon->picture.start ) {
190  fbcon->character.len );
191  } else {
192  memset_user ( fbcon->start, offset, 0,
193  fbcon->character.len );
194  }
195  }
196 
197  /* Draw character row */
198  for ( column = FBCON_CHAR_WIDTH, bitmask = glyph[row] ;
199  column ; column--, bitmask <<= 1, offset += pixel_len ) {
200  if ( bitmask & 0x80 ) {
201  src = &cell->foreground;
202  } else if ( ! transparent ) {
203  src = &cell->background;
204  } else {
205  continue;
206  }
207  copy_to_user ( fbcon->start, offset, src, pixel_len );
208  }
209 
210  /* Move to next row */
211  offset += skip_len;
212  }
213 }
unsigned int height
Character height (in pixels)
Definition: fbcon.h:35
userptr_t start
Start address.
Definition: fbcon.h:108
struct fbcon_font * font
Font definition.
Definition: fbcon.h:128
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:120
void(* glyph)(unsigned int character, uint8_t *glyph)
Get character glyph.
Definition: fbcon.h:42
struct fbcon_geometry * pixel
Pixel geometry.
Definition: fbcon.h:118
void memset_user(userptr_t userptr, off_t offset, int c, size_t len)
Fill user buffer with a constant byte.
uint32_t background
Background colour.
Definition: fbcon.h:94
size_t len
Length of a single entity.
Definition: fbcon.h:56
A frame buffer console.
Definition: fbcon.h:112
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
unsigned int character
Character.
Definition: fbcon.h:96
static __always_inline void off_t userptr_t src
Definition: efi_uaccess.h:66
uint32_t foreground
Foreground colour.
Definition: fbcon.h:92
static __always_inline void copy_to_user(userptr_t dest, off_t dest_off, const void *src, size_t len)
Copy data to user buffer.
Definition: uaccess.h:324
uint32_t column[4]
Viewed as an array of four-byte columns.
Definition: aes.h:14
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
struct fbcon_picture picture
Background picture.
Definition: fbcon.h:144
size_t indent
Indent to first character (in bytes)
Definition: fbcon.h:124
userptr_t start
Start address.
Definition: fbcon.h:114
size_t stride
Stride (offset between vertically adjacent entities)
Definition: fbcon.h:58
void memcpy_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers.

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

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

◆ fbcon_redraw()

static void fbcon_redraw ( struct fbcon fbcon)
static

Redraw all characters.

Parameters
fbconFrame buffer console

Definition at line 220 of file fbcon.c.

220  {
221  struct fbcon_text_cell cell;
222  size_t offset = 0;
223  unsigned int xpos;
224  unsigned int ypos;
225 
226  /* Redraw characters */
227  for ( ypos = 0 ; ypos < fbcon->character.height ; ypos++ ) {
228  for ( xpos = 0 ; xpos < fbcon->character.width ; xpos++ ) {
229  copy_from_user ( &cell, fbcon->text.start, offset,
230  sizeof ( cell ) );
231  fbcon_draw ( fbcon, &cell, xpos, ypos );
232  offset += sizeof ( cell );
233  }
234  }
235 }
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:157
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:52
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
Definition: uaccess.h:337
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 userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
userptr_t start
Stored text cells.
Definition: fbcon.h:102
struct fbcon_text text
Text array.
Definition: fbcon.h:142
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54

References fbcon::character, copy_from_user(), fbcon_draw(), fbcon_geometry::height, offset, fbcon_text::start, fbcon::text, and fbcon_geometry::width.

Referenced by fbcon_handle_ed(), and fbcon_scroll().

◆ fbcon_scroll()

static void fbcon_scroll ( struct fbcon fbcon)
static

Scroll screen.

Parameters
fbconFrame buffer console

Definition at line 242 of file fbcon.c.

242  {
243  size_t row_len;
244 
245  /* Sanity check */
247 
248  /* Scroll up character array */
249  row_len = ( fbcon->character.width * sizeof ( struct fbcon_text_cell ));
250  memmove_user ( fbcon->text.start, 0, fbcon->text.start, row_len,
251  ( row_len * ( fbcon->character.height - 1 ) ) );
252  fbcon_clear ( fbcon, ( fbcon->character.height - 1 ) );
253 
254  /* Update cursor position */
255  fbcon->ypos--;
256 
257  /* Redraw all characters */
258  fbcon_redraw ( fbcon );
259 }
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
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:111
A frame buffer console.
Definition: fbcon.h:112
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
userptr_t start
Stored text cells.
Definition: fbcon.h:102
struct fbcon_text text
Text array.
Definition: fbcon.h:142
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54
void memmove_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers, allowing for overlap.
static void fbcon_redraw(struct fbcon *fbcon)
Redraw all characters.
Definition: fbcon.c:220

References assert(), fbcon::character, fbcon_clear(), fbcon_redraw(), fbcon_geometry::height, memmove_user(), fbcon_text::start, fbcon::text, 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 267 of file fbcon.c.

267  {
268  struct fbcon_text_cell cell;
269  size_t offset;
270 
271  offset = ( ( ( fbcon->ypos * fbcon->character.width ) + fbcon->xpos ) *
272  sizeof ( cell ) );
273  copy_from_user ( &cell, fbcon->text.start, offset, sizeof ( cell ) );
274  if ( show_cursor ) {
275  cell.background = fbcon->foreground;
276  cell.foreground = ( ( fbcon->background == FBCON_TRANSPARENT ) ?
277  0 : fbcon->background );
278  }
279  fbcon_draw ( fbcon, &cell, fbcon->xpos, fbcon->ypos );
280 }
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:157
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 __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
Definition: uaccess.h:337
struct fbcon_geometry character
Character geometry.
Definition: fbcon.h:120
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
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
userptr_t start
Stored text cells.
Definition: fbcon.h:102
unsigned int xpos
Text cursor X position.
Definition: fbcon.h:136
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
struct fbcon_text text
Text array.
Definition: fbcon.h:142

References fbcon_text_cell::background, fbcon::background, fbcon::character, copy_from_user(), fbcon_draw(), FBCON_TRANSPARENT, fbcon_text_cell::foreground, fbcon::foreground, offset, fbcon_text::start, fbcon::text, fbcon_geometry::width, 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 290 of file fbcon.c.

291  {
292  struct fbcon *fbcon = container_of ( ctx, struct fbcon, ctx );
293  int cx = ( params[1] - 1 );
294  int cy = ( params[0] - 1 );
295 
296  fbcon_draw_cursor ( fbcon, 0 );
297  fbcon->xpos = cx;
298  if ( fbcon->xpos >= fbcon->character.width )
299  fbcon->xpos = 0;
300  fbcon->ypos = cy;
301  if ( fbcon->ypos >= fbcon->character.height )
302  fbcon->ypos = 0;
304 }
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:267
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:146

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

315  {
316  struct fbcon *fbcon = container_of ( ctx, struct fbcon, ctx );
317 
318  /* We assume that we always clear the whole screen */
319  assert ( params[0] == ANSIESC_ED_ALL );
320 
321  /* Clear character array */
322  fbcon_clear ( fbcon, 0 );
323 
324  /* Redraw all characters */
325  fbcon_redraw ( fbcon );
326 
327  /* Reset cursor position */
328  fbcon->xpos = 0;
329  fbcon->ypos = 0;
331 }
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:267
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:111
#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:146
static void fbcon_redraw(struct fbcon *fbcon)
Redraw all characters.
Definition: fbcon.c:220

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

341  {
342  struct fbcon *fbcon = container_of ( ctx, struct fbcon, ctx );
343  uint32_t *custom = NULL;
344  uint32_t rgb;
345  unsigned int end;
346  unsigned int i;
347  int aspect;
348 
349  for ( i = 0 ; i < count ; i++ ) {
350 
351  /* Process aspect */
352  aspect = params[i];
353  if ( aspect == 0 ) {
356  } else if ( aspect == 1 ) {
358  } else if ( aspect == 22 ) {
359  fbcon->bold = 0;
360  } else if ( ( aspect >= 30 ) && ( aspect <= 37 ) ) {
361  fbcon->foreground =
362  fbcon_ansi_colour ( fbcon, aspect - 30 );
363  } else if ( aspect == 38 ) {
364  custom = &fbcon->foreground;
365  } else if ( aspect == 39 ) {
367  } else if ( ( aspect >= 40 ) && ( aspect <= 47 ) ) {
368  fbcon->background =
369  fbcon_ansi_colour ( fbcon, aspect - 40 );
370  } else if ( aspect == 48 ) {
371  custom = &fbcon->background;
372  } else if ( aspect == 49 ) {
374  }
375 
376  /* Process custom RGB colour, if applicable
377  *
378  * We support the xterm-compatible
379  * "<ESC>[38;2;<red>;<green>;<blue>m" and
380  * "<ESC>[48;2;<red>;<green>;<blue>m" sequences.
381  */
382  if ( custom ) {
383  rgb = 0;
384  end = ( i + 5 );
385  for ( ; ( i < count ) && ( i < end ) ; i++ )
386  rgb = ( ( rgb << 8 ) | params[i] );
387  *custom = fbcon_colour ( fbcon, rgb );
388  custom = NULL;
389  }
390  }
391 }
#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:70
static uint32_t fbcon_colour(struct fbcon *fbcon, uint32_t rgb)
Calculate raw colour value.
Definition: fbcon.c:50
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:99
unsigned int uint32_t
Definition: stdint.h:12
uint32_t background
Text background raw colour.
Definition: fbcon.h:132
uint16_t count
Number of entries.
Definition: ena.h:22
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:362
static void fbcon_set_default_foreground(struct fbcon *fbcon)
Set default foreground colour.
Definition: fbcon.c:87

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

402  {
403  struct fbcon *fbcon = container_of ( ctx, struct fbcon, ctx );
404 
405  fbcon->show_cursor = 1;
406  fbcon_draw_cursor ( fbcon, 1 );
407 }
static void fbcon_draw_cursor(struct fbcon *fbcon, int show_cursor)
Draw character at cursor position.
Definition: fbcon.c:267
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:146

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

418  {
419  struct fbcon *fbcon = container_of ( ctx, struct fbcon, ctx );
420 
421  fbcon->show_cursor = 0;
422  fbcon_draw_cursor ( fbcon, 0 );
423 }
static void fbcon_draw_cursor(struct fbcon *fbcon, int show_cursor)
Draw character at cursor position.
Definition: fbcon.c:267
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:146

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

441  {
442  struct fbcon_text_cell cell;
443 
444  /* Intercept ANSI escape sequences */
446  if ( character < 0 )
447  return;
448 
449  /* Handle control characters */
450  switch ( character ) {
451  case '\r':
452  fbcon_draw_cursor ( fbcon, 0 );
453  fbcon->xpos = 0;
454  break;
455  case '\n':
456  fbcon_draw_cursor ( fbcon, 0 );
457  fbcon->xpos = 0;
458  fbcon->ypos++;
459  break;
460  case '\b':
461  fbcon_draw_cursor ( fbcon, 0 );
462  if ( fbcon->xpos ) {
463  fbcon->xpos--;
464  } else if ( fbcon->ypos ) {
465  fbcon->xpos = ( fbcon->character.width - 1 );
466  fbcon->ypos--;
467  }
468  break;
469  default:
470  /* Print character at current cursor position */
471  cell.foreground = ( fbcon->foreground | fbcon->bold );
472  cell.background = fbcon->background;
473  cell.character = character;
474  fbcon_store ( fbcon, &cell, fbcon->xpos, fbcon->ypos );
475  fbcon_draw ( fbcon, &cell, fbcon->xpos, fbcon->ypos );
476 
477  /* Advance cursor */
478  fbcon->xpos++;
479  if ( fbcon->xpos >= fbcon->character.width ) {
480  fbcon->xpos = 0;
481  fbcon->ypos++;
482  }
483  break;
484  }
485 
486  /* Scroll screen if necessary */
487  if ( fbcon->ypos >= fbcon->character.height )
488  fbcon_scroll ( fbcon );
489 
490  /* Show cursor */
492 }
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:157
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:267
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:242
uint32_t foreground
Text foreground raw colour.
Definition: fbcon.h:130
A frame buffer console.
Definition: fbcon.h:112
unsigned int character
Character.
Definition: fbcon.h:96
unsigned int xpos
Text cursor X position.
Definition: fbcon.h:136
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
uint32_t bold
Bold colour modifier raw colour.
Definition: fbcon.h:134
static void fbcon_store(struct fbcon *fbcon, struct fbcon_text_cell *cell, unsigned int xpos, unsigned int ypos)
Store character at specified position.
Definition: fbcon.c:139
int show_cursor
Display cursor.
Definition: fbcon.h:146

References ansiesc_process(), fbcon_text_cell::background, fbcon::background, fbcon::bold, fbcon_text_cell::character, fbcon::character, fbcon::ctx, fbcon_draw(), fbcon_draw_cursor(), fbcon_scroll(), fbcon_store(), fbcon_text_cell::foreground, fbcon::foreground, fbcon_geometry::height, fbcon::show_cursor, 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 501 of file fbcon.c.

502  {
503  struct fbcon_geometry *pixel = fbcon->pixel;
504  struct fbcon_picture *picture = &fbcon->picture;
505  size_t len;
506  size_t pixbuf_stride;
507  size_t indent;
508  size_t pixbuf_indent;
509  size_t offset;
510  size_t pixbuf_offset;
511  uint32_t rgb;
512  uint32_t raw;
513  unsigned int x;
514  unsigned int y;
515  unsigned int width;
516  unsigned int height;
517  int xgap;
518  int ygap;
519  int rc;
520 
521  /* Allocate buffer */
522  len = ( pixel->height * pixel->stride );
523  picture->start = umalloc ( len );
524  if ( ! picture->start ) {
525  DBGC ( fbcon, "FBCON %p could not allocate %zd bytes for "
526  "picture\n", fbcon, len );
527  rc = -ENOMEM;
528  goto err_umalloc;
529  }
530 
531  /* Centre picture on console */
532  pixbuf_stride = ( pixbuf->width * sizeof ( rgb ) );
533  xgap = ( ( ( int ) ( pixel->width - pixbuf->width ) ) / 2 );
534  ygap = ( ( ( int ) ( pixel->height - pixbuf->height ) ) / 2 );
535  indent = ( ( ( ( ygap >= 0 ) ? ygap : 0 ) * pixel->stride ) +
536  ( ( ( xgap >= 0 ) ? xgap : 0 ) * pixel->len ) );
537  pixbuf_indent = ( ( ( ( ygap < 0 ) ? -ygap : 0 ) * pixbuf_stride ) +
538  ( ( ( xgap < 0 ) ? -xgap : 0 ) * sizeof ( rgb ) ) );
539  width = pixbuf->width;
540  if ( width > pixel->width )
541  width = pixel->width;
542  height = pixbuf->height;
543  if ( height > pixel->height )
544  height = pixel->height;
545  DBGC ( fbcon, "FBCON %p picture is pixel %dx%d at [%d,%d),[%d,%d)\n",
546  fbcon, width, height, xgap, ( xgap + pixbuf->width ), ygap,
547  ( ygap + pixbuf->height ) );
548 
549  /* Convert to frame buffer raw format */
550  memset_user ( picture->start, 0, 0, len );
551  for ( y = 0 ; y < height ; y++ ) {
552  offset = ( indent + ( y * pixel->stride ) );
553  pixbuf_offset = ( pixbuf_indent + ( y * pixbuf_stride ) );
554  for ( x = 0 ; x < width ; x++ ) {
555  copy_from_user ( &rgb, pixbuf->data, pixbuf_offset,
556  sizeof ( rgb ) );
557  raw = fbcon_colour ( fbcon, rgb );
558  copy_to_user ( picture->start, offset, &raw,
559  pixel->len );
560  offset += pixel->len;
561  pixbuf_offset += sizeof ( rgb );
562  }
563  }
564 
565  return 0;
566 
567  ufree ( picture->start );
568  err_umalloc:
569  return rc;
570 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A frame buffer geometry.
Definition: fbcon.h:50
userptr_t start
Start address.
Definition: fbcon.h:108
unsigned int height
Height.
Definition: pixbuf.h:23
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:52
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
Definition: uaccess.h:337
#define DBGC(...)
Definition: compiler.h:505
static uint32_t fbcon_colour(struct fbcon *fbcon, uint32_t rgb)
Calculate raw colour value.
Definition: fbcon.c:50
struct fbcon_geometry * pixel
Pixel geometry.
Definition: fbcon.h:118
void memset_user(userptr_t userptr, off_t offset, int c, size_t len)
Fill user buffer with a constant byte.
#define ENOMEM
Not enough space.
Definition: errno.h:534
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
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
static __always_inline void copy_to_user(userptr_t dest, off_t dest_off, const void *src, size_t len)
Copy data to user buffer.
Definition: uaccess.h:324
unsigned int uint32_t
Definition: stdint.h:12
static __always_inline void ufree(userptr_t userptr)
Free external memory.
Definition: umalloc.h:65
uint32_t len
Length.
Definition: ena.h:14
static __always_inline userptr_t umalloc(size_t size)
Allocate external memory.
Definition: umalloc.h:54
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54
__be32 raw[7]
Definition: CIB_PRM.h:28
struct fbcon_picture picture
Background picture.
Definition: fbcon.h:144
userptr_t data
32-bit (8:8:8:8) xRGB pixel data, in host-endian order
Definition: pixbuf.h:25
size_t stride
Stride (offset between vertically adjacent entities)
Definition: fbcon.h:58
unsigned int width
Width.
Definition: pixbuf.h:21

References copy_from_user(), copy_to_user(), pixel_buffer::data, DBGC, ENOMEM, fbcon_colour(), pixel_buffer::height, fbcon_geometry::height, len, fbcon_geometry::len, memset_user(), offset, fbcon::picture, fbcon::pixel, raw, rc, fbcon_picture::start, fbcon_geometry::stride, ufree(), umalloc(), pixel_buffer::width, and fbcon_geometry::width.

Referenced by fbcon_init().

◆ fbcon_init()

int fbcon_init ( struct fbcon fbcon,
userptr_t  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 583 of file fbcon.c.

587  {
588  int width;
589  int height;
590  unsigned int xgap;
591  unsigned int ygap;
592  unsigned int left;
593  unsigned int right;
594  unsigned int top;
595  unsigned int bottom;
596  int rc;
597 
598  /* Initialise data structure */
599  memset ( fbcon, 0, sizeof ( *fbcon ) );
600  fbcon->start = start;
601  fbcon->pixel = pixel;
602  assert ( pixel->len <= sizeof ( uint32_t ) );
603  fbcon->map = map;
604  fbcon->font = font;
606  fbcon->show_cursor = 1;
607 
608  /* Derive overall length */
609  fbcon->len = ( pixel->height * pixel->stride );
610  DBGC ( fbcon, "FBCON %p at [%08lx,%08lx)\n", fbcon,
611  user_to_phys ( fbcon->start, 0 ),
612  user_to_phys ( fbcon->start, fbcon->len ) );
613 
614  /* Calculate margin. If the actual screen size is larger than
615  * the requested screen size, then update the margins so that
616  * the margin remains relative to the requested screen size.
617  * (As an exception, if a zero margin was specified then treat
618  * this as meaning "expand to edge of actual screen".)
619  */
620  xgap = ( pixel->width - config->width );
621  ygap = ( pixel->height - config->height );
622  left = ( xgap / 2 );
623  right = ( xgap - left );
624  top = ( ygap / 2 );
625  bottom = ( ygap - top );
626  fbcon->margin.left = ( config->left + ( config->left ? left : 0 ) );
627  fbcon->margin.right = ( config->right + ( config->right ? right : 0 ) );
628  fbcon->margin.top = ( config->top + ( config->top ? top : 0 ) );
629  fbcon->margin.bottom =
630  ( config->bottom + ( config->bottom ? bottom : 0 ) );
631 
632  /* Expand margin to accommodate whole characters */
633  width = ( pixel->width - fbcon->margin.left - fbcon->margin.right );
634  height = ( pixel->height - fbcon->margin.top - fbcon->margin.bottom );
635  if ( ( width < FBCON_CHAR_WIDTH ) ||
636  ( height < ( ( int ) font->height ) ) ) {
637  DBGC ( fbcon, "FBCON %p has unusable character area "
638  "[%d-%d),[%d-%d)\n", fbcon, fbcon->margin.left,
639  ( pixel->width - fbcon->margin.right ),
640  fbcon->margin.top,
641  ( pixel->height - fbcon->margin.bottom ) );
642  rc = -EINVAL;
643  goto err_margin;
644  }
645  xgap = ( width % FBCON_CHAR_WIDTH );
646  ygap = ( height % font->height );
647  fbcon->margin.left += ( xgap / 2 );
648  fbcon->margin.top += ( ygap / 2 );
649  fbcon->margin.right += ( xgap - ( xgap / 2 ) );
650  fbcon->margin.bottom += ( ygap - ( ygap / 2 ) );
651  fbcon->indent = ( ( fbcon->margin.top * pixel->stride ) +
652  ( fbcon->margin.left * pixel->len ) );
653 
654  /* Derive character geometry from pixel geometry */
655  fbcon->character.width = ( width / FBCON_CHAR_WIDTH );
656  fbcon->character.height = ( height / font->height );
657  fbcon->character.len = ( pixel->len * FBCON_CHAR_WIDTH );
658  fbcon->character.stride = ( pixel->stride * font->height );
659  DBGC ( fbcon, "FBCON %p is pixel %dx%d, char %dx%d at "
660  "[%d-%d),[%d-%d)\n", fbcon, fbcon->pixel->width,
663  ( fbcon->pixel->width - fbcon->margin.right ),
664  fbcon->margin.top,
665  ( fbcon->pixel->height - fbcon->margin.bottom ) );
666 
667  /* Set default colours */
670 
671  /* Allocate and initialise stored character array */
674  sizeof ( struct fbcon_text_cell ) );
675  if ( ! fbcon->text.start ) {
676  rc = -ENOMEM;
677  goto err_text;
678  }
679  fbcon_clear ( fbcon, 0 );
680 
681  /* Set framebuffer to all black (including margins) */
682  memset_user ( fbcon->start, 0, 0, fbcon->len );
683 
684  /* Generate pixel buffer from background image, if applicable */
685  if ( config->pixbuf &&
686  ( ( rc = fbcon_picture_init ( fbcon, config->pixbuf ) ) != 0 ) )
687  goto err_picture;
688 
689  /* Draw background picture (including margins), if applicable */
690  if ( fbcon->picture.start ) {
692  fbcon->len );
693  }
694 
695  /* Update console width and height */
697 
698  return 0;
699 
700  ufree ( fbcon->picture.start );
701  err_picture:
702  ufree ( fbcon->text.start );
703  err_text:
704  err_margin:
705  return rc;
706 }
static void console_set_size(unsigned int width, unsigned int height)
Set console size.
Definition: console.h:201
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:426
struct ansiesc_handler * handlers
Array of handlers.
Definition: ansiesc.h:79
unsigned int height
Height.
Definition: console.h:28
userptr_t start
Start address.
Definition: fbcon.h:108
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
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
#define DBGC(...)
Definition: compiler.h:505
struct ansiesc_context ctx
ANSI escape sequence context.
Definition: fbcon.h:140
A frame buffer text cell.
Definition: fbcon.h:90
unsigned int width
Width.
Definition: console.h:26
static userptr_t bottom
Bottom of heap (current lowest allocated block)
static void fbcon_clear(struct fbcon *fbcon, unsigned int ypos)
Clear rows of characters.
Definition: fbcon.c:111
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
void memset_user(userptr_t userptr, off_t offset, int c, size_t len)
Fill user buffer with a constant byte.
#define ENOMEM
Not enough space.
Definition: errno.h:534
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:99
unsigned int top
Top margin.
Definition: fbcon.h:68
userptr_t start
Stored text cells.
Definition: fbcon.h:102
static userptr_t top
Top of heap.
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:501
struct fbcon_text text
Text array.
Definition: fbcon.h:142
size_t len
Length of one complete displayed screen.
Definition: fbcon.h:116
static __always_inline void ufree(userptr_t userptr)
Free external memory.
Definition: umalloc.h:65
static __always_inline userptr_t umalloc(size_t size)
Allocate external memory.
Definition: umalloc.h:54
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
unsigned int top
Top margin.
Definition: console.h:36
unsigned int right
Right margin.
Definition: fbcon.h:66
struct fbcon_picture picture
Background picture.
Definition: fbcon.h:144
size_t indent
Indent to first character (in bytes)
Definition: fbcon.h:124
struct fbcon_colour_map * map
Colour mapping.
Definition: fbcon.h:126
userptr_t start
Start address.
Definition: fbcon.h:114
int show_cursor
Display cursor.
Definition: fbcon.h:146
static void fbcon_set_default_foreground(struct fbcon *fbcon)
Set default foreground colour.
Definition: fbcon.c:87
size_t stride
Stride (offset between vertically adjacent entities)
Definition: fbcon.h:58
void memcpy_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers.
unsigned int left
Left margin.
Definition: console.h:32
void * memset(void *dest, int character, size_t len) __nonnull

References assert(), console_configuration::bottom, bottom, fbcon_margin::bottom, 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, fbcon::margin, memcpy_user(), memset(), memset_user(), fbcon::picture, console_configuration::pixbuf, fbcon::pixel, rc, console_configuration::right, fbcon_margin::right, fbcon::show_cursor, start, fbcon_text::start, fbcon_picture::start, fbcon::start, fbcon_geometry::stride, fbcon::text, console_configuration::top, top, fbcon_margin::top, ufree(), umalloc(), user_to_phys(), 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 713 of file fbcon.c.

713  {
714 
715  ufree ( fbcon->text.start );
716  ufree ( fbcon->picture.start );
717 }
userptr_t start
Start address.
Definition: fbcon.h:108
A frame buffer console.
Definition: fbcon.h:112
userptr_t start
Stored text cells.
Definition: fbcon.h:102
struct fbcon_text text
Text array.
Definition: fbcon.h:142
static __always_inline void ufree(userptr_t userptr)
Free external memory.
Definition: umalloc.h:65
struct fbcon_picture picture
Background picture.
Definition: fbcon.h:144

References fbcon::picture, fbcon_text::start, 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:416
static void fbcon_handle_cup(struct ansiesc_context *ctx, unsigned int count __unused, int params[])
Handle ANSI CUP (cursor position)
Definition: fbcon.c:290
#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:313
static void fbcon_handle_sgr(struct ansiesc_context *ctx, unsigned int count, int params[])
Handle ANSI SGR (set graphics rendition)
Definition: fbcon.c:340
#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:400
#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:362

ANSI escape sequence handlers.

Definition at line 426 of file fbcon.c.

Referenced by fbcon_init().