diff --git a/common/setup.c b/common/setup.c index d0cf7bb5..17034f9d 100644 --- a/common/setup.c +++ b/common/setup.c @@ -52,6 +52,7 @@ #include #include #include +#include bool opt_debug = false; bool_cmd("debug", opt_debug); @@ -234,6 +235,7 @@ void __noreturn __text_init kernel_start(uint32_t multiboot_magic, map_multiboot_areas(); map_bios_area(); + map_vga_area(); write_cr3(cr3.paddr); WRITE_SP(get_free_pages_top(PAGE_ORDER_2M, GFP_KERNEL)); diff --git a/drivers/vga.c b/drivers/vga.c index 26137fc3..49af217d 100644 --- a/drivers/vga.c +++ b/drivers/vga.c @@ -79,3 +79,11 @@ void vga_write(const char *buf, size_t len, vga_color_t color) { scroll_screen = screen; write_vga_buffer(screen); } + +void map_vga_area(void) { + for (mfn_t vga_mfn = paddr_to_mfn(VGA_START_ADDR); + vga_mfn < paddr_to_mfn(VGA_END_ADDR); vga_mfn++) { + vmap_4k(mfn_to_virt(vga_mfn), vga_mfn, L1_PROT); + kmap_4k(vga_mfn, L1_PROT); + } +} \ No newline at end of file diff --git a/include/drivers/vga.h b/include/drivers/vga.h index c0acfb0f..50bf3e6b 100644 --- a/include/drivers/vga.h +++ b/include/drivers/vga.h @@ -59,4 +59,6 @@ extern void vga_scroll_up(void); extern void vga_scroll_down(void); extern void vga_write(const char *buf, size_t len, vga_color_t color); + +extern void map_vga_area(void); #endif /* KTF_DRV_VGA_H */