移植嵌入式Linux到ARM处理器:操作系统(13)

(1)内核初始化:Linux内核的入口点是start_kernel()函数。它初始化内核的其他部分,包括捕获,IRQ通道,调度,设备驱动,标定延迟循环,最重要的是能够fork"init"进程,以启动整个多任务环境。

  我们可以在init中加上一些特定的内容。

  (2)设备驱动:设备驱动占据了Linux内核很大部分。同其他操作系统一样,设备驱动为它们所控制的硬件设备和操作系统提供接口。

  本文第四章将单独讲解驱动程序的编写方法。

   (3)文件系统:Linux最重要的特性之一就是对多种文件系统的支持。这种特性使得Linux很容易地同其他操作系统共存。文件系统的概念使得用户能 够查看存储设备上的文件和路径而无须考虑实际物理设备的文件系统类型。Linux透明的支持许多不同的文件系统,将各种安装的文件和文件系统以一个完整的 虚拟文件系统的形式呈现给用户。

  我们可以在K9S1208 NAND FLASH上移植cramfs、jfss2、yaffs等FLASH文件系统。

  3. init进程

  在init函数中"加料",可以使得Linux启动的时候做点什么,例如广州友善之臂公司的demo板在其中加入了公司信息:

static int init(void * unused)
{
lock_kernel();
do_basic_setup();

prepare_namespace();

/*
* Ok, we have completed the initial bootup, and
* we're essentially up and running. Get rid of the
* initmem segments and start the user-mode stuff..
*/
free_initmem();
unlock_kernel();

if (open("/dev/console", O_RDWR, 0) < 0)
printk("Warning: unable to open an initial console.\n");

(void) dup(0);
(void) dup(0);

/*
* We try each of these until one succeeds.
*
* The Bourne shell can be used instead of init if we are
* trying to recover a really broken machine.
*/

printk("========================================\n");
printk("= Friendly-ARM Tech. Ltd. =\n");
printk("= http://www.arm9.net =\n");
printk("= http://www.arm9.com.cn =\n");
printk("========================================\n");

if (execute_command)
execve(execute_command,argv_init,envp_init);
execve("/sbin/init",argv_init,envp_init);
execve("/etc/init",argv_init,envp_init);
execve("/bin/init",argv_init,envp_init);
execve("/bin/sh",argv_init,envp_init);
panic("No init found. Try passing init= option to kernel.");
}

  这样在Linux的启动过程中,会额外地输出:

========================================
= Friendly-ARM Tech. Ltd. =
= http://www.arm9.net =
= http://www.arm9.com.cn =
========================================

作者:宋宝华   更新日期:2006-11-21
来源:dev.yesky.com   浏览次数:

相关文章

相关评论   发表评论