From owner-svn-src-head@FreeBSD.ORG Fri May 9 14:02:19 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B6B4C29D; Fri, 9 May 2014 14:02:19 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 897969B8; Fri, 9 May 2014 14:02:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s49E2Jhe077698; Fri, 9 May 2014 14:02:19 GMT (envelope-from loos@svn.freebsd.org) Received: (from loos@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s49E2IPV077696; Fri, 9 May 2014 14:02:18 GMT (envelope-from loos@svn.freebsd.org) Message-Id: <201405091402.s49E2IPV077696@svn.freebsd.org> From: Luiz Otavio O Souza Date: Fri, 9 May 2014 14:02:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265775 - in head/sys: conf mips/atheros X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 May 2014 14:02:19 -0000 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