changelog shortlog tags branches changeset file revisions annotate raw help

Mercurial > hg > plan9front / sys/src/9/bcm64/main.c

revision 7235: b1dc95374307
parent 7207: 19de954d8073
child 7309: 889b634159e5
     1.1--- a/sys/src/9/bcm64/main.c
     1.2+++ b/sys/src/9/bcm64/main.c
     1.3@@ -8,12 +8,12 @@
     1.4 #include "io.h"
     1.5 #include "init.h"
     1.6 #include "sysreg.h"
     1.7+#include "reboot.h"
     1.8 
     1.9 #include <pool.h>
    1.10 #include <libsec.h>
    1.11 
    1.12 Conf conf;
    1.13-ulong memsize = GiB;
    1.14 
    1.15 /*
    1.16  *  starting place for first process
    1.17@@ -122,7 +122,7 @@ userinit(void)
    1.18 	pg = newpage(1, 0, UTZERO);
    1.19 	pg->txtflush = ~0;
    1.20 	segpage(s, pg);
    1.21-	k = kmap(s->map[0]->pages[0]);
    1.22+	k = kmap(pg);
    1.23 	memmove((void*)VA(k), initcode, sizeof initcode);
    1.24 	kunmap(k);
    1.25 
    1.26@@ -133,7 +133,7 @@ void
    1.27 confinit(void)
    1.28 {
    1.29 	int i, userpcnt;
    1.30-	ulong kpages;
    1.31+	ulong kpages, memsize = 0;
    1.32 	uintptr pa;
    1.33 	char *p;
    1.34 
    1.35@@ -149,12 +149,10 @@ confinit(void)
    1.36 	else
    1.37 		userpcnt = 0;
    1.38 
    1.39-	if((p = getconf("*maxmem")) != nil){
    1.40+	if(p = getconf("*maxmem"))
    1.41 		memsize = strtoul(p, 0, 0) - PHYSDRAM;
    1.42-		if (memsize < 16*MB)		/* sanity */
    1.43-			memsize = 16*MB;
    1.44-	}
    1.45-
    1.46+	if (memsize < 16*MB)		/* sanity */
    1.47+		memsize = 16*MB;
    1.48 	getramsize(&conf.mem[0]);
    1.49 	if(conf.mem[0].limit == 0){
    1.50 		conf.mem[0].base = PHYSDRAM;
    1.51@@ -247,7 +245,7 @@ mpinit(void)
    1.52 	for(i = 1; i < conf.nmach; i++)
    1.53 		MACHP(i)->machno = i;
    1.54 
    1.55-	cachedwbinv();
    1.56+	coherence();
    1.57 
    1.58 	for(i = 1; i < conf.nmach; i++)
    1.59 		((uintptr*)SPINTABLE)[i] = PADDR(_start);
    1.60@@ -257,6 +255,9 @@ mpinit(void)
    1.61 	delay(100);
    1.62 	sev();
    1.63 	synccycles();
    1.64+
    1.65+	for(i = 0; i < MAXMACH; i++)
    1.66+		((uintptr*)SPINTABLE)[i] = 0;
    1.67 }
    1.68 
    1.69 void
    1.70@@ -276,12 +277,11 @@ main(void)
    1.71 		schedinit();
    1.72 		return;
    1.73 	}
    1.74+	quotefmtinstall();
    1.75 	bootargsinit();
    1.76 	confinit();
    1.77 	xinit();
    1.78 	printinit();
    1.79-	fmtinstall('H', encodefmt);
    1.80-	quotefmtinstall();
    1.81 	uartconsinit();
    1.82 	screeninit();
    1.83 	print("\nPlan 9\n");
    1.84@@ -308,17 +308,64 @@ main(void)
    1.85 	schedinit();
    1.86 }
    1.87 
    1.88+static void
    1.89+rebootjump(void *entry, void *code, ulong size)
    1.90+{
    1.91+	void (*f)(void*, void*, ulong);
    1.92+
    1.93+	intrsoff();
    1.94+	intrcpushutdown();
    1.95+
    1.96+	/* redo identity map */
    1.97+	mmuidmap((uintptr*)L1);
    1.98+
    1.99+	/* setup reboot trampoline function */
   1.100+	f = (void*)REBOOTADDR;
   1.101+	memmove(f, rebootcode, sizeof(rebootcode));
   1.102+	cachedwbinvse(f, sizeof(rebootcode));
   1.103+	cacheiinvse(f, sizeof(rebootcode));
   1.104+
   1.105+	(*f)(entry, code, size);
   1.106+
   1.107+	for(;;);
   1.108+}
   1.109+
   1.110 void
   1.111 exit(int)
   1.112 {
   1.113 	cpushutdown();
   1.114-	for(;;);
   1.115+	splfhi();
   1.116+	if(m->machno == 0)
   1.117+		archreboot();
   1.118+	rebootjump(0, 0, 0);
   1.119 }
   1.120 
   1.121 void
   1.122-reboot(void*, void*, ulong)
   1.123+reboot(void *entry, void *code, ulong size)
   1.124 {
   1.125-	error(Egreg);
   1.126+	writeconf();
   1.127+	while(m->machno != 0){
   1.128+		procwired(up, 0);
   1.129+		sched();
   1.130+	}
   1.131+
   1.132+	cpushutdown();
   1.133+	delay(2000);
   1.134+
   1.135+	splfhi();
   1.136+
   1.137+	/* turn off buffered serial console */
   1.138+	serialoq = nil;
   1.139+
   1.140+	/* shutdown devices */
   1.141+	chandevshutdown();
   1.142+
   1.143+	/* stop the clock (and watchdog if any) */
   1.144+	clockshutdown();
   1.145+	wdogoff();
   1.146+
   1.147+	/* off we go - never to return */
   1.148+	rebootjump(entry, code, size);
   1.149 }
   1.150 
   1.151 /*