OS Boot Sequence

当BIOS INT 19h被执行以后,系统进入OS Booting阶段。

下面定义几个程序段名称:

NameDescriptionSize limit
Master Booter放置于Hard disk的第一个扇区(即MBR),用于装载boot block的程序。466 bytes
Boot Sector放置与Floppy的第一个扇区,或者Hard disk的某一分区的第一个扇区的用于装载Secondary boot,或其它程序的可运行程序。512 bytes
Secondary Boot放置于非Floppy/Hard disk的第一个扇区,以及Hard disk的任意分区的第一个扇区之外的任意其它位置,用于装载OS,或其它程序的可运行程序。no limit

当用硬盘启动OS的时候,以上调用顺序为 MB -> BS -> SB -> OS;

当用软盘启动OS的时候,以上调用顺序为 BS -> SB -> OS。


当机器被打开时,等电源稳定之后,电源会发送一个“加电成功信号”给芯片,以启动时钟生成器(8284);


1.2.4.2 软盘启动

相对于硬盘启动过程,软盘启动则要简单的多,只需要将boot sector程序放置于软盘的第一个扇区。当INT 19从软盘启动的时候,会自动将boot sector读入内存的7C00h的位置,然后跳转到7C00h开始执行。


1.2.4.1 硬盘启动

硬盘的第一个扇区(sector)被称作MBR(Master Boot Record)。由于硬盘可以有多个分区,所以在MBR上,不仅放置着用于启动的可执行代码master boot,还放着磁盘分区表(DPT),占用66个字节,所以MBR中的可执行代码必须在512 - 66 = 446个字节以内。

OffsetContentSize
0hMaster booting programmax 466 bytes
01BEhDisk Partition Table64 bytes
01FEhSignature (HEX 55 AA)2 bytes

Table 1.2.1- MBR Layout

OffsetContentSize
01BEhPartition 1 data table16 bytes
01CEhPartition 2 data table16 bytes
01DEhPartition 3 data table16 bytes
01FEhPartition 4 data table16 bytes

Table 1.2.2 - DPT Layout

OffsetContentData Type
00hboot indicatorbyte
01hbeginning sector head numberbyte
02hbeginning sector (2 high bits of cylinder #)byte
03hbeginning cylinder# (low order bits of cylinder #)byte
04hsystem indicatorbyte
05hending sector head numberbyte
06hending sector (2 high bits of cylinder #)byte
07hending cylinder# (low order bits of cylinder #)byte
08hnumber of sectors preceding the partitiondword(4 bytes)
0Bhnumber of sectors in the partitiondword

Table 1.2.3 - Layout of Partition Data Table

Boot indicator (BYTE)

       00 - non-bootable partition

       80 - bootable partition (one partition only)

System Indicator (BYTE)

       00 - unknown operating system

       01 - DOS with 12 bit FAT, 16 bit sector number

       02 - XENIX

       04 - DOS with 16 bit FAT, 16 bit sector number

       05 - DOS Extended partition (DOS 3.3+)

       06 - DOS 4.0 (Compaq 3.31), 32 bit sector number

       51 - Ontrack extended partition

       64 - Novell

       75 - PCIX

       DB - CP/M

       FF – BBT

Signature

       Hex 55AA marks the end of valid boot sector.

       This is also required in each of the partition boot records.

What does master booter should do?

        INT 19会将MBR的512 bytes load到内存0x7c00中,然后JUMP到0x7c00处,开始执行MBR的可执行程序master booter,Master booter最起码需要做这些事情:

  • 检测MAGIC(Signature)是否为合法值(Hex 55AA);
  • 将自己移动到其它位置,将0x7C00到0x7c00+512K的空间让出来,以备其后将boot sector程序装入这个位置,这样才能和直接从软盘直接装入boot sector程序相一致;具体移动到什么位置,则根据设计而定,理论上,可以移动到任何非冲突位置(即没有被预留为其它程序所用的位置);但一般情况下,都是在0X000800至0X0A0000之间寻找一端空间存放。

  • 查看分区表,将被设为活动的分区的第一个Sector装入0X7C00的位置,正常的情况下,此Sector放置的就是boot sector程序;

  • 最终,master booter跳转到0X7C00的位置,开始执行boot sector。

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值