Changeset View
Changeset View
Standalone View
Standalone View
stand/efi/libefi/efi_console.c
Show All 28 Lines | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <efi.h> | #include <efi.h> | ||||
#include <efilib.h> | #include <efilib.h> | ||||
#include <teken.h> | #include <teken.h> | ||||
#include <sys/reboot.h> | #include <sys/reboot.h> | ||||
#include <machine/metadata.h> | #include <machine/metadata.h> | ||||
#include <gfx_fb.h> | #include <gfx_fb.h> | ||||
#include <framebuffer.h> | |||||
#include "bootstrap.h" | #include "bootstrap.h" | ||||
extern EFI_GUID gop_guid; | extern EFI_GUID gop_guid; | ||||
extern int efi_find_framebuffer(struct efi_fb *efifb); | |||||
static EFI_GUID simple_input_ex_guid = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID; | static EFI_GUID simple_input_ex_guid = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID; | ||||
static SIMPLE_TEXT_OUTPUT_INTERFACE *conout; | static SIMPLE_TEXT_OUTPUT_INTERFACE *conout; | ||||
static SIMPLE_INPUT_INTERFACE *conin; | static SIMPLE_INPUT_INTERFACE *conin; | ||||
static EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *coninex; | static EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *coninex; | ||||
static bool efi_started; | static bool efi_started; | ||||
static int mode; /* Does ConOut have serial console? */ | static int mode; /* Does ConOut have serial console? */ | ||||
▲ Show 20 Lines • Show All 830 Lines • ▼ Show 20 Lines | |||||
bool | bool | ||||
cons_update_mode(bool use_gfx_mode) | cons_update_mode(bool use_gfx_mode) | ||||
{ | { | ||||
UINTN cols, rows; | UINTN cols, rows; | ||||
const teken_attr_t *a; | const teken_attr_t *a; | ||||
teken_attr_t attr; | teken_attr_t attr; | ||||
EFI_STATUS status; | EFI_STATUS status; | ||||
EFI_GRAPHICS_OUTPUT *gop = NULL; | |||||
struct efi_fb efifb; | |||||
char env[10], *ptr; | char env[10], *ptr; | ||||
if (use_gfx_mode == true) { | |||||
gfx_state.tg_fb_type = FB_GOP; | |||||
if (gfx_state.tg_private == NULL) { | |||||
(void) BS->LocateProtocol(&gop_guid, NULL, | |||||
(void **)&gop); | |||||
gfx_state.tg_private = gop; | |||||
} else { | |||||
gop = gfx_state.tg_private; | |||||
} | |||||
/* | /* | ||||
* We have FB but no GOP - it must be UGA. | * Despite the use_gfx_mode, we want to make sure we call | ||||
* efi_find_framebuffer(). This will populate the fb data, | |||||
* which will be passed to kernel. | |||||
*/ | */ | ||||
if (gop == NULL) | if (efi_find_framebuffer(&gfx_state) == 0 && use_gfx_mode) { | ||||
gfx_state.tg_fb_type = FB_UGA; | |||||
if (efi_find_framebuffer(&efifb) == 0) { | |||||
int roff, goff, boff; | int roff, goff, boff; | ||||
gfx_state.tg_fb.fb_addr = efifb.fb_addr; | roff = ffs(gfx_state.tg_fb.fb_mask_red) - 1; | ||||
gfx_state.tg_fb.fb_size = efifb.fb_size; | goff = ffs(gfx_state.tg_fb.fb_mask_green) - 1; | ||||
gfx_state.tg_fb.fb_height = efifb.fb_height; | boff = ffs(gfx_state.tg_fb.fb_mask_blue) - 1; | ||||
gfx_state.tg_fb.fb_width = efifb.fb_width; | |||||
gfx_state.tg_fb.fb_stride = efifb.fb_stride; | |||||
gfx_state.tg_fb.fb_mask_red = efifb.fb_mask_red; | |||||
gfx_state.tg_fb.fb_mask_green = efifb.fb_mask_green; | |||||
gfx_state.tg_fb.fb_mask_blue = efifb.fb_mask_blue; | |||||
gfx_state.tg_fb.fb_mask_reserved = | |||||
efifb.fb_mask_reserved; | |||||
roff = ffs(efifb.fb_mask_red) - 1; | |||||
goff = ffs(efifb.fb_mask_green) - 1; | |||||
boff = ffs(efifb.fb_mask_blue) - 1; | |||||
(void) generate_cons_palette(cmap, COLOR_FORMAT_RGB, | (void) generate_cons_palette(cmap, COLOR_FORMAT_RGB, | ||||
efifb.fb_mask_red >> roff, roff, | gfx_state.tg_fb.fb_mask_red >> roff, roff, | ||||
efifb.fb_mask_green >> goff, goff, | gfx_state.tg_fb.fb_mask_green >> goff, goff, | ||||
efifb.fb_mask_blue >> boff, boff); | gfx_state.tg_fb.fb_mask_blue >> boff, boff); | ||||
gfx_state.tg_fb.fb_bpp = fls( | |||||
efifb.fb_mask_red | efifb.fb_mask_green | | |||||
efifb.fb_mask_blue | efifb.fb_mask_reserved); | |||||
} | |||||
} else { | } else { | ||||
/* | |||||
* Either text mode was asked by user or we failed to | |||||
* find frame buffer. | |||||
*/ | |||||
gfx_state.tg_fb_type = FB_TEXT; | gfx_state.tg_fb_type = FB_TEXT; | ||||
} | } | ||||
status = conout->QueryMode(conout, conout->Mode->Mode, &cols, &rows); | status = conout->QueryMode(conout, conout->Mode->Mode, &cols, &rows); | ||||
if (EFI_ERROR(status) || cols * rows == 0) { | if (EFI_ERROR(status) || cols * rows == 0) { | ||||
cols = TEXT_COLS; | cols = TEXT_COLS; | ||||
rows = TEXT_ROWS; | rows = TEXT_ROWS; | ||||
} | } | ||||
Show All 26 Lines | if ((mode & (RB_SERIAL | RB_MULTIPLE)) == 0) { | ||||
} else { | } else { | ||||
uint32_t fb_height, fb_width; | uint32_t fb_height, fb_width; | ||||
fb_height = gfx_state.tg_fb.fb_height; | fb_height = gfx_state.tg_fb.fb_height; | ||||
fb_width = gfx_state.tg_fb.fb_width; | fb_width = gfx_state.tg_fb.fb_width; | ||||
/* | /* | ||||
* setup_font() can adjust terminal size. | * setup_font() can adjust terminal size. | ||||
* Note, we assume 80x24 terminal first, this is | * Note, we do use UEFI terminal dimensions first, | ||||
* because the font selection will attempt to achieve | * this is because the font selection will attempt | ||||
* at least this terminal dimension and we do not | * to achieve at least this terminal dimension and | ||||
* end up with too small font. | * we do not end up with too small font. | ||||
*/ | */ | ||||
gfx_state.tg_tp.tp_row = TEXT_ROWS; | gfx_state.tg_tp.tp_row = rows; | ||||
gfx_state.tg_tp.tp_col = TEXT_COLS; | gfx_state.tg_tp.tp_col = cols; | ||||
setup_font(&gfx_state, fb_height, fb_width); | setup_font(&gfx_state, fb_height, fb_width); | ||||
rows = gfx_state.tg_tp.tp_row; | rows = gfx_state.tg_tp.tp_row; | ||||
cols = gfx_state.tg_tp.tp_col; | cols = gfx_state.tg_tp.tp_col; | ||||
/* Point of origin in pixels. */ | /* Point of origin in pixels. */ | ||||
gfx_state.tg_origin.tp_row = (fb_height - | gfx_state.tg_origin.tp_row = (fb_height - | ||||
(rows * gfx_state.tg_font.vf_height)) / 2; | (rows * gfx_state.tg_font.vf_height)) / 2; | ||||
gfx_state.tg_origin.tp_col = (fb_width - | gfx_state.tg_origin.tp_col = (fb_width - | ||||
(cols * gfx_state.tg_font.vf_width)) / 2; | (cols * gfx_state.tg_font.vf_width)) / 2; | ||||
▲ Show 20 Lines • Show All 415 Lines • Show Last 20 Lines |