I'm by no means an expert. However, I will speak to my personal experience. I started with the above advice as a starting point as a result of being challenged with the 32-bit immediate issues with 64-bit code. Ultimately, when I started working on my paging tables and trying to figure out recursive mapping, I made the critical decision to keep my recursive mappings at the highest memory locations.XenOS wrote:I'm quite curious how exactly you would split these things up. Do you have any particular locations for user mode libraries? Or page tables, PL0-stacks, other kernel relevant stuff?Brendan wrote:Of course then you'd split up each area into specific pieces (text, data, bss; shared library area, whatever).
Therefore, I have so far developed the following memory map. Disclaimer: I am only so far working on the kernel, so large portions of this map is currently unused. I might also get a few months down the road and change everything again as I learn more.
0x0000 0000 0000 0000 to 0x0000 7fff ffff ffff -- User memory space (not defined at this point)
0xffff 8000 0000 0000 to 0xffff 8fff ffff ffff -- Kernel Code (.text & .rodata)
0xffff 9000 0000 0000 to 0xffff 9fff ffff ffff -- Kernel Data (.data & .text)
0xffff a000 0000 0000 to 0xffff afff ffff ffff -- Kernel Heap
0xffff b000 0000 0000 to 0xffff bfff ffff ffff -- Driver/Daemon Code [future development]
0xffff c000 0000 0000 to 0xffff cfff ffff ffff -- Driver/Daemon Data [future development]
0xffff d000 0000 0000 to 0xffff dfff ffff ffff -- Driver/Daemon Heap [future development]
0xffff e000 0000 0000 to 0xffff efff ffff ffff -- Future Use -- Unknown at this time
0xffff f000 0000 0000 to 0xffff f001 ffff ffff -- Physical Memory Manager Bitmap -- enough room to manage 256TB
0xffff f002 0000 0000 to 0xffff f003 ffff ffff -- Stacks (not sure if kernel-only at this point); enough room for 512K X 16KB stacks
0xffff f004 0000 0000 to 0xffff ff7f ffdf ffff -- System reserved memory
0xffff ff7f ffe0 0000 to 0xffff ff7f ffef ffff -- Reserved for pointer initialization space (where dereferencing a pointer will cause page-fault)
0xffff ff7f fff0 0000 to 0xffff ff7f ffff efff -- TSSs (at 1 per CPU, this will be far more space than I will ever use; but I have space to do something different is I so choose)
0xffff ff7f ffff f000 to 0xffff ff7f ffff ffff -- Specific location for initializing page table internal structures before inserting them into their proper right location
0xffff ff80 0000 0000 to 0xffff ffff bfff ffff -- Page Tables recursive mapping
0xffff ffff c000 0000 to 0xffff ffff ffdf ffff -- Page Directories recursive mapping
0xffff ffff c000 0000 to 0xffff ffff ffdf ffff -- Page Directory Pointer Tables recursive mapping
0xffff ffff ffff f000 to 0xffff ffff ffff ffff -- PML4 recursive mapping