Revert "video: Many terminal related bug fixes and improvements"

This reverts commit f7638e965b.
This commit is contained in:
mintsuki 2021-04-11 01:26:50 +02:00
parent f7638e965b
commit 4bbc98b62e
15 changed files with 163 additions and 210 deletions

View File

@ -54,12 +54,9 @@ Some keys take *URIs* as values; these are described in the next section.
* `GRAPHICS` - If set to `yes`, use a graphical framebuffer for the boot menu, else use text mode. Ignored with Limine UEFI, forced to `yes`. * `GRAPHICS` - If set to `yes`, use a graphical framebuffer for the boot menu, else use text mode. Ignored with Limine UEFI, forced to `yes`.
* `MENU_RESOLUTION` - Specify screen resolution to be used by the Limine menu in the form `<width>x<height>`. This will *only* affect the menu, not any booted OS. If not specified, Limine will pick a resolution automatically. If the resolution is not available, Limine will pick another one automatically. Ignored if `GRAPHICS` is not `yes`. * `MENU_RESOLUTION` - Specify screen resolution to be used by the Limine menu in the form `<width>x<height>`. This will *only* affect the menu, not any booted OS. If not specified, Limine will pick a resolution automatically. If the resolution is not available, Limine will pick another one automatically. Ignored if `GRAPHICS` is not `yes`.
* `MENU_BRANDING` - A string that will be displayed on top of the Limine menu. * `MENU_BRANDING` - A string that will be displayed on top of the Limine menu.
* `MENU_FONT` - URI path to a font file to be used instead of the default one for the menu and terminal. The font file must be a code page 437 character set comprised of 256 consecutive 8x16 glyphs bitmaps (4096 byte font file). Each glyph's bitmap must be expressed left to right (1 byte per row), and top to bottom (16 bytes per whole glyph). * `MENU_FONT` - URI path to a font file to be used instead of the default one for the menu. The font file must be a code page 437 character set comprised of 256 consecutive 8x16 glyphs bitmaps (4096 byte font file). Each glyph's bitmap must be expressed left to right (1 byte per row), and top to bottom (16 bytes per whole glyph).
* `TERMINAL_FONT` - Alias of `MENU_FONT`.
* `THEME_COLOURS` - Specifies the colour palette used by the terminal (AARRGGBB). It is a `;` separated array of 10 colours: black, red, green, brown, blue, magenta, cyan, gray, background, and foreground respectively. While an alpha transparency value can be specified for every colour, it is ignored for all but background. Ignored if `GRAPHICS` is not `yes`. * `THEME_COLOURS` - Specifies the colour palette used by the terminal (AARRGGBB). It is a `;` separated array of 10 colours: black, red, green, brown, blue, magenta, cyan, gray, background, and foreground respectively. While an alpha transparency value can be specified for every colour, it is ignored for all but background. Ignored if `GRAPHICS` is not `yes`.
* `THEME_COLORS` - Alias of `THEME_COLOURS`. * `THEME_COLORS` - Alias of `THEME_COLOURS`.
* `THEME_BACKGROUND` - Alias of the background value in `THEME_COLOURS`.
* `THEME_FOREGROUND` - Alias of the foreground value in `THEME_COLOURS`.
* `THEME_MARGIN` - Set the amount of margin around the terminal. Ignored if `GRAPHICS` is not `yes`. * `THEME_MARGIN` - Set the amount of margin around the terminal. Ignored if `GRAPHICS` is not `yes`.
* `THEME_MARGIN_GRADIENT` - Set the thickness in pixel for the gradient around the terminal. Ignored if `GRAPHICS` is not `yes`. * `THEME_MARGIN_GRADIENT` - Set the thickness in pixel for the gradient around the terminal. Ignored if `GRAPHICS` is not `yes`.
* `BACKGROUND_PATH` - URI where to find the background .BMP file. Ignored if `GRAPHICS` is not `yes`. * `BACKGROUND_PATH` - URI where to find the background .BMP file. Ignored if `GRAPHICS` is not `yes`.

View File

@ -101,7 +101,8 @@ static bool try_mode(struct fb_info *ret, size_t mode, int width, int height, in
if ((int)mode == current_video_mode) { if ((int)mode == current_video_mode) {
print("gop: Mode was already set, perfect!\n"); print("gop: Mode was already set, perfect!\n");
} else { }
status = uefi_call_wrapper(gop->SetMode, 2, gop, mode); status = uefi_call_wrapper(gop->SetMode, 2, gop, mode);
if (status) { if (status) {
@ -109,13 +110,12 @@ static bool try_mode(struct fb_info *ret, size_t mode, int width, int height, in
print("gop: Failed to set video mode %x, moving on...\n", mode); print("gop: Failed to set video mode %x, moving on...\n", mode);
return false; return false;
} }
}
current_video_mode = mode; current_video_mode = mode;
ret->memory_model = 0x06; ret->memory_model = 0x06;
ret->framebuffer_addr = gop->Mode->FrameBufferBase; ret->framebuffer_addr = gop->Mode->FrameBufferBase;
ret->framebuffer_pitch = gop->Mode->Info->PixelsPerScanLine * (ret->framebuffer_bpp / 8); ret->framebuffer_pitch = gop->Mode->Info->PixelsPerScanLine * 4;
ret->framebuffer_width = gop->Mode->Info->HorizontalResolution; ret->framebuffer_width = gop->Mode->Info->HorizontalResolution;
ret->framebuffer_height = gop->Mode->Info->VerticalResolution; ret->framebuffer_height = gop->Mode->Info->VerticalResolution;
@ -124,14 +124,8 @@ static bool try_mode(struct fb_info *ret, size_t mode, int width, int height, in
return true; return true;
} }
#define INVALID_PRESET_MODE 0xfffffffff
static size_t preset_mode = INVALID_PRESET_MODE;
bool init_gop(struct fb_info *ret, bool init_gop(struct fb_info *ret,
uint16_t target_width, uint16_t target_height, uint16_t target_bpp) { uint16_t target_width, uint16_t target_height, uint16_t target_bpp) {
ret->default_res = false;
EFI_STATUS status; EFI_STATUS status;
EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
@ -154,8 +148,7 @@ bool init_gop(struct fb_info *ret,
panic("gop: Initialisation failed"); panic("gop: Initialisation failed");
} }
if (preset_mode == INVALID_PRESET_MODE) size_t preset_mode = gop->Mode->Mode;
preset_mode = gop->Mode->Mode;
struct resolution fallback_resolutions[] = { struct resolution fallback_resolutions[] = {
{ 0, 0, 0 }, // Overridden by preset mode { 0, 0, 0 }, // Overridden by preset mode
@ -169,8 +162,6 @@ bool init_gop(struct fb_info *ret,
size_t current_fallback = 0; size_t current_fallback = 0;
if (!target_width || !target_height || !target_bpp) { if (!target_width || !target_height || !target_bpp) {
ret->default_res = true;
struct edid_info_struct *edid_info = get_edid_info(); struct edid_info_struct *edid_info = get_edid_info();
if (edid_info != NULL) { if (edid_info != NULL) {
int edid_width = (int)edid_info->det_timing_desc1[2]; int edid_width = (int)edid_info->det_timing_desc1[2];
@ -199,8 +190,6 @@ retry:
} }
fallback: fallback:
ret->default_res = true;
if (current_fallback == 0) { if (current_fallback == 0) {
if (try_mode(ret, preset_mode, 0, 0, 0)) if (try_mode(ret, preset_mode, 0, 0, 0))
return true; return true;

View File

@ -120,8 +120,6 @@ bool init_vbe(struct fb_info *ret,
uint16_t target_width, uint16_t target_height, uint16_t target_bpp) { uint16_t target_width, uint16_t target_height, uint16_t target_bpp) {
print("vbe: Initialising...\n"); print("vbe: Initialising...\n");
ret->default_res = false;
size_t current_fallback = 0; size_t current_fallback = 0;
struct vbe_info_struct vbe_info; struct vbe_info_struct vbe_info;
@ -143,8 +141,6 @@ bool init_vbe(struct fb_info *ret,
}; };
if (!target_width || !target_height || !target_bpp) { if (!target_width || !target_height || !target_bpp) {
ret->default_res = true;
struct edid_info_struct *edid_info = get_edid_info(); struct edid_info_struct *edid_info = get_edid_info();
if (edid_info != NULL) { if (edid_info != NULL) {
int edid_width = (int)edid_info->det_timing_desc1[2]; int edid_width = (int)edid_info->det_timing_desc1[2];
@ -220,8 +216,6 @@ retry:
} }
fallback: fallback:
ret->default_res = true;
if (current_fallback < SIZEOF_ARRAY(fallback_resolutions)) { if (current_fallback < SIZEOF_ARRAY(fallback_resolutions)) {
target_width = fallback_resolutions[current_fallback].width; target_width = fallback_resolutions[current_fallback].width;
target_height = fallback_resolutions[current_fallback].height; target_height = fallback_resolutions[current_fallback].height;

View File

@ -24,19 +24,6 @@ void stage3_common(void);
#if defined (uefi) #if defined (uefi)
EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
// Invalid return address of 0 to end stacktraces here
asm volatile (
"push 0\n\t"
"jmp efi_entry_point\n\t"
:: "D" (ImageHandle), "S" (SystemTable)
: "memory"
);
__builtin_unreachable();
}
__attribute__((noreturn))
void efi_entry_point(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
gST = SystemTable; gST = SystemTable;
gBS = SystemTable->BootServices; gBS = SystemTable->BootServices;
gRT = SystemTable->RuntimeServices; gRT = SystemTable->RuntimeServices;
@ -44,8 +31,20 @@ void efi_entry_point(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
init_memmap(); init_memmap();
term_vbe(0, 0); uint32_t colourscheme[] = {
early_term = true; 0x00000000, // black
0x00aa0000, // red
0x0000aa00, // green
0x00aa5500, // brown
0x000000aa, // blue
0x00aa00aa, // magenta
0x0000aaaa, // cyan
0x00aaaaaa, // grey
0x00000000, // background (black)
0x00aaaaaa // foreground (white)
};
term_vbe(colourscheme, 64, 0, NULL);
print("Limine " LIMINE_VERSION "\n\n"); print("Limine " LIMINE_VERSION "\n\n");
@ -62,7 +61,13 @@ void efi_entry_point(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
panic("Can't determine boot disk"); panic("Can't determine boot disk");
} }
stage3_common(); // Invalid return address of 0 to end stacktraces here
asm volatile (
"push 0\n\t"
"jmp stage3_common\n\t"
);
__builtin_unreachable();
} }
#endif #endif

View File

@ -207,7 +207,7 @@ cont:
} }
char *config_get_value(const char *config, size_t index, const char *key) { char *config_get_value(const char *config, size_t index, const char *key) {
if (!key || !config_ready) if (!key)
return NULL; return NULL;
if (config == NULL) if (config == NULL)

View File

@ -16,6 +16,10 @@ bool fb_init(struct fb_info *ret,
r = init_gop(ret, target_width, target_height, target_bpp); r = init_gop(ret, target_width, target_height, target_bpp);
#endif #endif
memmap_alloc_range(ret->framebuffer_addr,
(uint64_t)ret->framebuffer_pitch * ret->framebuffer_height,
MEMMAP_FRAMEBUFFER, false, false, false, true);
return r; return r;
} }

View File

@ -10,7 +10,6 @@ struct resolution {
}; };
struct fb_info { struct fb_info {
bool default_res;
uint8_t memory_model; uint8_t memory_model;
uint64_t framebuffer_addr; uint64_t framebuffer_addr;
uint16_t framebuffer_pitch; uint16_t framebuffer_pitch;

View File

@ -1,7 +1,6 @@
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <lib/gterm.h> #include <lib/gterm.h>
#include <lib/term.h>
#include <lib/blib.h> #include <lib/blib.h>
#include <lib/libc.h> #include <lib/libc.h>
#include <lib/config.h> #include <lib/config.h>
@ -32,12 +31,9 @@ static int frame_height, frame_width;
static struct image *background; static struct image *background;
static size_t last_grid_size = 0;
static struct gterm_char *grid = NULL; static struct gterm_char *grid = NULL;
static size_t last_front_grid_size = 0;
static struct gterm_char *front_grid = NULL; static struct gterm_char *front_grid = NULL;
static size_t last_bg_canvas_size = 0;
static uint32_t *bg_canvas = NULL; static uint32_t *bg_canvas = NULL;
static bool double_buffer_enabled = false; static bool double_buffer_enabled = false;
@ -366,112 +362,17 @@ void gterm_putchar(uint8_t c) {
} }
} }
bool gterm_init(int *_rows, int *_cols, int width, int height) { bool gterm_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _margin_gradient, struct image *_background) {
if (current_video_mode >= 0 int req_width = 0, req_height = 0, req_bpp = 0;
&& fbinfo.default_res == true
&& width == 0
&& height == 0
&& fbinfo.framebuffer_bpp == 32
&& !early_term) {
gterm_clear(true);
return true;
}
if (current_video_mode >= 0 char *menu_resolution = config_get_value(NULL, 0, "MENU_RESOLUTION");
&& fbinfo.framebuffer_width == width if (menu_resolution != NULL)
&& fbinfo.framebuffer_height == height parse_resolution(&req_width, &req_height, &req_bpp, menu_resolution);
&& fbinfo.framebuffer_bpp == 32
&& !early_term) {
gterm_clear(true);
return true;
}
early_term = false;
// We force bpp to 32 // We force bpp to 32
if (!fb_init(&fbinfo, width, height, 32)) req_bpp = 32;
return false;
// default scheme fb_init(&fbinfo, req_width, req_height, req_bpp);
int margin = 64;
margin_gradient = 20;
ansi_colours[0] = 0x00000000; // black
ansi_colours[1] = 0x00aa0000; // red
ansi_colours[2] = 0x0000aa00; // green
ansi_colours[3] = 0x00aa5500; // brown
ansi_colours[4] = 0x000000aa; // blue
ansi_colours[5] = 0x00aa00aa; // magenta
ansi_colours[6] = 0x0000aaaa; // cyan
ansi_colours[7] = 0x00aaaaaa; // grey
ansi_colours[8] = 0x00000000; // background (black)
ansi_colours[9] = 0x00aaaaaa; // foreground (grey)
char *colours = config_get_value(NULL, 0, "THEME_COLOURS");
if (colours == NULL)
colours = config_get_value(NULL, 0, "THEME_COLORS");
if (colours != NULL) {
const char *first = colours;
int i;
for (i = 0; i < 10; i++) {
const char *last;
uint32_t col = strtoui(first, &last, 16);
if (first == last)
break;
ansi_colours[i] = col;
if (*last == 0)
break;
first = last + 1;
}
if (i < 8) {
ansi_colours[8] = ansi_colours[0];
ansi_colours[9] = ansi_colours[7];
}
}
char *theme_background = config_get_value(NULL, 0, "THEME_BACKGROUND");
if (theme_background != NULL) {
ansi_colours[8] = strtoui(theme_background, NULL, 16);
}
char *theme_foreground = config_get_value(NULL, 0, "THEME_FOREGROUND");
if (theme_foreground != NULL) {
ansi_colours[9] = strtoui(theme_foreground, NULL, 16);
}
char *theme_margin = config_get_value(NULL, 0, "THEME_MARGIN");
if (theme_margin != NULL) {
margin = strtoui(theme_margin, NULL, 10);
}
char *theme_margin_gradient = config_get_value(NULL, 0, "THEME_MARGIN_GRADIENT");
if (theme_margin_gradient != NULL) {
margin_gradient = strtoui(theme_margin_gradient, NULL, 10);
}
char *background_path = config_get_value(NULL, 0, "BACKGROUND_PATH");
if (background_path != NULL) {
struct file_handle *bg_file = ext_mem_alloc(sizeof(struct file_handle));
if (uri_open(bg_file, background_path)) {
background = ext_mem_alloc(sizeof(struct image));
if (open_image(background, bg_file)) {
background = NULL;
}
}
}
if (background != NULL) {
char *background_layout = config_get_value(NULL, 0, "BACKGROUND_STYLE");
if (background_layout != NULL && strcmp(background_layout, "centered") == 0) {
char *background_colour = config_get_value(NULL, 0, "BACKDROP_COLOUR");
if (background_colour == NULL)
background_colour = config_get_value(NULL, 0, "BACKDROP_COLOR");
if (background_colour == NULL)
background_colour = "0";
uint32_t bg_col = strtoui(background_colour, NULL, 16);
image_make_centered(background, fbinfo.framebuffer_width, fbinfo.framebuffer_height, bg_col);
}
}
// Ensure this is xRGB8888, we only support that for the menu // Ensure this is xRGB8888, we only support that for the menu
if (fbinfo.red_mask_size != 8 if (fbinfo.red_mask_size != 8
@ -494,8 +395,6 @@ bool gterm_init(int *_rows, int *_cols, int width, int height) {
memcpy(vga_font, (void *)_binary_font_bin_start, VGA_FONT_MAX); memcpy(vga_font, (void *)_binary_font_bin_start, VGA_FONT_MAX);
char *menu_font = config_get_value(NULL, 0, "MENU_FONT"); char *menu_font = config_get_value(NULL, 0, "MENU_FONT");
if (menu_font == NULL)
menu_font = config_get_value(NULL, 0, "TERMINAL_FONT");
if (menu_font != NULL) { if (menu_font != NULL) {
struct file_handle f; struct file_handle f;
if (!uri_open(&f, menu_font)) { if (!uri_open(&f, menu_font)) {
@ -505,29 +404,23 @@ bool gterm_init(int *_rows, int *_cols, int width, int height) {
} }
} }
*_cols = cols = (gterm_width - margin * 2) / VGA_FONT_WIDTH; *_cols = cols = (gterm_width - _margin * 2) / VGA_FONT_WIDTH;
*_rows = rows = (gterm_height - margin * 2) / VGA_FONT_HEIGHT; *_rows = rows = (gterm_height - _margin * 2) / VGA_FONT_HEIGHT;
if (grid == NULL)
grid = ext_mem_alloc(rows * cols * sizeof(struct gterm_char));
if (front_grid == NULL)
front_grid = ext_mem_alloc(rows * cols * sizeof(struct gterm_char));
background = _background;
size_t new_grid_size = rows * cols * sizeof(struct gterm_char); memcpy(ansi_colours, _colours, sizeof(ansi_colours));
if (new_grid_size > last_grid_size) {
grid = ext_mem_alloc(new_grid_size);
last_grid_size = new_grid_size;
}
size_t new_front_grid_size = rows * cols * sizeof(struct gterm_char); margin_gradient = _margin_gradient;
if (new_front_grid_size > last_front_grid_size) {
front_grid = ext_mem_alloc(new_front_grid_size);
last_front_grid_size = new_front_grid_size;
}
frame_height = gterm_height / 2 - (VGA_FONT_HEIGHT * rows) / 2; frame_height = gterm_height / 2 - (VGA_FONT_HEIGHT * rows) / 2;
frame_width = gterm_width / 2 - (VGA_FONT_WIDTH * cols) / 2; frame_width = gterm_width / 2 - (VGA_FONT_WIDTH * cols) / 2;
size_t new_bg_canvas_size = gterm_width * gterm_height * sizeof(uint32_t); if (bg_canvas == NULL)
if (new_bg_canvas_size > last_bg_canvas_size) { bg_canvas = ext_mem_alloc(gterm_width * gterm_height * sizeof(uint32_t));
bg_canvas = ext_mem_alloc(new_bg_canvas_size);
last_bg_canvas_size = new_bg_canvas_size;
}
gterm_generate_canvas(); gterm_generate_canvas();
gterm_clear(true); gterm_clear(true);

View File

@ -8,7 +8,8 @@
extern struct fb_info fbinfo; extern struct fb_info fbinfo;
bool gterm_init(int *_rows, int *_cols, int width, int height); bool gterm_init(int *rows, int *cols, uint32_t *colours, int margin,
int margin_gradient, struct image *background);
void gterm_putchar(uint8_t c); void gterm_putchar(uint8_t c);
void gterm_clear(bool move); void gterm_clear(bool move);

View File

@ -6,12 +6,10 @@
#include <lib/blib.h> #include <lib/blib.h>
#include <lib/gterm.h> #include <lib/gterm.h>
bool early_term = false; void term_vbe(uint32_t *colours, int margin, int margin_gradient, struct image *background) {
void term_vbe(int width, int height) {
term_backend = NOT_READY; term_backend = NOT_READY;
if (!gterm_init(&term_rows, &term_cols, width, height)) { if (!gterm_init(&term_rows, &term_cols, colours, margin, margin_gradient, background)) {
#if defined (bios) #if defined (bios)
// Failed to set VBE properly, default to text mode // Failed to set VBE properly, default to text mode
term_textmode(); term_textmode();

View File

@ -17,7 +17,7 @@ extern void (*set_text_bg)(int bg);
extern void (*term_double_buffer)(bool status); extern void (*term_double_buffer)(bool status);
extern void (*term_double_buffer_flush)(void); extern void (*term_double_buffer_flush)(void);
void term_vbe(int width, int height); void term_vbe(uint32_t *colours, int margin, int margin_gradient, struct image *background);
void term_textmode(void); void term_textmode(void);
void term_write(const char *buf, size_t count); void term_write(const char *buf, size_t count);
@ -34,6 +34,4 @@ enum {
extern int term_backend; extern int term_backend;
extern int current_video_mode; extern int current_video_mode;
extern bool early_term;
#endif #endif

View File

@ -369,13 +369,85 @@ char *menu(char **cmdline) {
char *graphics = "yes"; char *graphics = "yes";
#endif #endif
if (graphics != NULL && !strcmp(graphics, "yes")) { if (graphics != NULL && !strcmp(graphics, "yes")) {
int req_width = 0, req_height = 0, req_bpp = 0; // default scheme
int margin = 64;
int margin_gradient = 20;
uint32_t colourscheme[] = {
0x00000000, // black
0x00aa0000, // red
0x0000aa00, // green
0x00aa5500, // brown
0x000000aa, // blue
0x00aa00aa, // magenta
0x0000aaaa, // cyan
0x00aaaaaa, // grey
0x00000000, // background (black)
0x00aaaaaa // foreground (grey)
};
char *menu_resolution = config_get_value(NULL, 0, "MENU_RESOLUTION"); char *colours = config_get_value(NULL, 0, "THEME_COLOURS");
if (menu_resolution != NULL) if (colours == NULL)
parse_resolution(&req_width, &req_height, &req_bpp, menu_resolution); colours = config_get_value(NULL, 0, "THEME_COLORS");
if (colours != NULL) {
const char *first = colours;
int i;
for (i = 0; i < 10; i++) {
const char *last;
uint32_t col = strtoui(first, &last, 16);
if (first == last)
break;
colourscheme[i] = col;
if (*last == 0)
break;
first = last + 1;
}
if (i < 8) {
colourscheme[8] = colourscheme[0];
colourscheme[9] = colourscheme[7];
}
}
term_vbe(req_width, req_height); char *theme_margin = config_get_value(NULL, 0, "THEME_MARGIN");
if (theme_margin != NULL) {
margin = strtoui(theme_margin, NULL, 10);
}
char *theme_margin_gradient = config_get_value(NULL, 0, "THEME_MARGIN_GRADIENT");
if (theme_margin_gradient != NULL) {
margin_gradient = strtoui(theme_margin_gradient, NULL, 10);
}
struct image *bg = NULL;
char *background_path = config_get_value(NULL, 0, "BACKGROUND_PATH");
if (background_path == NULL)
goto nobg;
struct file_handle *bg_file = ext_mem_alloc(sizeof(struct file_handle));
if (!uri_open(bg_file, background_path))
goto nobg;
bg = ext_mem_alloc(sizeof(struct image));
if (open_image(bg, bg_file))
bg = NULL;
nobg:
term_vbe(colourscheme, margin, margin_gradient, NULL);
if (bg != NULL) {
char *background_layout = config_get_value(NULL, 0, "BACKGROUND_STYLE");
if (background_layout != NULL && strcmp(background_layout, "centered") == 0) {
char *background_colour = config_get_value(NULL, 0, "BACKDROP_COLOUR");
if (background_colour == NULL)
background_colour = config_get_value(NULL, 0, "BACKDROP_COLOR");
if (background_colour == NULL)
background_colour = "0";
uint32_t bg_col = strtoui(background_colour, NULL, 16);
image_make_centered(bg, fbinfo.framebuffer_width, fbinfo.framebuffer_height, bg_col);
}
}
term_vbe(colourscheme, margin, margin_gradient, bg);
} }
disable_cursor(); disable_cursor();

View File

@ -171,10 +171,6 @@ void stivale_load(char *config, char *cmdline) {
if (!fb_init(&fbinfo, req_width, req_height, req_bpp)) if (!fb_init(&fbinfo, req_width, req_height, req_bpp))
panic("stivale: Unable to set video mode"); panic("stivale: Unable to set video mode");
memmap_alloc_range(fbinfo.framebuffer_addr,
(uint64_t)fbinfo.framebuffer_pitch * fbinfo.framebuffer_height,
MEMMAP_FRAMEBUFFER, false, false, false, true);
stivale_struct.framebuffer_addr = (uint64_t)fbinfo.framebuffer_addr; stivale_struct.framebuffer_addr = (uint64_t)fbinfo.framebuffer_addr;
stivale_struct.framebuffer_width = fbinfo.framebuffer_width; stivale_struct.framebuffer_width = fbinfo.framebuffer_width;
stivale_struct.framebuffer_height = fbinfo.framebuffer_height; stivale_struct.framebuffer_height = fbinfo.framebuffer_height;

View File

@ -269,24 +269,27 @@ void stivale2_load(char *config, char *cmdline, bool pxe, void *efi_system_table
struct fb_info *fb = NULL; struct fb_info *fb = NULL;
struct fb_info _fb; struct fb_info _fb;
struct stivale2_header_tag_framebuffer *hdrtag = get_tag(&stivale2_hdr, STIVALE2_HEADER_TAG_FRAMEBUFFER_ID);
int req_width, req_height, req_bpp;
if (hdrtag != NULL) {
req_width = hdrtag->framebuffer_width;
req_height = hdrtag->framebuffer_height;
req_bpp = hdrtag->framebuffer_bpp;
char *resolution = config_get_value(config, 0, "RESOLUTION");
if (resolution != NULL)
parse_resolution(&req_width, &req_height, &req_bpp, resolution);
}
struct stivale2_header_tag_terminal *terminal_hdr_tag = get_tag(&stivale2_hdr, STIVALE2_HEADER_TAG_TERMINAL_ID); struct stivale2_header_tag_terminal *terminal_hdr_tag = get_tag(&stivale2_hdr, STIVALE2_HEADER_TAG_TERMINAL_ID);
struct stivale2_header_tag_framebuffer *hdrtag = get_tag(&stivale2_hdr, STIVALE2_HEADER_TAG_FRAMEBUFFER_ID);
if (bits == 64 && terminal_hdr_tag != NULL && hdrtag != NULL) { if (bits == 64 && terminal_hdr_tag != NULL && hdrtag != NULL) {
term_vbe(req_width, req_height); // If we're coming from some odd mode (text mode), reinitialise the graphical console
if (current_video_mode < 0) {
uint32_t colourscheme[] = {
0x00000000, // black
0x00aa0000, // red
0x0000aa00, // green
0x00aa5500, // brown
0x000000aa, // blue
0x00aa00aa, // magenta
0x0000aaaa, // cyan
0x00aaaaaa, // grey
0x00000000, // background (black)
0x00aaaaaa // foreground (grey)
};
term_vbe(colourscheme, 64, 20, NULL);
}
if (current_video_mode < 0) { if (current_video_mode < 0) {
panic("stivale2: Failed to initialise terminal"); panic("stivale2: Failed to initialise terminal");
@ -313,15 +316,19 @@ void stivale2_load(char *config, char *cmdline, bool pxe, void *efi_system_table
if (hdrtag != NULL) { if (hdrtag != NULL) {
term_deinit(); term_deinit();
int req_width = hdrtag->framebuffer_width;
int req_height = hdrtag->framebuffer_height;
int req_bpp = hdrtag->framebuffer_bpp;
char *resolution = config_get_value(config, 0, "RESOLUTION");
if (resolution != NULL)
parse_resolution(&req_width, &req_height, &req_bpp, resolution);
if (fb_init(fb, req_width, req_height, req_bpp)) { if (fb_init(fb, req_width, req_height, req_bpp)) {
skip_modeset:; skip_modeset:;
struct stivale2_struct_tag_framebuffer *tag = ext_mem_alloc(sizeof(struct stivale2_struct_tag_framebuffer)); struct stivale2_struct_tag_framebuffer *tag = ext_mem_alloc(sizeof(struct stivale2_struct_tag_framebuffer));
tag->tag.identifier = STIVALE2_STRUCT_TAG_FRAMEBUFFER_ID; tag->tag.identifier = STIVALE2_STRUCT_TAG_FRAMEBUFFER_ID;
memmap_alloc_range(fb->framebuffer_addr,
(uint64_t)fb->framebuffer_pitch * fb->framebuffer_height,
MEMMAP_FRAMEBUFFER, false, false, false, true);
tag->memory_model = STIVALE2_FBUF_MMODEL_RGB; tag->memory_model = STIVALE2_FBUF_MMODEL_RGB;
tag->framebuffer_addr = fb->framebuffer_addr; tag->framebuffer_addr = fb->framebuffer_addr;
tag->framebuffer_width = fb->framebuffer_width; tag->framebuffer_width = fb->framebuffer_width;

View File

@ -3,7 +3,7 @@ TIMEOUT=3
GRAPHICS=yes GRAPHICS=yes
MENU_FONT=boot:///boot/font.bin MENU_FONT=boot:///boot/font.bin
THEME_BACKGROUND=60000000 THEME_COLOURS=000000;aa0000;00aaff;aa5500;0000aa;aa00aa;9076de;aaaaaa;60000000;aaaaaa
THEME_MARGIN=64 THEME_MARGIN=64
BACKGROUND_PATH=boot:///boot/bg.bmp BACKGROUND_PATH=boot:///boot/bg.bmp