Author: adrian Date: Sun Mar 27 13:55:35 2011 New Revision: 220056 URL: http://svn.freebsd.org/changeset/base/220056
Log: Refactor out the ar71xx mac address code into something that's just for Redboot. At some point we're going to need to build options for different boot environments - for example, the UBoot setups I've seen simply have the MAC address hard-coded at a fixed location in flash. The OpenWRT support simply yanks the if_arge MAC directly from that in code, rather than trying to find a uboot environment to pull it from. Modified: head/sys/mips/atheros/ar71xx_machdep.c Modified: head/sys/mips/atheros/ar71xx_machdep.c ============================================================================== --- head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 12:53:20 2011 (r220055) +++ head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 13:55:35 2011 (r220056) @@ -139,13 +139,39 @@ platform_trap_exit(void) } +/* + * Obtain the MAC address via the Redboot environment. + */ +static void +ar71xx_redboot_get_macaddr(void) +{ + char *var; + int count = 0; + + /* + * "ethaddr" is passed via envp on RedBoot platforms + * "kmac" is passed via argv on RouterBOOT platforms + */ + 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); + } +} + void platform_start(__register_t a0 __unused, __register_t a1 __unused, __register_t a2 __unused, __register_t a3 __unused) { uint64_t platform_counter_freq; - int argc, i, count = 0; - char **argv, **envp, *var; + int argc, i; + char **argv, **envp; vm_offset_t kernend; /* @@ -252,21 +278,8 @@ platform_start(__register_t a0 __unused, else printf ("envp is invalid\n"); - /* - * "ethaddr" is passed via envp on RedBoot platforms - * "kmac" is passed via argv on RouterBOOT platforms - */ - 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); - } + /* Redboot if_arge MAC address is in the environment */ + ar71xx_redboot_get_macaddr(); init_param2(physmem); mips_cpu_init(); _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"