Chinaunix首页 | 论坛 | 博客
  • 博客访问: 498352
  • 博文数量: 224
  • 博客积分: 2175
  • 博客等级: 大尉
  • 技术积分: 2433
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-05 22:02
个人简介

目前在一家公司担任软件总监,主要涉及智能手机,笔记本电脑的开发

文章分类

全部博文(224)

文章存档

2024年(5)

2023年(68)

2022年(13)

2021年(7)

2020年(11)

2019年(3)

2018年(10)

2017年(8)

2012年(7)

2011年(4)

2010年(32)

2009年(41)

2008年(6)

2007年(9)

分类: LINUX

2007-05-23 14:28:11

GRUB :
GRUB source:    

1 BIOS stage
   当你Power On 电源后,PC会Reset所有的hardware register ,并从一个特定的地址执行代码。这个地址和硬件有关,对于IBM PC ,是0xFFFFFFF0,此时CPU在实模式下运行,CS= F000 ,IP = FFFF0 .
   BIOS ROM的地址是F0000H~FFFFFH,这个是通过硬件接线来完成的,可以参考以前的单片机地址解析。
BIOS实际上是一段存储在ROM里的程序。它包含了一系列可以被某些操作系统调用,
用于处理计算机各种硬件设备的中断驱动和低级程序。
   在FFFF0处的代码是JMP XXX , XXX为BIOS ROM启动程序的首地址。
   然后执行POST(Power On self Test),自检。包括了检查RAM,keyboard,显示
器,软硬磁盘等等,这些动作是由系统测试码(system test code)来执行的,然后初始化硬件。
    下一步根据CMOS 的设置定义的顺序来搜索处于活动状态并且可以引导的设备。也就是我们在CMOS中定义的
先从光盘启动,再从Hard Driver ,{BANNED}最佳后Floppy 等等。
    如果是从硬盘启动,那么它将load MBR(位于磁盘的{BANNED}中国第一个扇区,0磁头0磁道1扇区,大小512字节)。将它装载
在内存地址0000:7c00处。
     检查(WORD)0000:7dfe是否等于0xaa55.若不等于则转去尝试其他介质;如果没有其他启动介质,
则显示 “No ROM BASIC” ,然后死机。
2 MBR
 BIOS Stage后,将JMP 0000:7C00执行程序,也就是MBR程序,MBR分为两部分,{BANNED}中国第一部分446字节,
主boot loader,它里面就包含有可执行代码以及错误消息文本,第2部分64字节,分区表,其中包含
有四个分区的各自的记录(一个分区占16字节),分别为分区类型(1),分区的开始地址(3字节,面/扇区/道),
分区的操作系统类型(1字节),分区的end address(3 bytes),分区的start logic 扇区(4 bytes)以及
该分区占用的总扇区数(4 bytes)。{BANNED}最佳后2个字节为结束标记,0xAA55 (magic number in electronic ??)
  The main boot loader parst the DPT and find the active partition and assure the other partition are not
active . Then the boot record will load into RAM from the active partition .
  如果用Grub,它的stage1即为MBR.
3 stage1.5
在/boot/grub/目录中,可以看到很多stage1.5,其中e2fs_stage1_5为ext2 file system ,因为stage1不能识别File
System ,所以其他的stage1.5认识某个File System ,他们的位置紧接MBR之后.
 通过stage1.5 , 将stage2装载
4 stage 2
   它是Grub的核心,根据/boot/grub/grub.conf读入菜单,实现多操作系统的启动.加载linux 内核
5  setup()
 在 /usr/src/linux-2.4.2/arch/i386/boot/setup.S。链接程序把setup()函数代码紧跟在内核中所集成的引导装入程序之后,
位置为0x00090200,它以自己的方式初始化设备,为了可移植和健壮性。
 change from real mode to protected mode .
jmp startup_32()
6 startup_32()
  it will call decompress_kernel() to decompress the kernel image .then jmp to 0x100000
(zImage(<512KB) or bzImage (>512KB))
 the secode startup32() will call start_kernel()
7 start_Kernel()
    it will call kernel_thread(init, NULL, CLONE_KERNEL); and then init() function will call
execve("/sbin/init",argv_init,envp_init);将/sbin/init启动起来,并永远不退出。也就是execve不返回。
8 /sbin/init process
   PID 为1 ,并永远不会结束。
 读取 /etc/inittab ,设置键盘、字体, 装载模块,设置网络,它可以配置runlevel , 5为x window
模式。
  在/etc/inittab中,执行/etc/rc.d/rc.sysinit ,读入 /etc/sysconfig/clock 配置文件来初始化硬件时钟。
如果有必须初始化的特殊串口进程,rc.sysinit 会执行 /etc/rc.serial 脚本. 并 装入模块。
  From the runlevel defined in /etc/inittab, the init process will read the scripts in etc/rc.d/rcx.d。These scripts are the link symbols which are stored in /etc/rc.d/init.d . You can use command ls -l to see the link symbols .We can find
init.d/gpm --mouse
init.d/xinetd -- internet, xinetd will use the configure file /etc/xinetd.conf which includes /etc/xinetd.d directory .
运行模式2、3、5都把/etc/rc.d/rc.local做为初始化脚本中的{BANNED}最佳后一个,用户可以自己在这个文件中添加一些需要在其他初始化工作之后,
9  According to the runlevel ,/sbin/mingetty ttyx will run , 执行  /bin/login 程式  ,user  输入账号及密码, 如果密码正确,执行/etc/passwd所对应的程序
10   At the end of /etc/inittab , you will find x:5:respawn:/etc/x11/prefdm . it will run the prefered windows manager .
11 over
阅读(1207) | 评论(0) | 转发(0) |
0

上一篇: 别小瞧了LCD驱动

下一篇:我看SQA的失败

给主人留下些什么吧!~~