summaryrefslogtreecommitdiff
path: root/sys/src/9/pc
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/pc
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/pc')
-rw-r--r--sys/src/9/pc/dat.h1
-rw-r--r--sys/src/9/pc/main.c54
-rw-r--r--sys/src/9/pc/screen.c2
3 files changed, 5 insertions, 52 deletions
diff --git a/sys/src/9/pc/dat.h b/sys/src/9/pc/dat.h
index 8bcc5053a..19b7dfae2 100644
--- a/sys/src/9/pc/dat.h
+++ b/sys/src/9/pc/dat.h
@@ -272,7 +272,6 @@ struct
Lock;
int machs; /* bitmap of active CPUs */
int exiting; /* shutdown */
- int ispanic; /* shutdown in response to a panic */
int thunderbirdsarego; /* lets the added processors continue to schedinit */
}active;
diff --git a/sys/src/9/pc/main.c b/sys/src/9/pc/main.c
index 6672717c2..6d8341997 100644
--- a/sys/src/9/pc/main.c
+++ b/sys/src/9/pc/main.c
@@ -163,7 +163,6 @@ main(void)
pcimatch(0, 0, 0);
}else
links();
- conf.monitor = 1;
chandevreset();
pageinit();
swapinit();
@@ -890,50 +889,6 @@ procsave(Proc *p)
mmuflushtlb(PADDR(m->pdb));
}
-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);
- /*
- * setting exiting will make hzclock() on each processor call exit(0),
- * which calls shutdown(0) and arch->reset(), which on mp systems calls
- * mpshutdown(), from which there is no return: the processor is idled
- * or initiates a reboot. clearing our bit in machs avoids calling
- * exit(0) from hzclock() on this processor.
- */
- active.machs &= ~(1<<m->machno);
- active.exiting = 1;
- unlock(&active);
-
- if(once)
- iprint("cpu%d: exiting\n", m->machno);
-
- /* wait for any other processors to shutdown */
- spllo();
- for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){
- delay(TK2MS(2));
- if(active.machs == 0 && consactive() == 0)
- break;
- }
-
- if(active.ispanic){
- if(!cpuserver)
- for(;;)
- halt();
- if(getconf("*debug"))
- delay(5*60*1000);
- else
- delay(10000);
- }
-}
-
void
reboot(void *entry, void *code, ulong size)
{
@@ -952,10 +907,7 @@ reboot(void *entry, void *code, ulong size)
procwired(up, 0);
sched();
}
- shutdown(0);
-
- iprint("shutting down...\n");
- delay(200);
+ cpushutdown();
splhi();
@@ -985,8 +937,8 @@ reboot(void *entry, void *code, ulong size)
void
-exit(int ispanic)
+exit(int)
{
- shutdown(ispanic);
+ cpushutdown();
arch->reset();
}
diff --git a/sys/src/9/pc/screen.c b/sys/src/9/pc/screen.c
index 4ff7a9485..c74d2da71 100644
--- a/sys/src/9/pc/screen.c
+++ b/sys/src/9/pc/screen.c
@@ -664,6 +664,8 @@ bootscreeninit(void)
scr->cur = &swcursor;
scr->cur->enable(scr);
cursoron();
+
+ conf.monitor = 1;
}
/*