我的学习之旅(6)setup.s

49 篇文章 0 订阅
49 篇文章 0 订阅
;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。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值