Newer
Older
#include "param.h"
#include "mmu.h"
#include "proc.h"
#include "x86.h"
static void mpmain(void) __attribute__((noreturn));
// pushcli() every processor during bootstrap.
cpus[i].ncli = 1; // no interrupts during bootstrap
bcpu = mp_bcpu();
lapic_init(bcpu);
pinit(); // process table
binit(); // buffer cache
pic_init(); // interrupt controller
ioapic_init(); // another interrupt controller
kinit(); // physical memory allocator
tvinit(); // trap vectors
fileinit(); // file table
iinit(); // inode cache
console_init(); // I/O devices & their interrupts
ide_init(); // disk
// Allocate scheduler stacks and boot the other CPUs.
cpus[i].stack = kalloc(KSTACKSIZE);
bootothers();
// Switch to our scheduler stack and continue with mpmain.
asm volatile("movl %0, %%esp" : : "r" (cpus[bcpu].stack+KSTACKSIZE));
cpuid(0, 0, 0, 0, 0); // memory barrier
bootothers(void)
{
extern uchar _binary_bootother_start[], _binary_bootother_size[];
uchar *code;
struct cpu *c;
// Write bootstrap code to unused memory at 0x7000.
code = (uchar*)0x7000;
memmove(code, _binary_bootother_start, (uint)_binary_bootother_size);
for(c = cpus; c < cpus+ncpu; c++){
if(c == cpus+cpu()) // We've started already.
continue;