From 7f3659e78f83a59badebeae6414b9b3cd89d7a58 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 30 Nov 2015 14:56:00 +0100 Subject: 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. --- sys/src/9/bcm/main.c | 45 +++------------------------------------------ 1 file changed, 3 insertions(+), 42 deletions(-) (limited to 'sys/src/9/bcm/main.c') diff --git a/sys/src/9/bcm/main.c b/sys/src/9/bcm/main.c index 1746a5279..a39637a21 100644 --- a/sys/src/9/bcm/main.c +++ b/sys/src/9/bcm/main.c @@ -522,39 +522,13 @@ confinit(void) } -static void -shutdown(int ispanic) -{ - int ms, once; - - lock(&active); - if(ispanic) - active.ispanic = ispanic; - else if(m->machno == 0 && (active.machs & (1<machno)) == 0) - active.ispanic = 0; - once = active.machs & (1<machno); - active.machs &= ~(1<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(); splfhi(); archreboot(); } @@ -579,17 +553,8 @@ reboot(void *entry, void *code, ulong size) { void (*f)(ulong, ulong, ulong); - print("starting reboot..."); writeconf(); - shutdown(0); - - /* - * should be the only processor running now - */ - - print("reboot entry %#lux code %#lux size %ld\n", - PADDR(entry), PADDR(code), size); - delay(100); + cpushutdown(); /* turn off buffered serial console */ serialoq = nil; @@ -612,10 +577,6 @@ reboot(void *entry, void *code, ulong size) /* off we go - never to return */ (*f)(PADDR(entry), PADDR(code), size); - - iprint("loaded kernel returned!\n"); - delay(1000); - archreboot(); } int -- cgit v1.2.3