Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/evbarm/fdt If the bootloader specifies a boot mac-a...



details:   https://anonhg.NetBSD.org/src/rev/4269d2cf04dc
branches:  trunk
changeset: 837009:4269d2cf04dc
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Nov 15 23:53:40 2018 +0000

description:
If the bootloader specifies a boot mac-address, use it to find the root device.

diffstat:

 sys/arch/evbarm/fdt/fdt_machdep.c |  25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diffs (53 lines):

diff -r c7cdaf0cad0b -r 4269d2cf04dc sys/arch/evbarm/fdt/fdt_machdep.c
--- a/sys/arch/evbarm/fdt/fdt_machdep.c Thu Nov 15 23:52:33 2018 +0000
+++ b/sys/arch/evbarm/fdt/fdt_machdep.c Thu Nov 15 23:53:40 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.54 2018/11/03 15:02:32 skrll Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.55 2018/11/15 23:53:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.54 2018/11/03 15:02:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.55 2018/11/15 23:53:40 jmcneill Exp $");
 
 #include "opt_machdep.h"
 #include "opt_bootconfig.h"
@@ -63,6 +63,10 @@
 #include <sys/uuid.h>
 #include <sys/disk.h>
 #include <sys/md5.h>
+#include <sys/pserialize.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
 
 #include <dev/cons.h>
 #include <uvm/uvm_extern.h>
@@ -697,6 +701,23 @@
                if (dv != NULL)
                        booted_device = dv;
        }
+
+       if (of_hasprop(chosen, "netbsd,booted-mac-address")) {
+               const uint8_t *macaddr = fdtbus_get_prop(chosen, "netbsd,booted-mac-address", &len);
+               if (macaddr == NULL || len != 6)
+                       return;
+               int s = pserialize_read_enter();
+               struct ifnet *ifp;
+               IFNET_READER_FOREACH(ifp) {
+                       if (memcmp(macaddr, CLLADDR(ifp->if_sadl), len) == 0) {
+                               device_t dv = device_find_by_xname(ifp->if_xname);
+                               if (dv != NULL)
+                                       booted_device = dv;
+                               break;
+                       }
+               }
+               pserialize_read_exit(s);
+       }
 }
 
 static void



Home | Main Index | Thread Index | Old Index