grub 0.97 浅析
来源:互联网 发布:中美俄在世界地位知乎 编辑:程序博客网 时间:2024/05/16 06:40
说明:
grub分为stage1、stage1.5、stage2三部分,其中stage1.5是可选的。
stage1/stage1.S:被编译成stage1,位于0号扇区(逻辑扇区号),即MBR。
stage1的作用是将1号扇区的start载入到内存0x0000:0x8000处,然后跳到0x0000:0x8000处执行。
stage2/start.S:被编译成start,位于1号扇区,被stage1载入到0x0000:0x8000并跳转执行。
stage2/start.S的作用分两种情况。
I.若定义了STAGE1_5,则它加载stage1_5(2~N号扇区)到内存0x0000:0x2200,并跳到0x0000:0x2200执行。
II.若未定义STAGE1_5,则它加载stage2 (2~N号扇区)到内存0x0000:0x8200,并跳到0x0000:0x8200执行。
stage2/asm.S,由start跳入执行。
stage2/asm.S的作用是:
装载gdt,切换到保护模式,调用函数init_bios_info(至此,代码从汇编转换到C)。
init_bios_info取得内存和磁盘相关的信息之后,调用cmain。
cmain即stage1.5和stage2的分叉点,源代码中有两个cmain函数,对应stage1.5和stage2的实现。
说明:
1. stage2/start.S编译出的512bytes的start会添在stage1.5或者stage2的头部,作为其的一部分。
2. grub中最重要的数据结构:struct builtin;
grub中的每一个命令都是一个builtin结构。
struct builtin
{
/* The command name. */
char *name;
/* The callback function. */
int (*func) (char *, int);
/* The combination of the flags defined above. */
int flags;
/* The short version of the documentation. */
char *short_doc;
/* The long version of the documentation. */
char *long_doc;
};
{
/* The command name. */
char *name;
/* The callback function. */
int (*func) (char *, int);
/* The combination of the flags defined above. */
int flags;
/* The short version of the documentation. */
char *short_doc;
/* The long version of the documentation. */
char *long_doc;
};
name为命令名称。
func为命令执行的功能函数。
flags为命令的一些属性,比如有些命令只在控制台中(grub>)使用,有些命令只在菜单中使用。
short_doc和long_doc是此命令的一些说明。
- grub 0.97 浅析
- GRUB 0.97
- grub 0.97
- Grub 0.97安装 / 安装老版本Grub
- 制作grub 0.97启动盘
- fedora20编译grub-0.97
- MBR及linux下grub执行原理浅析
- grub
- grub
- grub
- GRUB
- grub
- grub
- grub
- grub
- grub
- GRUB
- grub
- 移动应用开发部,实施敏捷开发3个月后的一些经验和教训。
- 项目经理修炼路
- Android 安全机制
- 技术人员如何创业《二》—— 合伙人的模式
- Erlang四个BIF来操纵注册进程的名字
- grub 0.97 浅析
- 博客之开始旅程
- 技术人员如何创业《三》—— 合伙人的分工
- mfc 导出数据保存成excel和txt格式
- extjs的本地化方法
- YAF框架配置及 windows、linux本地域名配置
- 技术人员如何创业《四》—— 打造超强执行力团队
- Oracle数据库视图
- wap测试中用IE和Chrome打开时下载的问题