1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| void cpu_initialize(unsigned int index) { /* Because we busy wait at the printk spinlock. * It is important to keep the number of printed messages * from secondary cpus to a minimum, when debugging is * disabled. */ struct device *cpu; struct cpu_info *info; struct cpuinfo_x86 c;
info = cpu_info();
printk(BIOS_INFO, "Initializing CPU #%d\n", index);
cpu = info->cpu; if (!cpu) { die("CPU: missing cpu device structure"); }
if (cpu->initialized) return;
post_log_path(cpu);
/* Find what type of cpu we are dealing with */ identify_cpu(cpu); // 获取cpu信息 printk(BIOS_DEBUG, "CPU: vendor %s device 0x%x\n", cpu_vendor_name(cpu->vendor), cpu->device);
get_fms(&c, cpu->device); // fms难道是family model stepping的意思?
/* 打印CPU family、model,例如0x06_0x37表示atom e3000系列(e3800也在其中),参考IA32手册卷3第35章表格1 */ printk(BIOS_DEBUG, "CPU: family 0x%02x, model 0x%02x, stepping 0x%02x\n", c.x86, c.x86_model, c.x86_mask); printk(BIOS_DEBUG, "DisplayFamily_DisplayModel: %02X_%02XH\n", c.x86, c.x86_model); // test msr_t platform_id = rdmsr(0x17); printk(BIOS_DEBUG, "platform_id: %x %x\n", platform_id.hi, platform_id.lo);
// my test... char processor_name[49]; /* Print processor name */ fill_processor_name1(processor_name); // 打印CPU,如qemu会打印:QEMU Virtual CPU version 2.0.0 printk(BIOS_INFO, "LLDEBUG CPU: %s.\n", processor_name);
/* Lookup the cpu's operations */ set_cpu_ops(cpu);
if(!cpu->ops) { /* mask out the stepping and try again */ cpu->device -= c.x86_mask; set_cpu_ops(cpu); // 设置操作函数 cpu->device += c.x86_mask; if(!cpu->ops) die("Unknown cpu"); printk(BIOS_DEBUG, "Using generic cpu ops (good)\n"); }
/* Initialize the cpu */ if (cpu->ops && cpu->ops->init) { cpu->enabled = 1; cpu->initialized = 1; // 已经初始化好了 cpu->ops->init(cpu); // 调用具体的init函数 如baytrail的为baytrail_init_cpus, qemu为qemu_cpu_init } post_log_clear();
printk(BIOS_INFO, "CPU #%d initialized\n", index); return; }
|