📄 booting-loading_process_5.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0068)http://www.huihoo.com/gnu_linux/own_os/booting-loading_process_5.htm -->
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT
face="Times New Roman" size=6><SPAN style="mso-tab-count: 1"><STRONG>1.5 Loading
Processing</STRONG></SPAN></FONT></SPAN></P><SPAN lang=EN-US><FONT
face="Times New Roman" size=5><SPAN style="mso-tab-count: 1">
<P>
<P tppabs="http://pagoda-ooos.51.net/os_book/booting/booting.htm"
HREF="javascript:if(confirm('http://pagoda-ooos.51.net/os_book/booting/booting.htm \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found. \n\nDo you want to open it from the server?'))window.location='http://pagoda-ooos.51.net/os_book/booting/booting.htm'"><FONT
size=3>[</FONT><A href="http://www.huihoo.com/gnu_linux/own_os/index.htm"
tppabs="http://pagoda-ooos.51.net/os_book/index.htm"><FONT
size=3>Home</FONT></A><FONT size=3>] [</FONT><A
href="booting.htm"
tppabs="http://pagoda-ooos.51.net/os_book/booting.htm"><FONT
size=3>Top</FONT></A><FONT size=3>] [</FONT><A
href="booting-a20_4.htm"
tppabs="http://pagoda-ooos.51.net/os_book/booting/booting-a20_4.htm"><FONT
size=3>Previous</FONT></A><FONT size=3>] [</FONT><A
href="booting-memory_check_6.htm"
tppabs="http://pagoda-ooos.51.net/os_book/booting/booting-memory_check_6.htm"><FONT
size=3>Next</FONT></A><FONT size=3>]</FONT></P>
<P><STRONG>
<HR width="100%" SIZE=2>
</STRONG>
<P></P>
<P><FONT size=4><SPAN lang=EN-US><FONT face="Times New Roman TUR"><SPAN
style="mso-tab-count: 1"><STRONG> <SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><FONT face="Times New Roman" size=5>1.5.1
Overview</FONT></SPAN></SPAN></STRONG></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l5 level1 lfo3"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT
face="Times New Roman TUR" size=3>我们在After
Power-On一节已经介绍——当主机被启动之后,会自动将软盘或硬盘的第一个扇区的内容(<STRONG>boot block </STRONG>for
floppy, <STRONG>master boot </STRONG>for hard
disk)Load到内存0000:7c00H的位置,然后执行它。但OS的内核绝对不仅仅只有一个扇区大小。这就意味着boot
block需要进一步的从磁盘(软盘或硬盘)上读取OS的剩余部分。</FONT></SPAN></SPAN></SPAN></SPAN></SPAN></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l5 level1 lfo3"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT
size=3></FONT></SPAN></SPAN></SPAN></SPAN></SPAN> </P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l5 level1 lfo3"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT
face="Times New Roman TUR"
size=3>事实上,从机器被Power-On或Reset之后,到OS的Kernel被正式的载入到运行,中间可以经历这些过程:</FONT></SPAN></SPAN></SPAN></SPAN></SPAN></P><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">
<OL type=1 start=0>
<LI><FONT face="Times New Roman TUR" size=3>由BIOS INT 19中断读入Master
boot;</FONT>
<LI></SPAN></SPAN></SPAN></SPAN></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT
face="Times New Roman TUR" size=3>由Master boot读入并执行Boot
Block;</FONT></SPAN></SPAN></SPAN></SPAN></SPAN>
<LI><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></SPAN></SPAN></SPAN></SPAN></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT
face="Times New Roman TUR"><FONT size=3><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">由Master
boot读入并执行</SPAN></SPAN></SPAN></SPAN></SPAN>Second Booter(Monitor
or Setup Program);</FONT></FONT></SPAN></SPAN></SPAN></SPAN></SPAN>
<LI><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"></SPAN></SPAN></SPAN></SPAN></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT
face="Times New Roman TUR" size=3>最后由Second booter读入并执行OS
Kernel。</FONT></SPAN></SPAN></SPAN></SPAN></SPAN></LI></OL>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l5 level1 lfo3"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><FONT face="Times New Roman TUR"
size=3>比如Linux的启动过程为:</FONT></SPAN></SPAN></P><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><FONT face="Times New Roman TUR" size=3>
<OL type=1 start=0>
<LI>Master boot(LILO)
<LI></FONT></SPAN></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><FONT face="Times New Roman TUR" size=3>Boot
Block(bootsect.S)</FONT></SPAN></SPAN>
<LI><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US></SPAN></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><FONT face="Times New Roman TUR"
size=3>Setup(Setup.S)</FONT></SPAN></SPAN>
<LI><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US></SPAN></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><FONT face="Times New Roman TUR" size=3>Linux
Kernel</FONT></SPAN></SPAN></LI></OL>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l5 level1 lfo3"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US><FONT face="Times New Roman TUR" size=3>Loading
Processing是Booting阶段的一个重要任务。为了很好的完成这一任务,我们必须清楚的了解磁盘(硬盘和软盘)操作的详细细节,对Loading过程和各个部分内存布局进行详细的规划。</FONT></SPAN></SPAN></P><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN
lang=EN-US>
<P>
<HR width="100%" SIZE=2>
<P></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l5 level1 lfo3"> <SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><STRONG><FONT
face="Times New Roman TUR" size=5>1.5.2 Memory Layout </FONT></STRONG></P>
<P><FONT face="Times New Roman TUR" size=3>在Real mode下,磁盘操作可以通过两种方法进行,BIOS
13H中断,或者通过读写端口。而在Protected
Mode下,BIOS中断不可用,只能通过读写端口的方式。而BIOS中断简单易用而且功能强大,同时我们在Booting阶段除了Loading
Processing之外,所作的许多工作都需要依赖BIOS中断,所以我们Loading Processing应该发生在Real
Mode下,通过BIOS中断调用来完成。</FONT></P>
<P><FONT face="Times New Roman TUR" size=3>但Real
Mode下的一种重要限制是1MB内存的局限,事实上仅有不到640
KB的可用RAM,我们必须把启动阶段所需要的各个程序,以及在启动阶段获取到的各种硬件参数,以及OS Kernel放入到这不到640
KB的RAM中。这样一来,我们如何在整个Booting阶段,合理有效的安排内存布局就显得非常重要。</FONT></P></SPAN></SPAN></SPAN>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l5 level1 lfo3"
align=center><IMG src="booting-loading_process_5.files/memory_layout2.gif"
tppabs="http://pagoda-ooos.51.net/os_book/booting/loading-process/memory_layout2.gif"></P>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; tab-stops: list 21.0pt; mso-list: l5 level1 lfo3"
align=center><SPAN
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -