summaryrefslogtreecommitdiff
path: root/sys/src/9/alphapc
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-11-30 14:56:00 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2015-11-30 14:56:00 +0100
commit7f3659e78f83a59badebeae6414b9b3cd89d7a58 (patch)
treef7d3b4c1efbc4e8ecc14ee6201563db3152012a2 /sys/src/9/alphapc
parent254031cf7020f1b185c6d0af89c653a271e0ed01 (diff)
kernel: cleanup exit()/shutdown()/reboot() code
introduce cpushutdown() function that does the common operation of initiating shutdown, returning once all cpu's got the message and are about to shutdown. this avoids duplicated code which isnt really machine specific. automatic reboot on panic only when *debug= is not set and the machine is a cpu server or has no display, otherwise just hang.
Diffstat (limited to 'sys/src/9/alphapc')
-rw-r--r--sys/src/9/alphapc/dat.h1
-rw-r--r--sys/src/9/alphapc/main.c110
2 files changed, 4 insertions, 107 deletions
diff --git a/sys/src/9/alphapc/dat.h b/sys/src/9/alphapc/dat.h
index 5257a291e..250d607e0 100644
--- a/sys/src/9/alphapc/dat.h
+++ b/sys/src/9/alphapc/dat.h
@@ -186,7 +186,6 @@ struct
Lock;
short machs;
short exiting;
- short ispanic;
}active;
/*
diff --git a/sys/src/9/alphapc/main.c b/sys/src/9/alphapc/main.c
index ac123ea9f..9175c2627 100644
--- a/sys/src/9/alphapc/main.c
+++ b/sys/src/9/alphapc/main.c
@@ -308,123 +308,21 @@ setupboot(int halt)
cpu->state |= (halt? Cpuhaltstayhalted: Cpuhaltwarmboot);
}
-/* from ../pc */
-static void
-shutdown(int ispanic)
-{
- int ms, once;
-
- lock(&active);
- if(ispanic)
- active.ispanic = ispanic;
- else if(m->machno == 0 && (active.machs & (1<<m->machno)) == 0)
- active.ispanic = 0;
- once = active.machs & (1<<m->machno);
- active.machs &= ~(1<<m->machno);
- active.exiting = 1;
- unlock(&active);
-
- if(once)
- print("cpu%d: exiting\n", m->machno);
- spllo();
- for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){
- delay(TK2MS(2));
- if(active.machs == 0 && consactive() == 0)
- break;
- }
-
- if(active.ispanic && m->machno == 0) {
- if(cpuserver)
- delay(10000);
- else
- for (;;)
- continue;
- } else
- delay(1000);
-}
-
-/* from ../pc: */
void
-reboot(void *entry, void *code, ulong size)
+reboot(void *, void *, ulong)
{
- // 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);
}
void
-exit(int ispanic)
+exit(int)
{
- canlock(&active);
- active.machs &= ~(1<<m->machno);
- active.exiting = 1;
- unlock(&active);
-
- spllo();
- print("cpu %d exiting\n", m->machno);
- do
- delay(100);
- while(consactive());
-
+ cpushutdown();
splhi();
- delay(1000); /* give serial fifo time to finish flushing */
- if (getconf("*debug") != nil) {
- USED(ispanic);
- delay(60*1000); /* give us time to read the screen */
- }
if(arch->coredetach)
arch->coredetach();
setupboot(1); // set up to halt
- for (; ; )
+ for (;;)
firmware();
-
- // on PC is just:
- //if (0) {
- // shutdown(ispanic);
- // arch->reset();
- //}
}
void