From eb909686f19073b324dee15366b957802dc095a7 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 14 Mar 2021 23:08:46 +0200 Subject: CGA: map and set buffer address in kernel main --- src/boot.S | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/boot.S') diff --git a/src/boot.S b/src/boot.S index d1c4f9b..e39883e 100644 --- a/src/boot.S +++ b/src/boot.S @@ -51,9 +51,10 @@ kernel_ptable0: bootloader will jump to this position once the kernel has been loaded. */ .section .multiboot.text, "ax" +.global VADDR_OFFSET .set VADDR_OFFSET, 0xc0000000 - 0x400000 .global _start -.type _start, @function + .type _start, @function _start: cli @@ -62,12 +63,12 @@ _start: # Only map the kernel. mov $_kernel_start - VADDR_OFFSET, %esi - # Map 1023 pages. The 1024th will be the VGA text buffer. - movl $1023, %ecx + # Map 1024 pages + movl $1024, %ecx l_page_init: - cmpl $(_kernel_end - VADDR_OFFSET), %esi - jge map_vga + cmpl $(_kernel_end - VADDR_OFFSET), %esi + jge map_table /* TODO: Map physical address as "present, writable". Note that this maps .text and .rodata as writable. Mind security and map them as non-writable. */ @@ -82,10 +83,7 @@ l_page_init: # Loop to the next entry if we haven't finished. loop l_page_init -map_vga: - # Map VGA video memory to 0xC03FF000 as "present, writable". - movl $(0x000B8000 | 0x003), kernel_ptable0 - VADDR_OFFSET + 1023 * 4 - +map_table: /* Enabling paging does not change the next instruction, which continues to be physical. Therefore, map the kernel to both its physical address and to the higher half. -- cgit v1.2.1