学习linux0.11内核代码——引导启动程序bootsect.s(2)

本文详细探讨了Linux0.11内核的引导启动程序bootsect.s,解释了它如何在PC加电自检后被加载到0x7C00处执行,并逐步转移到0x90000。内容涉及bootsect如何加载setup模块到内存0x90200,设置段寄存器,利用BIOS中断0x13读取磁盘数据,以及获取磁盘参数表中的信息。通过对源代码的分析,文章解答了关于汇编指令和磁盘加载过程的疑问。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

二、 bootsect.s程序
1、 在PC加电自检后,ROM-BIOS会把引导扇区代码bootsect加载到0x7C00处并执行,执行过程中bootsect把自己移到0x90000处。程序主要负责:
1)把从磁盘第2扇区开始的4个扇区的setup模块(setup.s生成)加载到内存0x90200处(此处为紧接着ROM-BIOS之后),加载后内存如下分布(第一扇区即存放bootsect.s):
这里写图片描述

2) 利用BIOS中断0x13取磁盘参数表中当前启动引导盘的参数
3) 屏幕显示“Loading system…”
4) 把磁盘setup模块后面的system模块加载到内存0x10000
5) 确定根文件系统设备号并保存其设备号于root_dev
6) 跳转到setup程序开始处(即0x90200)执行setup程序

2、 根据源代码分析每一步骤执行过程
1) 执行bootsect过程中,bootsect把自己移到0x90000

…
BOOTSEG  = 0x07c0                      ! original address of boot-sector
INITSEG  = 0x9000                         ! we move boot here - out of the way
…

entry _start
_start:
    mov  ax,#BOOTSEG    
    mov  ds,ax                             !ds寄存器置为0x07c0
    mov  ax,#INITSEG
    mov  es,ax                             !es寄存器置为0x9000
    mov  cx,#256                         !设置计数器,计数25
linux .....\boot .....\....\bootsect.s .....\....\head.s .....\....\setup.s .....\fs .....\..\bitmap.c .....\..\block_dev.c .....\..\buffer.c .....\..\char_dev.c .....\..\exec.c .....\..\fcntl.c .....\..\file_dev.c .....\..\file_table.c .....\..\inode.c .....\..\ioctl.c .....\..\Makefile .....\..\namei.c .....\..\open.c .....\..\pipe.c .....\..\read_write.c .....\..\stat.c .....\..\super.c .....\..\truncate.c .....\include .....\.......\a.out.h .....\.......\asm .....\.......\...\io.h .....\.......\...\memory.h .....\.......\...\segment.h .....\.......\...\system.h .....\.......\const.h .....\.......\ctype.h .....\.......\errno.h .....\.......\fcntl.h .....\.......\linux .....\.......\.....\config.h .....\.......\.....\fs.h .....\.......\.....\hdreg.h .....\.......\.....\head.h .....\.......\.....\kernel.h .....\.......\.....\mm.h .....\.......\.....\sched.h .....\.......\.....\sys.h .....\.......\.....\tty.h .....\.......\signal.h .....\.......\stdarg.h .....\.......\stddef.h .....\.......\string.h .....\.......\sys .....\.......\...\stat.h .....\.......\...\times.h .....\.......\...\types.h .....\.......\...\utsname.h .....\.......\...\wait.h .....\.......\termios.h .....\.......\time.h .....\.......\unistd.h .....\.......\utime.h .....\init .....\....\main.c .....\kernel .....\......\asm.s .....\......\blk_drv .....\......\.......\blk.h .....\......\.......\floppy.c .....\......\.......\hd.c .....\......\.......\ll_rw_blk.c .....\......\.......\Makefile .....\......\.......\ramdisk.c .....\......\chr_drv .....\......\.......\console.c .....\......\.......\keyboard.S .....\......\.......\Makefile .....\......\.......\rs_io.s .....\......\.......\serial.c .....\......\.......\tty_io.c .....\......\.......\tty_ioctl.c .....\......\exit.c .....\......\fork.c .....\......\math .....\......\....\Makefile .....\......\....\math_emulate.c .....\......\mktime.c .....\......\panic.c .....\......\printk.c .....\......\sched.c .....\......\signal.c .....\......\sys.c .....\......\system_call.s .....\......\vsprintf.c .....\lib .....\...\close.c .....\...\ctype.c .....\...\dup.c .....\...\errno.c .....\...\execve.c .....\...\Makefile .....\...\malloc.c .....\...\open.c
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hello小崔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值