2 #include "../port/lib.h"
14 // iprint("Hello Squidboy\n");
33 active.machs[m->machno] = 1;
36 while(!active.thunderbirdsarego)
45 ulong *apbootp, *pdb, *pte;
53 * Initialise the AP page-tables and Mach structure. The page-tables
54 * are the same as for the bootstrap processor with the exception of
55 * the PTE for the Mach structure.
56 * Xspanalloc will panic if an allocation can't be made.
58 p = xspanalloc(4*BY2PG, BY2PG, 0);
60 memmove(pdb, mach0->pdb, BY2PG);
63 if((pte = mmuwalk(pdb, MACHADDR, 1, 0)) == nil)
65 memmove(p, KADDR(PPN(*pte)), BY2PG);
66 *pte = PADDR(p)|PTEWRITE|PTEVALID;
72 if((pte = mmuwalk(pdb, MACHADDR, 2, 0)) == nil)
74 *pte = PADDR(mach)|PTEWRITE|PTEVALID;
79 machno = apic->machno;
81 mach->machno = machno;
83 mach->gdt = (Segdesc*)p; /* filled by mmuinit */
86 * Tell the AP where its kernel vector and pdb are.
87 * The offsets are known in the AP bootstrap code.
89 apbootp = (ulong*)(APBOOTSTRAP+0x08);
90 *apbootp++ = (ulong)squidboy; /* assembler jumps here eventually */
91 *apbootp++ = PADDR(pdb);
92 *apbootp = (ulong)apic;
95 * Universal Startup Algorithm.
97 p = KADDR(0x467); /* warm-reset vector */
98 *p++ = PADDR(APBOOTSTRAP);
99 *p++ = PADDR(APBOOTSTRAP)>>8;
100 i = (PADDR(APBOOTSTRAP) & ~0xFFFF)/16;
101 /* code assumes i==0 */
103 print("mp: bad APBOOTSTRAP\n");
108 nvramwrite(0x0F, 0x0A); /* shutdown code: warm reset upon init ipi */
109 lapicstartap(apic, PADDR(APBOOTSTRAP));
110 for(i = 0; i < 1000; i++){
115 nvramwrite(0x0F, 0x00);