Newer
Older
#include "types.h"
#include "mp.h"
#include "defs.h"
#include "param.h"
#include "x86.h"
#include "mmu.h"
"CBUSI ",
"CBUSII",
"EISA ",
"FUTURE",
"INTERN",
"ISA ",
"MBI ",
"MBII ",
"MCA ",
"MPI ",
"MPSA ",
"NUBUS ",
"PCI ",
"PCMCIA",
"TC ",
"VL ",
"VME ",
"XPRESS",
0,
static struct cpu *bcpu;
static struct mp* mp; // The MP floating point structure
for(p = addr; p < e; p += sizeof(struct mp)){
if(memcmp(p, "_MP_", 4))
continue;
sum = 0;
for(i = 0; i < sizeof(struct mp); i++)
/*
* Search for the MP Floating Pointer Structure, which according to the
* spec is in one of the following three locations:
* 1) in the first KB of the EBDA;
* 2) in the last KB of system base memory;
* 3) in the BIOS ROM between 0xE0000 and 0xFFFFF.
*/
return mp;
}
else{
p = ((bda[0x14]<<8)|bda[0x13])*1024;
}
static int
mp_detect(void)
{
/*
* Search for an MP configuration table. For now,
* don't accept the default configurations (physaddr == 0).
* Check for correct signature, calculate the checksum and,
* if correct, check the version.
* To do: check extended table checksum.
*/
if((mp = mp_search()) == 0 || mp->physaddr == 0)
pcmp = (struct mpctb *) mp->physaddr;
if(memcmp(pcmp, "PCMP", 4))
return 2;
length = pcmp->length;
sum = 0;
sum += *p++;
if(sum || (pcmp->version != 1 && pcmp->version != 4))
return 3;
return 0;
}
void
struct mpctb *mpctb;
struct mppe *proc;
struct mpbe *bus;
struct mpioapic *ioapic;
struct mpie *intr;
ncpu = 0;
if ((r = mp_detect()) != 0) return;
/*
* Run through the table saving information needed for starting
* application processors and initialising any I/O APICs. The table
* is guaranteed to be in order such that only one pass is necessary.
*/
mpctb = (struct mpctb *) mp->physaddr;
lapicaddr = (uint *) mpctb->lapicaddr;
p = ((uchar*)mpctb)+sizeof(struct mpctb);
e = ((uchar*)mpctb)+mpctb->length;
case MPPROCESSOR:
if (proc->flags & MPBP) {
}
case MPBUS:
if(strncmp(buses[i], bus->string, sizeof(bus->string)) == 0)
break;
case MPIOAPIC:
ioapic = (struct mpioapic *) p;
ioapic_id = ioapic->apicno;
case MPIOINTR:
continue;
default:
cprintf("mpinit: unknown PCMP type 0x%x (e-p 0x%x)\n", *p, e-p);
while(p < e){
if (mp->imcrp) { // it appears that bochs doesn't support IMCR, and code won't run
outb(0x22, 0x70); /* select IMCR */
byte = inb(0x23); /* current contents */
byte |= 0x01; /* mask external INTR */
outb(0x23, byte); /* disconnect 8259s/NMI */
int
mp_bcpu(void)
{
return bcpu-cpus;
}
#define APBOOTCODE 0x7000 // XXX hack
extern uchar _binary_bootother_start[], _binary_bootother_size[];
memmove((void *) APBOOTCODE,_binary_bootother_start,
*(uint *)(APBOOTCODE-4) = (uint) (cpus[c].mpstack) + MPSTACK; // tell it what to use for %esp
*(uint *)(APBOOTCODE-8) = (uint)mpmain; // tell it where to jump to
}