2 #include "../port/lib.h"
27 active.machs |= 1<<m->machno;
30 while(!active.thunderbirdsarego)
39 uintptr *apbootp, *pml4, *pdp0;
46 * Initialise the AP page-tables and Mach structure.
47 * Xspanalloc will panic if an allocation can't be made.
49 p = xspanalloc(2*PTSZ + BY2PG + MACHSIZE, BY2PG, 0);
58 memset(pml4, 0, PTSZ);
59 memset(pdp0, 0, PTSZ);
60 memset(gdt, 0, BY2PG);
61 memset(mach, 0, MACHSIZE);
63 mach->machno = apic->machno;
65 mach->gdt = gdt; /* filled by mmuinit */
66 MACHP(mach->machno) = mach;
69 * map KZERO (note that we share the KZERO (and VMAP)
70 * PDP between processors.
72 pml4[PTLX(KZERO, 3)] = MACHP(0)->pml4[PTLX(KZERO, 3)];
73 pml4[PTLX(VMAP, 3)] = MACHP(0)->pml4[PTLX(VMAP, 3)];
76 pml4[0] = PADDR(pdp0) | PTEWRITE|PTEVALID;
77 pdp0[0] = *mmuwalk(pml4, KZERO, 2, 0);
80 * Tell the AP where its kernel vector and pdb are.
81 * The offsets are known in the AP bootstrap code.
83 apbootp = (uintptr*)(APBOOTSTRAP+0x08);
84 apbootp[0] = (uintptr)squidboy; /* assembler jumps here eventually */
85 apbootp[1] = (uintptr)PADDR(pml4);
86 apbootp[2] = (uintptr)apic;
87 apbootp[3] = (uintptr)mach;
90 * Universal Startup Algorithm.
92 p = KADDR(0x467); /* warm-reset vector */
93 *p++ = PADDR(APBOOTSTRAP);
94 *p++ = PADDR(APBOOTSTRAP)>>8;
95 i = (PADDR(APBOOTSTRAP) & ~0xFFFF)/16;
96 /* code assumes i==0 */
98 print("mp: bad APBOOTSTRAP\n");
103 nvramwrite(0x0F, 0x0A); /* shutdown code: warm reset upon init ipi */
104 lapicstartap(apic, PADDR(APBOOTSTRAP));
105 for(i = 0; i < 1000; i++){
110 nvramwrite(0x0F, 0x00);