我在xv6 https://github.com/chrisdew/xv6/blob/master/bootasm.S中找到了不错的汇编语言,它向我展示了如何从16位保护模式转换为32位保护模式。
有谁知道进入64位模式的类似示例吗? (通过或不使用32位模式。)
最佳答案
为了启用64位功能,必须将CPU切换到长模式。
要在64位x86处理器(x86-64)上进入“长模式”:
If paging is enabled, disable paging.
If CR4.PAE is not already set, set it.
Set IA32_EFER.LME = 1.
Load CR3 with a valid PML4 table.
Enable paging.
At this point you will be in compatibility mode. A far jump may be executed to switch to long mode. However, the offset must not exceed 32-bit.