_nosay 发表于 2016-03-31 21:55

回复 20# nswcfd

不懂,你搞懂了告诉我 {:qq13:} 。

_nosay 发表于 2016-04-01 10:34

本帖最后由 _nosay 于 2016-04-01 11:05 编辑

回复 4# nswcfd

还发现了一点“r_base = .”与“r_here:”的区别,r_base类似“局部标号”,fun1()、fun2()都可以有“r_base = .”,页r_here类似“全局标号”,fun1()、fun2()如果都有“r_here:”,编译会报错,说r_here重复定义。

BP负责将trampoline.S(trampoline_data标号处)的代码设置到一个中断向量上,用于AP在处理IPI中断时过渡到保护模式,BP自己好像不执行这段代码,那BP是怎么过渡到保护模式的?void __init smp_boot_cpus(void)
{
        ...

        for (apicid = 0; apicid < NR_CPUS; apicid++) {
                /*
               * Don't even attempt to start the boot CPU!
               */
                if (apicid == boot_cpu_id)// 引导CPU跳过
                        continue;

                if (!(phys_cpu_present_map & (1 << apicid)))
                        continue;
                if ((max_cpus >= 0) && (max_cpus <= cpucount+1))
                        continue;

                do_boot_cpu(apicid);// 这里面会执行trampoline.S代码

                /*
               * Make sure we unmap all failed CPUs
               */
                if ((x86_apicid_to_cpu == -1) &&
                                (phys_cpu_present_map & (1 << apicid)))
                        printk("phys CPU #%d not responding - cannot use it.\n",apicid);
        }

        ...
}setup.S里面发现:start:
        jmp        trampoline

...

trampoline:        call        start_of_setup
...

start_of_setup:
# 一大堆代码,看不懂

_nosay 发表于 2016-04-01 13:18

本帖最后由 _nosay 于 2016-04-06 17:16 编辑

bootsect.S、setup.S、head.S概要:
http://blog.csdn.net/xljiulong/article/details/7385842
http://www.xuebuyuan.com/zh-tw/1334790.html

SMP boot:
http://tldp.org/HOWTO/Linux-i386-Boot-Code-HOWTO/smpboot.html

bootsect.S注释:
http://www.educity.cn/linux/1610794.html

setup.S注释:
http://blog.csdn.net/yuan1125/article/details/5580316

head.S分析:
《Linux内核源代码情景分析》

nswcfd 发表于 2016-04-01 17:51

回复 22# _nosay
bp这时候应该已经在保护模式下了吧(都已经是c代码了)

symbol赋值不是“局部”,是后面的覆盖前面的,只对应一个符号。

重复出现的label:对应多个(同名)符号,所以最后会有符号冲突。
as里面有局部符号(local symbol)的概念(可以重复出现),像常见的1f,2b就是这样的例子。

详情可以参考 info as Symbols


   

_nosay 发表于 2016-07-12 15:54

BIOS/uboot(bootloader)
MBR(分区信息)->引导扇区(下一步"对象")
LILO/GRUB->setup
zImage/bzImage(kernel)
页: 1 2 [3]
查看完整版本: trampoline.S代码疑问?