fix up reboot code so we can at least get to the point where we need to set up page tables, etc. work in progress Reference: /n/atom/patch/applied2013/rebootshut Date: Sun Dec 29 16:29:33 CET 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/nix/k10/main.c Sun Dec 29 16:29:05 2013 +++ /sys/src/nix/k10/main.c Sun Dec 29 16:29:05 2013 @@ -53,9 +53,8 @@ m->machno, machcolor(m), m->rdtsc); /* - * Enable the timer interrupt. + * enable interrupts. */ -// apictimerenab(); lapicpri(0); timersinit(); @@ -348,7 +347,7 @@ { int ms, once; - lock(&active); + ilock(&active); if(ispanic) active.ispanic = ispanic; else if(m->machno == 0 && m->online == 0) @@ -357,7 +356,7 @@ m->online = 0; adec(&active.nonline); active.exiting = 1; - unlock(&active); + iunlock(&active); if(once) iprint("cpu%d: exiting\n", m->machno); @@ -389,10 +388,8 @@ procwired(up, i); sched(); splhi(); - lapicpri(0xff); adec(&active.nonline); - for(;;) - hardhalt(); + ndnr(); } #include "amd64.h" @@ -400,35 +397,38 @@ reboot(void *entry, void *code, usize size) { int i; + uintptr a; void (*f)(uintmem, uintmem, usize); - panic("reboot"); +// writeconf(); procwired(up, 0); sched(); - for(i = 0; i < active.nonline; i++) + for(i = 1; i < active.nonline; i++) kproc("apshut", apshut, (void*)i); - while(active.nonline>1) - pause(); - - /* turn off buffered serial console? */ + while((a=active.nonline)>1) + monmwait(&active.nonline, a); + synccons(); devtabshutdown(); pcireset(); + splhi(); lapicpri(0xff); - outb(0x21, 0xff); - outb(0xa1, 0xff); + outb(0x21, 0xff); /* 8259 pic 0: mask irqs */ + outb(0xa1, 0xff); /* 8259 pic 1: mask irqs */ + up = nil; + m->proc = nil; + /* flush mmu */ -// m->pdp[0] = 0 | PtePS | PteP | PteRW; - m->pml4[0] = m->pml4[PTLX(KZERO, 3)]; - putcr3(PADDR(m->pml4)); +// m->mmuptp[0] = 0 | PtePS | PteP | PteRW; +// m->pml4[0] = m->pml4[PTLX(KZERO, 3)]; + putcr3(m->pml4->pa); // f = (void*)REBOOTADDR; // memmove(f, rebootcode, sizeof(rebootcode)); f = (void*)0; - coherence(); (*f)(PADDR(entry), PADDR(code), size); } --- /sys/src/nix/k10/apic.h Sun Dec 29 16:29:05 2013 +++ /sys/src/nix/k10/apic.h Sun Dec 29 16:29:05 2013 @@ -81,7 +81,6 @@ Im = 0x00010000, /* Interrupt Mask */ }; -void apictimerenab(void); int gsitoapicid(int, uint*); void ioapicdump(void); Apic* ioapicinit(int, int, uintmem);