shithub: nix

Download patch

ref: 0d44215be55c15455358d30b7609c7f839afd873
parent: bc42e2e14ccfea0651ca99179e2d470fd68f98d3
author: glenda <glenda@cirno>
date: Wed May 8 09:14:00 EDT 2024

We are now able to do our first NIX test call.
calling core 4... wait for it...
acsched: cpu4: fn 0xffffffff80232fbf
called icc
acsched: cpu4: idle
Next steps: user mode.

--- a/sys/src/nix/pc64/acore.c
+++ b/sys/src/nix/pc64/acore.c
@@ -48,28 +48,24 @@
 static void
 testiccfn(void)
 {
-	print("called: %s\n", (char*)m->icc->data);
+	print("called icc\n");
 }
 
 void
-testicc(int )
+testicc(int core, NIX *nix)
 {
-/* TODO: testicc code
-	Mach *mp;
-
-	if((mp = sys->machptr[i]) != nil && mp->online != 0){
-		if(mp->nixtype != NIXAC){
-			print("testicc: core %d is not an AC\n", i);
-			return;
-		}
-		print("calling core %d... ", i);
-		mp->icc->flushtlb = 0;
-		snprint((char*)mp->icc->data, ICCLNSZ, "<%d>", i);
+	int i;
+	// TODO: restore check code.
+		print("calling core %d... ", core);
+		nix->icc->flushtlb = 0;
+		snprint((char*)nix->icc->data, ICCLNSZ, "<%d>", core);
 		mfence();
-		mp->icc->fn = testiccfn;
-		mwait(&mp->icc->fn);
+		nix->icc->fn = testiccfn;
+		for(i = 0; (i < 30) && (nix->icc->fn != 0); i++) {
+			print("wait for it...\n");
+			delay(1000);
+		// TODO: mwait mwait(&mp->icc->fn);
 	}
-*/
 }
 
 /*
@@ -119,6 +115,7 @@
 	int core = m->machno;
 	acmmuswitch();
 	nix->icc->fn = nil;
+	print("acsched %d times on core %d\n", i, core);
 	for(;i;i--){
 		acstackok();
 		while (nix->icc->fn == 0)
@@ -132,6 +129,7 @@
 		mfence();
 		nix->icc->fn = nil;
 	}
+	print("acsched: all done on core %d\n", core);
 }
 
 /*
--- a/sys/src/nix/pc64/devnix.c
+++ b/sys/src/nix/pc64/devnix.c
@@ -112,12 +112,8 @@
 static long
 nixread(Chan *c, void *va, long n, vlong voff)
 {
-	int i, len;
-	long off = voff;
-	uchar *buf = va;
+	int i,len;	uchar *buf = va;
 	static char nixinfo[1024];
-
-	i = 0;
 	switch((ulong)c->qid.path){
 	case Qdir:
 		if(debug&(DBGFS|DBGREAD))
@@ -125,7 +121,7 @@
 
 		n = devdirread(c, (char *)buf, n, nixdir, nelem(nixdir), devgen);
 		if(debug&(DBGFS|DBGREAD))
-			print("nixread %ld\n", n);
+			print("nixread %d\n", n);
 		return n;
 	case Qctl:
 		error(Eperm);
@@ -141,7 +137,6 @@
 	default:
 		panic("nixread: %d\n", c->qid.path);
 	}
-	return -1;
 }
 
 /* can only write to Qctl */
@@ -172,7 +167,7 @@
 		nixes[m->machno].nixed = 1;
 		print("NIX ME %d\n", m->machno);
 		/* acsched here */
-		acsched(1, &nixes[m->machno].nix);
+		acsched(1024, &nixes[m->machno].nix);
 		/* acsched returns and we're back. */
 		print("UN NIX ME %d\n", m->machno);
 		nixes[m->machno].nixed = 0;
@@ -190,6 +185,21 @@
 			error("Core is not nixed");
 		print("I guess we run on it\n");
 		print("I guess we're back\n");
+		return n;
+	}
+
+	if (strcmp(f[0], "test") == 0) {
+		void testicc(int core, NIX *nix);
+		int core;
+		if (nf != 2)
+			error("usage: test <core#>");
+		core = strtoull(f[1], 0, 0);
+		if (core > MAXMACH)
+			error("Core is > MAXMACH");
+		if (nixes[core].nixed == 0)
+			error("Core is not nixed");
+		testicc(core, &nixes[core].nix);
+		return n;
 	}
 
 	error("no such operation\n");