From f06ffda24307372cdf9724883f8b78e76ba141cc Mon Sep 17 00:00:00 2001 From: nwhitehorn Date: Sun, 5 Jan 2014 18:46:58 +0000 Subject: [PATCH] Retire machine/fdt.h as a header used by MI code, as its function is now obsolete. This involves the following pieces: - Remove it entirely on PowerPC, where it is not used by MD code either - Remove all references to machine/fdt.h in non-architecture-specific code (aside from uart_cpu_fdt.c, shared by ARM and MIPS, and so is somewhat non-arch-specific). - Fix code relying on header pollution from machine/fdt.h includes - Legacy fdtbus.c (still used on x86 FDT systems) now passes resource requests to its parent (nexus). This allows x86 FDT devices to allocate both memory and IO requests and removes the last notionally MI use of fdtbus_bs_tag. - On those architectures that retain a machine/fdt.h, unused bits like FDT_MAP_IRQ and FDT_INTR_MAX have been removed. --- sys/arm/arm/machdep.c | 1 + sys/arm/include/fdt.h | 5 ----- sys/arm/include/ofw_machdep.h | 7 ++++++ sys/arm/mv/mv_machdep.c | 1 + sys/arm/mv/mv_pci.c | 1 + sys/dev/fdt/fdt_common.c | 1 - sys/dev/fdt/fdt_common.h | 1 - sys/dev/fdt/fdt_pci.c | 4 +++- sys/dev/fdt/fdtbus.c | 41 ++--------------------------------- sys/dev/fdt/simplebus.c | 2 -- sys/dev/uart/uart_bus_fdt.c | 1 - sys/mips/include/fdt.h | 11 ---------- sys/powerpc/include/fdt.h | 41 ----------------------------------- sys/x86/include/fdt.h | 18 --------------- sys/x86/include/ofw_machdep.h | 6 +++++ 15 files changed, 21 insertions(+), 120 deletions(-) delete mode 100644 sys/powerpc/include/fdt.h diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c index 00a3820efd25..c48933d2c68c 100644 --- a/sys/arm/arm/machdep.c +++ b/sys/arm/arm/machdep.c @@ -92,6 +92,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/arm/include/fdt.h b/sys/arm/include/fdt.h index 0be9927d9bed..3785f97b8d73 100644 --- a/sys/arm/include/fdt.h +++ b/sys/arm/include/fdt.h @@ -51,11 +51,6 @@ */ extern bus_space_tag_t fdtbus_bs_tag; -struct mem_region { - vm_offset_t mr_start; - vm_size_t mr_size; -}; - struct arm_devmap_entry; int fdt_localbus_devmap(phandle_t, struct arm_devmap_entry *, int, int *); diff --git a/sys/arm/include/ofw_machdep.h b/sys/arm/include/ofw_machdep.h index 11797da415d7..d6bd57628584 100644 --- a/sys/arm/include/ofw_machdep.h +++ b/sys/arm/include/ofw_machdep.h @@ -32,6 +32,13 @@ #ifndef _MACHINE_OFW_MACHDEP_H_ #define _MACHINE_OFW_MACHDEP_H_ +#include + typedef uint32_t cell_t; +struct mem_region { + vm_offset_t mr_start; + vm_size_t mr_size; +}; + #endif /* _MACHINE_OFW_MACHDEP_H_ */ diff --git a/sys/arm/mv/mv_machdep.c b/sys/arm/mv/mv_machdep.c index 6fb6db6bc045..5b2fbe7321fd 100644 --- a/sys/arm/mv/mv_machdep.c +++ b/sys/arm/mv/mv_machdep.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include /* XXX */ diff --git a/sys/arm/mv/mv_pci.c b/sys/arm/mv/mv_pci.c index ff129744ce19..597e1b6f4589 100644 --- a/sys/arm/mv/mv_pci.c +++ b/sys/arm/mv/mv_pci.c @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c index 62330942b557..9d6840cae5f4 100644 --- a/sys/dev/fdt/fdt_common.c +++ b/sys/dev/fdt/fdt_common.c @@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include diff --git a/sys/dev/fdt/fdt_common.h b/sys/dev/fdt/fdt_common.h index f3f9b07a4023..e8e274f9f29f 100644 --- a/sys/dev/fdt/fdt_common.h +++ b/sys/dev/fdt/fdt_common.h @@ -35,7 +35,6 @@ #include #include #include -#include #define FDT_MEM_REGIONS 8 diff --git a/sys/dev/fdt/fdt_pci.c b/sys/dev/fdt/fdt_pci.c index d4f4b6c170a3..207b70651e52 100644 --- a/sys/dev/fdt/fdt_pci.c +++ b/sys/dev/fdt/fdt_pci.c @@ -41,9 +41,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include #if defined(__arm__) +#include +#include #include +#include #endif #include "ofw_bus_if.h" diff --git a/sys/dev/fdt/fdtbus.c b/sys/dev/fdt/fdtbus.c index 3a6659a6e7d5..a0ebec8e0c85 100644 --- a/sys/dev/fdt/fdtbus.c +++ b/sys/dev/fdt/fdtbus.c @@ -39,8 +39,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include - #include #include @@ -52,11 +50,6 @@ __FBSDID("$FreeBSD$"); static void fdtbus_identify(driver_t *, device_t); static int fdtbus_probe(device_t); -static int fdtbus_activate_resource(device_t, device_t, int, int, - struct resource *); -static int fdtbus_deactivate_resource(device_t, device_t, int, int, - struct resource *); - /* * Bus interface definition. */ @@ -66,8 +59,8 @@ static device_method_t fdtbus_methods[] = { DEVMETHOD(device_probe, fdtbus_probe), /* Bus interface */ - DEVMETHOD(bus_activate_resource, fdtbus_activate_resource), - DEVMETHOD(bus_deactivate_resource, fdtbus_deactivate_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_config_intr, bus_generic_config_intr), DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), @@ -96,33 +89,3 @@ fdtbus_probe(device_t dev) return (BUS_PROBE_NOWILDCARD); } -static int -fdtbus_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - bus_space_handle_t p; - int error; - - if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { - /* XXX endianess should be set based on SOC node */ - rman_set_bustag(res, fdtbus_bs_tag); - rman_set_bushandle(res, rman_get_start(res)); - - error = bus_space_map(rman_get_bustag(res), - rman_get_bushandle(res), rman_get_size(res), 0, &p); - if (error) - return (error); - rman_set_bushandle(res, p); - } - - return (rman_activate_resource(res)); -} - -static int -fdtbus_deactivate_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - - return (rman_deactivate_resource(res)); -} - diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index 5ed145ff5afa..b0f8fee203b2 100644 --- a/sys/dev/fdt/simplebus.c +++ b/sys/dev/fdt/simplebus.c @@ -40,8 +40,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include - #include #include #include diff --git a/sys/dev/uart/uart_bus_fdt.c b/sys/dev/uart/uart_bus_fdt.c index 259ab85d58d2..a98c50af4e10 100644 --- a/sys/dev/uart/uart_bus_fdt.c +++ b/sys/dev/uart/uart_bus_fdt.c @@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include diff --git a/sys/mips/include/fdt.h b/sys/mips/include/fdt.h index 2f1fda5c5cfd..72cc4850db66 100644 --- a/sys/mips/include/fdt.h +++ b/sys/mips/include/fdt.h @@ -33,17 +33,6 @@ #define _MACHINE_FDT_H_ #include -#include - -/* Max interrupt number */ -#if defined(CPU_RMI) || defined(CPU_NLM) -#define FDT_INTR_MAX XLR_MAX_INTR -#else -#define FDT_INTR_MAX (NHARD_IRQS + NSOFT_IRQS) -#endif - -/* Map phandle/intpin pair to global IRQ number */ -#define FDT_MAP_IRQ(node, pin) (pin) /* * Bus space tag. XXX endianess info needs to be derived from the blob. diff --git a/sys/powerpc/include/fdt.h b/sys/powerpc/include/fdt.h deleted file mode 100644 index 955e3c7303c9..000000000000 --- a/sys/powerpc/include/fdt.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 2010 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Semihalf under sponsorship from - * the FreeBSD Foundation. - * - * 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 AUTHOR 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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_FDT_H_ -#define _MACHINE_FDT_H_ - -#include -#include - -/* Map phandle/intpin pair to global IRQ number */ -#define FDT_MAP_IRQ(node, pin) powerpc_get_irq(node, pin) - -#endif /* _MACHINE_FDT_H_ */ diff --git a/sys/x86/include/fdt.h b/sys/x86/include/fdt.h index 77a0a2f2b167..b25cacb280a5 100644 --- a/sys/x86/include/fdt.h +++ b/sys/x86/include/fdt.h @@ -29,24 +29,6 @@ #ifndef _MACHINE_FDT_H_ #define _MACHINE_FDT_H_ -#include -#include - -/* Max interrupt number. */ -#define FDT_INTR_MAX NUM_IO_INTS - -/* Map phandle/intpin pair to global IRQ number */ -#define FDT_MAP_IRQ(node, pin) \ - (panic("%s: FDT_MAP_IRQ(%#x, %#x)", __func__, node, pin), -1) - -/* Bus space tag. XXX we only support I/O port space this way. */ -#define fdtbus_bs_tag X86_BUS_SPACE_IO - -struct mem_region { - vm_offset_t mr_start; - vm_size_t mr_size; -}; - __BEGIN_DECLS int x86_init_fdt(void); __END_DECLS diff --git a/sys/x86/include/ofw_machdep.h b/sys/x86/include/ofw_machdep.h index 13e756e07b1c..8344f56d65a9 100644 --- a/sys/x86/include/ofw_machdep.h +++ b/sys/x86/include/ofw_machdep.h @@ -30,7 +30,13 @@ #define _MACHINE_OFW_MACHDEP_H_ #include +#include typedef uint32_t cell_t; +struct mem_region { + vm_offset_t mr_start; + vm_size_t mr_size; +}; + #endif /* _MACHINE_OFW_MACHDEP_H_ */