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

📄 354.html

📁 著名的linux英雄站点的文档打包
💻 HTML
📖 第 1 页 / 共 4 页
字号:
/*<br>
* Turn on what we want<br>
*/<br>
orr r0, r0, #0x0031<br>
orr r0, r0, #0x2100 @ ..1. ...1 ..11 ...1<br>
<br>
#ifdef CONFIG_CPU_ARM920_D_CACHE_ON<br>
orr r0, r0, #0x0004 @ .... .... .... .1..<br>
#endif<br>
#ifdef CONFIG_CPU_ARM920_I_CACHE_ON<br>
orr r0, r0, #0x1000 @ ...1 .... .... ....<br>
#endif<br>
mov pc, lr<br>
<br>
这一段首先关闭i,d cache,清除write buffer ,然后设置页目录地址,设置<br>
domain的保护,在上节中,注意到页目录项的domain都是0,domain寄存器中<br>
的domain 0 对应的是0b11,表示访问模式为manager,不受限制。<br>
<br>
接下来设置控制寄存器,打开d,i cache和mmu<br>
注意arm的d cache必须和mmu一起打开,而i cache可以单独打开<br>
<br>
其实,cache和mmu的关系实在是紧密,每一个页表项都有标志标示是否是<br>
cacheable的,可以说本来就是设计一起使用的<br>
<br>
最后,自函数返回后,有一句<br>
mcr p15, 0, r0, c1, c0<br>
使设置生效。<br>
<br>
长篇连载--arm linux演艺---第八回<br>
--------------------------------------------------------------------------------<br>
<br>
上回我们讲到arm靠初始化完成了,打开了cache,<br>
到此为止,汇编部分的初始化代码就差不多了,最后还有几件事情做:<br>
<br>
1。初始化BSS段,全部清零,BSS是全局变量区域。<br>
2。保存与系统相关的信息:如<br>
.long SYMBOL_NAME(compat)<br>
.long SYMBOL_NAME(__bss_start)<br>
.long SYMBOL_NAME(_end)<br>
.long SYMBOL_NAME(processor_id)<br>
.long SYMBOL_NAME(__machine_arch_type)<br>
.long SYMBOL_NAME(cr_alignment)<br>
.long SYMBOL_NAME(init_task_union)+8192<br>
不用讲,大家一看就明白意思<br>
<br>
3。重新设置堆栈指针,指向init_task的堆栈。init_task是系统的第一个任务,init_task的堆栈在task structure的后8K,我们后面会看到。<br>
<br>
4。最后就要跳到C代码的start_kernel。<br>
b SYMBOL_NAME(start_kernel)<br>
<br>
现在让我们来回忆一下目前的系统状态:<br>
临时页表已经建立,在0X08004000处,映射了4M,虚地址0XC000000被映射到0X08000000.<br>
CACHE,MMU都已经打开。<br>
堆栈用的是任务init_task的堆栈。<br>
<br>
如果以为到了c代码可以松一口气的话,就大错特措了,linux的c也不比汇编好懂多少,相反到掩盖了汇编的一些和机器相关的部分,有时候更难懂。其实作为编写操作系统的c代码,只不过是汇编的另一种写法,和机器代码的联系是很紧密的。<br>
<br>
start_kernel在 /linux/init/main.c中定义:<br>
<br>
asmlinkage void __init start_kernel(void)<br>
{<br>
char * command_line;<br>
unsigned long mempages;<br>
extern char saved_command_line[];<br>
lock_kernel();<br>
printk(linux_banner);<br>
setup_arch(&command_line); //arm/kernel/setup.c<br>
printk("Kernel command line: %s", saved_command_line);<br>
parse_options(command_line);<br>
<br>
trap_init(); // arm/kernle/traps.c install<br>
。。。。。。。。。<br>
<br>
start_kernel中的函数个个都是重量级的,首先用printk(linux_banner);打出<br>
系统版本号,这里面就大有文章,系统才刚开张,你让他打印到哪里去呢?<br>
先给大家交个底,以后到console的部分自然清楚,printk和printf不同,他首先输出到系统的一个缓冲区内,大约4k,如果登记了console,则调用console-&gt;wirte函数输出,否则就一直在buffer里呆着。所以,用printk输出的信息,如果超出了4k,会冲掉前面的。在系统引导起来后,用dmesg看的也就是这个buffer中的东东。<br>
<br>
待续。。。。。<br>
<br>
长篇连载--arm linux演艺---第九回<br>
--------------------------------------------------------------------------------<br>
下面就是一个重量级的函数:<br>
setup_arch(&command_line); //arm/kernel/setup.c<br>
完成内存映像的初始化,其中command_line是从bootloader中传下来的。<br>
<br>
void __init setup_arch(char **cmdline_p)<br>
{<br>
struct param_struct *params = NULL;<br>
struct machine_desc *mdesc; //arch structure, for your ads, defined in include/arm-asm/mach/arch.h very long<br>
struct meminfo meminfo;<br>
char *from = default_command_line;<br>
<br>
memset(&meminfo, 0, sizeof(meminfo));<br>
<br>
首先把meminfo清零,有个背景介绍一下,从linux 2.4的内核开始,支持内存的节点(node),也就是可支持不连续的物理内存区域。这一点在嵌入式系统中很有用,例如对于SDRAM和FALSH,性质不同,可作为不同的内存节点。<br>
<br>
meminfo结构定义如下:<br>
<br>
/******************************************************/<br>
#define NR_BANKS 4<br>
//define the systen mem region, not consistent<br>
struct meminfo {<br>
int nr_banks;<br>
unsigned long end;<br>
struct {<br>
unsigned long start;<br>
unsigned long size;<br>
int node;<br>
} bank[NR_BANKS];<br>
};<br>
/******************************************************/<br>
<br>
下面是:ROOT_DEV = MKDEV(0, 255);<br>
<br>
ROOT_DEV是宏,指明启动的设备,嵌入式系统中通常是flash disk.<br>
这里面有一个有趣的悖论:linux的设备都是在/dev/下,访问这些设备文件需要设备驱动程序支持,而访问设备文件才能取得设备号,才能加载驱动程序,那么第一个设备驱动程序是怎么加载呢?就是ROOT_DEV, 不需要访问设备文件,直接指定设备号。<br>
<br>
下面我们准备初始化真正的内核页表,而不再是临时的了。<br>
首先还是取得当前系统的内存映像:<br>
<br>
mdesc = setup_architecture(machine_arch_type);<br>
//find the machine type in mach-integrator/arch.c<br>
//the ads name, mem map, io map<br>
<br>
返回如下结构:<br>
mach-integrator/arch.c<br>
<br>
MACHINE_START(INTEGRATOR, "Motorola MX1ADS")<br>
MAINTAINER("ARM Ltd/Deep Blue Solutions Ltd")<br>
BOOT_MEM(0x08000000, 0x00200000, 0xf0200000)<br>
FIXUP(integrator_fixup)<br>
MAPIO(integrator_map_io)<br>
INITIRQ(integrator_init_irq)<br>
MACHINE_END<br>
<br>
我们在前面介绍过这个结构,不过这次用它可是玩真的了。<br>
<br>
长篇连载--arm linux演艺---第十回<br>
--------------------------------------------------------------------------------<br>
<br>
  书接上回,<br>
下面是init_mm的初始化,init_mm定义在/arch/arm/kernel/init_task.c:<br>
struct mm_struct init_mm = INIT_MM(init_mm);<br>
<br>
从本回开始的相当一部分内容是和内存管理相关的,凭心而论,操作系统的<br>
内存管理是很复杂的,牵扯到处理器的硬件细节和软件算法,<br>
限于篇幅所限制,请大家先仔细读一读arm mmu的部分,<br>
中文参考资料:linux内核源代码情景对话,<br>
linux2.4.18原代码分析。<br>
<br>
init_mm.start_code = (unsigned long) &_text;<br>
内核代码段开始<br>
init_mm.end_code = (unsigned long) &_etext;<br>
内核代码段结束<br>
init_mm.end_data = (unsigned long) &_edata;<br>
内核数据段开始<br>
init_mm.brk = (unsigned long) &_end;<br>
内核数据段结束<br>
<br>
每一个任务都有一个mm_struct结构管理任务内存空间,init_mm<br>
是内核的mm_struct,其中设置成员变量* mmap指向自己,<br>
意味着内核只有一个内存管理结构,设置* pgd=swapper_pg_dir,<br>
swapper_pg_dir是内核的页目录,在arm体系结构有16k,<br>
所以init_mm定义了整个kernel的内存空间,下面我们会碰到内核<br>
线程,所有的内核线程都使用内核空间,拥有和内核同样的访问<br>
权限。<br>
<br>
memcpy(saved_command_line, from, COMMAND_LINE_SIZE);<br>
//clear command array<br>
<br>
saved_command_line[COMMAND_LINE_SIZE-1] = '</FONT><br>
                                      </TD>
                                    </TR>
                                <TR>
                                <TD colSpan=2><FONT 
                                class=middlefont></FONT><BR>
                                        <FONT 
                                class=normalfont>全文结束</FONT> </TD>
                                    </TR>
                                <TR>
                                <TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2 
                                height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
                        <TD vAlign=top width="20%" 
                      background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2> 
                          <DIV align=center> 
                            <table class=tableoutline cellspacing=1 cellpadding=4 
                        width="100%" align=center border=0>
                              <tr class=firstalt> 
                                <td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
                                <font class=normalfont><b>所有分类</b></font></td>
                              </tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td>    </tr>  </table></td></tr>                            </table>
                          </DIV></TD></TR>
                    <TR vAlign=top>
                        <TD width="80%"> 
                          <DIV align=center><BR>
                          </DIV>
                        </TD></TR></TBODY></TABLE></TD></TR>
                </TABLE></TD></TR>
          </TABLE>
      <TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee 
        border=0><TBODY>
        <TR>
          <TD width="50%">
              <P><FONT class=middlefont>版权所有 &copy; 2004 <A 
            href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
                违者必究. </FONT></P>
            </TD>
          <TD width="50%">
              <DIV align=right><FONT class=middlefont>Powered by: <A 
            href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
            </TD></TR></TBODY></TABLE>
      <CENTER></CENTER></TD></TR>
    </TABLE></CENTER></BODY></HTML>

⌨️ 快捷键说明

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