Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Sep 2010 01:09:12 +0000 (UTC)
From:      Andrew Thompson <thompsa@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r212774 - head/sys/mips/atheros
Message-ID:  <201009170109.o8H19CZP013821@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: thompsa
Date: Fri Sep 17 01:09:12 2010
New Revision: 212774
URL: http://svn.freebsd.org/changeset/base/212774

Log:
  Use getenv to find the mac address since it could be in the bootloader
  environment or command line and under different names.

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

Modified: head/sys/mips/atheros/ar71xx_machdep.c
==============================================================================
--- head/sys/mips/atheros/ar71xx_machdep.c	Thu Sep 16 23:33:24 2010	(r212773)
+++ head/sys/mips/atheros/ar71xx_machdep.c	Fri Sep 17 01:09:12 2010	(r212774)
@@ -145,7 +145,7 @@ platform_start(__register_t a0 __unused,
 {
 	uint64_t platform_counter_freq;
 	int argc, i, count = 0;
-	char **argv, **envp;
+	char **argv, **envp, *var;
 	vm_offset_t kernend;
 
 	/* 
@@ -167,19 +167,9 @@ platform_start(__register_t a0 __unused,
 	 * Protect ourselves from garbage in registers 
 	 */
 	if (MIPS_IS_VALID_PTR(envp)) {
-		for (i = 0; envp[i]; i += 2)
-		{
+		for (i = 0; envp[i]; i += 2) {
 			if (strcmp(envp[i], "memsize") == 0)
 				realmem = btoc(strtoul(envp[i+1], NULL, 16));
-			else if (strcmp(envp[i], "ethaddr") == 0) {
-				count = sscanf(envp[i+1], "%x.%x.%x.%x.%x.%x", 
-				    &ar711_base_mac[0], &ar711_base_mac[1],
-				    &ar711_base_mac[2], &ar711_base_mac[3],
-				    &ar711_base_mac[4], &ar711_base_mac[5]);
-				if (count < 6)
-					memset(ar711_base_mac, 0,
-					    sizeof(ar711_base_mac));
-			}
 		}
 	}
 
@@ -245,6 +235,18 @@ platform_start(__register_t a0 __unused,
 	else 
 		printf ("envp is invalid\n");
 
+	if ((var = getenv("ethaddr")) != NULL ||
+	    (var = getenv("kmac")) != NULL) {
+		count = sscanf(var, "%x%*c%x%*c%x%*c%x%*c%x%*c%x",
+		    &ar711_base_mac[0], &ar711_base_mac[1],
+		    &ar711_base_mac[2], &ar711_base_mac[3],
+		    &ar711_base_mac[4], &ar711_base_mac[5]);
+		if (count < 6)
+			memset(ar711_base_mac, 0,
+			    sizeof(ar711_base_mac));
+		freeenv(var);
+	}
+
 	init_param2(physmem);
 	mips_cpu_init();
 	pmap_bootstrap();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009170109.o8H19CZP013821>