iPXE
efi_fbcon.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 
26 /**
27  * @file
28  *
29  * EFI frame buffer console
30  *
31  */
32 
33 #include <string.h>
34 #include <strings.h>
35 #include <ctype.h>
36 #include <errno.h>
37 #include <assert.h>
38 #include <limits.h>
39 #include <ipxe/efi/efi.h>
42 #include <ipxe/ansicol.h>
43 #include <ipxe/fbcon.h>
44 #include <ipxe/console.h>
45 #include <ipxe/uaccess.h>
46 #include <ipxe/umalloc.h>
47 #include <ipxe/rotate.h>
48 #include <config/console.h>
49 
50 /* Avoid dragging in EFI console if not otherwise used */
51 extern struct console_driver efi_console;
53 
54 /* Set default console usage if applicable
55  *
56  * We accept either CONSOLE_FRAMEBUFFER or CONSOLE_EFIFB.
57  */
58 #if ( defined ( CONSOLE_FRAMEBUFFER ) && ! defined ( CONSOLE_EFIFB ) )
59 #define CONSOLE_EFIFB CONSOLE_FRAMEBUFFER
60 #endif
61 #if ! ( defined ( CONSOLE_EFIFB ) && CONSOLE_EXPLICIT ( CONSOLE_EFIFB ) )
62 #undef CONSOLE_EFIFB
63 #define CONSOLE_EFIFB ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG )
64 #endif
65 
66 /** Number of ASCII glyphs in cache */
67 #define EFIFB_ASCII 128
68 
69 /** Number of dynamic non-ASCII glyphs in cache */
70 #define EFIFB_DYNAMIC 32
71 
72 /* Forward declaration */
73 struct console_driver efifb_console __console_driver;
74 
75 /** An EFI frame buffer */
76 struct efifb {
77  /** EFI graphics output protocol */
79  /** EFI HII font protocol */
81  /** Saved mode */
83 
84  /** Frame buffer console */
85  struct fbcon fbcon;
86  /** Physical start address */
88  /** Pixel geometry */
90  /** Colour mapping */
92  /** Font definition */
93  struct fbcon_font font;
94  /** Character glyph cache */
96  /** Dynamic characters in cache */
97  unsigned int dynamic[EFIFB_DYNAMIC];
98  /** Next dynamic character cache entry to evict */
99  unsigned int next;
100 };
101 
102 /** The EFI frame buffer */
103 static struct efifb efifb;
104 
105 /**
106  * Draw character glyph
107  *
108  * @v character Character
109  * @v index Index within glyph cache
110  * @v toggle Bits to toggle in each bitmask
111  * @ret height Character height, or negative error
112  */
113 static int efifb_draw ( unsigned int character, unsigned int index,
114  unsigned int toggle ) {
116  EFI_IMAGE_OUTPUT *blt;
118  unsigned int height;
119  unsigned int x;
120  unsigned int y;
121  uint8_t *glyph;
122  uint8_t bitmask;
123  EFI_STATUS efirc;
124  int rc;
125 
126  /* Clear existing glyph */
127  glyph = &efifb.glyphs[ index * efifb.font.height ];
128  memset ( glyph, 0, efifb.font.height );
129 
130  /* Get glyph */
131  blt = NULL;
132  if ( ( efirc = efifb.hiifont->GetGlyph ( efifb.hiifont, character,
133  NULL, &blt, NULL ) ) != 0 ) {
134  rc = -EEFI ( efirc );
135  DBGC ( &efifb, "EFIFB could not get glyph %#02x: %s\n",
136  character, strerror ( rc ) );
137  goto err_get;
138  }
139  assert ( blt != NULL );
140 
141  /* Sanity check */
142  if ( blt->Width > 8 ) {
143  DBGC ( &efifb, "EFIFB glyph %#02x invalid width %d\n",
144  character, blt->Width );
145  rc = -EINVAL;
146  goto err_width;
147  }
148 
149  /* Convert glyph to bitmap */
150  pixel = blt->Image.Bitmap;
151  height = blt->Height;
152  for ( y = 0 ; ( ( y < height ) && ( y < efifb.font.height ) ) ; y++ ) {
153  bitmask = 0;
154  for ( x = 0 ; x < blt->Width ; x++ ) {
155  bitmask = rol8 ( bitmask, 1 );
156  if ( pixel->Blue || pixel->Green || pixel->Red )
157  bitmask |= 0x01;
158  pixel++;
159  }
160  bitmask ^= toggle;
161  *(glyph++) = bitmask;
162  }
163 
164  /* Free glyph */
165  bs->FreePool ( blt );
166 
167  return height;
168 
169  err_width:
170  bs->FreePool ( blt );
171  err_get:
172  return rc;
173 }
174 
175 /**
176  * Draw "unknown character" glyph
177  *
178  * @v index Index within glyph cache
179  * @ret rc Return status code
180  */
181 static int efifb_draw_unknown ( unsigned int index ) {
182 
183  /* Draw an inverted '?' glyph */
184  return efifb_draw ( '?', index, -1U );
185 }
186 
187 /**
188  * Get dynamic glyph index
189  *
190  * @v character Unicode character
191  * @ret index Glyph cache index
192  */
193 static unsigned int efifb_dynamic ( unsigned int character ) {
194  unsigned int dynamic;
195  unsigned int index;
196  unsigned int i;
197  int height;
198 
199  /* Search existing cached entries */
200  for ( i = 0 ; i < EFIFB_DYNAMIC ; i++ ) {
201  if ( character == efifb.dynamic[i] )
202  return ( EFIFB_ASCII + i );
203  }
204 
205  /* Overwrite the oldest cache entry */
206  dynamic = ( efifb.next++ % EFIFB_DYNAMIC );
207  index = ( EFIFB_ASCII + dynamic );
208  DBGC2 ( &efifb, "EFIFB dynamic %#02x is glyph %#02x\n",
209  dynamic, character );
210 
211  /* Draw glyph */
212  height = efifb_draw ( character, index, 0 );
213  if ( height < 0 )
215 
216  /* Record cached character */
217  efifb.dynamic[dynamic] = character;
218 
219  return index;
220 }
221 
222 /**
223  * Get character glyph
224  *
225  * @v character Unicode character
226  * @ret glyph Character glyph to fill in
227  */
228 static const uint8_t * efifb_glyph ( unsigned int character ) {
229  unsigned int index;
230 
231  /* Identify glyph */
232  if ( character < EFIFB_ASCII ) {
233 
234  /* ASCII character: use fixed cache entry */
235  index = character;
236 
237  } else {
238 
239  /* Non-ASCII character: use dynamic glyph cache */
240  index = efifb_dynamic ( character );
241  }
242 
243  /* Return cached glyph */
244  return &efifb.glyphs[ index * efifb.font.height ];
245 }
246 
247 /**
248  * Get character glyphs
249  *
250  * @ret rc Return status code
251  */
252 static int efifb_glyphs ( void ) {
253  unsigned int character;
254  int height;
255  int max;
256  size_t len;
257  int rc;
258 
259  /* Get font height. The GetFontInfo() call nominally returns
260  * this information in an EFI_FONT_DISPLAY_INFO structure, but
261  * is known to fail on many UEFI implementations. Instead, we
262  * iterate over all printable characters to find the maximum
263  * height.
264  */
265  efifb.font.height = 0;
266  max = 0;
267  for ( character = 0 ; character < EFIFB_ASCII ; character++ ) {
268 
269  /* Skip non-printable characters */
270  if ( ! isprint ( character ) )
271  continue;
272 
273  /* Get glyph */
274  height = efifb_draw ( character, 0, 0 );
275  if ( height < 0 ) {
276  rc = height;
277  goto err_height;
278  }
279 
280  /* Calculate maximum height */
281  if ( max < height )
282  max = height;
283  }
284  if ( ! max ) {
285  DBGC ( &efifb, "EFIFB could not get font height\n" );
286  return -ENOENT;
287  }
288  efifb.font.height = max;
289 
290  /* Allocate glyph data */
292  efifb.glyphs = umalloc ( len );
293  if ( ! efifb.glyphs ) {
294  rc = -ENOMEM;
295  goto err_alloc;
296  }
297  memset ( efifb.glyphs, 0, len );
298 
299  /* Get font data */
300  for ( character = 0 ; character < EFIFB_ASCII ; character++ ) {
301 
302  /* Skip non-printable characters */
303  if ( ! isprint ( character ) ) {
304  efifb_draw_unknown ( character );
305  continue;
306  }
307 
308  /* Get glyph */
309  height = efifb_draw ( character, character, 0 );
310  if ( height < 0 ) {
311  rc = height;
312  goto err_draw;
313  }
314  }
315 
316  /* Clear dynamic glyph character cache */
317  memset ( efifb.dynamic, 0, sizeof ( efifb.dynamic ) );
318 
320  return 0;
321 
322  err_draw:
323  ufree ( efifb.glyphs );
324  err_alloc:
325  err_height:
326  return rc;
327 }
328 
329 /**
330  * Generate colour mapping for a single colour component
331  *
332  * @v mask Mask value
333  * @v scale Scale value to fill in
334  * @v lsb LSB value to fill in
335  * @ret rc Return status code
336  */
337 static int efifb_colour_map_mask ( uint32_t mask, uint8_t *scale,
338  uint8_t *lsb ) {
339  uint32_t check;
340 
341  /* Fill in LSB and scale */
342  *lsb = ( mask ? ( ffs ( mask ) - 1 ) : 0 );
343  *scale = ( mask ? ( 8 - ( fls ( mask ) - *lsb ) ) : 8 );
344 
345  /* Check that original mask was contiguous */
346  check = ( ( 0xff >> *scale ) << *lsb );
347  if ( check != mask )
348  return -ENOTSUP;
349 
350  return 0;
351 }
352 
353 /**
354  * Generate colour mapping
355  *
356  * @v info EFI mode information
357  * @v map Colour mapping to fill in
358  * @ret bpp Number of bits per pixel, or negative error
359  */
361  struct fbcon_colour_map *map ) {
362  static EFI_PIXEL_BITMASK rgb_mask = {
363  0x000000ffUL, 0x0000ff00UL, 0x00ff0000UL, 0xff000000UL
364  };
365  static EFI_PIXEL_BITMASK bgr_mask = {
366  0x00ff0000UL, 0x0000ff00UL, 0x000000ffUL, 0xff000000UL
367  };
368  EFI_PIXEL_BITMASK *mask;
369  uint8_t reserved_scale;
370  uint8_t reserved_lsb;
371  int rc;
372 
373  /* Determine applicable mask */
374  switch ( info->PixelFormat ) {
376  mask = &rgb_mask;
377  break;
379  mask = &bgr_mask;
380  break;
381  case PixelBitMask:
382  mask = &info->PixelInformation;
383  break;
384  default:
385  DBGC ( &efifb, "EFIFB unrecognised pixel format %d\n",
386  info->PixelFormat );
387  return -ENOTSUP;
388  }
389 
390  /* Map each colour component */
391  if ( ( rc = efifb_colour_map_mask ( mask->RedMask, &map->red_scale,
392  &map->red_lsb ) ) != 0 )
393  return rc;
394  if ( ( rc = efifb_colour_map_mask ( mask->GreenMask, &map->green_scale,
395  &map->green_lsb ) ) != 0 )
396  return rc;
397  if ( ( rc = efifb_colour_map_mask ( mask->BlueMask, &map->blue_scale,
398  &map->blue_lsb ) ) != 0 )
399  return rc;
400  if ( ( rc = efifb_colour_map_mask ( mask->ReservedMask, &reserved_scale,
401  &reserved_lsb ) ) != 0 )
402  return rc;
403 
404  /* Calculate total number of bits per pixel */
405  return ( 32 - ( reserved_scale + map->red_scale + map->green_scale +
406  map->blue_scale ) );
407 }
408 
409 /**
410  * Select video mode
411  *
412  * @v min_width Minimum required width (in pixels)
413  * @v min_height Minimum required height (in pixels)
414  * @v min_bpp Minimum required colour depth (in bits per pixel)
415  * @ret mode_number Mode number, or negative error
416  */
417 static int efifb_select_mode ( unsigned int min_width, unsigned int min_height,
418  unsigned int min_bpp ) {
420  struct fbcon_colour_map map;
422  int best_mode_number = -ENOENT;
423  unsigned int best_score = INT_MAX;
424  unsigned int score;
425  unsigned int mode;
426  int bpp;
427  UINTN size;
428  EFI_STATUS efirc;
429  int rc;
430 
431  /* Find the best mode */
432  for ( mode = 0 ; mode < efifb.gop->Mode->MaxMode ; mode++ ) {
433 
434  /* Get mode information */
435  if ( ( efirc = efifb.gop->QueryMode ( efifb.gop, mode, &size,
436  &info ) ) != 0 ) {
437  rc = -EEFI ( efirc );
438  DBGC ( &efifb, "EFIFB could not get mode %d "
439  "information: %s\n", mode, strerror ( rc ) );
440  goto err_query;
441  }
442 
443  /* Skip unusable modes */
444  bpp = efifb_colour_map ( info, &map );
445  if ( bpp < 0 ) {
446  rc = bpp;
447  DBGC ( &efifb, "EFIFB could not build colour map for "
448  "mode %d: %s\n", mode, strerror ( rc ) );
449  goto err_map;
450  }
451 
452  /* Skip modes not meeting the requirements */
453  if ( ( info->HorizontalResolution < min_width ) ||
454  ( info->VerticalResolution < min_height ) ||
455  ( ( ( unsigned int ) bpp ) < min_bpp ) ) {
456  goto err_requirements;
457  }
458 
459  /* Select this mode if it has the best (i.e. lowest)
460  * score. We choose the scoring system to favour
461  * modes close to the specified width and height;
462  * within modes of the same width and height we prefer
463  * a higher colour depth.
464  */
465  score = ( ( info->HorizontalResolution *
466  info->VerticalResolution ) - bpp );
467  if ( score < best_score ) {
468  best_mode_number = mode;
469  best_score = score;
470  }
471 
472  err_requirements:
473  err_map:
474  bs->FreePool ( info );
475  err_query:
476  continue;
477  }
478 
479  if ( best_mode_number < 0 )
480  DBGC ( &efifb, "EFIFB found no suitable mode\n" );
481  return best_mode_number;
482 }
483 
484 /**
485  * Restore video mode
486  *
487  * @v rc Return status code
488  */
489 static int efifb_restore ( void ) {
490  EFI_STATUS efirc;
491  int rc;
492 
493  /* Restore original mode */
494  if ( ( efirc = efifb.gop->SetMode ( efifb.gop,
495  efifb.saved_mode ) ) != 0 ) {
496  rc = -EEFI ( efirc );
497  DBGC ( &efifb, "EFIFB could not restore mode %d: %s\n",
498  efifb.saved_mode, strerror ( rc ) );
499  return rc;
500  }
501 
502  return 0;
503 }
504 
505 /**
506  * Initialise EFI frame buffer
507  *
508  * @v config Console configuration, or NULL to reset
509  * @ret rc Return status code
510  */
511 static int efifb_init ( struct console_configuration *config ) {
514  void *interface;
515  int mode;
516  int bpp;
517  EFI_STATUS efirc;
518  int rc;
519 
520  /* Locate graphics output protocol */
522  NULL, &interface ) ) != 0 ) {
523  rc = -EEFI ( efirc );
524  DBGC ( &efifb, "EFIFB could not locate graphics output "
525  "protocol: %s\n", strerror ( rc ) );
526  goto err_locate_gop;
527  }
528  efifb.gop = interface;
529 
530  /* Locate HII font protocol */
531  if ( ( efirc = bs->LocateProtocol ( &efi_hii_font_protocol_guid,
532  NULL, &interface ) ) != 0 ) {
533  rc = -EEFI ( efirc );
534  DBGC ( &efifb, "EFIFB could not locate HII font protocol: %s\n",
535  strerror ( rc ) );
536  goto err_locate_hiifont;
537  }
539 
540  /* Locate glyphs */
541  if ( ( rc = efifb_glyphs() ) != 0 )
542  goto err_glyphs;
543 
544  /* Save original mode */
546 
547  /* Select mode */
548  if ( ( mode = efifb_select_mode ( config->width, config->height,
549  config->depth ) ) < 0 ) {
550  rc = mode;
551  goto err_select_mode;
552  }
553 
554  /* Set mode */
555  if ( ( efirc = efifb.gop->SetMode ( efifb.gop, mode ) ) != 0 ) {
556  rc = -EEFI ( efirc );
557  DBGC ( &efifb, "EFIFB could not set mode %d: %s\n",
558  mode, strerror ( rc ) );
559  goto err_set_mode;
560  }
561  info = efifb.gop->Mode->Info;
562 
563  /* Populate colour map */
564  bpp = efifb_colour_map ( info, &efifb.map );
565  if ( bpp < 0 ) {
566  rc = bpp;
567  DBGC ( &efifb, "EFIFB could not build colour map for "
568  "mode %d: %s\n", mode, strerror ( rc ) );
569  goto err_map;
570  }
571 
572  /* Populate pixel geometry */
573  efifb.pixel.width = info->HorizontalResolution;
574  efifb.pixel.height = info->VerticalResolution;
575  efifb.pixel.len = ( ( bpp + 7 ) / 8 );
576  efifb.pixel.stride = ( efifb.pixel.len * info->PixelsPerScanLine );
577 
578  /* Populate frame buffer address */
580  DBGC ( &efifb, "EFIFB using mode %d (%dx%d %dbpp at %#08lx)\n",
582 
583  /* Initialise frame buffer console */
584  if ( ( rc = fbcon_init ( &efifb.fbcon, phys_to_virt ( efifb.start ),
585  &efifb.pixel, &efifb.map, &efifb.font,
586  config ) ) != 0 )
587  goto err_fbcon_init;
588 
589  return 0;
590 
591  fbcon_fini ( &efifb.fbcon );
592  err_fbcon_init:
593  err_map:
594  efifb_restore();
595  err_set_mode:
596  err_select_mode:
597  ufree ( efifb.glyphs );
598  err_glyphs:
599  err_locate_hiifont:
600  err_locate_gop:
601  return rc;
602 }
603 
604 /**
605  * Finalise EFI frame buffer
606  *
607  */
608 static void efifb_fini ( void ) {
609 
610  /* Finalise frame buffer console */
611  fbcon_fini ( &efifb.fbcon );
612 
613  /* Restore saved mode */
614  efifb_restore();
615 
616  /* Free glyphs */
617  ufree ( efifb.glyphs );
618 }
619 
620 /**
621  * Print a character to current cursor position
622  *
623  * @v character Character
624  */
625 static void efifb_putchar ( int character ) {
626 
627  fbcon_putchar ( &efifb.fbcon, character );
628 }
629 
630 /**
631  * Configure console
632  *
633  * @v config Console configuration, or NULL to reset
634  * @ret rc Return status code
635  */
636 static int efifb_configure ( struct console_configuration *config ) {
637  int rc;
638 
639  /* Reset console, if applicable */
640  if ( ! efifb_console.disabled ) {
641  efifb_fini();
644  }
645  efifb_console.disabled = CONSOLE_DISABLED;
646 
647  /* Do nothing more unless we have a usable configuration */
648  if ( ( config == NULL ) ||
649  ( config->width == 0 ) || ( config->height == 0 ) ) {
650  return 0;
651  }
652 
653  /* Initialise EFI frame buffer */
654  if ( ( rc = efifb_init ( config ) ) != 0 )
655  return rc;
656 
657  /* Mark console as enabled */
658  efifb_console.disabled = 0;
660 
661  /* Set magic colour to transparent if we have a background picture */
662  if ( config->pixbuf )
664 
665  return 0;
666 }
667 
668 /** EFI graphics output protocol console driver */
669 struct console_driver efifb_console __console_driver = {
670  .usage = CONSOLE_EFIFB,
671  .putchar = efifb_putchar,
672  .configure = efifb_configure,
673  .disabled = CONSOLE_DISABLED,
674 };
static __always_inline void ufree(void *ptr)
Free external memory.
Definition: umalloc.h:67
unsigned int height
Character height (in pixels)
Definition: fbcon.h:35
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2098
#define EINVAL
Invalid argument.
Definition: errno.h:428
The Pixel definition of the physical frame buffer.
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A frame buffer geometry.
Definition: fbcon.h:50
EFI_GUID efi_hii_font_protocol_guid
HII font protocol GUID.
Definition: efi_guid.c:224
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:174
unsigned int height
Height.
Definition: console.h:28
u32 info
Definition: ar9003_mac.h:67
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE * Mode
Pointer to EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE data.
static int efifb_init(struct console_configuration *config)
Initialise EFI frame buffer.
Definition: efi_fbcon.c:511
#define max(x, y)
Definition: ath.h:40
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.
Definition: fbcon.c:600
#define EFIFB_ASCII
Number of ASCII glyphs in cache.
Definition: efi_fbcon.c:67
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:2008
Frame buffer console.
Error codes.
EFI_HII_GET_GLYPH GetGlyph
Definition: HiiFont.h:460
static int efifb_configure(struct console_configuration *config)
Configure console.
Definition: efi_fbcon.c:636
uint16_t mode
Acceleration mode.
Definition: ena.h:26
EFI_GUID efi_graphics_output_protocol_guid
Graphics output protocol GUID.
Definition: efi_guid.c:216
struct fbcon fbcon
Frame buffer console.
Definition: efi_fbcon.c:85
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:52
#define CONSOLE_DISABLED
Console is disabled for all uses.
Definition: console.h:111
uint16_t size
Buffer size.
Definition: dwmac.h:14
#define DBGC(...)
Definition: compiler.h:505
static int efifb_glyphs(void)
Get character glyphs.
Definition: efi_fbcon.c:252
struct fbcon_geometry pixel
Pixel geometry.
Definition: efi_fbcon.c:89
static void efifb_fini(void)
Finalise EFI frame buffer.
Definition: efi_fbcon.c:608
long index
Definition: bigint.h:62
#define ENOENT
No such file or directory.
Definition: errno.h:514
unsigned int UINT32
Definition: ProcessorBind.h:98
static unsigned int x
Definition: pixbuf.h:62
void fbcon_putchar(struct fbcon *fbcon, int character)
Print a character to current cursor position.
Definition: fbcon.c:460
static int efifb_select_mode(unsigned int min_width, unsigned int min_height, unsigned int min_bpp)
Select video mode.
Definition: efi_fbcon.c:417
unsigned int width
Width.
Definition: console.h:26
Character types.
static unsigned int efifb_dynamic(unsigned int character)
Get dynamic glyph index.
Definition: efi_fbcon.c:193
unsigned int depth
Colour depth.
Definition: console.h:30
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * Info
Pointer to read-only EFI_GRAPHICS_OUTPUT_MODE_INFORMATION data.
A pixel is 32-bits and byte zero represents blue, byte one represents green, byte two represents red,...
A console configuration.
Definition: console.h:24
An EFI frame buffer.
Definition: efi_fbcon.c:76
int usage
Console usage bitmask.
Definition: console.h:101
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
static int isprint(int character)
Check if character is printable.
Definition: ctype.h:97
struct fbcon_colour_map map
Colour mapping.
Definition: efi_fbcon.c:91
EFI_GRAPHICS_OUTPUT_PROTOCOL * gop
EFI graphics output protocol.
Definition: efi_fbcon.c:78
EFI_GRAPHICS_OUTPUT_BLT_PIXEL * Bitmap
Definition: HiiImage.h:193
#define CONSOLE_DISABLED_OUTPUT
Console is disabled for output.
Definition: console.h:108
EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE QueryMode
#define ENOMEM
Not enough space.
Definition: errno.h:534
Provides a basic abstraction to set video modes and copy pixels to and from the graphics controller's...
size_t len
Length of a single entity.
Definition: fbcon.h:56
Assertions.
A frame buffer console.
Definition: fbcon.h:112
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct console_driver efifb_console __console_driver
EFI graphics output protocol console driver.
Definition: efi_fbcon.c:73
Access to external ("user") memory.
An object interface.
Definition: interface.h:124
union _EFI_IMAGE_OUTPUT::@581 Image
unsigned int dynamic[EFIFB_DYNAMIC]
Dynamic characters in cache.
Definition: efi_fbcon.c:97
#define EFIFB_DYNAMIC
Number of dynamic non-ASCII glyphs in cache.
Definition: efi_fbcon.c:70
ring len
Length.
Definition: dwmac.h:231
A frame buffer colour mapping.
Definition: fbcon.h:74
A 16-bit general register.
Definition: registers.h:24
static int efifb_draw(unsigned int character, unsigned int index, unsigned int toggle)
Draw character glyph.
Definition: efi_fbcon.c:113
struct fbcon_font font
Font definition.
Definition: efi_fbcon.c:93
struct console_driver efi_console
Definition: efi_fbcon.c:52
User interaction.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE SetMode
void fbcon_fini(struct fbcon *fbcon)
Finalise frame buffer console.
Definition: fbcon.c:728
static int efifb_draw_unknown(unsigned int index)
Draw "unknown character" glyph.
Definition: efi_fbcon.c:181
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1930
unsigned int next
Next dynamic character cache entry to evict.
Definition: efi_fbcon.c:99
static int efifb_colour_map_mask(uint32_t mask, uint8_t *scale, uint8_t *lsb)
Generate colour mapping for a single colour component.
Definition: efi_fbcon.c:337
static int efifb_colour_map(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info, struct fbcon_colour_map *map)
Generate colour mapping.
Definition: efi_fbcon.c:360
User memory allocation.
unsigned char uint8_t
Definition: stdint.h:10
UINT64 UINTN
Unsigned value of native width.
A pixel is 32-bits and byte zero represents red, byte one represents green, byte two represents blue,...
UINT32 MaxMode
The number of modes supported by QueryMode() and SetMode().
EFI_PHYSICAL_ADDRESS FrameBufferBase
Base address of graphics linear frame buffer.
void ansicol_set_magic_transparent(void)
Set magic colour to transparent.
Definition: ansicoldef.c:189
unsigned int uint32_t
Definition: stdint.h:12
#define CONSOLE_EFIFB
Definition: efi_fbcon.c:63
#define ffs(x)
Find first (i.e.
Definition: strings.h:140
A font definition.
Definition: fbcon.h:33
Console configuration.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1949
static void efifb_putchar(int character)
Print a character to current cursor position.
Definition: efi_fbcon.c:625
EFI API.
UINT32 Mode
Current Mode of the graphics device.
unsigned long physaddr_t
Definition: stdint.h:20
Graphics Output Protocol from the UEFI 2.0 specification.
static const uint8_t * efifb_glyph(unsigned int character)
Get character glyph.
Definition: efi_fbcon.c:228
int disabled
Console disabled flags.
Definition: console.h:62
static __always_inline int struct dma_mapping * map
Definition: dma.h:183
const uint8_t *(* glyph)(unsigned int character)
Get character glyph.
Definition: fbcon.h:42
#define DBGC2(...)
Definition: compiler.h:522
void ansicol_reset_magic(void)
Reset magic colour.
Definition: ansicoldef.c:179
The protocol provides the service to retrieve the font informations.
Definition: HiiFont.h:457
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
struct pixel_buffer * pixbuf
Background picture, if any.
Definition: console.h:40
static __always_inline void * umalloc(size_t size)
Allocate external memory.
Definition: umalloc.h:56
static unsigned int unsigned int y
Definition: pixbuf.h:62
EFI_SYSTEM_TABLE * efi_systab
A console driver.
Definition: console.h:55
#define INT_MAX
Definition: limits.h:37
#define fls(x)
Find last (i.e.
Definition: strings.h:166
UINT32 saved_mode
Saved mode.
Definition: efi_fbcon.c:82
The file provides services to retrieve font information.
uint8_t * glyphs
Character glyph cache.
Definition: efi_fbcon.c:95
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
String functions.
size_t stride
Stride (offset between vertically adjacent entities)
Definition: fbcon.h:58
EFI_HII_FONT_PROTOCOL * hiifont
EFI HII font protocol.
Definition: efi_fbcon.c:80
ANSI colours.
Definition of EFI_IMAGE_OUTPUT.
Definition: HiiImage.h:189
static int efifb_restore(void)
Restore video mode.
Definition: efi_fbcon.c:489
String functions.
Bit operations.
void * memset(void *dest, int character, size_t len) __nonnull
physaddr_t start
Physical start address.
Definition: efi_fbcon.c:87