summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2022-01-22 11:49:16 +0000
committerthorpej <thorpej@NetBSD.org>2022-01-22 11:49:16 +0000
commit09eb5c43f131a6790fa9b46f440dd5a2d4ae03ae (patch)
treeffdfd13d89a9bfa56433c400ad83033887f60a5f /sys
parent1c2752a686271470f2f20bdba60a27d2b6d5b8a8 (diff)
Change the devhandle_from_*() functions to also take a "super handle",
from which the newly created handle will inherit it's implementation. The root implementation for a new handle type is used if an invalid "super handle" is passed.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/macppc/dev/gpio.c7
-rw-r--r--sys/arch/macppc/dev/mediabay.c7
-rw-r--r--sys/arch/macppc/dev/obio.c7
-rw-r--r--sys/arch/macppc/dev/smu.c3
-rw-r--r--sys/arch/macppc/dev/uni-n.c7
-rw-r--r--sys/arch/macppc/macppc/mainbus.c13
-rw-r--r--sys/arch/sparc/dev/bootbus.c7
-rw-r--r--sys/arch/sparc/dev/ebus.c7
-rw-r--r--sys/arch/sparc/dev/sbus.c9
-rw-r--r--sys/arch/sparc/include/promlib.h8
-rw-r--r--sys/arch/sparc/sparc/autoconf.c19
-rw-r--r--sys/arch/sparc/sparc/iommu.c10
-rw-r--r--sys/arch/sparc/sparc/promlib.c22
-rw-r--r--sys/arch/sparc64/dev/cbus.c5
-rw-r--r--sys/arch/sparc64/dev/central.c8
-rw-r--r--sys/arch/sparc64/dev/ebus.c8
-rw-r--r--sys/arch/sparc64/dev/ebus_mainbus.c8
-rw-r--r--sys/arch/sparc64/dev/fhc.c7
-rw-r--r--sys/arch/sparc64/dev/sbus.c7
-rw-r--r--sys/arch/sparc64/dev/upa.c7
-rw-r--r--sys/arch/sparc64/dev/vbus.c6
-rw-r--r--sys/arch/sparc64/sparc64/autoconf.c11
-rw-r--r--sys/arch/x86/x86/mpacpi.c7
-rw-r--r--sys/dev/acpi/acpi.c10
-rw-r--r--sys/dev/acpi/acpi_pci.c6
-rw-r--r--sys/dev/acpi/acpi_util.c23
-rw-r--r--sys/dev/acpi/acpi_util.h4
-rw-r--r--sys/dev/fdt/fdtbus.c12
-rw-r--r--sys/dev/i2c/i2c.c10
-rw-r--r--sys/dev/ofisa/ofisa.c7
-rw-r--r--sys/dev/ofw/ofbus.c12
-rw-r--r--sys/dev/ofw/ofw_pci_subr.c6
-rw-r--r--sys/dev/ofw/ofw_subr.c22
-rw-r--r--sys/dev/ofw/openfirm.h4
-rw-r--r--sys/dev/sbus/dma_sbus.c7
-rw-r--r--sys/dev/sbus/lebuffer.c7
-rw-r--r--sys/dev/sbus/qec.c7
37 files changed, 203 insertions, 134 deletions
diff --git a/sys/arch/macppc/dev/gpio.c b/sys/arch/macppc/dev/gpio.c
index 677cc0c3999..fd2abb47f7e 100644
--- a/sys/arch/macppc/dev/gpio.c
+++ b/sys/arch/macppc/dev/gpio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: gpio.c,v 1.15 2021/08/07 16:18:57 thorpej Exp $ */
+/* $NetBSD: gpio.c,v 1.16 2022/01/22 11:49:16 thorpej Exp $ */
/*-
* Copyright (C) 1998 Internet Research Institute, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.15 2021/08/07 16:18:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.16 2022/01/22 11:49:16 thorpej Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -97,6 +97,7 @@ gpio_obio_attach(device_t parent, device_t self, void *aux)
sc->sc_port = mapiodev(ca->ca_baseaddr + ca->ca_reg[0], ca->ca_reg[1],
false);
+ devhandle_t selfh = device_handle(self);
ca2.ca_baseaddr = ca->ca_baseaddr;
for (child = OF_child(ca->ca_node); child; child = OF_peer(child)) {
namelen = OF_getprop(child, "name", name, sizeof(name));
@@ -120,7 +121,7 @@ gpio_obio_attach(device_t parent, device_t self, void *aux)
ca2.ca_intr = intr;
config_found(self, &ca2, gpio_obio_print,
- CFARGS(.devhandle = devhandle_from_of(child)));
+ CFARGS(.devhandle = devhandle_from_of(selfh, child)));
}
}
diff --git a/sys/arch/macppc/dev/mediabay.c b/sys/arch/macppc/dev/mediabay.c
index 88da69bdaff..bb97e3be04b 100644
--- a/sys/arch/macppc/dev/mediabay.c
+++ b/sys/arch/macppc/dev/mediabay.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mediabay.c,v 1.26 2021/08/07 16:18:57 thorpej Exp $ */
+/* $NetBSD: mediabay.c,v 1.27 2022/01/22 11:49:16 thorpej Exp $ */
/*-
* Copyright (C) 1999 Tsubai Masanari. All rights reserved.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mediabay.c,v 1.26 2021/08/07 16:18:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mediabay.c,v 1.27 2022/01/22 11:49:16 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -225,6 +225,7 @@ mediabay_attach_content(struct mediabay_softc *sc)
printf(" done.\n");
}
+ devhandle_t selfh = device_handle(sc->sc_dev);
for (child = OF_child(sc->sc_node); child; child = OF_peer(child)) {
memset(name, 0, sizeof(name));
if (OF_getprop(child, "name", name, sizeof(name)) == -1)
@@ -244,7 +245,7 @@ mediabay_attach_content(struct mediabay_softc *sc)
ca.ca_intr = intr;
content = config_found(sc->sc_dev, &ca, mediabay_print,
- CFARGS(.devhandle = devhandle_from_of(child)));
+ CFARGS(.devhandle = devhandle_from_of(selfh, child)));
if (content) {
sc->sc_content = content;
return;
diff --git a/sys/arch/macppc/dev/obio.c b/sys/arch/macppc/dev/obio.c
index b1eb97856da..e186e50aa30 100644
--- a/sys/arch/macppc/dev/obio.c
+++ b/sys/arch/macppc/dev/obio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: obio.c,v 1.50 2021/08/07 16:18:57 thorpej Exp $ */
+/* $NetBSD: obio.c,v 1.51 2022/01/22 11:49:16 thorpej Exp $ */
/*-
* Copyright (C) 1998 Internet Research Institute, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.50 2021/08/07 16:18:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.51 2022/01/22 11:49:16 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -236,6 +236,7 @@ obio_attach(device_t parent, device_t self, void *aux)
bus_space_write_1(ca.ca_tag, bsh, 0x37, 0x03);
}
+ devhandle_t selfh = device_handle(self);
for (child = OF_child(node); child; child = OF_peer(child)) {
namelen = OF_getprop(child, "name", name, sizeof(name));
if (namelen < 0)
@@ -272,7 +273,7 @@ obio_attach(device_t parent, device_t self, void *aux)
ca.ca_intr = intr;
config_found(self, &ca, obio_print,
- CFARGS(.devhandle = devhandle_from_of(child)));
+ CFARGS(.devhandle = devhandle_from_of(selfh, child)));
}
}
diff --git a/sys/arch/macppc/dev/smu.c b/sys/arch/macppc/dev/smu.c
index cb0fb182bda..c190e06648b 100644
--- a/sys/arch/macppc/dev/smu.c
+++ b/sys/arch/macppc/dev/smu.c
@@ -365,6 +365,7 @@ smu_setup_iicbus(struct smu_softc *sc)
int node;
char name[32];
+ devhandle_t selfh = device_handle(sc->sc_dev);
node = of_getnode_byname(sc->sc_node, "smu-i2c-control");
if (node == 0) node = sc->sc_node;
for (node = OF_child(node);
@@ -393,7 +394,7 @@ smu_setup_iicbus(struct smu_softc *sc)
ca.ca_node = node;
ca.ca_tag = i2c;
config_found(sc->sc_dev, &ca, smu_iicbus_print,
- CFARGS(.devhandle = devhandle_from_of(node)));
+ CFARGS(.devhandle = devhandle_from_of(selfh, node)));
sc->sc_num_iicbus++;
}
diff --git a/sys/arch/macppc/dev/uni-n.c b/sys/arch/macppc/dev/uni-n.c
index 0c749fada3c..0ea58134598 100644
--- a/sys/arch/macppc/dev/uni-n.c
+++ b/sys/arch/macppc/dev/uni-n.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uni-n.c,v 1.11 2021/08/07 16:18:58 thorpej Exp $ */
+/* $NetBSD: uni-n.c,v 1.12 2022/01/22 11:49:16 thorpej Exp $ */
/*-
* Copyright (C) 2005 Michael Lorenz.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uni-n.c,v 1.11 2021/08/07 16:18:58 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uni-n.c,v 1.12 2022/01/22 11:49:16 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -129,6 +129,7 @@ uni_n_attach(device_t parent, device_t self, void *aux)
panic("Can't init uni-n mem tag");
}
+ devhandle_t selfh = device_handle(self);
for (child = OF_child(node); child; child = OF_peer(child)) {
namelen = OF_getprop(child, "name", name, sizeof(name));
if (namelen < 0)
@@ -150,7 +151,7 @@ uni_n_attach(device_t parent, device_t self, void *aux)
ca.ca_reg = reg;
ca.ca_intr = intr;
config_found(self, &ca, uni_n_print,
- CFARGS(.devhandle = devhandle_from_of(child)));
+ CFARGS(.devhandle = devhandle_from_of(selfh, child)));
}
}
diff --git a/sys/arch/macppc/macppc/mainbus.c b/sys/arch/macppc/macppc/mainbus.c
index 0efc3d372b5..88bb1257ffc 100644
--- a/sys/arch/macppc/macppc/mainbus.c
+++ b/sys/arch/macppc/macppc/mainbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mainbus.c,v 1.24 2021/08/07 16:18:58 thorpej Exp $ */
+/* $NetBSD: mainbus.c,v 1.25 2022/01/22 11:49:16 thorpej Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.24 2021/08/07 16:18:58 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.25 2022/01/22 11:49:16 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -73,6 +73,8 @@ mainbus_attach(device_t parent, device_t self, void *aux)
printf("\n");
+ devhandle_t selfh = device_handle(self);
+
cpus = OF_finddevice("/cpus");
if (cpus != 0) {
node = OF_child(cpus);
@@ -81,7 +83,8 @@ mainbus_attach(device_t parent, device_t self, void *aux)
ca.ca_reg = reg;
ca.ca_nreg = OF_getprop(node, "reg", reg, sizeof(reg));
config_found(self, &ca, NULL,
- CFARGS(.devhandle = devhandle_from_of(node)));
+ CFARGS(.devhandle = devhandle_from_of(selfh,
+ node)));
node = OF_peer(node);
}
} else {
@@ -100,7 +103,7 @@ mainbus_attach(device_t parent, device_t self, void *aux)
oba.oba_busname = "ofw";
oba.oba_phandle = node;
config_found(self, &oba, NULL,
- CFARGS(.devhandle = devhandle_from_of(node)));
+ CFARGS(.devhandle = devhandle_from_of(selfh, node)));
}
for (node = OF_child(OF_finddevice("/")); node; node = OF_peer(node)) {
@@ -113,7 +116,7 @@ mainbus_attach(device_t parent, device_t self, void *aux)
ca.ca_nreg = OF_getprop(node, "reg", reg, sizeof(reg));
ca.ca_reg = reg;
config_found(self, &ca, NULL,
- CFARGS(.devhandle = devhandle_from_of(node)));
+ CFARGS(.devhandle = devhandle_from_of(selfh, node)));
}
#ifdef MAMBO
diff --git a/sys/arch/sparc/dev/bootbus.c b/sys/arch/sparc/dev/bootbus.c
index 56303465f67..95ab3cf71c5 100644
--- a/sys/arch/sparc/dev/bootbus.c
+++ b/sys/arch/sparc/dev/bootbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bootbus.c,v 1.23 2021/08/07 16:19:05 thorpej Exp $ */
+/* $NetBSD: bootbus.c,v 1.24 2022/01/22 11:49:16 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bootbus.c,v 1.23 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bootbus.c,v 1.24 2022/01/22 11:49:16 thorpej Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
@@ -115,6 +115,7 @@ bootbus_attach(device_t parent, device_t self, void *aux)
}
/* Attach the CPU (and possibly bootbus) child nodes. */
+ devhandle_t selfh = device_handle(self);
for (node = firstchild(sc->sc_node); node != 0;
node = nextsibling(node)) {
struct bootbus_attach_args baa;
@@ -123,7 +124,7 @@ bootbus_attach(device_t parent, device_t self, void *aux)
panic("bootbus_attach: failed to set up attach args");
config_found(self, &baa, bootbus_print,
- CFARGS(.devhandle = prom_node_to_devhandle(node),
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node),
.submatch = bootbus_submatch));
bootbus_destroy_attach_args(&baa);
diff --git a/sys/arch/sparc/dev/ebus.c b/sys/arch/sparc/dev/ebus.c
index e1bd3e7ff68..a2623f67487 100644
--- a/sys/arch/sparc/dev/ebus.c
+++ b/sys/arch/sparc/dev/ebus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ebus.c,v 1.41 2021/08/07 16:19:05 thorpej Exp $ */
+/* $NetBSD: ebus.c,v 1.42 2022/01/22 11:49:16 thorpej Exp $ */
/*
* Copyright (c) 1999, 2000 Matthew R. Green
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.41 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.42 2022/01/22 11:49:16 thorpej Exp $");
#if defined(DEBUG) && !defined(EBUS_DEBUG)
#define EBUS_DEBUG
@@ -307,6 +307,7 @@ ebus_attach(device_t parent, device_t self, void *aux)
* now attach all our children
*/
DPRINTF(EDB_CHILD, ("ebus node %08x, searching children...\n", node));
+ devhandle_t selfh = device_handle(self);
for (node = firstchild(node); node; node = nextsibling(node)) {
char *name = prom_getpropstring(node, "name");
@@ -317,7 +318,7 @@ ebus_attach(device_t parent, device_t self, void *aux)
DPRINTF(EDB_CHILD,
("- found child `%s', attaching\n", ea.ea_name));
(void)config_found(self, &ea, ebus_print,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node)));
ebus_destroy_attach_args(&ea);
}
}
diff --git a/sys/arch/sparc/dev/sbus.c b/sys/arch/sparc/dev/sbus.c
index 385d3c1c0ab..dd0163c2c2a 100644
--- a/sys/arch/sparc/dev/sbus.c
+++ b/sys/arch/sparc/dev/sbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sbus.c,v 1.83 2021/08/07 16:19:05 thorpej Exp $ */
+/* $NetBSD: sbus.c,v 1.84 2022/01/22 11:49:16 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.83 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.84 2022/01/22 11:49:16 thorpej Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
@@ -352,6 +352,7 @@ sbus_attach_common(struct sbus_softc *sc, const char *busname, int busnode,
const char *const *ssp;
bus_space_tag_t sbt;
struct sbus_attach_args sa;
+ devhandle_t selfh = device_handle(sc->sc_dev);
if ((sbt = bus_space_tag_alloc(sc->sc_bustag, sc)) == NULL) {
printf("%s: attach: out of memory\n",
@@ -413,7 +414,7 @@ sbus_attach_common(struct sbus_softc *sc, const char *busname, int busnode,
panic("sbus_attach: %s: incomplete", sp);
}
(void) config_found(sc->sc_dev, (void *)&sa, sbus_print,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node)));
sbus_destroy_attach_args(&sa);
}
@@ -435,7 +436,7 @@ sbus_attach_common(struct sbus_softc *sc, const char *busname, int busnode,
continue;
}
(void) config_found(sc->sc_dev, (void *)&sa, sbus_print,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node)));
sbus_destroy_attach_args(&sa);
}
}
diff --git a/sys/arch/sparc/include/promlib.h b/sys/arch/sparc/include/promlib.h
index 38a08d9c8b6..cf42b841f3f 100644
--- a/sys/arch/sparc/include/promlib.h
+++ b/sys/arch/sparc/include/promlib.h
@@ -1,4 +1,4 @@
-/* $NetBSD: promlib.h,v 1.26 2021/05/10 13:59:30 thorpej Exp $ */
+/* $NetBSD: promlib.h,v 1.27 2022/01/22 11:49:16 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -113,7 +113,7 @@ struct promops {
int (*po_finddevice)(const char *);
/* devhandle_t interface */
- devhandle_t (*po_node_to_devhandle)(int);
+ devhandle_t (*po_node_to_devhandle)(devhandle_t, int);
int (*po_devhandle_to_node)(devhandle_t);
};
@@ -217,8 +217,8 @@ void prom_boot(char *) __attribute__((__noreturn__));
#define prom_getproplen(node,name) prom_proplen(node, name)
/* devhandle_t interface */
-#define prom_node_to_devhandle(n) ((*promops.po_node_to_devhandle)(n))
-#define prom_devhandle_to_node(dh) ((*promops.po_devhandle_to_node)(dh))
+#define prom_node_to_devhandle(s, n) ((*promops.po_node_to_devhandle)((s), (n)))
+#define prom_devhandle_to_node(dh) ((*promops.po_devhandle_to_node)(dh))
/* MP stuff - not currently used */
#define prom_cpustart(m,a,c,pc) ((*promops.po_cpustart)(m,a,c,pc))
diff --git a/sys/arch/sparc/sparc/autoconf.c b/sys/arch/sparc/sparc/autoconf.c
index 6d07f39d8c5..65e468f5d87 100644
--- a/sys/arch/sparc/sparc/autoconf.c
+++ b/sys/arch/sparc/sparc/autoconf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.269 2021/08/07 16:19:05 thorpej Exp $ */
+/* $NetBSD: autoconf.c,v 1.270 2022/01/22 11:49:16 thorpej Exp $ */
/*
* Copyright (c) 1996
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.269 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.270 2022/01/22 11:49:16 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -1243,6 +1243,7 @@ mainbus_attach(device_t parent, device_t dev, void *aux)
* The rest of this routine is for OBP machines exclusively.
*/
#if defined(SUN4C) || defined(SUN4M) || defined(SUN4D)
+ devhandle_t selfh = device_handle(dev);
if (CPU_ISSUN4D)
openboot_special = openboot_special4d;
@@ -1286,7 +1287,8 @@ mainbus_attach(device_t parent, device_t dev, void *aux)
ma.ma_node = node;
ma.ma_name = "cpu";
config_found(dev, (void *)&ma, mbprint,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh,
+ node)));
if (node == bootnode && bootmid != 0) {
/* Re-enter loop to find all remaining CPUs */
goto rescan;
@@ -1299,7 +1301,8 @@ mainbus_attach(device_t parent, device_t dev, void *aux)
ma.ma_node = findroot();
ma.ma_name = "cpu";
config_found(dev, (void *)&ma, mbprint,
- CFARGS(.devhandle = prom_node_to_devhandle(ma.ma_node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh,
+ ma.ma_node)));
}
for (ssp = openboot_special; (sp = ssp->dev) != NULL; ssp++) {
@@ -1331,7 +1334,8 @@ mainbus_attach(device_t parent, device_t dev, void *aux)
if (config_found(dev, (void *)&ma, mbprint,
CFARGS(.devhandle =
- prom_node_to_devhandle(node))) == NULL) {
+ prom_node_to_devhandle(selfh,
+ node))) == NULL) {
if (ssp->flags & BS_OPTIONAL) continue;
panic("%s", sp);
}
@@ -1391,7 +1395,8 @@ mainbus_attach(device_t parent, device_t dev, void *aux)
ma.ma_promvaddr = 0;
config_found(dev, (void *)&ma, mbprint,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh,
+ node)));
continue;
}
#endif /* SUN4M */
@@ -1409,7 +1414,7 @@ mainbus_attach(device_t parent, device_t dev, void *aux)
continue;
config_found(dev, (void *)&ma, mbprint,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node)));
}
#endif /* SUN4C || SUN4M || SUN4D */
}
diff --git a/sys/arch/sparc/sparc/iommu.c b/sys/arch/sparc/sparc/iommu.c
index af59ba11ba6..5ecb57790af 100644
--- a/sys/arch/sparc/sparc/iommu.c
+++ b/sys/arch/sparc/sparc/iommu.c
@@ -1,4 +1,4 @@
-/* $NetBSD: iommu.c,v 1.100 2021/08/09 21:08:06 andvar Exp $ */
+/* $NetBSD: iommu.c,v 1.101 2022/01/22 11:49:16 thorpej Exp $ */
/*
* Copyright (c) 1996
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.100 2021/08/09 21:08:06 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.101 2022/01/22 11:49:16 thorpej Exp $");
#include "opt_sparc_arch.h"
@@ -278,6 +278,8 @@ iommu_attach(device_t parent, device_t self, void *aux)
IOMMU_DVMA_BASE, IOMMU_DVMA_END,
0, 0, EX_WAITOK);
+ devhandle_t selfh = device_handle(self);
+
/*
* If we are attaching implicit iommu on JS1/OF we do not have
* an iommu node to traverse, instead mainbus_attach passed us
@@ -299,7 +301,7 @@ iommu_attach(device_t parent, device_t self, void *aux)
ia.iom_nreg = 1;
config_found(self, (void *)&ia, iommu_print,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node)));
return;
}
@@ -323,7 +325,7 @@ iommu_attach(device_t parent, device_t self, void *aux)
&ia.iom_nreg, &ia.iom_reg);
config_found(self, (void *)&ia, iommu_print,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node)));
if (ia.iom_reg != NULL)
free(ia.iom_reg, M_DEVBUF);
}
diff --git a/sys/arch/sparc/sparc/promlib.c b/sys/arch/sparc/sparc/promlib.c
index 44ffd01d2a4..1e1bae6479e 100644
--- a/sys/arch/sparc/sparc/promlib.c
+++ b/sys/arch/sparc/sparc/promlib.c
@@ -1,4 +1,4 @@
-/* $NetBSD: promlib.c,v 1.51 2022/01/21 15:55:36 thorpej Exp $ */
+/* $NetBSD: promlib.c,v 1.52 2022/01/22 11:49:16 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.51 2022/01/21 15:55:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.52 2022/01/22 11:49:16 thorpej Exp $");
#if defined(_KERNEL_OPT)
#include "opt_sparc_arch.h"
@@ -239,12 +239,18 @@ static const struct devhandle_impl obp_devhandle_impl = {
};
static devhandle_t
-devhandle_from_obp(int node)
+devhandle_from_obp(devhandle_t super_handle, int node)
{
- devhandle_t handle = {
- .impl = &obp_devhandle_impl,
- .integer = node,
- };
+ devhandle_type_t super_type = devhandle_type(super_handle);
+ devhandle_t handle = { 0 };
+
+ if (super_type == DEVHANDLE_TYPE_OPENBOOT) {
+ handle.impl = super_handle.impl;
+ } else {
+ KASSERT(super_type == DEVHANDLE_TYPE_INVALID);
+ handle.impl = &obp_devhandle_impl;
+ }
+ handle.integer = node;
return handle;
}
@@ -265,7 +271,7 @@ obp_device_enumerate_children(device_t dev, devhandle_t call_handle, void *v)
for (node = prom_firstchild(node); node != 0;
node = prom_nextsibling(node)) {
- if (!args->callback(dev, devhandle_from_obp(node),
+ if (!args->callback(dev, devhandle_from_obp(call_handle, node),
args->callback_arg)) {
break;
}
diff --git a/sys/arch/sparc64/dev/cbus.c b/sys/arch/sparc64/dev/cbus.c
index 7863a29fac7..a7b11f70b1a 100644
--- a/sys/arch/sparc64/dev/cbus.c
+++ b/sys/arch/sparc64/dev/cbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cbus.c,v 1.7 2021/08/07 16:19:05 thorpej Exp $ */
+/* $NetBSD: cbus.c,v 1.8 2022/01/22 11:49:17 thorpej Exp $ */
/* $OpenBSD: cbus.c,v 1.15 2015/09/27 11:29:20 kettenis Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis
@@ -101,6 +101,7 @@ cbus_attach(device_t parent, device_t self, void *aux)
return;
}
+ devhandle_t selfh = device_handle(self);
for (node = OF_child(va->va_node); node; node = OF_peer(node)) {
struct cbus_attach_args ca;
char buf[32];
@@ -122,7 +123,7 @@ cbus_attach(device_t parent, device_t self, void *aux)
}
config_found(self, &ca, cbus_print,
- CFARGS(.devhandle = devhandle_from_of(ca.ca_node)));
+ CFARGS(.devhandle = devhandle_from_of(selfh, ca.ca_node)));
}
}
diff --git a/sys/arch/sparc64/dev/central.c b/sys/arch/sparc64/dev/central.c
index 38c47fa798f..e372f0da6f4 100644
--- a/sys/arch/sparc64/dev/central.c
+++ b/sys/arch/sparc64/dev/central.c
@@ -1,4 +1,4 @@
-/* $NetBSD: central.c,v 1.8 2021/08/07 16:19:05 thorpej Exp $ */
+/* $NetBSD: central.c,v 1.9 2022/01/22 11:49:17 thorpej Exp $ */
/* $OpenBSD: central.c,v 1.7 2010/11/11 17:58:23 miod Exp $ */
/*
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: central.c,v 1.8 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: central.c,v 1.9 2022/01/22 11:49:17 thorpej Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -97,6 +97,7 @@ central_attach(device_t parent, device_t self, void *aux)
printf("\n");
+ devhandle_t selfh = device_handle(self);
node0 = firstchild(sc->sc_node);
for (node = node0; node; node = nextsibling(node)) {
struct central_attach_args ca;
@@ -113,7 +114,8 @@ central_attach(device_t parent, device_t self, void *aux)
&ca.ca_nreg, (void **)&ca.ca_reg);
(void)config_found(self, (void *)&ca, central_print,
- CFARGS(.devhandle = prom_node_to_devhandle(ca.ca_node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh,
+ ca.ca_node)));
if (ca.ca_name != NULL)
free(ca.ca_name, M_DEVBUF);
diff --git a/sys/arch/sparc64/dev/ebus.c b/sys/arch/sparc64/dev/ebus.c
index 2e32d869f04..3bab9df7f36 100644
--- a/sys/arch/sparc64/dev/ebus.c
+++ b/sys/arch/sparc64/dev/ebus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ebus.c,v 1.68 2021/08/07 16:19:05 thorpej Exp $ */
+/* $NetBSD: ebus.c,v 1.69 2022/01/22 11:49:17 thorpej Exp $ */
/*
* Copyright (c) 1999, 2000, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.68 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.69 2022/01/22 11:49:17 thorpej Exp $");
#include "opt_ddb.h"
@@ -204,6 +204,7 @@ ebus_attach(device_t parent, device_t self, void *aux)
* now attach all our children
*/
DPRINTF(EDB_CHILD, ("ebus node %08x, searching children...\n", node));
+ devhandle_t selfh = device_handle(self);
for (node = firstchild(node); node; node = nextsibling(node)) {
char *name = prom_getpropstring(node, "name");
@@ -214,7 +215,8 @@ ebus_attach(device_t parent, device_t self, void *aux)
DPRINTF(EDB_CHILD, ("- found child `%s', attaching\n",
eba.ea_name));
(void)config_found(self, &eba, ebus_print,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh,
+ node)));
}
ebus_destroy_attach_args(&eba);
}
diff --git a/sys/arch/sparc64/dev/ebus_mainbus.c b/sys/arch/sparc64/dev/ebus_mainbus.c
index 1f9f27c00bd..35d1b5d0ee2 100644
--- a/sys/arch/sparc64/dev/ebus_mainbus.c
+++ b/sys/arch/sparc64/dev/ebus_mainbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ebus_mainbus.c,v 1.21 2021/08/07 16:19:05 thorpej Exp $ */
+/* $NetBSD: ebus_mainbus.c,v 1.22 2022/01/22 11:49:17 thorpej Exp $ */
/* $OpenBSD: ebus_mainbus.c,v 1.7 2010/11/11 17:58:23 miod Exp $ */
/*
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ebus_mainbus.c,v 1.21 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ebus_mainbus.c,v 1.22 2022/01/22 11:49:17 thorpej Exp $");
#ifdef DEBUG
#define EDB_PROM 0x01
@@ -164,6 +164,7 @@ ebus_mainbus_attach(device_t parent, device_t self, void *aux)
* now attach all our children
*/
DPRINTF(EDB_CHILD, ("ebus node %08x, searching children...\n", node));
+ devhandle_t selfh = device_handle(self);
for (node = firstchild(node); node; node = nextsibling(node)) {
if (ebus_setup_attach_args(sc, node, &eba) != 0) {
DPRINTF(EDB_CHILD,
@@ -174,7 +175,8 @@ ebus_mainbus_attach(device_t parent, device_t self, void *aux)
DPRINTF(EDB_CHILD, ("- found child `%s', attaching\n",
eba.ea_name));
(void)config_found(self, &eba, ebus_print,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh,
+ node)));
}
ebus_destroy_attach_args(&eba);
}
diff --git a/sys/arch/sparc64/dev/fhc.c b/sys/arch/sparc64/dev/fhc.c
index c22d2adbe73..6923b1e0cb4 100644
--- a/sys/arch/sparc64/dev/fhc.c
+++ b/sys/arch/sparc64/dev/fhc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fhc.c,v 1.10 2021/08/07 16:19:05 thorpej Exp $ */
+/* $NetBSD: fhc.c,v 1.11 2022/01/22 11:49:17 thorpej Exp $ */
/* $OpenBSD: fhc.c,v 1.17 2010/11/11 17:58:23 miod Exp $ */
/*
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fhc.c,v 1.10 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fhc.c,v 1.11 2022/01/22 11:49:17 thorpej Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -91,6 +91,7 @@ fhc_attach(struct fhc_softc *sc)
prom_getprop(sc->sc_node, "ranges", sizeof(struct fhc_range),
&sc->sc_nrange, (void **)&sc->sc_range);
+ devhandle_t selfh = device_handle(sc->sc_dev);
node0 = firstchild(sc->sc_node);
for (node = node0; node; node = nextsibling(node)) {
struct fhc_attach_args fa;
@@ -117,7 +118,7 @@ fhc_attach(struct fhc_softc *sc)
&fa.fa_npromvaddrs, (void **)&fa.fa_promvaddrs);
(void)config_found(sc->sc_dev, (void *)&fa, fhc_print,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node)));
if (fa.fa_name != NULL)
free(fa.fa_name, M_DEVBUF);
diff --git a/sys/arch/sparc64/dev/sbus.c b/sys/arch/sparc64/dev/sbus.c
index 3fcfc69f551..cbc86a7d010 100644
--- a/sys/arch/sparc64/dev/sbus.c
+++ b/sys/arch/sparc64/dev/sbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sbus.c,v 1.103 2021/08/07 16:19:05 thorpej Exp $ */
+/* $NetBSD: sbus.c,v 1.104 2022/01/22 11:49:17 thorpej Exp $ */
/*
* Copyright (c) 1999-2002 Eduardo Horvath
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.103 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.104 2022/01/22 11:49:17 thorpej Exp $");
#include "opt_ddb.h"
@@ -284,6 +284,7 @@ sbus_attach(device_t parent, device_t self, void *aux)
* `specials' is an array of device names that are treated
* specially:
*/
+ devhandle_t selfh = device_handle(self);
node0 = OF_child(node);
for (node = node0; node; node = OF_peer(node)) {
char *name1 = prom_getpropstring(node, "name");
@@ -294,7 +295,7 @@ sbus_attach(device_t parent, device_t self, void *aux)
continue;
}
(void) config_found(self, &sa, sbus_print,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node)));
sbus_destroy_attach_args(&sa);
}
}
diff --git a/sys/arch/sparc64/dev/upa.c b/sys/arch/sparc64/dev/upa.c
index a01a939d3b4..2399d6676d8 100644
--- a/sys/arch/sparc64/dev/upa.c
+++ b/sys/arch/sparc64/dev/upa.c
@@ -1,4 +1,4 @@
-/* $NetBSD: upa.c,v 1.23 2021/08/07 16:19:05 thorpej Exp $ */
+/* $NetBSD: upa.c,v 1.24 2022/01/22 11:49:17 thorpej Exp $ */
/* $OpenBSD: upa.c,v 1.8 2008/01/17 22:53:18 kettenis Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: upa.c,v 1.23 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: upa.c,v 1.24 2022/01/22 11:49:17 thorpej Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -116,6 +116,7 @@ upa_attach(device_t parent, device_t self, void *aux)
sc->sc_cbt = upa_alloc_bus_tag(sc);
+ devhandle_t selfh = device_handle(sc->sc_dev);
for (node = OF_child(sc->sc_node); node; node = OF_peer(node)) {
char buf[32];
struct mainbus_attach_args map;
@@ -133,7 +134,7 @@ upa_attach(device_t parent, device_t self, void *aux)
map.ma_bustag = sc->sc_cbt;
map.ma_dmatag = ma->ma_dmatag;
config_found(sc->sc_dev, &map, upa_print,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node)));
}
}
diff --git a/sys/arch/sparc64/dev/vbus.c b/sys/arch/sparc64/dev/vbus.c
index f6e73a05f9a..e354458b56b 100644
--- a/sys/arch/sparc64/dev/vbus.c
+++ b/sys/arch/sparc64/dev/vbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vbus.c,v 1.8 2021/08/07 16:19:05 thorpej Exp $ */
+/* $NetBSD: vbus.c,v 1.9 2022/01/22 11:49:17 thorpej Exp $ */
/* $OpenBSD: vbus.c,v 1.8 2015/09/27 11:29:20 kettenis Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis
@@ -81,6 +81,7 @@ vbus_attach(device_t parent, device_t self, void *aux)
sc->sc_dmatag = ma->ma_dmatag;
printf("\n");
+ devhandle_t selfh = device_handle(self);
for (node = OF_child(ma->ma_node); node; node = OF_peer(node)) {
struct vbus_attach_args va;
char buf[32];
@@ -97,7 +98,8 @@ vbus_attach(device_t parent, device_t self, void *aux)
prom_getprop(node, "interrupts", sizeof(*va.va_intr),
&va.va_nintr, (void **)&va.va_intr);
config_found(self, &va, vbus_print,
- CFARGS(.devhandle = prom_node_to_devhandle(va.va_node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh,
+ va.va_node)));
}
struct vbus_attach_args va;
diff --git a/sys/arch/sparc64/sparc64/autoconf.c b/sys/arch/sparc64/sparc64/autoconf.c
index 42fc4ae05cc..283df2dd2e9 100644
--- a/sys/arch/sparc64/sparc64/autoconf.c
+++ b/sys/arch/sparc64/sparc64/autoconf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.237 2021/10/04 21:02:39 andvar Exp $ */
+/* $NetBSD: autoconf.c,v 1.238 2022/01/22 11:49:17 thorpej Exp $ */
/*
* Copyright (c) 1996
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.237 2021/10/04 21:02:39 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.238 2022/01/22 11:49:17 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -701,6 +701,8 @@ extern struct sparc_bus_space_tag mainbus_space_tag;
aprint_normal(": %s: hostid %lx\n", machine_model, hostid);
aprint_naive("\n");
+ devhandle_t selfh = device_handle(dev);
+
/*
* Locate and configure the ``early'' devices. These must be
* configured before we can do the rest. For instance, the
@@ -730,7 +732,7 @@ extern struct sparc_bus_space_tag mainbus_space_tag;
ma.ma_node = node;
ma.ma_name = "cpu";
config_found(dev, &ma, mbprint,
- CFARGS(.devhandle = devhandle_from_of(ma.ma_node)));
+ CFARGS(.devhandle = devhandle_from_of(selfh, ma.ma_node)));
}
node = findroot(); /* re-init root node */
@@ -814,7 +816,8 @@ extern struct sparc_bus_space_tag mainbus_space_tag;
}
#endif
(void) config_found(dev, (void *)&ma, mbprint,
- CFARGS(.devhandle = prom_node_to_devhandle(ma.ma_node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh,
+ ma.ma_node)));
free(ma.ma_reg, M_DEVBUF);
if (ma.ma_ninterrupts)
free(ma.ma_interrupts, M_DEVBUF);
diff --git a/sys/arch/x86/x86/mpacpi.c b/sys/arch/x86/x86/mpacpi.c
index 5ab576c648a..1d2b7c459b4 100644
--- a/sys/arch/x86/x86/mpacpi.c
+++ b/sys/arch/x86/x86/mpacpi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mpacpi.c,v 1.108 2021/10/07 12:52:27 msaitoh Exp $ */
+/* $NetBSD: mpacpi.c,v 1.109 2022/01/22 11:49:17 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.108 2021/10/07 12:52:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.109 2022/01/22 11:49:17 thorpej Exp $");
#include "acpica.h"
#include "opt_acpi.h"
@@ -506,7 +506,8 @@ mpacpi_pci_foundbus(struct acpi_devnode *ad)
}
mpr = kmem_zalloc(sizeof(struct mpacpi_pcibus), KM_SLEEP);
- mpr->mpr_devhandle = devhandle_from_acpi(ad->ad_handle);
+ mpr->mpr_devhandle =
+ devhandle_from_acpi(devhandle_invalid(), ad->ad_handle);
mpr->mpr_buf = buf;
mpr->mpr_seg = ad->ad_pciinfo->ap_segment;
mpr->mpr_bus = ad->ad_pciinfo->ap_downbus;
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index d018fdda109..3d955d536d4 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi.c,v 1.295 2021/12/31 14:22:42 riastradh Exp $ */
+/* $NetBSD: acpi.c,v 1.296 2022/01/22 11:49:17 thorpej Exp $ */
/*-
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -100,7 +100,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.295 2021/12/31 14:22:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.296 2022/01/22 11:49:17 thorpej Exp $");
#include "pci.h"
#include "opt_acpi.h"
@@ -962,7 +962,8 @@ acpi_rescan_early(struct acpi_softc *sc)
ad->ad_device = config_found(sc->sc_dev, &aa, acpi_print,
CFARGS(.iattr = "acpinodebus",
- .devhandle = devhandle_from_acpi(ad->ad_handle)));
+ .devhandle = devhandle_from_acpi(devhandle_invalid(),
+ ad->ad_handle)));
}
}
@@ -1029,7 +1030,8 @@ acpi_rescan_nodes(struct acpi_softc *sc)
ad->ad_device = config_found(sc->sc_dev, &aa, acpi_print,
CFARGS(.iattr = "acpinodebus",
- .devhandle = devhandle_from_acpi(ad->ad_handle)));
+ .devhandle = devhandle_from_acpi(devhandle_invalid(),
+ ad->ad_handle)));
}
}
diff --git a/sys/dev/acpi/acpi_pci.c b/sys/dev/acpi/acpi_pci.c
index e8be8114d58..83a2e152afd 100644
--- a/sys/dev/acpi/acpi_pci.c
+++ b/sys/dev/acpi/acpi_pci.c
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.c,v 1.33 2021/12/20 11:17:40 skrll Exp $ */
+/* $NetBSD: acpi_pci.c,v 1.34 2022/01/22 11:49:17 thorpej Exp $ */
/*
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.33 2021/12/20 11:17:40 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.34 2022/01/22 11:49:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -572,7 +572,7 @@ acpi_pci_bus_get_child_devhandle(device_t dev, devhandle_t call_handle, void *v)
if (ad != NULL && (hdl = ad->ad_handle) != NULL) {
/* Found it! */
- args->devhandle = devhandle_from_acpi(hdl);
+ args->devhandle = devhandle_from_acpi(call_handle, hdl);
return 0;
}
diff --git a/sys/dev/acpi/acpi_util.c b/sys/dev/acpi/acpi_util.c
index a1087fbcfce..674d9f9132c 100644
--- a/sys/dev/acpi/acpi_util.c
+++ b/sys/dev/acpi/acpi_util.c
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_util.c,v 1.31 2022/01/15 14:40:22 jmcneill Exp $ */
+/* $NetBSD: acpi_util.c,v 1.32 2022/01/22 11:49:17 thorpej Exp $ */
/*-
* Copyright (c) 2003, 2007, 2021 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.31 2022/01/15 14:40:22 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.32 2022/01/22 11:49:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -121,12 +121,18 @@ static const struct devhandle_impl acpi_devhandle_impl = {
};
devhandle_t
-devhandle_from_acpi(ACPI_HANDLE const hdl)
+devhandle_from_acpi(devhandle_t super_handle, ACPI_HANDLE const hdl)
{
- devhandle_t handle = {
- .impl = &acpi_devhandle_impl,
- .pointer = hdl,
- };
+ devhandle_type_t super_type = devhandle_type(super_handle);
+ devhandle_t handle = { 0 };
+
+ if (super_type == DEVHANDLE_TYPE_ACPI) {
+ handle.impl = super_handle.impl;
+ } else {
+ KASSERT(super_type == DEVHANDLE_TYPE_INVALID);
+ handle.impl = &acpi_devhandle_impl;
+ }
+ handle.pointer = hdl;
return handle;
}
@@ -154,7 +160,8 @@ acpi_device_enumerate_children(device_t dev, devhandle_t call_handle, void *v)
!acpi_device_present(ad->ad_handle)) {
continue;
}
- if (!args->callback(dev, devhandle_from_acpi(ad->ad_handle),
+ if (!args->callback(dev, devhandle_from_acpi(call_handle,
+ ad->ad_handle),
args->callback_arg)) {
break;
}
diff --git a/sys/dev/acpi/acpi_util.h b/sys/dev/acpi/acpi_util.h
index 74b8db97bbf..0659d21299c 100644
--- a/sys/dev/acpi/acpi_util.h
+++ b/sys/dev/acpi/acpi_util.h
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_util.h,v 1.13 2022/01/15 14:40:33 jmcneill Exp $ */
+/* $NetBSD: acpi_util.h,v 1.14 2022/01/22 11:49:17 thorpej Exp $ */
/*-
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
#ifndef _SYS_DEV_ACPI_ACPI_UTIL_H
#define _SYS_DEV_ACPI_ACPI_UTIL_H
-devhandle_t devhandle_from_acpi(ACPI_HANDLE);
+devhandle_t devhandle_from_acpi(devhandle_t, ACPI_HANDLE);
ACPI_HANDLE devhandle_to_acpi(devhandle_t);
#define ACPI_DEVICE_CALL_REGISTER(_n_, _c_) \
diff --git a/sys/dev/fdt/fdtbus.c b/sys/dev/fdt/fdtbus.c
index c9e2a2e83d6..86879f63c14 100644
--- a/sys/dev/fdt/fdtbus.c
+++ b/sys/dev/fdt/fdtbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtbus.c,v 1.44 2021/11/07 17:12:15 jmcneill Exp $ */
+/* $NetBSD: fdtbus.c,v 1.45 2022/01/22 11:49:17 thorpej Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.44 2021/11/07 17:12:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.45 2022/01/22 11:49:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -423,12 +423,15 @@ fdt_scan(struct fdt_softc *sc, int pass)
*/
fdt_pre_attach(node);
+ devhandle_t nodeh = device_handle(node->n_bus);
+
if (quiet) {
node->n_dev = config_attach(node->n_bus, node->n_cf,
&faa, fdtbus_print,
CFARGS(.locators = locs,
.devhandle =
- devhandle_from_of(node->n_phandle)));
+ devhandle_from_of(nodeh,
+ node->n_phandle)));
} else {
/*
* Default pass.
@@ -439,7 +442,8 @@ fdt_scan(struct fdt_softc *sc, int pass)
.iattr = "fdt",
.locators = locs,
.devhandle =
- devhandle_from_of(node->n_phandle)));
+ devhandle_from_of(nodeh,
+ node->n_phandle)));
}
if (node->n_dev != NULL)
diff --git a/sys/dev/i2c/i2c.c b/sys/dev/i2c/i2c.c
index c6ef68e2019..f31abc9b4a9 100644
--- a/sys/dev/i2c/i2c.c
+++ b/sys/dev/i2c/i2c.c
@@ -1,4 +1,4 @@
-/* $NetBSD: i2c.c,v 1.82 2022/01/21 15:55:36 thorpej Exp $ */
+/* $NetBSD: i2c.c,v 1.83 2022/01/22 11:49:17 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -53,7 +53,7 @@
#endif /* _KERNEL_OPT */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.82 2022/01/21 15:55:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.83 2022/01/22 11:49:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -498,13 +498,15 @@ iic_attach(device_t parent, device_t self, void *aux)
devhandle = devhandle_invalid();
#ifdef I2C_USE_FDT
if (cookietype == I2C_COOKIE_OF) {
- devhandle = devhandle_from_of((int)cookie);
+ devhandle = devhandle_from_of(devhandle,
+ (int)cookie);
}
#endif /* I2C_USE_FDT */
#ifdef I2C_USE_ACPI
if (cookietype == I2C_COOKIE_ACPI) {
devhandle =
- devhandle_from_acpi((ACPI_HANDLE)cookie);
+ devhandle_from_acpi(devhandle,
+ (ACPI_HANDLE)cookie);
}
#endif /* I2C_USE_ACPI */
diff --git a/sys/dev/ofisa/ofisa.c b/sys/dev/ofisa/ofisa.c
index f2bbf204613..cc9045522cd 100644
--- a/sys/dev/ofisa/ofisa.c
+++ b/sys/dev/ofisa/ofisa.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ofisa.c,v 1.34 2021/08/07 16:19:13 thorpej Exp $ */
+/* $NetBSD: ofisa.c,v 1.35 2022/01/22 11:49:17 thorpej Exp $ */
/*
* Copyright 1997, 1998
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofisa.c,v 1.34 2021/08/07 16:19:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofisa.c,v 1.35 2022/01/22 11:49:17 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -127,6 +127,7 @@ ofisaattach(device_t parent, device_t self, void *aux)
isa_dmainit(iba.iba_ic, iba.iba_iot, iba.iba_dmat, self);
#endif
+ devhandle_t selfh = device_handle(self);
for (child = OF_child(oba->oba_phandle); child;
child = OF_peer(child)) {
if (ofisa_ignore_child(oba->oba_phandle, child))
@@ -142,7 +143,7 @@ ofisaattach(device_t parent, device_t self, void *aux)
aa.ic = iba.iba_ic;
config_found(self, &aa, ofisaprint,
- CFARGS(.devhandle = devhandle_from_of(child)));
+ CFARGS(.devhandle = devhandle_from_of(selfh, child)));
}
}
diff --git a/sys/dev/ofw/ofbus.c b/sys/dev/ofw/ofbus.c
index dfb07dcf003..2abf8f9341c 100644
--- a/sys/dev/ofw/ofbus.c
+++ b/sys/dev/ofw/ofbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ofbus.c,v 1.30 2021/08/07 16:19:14 thorpej Exp $ */
+/* $NetBSD: ofbus.c,v 1.31 2022/01/22 11:49:18 thorpej Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofbus.c,v 1.30 2021/08/07 16:19:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofbus.c,v 1.31 2022/01/22 11:49:18 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -159,6 +159,8 @@ ofbus_attach(device_t parent, device_t dev, void *aux)
units = 2;
}
+ devhandle_t selfh = device_handle(dev);
+
/* attach displays first */
for (child = OF_child(oba->oba_phandle); child != 0;
child = OF_peer(child)) {
@@ -181,7 +183,8 @@ ofbus_attach(device_t parent, device_t dev, void *aux)
sizeof(oba2.oba_ofname));
}
config_found(dev, &oba2, ofbus_print,
- CFARGS(.devhandle = devhandle_from_of(child)));
+ CFARGS(.devhandle = devhandle_from_of(selfh,
+ child)));
}
}
@@ -211,7 +214,8 @@ ofbus_attach(device_t parent, device_t dev, void *aux)
sizeof(oba2.oba_ofname));
}
config_found(dev, &oba2, ofbus_print,
- CFARGS(.devhandle = devhandle_from_of(child)));
+ CFARGS(.devhandle = devhandle_from_of(selfh,
+ child)));
}
}
}
diff --git a/sys/dev/ofw/ofw_pci_subr.c b/sys/dev/ofw/ofw_pci_subr.c
index 0671befc1e6..f658e79bff8 100644
--- a/sys/dev/ofw/ofw_pci_subr.c
+++ b/sys/dev/ofw/ofw_pci_subr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_pci_subr.c,v 1.2 2021/09/15 17:33:08 thorpej Exp $ */
+/* $NetBSD: ofw_pci_subr.c,v 1.3 2022/01/22 11:49:18 thorpej Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_pci_subr.c,v 1.2 2021/09/15 17:33:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_pci_subr.c,v 1.3 2022/01/22 11:49:18 thorpej Exp $");
#include <sys/types.h>
#include <sys/device.h>
@@ -77,7 +77,7 @@ ofw_pci_bus_get_child_devhandle(device_t dev, devhandle_t call_handle, void *v)
}
/* Found it! */
- args->devhandle = devhandle_from_of(phandle);
+ args->devhandle = devhandle_from_of(call_handle, phandle);
return 0;
}
diff --git a/sys/dev/ofw/ofw_subr.c b/sys/dev/ofw/ofw_subr.c
index 01cbed6fd44..e0532a5ad8d 100644
--- a/sys/dev/ofw/ofw_subr.c
+++ b/sys/dev/ofw/ofw_subr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_subr.c,v 1.59 2021/09/15 17:33:08 thorpej Exp $ */
+/* $NetBSD: ofw_subr.c,v 1.60 2022/01/22 11:49:18 thorpej Exp $ */
/*
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.59 2021/09/15 17:33:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.60 2022/01/22 11:49:18 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -99,12 +99,18 @@ static const struct devhandle_impl of_devhandle_impl = {
};
devhandle_t
-devhandle_from_of(int phandle)
+devhandle_from_of(devhandle_t super_handle, int phandle)
{
- devhandle_t handle = {
- .impl = &of_devhandle_impl,
- .integer = phandle,
- };
+ devhandle_type_t super_type = devhandle_type(super_handle);
+ devhandle_t handle = { 0 };
+
+ if (super_type == DEVHANDLE_TYPE_OF) {
+ handle.impl = super_handle.impl;
+ } else {
+ KASSERT(super_type == DEVHANDLE_TYPE_INVALID);
+ handle.impl = &of_devhandle_impl;
+ }
+ handle.integer = phandle;
return handle;
}
@@ -125,7 +131,7 @@ of_device_enumerate_children(device_t dev, devhandle_t call_handle, void *v)
int child;
for (child = OF_child(phandle); child != 0; child = OF_peer(child)) {
- if (!args->callback(dev, devhandle_from_of(child),
+ if (!args->callback(dev, devhandle_from_of(call_handle, child),
args->callback_arg)) {
break;
}
diff --git a/sys/dev/ofw/openfirm.h b/sys/dev/ofw/openfirm.h
index 34eee8e53bc..55733c08483 100644
--- a/sys/dev/ofw/openfirm.h
+++ b/sys/dev/ofw/openfirm.h
@@ -1,4 +1,4 @@
-/* $NetBSD: openfirm.h,v 1.47 2021/04/24 23:36:57 thorpej Exp $ */
+/* $NetBSD: openfirm.h,v 1.48 2022/01/22 11:49:18 thorpej Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -107,7 +107,7 @@ int openfirmware(void *);
#ifdef _KERNEL
struct device_compatible_entry;
-devhandle_t devhandle_from_of(int);
+devhandle_t devhandle_from_of(devhandle_t, int);
int devhandle_to_of(devhandle_t);
#define OF_DEVICE_CALL_REGISTER(_n_, _c_) \
diff --git a/sys/dev/sbus/dma_sbus.c b/sys/dev/sbus/dma_sbus.c
index 56fdca53073..6efd00de826 100644
--- a/sys/dev/sbus/dma_sbus.c
+++ b/sys/dev/sbus/dma_sbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dma_sbus.c,v 1.38 2021/08/07 16:19:15 thorpej Exp $ */
+/* $NetBSD: dma_sbus.c,v 1.39 2022/01/22 11:49:18 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dma_sbus.c,v 1.38 2021/08/07 16:19:15 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dma_sbus.c,v 1.39 2022/01/22 11:49:18 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -207,11 +207,12 @@ dmaattach_sbus(device_t parent, device_t self, void *aux)
lsi64854_attach(sc);
/* Attach children */
+ devhandle_t selfh = device_handle(self);
for (node = firstchild(sa->sa_node); node; node = nextsibling(node)) {
struct sbus_attach_args sax;
sbus_setup_attach_args(sbsc, sbt, sc->sc_dmatag, node, &sax);
(void)config_found(self, (void *)&sax, dmaprint_sbus,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node)));
sbus_destroy_attach_args(&sax);
}
}
diff --git a/sys/dev/sbus/lebuffer.c b/sys/dev/sbus/lebuffer.c
index 7bfc7c22297..0630927e3f1 100644
--- a/sys/dev/sbus/lebuffer.c
+++ b/sys/dev/sbus/lebuffer.c
@@ -1,4 +1,4 @@
-/* $NetBSD: lebuffer.c,v 1.39 2021/08/07 16:19:15 thorpej Exp $ */
+/* $NetBSD: lebuffer.c,v 1.40 2022/01/22 11:49:18 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lebuffer.c,v 1.39 2021/08/07 16:19:15 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lebuffer.c,v 1.40 2022/01/22 11:49:18 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -120,12 +120,13 @@ lebufattach(device_t parent, device_t self, void *aux)
printf(": %dK memory\n", sc->sc_bufsiz / 1024);
/* search through children */
+ devhandle_t selfh = device_handle(self);
for (node = firstchild(node); node; node = nextsibling(node)) {
struct sbus_attach_args sax;
sbus_setup_attach_args(sbsc,
bt, dt, node, &sax);
(void)config_found(self, (void *)&sax, lebufprint,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node)));
sbus_destroy_attach_args(&sax);
}
}
diff --git a/sys/dev/sbus/qec.c b/sys/dev/sbus/qec.c
index 2842343bb56..bcff50b1600 100644
--- a/sys/dev/sbus/qec.c
+++ b/sys/dev/sbus/qec.c
@@ -1,4 +1,4 @@
-/* $NetBSD: qec.c,v 1.53 2021/08/07 16:19:15 thorpej Exp $ */
+/* $NetBSD: qec.c,v 1.54 2022/01/22 11:49:18 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: qec.c,v 1.53 2021/08/07 16:19:15 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: qec.c,v 1.54 2022/01/22 11:49:18 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -203,12 +203,13 @@ qecattach(device_t parent, device_t self, void *aux)
qec_init(sc);
/* search through children */
+ devhandle_t selfh = device_handle(self);
for (node = firstchild(node); node; node = nextsibling(node)) {
struct sbus_attach_args sax;
sbus_setup_attach_args(sbsc,
sbt, sc->sc_dmatag, node, &sax);
(void)config_found(self, (void *)&sax, qecprint,
- CFARGS(.devhandle = prom_node_to_devhandle(node)));
+ CFARGS(.devhandle = prom_node_to_devhandle(selfh, node)));
sbus_destroy_attach_args(&sax);
}
}