diff --git a/arch/x86_64/start_32.S b/arch/x86_64/start_32.S index 2958500..988d1b4 100644 --- a/arch/x86_64/start_32.S +++ b/arch/x86_64/start_32.S @@ -5,10 +5,15 @@ .set MAGIC, 0x1BADB002 .set CHECKSUM, -(MAGIC + FLAGS) -/* the amount of memory to allocate for bootstrap page directories. */ -/* with buffer size 0x1000 (enough for exactly one page directory) -/* we can map 1 GiB of virtual memory */ -#define BOOTSTRAP_PDIR_SIZE 0x1000 +/* the amount of memory to allocate for bootstrap page directories. + with buffer size 0x2000 (enough for exactly two page directories) + we can map 2 GiB of virtual memory. + + we use this to map the virtual address range 0xffffffff'80000000 -> 0xffffffff'fffff000 + to the physical address range 0x00000000 -> 0x80000000, + to map the kernel's code and data, and give the kernel plenty of space to initialise itself. + */ +#define BOOTSTRAP_PDIR_SIZE 0x2000 .extern start_64 # defined in start_64.S @@ -166,8 +171,9 @@ init_page_tables: xchg %eax, %ecx add $0x1000, %edi sub %ecx, %edi - sub $0x08, %edi # subtract one from the index here, otherwise the mapping will be at 0xffffffffc0000000 - # (each entry in the array is 8 bytes long) + + #sub $0x08, %edi # subtract from the index here to adjust where the mapping starts + # NOTE that you must subtract in multiples of 0x8 /* %ESI is a pointer into the pagedir buffer. %EDI is a pointer into the PDPT.