2 #include "../port/lib.h"
14 // iprint("Hello Squidboy\n");
20 active.machs[m->machno] = 1;
32 ulong *apbootp, *pdb, *pte;
40 * Initialise the AP page-tables and Mach structure. The page-tables
41 * are the same as for the bootstrap processor with the exception of
42 * the PTE for the Mach structure.
43 * Xspanalloc will panic if an allocation can't be made.
45 p = xspanalloc(4*BY2PG, BY2PG, 0);
47 memmove(pdb, mach0->pdb, BY2PG);
50 if((pte = mmuwalk(pdb, MACHADDR, 1, 0)) == nil)
52 memmove(p, KADDR(PPN(*pte)), BY2PG);
53 *pte = PADDR(p)|PTEWRITE|PTEVALID;
59 if((pte = mmuwalk(pdb, MACHADDR, 2, 0)) == nil)
61 *pte = PADDR(mach)|PTEWRITE|PTEVALID;
66 machno = apic->machno;
68 mach->machno = machno;
70 mach->gdt = (Segdesc*)p; /* filled by mmuinit */
73 * Tell the AP where its kernel vector and pdb are.
74 * The offsets are known in the AP bootstrap code.
76 apbootp = (ulong*)(APBOOTSTRAP+0x08);
77 *apbootp++ = (ulong)squidboy; /* assembler jumps here eventually */
78 *apbootp++ = PADDR(pdb);
79 *apbootp = (ulong)apic;
82 * Universal Startup Algorithm.
84 p = KADDR(0x467); /* warm-reset vector */
85 *p++ = PADDR(APBOOTSTRAP);
86 *p++ = PADDR(APBOOTSTRAP)>>8;
87 i = (PADDR(APBOOTSTRAP) & ~0xFFFF)/16;
88 /* code assumes i==0 */
90 print("mp: bad APBOOTSTRAP\n");
95 nvramwrite(0x0F, 0x0A); /* shutdown code: warm reset upon init ipi */
96 lapicstartap(apic, PADDR(APBOOTSTRAP));
97 for(i = 0; i < 100000; i++){
98 if(arch->fastclock == tscticks)
99 cycles(&m->tscticks); /* for ap's syncclock(); */
104 nvramwrite(0x0F, 0x00);