multiboot2: Bring framebuffer tag up to par with mb1

This commit is contained in:
mintsuki 2022-06-29 13:25:09 +02:00
parent 77b405a6b6
commit a1bf37382d
2 changed files with 12 additions and 5 deletions

View File

@ -372,7 +372,6 @@ nofb:;
mmap[i].type = raw_memmap[i].type;
}
struct meminfo memory_info = mmap_get_info(mb_mmap_count, raw_memmap);
// Convert the uppermem and lowermem fields from bytes to

View File

@ -450,9 +450,11 @@ bool multiboot2_load(char *config, char* cmdline) {
// Create framebuffer tag
//////////////////////////////////////////////
{
struct multiboot_tag_framebuffer *tag = (struct multiboot_tag_framebuffer *)(mb2_info + info_idx);
term_deinit();
if (fbtag) {
if (fbtag && fbtag->type == MULTIBOOT_FRAMEBUFFER_TYPE_RGB) {
size_t req_width = fbtag->width;
size_t req_height = fbtag->height;
size_t req_bpp = fbtag->depth;
@ -461,7 +463,6 @@ bool multiboot2_load(char *config, char* cmdline) {
if (resolution != NULL)
parse_resolution(&req_width, &req_height, &req_bpp, resolution);
struct multiboot_tag_framebuffer *tag = (struct multiboot_tag_framebuffer *)(mb2_info + info_idx);
struct fb_info fbinfo;
if (!fb_init(&fbinfo, req_width, req_height, req_bpp)) {
@ -495,16 +496,23 @@ bool multiboot2_load(char *config, char* cmdline) {
tag->framebuffer_blue_field_position = fbinfo.blue_mask_shift;
tag->framebuffer_blue_mask_size = fbinfo.blue_mask_size;
}
append_tag(info_idx, &tag->common);
} else {
#if uefi == 1
panic(true, "multiboot2: Cannot use text mode with UEFI");
#elif bios == 1
size_t rows, cols;
init_vga_textmode(&rows, &cols, false);
tag->common.framebuffer_addr = 0xb8000;
tag->common.framebuffer_width = cols;
tag->common.framebuffer_height = rows;
tag->common.framebuffer_bpp = 16;
tag->common.framebuffer_pitch = 2 * cols;
tag->common.framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT;
#endif
}
append_tag(info_idx, &tag->common);
}
//////////////////////////////////////////////