Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Adjust the device_call() calling convention so as to...
details: https://anonhg.NetBSD.org/src/rev/58de4e40c13d
branches: trunk
changeset: 1023572:58de4e40c13d
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Sep 15 17:33:08 2021 +0000
description:
Adjust the device_call() calling convention so as to provide type checking
of the arguments passed to the call, using auto-generated argument
structures and binding macros.
diffstat:
sys/arch/sparc/sparc/promlib.c | 8 ++-
sys/dev/acpi/acpi_pci.c | 8 ++-
sys/dev/acpi/acpi_util.c | 8 ++-
sys/dev/ofw/ofw_pci_subr.c | 7 +-
sys/dev/ofw/ofw_subr.c | 9 ++-
sys/dev/pci/Makefile | 8 +++-
sys/dev/pci/pci.c | 9 ++-
sys/dev/pci/pci_calls.h | 90 ++++++++++++++++++++++++++++++++++++++++++
sys/dev/pci/pcivar.h | 27 +------------
sys/kern/subr_device.c | 14 +++--
sys/sys/Makefile | 8 +++-
sys/sys/device.h | 25 +++++------
sys/sys/device_calls.h | 78 ++++++++++++++++++++++++++++++++++++
13 files changed, 233 insertions(+), 66 deletions(-)
diffs (truncated from 563 to 300 lines):
diff -r 3a9741732d40 -r 58de4e40c13d sys/arch/sparc/sparc/promlib.c
--- a/sys/arch/sparc/sparc/promlib.c Wed Sep 15 17:26:06 2021 +0000
+++ b/sys/arch/sparc/sparc/promlib.c Wed Sep 15 17:33:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: promlib.c,v 1.48 2021/05/10 13:59:30 thorpej Exp $ */
+/* $NetBSD: promlib.c,v 1.49 2021/09/15 17:33:08 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.48 2021/05/10 13:59:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.49 2021/09/15 17:33:08 thorpej Exp $");
#if defined(_KERNEL_OPT)
#include "opt_sparc_arch.h"
@@ -45,6 +45,8 @@
#include <sys/kernel.h>
#include <sys/device.h>
+#include <sys/device_calls.h>
+
#ifdef _STANDALONE
#include <lib/libsa/stand.h>
#define malloc(s,t,f) alloc(s)
@@ -276,7 +278,7 @@
return 0;
}
-OBP_DEVICE_CALL_REGISTER("device-enumerate-children",
+OBP_DEVICE_CALL_REGISTER(DEVICE_ENUMERATE_CHILDREN_STR,
obp_device_enumerate_children)
#endif /* ! _STANDALONE */
diff -r 3a9741732d40 -r 58de4e40c13d sys/dev/acpi/acpi_pci.c
--- a/sys/dev/acpi/acpi_pci.c Wed Sep 15 17:26:06 2021 +0000
+++ b/sys/dev/acpi/acpi_pci.c Wed Sep 15 17:33:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.c,v 1.31 2021/05/12 23:22:33 thorpej Exp $ */
+/* $NetBSD: acpi_pci.c,v 1.32 2021/09/15 17:33:08 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.31 2021/05/12 23:22:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.32 2021/09/15 17:33:08 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -41,6 +41,8 @@
#include <dev/pci/pcidevs.h>
#include <dev/pci/ppbreg.h>
+#include <dev/pci/pci_calls.h>
+
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
#include <dev/acpi/acpi_pci.h>
@@ -576,5 +578,5 @@
return ENODEV;
}
-ACPI_DEVICE_CALL_REGISTER("pci-bus-get-child-devhandle",
+ACPI_DEVICE_CALL_REGISTER(PCI_BUS_GET_CHILD_DEVHANDLE_STR,
acpi_pci_bus_get_child_devhandle)
diff -r 3a9741732d40 -r 58de4e40c13d sys/dev/acpi/acpi_util.c
--- a/sys/dev/acpi/acpi_util.c Wed Sep 15 17:26:06 2021 +0000
+++ b/sys/dev/acpi/acpi_util.c Wed Sep 15 17:33:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_util.c,v 1.25 2021/08/09 20:49:09 andvar Exp $ */
+/* $NetBSD: acpi_util.c,v 1.26 2021/09/15 17:33:08 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.25 2021/08/09 20:49:09 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.26 2021/09/15 17:33:08 thorpej Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -75,6 +75,8 @@
#include <dev/acpi/acpivar.h>
#include <dev/acpi/acpi_intr.h>
+#include <sys/device_calls.h>
+
#include <machine/acpi_machdep.h>
#define _COMPONENT ACPI_BUS_COMPONENT
@@ -153,7 +155,7 @@
return 0;
}
-ACPI_DEVICE_CALL_REGISTER("device-enumerate-children",
+ACPI_DEVICE_CALL_REGISTER(DEVICE_ENUMERATE_CHILDREN_STR,
acpi_device_enumerate_children)
/*
diff -r 3a9741732d40 -r 58de4e40c13d sys/dev/ofw/ofw_pci_subr.c
--- a/sys/dev/ofw/ofw_pci_subr.c Wed Sep 15 17:26:06 2021 +0000
+++ b/sys/dev/ofw/ofw_pci_subr.c Wed Sep 15 17:33:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_pci_subr.c,v 1.1 2021/05/12 23:22:33 thorpej Exp $ */
+/* $NetBSD: ofw_pci_subr.c,v 1.2 2021/09/15 17:33:08 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.1 2021/05/12 23:22:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_pci_subr.c,v 1.2 2021/09/15 17:33:08 thorpej Exp $");
#include <sys/types.h>
#include <sys/device.h>
@@ -38,6 +38,7 @@
#include <sys/errno.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/pci_calls.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_pci.h>
@@ -82,5 +83,5 @@
return ENODEV;
}
-OF_DEVICE_CALL_REGISTER("pci-bus-get-child-devhandle",
+OF_DEVICE_CALL_REGISTER(PCI_BUS_GET_CHILD_DEVHANDLE_STR,
ofw_pci_bus_get_child_devhandle)
diff -r 3a9741732d40 -r 58de4e40c13d sys/dev/ofw/ofw_subr.c
--- a/sys/dev/ofw/ofw_subr.c Wed Sep 15 17:26:06 2021 +0000
+++ b/sys/dev/ofw/ofw_subr.c Wed Sep 15 17:33:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_subr.c,v 1.58 2021/04/24 23:36:57 thorpej Exp $ */
+/* $NetBSD: ofw_subr.c,v 1.59 2021/09/15 17:33:08 thorpej Exp $ */
/*
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -60,12 +60,15 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.58 2021/04/24 23:36:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.59 2021/09/15 17:33:08 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/kmem.h>
#include <sys/systm.h>
+
+#include <sys/device_calls.h>
+
#include <dev/ofw/openfirm.h>
#define OFW_MAX_STACK_BUF_SIZE 256
@@ -130,7 +133,7 @@
return 0;
}
-OF_DEVICE_CALL_REGISTER("device-enumerate-children",
+OF_DEVICE_CALL_REGISTER(DEVICE_ENUMERATE_CHILDREN_STR,
of_device_enumerate_children)
/*
diff -r 3a9741732d40 -r 58de4e40c13d sys/dev/pci/Makefile
--- a/sys/dev/pci/Makefile Wed Sep 15 17:26:06 2021 +0000
+++ b/sys/dev/pci/Makefile Wed Sep 15 17:33:08 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.15 2018/12/12 07:04:05 maxv Exp $
+# $NetBSD: Makefile,v 1.16 2021/09/15 17:33:08 thorpej Exp $
# use 'make -f Makefile.pcidevs' to make pcidevs.h and pcidevs_data.h
@@ -9,4 +9,10 @@
pcidevs.h pcidevs_data.h pciio.h pcireg.h \
tgareg.h twereg.h tweio.h
+pci_calls.h: ${.CURDIR}/pci_calls
+ echo "${TOOL_AWK} -f ${.CURDIR}/../../kern/gendevcalls.awk \
+ ${.CURDIR}/pci_calls > ${.CURDIR}/pci_calls.h"
+ ${TOOL_AWK} -f ${.CURDIR}/../../kern/gendevcalls.awk \
+ ${.CURDIR}/pci_calls > ${.CURDIR}/pci_calls.h
+
.include <bsd.kinc.mk>
diff -r 3a9741732d40 -r 58de4e40c13d sys/dev/pci/pci.c
--- a/sys/dev/pci/pci.c Wed Sep 15 17:26:06 2021 +0000
+++ b/sys/dev/pci/pci.c Wed Sep 15 17:33:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci.c,v 1.161 2021/08/07 16:19:14 thorpej Exp $ */
+/* $NetBSD: pci.c,v 1.162 2021/09/15 17:33:08 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.161 2021/08/07 16:19:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.162 2021/09/15 17:33:08 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_pci.h"
@@ -53,6 +53,8 @@
#include <dev/pci/pcidevs.h>
#include <dev/pci/ppbvar.h>
+#include <dev/pci/pci_calls.h>
+
#include <net/if.h>
#include "locators.h"
@@ -275,8 +277,7 @@
.tag = tag,
};
- if (device_call(sc->sc_dev, "pci-bus-get-child-devhandle",
- &args) != 0) {
+ if (device_call(sc->sc_dev, PCI_BUS_GET_CHILD_DEVHANDLE(&args)) != 0) {
/*
* The call is either not supported or the requested
* device was not found in the platform device tree.
diff -r 3a9741732d40 -r 58de4e40c13d sys/dev/pci/pci_calls.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/pci_calls.h Wed Sep 15 17:33:08 2021 +0000
@@ -0,0 +1,90 @@
+/* $NetBSD: pci_calls.h,v 1.1 2021/09/15 17:33:08 thorpej Exp $ */
+
+/*
+ * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
+ *
+ * generated from:
+ * NetBSD: pci_calls,v 1.1 2021/09/15 17:26:07 thorpej Exp
+ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Device calls used by the PCI subsystem.
+ */
+
+#ifndef _PCI_CALLS_H_
+#define _PCI_CALLS_H_
+
+#include <sys/device.h>
+
+#include <dev/pci/pcivar.h>
+
+/*
+ * pci-bus-get-child-devhandle
+ *
+ * Retrieve the devhandle for the PCI device represented by 'tag'
+ * in the PCI segment represented by 'pc'. The PCI bus's device_t
+ * is the one that's passed in the call, and the device whose handle
+ * is being requested must be a direct child of that bus, otherwise
+ * behavior is undefined.
+ *
+ * Call returns 0 if successful, or an error code upon failure:
+ *
+ * ENOTSUP The device handle implementation for the
+ * PCI bus does not support this device call.
+ *
+ * ENODEV The PCI device represented by the pcitag_t
+ * was not found in a bus-scoped search of the
Home |
Main Index |
Thread Index |
Old Index