Skip to contentSkip to conversation

nios2: pass command line and initrd to linux in bootm.c

PATCH New Thomas Chou 2 participants 2 messages Mar 24, 2010 – Mar 31, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nios2: pass command line and initrd to linux in bootm.c

This patch adds bootargs passing to nios2 linux.

The args passing is enabled with, r4 : 'NIOS' magic
r5 : pointer to initrd start r6 : pointer to initrd end r7 : pointer to command line

---
 lib_nios2/bootm.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
lib_nios2/bootm.c +12 -7
index 675bfac..5d25edf 100644
@@ -26,21 +26,26 @@
 #include <asm/byteorder.h>
 #include <asm/cache.h>
 
+#define NIOS_MAGIC 0x534f494e /* enable command line and initrd passing */
+
 int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 {
-	void (*kernel)(void) = (void (*)(void))images->ep;
+	void (*kernel)(int, int, int, char *) = (void *)images->ep;
+	char *commandline = getenv("bootargs");
+	ulong initrd_start = images->rd_start;
+	ulong initrd_end = images->rd_end;
 
 	if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
 		return 1;
 
 	/* flushes data and instruction caches before calling the kernel */
-	flush_dcache (0,CONFIG_SYS_DCACHE_SIZE);
-	flush_icache (0,CONFIG_SYS_ICACHE_SIZE);
+	disable_interrupts();
+	flush_dcache((ulong)kernel, CONFIG_SYS_DCACHE_SIZE);
+	flush_icache((ulong)kernel, CONFIG_SYS_ICACHE_SIZE);
 
-	/* For now we assume the Microtronix linux ... which only
-	 * needs to be called ;-)
-	 */
-	kernel ();
+	debug("bootargs=%s @ 0x%lx\n", commandline, (ulong)&commandline);
+	debug("initrd=0x%lx-0x%lx\n", (ulong)initrd_start, (ulong)initrd_end);
+	kernel(NIOS_MAGIC, initrd_start, initrd_end, commandline);
 	/* does not return */
 
 	return 1;
Signature · 1 line
1.6.6.1
Applied
#1 lore raw

PATCH 1/1 nios2: pass command line and initrd to linux in bootm.c

Thomas,

Applied.

Theank you,
--Scott

Quoted 51 lines · Thomas Chou

This patch adds bootargs passing to nios2 linux.

The args passing is enabled with, r4 : 'NIOS' magic
r5 : pointer to initrd start r6 : pointer to initrd end r7 : pointer to command line

---
 lib_nios2/bootm.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
lib_nios2/bootm.c +12 -7
index 675bfac..5d25edf 100644
@@ -26,21 +26,26 @@
 #include <asm/byteorder.h>
 #include <asm/cache.h>
 
+#define NIOS_MAGIC 0x534f494e /* enable command line and initrd passing */
+
 int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 {
-	void (*kernel)(void) = (void (*)(void))images->ep;
+	void (*kernel)(int, int, int, char *) = (void *)images->ep;
+	char *commandline = getenv("bootargs");
+	ulong initrd_start = images->rd_start;
+	ulong initrd_end = images->rd_end;
 
 	if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
 		return 1;
 
 	/* flushes data and instruction caches before calling the kernel */
-	flush_dcache (0,CONFIG_SYS_DCACHE_SIZE);
-	flush_icache (0,CONFIG_SYS_ICACHE_SIZE);
+	disable_interrupts();
+	flush_dcache((ulong)kernel, CONFIG_SYS_DCACHE_SIZE);
+	flush_icache((ulong)kernel, CONFIG_SYS_ICACHE_SIZE);
 
-	/* For now we assume the Microtronix linux ... which only
-	 * needs to be called ;-)
-	 */
-	kernel ();
+	debug("bootargs=%s @ 0x%lx\n", commandline, (ulong)&commandline);
+	debug("initrd=0x%lx-0x%lx\n", (ulong)initrd_start, (ulong)initrd_end);
+	kernel(NIOS_MAGIC, initrd_start, initrd_end, commandline);
 	/* does not return */
 
 	return 1;