This commit is contained in:
rsc 2007-08-27 16:12:08 +00:00
parent 3ce1647078
commit da94233784

30
mp.c
View file

@ -72,8 +72,7 @@ mp_search(void)
if((p = (bda[0x0F]<<8)|bda[0x0E])){ if((p = (bda[0x0F]<<8)|bda[0x0E])){
if((mp = mp_scan((uchar*) p, 1024))) if((mp = mp_scan((uchar*) p, 1024)))
return mp; return mp;
} }else{
else{
p = ((bda[0x14]<<8)|bda[0x13])*1024; p = ((bda[0x14]<<8)|bda[0x13])*1024;
if((mp = mp_scan((uchar*)p-1024, 1024))) if((mp = mp_scan((uchar*)p-1024, 1024)))
return mp; return mp;
@ -94,19 +93,20 @@ mp_detect(void)
uint length; uint length;
if((mp = mp_search()) == 0 || mp->physaddr == 0) if((mp = mp_search()) == 0 || mp->physaddr == 0)
return 1; return -1;
pcmp = (struct mpctb*) mp->physaddr; pcmp = (struct mpctb*) mp->physaddr;
if(memcmp(pcmp, "PCMP", 4)) if(memcmp(pcmp, "PCMP", 4) != 0)
return 2; return -1;
if(pcmp->version != 1 && pcmp->version != 4)
return -1;
length = pcmp->length; length = pcmp->length;
sum = 0; sum = 0;
for(p = (uchar*)pcmp; length; length--) for(p = (uchar*)pcmp; length; length--)
sum += *p++; sum += *p++;
if(sum != 0)
if(sum || (pcmp->version != 1 && pcmp->version != 4)) return -1;
return 3;
return 0; return 0;
} }
@ -114,20 +114,17 @@ mp_detect(void)
void void
mp_init(void) mp_init(void)
{ {
int r; int i, r;
uchar *p, *e; uchar *p, *e;
struct mpctb *mpctb; struct mpctb *mpctb;
struct mppe *proc; struct mppe *proc;
struct mpbe *bus; struct mpbe *bus;
struct mpioapic *ioapic; struct mpioapic *ioapic;
struct mpie *intr; struct mpie *intr;
int i;
uchar byte;
ncpu = 0; ncpu = 0;
if((r = mp_detect()) != 0) { if(mp_detect() < 0)
return; return;
}
ismp = 1; ismp = 1;
@ -179,11 +176,10 @@ mp_init(void)
} }
if(mp->imcrp) { if(mp->imcrp) {
// It appears that Bochs doesn't support IMCR, so code won't run. // Bochs doesn't support IMCR, so this doesn't run on Bochs.
// But it would on real hardware.
outb(0x22, 0x70); // Select IMCR outb(0x22, 0x70); // Select IMCR
byte = inb(0x23); // Current contents outb(0x23, inb(0x23) | 1); // Mask external interrupts.
byte |= 0x01; // Mask external INTR
outb(0x23, byte); // Disconnect 8259s/NMI
} }
} }