diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-11-30 14:56:00 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-11-30 14:56:00 +0100 |
commit | 7f3659e78f83a59badebeae6414b9b3cd89d7a58 (patch) | |
tree | f7d3b4c1efbc4e8ecc14ee6201563db3152012a2 /sys/src/9/kw | |
parent | 254031cf7020f1b185c6d0af89c653a271e0ed01 (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/kw')
-rw-r--r-- | sys/src/9/kw/dat.h | 1 | ||||
-rw-r--r-- | sys/src/9/kw/main.c | 50 |
2 files changed, 3 insertions, 48 deletions
diff --git a/sys/src/9/kw/dat.h b/sys/src/9/kw/dat.h index f0327bb6a..a6623abac 100644 --- a/sys/src/9/kw/dat.h +++ b/sys/src/9/kw/dat.h @@ -196,7 +196,6 @@ struct Lock; int machs; /* bitmap of active CPUs */ int exiting; /* shutdown */ - int ispanic; /* shutdown in response to a panic */ }active; enum { diff --git a/sys/src/9/kw/main.c b/sys/src/9/kw/main.c index 8b2080ef7..e938660b3 100644 --- a/sys/src/9/kw/main.c +++ b/sys/src/9/kw/main.c @@ -355,39 +355,13 @@ machinit(void) up = nil; } -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) - iprint("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; - } - delay(1000); -} - /* * exit kernel either on a panic or user request */ void -exit(int code) +exit(int) { - shutdown(code); + cpushutdown(); splhi(); archreboot(); } @@ -401,17 +375,8 @@ 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); + cpushutdown(); /* turn off buffered serial console */ serialoq = nil; @@ -430,19 +395,10 @@ reboot(void *entry, void *code, ulong size) 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(); } /* |