最近我在看linux 01的源代码,因为2.6.11和更高版本的bootsect.S是无用的,因此它是开始学习linux代码的好地方,因此我选择跟踪Linux的第一个版本。 :P关于linux v0.01 bootsect.S
我在bootsect.S中有一些问题。以下是bootsect.S linux v 0.01中的一些代码。
P.S第一个版本的汇编代码使用的是intel语法,而不是在& t。
mov ax,#0x0001 | protected mode (PE) bit
lmsw ax | This is it!
jmpi 0,8 | jmp offset 0 of segment 8 (cs) which is the second entry of the gdt.
GDT:
.word 0,0,0,0 | dummy
.word 0x07FF | 8Mb - limit=2047 (2048*4096=8Mb)
.word 0x0000 | base address=0
.word 0x9A00 | code read/exec
.word 0x00C0 | granularity=4096, 386
.word 0x07FF | 8Mb - limit=2047 (2048*4096=8Mb)
.word 0x0000 | base address=0
.word 0x9200 | data read/write
.word 0x00C0 | granularity=4096, 386
引导过程似乎是这样的:
移动的引导程序从0x7c00到0×9000
代码跳转到0×9000
设置段寄存器。
负载系统代码为0x10000 (系统代码包含启动/ head.S中和init/main.c中根据生成文件)
负载临时GDT和IDT与LGDT和LIDT
使A20能够访问16MB物理内存。
组CR0的PE位去保护模式
跳转到0x000000处
下面是Makefile文件系统:
tools/system:
boot/head.o init/main.o \
$(ARCHIVES) $(LIBS)
$(LD) $(LDFLAGS) boot/head.o init/main.o \
$(ARCHIVES) \
$(LIBS) \
-o tools/system > System.map
好像头部.S和main.c作为bootsect加载到内存中的系统二进制文件链接在一起。
我的问题是如果系统代码(哪个条目是head.S/startup_32)加载在0x10000比为什么不跳转到0x10000而是跳转到0x000000? 跳到0x0是不是很奇怪,因为里面没有加载代码?
一个链接到源将本来不错:) – sehe
我添加一个下载链接到帖子。 tks的回复:) – mike820324