操作系统的引导与启动程序

本文详细介绍了Linux操作系统的引导过程,从BIOS加载bootsect.s开始,到硬件初始化、参数设置,再到setup.s和head.s的角色,以及在main.c中进行的初始运行操作,特别是对高速缓冲区的概念进行了阐述。
摘要由CSDN通过智能技术生成

1.linux操作系统的引导

linux引导的三个文件:bootsect.s=>

1.1 linux是如何从硬盘中读出的

BIOS/Bootloader:
linux上电之后,就是设备打开电源之后,CPU会进入BIOS模式,
自动的从某个地址(一般为0xFFFF0)开始执行BIOS程序,
BIOS程序会把bootsect.s从某个固定地址(磁盘:0磁道0磁头1扇区)拿到内存中的某个固定地址(0.11版本是拿到0x7c00),
并进行一系列的硬件初始化和参数设置。
bootsect.s

bootsect.s是磁盘引导块程序,在磁盘的第一个扇区中的程序(磁盘:0磁道0磁头1扇区)。
作用:
    把自己从0x7c00移到0x90000的地址;
    将后续的setup.s代码从磁盘中加载到紧接着bootsect.s的地址;
    在显示屏上显示loading system;
    再将system(操作系统)模块加载到0x10000的地方;
    最后跳转到setup.s中运行
 SYS_SIZE is the number of clicks (16 bytes) to be loaded.
 0x3000 is 0x30000 bytes = 196kB, more than enough for current
 versions of linux

SYSSIZE = 0x3000

	bootsect.s		(C) 1991 Linus Torvalds

 bootsect.s is loaded at 0x7c00 by the bios-startup routines, and moves iself out of the way to address 0x90000, and jumps there.

 It then loads 'setup' directly after itself (0x90200), and the system at 0x10000, using BIOS interrupts. 

 NOTE! currently system is at most 8*65536 bytes long. This should be no problem, even in the future. I want to keep it simple. This 512 kB
 kernel size should be enough, especially as this doesn't contain the
 buffer cache as in minix

 The loader has been made as simple as possible, and continuos
 read errors will result in a unbreakable loop. Reboot by hand. It
 loads pretty fast by getting whole sectors at a time whenever possible.

1.2 linux在启动的时候如何拿到硬件参数的

setup.s

 解析BIOS/BOOTLOADER传递来的参数;
 设置系统内核运行的LDT(局部描述符,包含代码段和数据段)IDT(中断描述符寄存器) 全局描述符;
 设置中断控制芯片,进入保护模式运行(svc32保护模式);
 跳转到system模块的最前面的代码(head.s)运行;

head.s

加载内核运行时各数据段寄存器,重新设置中断描述符表;
开启内核正常运行时的协处理器等资源;
设置内存管理的分页机制;
跳转到main.c开始运行;

1.3 linux在初始运行中都做了什么

		trap.c trap_init()    //中断
		mktime.c time_init()   //时间
		sched.c sched_init()   //进程

main.c

void main
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值