summaryrefslogtreecommitdiff
path: root/sys/src/9/bcm/main.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-10-28 06:16:10 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2018-10-28 06:16:10 +0100
commitb715c39bfa1e2169f450f719ba8a7643c7b39b68 (patch)
treedc5becbf9c6826e8e17b34fe84723630e8410ad5 /sys/src/9/bcm/main.c
parent0fc2adb43dc8be67b6eca49e3e28339367a01246 (diff)
bcm: simplify reboot code
- synchronize rebootcode installation - handle the 1MB identity map in mmu.c (mmuinit1()) - do not overlap CONFADDR with rebootcode, the non boot processors are parked there. - make REBOOTADDR physical address
Diffstat (limited to 'sys/src/9/bcm/main.c')
-rw-r--r--sys/src/9/bcm/main.c60
1 files changed, 36 insertions, 24 deletions
diff --git a/sys/src/9/bcm/main.c b/sys/src/9/bcm/main.c
index 54956a3d0..9bf02215a 100644
--- a/sys/src/9/bcm/main.c
+++ b/sys/src/9/bcm/main.c
@@ -19,7 +19,7 @@
* Where configuration info is left for the loaded programme.
*/
#define BOOTARGS ((char*)CONFADDR)
-#define BOOTARGSLEN (MACHADDR-CONFADDR)
+#define BOOTARGSLEN (REBOOTADDR-PADDR(CONFADDR))
#define MAXCONF 64
#define MAXCONFLINE 160
@@ -301,7 +301,7 @@ main(void)
pageinit();
userinit();
launchinit();
- mmuinit1();
+ mmuinit1(0);
schedinit();
assert(0); /* shouldn't have returned */
}
@@ -550,6 +550,35 @@ confinit(void)
}
+static void
+rebootjump(ulong entry, ulong code, ulong size)
+{
+ static void (*f)(ulong, ulong, ulong);
+ static Lock lk;
+
+ intrsoff();
+ intrcpushutdown();
+
+ /* redo identity map */
+ mmuinit1(1);
+
+ lock(&lk);
+ if(f == nil){
+ /* setup reboot trampoline function */
+ f = (void*)REBOOTADDR;
+ memmove(f, rebootcode, sizeof(rebootcode));
+ cachedwbse(f, sizeof(rebootcode));
+ }
+ unlock(&lk);
+
+ cacheuwbinv();
+ l2cacheuwbinv();
+
+ (*f)(entry, code, size);
+
+ for(;;);
+}
+
/*
* exit kernel either on a panic or user request
*/
@@ -558,14 +587,8 @@ exit(int)
{
cpushutdown();
splfhi();
- if(m->machno != 0){
- void (*f)(ulong, ulong, ulong) = (void*)REBOOTADDR;
- intrsoff();
- intrcpushutdown();
- cacheuwbinv();
- (*f)(0, 0, 0);
- for(;;);
- }
+ if(m->machno != 0)
+ rebootjump(0, 0, 0);
archreboot();
}
@@ -585,21 +608,14 @@ isaconfig(char *, int, ISAConf *)
void
reboot(void *entry, void *code, ulong size)
{
- void (*f)(ulong, ulong, ulong);
-
writeconf();
if (m->machno != 0) {
procwired(up, 0);
sched();
}
- /* setup reboot trampoline function */
- f = (void*)REBOOTADDR;
- memmove(f, rebootcode, sizeof(rebootcode));
- cachedwbse(f, sizeof(rebootcode));
-
cpushutdown();
- delay(500);
+ delay(1000);
splfhi();
@@ -611,14 +627,10 @@ reboot(void *entry, void *code, ulong size)
/* stop the clock (and watchdog if any) */
clockshutdown();
- intrsoff();
- intrcpushutdown();
-
- cacheuwbinv();
- l2cacheuwbinv();
+ wdogoff();
/* off we go - never to return */
- (*f)(PADDR(entry), PADDR(code), size);
+ rebootjump(PADDR(entry), PADDR(code), size);
}
void