void reboot(void *entry, void *code, ulong size) { void (*f)(ulong, ulong, ulong); ulong *pdb; writeconf(); /* * the boot processor is cpu0. execute this function on it * so that the new kernel has the same cpu0. this only matters * because the hardware has a notion of which processor was the * boot processor and we look at it at start up. */ if (m->machno != 0) { procwired(up, 0); sched(); } shutdown(0); /* * should be the only processor running now */ if (m->machno != 0) print("on cpu%d (not 0)!\n", m->machno); if (active.machs) print("still have active ap processors!\n"); print("shutting down...\n"); delay(200); splhi(); /* turn off buffered serial console */ serialoq = nil; /* shutdown devices */ chandevshutdown(); arch->introff(); /* * Modify the machine page table to directly map the low 4MB of memory * This allows the reboot code to turn off the page mapping */ pdb = m->pdb; pdb[PDX(0)] = pdb[PDX(KZERO)]; mmuflushtlb(PADDR(pdb)); /* setup reboot trampoline function */ f = (void*)REBOOTADDR; memmove(f, rebootcode, sizeof(rebootcode)); print("rebooting...\n"); /* off we go - never to return */ coherence(); (*f)(PADDR(entry), PADDR(code), size); }
void exit(int ispanic) { USED(ispanic); spllo(); print("cpu exiting\n"); /* Shutdown running devices */ chandevshutdown(); microdelay(500); systemreset(); }
/* from ../pc: */ void reboot(void *entry, void *code, ulong size) { // writeconf(); // pass kernel environment to next kernel shutdown(0); /* * should be the only processor running now */ print("shutting down...\n"); delay(200); splhi(); /* turn off buffered serial console */ serialoq = nil; /* shutdown devices */ chandevshutdown(); #ifdef FUTURE { ulong *pdb; /* * Modify the machine page table to directly map the low 4MB of memory * This allows the reboot code to turn off the page mapping */ pdb = m->pdb; pdb[PDX(0)] = pdb[PDX(KZERO)]; mmuflushtlb(PADDR(pdb)); } /* setup reboot trampoline function */ { void (*f)(ulong, ulong, ulong) = (void*)REBOOTADDR; memmove(f, rebootcode, sizeof(rebootcode)); #else USED(entry, code, size); #endif print("rebooting...\n"); #ifdef FUTURE /* off we go - never to return */ (*f)(PADDR(entry), PADDR(code), size); } #endif setupboot(0); // reboot, don't halt exit(0); }
/* * the new kernel is already loaded at address `code' * of size `size' and entry point `entry'. */ void reboot(void *entry, void *code, ulong size) { void (*f)(ulong, ulong, ulong); iprint("starting reboot..."); writeconf(); shutdown(0); /* * should be the only processor running now */ print("shutting down...\n"); delay(200); /* turn off buffered serial console */ serialoq = nil; /* shutdown devices */ chandevshutdown(); /* call off the dog */ clockshutdown(); splhi(); /* setup reboot trampoline function */ f = (void*)REBOOTADDR; memmove(f, rebootcode, sizeof(rebootcode)); cacheuwbinv(); l2cacheuwb(); print("rebooting..."); iprint("entry %#lux code %#lux size %ld\n", PADDR(entry), PADDR(code), size); delay(100); /* wait for uart to quiesce */ /* off we go - never to return */ cacheuwbinv(); l2cacheuwb(); (*f)(PADDR(entry), PADDR(code), size); iprint("loaded kernel returned!\n"); delay(1000); archreboot(); }
void exit(int ispanic) { up = 0; spllo(); print("cpu %d exiting\n", m->machno); /* Shutdown running devices */ chandevshutdown(); delay(1000); splhi(); if(ispanic) for(;;); archreboot(); }
void reboot(void *entry, void *code, ulong size) { int i; void (*f)(ulong, ulong, ulong); ulong *pdb; /* we do pass options to the kernel we loaded, however, at CONFADDR. */ // writeconf(); /* * the boot processor is cpu0. execute this function on it * so that the new kernel has the same cpu0. this only matters * because the hardware has a notion of which processor was the * boot processor and we look at it at start up. */ if (m->machno != 0) { procwired(up, 0); sched(); } if(conf.nmach > 1) { /* * the other cpus could be holding locks that will never get * released (e.g., in the print path) if we put them into * reset now, so force them to shutdown gracefully first. */ lock(&active); active.rebooting = 1; unlock(&active); shutdown(0); if(arch->resetothers) arch->resetothers(); delay(20); } /* * should be the only processor running now */ active.machs = 0; if (m->machno != 0) print("on cpu%d (not 0)!\n", m->machno); print("shutting down...\n"); delay(200); splhi(); /* turn off buffered serial console */ serialoq = nil; /* shutdown devices */ chandevshutdown(); arch->introff(); /* * Modify the machine page table to directly map low memory * This allows the reboot code to turn off the page mapping */ pdb = m->pdb; for (i = 0; i < LOWPTEPAGES; i++) pdb[PDX(i*4*MB)] = pdb[PDX(KZERO + i*4*MB)]; mmuflushtlb(PADDR(pdb)); /* setup reboot trampoline function */ f = (void*)REBOOTADDR; memmove(f, rebootcode, sizeof(rebootcode)); print("rebooting...\n"); /* off we go - never to return */ coherence(); (*f)(PADDR(entry), PADDR(code), size); }