BBS水木清华站∶精华区

发信人: chenl (bigmouth), 信区: Linux        
标  题: Re: Linux 核心启动过程一览 
发信站: BBS 水木清华站 (Thu May  6 08:20:53 1999) 
 
【 在 vertex (lancelord) 的大作中提到: 】 
∶ 发信人: vertex (lacelord), 信区: Linux 
∶ 标  题: Linux 启动信息 
∶ 发信站: 9781 BBS (Tue May  4 10:26:21 1999), 转信 
∶ /* 
∶  本文参考了 
∶            http://gem.ncic.ac.cn/~xhg/khg/HyperNews/get/tour/tour.html 
∶  欢迎指正. 
∶  ------------------------------------------------------------------- 
∶  用dmesg命令可以看到linux启动打出的消息. 
∶  从这可以看到linux启动的过程. 
∶  主要的源文件 
∶  可以到 http://gem.ncic.ac.cn/lance/lxr/source/init/main.c 
∶ */ 
∶ -------------------------------------------------------------------- 
∶ /** 
∶     内核的启动最后是到 start_kernel ( in /init/main.c ) 
∶     head.S --> main.c(start_kernel) .. 
∶         建议每个人都读一下 main.c ( init/ ) 
∶         有空可以读 head.S ( arch/i386/boot/ )     
∶ **/ 
∶ /** 
∶   第一部分  : 内核初始化以及启动. 
∶ **/ 
∶ Loading ....[ bootsect.S ] 
∶ uncompress .....[ decompress_kernel() ] 
∶ /*  
∶  *  main.c ---> start_kernel() 开始. 
∶  *      
∶  *  开始 printk(banner); 
∶  */ 
∶ Linux version 2.2.6 (root@lance) (gcc version 2.7.2.3)  
∶     #40 Sun Apr 18 17:44:20 CST 1999 
∶ /* 以下是 /arch/i386/time.c 中 init_time() 打出的信息 */齱 
∶ Detected 199908264 Hz processor. 
∶ /* console_init() --> drivers/char/tty_io.c */ 
∶ Console: colour VGA+ 80x25 
∶ /*运行一个循环,测量一下 MIPS -- 为什么要干这件傻事??*/齱 
∶ /* 我知道了 ... 这是因为内核需要知道一个确定的机器指令周期来实现实时的延迟. 
∶    为什么要打印出来 ?? 这有两个原因 : 
∶             1 . 用于 DEBUG . 
∶             2 . 搞笑用途 , Linus Torvalds 每每看见用户对此疑惑不解时,总是 
∶                 大笑....:-(( 
∶ */ 
∶ Calibrating delay loop... 199.48 BogoMIPS 
∶ /* init_mem */ 
∶ Memory: 63396k/65536k available (848k kernel code, 408k reserved, 856k data, 28k  
∶ /** dquote_init()  **/ 
∶ VFS: Diskquotas version dquot_6.4.0 initialized 
∶ /* ?????????? **/ 
∶ CPU: Intel Pentium Pro stepping 09 
∶ Checking 386/387 coupling... OK, FPU using exception 16 error reporting. 
∶ Checking 'hlt' instruction... OK. 
∶ POSIX conformance testing by UNIFIX 
∶ /** 
∶ 此后调用 linux_thread(init ,..,..,)(arch/i386/kernel/process.c)  
∶ 创建一个运行 init 的进程. 
∶ 从此...开始了一个新的阶段 : 
∶               进入了用户模式 ( user_mode) ,跳到以下第二部分.----+ 
 
                ^^^^^^^^^^^^^^^ 
      这个地方值得讨论,我从程序上及从实际跟踪的情况看, kernel_thread 
      都不是用户模式,而是地道理的核心态!真正系统的第一个用户态进程是 
      执行了fork之后的/sbin/init. 
 
∶                                                                 | 
∶                                                                 | 
∶  End of start_kernel                                            | 
∶                                                                 | 
∶  最后进入cpu_idle ( arch/i386/kernel/process.c )                | 
∶                                                                 | 
∶ **/                                                             | 
∶                                                                 | 
∶ /**                                                             | 
∶    第二部分               <-------------------------------------+ 
∶    以下是对设备的初始化 . init()--->do_basic_init()--+ 
∶ **/                                                  | 
∶ /*                                                   | 
∶  *   pci_init() <------------------------------------+  
∶  *              |                
∶  */             +------------------------------------+ 
∶ PCI: PCI BIOS revision 2.10 entry at 0xfd8d1         | 
∶ PCI: Using configuration type 1                      | 
∶ PCI: Probing PCI hardware                            | 
∶                                                      | 
∶ /**                                                  | 
∶   对Socket的初始化,socket_init()  <------------------+ 
∶ **/                                |   
∶                                    +--------------------------+ 
∶ Linux NET4.0 for Linux 2.2                                    | 
∶ Based upon Swansea University Computer Society NET3.039       | 
∶ NET4: Unix domain sockets 1.0 for Linux NET4.0.               | 
∶ NET4: Linux TCP/IP 1.0 for NET4.0                             | 
∶ IP Protocols: ICMP, UDP, TCP                                  | 
∶ /** **/                                                       | 
∶ Starting kswapd v 1.5   kswapd_setup()    <-------------------+      
∶ /** Mouse **/                              | 
∶ Detected PS/2 Mouse Port.                  | 
∶                                     device_setup() 
∶ /** 声卡 **/                               | 
∶                                            |  
∶ Sound initialization started               | 
∶ Sound initialization complete              | 
∶                                            | 
∶ /** 软驱 **/                               | 
∶                                            | 
∶ Floppy drive(s): fd0 is 1.44M              | 
∶ FDC 0 is a National Semiconductor PC87306  | 
∶                                            | 
∶ /** SCSI 设备的初始化 **/                  +----------------------------+ 
∶                                                                         | 
∶ (scsi0) <Adaptec AIC-7880 Ultra SCSI host adapter> found at PCI 13/0    | 
∶ (scsi0) Wide Channel, SCSI ID=7, 16/255 SCBs                            | 
∶ (scsi0) Downloading sequencer code... 419 instructions downloaded       | 
∶ scsi0 : Adaptec AHA274x/284x/294x (EISA/VLB/PCI-Fast SCSI) 5.1.10/3.2.4 | 
∶        <Adaptec AIC-7880 Ultra SCSI host adapter>                       | 
∶ scsi : 1 host.                                                          | 
∶   Vendor: SEAGATE   Model: ST32155W          Rev: 0596                  | 
∶   Type:   Direct-Access                      ANSI SCSI revision: 02     | 
∶ Detected scsi disk sda at scsi0, channel 0, id 0, lun 0                 | 
∶   Vendor: SEAGATE   Model: ST32155W          Rev: 0596                  | 
∶   Type:   Direct-Access                      ANSI SCSI revision: 02     | 
∶ Detected scsi disk sdb at scsi0, channel 0, id 1, lun 0                 | 
∶ scsi : detected 2 SCSI disks total.                                     | 
∶ (scsi0:0:0:0) Synchronous at 40.0 Mbyte/sec, offset 8.                  |  
∶ SCSI device sda: hdwr sector= 512 bytes. Sectors= 4197405 [2049 MB] [2.0 GB] 
∶ (scsi0:0:1:0) Synchronous at 40.0 Mbyte/sec, offset 8. 
∶ SCSI device sdb: hdwr sector= 512 bytes. Sectors= 4197405 [2049 MB] [2.0 GB] 
∶ Partition check:                                                        | 
∶  sda: sda1                                                              |   
∶  sdb: sdb1 sdb2 < sdb5 sdb6 >                                           | 
∶ /**                                                                     | 
∶                                    <------------------------------------+ 
∶   安装 文件系统                 filesystem_setup() 
∶   安装设备驱动程序                | 
∶                               mount_root() 
∶  **/                              +------------------------------------>.. 
∶ VFS: Mounted root (ext2 filesystem) readonly.                          |  
∶                                                                        | 
∶ Freeing unused kernel memory: 28k freed                                | 
∶ Adding Swap: 66540k swap-space (priority -1)                           | 
∶ Soundblaster audio driver Copyright (C) by Hannu Savolainen 1993-1996  | 
∶ SB 3.01 detected OK (220)                                              | 
∶ <ESS ES1688 AudioDrive (rev 11) (3.01)> at 0x220 irq 5 dma 1           | 
∶ YM3812 and OPL-3 driver Copyright (C) by Hannu Savolainen, Rob Hooft 1993-1996 
∶ <Yamaha OPL3> at 0x388                                                 | 
∶ NET4: AppleTalk 0.18 for Linux NET4.0                                  +--+ 
∶ eth0: Intel EtherExpress Pro 10/100 at 0xf800, 00:A0:C9:49:2F:FF, IRQ 9.  | 
∶   Board assembly 645520-034, Physical connectors present: RJ45            | 
∶   Primary interface chip DP83840 PHY #1.                                  | 
∶   DP83840 specific setup, setting register 23 to 8462.                    | 
∶   General self-test: passed.                                              | 
∶   Serial sub-system self-test: passed.                                    |      
∶ �  Internal registers self-test: passed.                                  | 
∶   ROM checksum self-test: passed (0x49caa8d6).                            | 
∶   Receiver lock-up workaround activated.                                  | 
∶ NET4: AppleTalk 0.18 for Linux NET4.0                                     |      
∶                           <-----------------------------------------------+ 
∶ /*               结束 do_basic_setup() 
∶  *             open("/dev/console", O_RDWR, 0) 
∶  *                 开始执行 /sbin/init  ( execv(...) ) 
∶  *              内核就此启动完毕... 
∶  *          以后就他的作用就是接受消息和信号来工作. 
∶  *             ( 通过 fork 来产生新的进程 ).. 
∶  */ 
 
 
-- 
 
  舟摇摇而轻扬, 风飘飘以吹衣, 
  问征夫以前路, 恨晨光之曦微. 
 
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 202.115.6.100] 

BBS水木清华站∶精华区