+ -
当前位置:首页 → 问答吧 → 读grub的诸多疑惑,请指教!

读grub的诸多疑惑,请指教!

时间:2010-08-01

来源:互联网

本帖最后由 liujunwei1234 于 2010-08-01 16:26 编辑

小弟刚学linux,近来在读grub-0.97的代码,首先就碰到了与BPB相关的疑惑,在stage1.S中要对BPB进行初始化,看下面的代码:
/*BPB 数据结构的初始化*/
lba_mode:
        /* save the total number of sectors */
        movl        0x10(%si), %ecx       /* 1 这是什么意思 %si开始指向哪?*/
        /* set %si to the disk address packet */
        movw        $ABS(disk_address_packet), %si

        /* set the mode to non-zero */
        movb        $1, -1(%si)   
       
        movl        ABS(stage2_sector), %ebx

        /* the size and the reserved byte */
        movw        $0x0010, (%si)           

        /* the blocks */
        movw        $1, 2(%si)                /*2  赋值为1是什么意思?*/       
        /* the absolute address (low 32 bits) */
        movl        %ebx, 8(%si)  

        /* the segment of buffer address */
        movw        $STAGE1_BUFFERSEG, 6(%si)    /*3  6(%si)这个位置代表什么意思?*/
        xorl        %eax, %eax
        movw        %ax, 4(%si)  /* 0磁头*/
        movl        %eax, 12(%si)     /* 0柱面*/


对于上面的代码,就是不知道为什么要这么做,每个位置代表什么意思,以及为什么要赋这样的初值。
我也看到网上有很多关于BPB的讲解,什么与磁盘格式化相关啊,FAT之类的,但是都好像和grub中的上面的代码不想关,恳请各位大侠能给详细讲解一下啊!

问题2:
#ifdef STAGE1_5
# define ABS(x) (x-_start+0x2000)
#else
# define ABS(x) (x-_start+0x8000)
#endif /* STAGE1_5 */
在start.S的开始定义两个宏, 这里的意思应该是如果定义了 STAGE1_5,那么start.S应该在加载到0x2000的内存地址中才对。但是,在stage1.S中并没有找到把start.S加载到0x2000这个地址的代码?

作者: liujunwei1234   发布时间: 2010-08-01

怎么没人回答我阿,

作者: liujunwei1234   发布时间: 2010-08-02

热门下载

更多