Questions about paging in 64-bit mode
Posted: Tue Jan 06, 2009 1:34 pm
Hello,
Currently I know how to set up identity mapped pages in long mode. How do I also map physical memory to a virtual address?
For instance in the code below I map the first 4GB of RAM to start at 0x0000000000000000
How can I also map the first physical 4GB of RAM to start at 0xFFFF800000000000 ?
Still trying to wrap my head around Page maps... I would like to do this as I can have the kernel and apps running in the higher canonical area in memory so I can use all available RAM in the system (and it won't overlap with PCI devices that map memory in the first 4 Gigs).
Thanks,
-Ian
Currently I know how to set up identity mapped pages in long mode. How do I also map physical memory to a virtual address?
For instance in the code below I map the first 4GB of RAM to start at 0x0000000000000000
How can I also map the first physical 4GB of RAM to start at 0xFFFF800000000000 ?
Still trying to wrap my head around Page maps... I would like to do this as I can have the kernel and apps running in the higher canonical area in memory so I can use all available RAM in the system (and it won't overlap with PCI devices that map memory in the first 4 Gigs).
Code: Select all
; 16-bit code
; Create the Level 4 Page Map. (Maps 4GBs of 2MB pages)
; First create a PML4E enrty.
; A single PML4E entry can map 512GB with 2MB pages.
cld
mov di, 0x2000 ; Create a PML4E entry for the first 4GB of RAM
mov eax, 0x00003007
stosd
xor eax, eax
stosd
; Second create four PDPE entries.
; A single PDPE entry can map 1GB with 2MB pages
mov di, 0x3000
mov eax, 0x00010007
stosd
xor eax, eax
stosd
mov eax, 0x00011007
stosd
xor eax, eax
stosd
mov eax, 0x00012007
stosd
xor eax, eax
stosd
mov eax, 0x00013007
stosd
xor eax, eax
stosd
; Third create 2048 PDE entries.
push es
mov ax, 0x1000
mov es, ax
mov di, 0x0000
mov eax, 0x0000008F ; Bit 7 must be set to 1 as we have 2MB pages
xor ecx, ecx
again: ; create a 2MB page
stosd
push eax
xor eax, eax
stosd
pop eax
add eax, 0x00200000
inc ecx
cmp ecx, 2048
jne again ; Create 2048 2MB page maps.
pop es
-Ian