#include <inc/mmu.h>
# Start the CPU: switch to 32-bit protected mode, jump into C.
# The BIOS loads this code from the first sector of the hard disk into
# memory at physical address 0x7c00 and starts executing in real mode
# with %cs=0 %ip=7c00.
启动CPU,切换到32位保护模式,跳转到C代码
BIOS从硬盘的第一个扇区加载这个代码到
物理内存地址为0x7c00的地方,cs=0,ip=7c00
下面的3条.set指令类似于宏定义
内核代码段选择子
.set PROT_MODE_CSEG, 0x8 # kernel code segment selector
内核数据段选择子
.set PROT_MODE_DSEG, 0x10 # kernel data segment selector
保护模式使能标志
.set CR0_PE_ON, 0x1 # protected mode enable flag
定义一个全局名字start
.globl start
start:
CPU刚启动为16位模式
.code16 # Assemble for 16-bit mode
关中断
cli # Disable interrupts
清方向标志
cld # String operations increment
# Set up the important data segment registers (DS, ES, SS).
设置重要的数据段寄存器
ax清零
xorw %ax,%ax # Segment number zero
ds清零
MIT6.828 boot.S文件分析
最新推荐文章于 2024-05-06 22:58:17 发布
本文详细分析了MIT6.828课程中的boot.S文件,该文件负责启动CPU并切换到32位保护模式。通过设置段寄存器、开启A20地址线、加载全局描述符表,最终进入C代码执行。主要内容包括实模式到保护模式的转换、数据段寄存器初始化和调用bootmain函数。
摘要由CSDN通过智能技术生成