code: plan9front

Download patch

ref: 8b5714139bb0d965eb626f87115964d8dcad04af
parent: 297c6d8c490ea934a4cd968d9edc5656ecd209a4
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Oct 31 08:44:09 EDT 2022

reform: only override console=0 when no plan9.ini is passed

The kernel used to always set console=0, which as
usefull during bring-up, but makes it impossible
to use the uart for other purposes.

We now have the ability to pass plan9.ini using
the u-boot script, so add the console=0 line there.

To make debugging easy, we still apply
console=0 if no plan9.ini has been passed.

--- a/sys/lib/dist/mkfile
+++ b/sys/lib/dist/mkfile
@@ -92,7 +92,9 @@
 	@{
 	objtype=arm64
 	kernel=/n/src9/$objtype/9reform.u
-	echo 'bootargs=local!/dev/sdM0/fs' > /env/plan9.ini
+	> /env/plan9.ini {
+		echo 'console=0'
+	}
 	fatfiles=(/n/src9/sys/src/boot/reform/boot.scr /env/plan9.ini $kernel)
 	mb=1885	# storage vendors idea of 2GB
 	mk $target.$pid.disk
--- a/sys/src/9/imx8/main.c
+++ b/sys/src/9/imx8/main.c
@@ -17,7 +17,7 @@
 #define	MAXCONF 64
 static char *confname[MAXCONF];
 static char *confval[MAXCONF];
-static int nconf;
+static int nconf = -1;
 
 void
 bootargsinit(void)
@@ -28,7 +28,7 @@
 	/*
 	 *  parse configuration args from dos file plan9.ini
 	 */
-	cp = BOOTARGS;	/* where b.com leaves its config */
+	cp = BOOTARGS;
 	cp[BOOTARGSLEN-1] = 0;
 
 	/*
@@ -47,6 +47,12 @@
 	*p = 0;
 
 	n = getfields(cp, line, MAXCONF, 1, "\n");
+	if(n <= 0){
+		/* empty plan9.ini, no configuration passed */
+		return;
+	}
+
+	nconf = 0;
 	for(i = 0; i < n; i++){
 		if(*line[i] == '#')
 			continue;
@@ -81,6 +87,12 @@
 {
 	int i;
 
+	if(nconf < 0){
+		/* use defaults when there was no configuration */
+		ksetenv("console", "0", 0);
+		return;
+	}
+
 	for(i = 0; i < nconf; i++){
 		if(confname[i][0] != '*')
 			ksetenv(confname[i], confval[i], 0);
@@ -138,7 +150,6 @@
 			ksetenv("service", "cpu", 0);
 		else
 			ksetenv("service", "terminal", 0);
-		ksetenv("console", "0", 0);
 		setconfenv();
 		poperror();
 	}