libpayload/corebootfb: Replace obsolete macros FI and CHARS
These macros serve no purpose anymore, let's do the substitution manually once and for all. Also update the comment on the macros and fix whitespace on the touched lines. TEST=Checked that there are no changes in compiled code. Change-Id: Ib60f9ab157e2e7d44b551dd4f695a6c25ebeb405 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/39379 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
parent
cd0a5fcafc
commit
f6f54dd3fa
|
@ -64,41 +64,39 @@ static const u32 vga_colors[] = {
|
||||||
struct cb_framebuffer fbinfo;
|
struct cb_framebuffer fbinfo;
|
||||||
static unsigned short *chars;
|
static unsigned short *chars;
|
||||||
|
|
||||||
/* Addresses for the various components */
|
/* Shorthand for up-to-date virtual framebuffer address */
|
||||||
#define FI (&fbinfo)
|
#define FB ((unsigned char *)phys_to_virt(fbinfo.physical_address))
|
||||||
#define FB ((unsigned char *) phys_to_virt(FI->physical_address))
|
|
||||||
#define CHARS (chars)
|
|
||||||
|
|
||||||
static void corebootfb_scroll_up(void)
|
static void corebootfb_scroll_up(void)
|
||||||
{
|
{
|
||||||
unsigned char *dst = FB;
|
unsigned char *dst = FB;
|
||||||
unsigned char *src = FB + (FI->bytes_per_line * font_height);
|
unsigned char *src = FB + (fbinfo.bytes_per_line * font_height);
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
/* Scroll all lines up */
|
/* Scroll all lines up */
|
||||||
for(y = 0; y < FI->y_resolution - font_height; y++) {
|
for (y = 0; y < fbinfo.y_resolution - font_height; y++) {
|
||||||
memcpy(dst, src, FI->x_resolution * (FI->bits_per_pixel >> 3));
|
memcpy(dst, src, fbinfo.x_resolution * (fbinfo.bits_per_pixel >> 3));
|
||||||
|
|
||||||
dst += FI->bytes_per_line;
|
dst += fbinfo.bytes_per_line;
|
||||||
src += FI->bytes_per_line;
|
src += fbinfo.bytes_per_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Erase last line */
|
/* Erase last line */
|
||||||
dst = FB + (FI->y_resolution - font_height) * FI->bytes_per_line;
|
dst = FB + (fbinfo.y_resolution - font_height) * fbinfo.bytes_per_line;
|
||||||
|
|
||||||
for(; y < FI->y_resolution; y++) {
|
for (; y < fbinfo.y_resolution; y++) {
|
||||||
memset(dst, 0, FI->x_resolution * (FI->bits_per_pixel >> 3));
|
memset(dst, 0, fbinfo.x_resolution * (fbinfo.bits_per_pixel >> 3));
|
||||||
dst += FI->bytes_per_line;
|
dst += fbinfo.bytes_per_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* And update the char buffer */
|
/* And update the char buffer */
|
||||||
dst = (unsigned char *) CHARS;
|
dst = (unsigned char *)chars;
|
||||||
src = (unsigned char *) (CHARS + coreboot_video_console.columns);
|
src = (unsigned char *)(chars + coreboot_video_console.columns);
|
||||||
memcpy(dst, src, coreboot_video_console.columns *
|
memcpy(dst, src, coreboot_video_console.columns *
|
||||||
(coreboot_video_console.rows - 1) * 2);
|
(coreboot_video_console.rows - 1) * 2);
|
||||||
int column;
|
int column;
|
||||||
for (column = 0; column < coreboot_video_console.columns; column++)
|
for (column = 0; column < coreboot_video_console.columns; column++)
|
||||||
CHARS[(coreboot_video_console.rows - 1) * coreboot_video_console.columns + column] = (VGA_COLOR_DEFAULT << 8);
|
chars[(coreboot_video_console.rows - 1) * coreboot_video_console.columns + column] = (VGA_COLOR_DEFAULT << 8);
|
||||||
|
|
||||||
cursor_y--;
|
cursor_y--;
|
||||||
}
|
}
|
||||||
|
@ -109,15 +107,15 @@ static void corebootfb_clear(void)
|
||||||
unsigned char *ptr = FB;
|
unsigned char *ptr = FB;
|
||||||
|
|
||||||
/* Clear the screen */
|
/* Clear the screen */
|
||||||
for(row = 0; row < FI->y_resolution; row++) {
|
for (row = 0; row < fbinfo.y_resolution; row++) {
|
||||||
memset(ptr, 0, FI->x_resolution * (FI->bits_per_pixel >> 3));
|
memset(ptr, 0, fbinfo.x_resolution * (fbinfo.bits_per_pixel >> 3));
|
||||||
ptr += FI->bytes_per_line;
|
ptr += fbinfo.bytes_per_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* And update the char buffer */
|
/* And update the char buffer */
|
||||||
for(row = 0; row < coreboot_video_console.rows; row++)
|
for(row = 0; row < coreboot_video_console.rows; row++)
|
||||||
for (column = 0; column < coreboot_video_console.columns; column++)
|
for (column = 0; column < coreboot_video_console.columns; column++)
|
||||||
CHARS[row * coreboot_video_console.columns + column] = (VGA_COLOR_DEFAULT << 8);
|
chars[row * coreboot_video_console.columns + column] = (VGA_COLOR_DEFAULT << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void corebootfb_putchar(u8 row, u8 col, unsigned int ch)
|
static void corebootfb_putchar(u8 row, u8 col, unsigned int ch)
|
||||||
|
@ -132,55 +130,55 @@ static void corebootfb_putchar(u8 row, u8 col, unsigned int ch)
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
if (FI->bits_per_pixel > 8) {
|
if (fbinfo.bits_per_pixel > 8) {
|
||||||
bgval = ((((vga_colors[bg] >> 0) & 0xff) >> (8 - FI->blue_mask_size)) << FI->blue_mask_pos) |
|
bgval = ((((vga_colors[bg] >> 0) & 0xff) >> (8 - fbinfo.blue_mask_size)) << fbinfo.blue_mask_pos) |
|
||||||
((((vga_colors[bg] >> 8) & 0xff) >> (8 - FI->green_mask_size)) << FI->green_mask_pos) |
|
((((vga_colors[bg] >> 8) & 0xff) >> (8 - fbinfo.green_mask_size)) << fbinfo.green_mask_pos) |
|
||||||
((((vga_colors[bg] >> 16) & 0xff) >> (8 - FI->red_mask_size)) << FI->red_mask_pos);
|
((((vga_colors[bg] >> 16) & 0xff) >> (8 - fbinfo.red_mask_size)) << fbinfo.red_mask_pos);
|
||||||
fgval = ((((vga_colors[fg] >> 0) & 0xff) >> (8 - FI->blue_mask_size)) << FI->blue_mask_pos) |
|
fgval = ((((vga_colors[fg] >> 0) & 0xff) >> (8 - fbinfo.blue_mask_size)) << fbinfo.blue_mask_pos) |
|
||||||
((((vga_colors[fg] >> 8) & 0xff) >> (8 - FI->green_mask_size)) << FI->green_mask_pos) |
|
((((vga_colors[fg] >> 8) & 0xff) >> (8 - fbinfo.green_mask_size)) << fbinfo.green_mask_pos) |
|
||||||
((((vga_colors[fg] >> 16) & 0xff) >> (8 - FI->red_mask_size)) << FI->red_mask_pos);
|
((((vga_colors[fg] >> 16) & 0xff) >> (8 - fbinfo.red_mask_size)) << fbinfo.red_mask_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dst = FB + ((row * font_height) * FI->bytes_per_line);
|
dst = FB + ((row * font_height) * fbinfo.bytes_per_line);
|
||||||
dst += (col * font_width * (FI->bits_per_pixel >> 3));
|
dst += (col * font_width * (fbinfo.bits_per_pixel >> 3));
|
||||||
|
|
||||||
for(y = 0; y < font_height; y++) {
|
for(y = 0; y < font_height; y++) {
|
||||||
for(x = font_width - 1; x >= 0; x--) {
|
for(x = font_width - 1; x >= 0; x--) {
|
||||||
|
|
||||||
switch (FI->bits_per_pixel) {
|
switch (fbinfo.bits_per_pixel) {
|
||||||
case 8: /* Indexed */
|
case 8: /* Indexed */
|
||||||
dst[(font_width - x) * (FI->bits_per_pixel >> 3)] = font_glyph_filled(ch, x, y) ? fg : bg;
|
dst[(font_width - x) * (fbinfo.bits_per_pixel >> 3)] = font_glyph_filled(ch, x, y) ? fg : bg;
|
||||||
break;
|
break;
|
||||||
case 16: /* 16 bpp */
|
case 16: /* 16 bpp */
|
||||||
dst16 = (u16 *)(dst + (font_width - x) * (FI->bits_per_pixel >> 3));
|
dst16 = (u16 *)(dst + (font_width - x) * (fbinfo.bits_per_pixel >> 3));
|
||||||
*dst16 = font_glyph_filled(ch, x, y) ? fgval : bgval;
|
*dst16 = font_glyph_filled(ch, x, y) ? fgval : bgval;
|
||||||
break;
|
break;
|
||||||
case 24: /* 24 bpp */
|
case 24: /* 24 bpp */
|
||||||
if (font_glyph_filled(ch, x, y)) {
|
if (font_glyph_filled(ch, x, y)) {
|
||||||
dst[(font_width - x) * (FI->bits_per_pixel >> 3) + 0] = fgval & 0xff;
|
dst[(font_width - x) * (fbinfo.bits_per_pixel >> 3) + 0] = fgval & 0xff;
|
||||||
dst[(font_width - x) * (FI->bits_per_pixel >> 3) + 1] = (fgval >> 8) & 0xff;
|
dst[(font_width - x) * (fbinfo.bits_per_pixel >> 3) + 1] = (fgval >> 8) & 0xff;
|
||||||
dst[(font_width - x) * (FI->bits_per_pixel >> 3) + 2] = (fgval >> 16) & 0xff;
|
dst[(font_width - x) * (fbinfo.bits_per_pixel >> 3) + 2] = (fgval >> 16) & 0xff;
|
||||||
} else {
|
} else {
|
||||||
dst[(font_width - x) * (FI->bits_per_pixel >> 3) + 0] = bgval & 0xff;
|
dst[(font_width - x) * (fbinfo.bits_per_pixel >> 3) + 0] = bgval & 0xff;
|
||||||
dst[(font_width - x) * (FI->bits_per_pixel >> 3) + 1] = (bgval >> 8) & 0xff;
|
dst[(font_width - x) * (fbinfo.bits_per_pixel >> 3) + 1] = (bgval >> 8) & 0xff;
|
||||||
dst[(font_width - x) * (FI->bits_per_pixel >> 3) + 2] = (bgval >> 16) & 0xff;
|
dst[(font_width - x) * (fbinfo.bits_per_pixel >> 3) + 2] = (bgval >> 16) & 0xff;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 32: /* 32 bpp */
|
case 32: /* 32 bpp */
|
||||||
dst32 = (u32 *)(dst + (font_width - x) * (FI->bits_per_pixel >> 3));
|
dst32 = (u32 *)(dst + (font_width - x) * (fbinfo.bits_per_pixel >> 3));
|
||||||
*dst32 = font_glyph_filled(ch, x, y) ? fgval : bgval;
|
*dst32 = font_glyph_filled(ch, x, y) ? fgval : bgval;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dst += FI->bytes_per_line;
|
dst += fbinfo.bytes_per_line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void corebootfb_putc(u8 row, u8 col, unsigned int ch)
|
static void corebootfb_putc(u8 row, u8 col, unsigned int ch)
|
||||||
{
|
{
|
||||||
CHARS[row * coreboot_video_console.columns + col] = ch;
|
chars[row * coreboot_video_console.columns + col] = ch;
|
||||||
corebootfb_putchar(row, col, ch);
|
corebootfb_putchar(row, col, ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,10 +186,10 @@ static void corebootfb_update_cursor(void)
|
||||||
{
|
{
|
||||||
int ch, paint;
|
int ch, paint;
|
||||||
if(cursor_en) {
|
if(cursor_en) {
|
||||||
ch = CHARS[cursor_y * coreboot_video_console.columns + cursor_x];
|
ch = chars[cursor_y * coreboot_video_console.columns + cursor_x];
|
||||||
paint = (ch & 0xff) | ((ch << 4) & 0xf000) | ((ch >> 4) & 0x0f00);
|
paint = (ch & 0xff) | ((ch << 4) & 0xf000) | ((ch >> 4) & 0x0f00);
|
||||||
} else {
|
} else {
|
||||||
paint = CHARS[cursor_y * coreboot_video_console.columns + cursor_x];
|
paint = chars[cursor_y * coreboot_video_console.columns + cursor_x];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor_y < coreboot_video_console.rows)
|
if (cursor_y < coreboot_video_console.rows)
|
||||||
|
@ -231,20 +229,20 @@ static int corebootfb_init(void)
|
||||||
|
|
||||||
fbinfo = *lib_sysinfo.framebuffer;
|
fbinfo = *lib_sysinfo.framebuffer;
|
||||||
|
|
||||||
if (FI->physical_address == 0)
|
if (fbinfo.physical_address == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
font_init(FI->x_resolution);
|
font_init(fbinfo.x_resolution);
|
||||||
|
|
||||||
/* Draw centered on the framebuffer if requested and feasible, */
|
/* Draw centered on the framebuffer if requested and feasible, */
|
||||||
const int center =
|
const int center =
|
||||||
IS_ENABLED(CONFIG_LP_COREBOOT_VIDEO_CENTERED)
|
IS_ENABLED(CONFIG_LP_COREBOOT_VIDEO_CENTERED)
|
||||||
&& coreboot_video_console.columns * font_width <= FI->x_resolution
|
&& coreboot_video_console.columns * font_width <= fbinfo.x_resolution
|
||||||
&& coreboot_video_console.rows * font_height <= FI->y_resolution;
|
&& coreboot_video_console.rows * font_height <= fbinfo.y_resolution;
|
||||||
/* adapt to the framebuffer size, otherwise. */
|
/* adapt to the framebuffer size, otherwise. */
|
||||||
if (!center) {
|
if (!center) {
|
||||||
coreboot_video_console.columns = FI->x_resolution / font_width;
|
coreboot_video_console.columns = fbinfo.x_resolution / font_width;
|
||||||
coreboot_video_console.rows = FI->y_resolution / font_height;
|
coreboot_video_console.rows = fbinfo.y_resolution / font_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
chars = malloc(coreboot_video_console.rows *
|
chars = malloc(coreboot_video_console.rows *
|
||||||
|
@ -256,13 +254,13 @@ static int corebootfb_init(void)
|
||||||
corebootfb_clear();
|
corebootfb_clear();
|
||||||
|
|
||||||
if (center) {
|
if (center) {
|
||||||
FI->physical_address +=
|
fbinfo.physical_address +=
|
||||||
(FI->x_resolution - coreboot_video_console.columns * font_width)
|
(fbinfo.x_resolution - coreboot_video_console.columns * font_width)
|
||||||
/ 2 * FI->bits_per_pixel / 8
|
/ 2 * fbinfo.bits_per_pixel / 8
|
||||||
+ (FI->y_resolution - coreboot_video_console.rows * font_height)
|
+ (fbinfo.y_resolution - coreboot_video_console.rows * font_height)
|
||||||
/ 2 * FI->bytes_per_line;
|
/ 2 * fbinfo.bytes_per_line;
|
||||||
FI->x_resolution = coreboot_video_console.columns * font_width;
|
fbinfo.x_resolution = coreboot_video_console.columns * font_width;
|
||||||
FI->y_resolution = coreboot_video_console.rows * font_height;
|
fbinfo.y_resolution = coreboot_video_console.rows * font_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue