;gdt表配置参考 linux source code: setup.s, 2个entry,第一个给CS,第二个给DS
gdt:
.word 0,0,0,0 ! dummy
.word 0x3FFF ! 64Mb (4000*4096=64Mb),由于在boot.s中能识别的最大内存为64M
.word 0x0000 ! base address=0
.word 0x9A00 ! code read/exec
.word 0x00C0 ! granularity=4096, 386
.word 0x3FFF ! 64Mb (4000*4096=64Mb)
.word 0x0000 ! base address=0
.word 0x9200 ! data read/write
.word 0x00C0 ! granularity=4096, 386
;中断表默认为空
idt_48:
.word 0 ! idt limit=0
.word 0,0 ! idt base=0L
gdt_48:
.word 0x800 ! gdt limit=2048, 256 GDT entries
.word 512+gdt,0x9 ! gdt base = 0X9xxxx
.org 1008
hd_info: ;记录了第一个硬盘的CHS信息
.word 0x1111
.word 0x2222
.word 0x3333
.word 0x4444
.word 0x5555
memory_size:
.word 0x1122
current_track:
.byte 0x0
current_sector:
.byte 0x0
retry_count:
.byte 0x03
;内核代码最大不能超过64k ,所以最大127个sectors
kernel_sectors:
.byte 0x7f
编译boot.s和setup.s
as86 -0 -a -o boot.o boot.s
ld86 -0 -s -o boot boot.o
as86 -0 -a -o setup.o setup.s
ld86 -0 -s -o setup setup.o
另外还需要把编译出来的boot和setup 文件merge在一起,需要模仿linux build.c做个小工具build_boot和build_setup。