Skip to content

Commit

Permalink
drivers/vga: map and register VGA console only when supported
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel authored and bjoernd committed Aug 30, 2021
1 parent 3100556 commit 3868874
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions common/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ static void __text_init init_console(void) {
get_com_ports();

uart_init(com_ports[0], DEFAULT_BAUD_SPEED);

register_console_callback(serial_console_write);
register_console_callback(vga_console_write);

printk("COM1: %x, COM2: %x\n", com_ports[0], com_ports[1]);
}
Expand All @@ -183,7 +181,7 @@ void zap_boot_mappings(void) {
}
}

static void map_bios_area(void) {
static void __text_init map_bios_area(void) {
vmap_4k(paddr_to_virt(BDA_ADDR_START), paddr_to_mfn(BDA_ADDR_START), L1_PROT_RO);
kmap_4k(paddr_to_mfn(BDA_ADDR_START), L1_PROT_RO);

Expand All @@ -196,6 +194,15 @@ static void map_bios_area(void) {
kmap_4k(bios_mfn, L1_PROT_RO);
}

static void __text_init init_vga_console(void) {
if (!boot_flags.vga)
return;

printk("Enabling VGA support\n");
map_vga_area();
register_console_callback(vga_console_write);
}

void __noreturn __text_init kernel_start(uint32_t multiboot_magic,
multiboot_info_t *mbi) {
/* Zero-out BSS sections */
Expand Down Expand Up @@ -239,7 +246,6 @@ void __noreturn __text_init kernel_start(uint32_t multiboot_magic,

map_multiboot_areas();
map_bios_area();
map_vga_area();

write_cr3(cr3.paddr);
boot_flags.virt = true;
Expand All @@ -260,6 +266,8 @@ void __noreturn __text_init kernel_start(uint32_t multiboot_magic,
BUG();
}

init_vga_console();

init_apic(get_bsp_cpu_id(), APIC_MODE_XAPIC);

init_tasks();
Expand Down

0 comments on commit 3868874

Please sign in to comment.