diff options
| author | thorpej <thorpej@NetBSD.org> | 2021-04-24 23:36:23 +0000 |
|---|---|---|
| committer | thorpej <thorpej@NetBSD.org> | 2021-04-24 23:36:23 +0000 |
| commit | 3bee0c110b9ff2a9a0e2833be339e1c873af3a44 (patch) | |
| tree | 82c9f34b9867882723e76eff95e5d7ca6cab69bf /sys/arch/evbppc | |
| parent | e77b3a7c4b6598de68d8b78f86e7851410840595 (diff) | |
Merge thorpej-cfargs branch:
Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.
Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)
Remove unnecessary or redundant interface attributes where they're not
needed.
There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)
...and a sentinel value CFARG_EOL.
Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.
Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
Diffstat (limited to 'sys/arch/evbppc')
| -rw-r--r-- | sys/arch/evbppc/conf/files.pmppc | 4 | ||||
| -rw-r--r-- | sys/arch/evbppc/ev64260/mainbus.c | 10 | ||||
| -rw-r--r-- | sys/arch/evbppc/explora/dev/elb.c | 6 | ||||
| -rw-r--r-- | sys/arch/evbppc/explora/dev/fb_elb.c | 6 | ||||
| -rw-r--r-- | sys/arch/evbppc/mpc85xx/autoconf.c | 6 | ||||
| -rw-r--r-- | sys/arch/evbppc/pmppc/mainbus.c | 23 | ||||
| -rw-r--r-- | sys/arch/evbppc/virtex/autoconf.c | 6 | ||||
| -rw-r--r-- | sys/arch/evbppc/virtex/design_gsrd1.c | 8 | ||||
| -rw-r--r-- | sys/arch/evbppc/virtex/design_gsrd2.c | 8 | ||||
| -rw-r--r-- | sys/arch/evbppc/virtex/dev/tft.c | 6 | ||||
| -rw-r--r-- | sys/arch/evbppc/walnut/dev/pbus.c | 10 |
11 files changed, 51 insertions, 42 deletions
diff --git a/sys/arch/evbppc/conf/files.pmppc b/sys/arch/evbppc/conf/files.pmppc index 684b1db1a63..0902cc65d85 100644 --- a/sys/arch/evbppc/conf/files.pmppc +++ b/sys/arch/evbppc/conf/files.pmppc @@ -1,4 +1,4 @@ -# $NetBSD: files.pmppc,v 1.7 2017/02/18 05:08:47 rin Exp $ +# $NetBSD: files.pmppc,v 1.8 2021/04/24 23:36:36 thorpej Exp $ # # maxpartitions 16 @@ -32,7 +32,7 @@ file dev/md_root.c memory_disk_hooks # System bus types # define mainbus { [addr=-1], [irq=-1] } -device mainbus: mainbus, pcibus +device mainbus: mainbus attach mainbus at root device cpu attach cpu at mainbus diff --git a/sys/arch/evbppc/ev64260/mainbus.c b/sys/arch/evbppc/ev64260/mainbus.c index fce0601141c..37151916912 100644 --- a/sys/arch/evbppc/ev64260/mainbus.c +++ b/sys/arch/evbppc/ev64260/mainbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.7 2011/06/05 17:03:18 matt Exp $ */ +/* $NetBSD: mainbus.c,v 1.8 2021/04/24 23:36:36 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.7 2011/06/05 17:03:18 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.8 2021/04/24 23:36:36 thorpej Exp $"); #include "mainbus.h" #include "opt_multiprocessor.h" @@ -86,7 +86,7 @@ mainbus_attach(device_t parent, device_t self, void *aux) mba.mba_name = "cpu"; mba.mba_unit = 0; mba.mba_addr = MAINBUSCF_ADDR_DEFAULT; - config_found(self, &mba, mainbus_cfprint); + config_found(self, &mba, mainbus_cfprint, CFARG_EOL); #ifdef MULTIPROCESSOR /* @@ -95,7 +95,7 @@ mainbus_attach(device_t parent, device_t self, void *aux) mba.mba_name = "cpu"; mba.mba_unit = 1; mba.mba_addr = MAINBUSCF_ADDR_DEFAULT; - config_found(self, &mba, mainbus_cfprint); + config_found(self, &mba, mainbus_cfprint, CFARG_EOL); #endif /* @@ -104,7 +104,7 @@ mainbus_attach(device_t parent, device_t self, void *aux) mba.mba_name = "gt"; mba.mba_unit = -1; mba.mba_addr = gt_base; - config_found(self, &mba, mainbus_cfprint); + config_found(self, &mba, mainbus_cfprint, CFARG_EOL); } int diff --git a/sys/arch/evbppc/explora/dev/elb.c b/sys/arch/evbppc/explora/dev/elb.c index dff7047d4c8..e8ba9cea384 100644 --- a/sys/arch/evbppc/explora/dev/elb.c +++ b/sys/arch/evbppc/explora/dev/elb.c @@ -1,4 +1,4 @@ -/* $NetBSD: elb.c,v 1.9 2011/07/01 19:02:32 dyoung Exp $ */ +/* $NetBSD: elb.c,v 1.10 2021/04/24 23:36:36 thorpej Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: elb.c,v 1.9 2011/07/01 19:02:32 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: elb.c,v 1.10 2021/04/24 23:36:36 thorpej Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -141,7 +141,7 @@ elb_attach(device_t parent, device_t self, void *aux) eaa.elb_base2 = elb->elb_addr2; eaa.elb_irq = elb->elb_irq; - (void) config_found(self, &eaa, elb_print); + (void) config_found(self, &eaa, elb_print, CFARG_EOL); } } diff --git a/sys/arch/evbppc/explora/dev/fb_elb.c b/sys/arch/evbppc/explora/dev/fb_elb.c index e10871b7f00..c82173cb11e 100644 --- a/sys/arch/evbppc/explora/dev/fb_elb.c +++ b/sys/arch/evbppc/explora/dev/fb_elb.c @@ -1,4 +1,4 @@ -/* $NetBSD: fb_elb.c,v 1.18 2021/03/07 10:33:07 rin Exp $ */ +/* $NetBSD: fb_elb.c,v 1.19 2021/04/24 23:36:36 thorpej Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fb_elb.c,v 1.18 2021/03/07 10:33:07 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fb_elb.c,v 1.19 2021/04/24 23:36:36 thorpej Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -214,7 +214,7 @@ fb_elb_attach(device_t parent, device_t self, void *aux) waa.accessops = &accessops; waa.accesscookie = sc; - config_found(self, &waa, wsemuldisplaydevprint); + config_found(self, &waa, wsemuldisplaydevprint, CFARG_EOL); } static void diff --git a/sys/arch/evbppc/mpc85xx/autoconf.c b/sys/arch/evbppc/mpc85xx/autoconf.c index 885c71430ed..5189b47389c 100644 --- a/sys/arch/evbppc/mpc85xx/autoconf.c +++ b/sys/arch/evbppc/mpc85xx/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.9 2014/03/18 18:20:41 riastradh Exp $ */ +/* $NetBSD: autoconf.c,v 1.10 2021/04/24 23:36:36 thorpej Exp $ */ /*- * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.9 2014/03/18 18:20:41 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.10 2021/04/24 23:36:36 thorpej Exp $"); #define __INTR_PRIVATE @@ -156,7 +156,7 @@ mainbus_attach(device_t parent, device_t self, void *aux) ma.ma_le_memt = curcpu()->ci_softc->cpu_le_bst; ma.ma_dmat = &booke_bus_dma_tag; - config_found_sm_loc(self, "mainbus", NULL, &ma, mainbus_print, NULL); + config_found(self, &ma, mainbus_print, CFARG_EOL); } CFATTACH_DECL_NEW(mainbus, 0, mainbus_match, mainbus_attach, NULL, NULL); diff --git a/sys/arch/evbppc/pmppc/mainbus.c b/sys/arch/evbppc/pmppc/mainbus.c index aa9ab39ed5e..19711af012b 100644 --- a/sys/arch/evbppc/pmppc/mainbus.c +++ b/sys/arch/evbppc/pmppc/mainbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.6 2011/07/01 19:03:08 dyoung Exp $ */ +/* $NetBSD: mainbus.c,v 1.7 2021/04/24 23:36:36 thorpej Exp $ */ /* * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.6 2011/07/01 19:03:08 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.7 2021/04/24 23:36:36 thorpej Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -115,22 +115,24 @@ mainbus_attach(device_t parent, device_t self, void *aux) maa.mb_name = "cpu"; maa.mb_addr = MAINBUSCF_ADDR_DEFAULT; maa.mb_irq = MAINBUSCF_IRQ_DEFAULT; - config_found(self, &maa, mainbus_print); + config_found(self, &maa, mainbus_print, CFARG_EOL); if (a_config.a_has_rtc) { maa.mb_name = "rtc"; maa.mb_addr = PMPPC_RTC; maa.mb_irq = PMPPC_I_RTC_INT; - config_found_sm_loc(self, "mainbus", NULL, &maa, mainbus_print, - mainbus_submatch); + config_found(self, &maa, mainbus_print, + CFARG_SUBMATCH, mainbus_submatch, + CFARG_EOL); } if (a_config.a_has_eth) { maa.mb_name = "cs"; maa.mb_addr = PMPPC_CS_IO_BASE; maa.mb_irq = PMPPC_I_ETH_INT; - config_found_sm_loc(self, "mainbus", NULL, &maa, mainbus_print, - mainbus_submatch); + config_found(self, &maa, mainbus_print, + CFARG_SUBMATCH, mainbus_submatch, + CFARG_EOL); maa.mb_bt = &pmppc_mem_tag; } if (a_config.a_flash_width != 0) { @@ -139,14 +141,15 @@ mainbus_attach(device_t parent, device_t self, void *aux) maa.mb_irq = MAINBUSCF_IRQ_DEFAULT; maa.u.mb_flash.size = a_config.a_flash_size; maa.u.mb_flash.width = a_config.a_flash_width; - config_found_sm_loc(self, "mainbus", NULL, &maa, mainbus_print, - mainbus_submatch); + config_found(self, &maa, mainbus_print, + CFARG_SUBMATCH, mainbus_submatch, + CFARG_EOL); } maa.mb_name = "cpc"; maa.mb_addr = MAINBUSCF_ADDR_DEFAULT; maa.mb_irq = MAINBUSCF_IRQ_DEFAULT; - config_found(self, &maa, mainbus_print); + config_found(self, &maa, mainbus_print, CFARG_EOL); } static int cpu_match(device_t, cfdata_t, void *); diff --git a/sys/arch/evbppc/virtex/autoconf.c b/sys/arch/evbppc/virtex/autoconf.c index 82233d8efa5..51b5eeb43b5 100644 --- a/sys/arch/evbppc/virtex/autoconf.c +++ b/sys/arch/evbppc/virtex/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.6 2021/03/29 13:14:13 rin Exp $ */ +/* $NetBSD: autoconf.c,v 1.7 2021/04/24 23:36:36 thorpej Exp $ */ /* * Copyright (c) 2006 Jachym Holecek @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.6 2021/03/29 13:14:13 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.7 2021/04/24 23:36:36 thorpej Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -90,7 +90,7 @@ cpu_configure(void) intr_init(); calc_delayconst(); - if (config_rootfound("plb", &local_plb_devs) == NULL) + if (config_rootfound("plb", __UNCONST(&local_plb_devs)) == NULL) panic("configure: plb not configured"); (void)spl0(); diff --git a/sys/arch/evbppc/virtex/design_gsrd1.c b/sys/arch/evbppc/virtex/design_gsrd1.c index 5d96b882c85..dffe28f18e5 100644 --- a/sys/arch/evbppc/virtex/design_gsrd1.c +++ b/sys/arch/evbppc/virtex/design_gsrd1.c @@ -1,4 +1,4 @@ -/* $NetBSD: design_gsrd1.c,v 1.5 2020/11/21 15:42:20 thorpej Exp $ */ +/* $NetBSD: design_gsrd1.c,v 1.6 2021/04/24 23:36:36 thorpej Exp $ */ /* * Copyright (c) 2006 Jachym Holecek @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: design_gsrd1.c,v 1.5 2020/11/21 15:42:20 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: design_gsrd1.c,v 1.6 2021/04/24 23:36:36 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -348,7 +348,9 @@ virtex_autoconf(device_t self, struct plb_attach_args *paa) vaa.vaa_rx_dmac = virtex_mpmc_mapdma(g->gdv_rx_dma, &rx); vaa.vaa_tx_dmac = virtex_mpmc_mapdma(g->gdv_tx_dma, &tx); - config_found_ia(self, g->gdv_attr, &vaa, xcvbus_print); + config_found(self, &vaa, xcvbus_print, + CFARG_IATTR, g->gdv_attr, + CFARG_EOL); } /* Setup the dispatch handler. */ diff --git a/sys/arch/evbppc/virtex/design_gsrd2.c b/sys/arch/evbppc/virtex/design_gsrd2.c index 9ad7ded03ae..f5f757e27bc 100644 --- a/sys/arch/evbppc/virtex/design_gsrd2.c +++ b/sys/arch/evbppc/virtex/design_gsrd2.c @@ -1,4 +1,4 @@ -/* $NetBSD: design_gsrd2.c,v 1.6 2021/03/30 03:15:53 rin Exp $ */ +/* $NetBSD: design_gsrd2.c,v 1.7 2021/04/24 23:36:36 thorpej Exp $ */ /* * Copyright (c) 2006 Jachym Holecek @@ -32,7 +32,7 @@ #include "opt_virtex.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: design_gsrd2.c,v 1.6 2021/03/30 03:15:53 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: design_gsrd2.c,v 1.7 2021/04/24 23:36:36 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -405,7 +405,9 @@ virtex_autoconf(device_t self, struct plb_attach_args *paa) vaa.vaa_rx_dmac = virtex_mpmc_mapdma(g->gdv_rx_dma, &rx); vaa.vaa_tx_dmac = virtex_mpmc_mapdma(g->gdv_tx_dma, &tx); - config_found_ia(self, g->gdv_attr, &vaa, xcvbus_print); + config_found(self, &vaa, xcvbus_print, + CFARG_IATTR, g->gdv_attr, + CFARG_EOL); } /* Setup the dispatch handler. */ diff --git a/sys/arch/evbppc/virtex/dev/tft.c b/sys/arch/evbppc/virtex/dev/tft.c index 38b60f30a15..243a8f932df 100644 --- a/sys/arch/evbppc/virtex/dev/tft.c +++ b/sys/arch/evbppc/virtex/dev/tft.c @@ -1,4 +1,4 @@ -/* $NetBSD: tft.c,v 1.5 2012/07/22 14:02:45 matt Exp $ */ +/* $NetBSD: tft.c,v 1.6 2021/04/24 23:36:36 thorpej Exp $ */ /* * Copyright (c) 2006 Jachym Holecek @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tft.c,v 1.5 2012/07/22 14:02:45 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tft.c,v 1.6 2021/04/24 23:36:36 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -134,7 +134,7 @@ tft_attach(device_t self, struct wsdisplay_accessops *accessops) waa.accessops = accessops; waa.accesscookie = &sc->sc_vc_data; - config_found(self, &waa, wsemuldisplaydevprint); + config_found(self, &waa, wsemuldisplaydevprint, CFARG_EOL); } static void diff --git a/sys/arch/evbppc/walnut/dev/pbus.c b/sys/arch/evbppc/walnut/dev/pbus.c index 691c2331e38..8fe35fe3ade 100644 --- a/sys/arch/evbppc/walnut/dev/pbus.c +++ b/sys/arch/evbppc/walnut/dev/pbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: pbus.c,v 1.13 2011/07/01 19:03:51 dyoung Exp $ */ +/* $NetBSD: pbus.c,v 1.14 2021/04/24 23:36:36 thorpej Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pbus.c,v 1.13 2011/07/01 19:03:51 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pbus.c,v 1.14 2021/04/24 23:36:36 thorpej Exp $"); #include "locators.h" #include "pckbc.h" @@ -157,8 +157,10 @@ pbus_attach(device_t parent, device_t self, void *aux) [PBUSCF_IRQ] = pba.pb_irq }; - (void) config_found_sm_loc(self, "pbus", locs, &pba, pbus_print, - config_stdsubmatch); + config_found(self, &pba, pbus_print, + CFARG_SUBMATCH, config_stdsubmatch, + CFARG_LOCATORS, locs, + CFARG_EOL); } #if NPCKBC > 0 |
