2 #include "../port/lib.h"
11 extern void checkmtrr(void);
30 active.machs |= 1<<m->machno;
33 while(!active.thunderbirdsarego)
42 uintptr *apbootp, *pml4, *pdp0;
49 * Initialise the AP page-tables and Mach structure.
50 * Xspanalloc will panic if an allocation can't be made.
52 p = xspanalloc(2*PTSZ + BY2PG + MACHSIZE, BY2PG, 0);
61 memset(pml4, 0, PTSZ);
62 memset(pdp0, 0, PTSZ);
63 memset(gdt, 0, BY2PG);
64 memset(mach, 0, MACHSIZE);
66 mach->machno = apic->machno;
68 mach->gdt = gdt; /* filled by mmuinit */
69 MACHP(mach->machno) = mach;
72 * map KZERO (note that we share the KZERO (and VMAP)
73 * PDP between processors.
75 pml4[PTLX(KZERO, 3)] = MACHP(0)->pml4[PTLX(KZERO, 3)];
78 pml4[0] = PADDR(pdp0) | PTEWRITE|PTEVALID;
79 pdp0[0] = *mmuwalk(pml4, KZERO, 2, 0);
82 * Tell the AP where its kernel vector and pdb are.
83 * The offsets are known in the AP bootstrap code.
85 apbootp = (uintptr*)(APBOOTSTRAP+0x08);
86 apbootp[0] = (uintptr)squidboy; /* assembler jumps here eventually */
87 apbootp[1] = (uintptr)PADDR(pml4);
88 apbootp[2] = (uintptr)apic;
89 apbootp[3] = (uintptr)mach;
92 * Universal Startup Algorithm.
94 p = KADDR(0x467); /* warm-reset vector */
95 *p++ = PADDR(APBOOTSTRAP);
96 *p++ = PADDR(APBOOTSTRAP)>>8;
97 i = (PADDR(APBOOTSTRAP) & ~0xFFFF)/16;
98 /* code assumes i==0 */
100 print("mp: bad APBOOTSTRAP\n");
105 nvramwrite(0x0F, 0x0A); /* shutdown code: warm reset upon init ipi */
106 lapicstartap(apic, PADDR(APBOOTSTRAP));
107 for(i = 0; i < 1000; i++){
112 nvramwrite(0x0F, 0x00);