×
单片机 > 单片机程序设计 > 详情

mini2440系统移植篇之init启动流程

发布时间:2020-05-28 发布时间:
|

1. 启动

内核启动应用程序/linuxrc

busybox ini.c

init_main

设置信号处理函数

初始化控制台

parse_inittab解析inittab

1.1. 解析inittab

file = open(INITTAB, “r”); //打开配置文件/etc/inittab

new_init_action

//1 创建一个init_action结构,填充

//2 把结构放入init_action_list链表

默认配置

::sysinit:/etc/init.d/rcS

::askfirst:/bin/sh

tty2::askfirst:/bin/sh

tty3::askfirst:/bin/sh

tty4::askfirst:/bin/sh

::ctrlaltdel:/sbin/reboot

::shutdown:/sbin/swapoff -a

::shutdown:/bin/umount -a -r

::restart:/sbin/init


1.2. 运行


  1. /* First run the sysinit command */  

  2. run_actions(SYSINIT);  

  3.   

  4. /* Next run anything that wants to block */  

  5. run_actions(WAIT);  

  6.   

  7. /* Next run anything to be run only once */  

  8. run_actions(ONCE);  

  9.   

  10. /* Now run the looping stuff for the rest of forever */  

  11. while (1) {  

  12.     /* run the respawn/askfirst stuff */  

  13.     run_actions(RESPAWN | ASKFIRST);  

  14.   

  15.     /* Don't consume all CPU time -- sleep a bit */  

  16.     sleep(1);  

  17.   

  18.     /* Wait for any child process to exit */  

  19.     wpid = wait(NULL);  

  20.     while (wpid > 0) {  

  21.         /* Find out who died and clean up their corpse */  

  22.         for (a = init_action_list; a; a = a->next) {  

  23.             if (a->pid == wpid) {  

  24.                 /* Set the pid to 0 so that the process gets 

  25.                  * restarted by run_actions() */  

  26.                 a->pid = 0;  

  27.                 message(L_LOG, "process '%s' (pid %d) exited. "  

  28.                         "Scheduling for restart.",  

  29.                         a->command, wpid);  

  30.             }  

  31.         }  

  32.         /* see if anyone else is waiting to be reaped */  

  33.         wpid = wait_any_nohang(NULL);  

  34.     }  

  35. }  



关键字:mini2440  系统移植  init  启动流程 

『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
ARM基础知识八