-
-
Save naoki9911/fa0c45ba07143838c5fde7b08bb118ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void | |
mpinit(void) | |
{ | |
uchar *p, *e; | |
int ismp; | |
struct mp *mp; | |
struct mpconf *conf; | |
struct mpproc *proc; | |
struct mpioapic *ioapic; | |
if((conf = mpconfig(&mp)) == 0) | |
panic("Expect to run on an SMP"); | |
ismp = 1; | |
lapic = (uint*)conf->lapicaddr; | |
for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ | |
switch(*p){ | |
case MPPROC: | |
proc = (struct mpproc*)p; | |
if(ncpu < NCPU) { | |
cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu | |
ncpu++; | |
} | |
p += sizeof(struct mpproc); | |
continue; | |
case MPIOAPIC: | |
ioapic = (struct mpioapic*)p; | |
ioapicid = ioapic->apicno; | |
p += sizeof(struct mpioapic); | |
continue; | |
case MPBUS: | |
case MPIOINTR: | |
case MPLINTR: | |
p += 8; | |
continue; | |
default: | |
ismp = 0; | |
break; | |
} | |
} | |
if(!ismp) | |
panic("Didn't find a suitable machine"); | |
if(mp->imcrp){ | |
// Bochs doesn't support IMCR, so this doesn't run on Bochs. | |
// But it would on real hardware. | |
outb(0x22, 0x70); // Select IMCR | |
outb(0x23, inb(0x23) | 1); // Mask external interrupts. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment