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