assembly - 如何在x86_64上进入64位模式

标签 assembly x86-64 bare-metal

我在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.

关于assembly - 如何在x86_64上进入64位模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22962251/

相关文章:

c - ARM单核简单高效的调度实现

gcc - 我怎么知道 .data 部分需要从哪里获取 init 数据? (gcc 链接器)

c - 将函数分离到不同文件时的数据损坏

c - 制作可变参数函数被调用者清理

linux - Fork 系统调用失败后 rax 中的返回值是多少?

C11 Atomic Acquire/Release 和 x86_64 缺乏加载/存储一致性?

gcc - Oracle Linux 中的 Valgrind 安装错误

assembly - 如何在 MIPS 中遍历数组?

linux - 在 Linux 下执行平面二进制文件

c - 减少 C 中的 if 语句以提高效率