57 #if ( defined ( CONSOLE_FRAMEBUFFER ) && ! defined ( CONSOLE_EFIFB ) ) 58 #define CONSOLE_EFIFB CONSOLE_FRAMEBUFFER 60 #if ! ( defined ( CONSOLE_EFIFB ) && CONSOLE_EXPLICIT ( CONSOLE_EFIFB ) ) 62 #define CONSOLE_EFIFB ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG ) 66 #define EFIFB_ASCII 128 69 #define EFIFB_DYNAMIC 32 113 unsigned int toggle ) {
134 DBGC ( &
efifb,
"EFIFB could not get glyph %#02x: %s\n",
141 if ( blt->
Width > 8 ) {
142 DBGC ( &
efifb,
"EFIFB glyph %#02x invalid width %d\n",
143 character, blt->
Width );
151 for ( y = 0 ; ( ( y < height ) && ( y <
efifb.
font.
height ) ) ; y++ ) {
153 for ( x = 0 ; x < blt->
Width ; x++ ) {
154 bitmask = rol8 ( bitmask, 1 );
161 sizeof ( bitmask ) );
208 DBGC2 ( &
efifb,
"EFIFB dynamic %#02x is glyph %#02x\n",
255 unsigned int character;
269 for ( character = 0 ; character <
EFIFB_ASCII ; character++ ) {
287 DBGC ( &
efifb,
"EFIFB could not get font height\n" );
302 for ( character = 0 ; character <
EFIFB_ASCII ; character++ ) {
305 if ( !
isprint ( character ) ) {
311 height =
efifb_draw ( character, character, 0 );
344 *lsb = ( mask ? (
ffs ( mask ) - 1 ) : 0 );
345 *scale = ( mask ? ( 8 - (
fls ( mask ) - *lsb ) ) : 8 );
348 check = ( ( 0xff >> *scale ) << *lsb );
365 0x000000ffUL, 0x0000ff00UL, 0x00ff0000UL, 0xff000000UL
368 0x00ff0000UL, 0x0000ff00UL, 0x000000ffUL, 0xff000000UL
376 switch (
info->PixelFormat ) {
384 mask = &
info->PixelInformation;
387 DBGC ( &
efifb,
"EFIFB unrecognised pixel format %d\n",
394 &
map->red_lsb ) ) != 0 )
397 &
map->green_lsb ) ) != 0 )
400 &
map->blue_lsb ) ) != 0 )
403 &reserved_lsb ) ) != 0 )
407 return ( 32 - ( reserved_scale +
map->red_scale +
map->green_scale +
420 unsigned int min_bpp ) {
424 int best_mode_number = -
ENOENT;
425 unsigned int best_score =
INT_MAX;
440 DBGC ( &
efifb,
"EFIFB could not get mode %d " 449 DBGC ( &
efifb,
"EFIFB could not build colour map for " 455 if ( (
info->HorizontalResolution < min_width ) ||
456 (
info->VerticalResolution < min_height ) ||
457 ( ( (
unsigned int ) bpp ) < min_bpp ) ) {
458 goto err_requirements;
467 score = ( (
info->HorizontalResolution *
468 info->VerticalResolution ) - bpp );
469 if ( score < best_score ) {
470 best_mode_number = mode;
481 if ( best_mode_number < 0 )
482 DBGC ( &
efifb,
"EFIFB found no suitable mode\n" );
483 return best_mode_number;
499 DBGC ( &
efifb,
"EFIFB could not restore mode %d: %s\n",
526 DBGC ( &
efifb,
"EFIFB could not locate graphics output " 536 DBGC ( &
efifb,
"EFIFB could not locate HII font protocol: %s\n",
538 goto err_locate_hiifont;
551 config->
depth ) ) < 0 ) {
553 goto err_select_mode;
559 DBGC ( &
efifb,
"EFIFB could not set mode %d: %s\n",
569 DBGC ( &
efifb,
"EFIFB could not build colour map for " 582 DBGC ( &
efifb,
"EFIFB using mode %d (%dx%d %dbpp at %#08lx)\n",
642 if ( ! efifb_console.disabled ) {
650 if ( ( config ==
NULL ) ||
651 ( config->
width == 0 ) || ( config->
height == 0 ) ) {
660 efifb_console.disabled = 0;
unsigned int height
Character height (in pixels)
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
#define EINVAL
Invalid argument.
The Pixel definition of the physical frame buffer.
struct arbelprm_rc_send_wqe rc
static void efifb_glyph(unsigned int character, uint8_t *glyph)
Get character glyph.
EFI_GUID efi_hii_font_protocol_guid
HII font protocol GUID.
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
unsigned int height
Height.
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.
#define EFIFB_ASCII
Number of ASCII glyphs in cache.
EFI_LOCATE_PROTOCOL LocateProtocol
EFI_HII_GET_GLYPH GetGlyph
static int efifb_configure(struct console_configuration *config)
Configure console.
EFI_GUID efi_graphics_output_protocol_guid
Graphics output protocol GUID.
struct fbcon fbcon
Frame buffer console.
unsigned int width
Width (number of entities per displayed row)
#define CONSOLE_DISABLED
Console is disabled for all uses.
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
uint8_t size
Entry size (in 32-bit words)
static int efifb_glyphs(void)
Get character glyphs.
struct fbcon_geometry pixel
Pixel geometry.
static void efifb_fini(void)
Finalise EFI frame buffer.
#define ENOENT
No such file or directory.
void fbcon_putchar(struct fbcon *fbcon, int character)
Print a character to current cursor position.
userptr_t phys_to_user(unsigned long phys_addr)
Convert physical address to user pointer.
static int efifb_select_mode(unsigned int min_width, unsigned int min_height, unsigned int min_bpp)
Select video mode.
void(* glyph)(unsigned int character, uint8_t *glyph)
Get character glyph.
static unsigned int efifb_dynamic(unsigned int character)
Get dynamic glyph index.
unsigned int depth
Colour depth.
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,...
int usage
Console usage bitmask.
#define ENOTSUP
Operation not supported.
static int isprint(int character)
Check if character is printable.
struct fbcon_colour_map map
Colour mapping.
EFI_GRAPHICS_OUTPUT_PROTOCOL * gop
EFI graphics output protocol.
EFI_GRAPHICS_OUTPUT_BLT_PIXEL * Bitmap
#define CONSOLE_DISABLED_OUTPUT
Console is disabled for output.
union _EFI_IMAGE_OUTPUT::@572 Image
void memset_user(userptr_t userptr, off_t offset, int c, size_t len)
Fill user buffer with a constant byte.
EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE QueryMode
#define ENOMEM
Not enough space.
Provides a basic abstraction to set video modes and copy pixels to and from the graphics controller's...
uint32_t userptr_t
A pointer to a user buffer.
size_t len
Length of a single entity.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct console_driver efifb_console __console_driver
EFI graphics output protocol console driver.
unsigned int dynamic[EFIFB_DYNAMIC]
Dynamic characters in cache.
#define EFIFB_DYNAMIC
Number of dynamic non-ASCII glyphs in cache.
A frame buffer colour mapping.
A 16-bit general register.
static int efifb_draw(unsigned int character, unsigned int index, unsigned int toggle)
Draw character glyph.
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.
struct fbcon_font font
Font definition.
struct console_driver efi_console
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE SetMode
void fbcon_fini(struct fbcon *fbcon)
Finalise frame buffer console.
static int efifb_draw_unknown(unsigned int index)
Draw "unknown character" glyph.
char * strerror(int errno)
Retrieve string representation of error number.
unsigned int next
Next dynamic character cache entry to evict.
static int efifb_colour_map_mask(uint32_t mask, uint8_t *scale, uint8_t *lsb)
Generate colour mapping for a single colour component.
static int efifb_colour_map(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info, struct fbcon_colour_map *map)
Generate colour mapping.
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.
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.
static __always_inline int struct dma_mapping * map
void ansicol_set_magic_transparent(void)
Set magic colour to transparent.
#define ffs(x)
Find first (i.e.
static void efifb_putchar(int character)
Print a character to current cursor position.
UINT32 Mode
Current Mode of the graphics device.
Graphics Output Protocol from the UEFI 2.0 specification.
int disabled
Console disabled flags.
static __always_inline void ufree(userptr_t userptr)
Free external memory.
static __always_inline userptr_t umalloc(size_t size)
Allocate external memory.
void ansicol_reset_magic(void)
Reset magic colour.
The protocol provides the service to retrieve the font informations.
unsigned int height
Height (number of entities per displayed column)
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
struct pixel_buffer * pixbuf
Background picture, if any.
userptr_t glyphs
Character glyph cache.
uint16_t offset
Offset to command line.
EFI_SYSTEM_TABLE * efi_systab
#define fls(x)
Find last (i.e.
UINT32 saved_mode
Saved mode.
The file provides services to retrieve font information.
#define NULL
NULL pointer (VOID *)
size_t stride
Stride (offset between vertically adjacent entities)
EFI_HII_FONT_PROTOCOL * hiifont
EFI HII font protocol.
Definition of EFI_IMAGE_OUTPUT.
static int efifb_restore(void)
Restore video mode.
void * memset(void *dest, int character, size_t len) __nonnull
physaddr_t start
Physical start address.