Chinaunix首页 | 论坛 | 博客
  • 博客访问: 322492
  • 博文数量: 28
  • 博客积分: 609
  • 博客等级: 中士
  • 技术积分: 925
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-17 13:32
文章分类

全部博文(28)

文章存档

2022年(1)

2016年(1)

2015年(2)

2012年(1)

2011年(23)

分类: LINUX

2011-02-17 13:32:55

PC加电的过程就是将cs:ip指向0xFFFF0,这里是BIOS的内容。BIOS接下来就接管系统启动,负责检查并初始化硬件设备,初始化实模式下中断向量表。然后i386系统就会将硬盘的第一个扇区(0扇区)加载到内存0x7c00处---这就是MBR。
最简单的MBR的结构如下:
tructure of a master boot record
AddressDescriptionSize in bytes
HexOctDec
000000000code area440
(max. 446)
01B80670440disk signature (optional)4
01BC0674444Usually nulls; 0x00002
01BE0676446Table of primary partitions
(Four 16-byte entries, IBM partition table scheme)
64
01FE077651055hMBR signature;
0xAA55
2
01FF0777511AAh
MBR, total size: 446 + 64 + 2 =512

Layout of one 16-byte partition record
OffsetField
length
(bytes)
Description
0x001status (0x80 = bootable (active), 0x00 = non-bootable, other = invalid ) [a]
0x013CHS address of first absolute sector in partition. [b] The format is described by 3 bytes, see the next 3 rows.
0x011
h7-0head [c]
xxxxxxxx
0x021
c9-8s5–0sector is in bits 5–0; bits 9–8 of cylinder are in bits 7–6 [c]
xxxxxxxx
0x031
c7-0bits 7–0 of cylinder [d]
xxxxxxxx
0x041partition type[5][6]
0x053CHS address of last absolute sector in partition. [b] The format is described by 3 bytes, see the next 3 rows.
0x051
h7-0head [c]
xxxxxxxx
0x061
c9-8s5–0sector is in bits 5–0, bits 9–8 of cylinder are in bits 7–6 [c]
xxxxxxxx
0x071
c7-0bits 7–0 of cylinder [d]
xxxxxxxx
0x084LBA of first absolute sector in the partition [e]
0x0C4Number of sectors in partition, in little-endian format [e]
Notes:

^ a Formally, status values other than 0x00 and 0x80 are undefined.

^ b Starting Sector fields are limited to 1024 cylinders, 255 heads, and 63 sectors;[citation needed] Ending Sector fields have the same limitations.

^ c The range for sector is 1 through 63; the range for cylinder is 0 through 1023; the range for head is 0 through 254 inclusive.[citation needed]

^ d The 10-bit cylinder value is split into two bytes. The value can be reassembled using this formula: cylinder = ((byte[2] & 0xc0) << 2) | byte[3]

^ e Used by OSes only in certain circumstances; in such cases the CHS addresses are ignored.[7]

从上图中可以知道MBR已经知道硬盘的分区结构(最多四个主分区--16X4),并且知道哪个分区是活动分区。MBR找到活动分区并且把该活动分区的第一个扇区内容加载到
0x7c00的地方将自己覆盖掉,并将控制权交给0x7c00处的OS启动代码。在Linux里,这就是arch/boot/header.S

MBR实际就是Boot Loader,以上就是最简单的BootLoader的例子,现在的Bootloader一般都比这个复杂。一般来说一个BootLoader会占据不止一个扇区以支持多重启动。
阅读(4260) | 评论(5) | 转发(6) |
0

上一篇:没有了

下一篇:Linux Kernel 2.6.37 启动过程笔记 :Header.S

给主人留下些什么吧!~~

lxl1232012-05-19 16:53:14

收藏

limsco2011-05-16 13:33:38

恩,好东西!看懂了!

limsco2011-05-16 13:33:37

恩,好东西!看懂了!

amarant2011-02-26 08:20:31

顶~

crazyscottz2011-02-18 14:56:41

这个个沙发是我的。
沙发上慢慢看