⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 操作系统引导探究.htm

📁 操作系统引导探究
💻 HTM
📖 第 1 页 / 共 5 页
字号:
style="TEXT-INDENT: 42.75pt; mso-char-indent-count: 4.07"><SPAN lang=EN   
style="COLOR: blue">DL</SPAN><SPAN   
style="COLOR: blue; FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">寄存器:存驱动器号,表示欲读哪一个驱动器</SPAN><SPAN   
lang=EN style="COLOR: blue"><o:p></o:p></SPAN></P>  
<P class=MsoNormal   
style="TEXT-INDENT: 42.75pt; mso-char-indent-count: 4.07"><SPAN lang=EN   
style="COLOR: blue">CH</SPAN><SPAN   
style="COLOR: blue; FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">寄存器:存磁头号,表示欲读哪一个磁头</SPAN><SPAN   
lang=EN style="COLOR: blue"><o:p></o:p></SPAN></P>  
<P class=MsoNormal   
style="TEXT-INDENT: 42.75pt; mso-char-indent-count: 4.07"><SPAN lang=EN   
style="COLOR: blue">CL</SPAN><SPAN   
style="COLOR: blue; FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">寄存器:存扇区号,表示欲读的启始扇区</SPAN><SPAN   
lang=EN style="COLOR: blue"><o:p></o:p></SPAN></P>  
<P class=MsoNormal   
style="TEXT-INDENT: 42.75pt; mso-char-indent-count: 4.07"><SPAN lang=EN   
style="COLOR: blue">AL</SPAN><SPAN   
style="COLOR: blue; FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">寄存器:存计数值,表示欲读入的扇区数量</SPAN><SPAN   
lang=EN style="COLOR: blue"><o:p></o:p></SPAN></P>  
<P class=MsoNormal style="TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在设置了这几个寄存器后,我们就可以使用</SPAN>   
<SPAN class=SpellE><SPAN lang=EN style="COLOR: blue">int</SPAN></SPAN><SPAN   
lang=EN style="COLOR: blue"> 13</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这条指令调用</SPAN><SPAN   
lang=EN>BIOS 13</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">号中断读取指定的磁盘扇区,它将磁盘扇区读入</SPAN><SPAN   
lang=EN style="COLOR: blue">ES:BX</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">处,因此,在调用它之前,我们实际上还需要设置</SPAN><SPAN   
lang=EN>ES</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">与</SPAN><SPAN   
lang=EN>BX</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">寄存器,以指出数据在内存中存放的位置。</SPAN></P>  
<P class=MsoNormal><SPAN lang=EN><o:p>&nbsp;</o:p></SPAN></P>  
<P class=MsoNormal style="TEXT-ALIGN: center" align=center><B   
style="mso-bidi-font-weight: normal"><SPAN   
style="COLOR: #ff6600; FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">四、保护模式下段模式内存地址的访问</SPAN><SPAN   
lang=EN style="COLOR: #ff6600"><o:p></o:p></SPAN></B></P>  
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">写程序离不开对内存的访问,然而在保护模式下内存的访问与在实模式下内存的访问完全不同,这里我们将详细描述一下保护模式下内存的访问方法。当然,这里并不打算完整的介绍保护模式下所有的内存访问方法与机制,只介绍从实模式转到保护模式下所需要进行的转换,完整的内存访问请你最好参见《</SPAN><SPAN   
lang=EN>Intel</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用户手册》,当然,随着</SPAN><SPAN   
class=SpellE><SPAN lang=EN>pyos</SPAN></SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的实验进行,我也会在后面的实验报告与心得体会中渐渐描述,现在不描述主要原因是我还为通过</SPAN><SPAN   
class=SpellE><SPAN lang=EN>pyos</SPAN></SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进行实验,对与没经过实验验证的东西,我并不打算也不敢妄下结论,因为在前言中已然说过,这篇文章只是我的一些心得体会,如果我没有实验过,就没有心得,也没有体会,也就无法描述了。</SPAN></P>  
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">言归正转,我们还是先来看看实模式下内存访问方法吧。</SPAN></P>  
<P class=MsoNormal style="TEXT-ALIGN: center" align=center><B   
style="mso-bidi-font-weight: normal"><SPAN lang=EN style="COLOR: #ff6600">4.1   
</SPAN></B><B style="mso-bidi-font-weight: normal"><SPAN   
style="COLOR: #ff6600; FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实模式下的内存访问</SPAN><SPAN   
lang=EN style="COLOR: #ff6600"><o:p></o:p></SPAN></B></P>  
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">计算机在加电时,处于“实模式”,在计算机中有一个</SPAN><SPAN   
lang=EN style="COLOR: blue">CR0</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">寄存器,又称为</SPAN><SPAN   
lang=EN>0</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">号控制寄存器,在这个寄存器中,最低位也即第</SPAN><SPAN   
lang=EN>0</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">位,被称为</SPAN><SPAN   
lang=EN style="COLOR: blue">PM</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">(</SPAN><SPAN   
lang=EN>Protected <SPAN class=SpellE>Modle</SPAN></SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">:保护模式)位,当它被清零的时候表示</SPAN><SPAN   
lang=EN>CPU</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在“实模式”下工作,当它被置位的时候,表示</SPAN><SPAN   
lang=EN>CPU</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在“保护模式”下工作。在计算机加电的时候,它是被清零的,所在这个时候的计算机,处于“实模式”。</SPAN></P>  
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">“实模式”下的内存访问通过段寄存器与偏移量构成,比如前面描述中常常出现的</SPAN><SPAN   
lang=EN>0x:0000:0x0001</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就是一个实模式下的内存地址。分号前面的值表时段寄存器中的值,分号后面的值表是偏移量,实际物理地址的形成如下图所示:</SPAN></P>  
<P class=MsoNormal><SPAN lang=EN></SPAN></P>  
<P class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><IMG   
alt="" src="操作系统引导探究_files/20044621278430.gif" onload=""><BR>(图四)</SPAN></P>  
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">然而在保护模式下,内存地址却不是如上图所示的方法形成的。那么它又时怎样形成的呢?</SPAN></P>  
<P class=MsoNormal style="TEXT-ALIGN: center" align=center><B   
style="mso-bidi-font-weight: normal"><SPAN lang=EN style="COLOR: red">4.2   
</SPAN></B><B style="mso-bidi-font-weight: normal"><SPAN   
style="COLOR: red; FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">保护模式下的内存地址形成</SPAN></B></P>  
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">保护模式下内存地址就复杂多了,</SPAN>   
<SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我们首先要分清三个概念:<SPAN   
style="COLOR: blue">逻辑地址</SPAN>、<SPAN style="COLOR: blue">线性地址</SPAN>与<SPAN   
style="COLOR: blue">物理地址</SPAN>。物理地址很好理解,逻辑地址也好理解,就是程序所使用的地址。那么什么是线性地址呢?</SPAN></P>  
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其实如果不使用分页机制的话,线性地址就是物理地址,它与物理地址是一一对应的,线性地址</SPAN><SPAN   
lang=EN>0</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,也就是物理地址</SPAN><SPAN   
lang=EN>0</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。但我们知道,</SPAN><SPAN   
lang=EN>32</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">位的</SPAN><SPAN   
lang=EN>CPU</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">拥有</SPAN><SPAN   
lang=EN>32</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">根地址线,也就是可以访问:</SPAN></P>  
<P class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN   
lang=EN><SUB></SUB><SPAN style="mso-spacerun: yes"><IMG alt=""   
src="操作系统引导探究_files/200446212726779.gif" onload="">&nbsp;</SPAN><SPAN   
class=GramE>=<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>4GB</SPAN></SPAN></P>  
<P class=MsoNormal><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的内存空间,这实再是一个太大的空间了!现在很少有机器的物理内存能有这么大。那怎么在有限的物理空间中使用</SPAN><SPAN   
lang=EN>4GB</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的空间呢?人们把物理内存分成许多页,当某些页被使用的时候,某些页就没有被使用,而没有被使用的页就可以用来载入</SPAN><SPAN   
lang=EN>4GB</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">上的空间,这就称为从线性地址到物理地址的映射,这是一个多对一的映射,也就是说多个线性空间中的页对应一个物理空间中的页,希望下面一幅图能有助于你理解这样的分页机制。</SPAN></P>  
<P class=MsoNormal><SPAN lang=EN></SPAN></P>  
<P class=MsoNormal style="TEXT-ALIGN: center" align=center><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><IMG   
alt="" src="操作系统引导探究_files/200446212741748.gif" onload=""><BR>(图五)</SPAN></P>  
<P class=MsoNormal style="TEXT-INDENT: 21.75pt"><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">上面是一种最简单的映射方式,术语称作“直接相连”映射,它大约只能用来说明问题,而在一个实际的操作系统中通常是“全相联相连”映射,也就是说线性地址中的页可以是映射到物理地址中的任何一个页中,只要那块物理地址空间现在是空闲的。不过,通过上图也能说明问题,当线性地址中的页</SPAN><SPAN   
lang=EN>5</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">需要被访问时,</SPAN><SPAN   
lang=EN>CPU</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通过地址映射机制将其转换到物理地址,发现其对应物理地址中的页</SPAN><SPAN   
lang=EN>1</SPAN><SPAN   
style="FONT-FAMILY: SimSun; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。于是</SPAN><SPAN   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -