2 #include "../port/lib.h"
11 extern void _stts(void);
21 active.machs[m->machno] = 1;
33 uintptr *apbootp, *pml4, *pdp0;
40 * Initialise the AP page-tables and Mach structure.
41 * Xspanalloc will panic if an allocation can't be made.
43 p = xspanalloc(2*PTSZ + BY2PG + MACHSIZE, BY2PG, 0);
52 memset(pml4, 0, PTSZ);
53 memset(pdp0, 0, PTSZ);
54 memset(gdt, 0, BY2PG);
55 memset(mach, 0, MACHSIZE);
57 mach->machno = apic->machno;
59 mach->gdt = gdt; /* filled by mmuinit */
60 MACHP(mach->machno) = mach;
63 * map KZERO (note that we share the KZERO (and VMAP)
64 * PDP between processors.
66 pml4[PTLX(KZERO, 3)] = MACHP(0)->pml4[PTLX(KZERO, 3)];
67 pml4[PTLX(VMAP, 3)] = MACHP(0)->pml4[PTLX(VMAP, 3)];
70 pml4[0] = PADDR(pdp0) | PTEWRITE|PTEVALID;
71 pdp0[0] = *mmuwalk(pml4, KZERO, 2, 0);
74 * Tell the AP where its kernel vector and pdb are.
75 * The offsets are known in the AP bootstrap code.
77 apbootp = (uintptr*)(APBOOTSTRAP+0x08);
78 apbootp[0] = (uintptr)squidboy; /* assembler jumps here eventually */
79 apbootp[1] = (uintptr)PADDR(pml4);
80 apbootp[2] = (uintptr)apic;
81 apbootp[3] = (uintptr)mach;
82 apbootp[4] |= (uintptr)m->havenx<<11; /* EFER */
85 * Universal Startup Algorithm.
87 p = KADDR(0x467); /* warm-reset vector */
88 *p++ = PADDR(APBOOTSTRAP);
89 *p++ = PADDR(APBOOTSTRAP)>>8;
90 i = (PADDR(APBOOTSTRAP) & ~0xFFFF)/16;
91 /* code assumes i==0 */
93 print("mp: bad APBOOTSTRAP\n");
98 nvramwrite(0x0F, 0x0A); /* shutdown code: warm reset upon init ipi */
99 lapicstartap(apic, PADDR(APBOOTSTRAP));
100 for(i = 0; i < 100000; i++){
101 if(arch->fastclock == tscticks)
102 cycles(&m->tscticks); /* for ap's syncclock(); */
107 nvramwrite(0x0F, 0x00);