Skip to contentSkip to conversation

cmd_bootm: Add command line arguments to Plan 9

PATCH New Steven Stallion 2 participants 4 messages Jun 6, 2013 – Jun 10, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd_bootm: Add command line arguments to Plan 9

This patch introduces support for command line arguments to Plan 9. Plan 9 generally dedicates a small region of kernel memory (known as CONFADDR) for runtime configuration. A new environment variable named confaddr was introduced to indicate this location when copying arguments.

---
 common/cmd_bootm.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
common/cmd_bootm.c +19 -0
index 05130b6..5c62271 100644
@@ -1533,6 +1533,7 @@ static int do_bootm_plan9(int flag, int argc, char * const argv[],
 			   bootm_headers_t *images)
 {
 	void (*entry_point)(void);
+	char *s;
 
 	if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
 		return 1;
@@ -1544,6 +1545,24 @@ static int do_bootm_plan9(int flag, int argc, char * const argv[],
 	}
 #endif
 
+	if ((s = getenv("confaddr")) != NULL) {
+		char *confaddr = (char *)simple_strtoul(s, NULL, 16);
+
+		if (argc > 2) {
+			int i;
+
+			s = confaddr;
+			for (i = 2; i < argc; i++) {
+				if (i > 2)
+					*s++ = '\n';
+				strcpy(s, argv[i]);
+				s += strlen(argv[i]);
+			}
+		} else if ((s = getenv("bootargs")) != NULL) {
+			strcpy(confaddr, s);
+		}
+	}
+
 	entry_point = (void (*)(void))images->ep;
 
 	printf("## Transferring control to Plan 9 (at address %08lx) ...\n",
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 cmd_bootm: Add command line arguments to Plan 9

Quoted 5 lines · Steven Stallion

This patch introduces support for command line arguments to Plan 9. Plan 9 generally dedicates a small region of kernel memory (known as CONFADDR) for runtime configuration. A new environment variable named confaddr was introduced to indicate this location when copying arguments.

Apologies for the double post - it looks like the message had been sitting in an mqueue waiting to resend.

#2 lore raw

PATCH 1/1 cmd_bootm: Add command line arguments to Plan 9

In reply to Steven Stallion

Dear Steven Stallion,

Quoted 35 lines · In message <[email protected]> you wrote:

This patch introduces support for command line arguments to Plan 9. Plan 9 generally dedicates a small region of kernel memory (known as CONFADDR) for runtime configuration. A new environment variable named confaddr was introduced to indicate this location when copying arguments.

---
 common/cmd_bootm.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
common/cmd_bootm.c +9 -0
index 05130b6..5c62271 100644
@@ -1533,6 +1533,7 @@ static int do_bootm_plan9(int flag, int argc, char * const argv[],
 			   bootm_headers_t *images)
 {
 	void (*entry_point)(void);
+	char *s;
 
 	if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
 		return 1;
@@ -1544,6 +1545,24 @@ static int do_bootm_plan9(int flag, int argc, char * const argv[],
 	}
 #endif
 
+	if ((s = getenv("confaddr")) != NULL) {
+		char *confaddr = (char *)simple_strtoul(s, NULL, 16);
+
+		if (argc > 2) {
+			int i;
+
+			s = confaddr;
+			for (i = 2; i < argc; i++) {

common/cmd_bootm.c static int do_bootm_plan9(int flag, int argc, char * const argv[], · line 1565

Quoted 10 lines
common/cmd_bootm.c +10 -0
+				if (i > 2)
+					*s++ = '\n';
+				strcpy(s, argv[i]);
+				s += strlen(argv[i]);
+			}
+		} else if ((s = getenv("bootargs")) != NULL) {
+			strcpy(confaddr, s);
+		}
+	}
+

This is basically the same code (with only irrelevant differences) as used by do_bootm_netbsd(). Can you please

1) factor out this common code, and
2) documnt the behaviour
?

By the way: this patch still triggers two "do not use assignment in if condition" checkpoatch errors. Please fix these, too.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Advice is seldom welcome; and those who want it the most always like
it the least.                         -- Philip Earl of Chesterfield
#3 lore raw

PATCH 1/1 cmd_bootm: Add command line arguments to Plan 9

Quoted 6 lines · Wolfgang Denk

This is basically the same code (with only irrelevant differences) as used by do_bootm_netbsd(). Can you please

1) factor out this common code, and
2) documnt the behaviour
?

Will do.

Quoted 2 lines

By the way: this patch still triggers two "do not use assignment in if condition" checkpoatch errors. Please fix these, too.

Will do. I'll submit a v2 patch later this evening.

Thanks for being patient :-)

Steve