flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > [x86-64] Is it possible to mix 1GB pages and 4KB pages? |
Author |
|
revolution 23 Apr 2018, 14:32
CandyMan wrote: Whether it is possible to mix 1GB pages and 4KB pages? |
|||
23 Apr 2018, 14:32 |
|
CandyMan 23 Apr 2018, 14:36
how could a code look?
|
|||
23 Apr 2018, 14:36 |
|
Feryno 01 May 2018, 04:39
For that purpose just create 4-level 4KB paging and mix it together with already existing 2-level 1GB paging. For video memory 0xA0000-0xAFFFF it requires 1 PML4E, 1 PDPE, 1 PDE, 1 PTE. You already have PML4. Create 1 PDP, 1 PD, 1 PT. Add 1 entry into your PML4 pointing to the newly created PDP, add 1 entry into PDP pointing to the newly created PD, add 1 entry into PD pointing to the newly created PT, add 1 entry into PT pointing to the video memory. Also take care about page attributes as it is video memory (it may impact performance).
|
|||
01 May 2018, 04:39 |
|
CandyMan 01 May 2018, 17:16
I did as this way as below. It is working with qemu and withut emulator, but bochs generating #PF at the attempt of the reading of the 0xFC000000 address. where is the bug?
Code: PT_P = bit 0 ;present (else not) PT_W = bit 1 ;writable (else read-only) PT_U = bit 2 ;user mode (else kernel mode) PT_WT = bit 3 ;write through PT_CD = bit 4 ;page caching disabled (else enabled) PT_A = bit 5 ;accessed (else not) PT_D = bit 6 ;dirty (else clean) PT_PS = bit 7 ;page size = 4MB PT_AVL = bit 8 ;available PT_PAT = bit 12 ;1GB page PT_XD = bit 63 ;no execute MaxMemV = 69 ;69 GB long_PML4 = (1M+4k*0) long_PDPT = (1M+4k*1) long_PDT = (1M+4k*2) long_PT0 = (1M+4k*2+1G/2M*8) mov eax,1G movd mm1,eax mov eax,PT_PS+PT_P+PT_W+PT_U+PT_PAT movd mm0,eax xor ecx,ecx @@: movq [fs:long_PDPT+8*ecx],mm0 paddq mm0,mm1 inc ecx cmp ecx,MaxMemV jb @B mov [fs:long_PML4+000*8+0],dword long_PDPT+PT_P+PT_W+PT_U and [fs:long_PML4+000*8+4],dword 0 mov [fs:long_PDPT+000*8+0],dword long_PDT+PT_P+PT_W+PT_U and [fs:long_PDPT+000*8+4],dword 0 mov [fs:long_PDPT+068*8+0],dword long_68G+PT_P+PT_W+PT_U and [fs:long_PDPT+068*8+4],dword 0 ;2MB pages, map 1st 1GB Map1st = (1G/2M) mov ecx,Map1st mov eax,long_PDT mov edx,PT_PS+PT_P+PT_W+PT_U @@: mov [fs:eax],edx add edx,2M add eax,8 loopd @B long_68G = (long_PT0) mov ecx,16M/2M mov eax,long_68G mov edx,[AddrLFB] or edx,PT_PS+PT_P+PT_W+PT_U cmp [AddrLFB],0 jnz @F and dl,not PT_P @@: @@: mov [fs:eax],edx add edx,2M add eax,8 loopd @B mov [fs:eax],dword long_PTX+PT_P+PT_W+PT_U ;16M long_PTX = (long_68G+4K) mov edi,long_PTX mov ebx,0xA0000+PT_P+PT_W+PT_U mov ecx,(0xC0000-0xA0000)/4k @@: mov [fs:edi],ebx add ebx,4K add edi,8 loopd @B ... |
|||
01 May 2018, 17:16 |
|
Feryno 11 May 2018, 07:38
On #PF, error code is pushed into the stack with additional info. Did bochs report some info or not (in the second case you need to setup IDT and #PF handler which reports the error code).
|
|||
11 May 2018, 07:38 |
|
CandyMan 11 May 2018, 21:11
I already advised myself (I incorrectly accepted that bochs support 1GB paging while was turned off).
thanks all |
|||
11 May 2018, 21:11 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.