use bootstrap processor as specified by MP table. typically 0, but not
guaranteed.
This commit is contained in:
parent
f80873e602
commit
5cb7877e0f
2 changed files with 9 additions and 6 deletions
12
main.c
12
main.c
|
@ -23,22 +23,24 @@ void
|
|||
main0(void)
|
||||
{
|
||||
int i;
|
||||
int bcpu;
|
||||
struct proc *p;
|
||||
|
||||
// clear BSS
|
||||
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.
|
||||
for(i=0; i<NCPU; i++)
|
||||
cpus[i].nlock = 1;
|
||||
|
||||
mp_init(); // collect info about this machine
|
||||
bcpu = mp_bcpu();
|
||||
|
||||
lapic_init(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(bcpu);
|
||||
|
||||
cprintf("\ncpu%d: starting xv6\n\n", cpu());
|
||||
|
||||
|
|
3
mp.c
3
mp.c
|
@ -191,7 +191,8 @@ mp_init(void)
|
|||
int
|
||||
mp_bcpu(void)
|
||||
{
|
||||
return bcpu-cpus;
|
||||
if (ismp) return bcpu-cpus;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
extern void mpmain(void);
|
||||
|
|
Loading…
Reference in a new issue