shithub: nix

Download patch

ref: 526efbec42e8b2a311cd39df1c37e5ee630fee99
parent: 9df57796ae86da20d019b8184eca852d7e31a306
author: glenda <glenda@cirno>
date: Tue May 7 19:05:18 EDT 2024

booting but blows up in attach core command

--- a/sys/src/nix/pc64/acore.c
+++ b/sys/src/nix/pc64/acore.c
@@ -79,7 +79,7 @@
 static void
 acstackok(void)
 {
-	panic("acstackok");
+	return;
 /*
 	char dummy;
 	char *sstart;
@@ -97,6 +97,8 @@
 {
 	extern Page mach0pml4;
 
+	print("acmmuswitch no op\n");
+	return;
 //	DBG("acmmuswitch mpl4 %#p mach0pml4 %#p m0pml4 %#p\n", m->pml4->pa, mach0pml4.pa, sys->machptr[0]->pml4->pa);
 
 
@@ -112,19 +114,21 @@
  * wait for another call.
  */
 void
-acsched(void)
+acsched(int i, NIX *nix)
 {
+	int core = m->machno;
 	acmmuswitch();
-	for(;;){
+	nix->icc->fn = nil;
+	for(;i;i--){
 		acstackok();
-		mwait(&m->icc->fn);
-		if(m->icc->flushtlb)
+		mwait(&nix->icc->fn);
+		if(nix->icc->flushtlb)
 			acmmuswitch();
-		DBG("acsched: cpu%d: fn %#p\n", m->machno, m->icc->fn);
-		m->icc->fn();
-		DBG("acsched: cpu%d: idle\n", m->machno);
+		DBG("acsched: cpu%d: fn %#p\n", core, nix->icc->fn);
+		nix->icc->fn();
+		DBG("acsched: cpu%d: idle\n", core);
 		mfence();
-		m->icc->fn = nil;
+		nix->icc->fn = nil;
 	}
 }
 
@@ -228,7 +232,7 @@
 	if(m->icc->flushtlb)
 		acmmuswitch();
 	if(m->icc->fn != actrapret)
-		acsched();
+		acsched(-1, nil);
 	DBG("actrap: ret\n");
 	memmove(u, m->proc->dbgreg, sizeof *u);
 	if(m->proc)
@@ -264,7 +268,7 @@
 	 * stack, upon the next syscall.
 	 * We don't nest calls in the current stack for too long.
 	 */
-	acsched();
+	acsched(-1, nil);
 }
 
 /*
--- a/sys/src/nix/pc64/devnix.c
+++ b/sys/src/nix/pc64/devnix.c
@@ -37,6 +37,8 @@
 
 struct DEVNIX {
 	int nixed;
+	NIX nix;
+	ICC icc;
 } nixes[MAXMACH];
 
 int nnix = 0;
@@ -48,6 +50,7 @@
 
 	for(nnix = 0; nnix < MAXMACH; nnix++){
 		nix = &nixes[nnix];
+		nix->nix.icc = &(nixes[nnix].icc);
 		print("nix %p\n", nix);
 		}
 
@@ -152,6 +155,7 @@
 
 
 	if (strcmp(f[0], "a") == 0) {
+			void acsched(int i, NIX *);
 		if (nf != 1)
 			error("a takes no arguments");
 
@@ -168,6 +172,7 @@
 		nixes[m->machno].nixed = 1;
 		print("NIX ME %d\n", m->machno);
 		/* acsched here */
+		acsched(1, &nixes[m->machno].nix);
 		/* acsched returns and we're back. */
 		print("UN NIX ME %d\n", m->machno);
 		nixes[m->machno].nixed = 0;
--- a/sys/src/nix/pc64/nix.h
+++ b/sys/src/nix/pc64/nix.h
@@ -13,9 +13,9 @@
 {
 	ICC*	icc;			/* inter-core call */
 	int	nixtype;
-	int apicno; // not sure we need this? 
-	int online; // TODO: what is this really? 
 	uvlong nicc;
+	int apicno; // not sure we need this? 
+	int online; // TODO: what is this really? };
 };
 
 /*