提交 5cb7877e 创建 作者: kaashoek's avatar kaashoek

use bootstrap processor as specified by MP table. typically 0, but not

guaranteed.
上级 f80873e6
...@@ -23,22 +23,24 @@ void ...@@ -23,22 +23,24 @@ void
main0(void) main0(void)
{ {
int i; int i;
int bcpu;
struct proc *p; struct proc *p;
// clear BSS // clear BSS
memset(edata, 0, end - edata); memset(edata, 0, end - edata);
// switch to bootstrap processor's stack
asm volatile("movl %0, %%esp" : : "r" (cpus[0].mpstack + MPSTACK - 32));
asm volatile("movl %0, %%ebp" : : "r" (cpus[0].mpstack + MPSTACK));
// Prevent release() from enabling interrupts. // Prevent release() from enabling interrupts.
for(i=0; i<NCPU; i++) for(i=0; i<NCPU; i++)
cpus[i].nlock = 1; cpus[i].nlock = 1;
mp_init(); // collect info about this machine mp_init(); // collect info about this machine
bcpu = mp_bcpu();
// switch to bootstrap processor's stack
asm volatile("movl %0, %%esp" : : "r" (cpus[0].mpstack + MPSTACK - 32));
asm volatile("movl %0, %%ebp" : : "r" (cpus[0].mpstack + MPSTACK));
lapic_init(mp_bcpu()); lapic_init(bcpu);
cprintf("\ncpu%d: starting xv6\n\n", cpu()); cprintf("\ncpu%d: starting xv6\n\n", cpu());
......
...@@ -191,7 +191,8 @@ mp_init(void) ...@@ -191,7 +191,8 @@ mp_init(void)
int int
mp_bcpu(void) mp_bcpu(void)
{ {
return bcpu-cpus; if (ismp) return bcpu-cpus;
else return 0;
} }
extern void mpmain(void); extern void mpmain(void);
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论