繁体   English   中英

长模式1GB分页

[英]long mode 1GB paging

我想在长模式下使用1GB页面,因为4KB / 2MB使事情变得更复杂,然后我需要。 所以我只是从OSDev复制了示例: https ://wiki.osdev.org/Entering_Long_Mode_Directly

这在VirtualBox上运作良好。 然后我尝试按照AMD64手册第2卷第137页中的描述进行操作:带有2个分页表的https://support.amd.com/TechDocs/24593.pdf

(是的,我已经检查了cpuid 8000_0001h / EDX位26)

%define PAGE_PRESENT    (1 << 0)
%define PAGE_WRITE      (1 << 1)
%define PS_BIT      (1<<7)
;1GB Pages avec 2 tables
; Build the Page Map Level 4.
; di points to the Page Map Level 4 table.
lea eax, [di + 0x1000]         ; Put the address of the Page Directory Pointer Table in to EAX.
or eax, PAGE_PRESENT | PAGE_WRITE ; Or EAX with the flags - present flag, writable flag.
mov [di], eax                  ; Store the value of EAX as the first PML4E.

lea di, [di + 0x1000]             
mov eax, PAGE_PRESENT | PAGE_WRITE | PS_BIT    ; Move the flags into EAX - and point it to 0x0000.
mov ebx,0
mov ecx,512

; Build the Page Table.
.LoopPageTable:
mov [di], eax
add di,2
mov [di],ebx
add ebx,2^14 ;so this adds 1GB(2^30) to the table entry
add di, 6
loop .LoopPageTable

;continue Enter long mode.

但是现在VirtualBox崩溃了。

我希望有人可以在这里帮助我:)等待。

prl是正确的。 我已经通过16384替换了2 ^ 14,并且能够将jmp转换为64位代码。 非常感谢你

彼得也说得对,VirtualBox随后崩溃了

[BITS 64]      
LongMode:
mov ax, DATA_SEG
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax

; Blank out the screen to a blue color.
mov edi, 0xB8000
mov rcx, 500                      ; 500=80*25*2/8
mov rax, 0x1F201F201F201F20       ; Set the value to set the screen to: Blue background, white foreground, blank spaces.

尝试“ rep stosq”时崩溃

rep stosq  
hlt

©osdev.org

我不知道为什么,但是在使用我的计算机时可以正常工作(将字节码复制到USB并重新启动)

因此,请您花点时间解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM