Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sandpoint Recognize a network boot device by its PC...



details:   https://anonhg.NetBSD.org/src/rev/75ad64d07028
branches:  trunk
changeset: 754977:75ad64d07028
user:      phx <phx%NetBSD.org@localhost>
date:      Tue May 18 15:07:50 2010 +0000

description:
Recognize a network boot device by its PCI tag, even when it is not directly
attached to a PCI bus, but to a controller chip (e.g. sk(4) on skc(4)).
Extended BTINFO_NET to usa a PCI tag as well, now since it works.

diffstat:

 sys/arch/sandpoint/include/bootinfo.h   |   3 +-
 sys/arch/sandpoint/sandpoint/autoconf.c |  36 ++++++++++++++++++++++++++++----
 sys/arch/sandpoint/stand/netboot/main.c |   3 +-
 3 files changed, 35 insertions(+), 7 deletions(-)

diffs (95 lines):

diff -r ff7bd1b36338 -r 75ad64d07028 sys/arch/sandpoint/include/bootinfo.h
--- a/sys/arch/sandpoint/include/bootinfo.h     Tue May 18 15:01:17 2010 +0000
+++ b/sys/arch/sandpoint/include/bootinfo.h     Tue May 18 15:07:50 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootinfo.h,v 1.5 2010/05/16 11:27:49 phx Exp $ */
+/*     $NetBSD: bootinfo.h,v 1.6 2010/05/18 15:07:50 phx Exp $ */
 
 /*
  * Copyright (c) 1997
@@ -80,6 +80,7 @@
 struct btinfo_net {
        struct btinfo_common common;
        char devname[16];
+       unsigned cookie;
        uint8_t mac_address[6];
 };
 
diff -r ff7bd1b36338 -r 75ad64d07028 sys/arch/sandpoint/sandpoint/autoconf.c
--- a/sys/arch/sandpoint/sandpoint/autoconf.c   Tue May 18 15:01:17 2010 +0000
+++ b/sys/arch/sandpoint/sandpoint/autoconf.c   Tue May 18 15:07:50 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.20 2010/05/16 11:27:49 phx Exp $        */
+/*     $NetBSD: autoconf.c,v 1.21 2010/05/18 15:07:50 phx Exp $        */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.20 2010/05/16 11:27:49 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.21 2010/05/18 15:07:50 phx Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -90,13 +90,39 @@
 device_register(struct device *dev, void *aux)
 {
        struct pci_attach_args *pa;
+       static device_t boot_parent = NULL, net_parent = NULL;
+       static pcitag_t boot_tag, net_tag;
+       pcitag_t tag;
+
+       if (device_is_a(dev, "skc")) {
+               pa = aux;
+               if (bi_rdev != NULL && bi_rdev->cookie == pa->pa_tag) {
+                       boot_parent = dev;
+                       boot_tag = pa->pa_tag;
+               }
+               if (bi_net != NULL && bi_net->cookie == pa->pa_tag) {
+                       net_parent = dev;
+                       net_tag = pa->pa_tag;
+               }
+       }
 
        if (dev->dv_class == DV_IFNET) {
-               pa = aux;
+               if (device_is_a(device_parent(dev), "pci")) {
+                       pa = aux;
+                       tag = pa->pa_tag;
+               } else if (device_parent(dev) == boot_parent)
+                       tag = boot_tag;
+               else if (device_parent(dev) == net_parent)
+                       tag = net_tag;
+               else
+                       tag = 0;
+
                if (bi_rdev != NULL && device_is_a(dev, bi_rdev->devname)
-                   && bi_rdev->cookie == pa->pa_tag)
+                   && bi_rdev->cookie == tag)
                        booted_device = dev;
-               if (bi_net != NULL && device_is_a(dev, bi_net->devname)) {
+
+               if (bi_net != NULL && device_is_a(dev, bi_net->devname)
+                   && bi_net->cookie == tag) {
                        prop_data_t pd;
 
                        pd = prop_data_create_data_nocopy(bi_net->mac_address,
diff -r ff7bd1b36338 -r 75ad64d07028 sys/arch/sandpoint/stand/netboot/main.c
--- a/sys/arch/sandpoint/stand/netboot/main.c   Tue May 18 15:01:17 2010 +0000
+++ b/sys/arch/sandpoint/stand/netboot/main.c   Tue May 18 15:07:50 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.29 2010/05/16 11:27:49 phx Exp $ */
+/* $NetBSD: main.c,v 1.30 2010/05/18 15:07:50 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -163,6 +163,7 @@
                /* need to set MAC address for Marvell-SKnet */
                strcpy(bi_net.devname, "sk");
                memcpy(bi_net.mac_address, en, sizeof(en));
+               bi_net.cookie = tag;
        }
 
        bi_add(&bi_cons, BTINFO_CONSOLE, sizeof(bi_cons));



Home | Main Index | Thread Index | Old Index