Skip to content

Commit

Permalink
setup, vga: map VGA memory area
Browse files Browse the repository at this point in the history
This is needed to get rid of "Low memory" mappings.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Jul 30, 2021
1 parent 015fb7a commit 4f6bd7e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <drivers/pic.h>
#include <drivers/pit.h>
#include <drivers/serial.h>
#include <drivers/vga.h>

bool opt_debug = false;
bool_cmd("debug", opt_debug);
Expand Down Expand Up @@ -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));
Expand Down
8 changes: 8 additions & 0 deletions drivers/vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 2 additions & 0 deletions include/drivers/vga.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit 4f6bd7e

Please sign in to comment.