shithub: riscv

Download patch

ref: 5b7a62e5e699baa64086199ada29bf10e3a09314
parent: 2c6c64c47487dbe8af6a6dc450b33931ec937601
parent: 8177d20fb2709ba9290dfd41308b8e5bee4e00f8
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Mar 11 15:42:25 EST 2017

merge

--- a/sys/src/9/bcm/dat.h
+++ b/sys/src/9/bcm/dat.h
@@ -222,7 +222,6 @@
 
 struct
 {
-	Lock;
 	char	machs[MAXMACH];		/* active CPUs */
 	int	exiting;		/* shutdown */
 }active;
--- a/sys/src/9/kw/dat.h
+++ b/sys/src/9/kw/dat.h
@@ -193,7 +193,6 @@
 
 struct
 {
-	Lock;
 	char	machs[MAXMACH];		/* active CPUs */
 	int	exiting;		/* shutdown */
 }active;
--- a/sys/src/9/mtx/dat.h
+++ b/sys/src/9/mtx/dat.h
@@ -180,7 +180,6 @@
 
 struct
 {
-	Lock;
 	char	machs[MAXMACH];
 	int	exiting;
 }active;
--- a/sys/src/9/omap/dat.h
+++ b/sys/src/9/omap/dat.h
@@ -215,7 +215,6 @@
 
 struct
 {
-	Lock;
 	char	machs[MAXMACH];		/* active CPUs */
 	int	exiting;		/* shutdown */
 }active;
--- a/sys/src/9/pc/apic.c
+++ b/sys/src/9/pc/apic.c
@@ -141,7 +141,7 @@
 }
 
 /*
- *  use the i8253 clock to figure out our lapic timer rate.
+ *  use the i8253/tsc clock to figure out our lapic timer rate.
  */
 static void
 lapictimerinit(void)
@@ -149,6 +149,11 @@
 	uvlong x, v, hz;
 	Apictimer *a;
 	int s;
+
+	if(m->machno != 0){
+		lapictimer[m->machno] = lapictimer[0];
+		return;
+	}
 
 	s = splhi();
 	a = &lapictimer[m->machno];
--- a/sys/src/9/pc/dat.h
+++ b/sys/src/9/pc/dat.h
@@ -269,10 +269,8 @@
 
 struct
 {
-	Lock;
 	char	machs[MAXMACH];		/* active CPUs */
 	int	exiting;		/* shutdown */
-	int	thunderbirdsarego;	/* lets the added processors continue to schedinit */
 }active;
 
 /*
--- a/sys/src/9/pc/i8253.c
+++ b/sys/src/9/pc/i8253.c
@@ -130,6 +130,13 @@
 	int loops, x, y;
 	uvlong a, b, cpufreq;
 
+	if(m->machno != 0){
+		m->cpuhz = MACHP(0)->cpuhz;
+		m->cpumhz = MACHP(0)->cpumhz;
+		m->loopconst = MACHP(0)->loopconst;
+		return;
+	}
+
 	ilock(&i8253);
 	for(loops = 1000;;loops += 1000) {
 		/*
--- a/sys/src/9/pc/main.c
+++ b/sys/src/9/pc/main.c
@@ -167,7 +167,6 @@
 	pageinit();
 	swapinit();
 	userinit();
-	active.thunderbirdsarego = 1;
 	schedinit();
 }
 
@@ -426,6 +425,7 @@
 		if(userpcnt < 10)
 			userpcnt = 70;
 		kpages = conf.npage - (conf.npage*userpcnt)/100;
+		conf.nimage = conf.nproc;
 
 		/*
 		 * Hack for the big boys. Only good while physmem < 4GB.
@@ -438,7 +438,6 @@
 		if(getconf("*imagemaxmb") == 0)
 		if(kpages > (64*MB + conf.npage*sizeof(Page))/BY2PG){
 			kpages = (64*MB + conf.npage*sizeof(Page))/BY2PG;
-			conf.nimage = 2000;
 			kpages += (conf.nproc*KSTACK)/BY2PG;
 		}
 	} else {
--- a/sys/src/9/pc/mmu.c
+++ b/sys/src/9/pc/mmu.c
@@ -679,7 +679,7 @@
 	 * boot. In that case it suffices to flush the MACH(0) TLB
 	 * and return.
 	 */
-	if(!active.thunderbirdsarego){
+	if(up == nil){
 		putcr3(PADDR(MACHP(0)->pdb));
 		return;
 	}
--- a/sys/src/9/pc/squidboy.c
+++ b/sys/src/9/pc/squidboy.c
@@ -12,30 +12,17 @@
 squidboy(Apic* apic)
 {
 //	iprint("Hello Squidboy\n");
-
 	machinit();
 	mmuinit();
-
 	cpuidentify();
 	cpuidprint();
-
+	syncclock();
+	active.machs[m->machno] = 1;
 	apic->online = 1;
-	coherence();
-
 	lapicinit(apic);
 	lapiconline();
-	syncclock();
 	timersinit();
-
 	fpoff();
-
-	lock(&active);
-	active.machs[m->machno] = 1;
-	unlock(&active);
-
-	while(!active.thunderbirdsarego)
-		microdelay(100);
-
 	schedinit();
 }
 
@@ -107,10 +94,12 @@
 
 	nvramwrite(0x0F, 0x0A);		/* shutdown code: warm reset upon init ipi */
 	lapicstartap(apic, PADDR(APBOOTSTRAP));
-	for(i = 0; i < 1000; i++){
+	for(i = 0; i < 100000; i++){
+		if(arch->fastclock == tscticks)
+			cycles(&m->tscticks);	/* for ap's syncclock(); */
 		if(apic->online)
 			break;
-		delay(10);
+		delay(1);
 	}
 	nvramwrite(0x0F, 0x00);
 }
--- a/sys/src/9/pc64/dat.h
+++ b/sys/src/9/pc64/dat.h
@@ -232,10 +232,8 @@
 
 struct
 {
-	Lock;
 	char	machs[MAXMACH];		/* bitmap of active CPUs */
 	int	exiting;		/* shutdown */
-	int	thunderbirdsarego;	/* lets the added processors continue to schedinit */
 }active;
 
 /*
--- a/sys/src/9/pc64/main.c
+++ b/sys/src/9/pc64/main.c
@@ -200,6 +200,7 @@
 		if(userpcnt < 10)
 			userpcnt = 70;
 		kpages = conf.npage - (conf.npage*userpcnt)/100;
+		conf.nimage = conf.nproc;
 	} else {
 		if(userpcnt < 10) {
 			if(conf.npage*BY2PG < 16*MB)
@@ -517,7 +518,6 @@
 	pageinit();
 	swapinit();
 	userinit();
-	active.thunderbirdsarego = 1;
 	schedinit();
 }
 
--- a/sys/src/9/pc64/squidboy.c
+++ b/sys/src/9/pc64/squidboy.c
@@ -15,21 +15,12 @@
 	mmuinit();
 	cpuidentify();
 	cpuidprint();
+	syncclock();
+	active.machs[m->machno] = 1;
 	apic->online = 1;
-	coherence();
-
 	lapicinit(apic);
 	lapiconline();
-	syncclock();
 	timersinit();
-
-	lock(&active);
-	active.machs[m->machno] = 1;
-	unlock(&active);
-
-	while(!active.thunderbirdsarego)
-		microdelay(100);
-
 	schedinit();
 }
 
@@ -102,10 +93,12 @@
 
 	nvramwrite(0x0F, 0x0A);		/* shutdown code: warm reset upon init ipi */
 	lapicstartap(apic, PADDR(APBOOTSTRAP));
-	for(i = 0; i < 1000; i++){
+	for(i = 0; i < 100000; i++){
+		if(arch->fastclock == tscticks)
+			cycles(&m->tscticks);	/* for ap's syncclock(); */
 		if(apic->online)
 			break;
-		delay(10);
+		delay(1);
 	}
 	nvramwrite(0x0F, 0x00);
 }
--- a/sys/src/9/port/devcons.c
+++ b/sys/src/9/port/devcons.c
@@ -1008,11 +1008,9 @@
 {
 	int ms, once;
 
-	lock(&active);
 	once = active.machs[m->machno];
 	active.machs[m->machno] = 0;
 	active.exiting = 1;
-	unlock(&active);
 
 	if(once)
 		iprint("cpu%d: exiting\n", m->machno);
--- a/sys/src/9/ppc/dat.h
+++ b/sys/src/9/ppc/dat.h
@@ -188,7 +188,6 @@
 
 struct
 {
-	Lock;
 	char	machs[MAXMACH];
 	int	exiting;
 }active;
--- a/sys/src/9/sgi/dat.h
+++ b/sys/src/9/sgi/dat.h
@@ -203,7 +203,6 @@
 
 struct
 {
-	Lock;
 	char	machs[MAXMACH];		/* active cpus */
 	short	exiting;
 }active;
--- a/sys/src/9/teg2/dat.h
+++ b/sys/src/9/teg2/dat.h
@@ -250,7 +250,6 @@
 	int	wfi;			/* bitmap of CPUs in WFI state */
 	int	stopped;		/* bitmap of CPUs stopped */
 	int	exiting;		/* shutdown */
-	int	thunderbirdsarego;	/* lets the added processors continue to schedinit */
 }active;
 
 extern register Mach* m;			/* R10 */
--- a/sys/src/9/teg2/mmu.c
+++ b/sys/src/9/teg2/mmu.c
@@ -484,7 +484,7 @@
 	for(page = proc->mmul2cache; page != nil; page = next){
 		next = page->next;
 		if(--page->ref)
-			panic("mmurelease: page->ref %d", page->ref);
+			panic("mmurelease: page->ref %ld", page->ref);
 		pagechainhead(page);
 	}
 	if(proc->mmul2cache != nil)
--- a/sys/src/9/xen/main.c
+++ b/sys/src/9/xen/main.c
@@ -106,7 +106,6 @@
 
 	swapinit();
 	userinit();
-	active.thunderbirdsarego = 1;
 	schedinit();
 }
 
--- a/sys/src/9/zynq/dat.h
+++ b/sys/src/9/zynq/dat.h
@@ -174,7 +174,6 @@
 
 struct
 {
-	Lock;
 	char	machs[MAXMACH];		/* active CPUs */
 	int	exiting;		/* shutdown */
 }active;