svn commit: r265775 - in head/sys: conf mips/atheros

Luiz Otavio O Souza loos at FreeBSD.org
Fri May 9 14:02:19 UTC 2014


Author: loos
Date: Fri May  9 14:02:18 2014
New Revision: 265775
URL: http://svnweb.freebsd.org/changeset/base/265775

Log:
  Add support for reading RouterBoard's memory which is passed by the loader
  (RouterBOOT).
  
  Tested on RouterBoards, various and on RSPRO, TP-Link MR3x20
  (for regressions).

Modified:
  head/sys/conf/options.mips
  head/sys/mips/atheros/ar71xx_machdep.c

Modified: head/sys/conf/options.mips
==============================================================================
--- head/sys/conf/options.mips	Fri May  9 13:44:42 2014	(r265774)
+++ head/sys/conf/options.mips	Fri May  9 14:02:18 2014	(r265775)
@@ -104,6 +104,7 @@ ARGE_MDIO			opt_arge.h
 AR71XX_REALMEM			opt_ar71xx.h
 AR71XX_ENV_UBOOT		opt_ar71xx.h
 AR71XX_ENV_REDBOOT		opt_ar71xx.h
+AR71XX_ENV_ROUTERBOOT		opt_ar71xx.h
 AR71XX_ATH_EEPROM		opt_ar71xx.h
 
 #

Modified: head/sys/mips/atheros/ar71xx_machdep.c
==============================================================================
--- head/sys/mips/atheros/ar71xx_machdep.c	Fri May  9 13:44:42 2014	(r265774)
+++ head/sys/mips/atheros/ar71xx_machdep.c	Fri May  9 14:02:18 2014	(r265775)
@@ -140,6 +140,34 @@ ar71xx_redboot_get_macaddr(void)
 	}
 }
 
+#ifdef	AR71XX_ENV_ROUTERBOOT
+/*
+ * RouterBoot gives us the board memory in a command line argument.
+ */
+static int
+ar71xx_routerboot_get_mem(int argc, char **argv)
+{
+	int i, board_mem;
+
+	/*
+	 * Protect ourselves from garbage in registers.
+	 */
+	if (!MIPS_IS_VALID_PTR(argv))
+		return (0);
+
+	for (i = 0; i < argc; i++) {
+		if (argv[i] == NULL)
+			continue;
+		if (strncmp(argv[i], "mem=", 4) == 0) {
+			if (sscanf(argv[i] + 4, "%dM", &board_mem) == 1)
+				return (btoc(board_mem * 1024 * 1024));
+		}
+	}
+
+	return (0);
+}
+#endif
+
 void
 platform_start(__register_t a0 __unused, __register_t a1 __unused, 
     __register_t a2 __unused, __register_t a3 __unused)
@@ -183,6 +211,14 @@ platform_start(__register_t a0 __unused,
 		}
 	}
 
+#ifdef	AR71XX_ENV_ROUTERBOOT
+	/*
+	 * RouterBoot informs the board memory as a command line argument.
+	 */
+	if (realmem == 0)
+		realmem = ar71xx_routerboot_get_mem(argc, argv);
+#endif
+
 	/*
 	 * Just wild guess. RedBoot let us down and didn't reported 
 	 * memory size


More information about the svn-src-all mailing list