diff --git a/sys/amd64/acpica/acpi_wakeup.c b/sys/amd64/acpica/acpi_wakeup.c index 51d6d5e3684002..552011b1b1e652 100644 --- a/sys/amd64/acpica/acpi_wakeup.c +++ b/sys/amd64/acpica/acpi_wakeup.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c index 591bd196ca7dc6..6eccfd19ed297c 100644 --- a/sys/amd64/amd64/fpu.c +++ b/sys/amd64/amd64/fpu.c @@ -51,7 +51,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 73bfdd4d07f5af..d874e9b709998f 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -119,7 +119,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 265d48e26c0bd4..a0f06cdc46a0e5 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -153,7 +153,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 8e9b115ef22418..1f6f7e6c4fa00c 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -83,7 +83,7 @@ PMC_SOFT_DEFINE( , , page_fault, write); #include #include -#include +#include #include #include #include diff --git a/sys/amd64/ia32/ia32_syscall.c b/sys/amd64/ia32/ia32_syscall.c index c61587a93d1f0f..904c1f5c0fd58c 100644 --- a/sys/amd64/ia32/ia32_syscall.c +++ b/sys/amd64/ia32/ia32_syscall.c @@ -75,7 +75,7 @@ #include #include -#include +#include #include #include diff --git a/sys/amd64/include/intr_machdep.h b/sys/amd64/include/interrupt.h similarity index 92% rename from sys/amd64/include/intr_machdep.h rename to sys/amd64/include/interrupt.h index 1b78875bf85355..ffde17a7545030 100644 --- a/sys/amd64/include/intr_machdep.h +++ b/sys/amd64/include/interrupt.h @@ -25,10 +25,10 @@ * SUCH DAMAGE. */ -#ifndef __MACHINE_INTR_MACHDEP_H__ -#define __MACHINE_INTR_MACHDEP_H__ +#ifndef __MACHINE_INTERRUPT_H__ +#define __MACHINE_INTERRUPT_H__ -#include +#include /* * The following data structure holds per-cpu data, and is placed just @@ -44,4 +44,4 @@ struct nmi_pcpu { #define MCE_STACK_SIZE PAGE_SIZE #define DBG_STACK_SIZE PAGE_SIZE -#endif /* !__MACHINE_INTR_MACHDEP_H__ */ +#endif /* !__MACHINE_INTERRUPT_H__ */ diff --git a/sys/arm/allwinner/a10/a10_intc.c b/sys/arm/allwinner/a10/a10_intc.c index 0bac9edbfd0805..fe93d180aca234 100644 --- a/sys/arm/allwinner/a10/a10_intc.c +++ b/sys/arm/allwinner/a10/a10_intc.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include @@ -366,21 +366,21 @@ static device_method_t a10_aintc_methods[] = { DEVMETHOD(device_probe, a10_aintc_probe), DEVMETHOD(device_attach, a10_aintc_attach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, a10_intr_pre_ithread), + DEVMETHOD(intr_event_post_ithread, a10_intr_post_ithread), + DEVMETHOD(intr_event_post_filter, a10_intr_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_disable_intr, a10_intr_disable_intr), DEVMETHOD(pic_enable_intr, a10_intr_enable_intr), DEVMETHOD(pic_map_intr, a10_intr_map_intr), - DEVMETHOD(pic_post_filter, a10_intr_post_filter), - DEVMETHOD(pic_post_ithread, a10_intr_post_ithread), - DEVMETHOD(pic_pre_ithread, a10_intr_pre_ithread), - { 0, 0 } -}; -static driver_t a10_aintc_driver = { - "aintc", - a10_aintc_methods, - sizeof(struct a10_aintc_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(aintc, a10_aintc_driver, a10_aintc_methods, + sizeof(struct a10_aintc_softc), pic_base_class); + EARLY_DRIVER_MODULE(aintc, simplebus, a10_aintc_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_FIRST); diff --git a/sys/arm/allwinner/a10_ahci.c b/sys/arm/allwinner/a10_ahci.c index b7aa991b6543cf..ca65cb4680b1e0 100644 --- a/sys/arm/allwinner/a10_ahci.c +++ b/sys/arm/allwinner/a10_ahci.c @@ -411,13 +411,11 @@ static device_method_t ahci_ata_methods[] = { DEVMETHOD(bus_setup_intr, ahci_setup_intr), DEVMETHOD(bus_teardown_intr,ahci_teardown_intr), DEVMETHOD(bus_child_location, ahci_child_location), + DEVMETHOD_END }; -static driver_t ahci_ata_driver = { - "ahci", - ahci_ata_methods, - sizeof(struct ahci_a10_softc) -}; +PRIVATE_DEFINE_CLASSN(ahci, ahci_ata_driver, ahci_ata_methods, + sizeof(struct ahci_a10_softc)); DRIVER_MODULE(a10_ahci, simplebus, ahci_ata_driver, 0, 0); diff --git a/sys/arm/allwinner/a10_codec.c b/sys/arm/allwinner/a10_codec.c index 12d389d242438d..cdbc7fa8194656 100644 --- a/sys/arm/allwinner/a10_codec.c +++ b/sys/arm/allwinner/a10_codec.c @@ -1194,11 +1194,8 @@ static device_method_t a10codec_pcm_methods[] = { DEVMETHOD_END }; -static driver_t a10codec_pcm_driver = { - "pcm", - a10codec_pcm_methods, - PCM_SOFTC_SIZE, -}; +PRIVATE_DEFINE_CLASSN(pcm, a10codec_pcm_driver, a10codec_pcm_methods, + PCM_SOFTC_SIZE); DRIVER_MODULE(a10codec, simplebus, a10codec_pcm_driver, 0, 0); MODULE_DEPEND(a10codec, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER); diff --git a/sys/arm/allwinner/a10_dmac.c b/sys/arm/allwinner/a10_dmac.c index e711c5268b2df9..04f154a2bec29b 100644 --- a/sys/arm/allwinner/a10_dmac.c +++ b/sys/arm/allwinner/a10_dmac.c @@ -459,10 +459,7 @@ static device_method_t a10dmac_methods[] = { DEVMETHOD_END }; -static driver_t a10dmac_driver = { - "a10dmac", - a10dmac_methods, - sizeof(struct a10dmac_softc) -}; +PRIVATE_DEFINE_CLASSN(a10dmac, a10dmac_driver, a10dmac_methods, + sizeof(struct a10dmac_softc)); DRIVER_MODULE(a10dmac, simplebus, a10dmac_driver, 0, 0); diff --git a/sys/arm/allwinner/a10_sramc.c b/sys/arm/allwinner/a10_sramc.c index fe7dd4025d7e14..cd689a1b135f1b 100644 --- a/sys/arm/allwinner/a10_sramc.c +++ b/sys/arm/allwinner/a10_sramc.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include @@ -98,15 +98,13 @@ a10_sramc_attach(device_t dev) static device_method_t a10_sramc_methods[] = { DEVMETHOD(device_probe, a10_sramc_probe), DEVMETHOD(device_attach, a10_sramc_attach), - { 0, 0 } -}; -static driver_t a10_sramc_driver = { - "a10_sramc", - a10_sramc_methods, - sizeof(struct a10_sramc_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(a10_sramc, a10_sramc_driver, a10_sramc_methods, + sizeof(struct a10_sramc_softc)); + EARLY_DRIVER_MODULE(a10_sramc, simplebus, a10_sramc_driver, 0, 0, BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_FIRST); diff --git a/sys/arm/allwinner/a10_timer.c b/sys/arm/allwinner/a10_timer.c index 18fb2a56da3a9a..d14ce5eb24dee6 100644 --- a/sys/arm/allwinner/a10_timer.c +++ b/sys/arm/allwinner/a10_timer.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include @@ -470,11 +470,8 @@ static device_method_t a10_timer_methods[] = { DEVMETHOD_END }; -static driver_t a10_timer_driver = { - "a10_timer", - a10_timer_methods, - sizeof(struct a10_timer_softc), -}; +PRIVATE_DEFINE_CLASSN(a10_timer, a10_timer_driver, a10_timer_methods, + sizeof(struct a10_timer_softc)); EARLY_DRIVER_MODULE(a10_timer, simplebus, a10_timer_driver, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/allwinner/a20/a20_cpu_cfg.c b/sys/arm/allwinner/a20/a20_cpu_cfg.c index ffbb2cc183e762..b47168782bc46b 100644 --- a/sys/arm/allwinner/a20/a20_cpu_cfg.c +++ b/sys/arm/allwinner/a20/a20_cpu_cfg.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include @@ -104,15 +104,13 @@ a20_cpu_cfg_attach(device_t dev) static device_method_t a20_cpu_cfg_methods[] = { DEVMETHOD(device_probe, a20_cpu_cfg_probe), DEVMETHOD(device_attach, a20_cpu_cfg_attach), - { 0, 0 } -}; -static driver_t a20_cpu_cfg_driver = { - "a20_cpu_cfg", - a20_cpu_cfg_methods, - sizeof(struct a20_cpu_cfg_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(a20_cpu_cfg, a20_cpu_cfg_driver, a20_cpu_cfg_methods, + sizeof(struct a20_cpu_cfg_softc)); + EARLY_DRIVER_MODULE(a20_cpu_cfg, simplebus, a20_cpu_cfg_driver, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_FIRST); diff --git a/sys/arm/allwinner/a31_dmac.c b/sys/arm/allwinner/a31_dmac.c index 9dc98342a159fc..1cf035de4cfbc0 100644 --- a/sys/arm/allwinner/a31_dmac.c +++ b/sys/arm/allwinner/a31_dmac.c @@ -545,10 +545,7 @@ static device_method_t a31dmac_methods[] = { DEVMETHOD_END }; -static driver_t a31dmac_driver = { - "a31dmac", - a31dmac_methods, - sizeof(struct a31dmac_softc) -}; +PRIVATE_DEFINE_CLASSN(a31dmac, a31dmac_driver, a31dmac_methods, + sizeof(struct a31dmac_softc)); DRIVER_MODULE(a31dmac, simplebus, a31dmac_driver, 0, 0); diff --git a/sys/arm/allwinner/a33_codec.c b/sys/arm/allwinner/a33_codec.c index 4bf2863b74ef39..ec2370d79f8fc5 100644 --- a/sys/arm/allwinner/a33_codec.c +++ b/sys/arm/allwinner/a33_codec.c @@ -397,11 +397,8 @@ static device_method_t sun8i_codec_methods[] = { DEVMETHOD_END }; -static driver_t sun8i_codec_driver = { - "sun8icodec", - sun8i_codec_methods, - sizeof(struct sun8i_codec_softc), -}; +PRIVATE_DEFINE_CLASSN(sun8icodec, sun8i_codec_driver, sun8i_codec_methods, + sizeof(struct sun8i_codec_softc)); DRIVER_MODULE(sun8i_codec, simplebus, sun8i_codec_driver, 0, 0); SIMPLEBUS_PNP_INFO(compat_data); diff --git a/sys/arm/allwinner/a64/sun50i_a64_acodec.c b/sys/arm/allwinner/a64/sun50i_a64_acodec.c index 12c9a86cf36171..6f2ce78f8ee010 100644 --- a/sys/arm/allwinner/a64/sun50i_a64_acodec.c +++ b/sys/arm/allwinner/a64/sun50i_a64_acodec.c @@ -471,11 +471,8 @@ static device_method_t a64codec_methods[] = { DEVMETHOD_END }; -static driver_t a64codec_driver = { - "a64codec", - a64codec_methods, - sizeof(struct a64codec_softc), -}; +PRIVATE_DEFINE_CLASSN(a64codec, a64codec_driver, a64codec_methods, + sizeof(struct a64codec_softc)); DRIVER_MODULE(a64codec, simplebus, a64codec_driver, 0, 0); SIMPLEBUS_PNP_INFO(compat_data); diff --git a/sys/arm/allwinner/aw_cir.c b/sys/arm/allwinner/aw_cir.c index 5ebb57f480408b..a6f741b53b9413 100644 --- a/sys/arm/allwinner/aw_cir.c +++ b/sys/arm/allwinner/aw_cir.c @@ -548,11 +548,8 @@ static device_method_t aw_ir_methods[] = { DEVMETHOD_END }; -static driver_t aw_ir_driver = { - "aw_ir", - aw_ir_methods, - sizeof(struct aw_ir_softc), -}; +PRIVATE_DEFINE_CLASSN(aw_ir, aw_ir_driver, aw_ir_methods, + sizeof(struct aw_ir_softc)); DRIVER_MODULE(aw_ir, simplebus, aw_ir_driver, 0, 0); MODULE_DEPEND(aw_ir, evdev, 1, 1, 1); diff --git a/sys/arm/allwinner/aw_gmacclk.c b/sys/arm/allwinner/aw_gmacclk.c index 99e69674bd25c3..acc4698a3a6650 100644 --- a/sys/arm/allwinner/aw_gmacclk.c +++ b/sys/arm/allwinner/aw_gmacclk.c @@ -258,11 +258,7 @@ static device_method_t aw_gmacclk_methods[] = { DEVMETHOD_END }; -static driver_t aw_gmacclk_driver = { - "aw_gmacclk", - aw_gmacclk_methods, - 0 -}; +PRIVATE_DEFINE_CLASSN(aw_gmacclk, aw_gmacclk_driver, aw_gmacclk_methods, 0); EARLY_DRIVER_MODULE(aw_gmacclk, simplebus, aw_gmacclk_driver, 0, 0, BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/allwinner/aw_gpio.c b/sys/arm/allwinner/aw_gpio.c index 18b47bab12d955..d36559f352a484 100644 --- a/sys/arm/allwinner/aw_gpio.c +++ b/sys/arm/allwinner/aw_gpio.c @@ -43,8 +43,8 @@ #include #include +#include #include -#include #include #include @@ -1530,15 +1530,17 @@ static device_method_t aw_gpio_methods[] = { DEVMETHOD(device_attach, aw_gpio_attach), DEVMETHOD(device_detach, aw_gpio_detach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, aw_gpio_pic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, aw_gpio_pic_post_ithread), + DEVMETHOD(intr_event_post_filter, aw_gpio_pic_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_disable_intr, aw_gpio_pic_disable_intr), DEVMETHOD(pic_enable_intr, aw_gpio_pic_enable_intr), DEVMETHOD(pic_map_intr, aw_gpio_pic_map_intr), DEVMETHOD(pic_setup_intr, aw_gpio_pic_setup_intr), DEVMETHOD(pic_teardown_intr, aw_gpio_pic_teardown_intr), - DEVMETHOD(pic_post_filter, aw_gpio_pic_post_filter), - DEVMETHOD(pic_post_ithread, aw_gpio_pic_post_ithread), - DEVMETHOD(pic_pre_ithread, aw_gpio_pic_pre_ithread), /* GPIO protocol */ DEVMETHOD(gpio_get_bus, aw_gpio_get_bus), @@ -1563,11 +1565,8 @@ static device_method_t aw_gpio_methods[] = { DEVMETHOD_END }; -static driver_t aw_gpio_driver = { - "gpio", - aw_gpio_methods, - sizeof(struct aw_gpio_softc), -}; +PRIVATE_DEFINE_CLASSN(gpio, aw_gpio_driver, aw_gpio_methods, + sizeof(struct aw_gpio_softc), pic_base_class); EARLY_DRIVER_MODULE(aw_gpio, simplebus, aw_gpio_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/allwinner/aw_i2s.c b/sys/arm/allwinner/aw_i2s.c index 87dfb109363fd2..0c7dc83312798b 100644 --- a/sys/arm/allwinner/aw_i2s.c +++ b/sys/arm/allwinner/aw_i2s.c @@ -795,11 +795,8 @@ static device_method_t aw_i2s_methods[] = { DEVMETHOD_END }; -static driver_t aw_i2s_driver = { - "i2s", - aw_i2s_methods, - sizeof(struct aw_i2s_softc), -}; +PRIVATE_DEFINE_CLASSN(i2s, aw_i2s_driver, aw_i2s_methods, + sizeof(struct aw_i2s_softc)); DRIVER_MODULE(aw_i2s, simplebus, aw_i2s_driver, 0, 0); SIMPLEBUS_PNP_INFO(compat_data); diff --git a/sys/arm/allwinner/aw_machdep.c b/sys/arm/allwinner/aw_machdep.c index 8b6bdd9805d14e..336fbf25920aa6 100644 --- a/sys/arm/allwinner/aw_machdep.c +++ b/sys/arm/allwinner/aw_machdep.c @@ -167,7 +167,7 @@ static platform_method_t a10_methods[] = { PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init), PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset), - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(a10, "a10", 0, "allwinner,sun4i-a10", 200); #endif @@ -178,7 +178,7 @@ static platform_method_t a13_methods[] = { PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init), PLATFORMMETHOD(platform_cpu_reset, allwinner_cpu_reset), - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(a13, "a13", 0, "allwinner,sun5i-a13", 200); #endif @@ -193,7 +193,7 @@ static platform_method_t a20_methods[] = { PLATFORMMETHOD(platform_mp_start_ap, aw_mp_start_ap), PLATFORMMETHOD(platform_mp_setmaxid, aw_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(a20, "a20", 0, "allwinner,sun7i-a20", 200); #endif @@ -208,7 +208,7 @@ static platform_method_t a31_methods[] = { PLATFORMMETHOD(platform_mp_start_ap, aw_mp_start_ap), PLATFORMMETHOD(platform_mp_setmaxid, aw_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(a31, "a31", 0, "allwinner,sun6i-a31", 200); #endif @@ -223,7 +223,7 @@ static platform_method_t a31s_methods[] = { PLATFORMMETHOD(platform_mp_start_ap, aw_mp_start_ap), PLATFORMMETHOD(platform_mp_setmaxid, aw_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(a31s, "a31s", 0, "allwinner,sun6i-a31s", 200); #endif @@ -238,7 +238,7 @@ static platform_method_t a33_methods[] = { PLATFORMMETHOD(platform_mp_start_ap, aw_mp_start_ap), PLATFORMMETHOD(platform_mp_setmaxid, aw_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(a33, "a33", 0, "allwinner,sun8i-a33", 200); #endif @@ -253,7 +253,7 @@ static platform_method_t a83t_methods[] = { PLATFORMMETHOD(platform_mp_start_ap, a83t_mp_start_ap), PLATFORMMETHOD(platform_mp_setmaxid, aw_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(a83t, "a83t", 0, "allwinner,sun8i-a83t", 200); #endif @@ -268,7 +268,7 @@ static platform_method_t h2_plus_methods[] = { PLATFORMMETHOD(platform_mp_start_ap, aw_mp_start_ap), PLATFORMMETHOD(platform_mp_setmaxid, aw_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(h2_plus, "h2_plus", 0, "allwinner,sun8i-h2-plus", 200); #endif @@ -283,7 +283,7 @@ static platform_method_t h3_methods[] = { PLATFORMMETHOD(platform_mp_start_ap, aw_mp_start_ap), PLATFORMMETHOD(platform_mp_setmaxid, aw_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(h3, "h3", 0, "allwinner,sun8i-h3", 200); #endif diff --git a/sys/arm/allwinner/aw_mmc.c b/sys/arm/allwinner/aw_mmc.c index 9f61e1560658a2..89429a86ae0a9d 100644 --- a/sys/arm/allwinner/aw_mmc.c +++ b/sys/arm/allwinner/aw_mmc.c @@ -1501,11 +1501,8 @@ static device_method_t aw_mmc_methods[] = { DEVMETHOD_END }; -static driver_t aw_mmc_driver = { - "aw_mmc", - aw_mmc_methods, - sizeof(struct aw_mmc_softc), -}; +PRIVATE_DEFINE_CLASSN(aw_mmc, aw_mmc_driver, aw_mmc_methods, + sizeof(struct aw_mmc_softc)); DRIVER_MODULE(aw_mmc, simplebus, aw_mmc_driver, NULL, NULL); #ifndef MMCCAM diff --git a/sys/arm/allwinner/aw_mp.c b/sys/arm/allwinner/aw_mp.c index 0c773f71ac4141..04719367e9ae0c 100644 --- a/sys/arm/allwinner/aw_mp.c +++ b/sys/arm/allwinner/aw_mp.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/arm/allwinner/aw_nmi.c b/sys/arm/allwinner/aw_nmi.c index febf970c7ffbc2..8e2ffaf162da55 100644 --- a/sys/arm/allwinner/aw_nmi.c +++ b/sys/arm/allwinner/aw_nmi.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -393,24 +393,23 @@ static device_method_t aw_nmi_methods[] = { DEVMETHOD(device_probe, aw_nmi_probe), DEVMETHOD(device_attach, aw_nmi_attach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, aw_nmi_pre_ithread), + DEVMETHOD(intr_event_post_ithread, aw_nmi_post_ithread), + DEVMETHOD(intr_event_post_filter, aw_nmi_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_disable_intr, aw_nmi_disable_intr), DEVMETHOD(pic_enable_intr, aw_nmi_enable_intr), DEVMETHOD(pic_map_intr, aw_nmi_map_intr), DEVMETHOD(pic_setup_intr, aw_nmi_setup_intr), DEVMETHOD(pic_teardown_intr, aw_nmi_teardown_intr), - DEVMETHOD(pic_post_filter, aw_nmi_post_filter), - DEVMETHOD(pic_post_ithread, aw_nmi_post_ithread), - DEVMETHOD(pic_pre_ithread, aw_nmi_pre_ithread), - {0, 0}, + DEVMETHOD_END }; -static driver_t aw_nmi_driver = { - "aw_nmi", - aw_nmi_methods, - sizeof(struct aw_nmi_softc), -}; +PRIVATE_DEFINE_CLASSN(aw_nmi, aw_nmi_driver, aw_nmi_methods, + sizeof(struct aw_nmi_softc), pic_base_class); EARLY_DRIVER_MODULE(aw_nmi, simplebus, aw_nmi_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/allwinner/aw_r_intc.c b/sys/arm/allwinner/aw_r_intc.c index 6a2629a3576588..3acf6e4ec2c82c 100644 --- a/sys/arm/allwinner/aw_r_intc.c +++ b/sys/arm/allwinner/aw_r_intc.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -189,7 +189,7 @@ aw_r_intc_gicp_map_intr(device_t dev, struct intr_map_data *data, return (EINVAL); ret = PIC_MAP_INTR(sc->parent, data, isrcp); - (*isrcp)->isrc_dev = sc->dev; + (*isrcp)->isrc_event.ie_pic = sc->dev; return(ret); } @@ -243,7 +243,7 @@ aw_r_intc_gicp_pre_ithread(device_t dev, struct intr_irqsrc *isrc) sc = device_get_softc(dev); - PIC_PRE_ITHREAD(sc->parent, isrc); + INTR_EVENT_PRE_ITHREAD(sc->parent, isrc); } static void @@ -253,7 +253,7 @@ aw_r_intc_gicp_post_ithread(device_t dev, struct intr_irqsrc *isrc) sc = device_get_softc(dev); - PIC_POST_ITHREAD(sc->parent, isrc); + INTR_EVENT_POST_ITHREAD(sc->parent, isrc); } static void @@ -263,7 +263,7 @@ aw_r_intc_gicp_post_filter(device_t dev, struct intr_irqsrc *isrc) sc = device_get_softc(dev); - PIC_POST_FILTER(sc->parent, isrc); + INTR_EVENT_POST_FILTER(sc->parent, isrc); } static device_method_t aw_r_intc_gicp_methods[] = { @@ -272,6 +272,11 @@ static device_method_t aw_r_intc_gicp_methods[] = { DEVMETHOD(device_attach, aw_r_intc_gicp_attach), DEVMETHOD(device_detach, aw_r_intc_gicp_detach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, aw_r_intc_gicp_pre_ithread), + DEVMETHOD(intr_event_post_ithread, aw_r_intc_gicp_post_ithread), + DEVMETHOD(intr_event_post_filter, aw_r_intc_gicp_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_activate_intr, aw_r_intc_gicp_activate_intr), DEVMETHOD(pic_disable_intr, aw_r_intc_gicp_disable_intr), @@ -280,18 +285,13 @@ static device_method_t aw_r_intc_gicp_methods[] = { DEVMETHOD(pic_deactivate_intr, aw_r_intc_gicp_deactivate_intr), DEVMETHOD(pic_setup_intr, aw_r_intc_gicp_setup_intr), DEVMETHOD(pic_teardown_intr, aw_r_intc_gicp_teardown_intr), - DEVMETHOD(pic_post_filter, aw_r_intc_gicp_post_filter), - DEVMETHOD(pic_post_ithread, aw_r_intc_gicp_post_ithread), - DEVMETHOD(pic_pre_ithread, aw_r_intc_gicp_pre_ithread), DEVMETHOD_END }; -static driver_t aw_r_intc_gicp_driver = { - "aw_r_intc_gicp", - aw_r_intc_gicp_methods, - sizeof(struct aw_r_intc_gicp_softc), -}; +PRIVATE_DEFINE_CLASSN(aw_r_intc_gicp, aw_r_intc_gicp_driver, + aw_r_intc_gicp_methods, sizeof(struct aw_r_intc_gicp_softc), + pic_base_class); EARLY_DRIVER_MODULE(aw_r_intc_gicp, simplebus, aw_r_intc_gicp_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/allwinner/aw_reset.c b/sys/arm/allwinner/aw_reset.c index 4fadaf2bfef496..9f328c8fbed45f 100644 --- a/sys/arm/allwinner/aw_reset.c +++ b/sys/arm/allwinner/aw_reset.c @@ -147,11 +147,8 @@ static device_method_t aw_reset_methods[] = { DEVMETHOD_END }; -static driver_t aw_reset_driver = { - "aw_reset", - aw_reset_methods, - sizeof(struct aw_reset_softc), -}; +PRIVATE_DEFINE_CLASSN(aw_reset, aw_reset_driver, aw_reset_methods, + sizeof(struct aw_reset_softc)); EARLY_DRIVER_MODULE(aw_reset, simplebus, aw_reset_driver, 0, 0, BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/allwinner/aw_rsb.c b/sys/arm/allwinner/aw_rsb.c index 773b88d01d84bd..e2a2c836af82f9 100644 --- a/sys/arm/allwinner/aw_rsb.c +++ b/sys/arm/allwinner/aw_rsb.c @@ -490,11 +490,7 @@ static device_method_t rsb_methods[] = { DEVMETHOD_END }; -static driver_t rsb_driver = { - "iichb", - rsb_methods, - sizeof(struct rsb_softc), -}; +PRIVATE_DEFINE_CLASSN(iichb, rsb_driver, rsb_methods, sizeof(struct rsb_softc)); EARLY_DRIVER_MODULE(iicbus, rsb, iicbus_driver, 0, 0, BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/allwinner/aw_rtc.c b/sys/arm/allwinner/aw_rtc.c index a13c0e7d926e85..e29d3a71cca15f 100644 --- a/sys/arm/allwinner/aw_rtc.c +++ b/sys/arm/allwinner/aw_rtc.c @@ -177,11 +177,8 @@ static device_method_t aw_rtc_methods[] = { DEVMETHOD_END }; -static driver_t aw_rtc_driver = { - "rtc", - aw_rtc_methods, - sizeof(struct aw_rtc_softc), -}; +PRIVATE_DEFINE_CLASSN(rtc, aw_rtc_driver, aw_rtc_methods, + sizeof(struct aw_rtc_softc)); EARLY_DRIVER_MODULE(aw_rtc, simplebus, aw_rtc_driver, 0, 0, BUS_PASS_RESOURCE + BUS_PASS_ORDER_FIRST); diff --git a/sys/arm/allwinner/aw_sid.c b/sys/arm/allwinner/aw_sid.c index ba5faca33c5ed2..19e9310ad9b991 100644 --- a/sys/arm/allwinner/aw_sid.c +++ b/sys/arm/allwinner/aw_sid.c @@ -421,11 +421,8 @@ static device_method_t aw_sid_methods[] = { DEVMETHOD_END }; -static driver_t aw_sid_driver = { - "aw_sid", - aw_sid_methods, - sizeof(struct aw_sid_softc), -}; +PRIVATE_DEFINE_CLASSN(aw_sid, aw_sid_driver, aw_sid_methods, + sizeof(struct aw_sid_softc)); EARLY_DRIVER_MODULE(aw_sid, simplebus, aw_sid_driver, 0, 0, BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_FIRST); diff --git a/sys/arm/allwinner/aw_thermal.c b/sys/arm/allwinner/aw_thermal.c index bdb7e2dacc4eb8..323fd32d15ecd0 100644 --- a/sys/arm/allwinner/aw_thermal.c +++ b/sys/arm/allwinner/aw_thermal.c @@ -712,11 +712,8 @@ static device_method_t aw_thermal_methods[] = { DEVMETHOD_END }; -static driver_t aw_thermal_driver = { - "aw_thermal", - aw_thermal_methods, - sizeof(struct aw_thermal_softc), -}; +PRIVATE_DEFINE_CLASSN(aw_thermal, aw_thermal_driver, aw_thermal_methods, + sizeof(struct aw_thermal_softc)); DRIVER_MODULE(aw_thermal, simplebus, aw_thermal_driver, 0, 0); MODULE_VERSION(aw_thermal, 1); diff --git a/sys/arm/allwinner/aw_ts.c b/sys/arm/allwinner/aw_ts.c index ca35a29decf88f..a4ac685b53ca7a 100644 --- a/sys/arm/allwinner/aw_ts.c +++ b/sys/arm/allwinner/aw_ts.c @@ -216,10 +216,7 @@ static device_method_t aw_ts_methods[] = { DEVMETHOD_END }; -static driver_t aw_ts_driver = { - "aw_ts", - aw_ts_methods, - sizeof(struct aw_ts_softc), -}; +PRIVATE_DEFINE_CLASSN(aw_ts, aw_ts_driver, aw_ts_methods, + sizeof(struct aw_ts_softc)); DRIVER_MODULE(aw_ts, simplebus, aw_ts_driver, 0, 0); diff --git a/sys/arm/allwinner/aw_usb3phy.c b/sys/arm/allwinner/aw_usb3phy.c index 66033ef22a18f5..1c3d858d2eb7fb 100644 --- a/sys/arm/allwinner/aw_usb3phy.c +++ b/sys/arm/allwinner/aw_usb3phy.c @@ -282,11 +282,8 @@ static device_method_t awusb3phy_methods[] = { DEVMETHOD_END }; -static driver_t awusb3phy_driver = { - "awusb3phy", - awusb3phy_methods, - sizeof(struct awusb3phy_softc) -}; +PRIVATE_DEFINE_CLASSN(awusb3phy, awusb3phy_driver, awusb3phy_methods, + sizeof(struct awusb3phy_softc)); /* aw_usb3phy needs to come up after regulators/gpio/etc, but before ehci/ohci */ EARLY_DRIVER_MODULE(awusb3phy, simplebus, awusb3phy_driver, 0, 0, diff --git a/sys/arm/allwinner/aw_usbphy.c b/sys/arm/allwinner/aw_usbphy.c index 97c3d220777320..380139d88654c7 100644 --- a/sys/arm/allwinner/aw_usbphy.c +++ b/sys/arm/allwinner/aw_usbphy.c @@ -521,11 +521,8 @@ static device_method_t awusbphy_methods[] = { DEVMETHOD_END }; -static driver_t awusbphy_driver = { - "awusbphy", - awusbphy_methods, - sizeof(struct awusbphy_softc) -}; +PRIVATE_DEFINE_CLASSN(awusbphy, awusbphy_driver, awusbphy_methods, + sizeof(struct awusbphy_softc)); /* aw_usbphy needs to come up after regulators/gpio/etc, but before ehci/ohci */ EARLY_DRIVER_MODULE(awusbphy, simplebus, awusbphy_driver, 0, 0, diff --git a/sys/arm/allwinner/aw_wdog.c b/sys/arm/allwinner/aw_wdog.c index acfbdd8fe6d070..4e3867137342f5 100644 --- a/sys/arm/allwinner/aw_wdog.c +++ b/sys/arm/allwinner/aw_wdog.c @@ -291,10 +291,7 @@ static device_method_t aw_wdog_methods[] = { DEVMETHOD_END }; -static driver_t aw_wdog_driver = { - "aw_wdog", - aw_wdog_methods, - sizeof(struct aw_wdog_softc), -}; +PRIVATE_DEFINE_CLASSN(aw_wdog, aw_wdog_driver, aw_wdog_methods, + sizeof(struct aw_wdog_softc)); DRIVER_MODULE(aw_wdog, simplebus, aw_wdog_driver, 0, 0); diff --git a/sys/arm/allwinner/axp209.c b/sys/arm/allwinner/axp209.c index 239ead02d0e069..d77705879d1742 100644 --- a/sys/arm/allwinner/axp209.c +++ b/sys/arm/allwinner/axp209.c @@ -1402,11 +1402,8 @@ static device_method_t axp2xx_methods[] = { DEVMETHOD_END }; -static driver_t axp2xx_driver = { - "axp2xx_pmu", - axp2xx_methods, - sizeof(struct axp2xx_softc), -}; +PRIVATE_DEFINE_CLASSN(axp2xx_pmu, axp2xx_driver, axp2xx_methods, + sizeof(struct axp2xx_softc)); extern driver_t ofw_gpiobus_driver, gpioc_driver; diff --git a/sys/arm/allwinner/axp81x.c b/sys/arm/allwinner/axp81x.c index fc1a168595e5c6..d69dcfb771f815 100644 --- a/sys/arm/allwinner/axp81x.c +++ b/sys/arm/allwinner/axp81x.c @@ -1640,11 +1640,8 @@ static device_method_t axp8xx_methods[] = { DEVMETHOD_END }; -static driver_t axp8xx_driver = { - "axp8xx_pmu", - axp8xx_methods, - sizeof(struct axp8xx_softc), -}; +PRIVATE_DEFINE_CLASSN(axp8xx_pmu, axp8xx_driver, axp8xx_methods, + sizeof(struct axp8xx_softc)); extern driver_t ofw_gpiobus_driver, gpioc_driver; diff --git a/sys/arm/allwinner/if_awg.c b/sys/arm/allwinner/if_awg.c index 98e879d22d3dd5..9feed01eeec74e 100644 --- a/sys/arm/allwinner/if_awg.c +++ b/sys/arm/allwinner/if_awg.c @@ -2006,11 +2006,7 @@ static device_method_t awg_methods[] = { DEVMETHOD_END }; -static driver_t awg_driver = { - "awg", - awg_methods, - sizeof(struct awg_softc), -}; +PRIVATE_DEFINE_CLASSN(awg, awg_driver, awg_methods, sizeof(struct awg_softc)); DRIVER_MODULE(awg, simplebus, awg_driver, 0, 0); DRIVER_MODULE(miibus, awg, miibus_driver, 0, 0); diff --git a/sys/arm/allwinner/if_emac.c b/sys/arm/allwinner/if_emac.c index 1fa6691ade1ab2..0a595a0b2db75b 100644 --- a/sys/arm/allwinner/if_emac.c +++ b/sys/arm/allwinner/if_emac.c @@ -43,8 +43,8 @@ #include #include +#include #include -#include #include #include @@ -1149,11 +1149,8 @@ static device_method_t emac_methods[] = { DEVMETHOD_END }; -static driver_t emac_driver = { - "emac", - emac_methods, - sizeof(struct emac_softc) -}; +PRIVATE_DEFINE_CLASSN(emac, emac_driver, emac_methods, + sizeof(struct emac_softc)); DRIVER_MODULE(emac, simplebus, emac_driver, 0, 0); DRIVER_MODULE(miibus, emac, miibus_driver, 0, 0); diff --git a/sys/arm/annapurna/alpine/alpine_ccu.c b/sys/arm/annapurna/alpine/alpine_ccu.c index ac5d276cd114bb..6081110040b725 100644 --- a/sys/arm/annapurna/alpine/alpine_ccu.c +++ b/sys/arm/annapurna/alpine/alpine_ccu.c @@ -59,15 +59,13 @@ static device_method_t al_ccu_methods[] = { DEVMETHOD(device_probe, al_ccu_probe), DEVMETHOD(device_attach, al_ccu_attach), DEVMETHOD(device_detach, al_ccu_detach), - { 0, 0 } -}; -static driver_t al_ccu_driver = { - "ccu", - al_ccu_methods, - sizeof(struct al_ccu_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(ccu, al_ccu_driver, al_ccu_methods, + sizeof(struct al_ccu_softc)); + EARLY_DRIVER_MODULE(al_ccu, simplebus, al_ccu_driver, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_MIDDLE); EARLY_DRIVER_MODULE(al_ccu, ofwbus, al_ccu_driver, 0, 0, diff --git a/sys/arm/annapurna/alpine/alpine_machdep.c b/sys/arm/annapurna/alpine/alpine_machdep.c index 89d21bf9fcae3d..3e4c03112d933c 100644 --- a/sys/arm/annapurna/alpine/alpine_machdep.c +++ b/sys/arm/annapurna/alpine/alpine_machdep.c @@ -154,6 +154,6 @@ static platform_method_t alpine_methods[] = { PLATFORMMETHOD(platform_mp_start_ap, alpine_mp_start_ap), PLATFORMMETHOD(platform_mp_setmaxid, alpine_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(alpine, "alpine", 0, "annapurna,alpine", 200); diff --git a/sys/arm/annapurna/alpine/alpine_machdep_mp.c b/sys/arm/annapurna/alpine/alpine_machdep_mp.c index 00a6578621c390..51a5263fd4c284 100644 --- a/sys/arm/annapurna/alpine/alpine_machdep_mp.c +++ b/sys/arm/annapurna/alpine/alpine_machdep_mp.c @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include diff --git a/sys/arm/annapurna/alpine/alpine_nb_service.c b/sys/arm/annapurna/alpine/alpine_nb_service.c index 3e6aa26aae7806..53302c677011f3 100644 --- a/sys/arm/annapurna/alpine/alpine_nb_service.c +++ b/sys/arm/annapurna/alpine/alpine_nb_service.c @@ -58,15 +58,13 @@ static device_method_t nb_service_methods[] = { DEVMETHOD(device_probe, nb_service_probe), DEVMETHOD(device_attach, nb_service_attach), DEVMETHOD(device_detach, nb_service_detach), - { 0, 0 } -}; -static driver_t nb_service_driver = { - "nb_service", - nb_service_methods, - sizeof(struct nb_service_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(nb_service, nb_service_driver, nb_service_methods, + sizeof(struct nb_service_softc)); + EARLY_DRIVER_MODULE(nb_service, simplebus, nb_service_driver, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_MIDDLE); EARLY_DRIVER_MODULE(nb_service, ofwbus, nb_service_driver, 0, 0, diff --git a/sys/arm/annapurna/alpine/alpine_pci.c b/sys/arm/annapurna/alpine/alpine_pci.c index 4d2a1ad36a62c9..6d55ffc2c2320b 100644 --- a/sys/arm/annapurna/alpine/alpine_pci.c +++ b/sys/arm/annapurna/alpine/alpine_pci.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/sys/arm/annapurna/alpine/alpine_pci_msix.c b/sys/arm/annapurna/alpine/alpine_pci_msix.c index fc2915ae781573..00b4e696c45cf0 100644 --- a/sys/arm/annapurna/alpine/alpine_pci_msix.c +++ b/sys/arm/annapurna/alpine/alpine_pci_msix.c @@ -71,20 +71,6 @@ static struct ofw_compat_data compat_data[] = { /* * Bus interface definitions. */ -static device_method_t al_msix_methods[] = { - DEVMETHOD(device_probe, al_msix_probe), - DEVMETHOD(device_attach, al_msix_attach), - - /* Interrupt controller interface */ - DEVMETHOD(msi_alloc_msi, al_msix_alloc_msi), - DEVMETHOD(msi_release_msi, al_msix_release_msi), - DEVMETHOD(msi_alloc_msix, al_msix_alloc_msix), - DEVMETHOD(msi_release_msix, al_msix_release_msix), - DEVMETHOD(msi_map_msi, al_msix_map_msi), - - DEVMETHOD_END -}; - struct al_msix_softc { bus_addr_t base_addr; struct resource *res; @@ -98,12 +84,23 @@ struct al_msix_softc { struct intr_irqsrc *isrcs[MAX_MSIX_COUNT]; }; -static driver_t al_msix_driver = { - "al_msix", - al_msix_methods, - sizeof(struct al_msix_softc), +static device_method_t al_msix_methods[] = { + DEVMETHOD(device_probe, al_msix_probe), + DEVMETHOD(device_attach, al_msix_attach), + + /* Interrupt controller interface */ + DEVMETHOD(msi_alloc_msi, al_msix_alloc_msi), + DEVMETHOD(msi_release_msi, al_msix_release_msi), + DEVMETHOD(msi_alloc_msix, al_msix_alloc_msix), + DEVMETHOD(msi_release_msix, al_msix_release_msix), + DEVMETHOD(msi_map_msi, al_msix_map_msi), + + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(al_msix, al_msix_driver, al_msix_methods, + sizeof(struct al_msix_softc)); + DRIVER_MODULE(al_msix, ofwbus, al_msix_driver, 0, 0); DRIVER_MODULE(al_msix, simplebus, al_msix_driver, 0, 0); diff --git a/sys/arm/annapurna/alpine/alpine_serdes.c b/sys/arm/annapurna/alpine/alpine_serdes.c index a5d7f24e30741e..9ac70e927e92b3 100644 --- a/sys/arm/annapurna/alpine/alpine_serdes.c +++ b/sys/arm/annapurna/alpine/alpine_serdes.c @@ -73,11 +73,8 @@ static device_method_t al_serdes_methods[] = { DEVMETHOD_END }; -static driver_t al_serdes_driver = { - "serdes", - al_serdes_methods, - sizeof(struct al_serdes_softc) -}; +PRIVATE_DEFINE_CLASSN(serdes, al_serdes_driver, al_serdes_methods, + sizeof(struct al_serdes_softc)); DRIVER_MODULE(al_serdes, simplebus, al_serdes_driver, 0, 0); DRIVER_MODULE(al_serdes, ofwbus, al_serdes_driver, 0, 0); diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c index 99a72c9e79d0ca..85e5e254c08661 100644 --- a/sys/arm/arm/busdma_machdep.c +++ b/sys/arm/arm/busdma_machdep.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -59,6 +58,7 @@ #include #include #include +#include #include //#define ARM_BUSDMA_MAPLOAD_STATS diff --git a/sys/arm/arm/exception.S b/sys/arm/arm/exception.S index 2c25628f77cc04..efd460de9b3567 100644 --- a/sys/arm/arm/exception.S +++ b/sys/arm/arm/exception.S @@ -51,8 +51,8 @@ #include #include #include +#include #include -#include #ifdef KDTRACE_HOOKS .bss diff --git a/sys/arm/arm/generic_timer.c b/sys/arm/arm/generic_timer.c index 9b5f0f52368b8f..fb7701f05289b2 100644 --- a/sys/arm/arm/generic_timer.c +++ b/sys/arm/arm/generic_timer.c @@ -54,7 +54,7 @@ #include #include -#include +#include #include #include @@ -778,10 +778,11 @@ arm_tmr_attach(device_t dev) static device_method_t arm_tmr_fdt_methods[] = { DEVMETHOD(device_probe, arm_tmr_fdt_probe), DEVMETHOD(device_attach, arm_tmr_fdt_attach), - { 0, 0 } + + DEVMETHOD_END }; -static DEFINE_CLASS_0(generic_timer, arm_tmr_fdt_driver, arm_tmr_fdt_methods, +PRIVATE_DEFINE_CLASSN(generic_timer, arm_tmr_fdt_driver, arm_tmr_fdt_methods, sizeof(struct arm_tmr_softc)); EARLY_DRIVER_MODULE(timer, simplebus, arm_tmr_fdt_driver, 0, 0, @@ -795,10 +796,11 @@ static device_method_t arm_tmr_acpi_methods[] = { DEVMETHOD(device_identify, arm_tmr_acpi_identify), DEVMETHOD(device_probe, arm_tmr_acpi_probe), DEVMETHOD(device_attach, arm_tmr_acpi_attach), - { 0, 0 } + + DEVMETHOD_END }; -static DEFINE_CLASS_0(generic_timer, arm_tmr_acpi_driver, arm_tmr_acpi_methods, +PRIVATE_DEFINE_CLASSN(generic_timer, arm_tmr_acpi_driver, arm_tmr_acpi_methods, sizeof(struct arm_tmr_softc)); EARLY_DRIVER_MODULE(timer, acpi, arm_tmr_acpi_driver, 0, 0, diff --git a/sys/arm/arm/gic.c b/sys/arm/arm/gic.c index b1b7aacd63abb2..10fd11081d2830 100644 --- a/sys/arm/arm/gic.c +++ b/sys/arm/arm/gic.c @@ -58,7 +58,7 @@ #include #include -#include +#include #include #ifdef FDT @@ -1224,15 +1224,17 @@ static device_method_t arm_gic_methods[] = { DEVMETHOD(bus_read_ivar, arm_gic_read_ivar), DEVMETHOD(bus_write_ivar, arm_gic_write_ivar), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, arm_gic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, arm_gic_post_ithread), + DEVMETHOD(intr_event_post_filter, arm_gic_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_disable_intr, arm_gic_disable_intr), DEVMETHOD(pic_enable_intr, arm_gic_enable_intr), DEVMETHOD(pic_map_intr, arm_gic_map_intr), DEVMETHOD(pic_setup_intr, arm_gic_setup_intr), DEVMETHOD(pic_teardown_intr, arm_gic_teardown_intr), - DEVMETHOD(pic_post_filter, arm_gic_post_filter), - DEVMETHOD(pic_post_ithread, arm_gic_post_ithread), - DEVMETHOD(pic_pre_ithread, arm_gic_pre_ithread), #ifdef SMP DEVMETHOD(pic_bind_intr, arm_gic_bind_intr), DEVMETHOD(pic_init_secondary, arm_gic_init_secondary), @@ -1250,11 +1252,11 @@ static device_method_t arm_gic_methods[] = { DEVMETHOD(gic_db_show, arm_gic_db_show), #endif - { 0, 0 } + DEVMETHOD_END }; -DEFINE_CLASS_0(gic, arm_gic_driver, arm_gic_methods, - sizeof(struct arm_gic_softc)); +DEFINE_CLASSN(gic, arm_gic_driver, arm_gic_methods, + sizeof(struct arm_gic_softc), pic_base_class); #ifdef DDB DB_SHOW_COMMAND_FLAGS(gic, db_show_gic, CS_OWN) diff --git a/sys/arm/arm/gic_acpi.c b/sys/arm/arm/gic_acpi.c index 6c8257beddfb95..5922b8603e6c4a 100644 --- a/sys/arm/arm/gic_acpi.c +++ b/sys/arm/arm/gic_acpi.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include #include @@ -71,7 +71,7 @@ static device_method_t gic_acpi_methods[] = { /* Bus interface */ DEVMETHOD(bus_get_resource_list, gic_acpi_get_resource_list), - DEVMETHOD_END, + DEVMETHOD_END }; DEFINE_CLASS_1(gic, gic_acpi_driver, gic_acpi_methods, diff --git a/sys/arm/arm/gic_fdt.c b/sys/arm/arm/gic_fdt.c index 1546e754c2e3fc..c2183c5d17df4c 100644 --- a/sys/arm/arm/gic_fdt.c +++ b/sys/arm/arm/gic_fdt.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include @@ -97,7 +97,7 @@ static device_method_t gic_fdt_methods[] = { DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - DEVMETHOD_END, + DEVMETHOD_END }; DEFINE_CLASS_1(gic, gic_fdt_driver, gic_fdt_methods, diff --git a/sys/arm/arm/machdep_intr.c b/sys/arm/arm/machdep_intr.c index 712336e7c0483f..976b74b93b69bb 100644 --- a/sys/arm/arm/machdep_intr.c +++ b/sys/arm/arm/machdep_intr.c @@ -32,7 +32,7 @@ #include #include -#include +#include /* * arm_irq_memory_barrier() diff --git a/sys/arm/arm/mp_machdep.c b/sys/arm/arm/mp_machdep.c index 9a4dc4e503e15b..0e10ae35004d97 100644 --- a/sys/arm/arm/mp_machdep.c +++ b/sys/arm/arm/mp_machdep.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -52,6 +51,7 @@ #include #include #include +#include #include #ifdef VFP #include diff --git a/sys/arm/arm/mpcore_timer.c b/sys/arm/arm/mpcore_timer.c index b4da9426128a51..5c9f63d5b03702 100644 --- a/sys/arm/arm/mpcore_timer.c +++ b/sys/arm/arm/mpcore_timer.c @@ -56,7 +56,7 @@ #include #include #include -#include +#include #include /* For arm_set_delay */ @@ -447,15 +447,13 @@ arm_tmr_attach(device_t dev) static device_method_t arm_tmr_methods[] = { DEVMETHOD(device_probe, arm_tmr_probe), DEVMETHOD(device_attach, arm_tmr_attach), - { 0, 0 } -}; -static driver_t arm_tmr_driver = { - "mp_tmr", - arm_tmr_methods, - sizeof(struct arm_tmr_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(arm_tmr_methods, arm_tmr_driver, arm_tmr_methods, + sizeof(struct arm_tmr_softc)); + EARLY_DRIVER_MODULE(mp_tmr, simplebus, arm_tmr_driver, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_MIDDLE); EARLY_DRIVER_MODULE(mp_tmr, ofwbus, arm_tmr_driver, 0, 0, diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c index 3653d7087a5cfd..8e2c0477b422c1 100644 --- a/sys/arm/arm/nexus.c +++ b/sys/arm/arm/nexus.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -53,7 +52,7 @@ #include #include -#include +#include #include #include @@ -139,14 +138,11 @@ static device_method_t nexus_methods[] = { /* ofw_bus interface */ DEVMETHOD(ofw_bus_map_intr, nexus_ofw_map_intr), #endif + DEVMETHOD_END }; -static driver_t nexus_driver = { - "nexus", - nexus_methods, - 1 /* no softc */ -}; +PRIVATE_DEFINE_CLASSN(nexus, nexus_driver, nexus_methods, 0 /* no softc */); EARLY_DRIVER_MODULE(nexus, root, nexus_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_EARLY); diff --git a/sys/arm/arm/pl310.c b/sys/arm/arm/pl310.c index 46bf654de90b94..a1342e3a5a1e4c 100644 --- a/sys/arm/arm/pl310.c +++ b/sys/arm/arm/pl310.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include @@ -577,14 +577,12 @@ pl310_attach(device_t dev) static device_method_t pl310_methods[] = { DEVMETHOD(device_probe, pl310_probe), DEVMETHOD(device_attach, pl310_attach), + DEVMETHOD_END }; -static driver_t pl310_driver = { - "l2cache", - pl310_methods, - sizeof(struct pl310_softc), -}; +PRIVATE_DEFINE_CLASSN(l2cache, pl310_driver, pl310_methods, + sizeof(struct pl310_softc)); EARLY_DRIVER_MODULE(pl310, simplebus, pl310_driver, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/arm/platform.c b/sys/arm/arm/platform.c index 9cf2968ace6c50..ffc409f55ef0cc 100644 --- a/sys/arm/arm/platform.c +++ b/sys/arm/arm/platform.c @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/arm/arm/pmu.c b/sys/arm/arm/pmu.c index 1c9e17a85c5791..c90ca2a2f51064 100644 --- a/sys/arm/arm/pmu.c +++ b/sys/arm/arm/pmu.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include "pmu.h" diff --git a/sys/arm/arm/pmu_acpi.c b/sys/arm/arm/pmu_acpi.c index db4790f2760a49..c869ea1e927fdc 100644 --- a/sys/arm/arm/pmu_acpi.c +++ b/sys/arm/arm/pmu_acpi.c @@ -182,7 +182,8 @@ static device_method_t pmu_acpi_methods[] = { DEVMETHOD(device_identify, pmu_acpi_identify), DEVMETHOD(device_probe, pmu_acpi_probe), DEVMETHOD(device_attach, pmu_acpi_attach), - DEVMETHOD_END, + + DEVMETHOD_END }; DEFINE_CLASS_0(pmu, pmu_acpi_driver, pmu_acpi_methods, diff --git a/sys/arm/arm/pmu_fdt.c b/sys/arm/arm/pmu_fdt.c index 3e733f3e1b18ba..18b5f30e7ca1f9 100644 --- a/sys/arm/arm/pmu_fdt.c +++ b/sys/arm/arm/pmu_fdt.c @@ -222,13 +222,11 @@ pmu_fdt_attach(device_t dev) static device_method_t pmu_fdt_methods[] = { DEVMETHOD(device_probe, pmu_fdt_probe), DEVMETHOD(device_attach, pmu_fdt_attach), - { 0, 0 } -}; -static driver_t pmu_fdt_driver = { - "pmu", - pmu_fdt_methods, - sizeof(struct pmu_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(pmu, pmu_fdt_driver, pmu_fdt_methods, + sizeof(struct pmu_softc)); + DRIVER_MODULE(pmu, simplebus, pmu_fdt_driver, 0, 0); diff --git a/sys/arm/arm/sp804.c b/sys/arm/arm/sp804.c index 98d6fa361a9856..0a02c5787888c4 100644 --- a/sys/arm/arm/sp804.c +++ b/sys/arm/arm/sp804.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include /* For arm_set_delay */ @@ -298,15 +298,13 @@ sp804_timer_attach(device_t dev) static device_method_t sp804_timer_methods[] = { DEVMETHOD(device_probe, sp804_timer_probe), DEVMETHOD(device_attach, sp804_timer_attach), - { 0, 0 } -}; -static driver_t sp804_timer_driver = { - "timer", - sp804_timer_methods, - sizeof(struct sp804_timer_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(timer, sp804_timer_driver, sp804_timer_methods, + sizeof(struct sp804_timer_softc)); + DRIVER_MODULE(sp804_timer, simplebus, sp804_timer_driver, 0, 0); static void diff --git a/sys/arm/broadcom/bcm2835/bcm2835_audio.c b/sys/arm/broadcom/bcm2835/bcm2835_audio.c index 13f309dd3f110c..41de71012a29d1 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_audio.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_audio.c @@ -952,15 +952,13 @@ static device_method_t bcm2835_audio_methods[] = { DEVMETHOD(device_probe, bcm2835_audio_probe), DEVMETHOD(device_attach, bcm2835_audio_attach), DEVMETHOD(device_detach, bcm2835_audio_detach), - { 0, 0 } -}; -static driver_t bcm2835_audio_driver = { - "pcm", - bcm2835_audio_methods, - PCM_SOFTC_SIZE, + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(pcm, bcm2835_audio_driver, bcm2835_audio_methods, + PCM_SOFTC_SIZE); + DRIVER_MODULE(bcm2835_audio, vchiq, bcm2835_audio_driver, 0, 0); MODULE_DEPEND(bcm2835_audio, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER); MODULE_DEPEND(bcm2835_audio, vchiq, 1, 1, 1); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_bsc.c b/sys/arm/broadcom/bcm2835/bcm2835_bsc.c index a4cbef7d528fdd..67000346d77104 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_bsc.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_bsc.c @@ -712,11 +712,8 @@ static device_method_t bcm_bsc_methods[] = { DEVMETHOD_END }; -static driver_t bcm_bsc_driver = { - "iichb", - bcm_bsc_methods, - sizeof(struct bcm_bsc_softc), -}; +PRIVATE_DEFINE_CLASSN(iichb, bcm_bsc_driver, bcm_bsc_methods, + sizeof(struct bcm_bsc_softc)); DRIVER_MODULE(iicbus, bcm2835_bsc, iicbus_driver, 0, 0); DRIVER_MODULE(bcm2835_bsc, simplebus, bcm_bsc_driver, 0, 0); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_clkman.c b/sys/arm/broadcom/bcm2835/bcm2835_clkman.c index 7061acbba8200c..b4fbcc07ca18eb 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_clkman.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_clkman.c @@ -200,11 +200,8 @@ static device_method_t bcm2835_clkman_methods[] = { DEVMETHOD_END }; -static driver_t bcm2835_clkman_driver = { - "bcm2835_clkman", - bcm2835_clkman_methods, - sizeof(struct bcm2835_clkman_softc), -}; +PRIVATE_DEFINE_CLASSN(bcm2835_clkman, bcm2835_clkman_driver, + bcm2835_clkman_methods, sizeof(struct bcm2835_clkman_softc)); DRIVER_MODULE(bcm2835_clkman, simplebus, bcm2835_clkman_driver, 0, 0); MODULE_VERSION(bcm2835_clkman, 1); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c b/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c index 3ef564c6ae13c6..350bd80b014979 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include @@ -1569,11 +1569,8 @@ static device_method_t bcm2835_cpufreq_methods[] = { DEVMETHOD_END }; -static driver_t bcm2835_cpufreq_driver = { - "bcm2835_cpufreq", - bcm2835_cpufreq_methods, - sizeof(struct bcm2835_cpufreq_softc), -}; +PRIVATE_DEFINE_CLASSN(bcm2835_cpufreq, bcm2835_cpufreq_driver, + bcm2835_cpufreq_methods, sizeof(struct bcm2835_cpufreq_softc)); DRIVER_MODULE(bcm2835_cpufreq, cpu, bcm2835_cpufreq_driver, 0, 0); MODULE_DEPEND(bcm2835_cpufreq, bcm2835_firmware, 1, 1, 1); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_dma.c b/sys/arm/broadcom/bcm2835/bcm2835_dma.c index 3515b0315e5676..f344a4217eb4cc 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_dma.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_dma.c @@ -767,15 +767,13 @@ bcm_dma_attach(device_t dev) static device_method_t bcm_dma_methods[] = { DEVMETHOD(device_probe, bcm_dma_probe), DEVMETHOD(device_attach, bcm_dma_attach), - { 0, 0 } -}; -static driver_t bcm_dma_driver = { - "bcm_dma", - bcm_dma_methods, - sizeof(struct bcm_dma_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(bcm_dma, bcm_dma_driver, bcm_dma_methods, + sizeof(struct bcm_dma_softc)); + EARLY_DRIVER_MODULE(bcm_dma, simplebus, bcm_dma_driver, 0, 0, BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_MIDDLE); MODULE_VERSION(bcm_dma, 1); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_fb.c b/sys/arm/broadcom/bcm2835/bcm2835_fb.c index fd198afa18b41e..712df31b3c556a 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_fb.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_fb.c @@ -189,15 +189,13 @@ static device_method_t bcm_fb_methods[] = { /* Device interface */ DEVMETHOD(device_probe, bcm_fb_probe), DEVMETHOD(device_attach, bcm_fb_attach), - { 0, 0 } -}; -static driver_t bcm_fb_driver = { - "fb", - bcm_fb_methods, - sizeof(struct bcmsc_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(fb, bcm_fb_driver, bcm_fb_methods, + sizeof(struct bcmsc_softc)); + DRIVER_MODULE(bcm2835fb, ofwbus, bcm_fb_driver, 0, 0); DRIVER_MODULE(bcm2835fb, simplebus, bcm_fb_driver, 0, 0); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_fbd.c b/sys/arm/broadcom/bcm2835/bcm2835_fbd.c index 50e8689e9d8318..e43247b07ec1a2 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_fbd.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_fbd.c @@ -273,11 +273,8 @@ static device_method_t bcm_fb_methods[] = { DEVMETHOD_END }; -static driver_t bcm_fb_driver = { - "fb", - bcm_fb_methods, - sizeof(struct bcmsc_softc), -}; +PRIVATE_DEFINE_CLASSN(fb, bcm_fb_driver, bcm_fb_methods, + sizeof(struct bcmsc_softc)); DRIVER_MODULE(bcm2835fb, ofwbus, bcm_fb_driver, 0, 0); DRIVER_MODULE(bcm2835fb, simplebus, bcm_fb_driver, 0, 0); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c b/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c index bb8833574471aa..1f19602cde0315 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c @@ -52,7 +52,7 @@ #include #include -#include +#include #include #include @@ -322,11 +322,8 @@ static device_method_t ft5406ts_methods[] = { DEVMETHOD_END }; -static driver_t ft5406ts_driver = { - "ft5406ts", - ft5406ts_methods, - sizeof(struct ft5406ts_softc), -}; +PRIVATE_DEFINE_CLASSN(ft5406ts, ft5406ts_driver, ft5406ts_methods, + sizeof(struct ft5406ts_softc)); DRIVER_MODULE(ft5406ts, simplebus, ft5406ts_driver, 0, 0); MODULE_DEPEND(ft5406ts, evdev, 1, 1, 1); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c index e4fc57b79ba58a..d392a6cc1eec9c 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -44,7 +43,7 @@ #include #include -#include +#include #include #include @@ -1331,13 +1330,15 @@ static device_method_t bcm_gpio_methods[] = { DEVMETHOD(gpio_pin_set, bcm_gpio_pin_set), DEVMETHOD(gpio_pin_toggle, bcm_gpio_pin_toggle), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, bcm_gpio_pic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, bcm_gpio_pic_post_ithread), + DEVMETHOD(intr_event_post_filter, bcm_gpio_pic_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_disable_intr, bcm_gpio_pic_disable_intr), DEVMETHOD(pic_enable_intr, bcm_gpio_pic_enable_intr), DEVMETHOD(pic_map_intr, bcm_gpio_pic_map_intr), - DEVMETHOD(pic_post_filter, bcm_gpio_pic_post_filter), - DEVMETHOD(pic_post_ithread, bcm_gpio_pic_post_ithread), - DEVMETHOD(pic_pre_ithread, bcm_gpio_pic_pre_ithread), DEVMETHOD(pic_setup_intr, bcm_gpio_pic_setup_intr), DEVMETHOD(pic_teardown_intr, bcm_gpio_pic_teardown_intr), @@ -1350,11 +1351,8 @@ static device_method_t bcm_gpio_methods[] = { DEVMETHOD_END }; -static driver_t bcm_gpio_driver = { - "gpio", - bcm_gpio_methods, - sizeof(struct bcm_gpio_softc), -}; +PRIVATE_DEFINE_CLASSN(gpio, bcm_gpio_driver, bcm_gpio_methods, + sizeof(struct bcm_gpio_softc), pic_base_class); EARLY_DRIVER_MODULE(bcm_gpio, simplebus, bcm_gpio_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_intr.c b/sys/arm/broadcom/bcm2835/bcm2835_intr.c index 65ada57c0b605d..0ea7eed588e7aa 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_intr.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_intr.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include @@ -431,20 +431,20 @@ static device_method_t bcm_intc_methods[] = { DEVMETHOD(device_probe, bcm_intc_probe), DEVMETHOD(device_attach, bcm_intc_attach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, bcm_intc_pre_ithread), + DEVMETHOD(intr_event_post_ithread, bcm_intc_post_ithread), + DEVMETHOD(intr_event_post_filter, bcm_intc_post_filter), + DEVMETHOD(pic_disable_intr, bcm_intc_disable_intr), DEVMETHOD(pic_enable_intr, bcm_intc_enable_intr), DEVMETHOD(pic_map_intr, bcm_intc_map_intr), - DEVMETHOD(pic_post_filter, bcm_intc_post_filter), - DEVMETHOD(pic_post_ithread, bcm_intc_post_ithread), - DEVMETHOD(pic_pre_ithread, bcm_intc_pre_ithread), - { 0, 0 } -}; -static driver_t bcm_intc_driver = { - "intc", - bcm_intc_methods, - sizeof(struct bcm_intc_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(intc, bcm_intc_driver, bcm_intc_methods, + sizeof(struct bcm_intc_softc), pic_base_class); + EARLY_DRIVER_MODULE(intc, simplebus, bcm_intc_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c index be6b8971437d5f..c2b38a123ddc40 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_machdep.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_machdep.c @@ -117,7 +117,7 @@ static platform_method_t bcm2836_methods[] = { PLATFORMMETHOD(platform_mp_setmaxid, bcm2836_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF2(bcm2836, bcm2836_legacy, "bcm2836 (legacy)", 0, "brcm,bcm2709", 100); FDT_PLATFORM_DEF2(bcm2836, bcm2836, "bcm2836", 0, "brcm,bcm2836", 100); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c index a3a3744ce43c1f..86d83a9319f30d 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c @@ -283,11 +283,8 @@ static device_method_t bcm_mbox_methods[] = { DEVMETHOD_END }; -static driver_t bcm_mbox_driver = { - "mbox", - bcm_mbox_methods, - sizeof(struct bcm_mbox_softc), -}; +PRIVATE_DEFINE_CLASSN(mbox, bcm_mbox_driver, bcm_mbox_methods, + sizeof(struct bcm_mbox_softc)); EARLY_DRIVER_MODULE(mbox, simplebus, bcm_mbox_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_pwm.c b/sys/arm/broadcom/bcm2835/bcm2835_pwm.c index ad794a6d20ed13..72f580aa9c91cd 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_pwm.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_pwm.c @@ -498,11 +498,8 @@ static device_method_t bcm_pwm_methods[] = { DEVMETHOD_END }; -static driver_t bcm_pwm_driver = { - "pwm", - bcm_pwm_methods, - sizeof(struct bcm_pwm_softc), -}; +PRIVATE_DEFINE_CLASSN(pwm, bcm_pwm_driver, bcm_pwm_methods, + sizeof(struct bcm_pwm_softc)); DRIVER_MODULE(bcm2835_pwm, simplebus, bcm_pwm_driver, 0, 0); MODULE_DEPEND(bcm2835_pwm, bcm2835_clkman, 1, 1, 1); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_rng.c b/sys/arm/broadcom/bcm2835/bcm2835_rng.c index bc13bdba223834..de8451dddd0e7c 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_rng.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_rng.c @@ -541,11 +541,8 @@ static device_method_t bcm2835_rng_methods[] = { DEVMETHOD_END }; -static driver_t bcm2835_rng_driver = { - "bcmrng", - bcm2835_rng_methods, - sizeof(struct bcm2835_rng_softc) -}; +PRIVATE_DEFINE_CLASSN(bcmrng, bcm2835_rng_driver, bcm2835_rng_methods, + sizeof(struct bcm2835_rng_softc)); DRIVER_MODULE(bcm2835_rng, simplebus, bcm2835_rng_driver, 0, 0); DRIVER_MODULE(bcm2835_rng, ofwbus, bcm2835_rng_driver, 0, 0); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c b/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c index e0c4327d8e052e..71d6864c0f924d 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c @@ -850,11 +850,8 @@ static device_method_t bcm_sdhci_methods[] = { DEVMETHOD_END }; -static driver_t bcm_sdhci_driver = { - "sdhci_bcm", - bcm_sdhci_methods, - sizeof(struct bcm_sdhci_softc), -}; +PRIVATE_DEFINE_CLASSN(sdhci_bcm, bcm_sdhci_driver, bcm_sdhci_methods, + sizeof(struct bcm_sdhci_softc)); DRIVER_MODULE(sdhci_bcm, simplebus, bcm_sdhci_driver, NULL, NULL); #ifdef NOTYET diff --git a/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c b/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c index 2fe641ebe390c5..3bad21fde7140b 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c @@ -1272,11 +1272,8 @@ static device_method_t bcm_sdhost_methods[] = { DEVMETHOD_END }; -static driver_t bcm_sdhost_driver = { - "sdhost_bcm", - bcm_sdhost_methods, - sizeof(struct bcm_sdhost_softc), -}; +PRIVATE_DEFINE_CLASSN(sdhost_bcm, bcm_sdhost_driver, bcm_sdhost_methods, + sizeof(struct bcm_sdhost_softc)); DRIVER_MODULE(sdhost_bcm, simplebus, bcm_sdhost_driver, NULL, NULL); SDHCI_DEPEND(sdhost_bcm); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_spi.c b/sys/arm/broadcom/bcm2835/bcm2835_spi.c index a1a77d9fabb080..3aa6aa3db8fa2e 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_spi.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_spi.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include @@ -573,10 +573,7 @@ static device_method_t bcm_spi_methods[] = { DEVMETHOD_END }; -static driver_t bcm_spi_driver = { - "spi", - bcm_spi_methods, - sizeof(struct bcm_spi_softc), -}; +PRIVATE_DEFINE_CLASSN(spi, bcm_spi_driver, bcm_spi_methods, + sizeof(struct bcm_spi_softc)); DRIVER_MODULE(bcm2835_spi, simplebus, bcm_spi_driver, 0, 0); diff --git a/sys/arm/broadcom/bcm2835/bcm2835_wdog.c b/sys/arm/broadcom/bcm2835/bcm2835_wdog.c index 80cf22548791ea..f257abfcc0407a 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_wdog.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_wdog.c @@ -249,10 +249,7 @@ static device_method_t bcmwd_methods[] = { DEVMETHOD_END }; -static driver_t bcmwd_driver = { - "bcmwd", - bcmwd_methods, - sizeof(struct bcmwd_softc), -}; +PRIVATE_DEFINE_CLASSN(bcmwd, bcmwd_driver, bcmwd_methods, + sizeof(struct bcmwd_softc)); DRIVER_MODULE(bcmwd, simplebus, bcmwd_driver, 0, 0); diff --git a/sys/arm/broadcom/bcm2835/bcm2836.c b/sys/arm/broadcom/bcm2835/bcm2836.c index 7ed9dedaa77ebb..1263508dfaaaf5 100644 --- a/sys/arm/broadcom/bcm2835/bcm2836.c +++ b/sys/arm/broadcom/bcm2835/bcm2836.c @@ -44,7 +44,7 @@ #endif #include -#include +#include #include #ifdef SMP #include @@ -726,12 +726,14 @@ static device_method_t bcm_lintc_methods[] = { DEVMETHOD(device_probe, bcm_lintc_probe), DEVMETHOD(device_attach, bcm_lintc_attach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, bcm_lintc_pre_ithread), + DEVMETHOD(intr_event_post_ithread, bcm_lintc_post_ithread), + DEVMETHOD(intr_event_post_filter, bcm_lintc_post_filter), + DEVMETHOD(pic_disable_intr, bcm_lintc_disable_intr), DEVMETHOD(pic_enable_intr, bcm_lintc_enable_intr), DEVMETHOD(pic_map_intr, bcm_lintc_map_intr), - DEVMETHOD(pic_post_filter, bcm_lintc_post_filter), - DEVMETHOD(pic_post_ithread, bcm_lintc_post_ithread), - DEVMETHOD(pic_pre_ithread, bcm_lintc_pre_ithread), DEVMETHOD(pic_setup_intr, bcm_lintc_setup_intr), #ifdef SMP DEVMETHOD(pic_init_secondary, bcm_lintc_init_secondary), @@ -742,11 +744,8 @@ static device_method_t bcm_lintc_methods[] = { DEVMETHOD_END }; -static driver_t bcm_lintc_driver = { - "lintc", - bcm_lintc_methods, - sizeof(struct bcm_lintc_softc), -}; +PRIVATE_DEFINE_CLASSN(lintc, bcm_lintc_driver, bcm_lintc_methods, + sizeof(struct bcm_lintc_softc), pic_base_class); EARLY_DRIVER_MODULE(lintc, simplebus, bcm_lintc_driver, 0, 0, BUS_PASS_INTERRUPT); diff --git a/sys/arm/broadcom/bcm2835/bcm2836_mp.c b/sys/arm/broadcom/bcm2835/bcm2836_mp.c index c9b5599a416246..dbe3befc050c6e 100644 --- a/sys/arm/broadcom/bcm2835/bcm2836_mp.c +++ b/sys/arm/broadcom/bcm2835/bcm2836_mp.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/arm/broadcom/bcm2835/bcm2838_pci.c b/sys/arm/broadcom/bcm2835/bcm2838_pci.c index 2b2ad1e3bdf855..77077877c0e768 100644 --- a/sys/arm/broadcom/bcm2835/bcm2838_pci.c +++ b/sys/arm/broadcom/bcm2835/bcm2838_pci.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -47,7 +46,6 @@ #include #include -#include #include "pcib_if.h" #include "msi_if.h" diff --git a/sys/arm/broadcom/bcm2835/bcm2838_xhci.c b/sys/arm/broadcom/bcm2835/bcm2838_xhci.c index 25579d7227a57b..796bc2fed8d2c3 100644 --- a/sys/arm/broadcom/bcm2835/bcm2838_xhci.c +++ b/sys/arm/broadcom/bcm2835/bcm2838_xhci.c @@ -204,7 +204,7 @@ static device_method_t bcm_xhci_methods[] = { DEVMETHOD(device_probe, bcm_xhci_probe), DEVMETHOD(device_attach, bcm_xhci_attach), - DEVMETHOD_END, + DEVMETHOD_END }; DEFINE_CLASS_1(bcm_xhci, bcm_xhci_driver, bcm_xhci_methods, diff --git a/sys/arm/broadcom/bcm2835/raspberrypi_gpio.c b/sys/arm/broadcom/bcm2835/raspberrypi_gpio.c index 5a0f5cf2b1b372..73412950a199c8 100644 --- a/sys/arm/broadcom/bcm2835/raspberrypi_gpio.c +++ b/sys/arm/broadcom/bcm2835/raspberrypi_gpio.c @@ -443,11 +443,8 @@ static device_method_t rpi_fw_gpio_methods[] = { DEVMETHOD_END }; -static driver_t rpi_fw_gpio_driver = { - "gpio", - rpi_fw_gpio_methods, - sizeof(struct rpi_fw_gpio_softc), -}; +PRIVATE_DEFINE_CLASSN(gpio, rpi_fw_gpio_driver, rpi_fw_gpio_methods, + sizeof(struct rpi_fw_gpio_softc)); EARLY_DRIVER_MODULE(rpi_fw_gpio, bcm2835_firmware, rpi_fw_gpio_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/freescale/fsl_ocotp.c b/sys/arm/freescale/fsl_ocotp.c index cf275f9da41b3e..fb46cada583ffa 100644 --- a/sys/arm/freescale/fsl_ocotp.c +++ b/sys/arm/freescale/fsl_ocotp.c @@ -192,11 +192,8 @@ static device_method_t ocotp_methods[] = { DEVMETHOD_END }; -static driver_t ocotp_driver = { - "ocotp", - ocotp_methods, - sizeof(struct ocotp_softc) -}; +PRIVATE_DEFINE_CLASSN(ocotp, ocotp_driver, ocotp_methods, + sizeof(struct ocotp_softc)); EARLY_DRIVER_MODULE(ocotp, simplebus, ocotp_driver, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_FIRST); diff --git a/sys/arm/freescale/imx/imx6_ahci.c b/sys/arm/freescale/imx/imx6_ahci.c index ad46452903a49c..b51a3a72de942d 100644 --- a/sys/arm/freescale/imx/imx6_ahci.c +++ b/sys/arm/freescale/imx/imx6_ahci.c @@ -349,11 +349,8 @@ static device_method_t imx6_ahci_ata_methods[] = { DEVMETHOD_END }; -static driver_t ahci_ata_driver = { - "ahci", - imx6_ahci_ata_methods, - sizeof(struct ahci_controller) -}; +PRIVATE_DEFINE_CLASSN(ahci, ahci_ata_driver, imx6_ahci_ata_methods, + sizeof(struct ahci_controller)); DRIVER_MODULE(imx6_ahci, simplebus, ahci_ata_driver, 0, 0); MODULE_DEPEND(imx6_ahci, ahci, 1, 1, 1); diff --git a/sys/arm/freescale/imx/imx6_anatop.c b/sys/arm/freescale/imx/imx6_anatop.c index 740f185bfb8b64..8719508cf4da97 100644 --- a/sys/arm/freescale/imx/imx6_anatop.c +++ b/sys/arm/freescale/imx/imx6_anatop.c @@ -802,11 +802,8 @@ static device_method_t imx6_anatop_methods[] = { DEVMETHOD_END }; -static driver_t imx6_anatop_driver = { - "imx6_anatop", - imx6_anatop_methods, - sizeof(struct imx6_anatop_softc) -}; +PRIVATE_DEFINE_CLASSN(imx6_anatop, imx6_anatop_driver, imx6_anatop_methods, + sizeof(struct imx6_anatop_softc)); EARLY_DRIVER_MODULE(imx6_anatop, simplebus, imx6_anatop_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/freescale/imx/imx6_audmux.c b/sys/arm/freescale/imx/imx6_audmux.c index 45f00d362a1eee..c8bf3dd0a0c495 100644 --- a/sys/arm/freescale/imx/imx6_audmux.c +++ b/sys/arm/freescale/imx/imx6_audmux.c @@ -47,7 +47,7 @@ #include #include -#include +#include #define READ4(_sc, _reg) \ bus_space_read_4(_sc->bst, _sc->bsh, _reg) @@ -140,13 +140,11 @@ static device_method_t audmux_methods[] = { /* Device interface */ DEVMETHOD(device_probe, audmux_probe), DEVMETHOD(device_attach, audmux_attach), - { 0, 0 } -}; -static driver_t audmux_driver = { - "audmux", - audmux_methods, - sizeof(struct audmux_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(audmux, audmux_driver, audmux_methods, + sizeof(struct audmux_softc)); + DRIVER_MODULE(audmux, simplebus, audmux_driver, 0, 0); diff --git a/sys/arm/freescale/imx/imx6_ccm.c b/sys/arm/freescale/imx/imx6_ccm.c index b97d02553bf597..7800ba56f2c511 100644 --- a/sys/arm/freescale/imx/imx6_ccm.c +++ b/sys/arm/freescale/imx/imx6_ccm.c @@ -506,11 +506,7 @@ static device_method_t ccm_methods[] = { DEVMETHOD_END }; -static driver_t ccm_driver = { - "ccm", - ccm_methods, - sizeof(struct ccm_softc) -}; +PRIVATE_DEFINE_CLASSN(ccm, ccm_driver, ccm_methods, sizeof(struct ccm_softc)); EARLY_DRIVER_MODULE(ccm, simplebus, ccm_driver, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_EARLY); diff --git a/sys/arm/freescale/imx/imx6_hdmi.c b/sys/arm/freescale/imx/imx6_hdmi.c index 6a316fd1cbc33e..b4d8cae28d80bd 100644 --- a/sys/arm/freescale/imx/imx6_hdmi.c +++ b/sys/arm/freescale/imx/imx6_hdmi.c @@ -205,10 +205,7 @@ static device_method_t imx_hdmi_methods[] = { DEVMETHOD_END }; -static driver_t imx_hdmi_driver = { - "hdmi", - imx_hdmi_methods, - sizeof(struct imx_hdmi_softc) -}; +PRIVATE_DEFINE_CLASSN(hdmi, imx_hdmi_driver, imx_hdmi_methods, + sizeof(struct imx_hdmi_softc)); DRIVER_MODULE(hdmi, simplebus, imx_hdmi_driver, 0, 0); diff --git a/sys/arm/freescale/imx/imx6_ipu.c b/sys/arm/freescale/imx/imx6_ipu.c index 417c66002f7a7a..0341ee52e9b4c8 100644 --- a/sys/arm/freescale/imx/imx6_ipu.c +++ b/sys/arm/freescale/imx/imx6_ipu.c @@ -1256,11 +1256,7 @@ static device_method_t ipu_methods[] = { DEVMETHOD_END }; -static driver_t ipu_driver = { - "fb", - ipu_methods, - sizeof(struct ipu_softc), -}; +PRIVATE_DEFINE_CLASSN(fb, ipu_driver, ipu_methods, sizeof(struct ipu_softc)); DRIVER_MODULE(ipu, simplebus, ipu_driver, 0, 0); MODULE_VERSION(ipu, 1); diff --git a/sys/arm/freescale/imx/imx6_machdep.c b/sys/arm/freescale/imx/imx6_machdep.c index 9cfae5b9c802d1..519c5016b73a3a 100644 --- a/sys/arm/freescale/imx/imx6_machdep.c +++ b/sys/arm/freescale/imx/imx6_machdep.c @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include @@ -384,7 +384,7 @@ static platform_method_t imx6_methods[] = { PLATFORMMETHOD(platform_pl310_init, imx6_pl310_init), - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF2(imx6, imx6s, "i.MX6 Solo", 0, "fsl,imx6s", 80); diff --git a/sys/arm/freescale/imx/imx6_mp.c b/sys/arm/freescale/imx/imx6_mp.c index 0a8b9109c8bdf8..934f0f94a5d6c7 100644 --- a/sys/arm/freescale/imx/imx6_mp.c +++ b/sys/arm/freescale/imx/imx6_mp.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/arm/freescale/imx/imx6_sdma.c b/sys/arm/freescale/imx/imx6_sdma.c index 805024903b4e7c..2b82fd13808419 100644 --- a/sys/arm/freescale/imx/imx6_sdma.c +++ b/sys/arm/freescale/imx/imx6_sdma.c @@ -53,7 +53,7 @@ #include #include -#include +#include #include @@ -505,15 +505,13 @@ static device_method_t sdma_methods[] = { /* Device interface */ DEVMETHOD(device_probe, sdma_probe), DEVMETHOD(device_attach, sdma_attach), - { 0, 0 } -}; -static driver_t sdma_driver = { - "sdma", - sdma_methods, - sizeof(struct sdma_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(sdma, sdma_driver, sdma_methods, + sizeof(struct sdma_softc)); + /* We want to attach after all interrupt controllers, before anything else. */ EARLY_DRIVER_MODULE(sdma, simplebus, sdma_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST); diff --git a/sys/arm/freescale/imx/imx6_snvs.c b/sys/arm/freescale/imx/imx6_snvs.c index 82ba50f5481ea3..5f1dd471489705 100644 --- a/sys/arm/freescale/imx/imx6_snvs.c +++ b/sys/arm/freescale/imx/imx6_snvs.c @@ -221,11 +221,8 @@ static device_method_t snvs_methods[] = { DEVMETHOD_END }; -static driver_t snvs_driver = { - "snvs", - snvs_methods, - sizeof(struct snvs_softc), -}; +PRIVATE_DEFINE_CLASSN(snvs, snvs_driver, snvs_methods, + sizeof(struct snvs_softc)); DRIVER_MODULE(snvs, simplebus, snvs_driver, 0, 0); SIMPLEBUS_PNP_INFO(compat_data); diff --git a/sys/arm/freescale/imx/imx6_src.c b/sys/arm/freescale/imx/imx6_src.c index 0316338128fc25..92217b98e2a8b4 100644 --- a/sys/arm/freescale/imx/imx6_src.c +++ b/sys/arm/freescale/imx/imx6_src.c @@ -160,10 +160,6 @@ static device_method_t src_methods[] = { DEVMETHOD_END }; -static driver_t src_driver = { - "src", - src_methods, - sizeof(struct src_softc) -}; +PRIVATE_DEFINE_CLASSN(src, src_driver, src_methods, sizeof(struct src_softc)); DRIVER_MODULE(src, simplebus, src_driver, 0, 0); diff --git a/sys/arm/freescale/imx/imx6_ssi.c b/sys/arm/freescale/imx/imx6_ssi.c index cb77f1454e631e..bd6dd74541c615 100644 --- a/sys/arm/freescale/imx/imx6_ssi.c +++ b/sys/arm/freescale/imx/imx6_ssi.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include @@ -840,15 +840,12 @@ ssi_attach(device_t dev) static device_method_t ssi_pcm_methods[] = { DEVMETHOD(device_probe, ssi_probe), DEVMETHOD(device_attach, ssi_attach), - { 0, 0 } -}; -static driver_t ssi_pcm_driver = { - "pcm", - ssi_pcm_methods, - PCM_SOFTC_SIZE, + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(pcm, ssi_pcm_driver, ssi_pcm_methods, PCM_SOFTC_SIZE); + DRIVER_MODULE(ssi, simplebus, ssi_pcm_driver, 0, 0); MODULE_DEPEND(ssi, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER); MODULE_DEPEND(ssi, sdma, 0, 0, 0); diff --git a/sys/arm/freescale/imx/imx6_usbphy.c b/sys/arm/freescale/imx/imx6_usbphy.c index 648ddd51eb9f17..9904a3fa81f518 100644 --- a/sys/arm/freescale/imx/imx6_usbphy.c +++ b/sys/arm/freescale/imx/imx6_usbphy.c @@ -190,11 +190,8 @@ static device_method_t usbphy_methods[] = { DEVMETHOD_END }; -static driver_t usbphy_driver = { - "usbphy", - usbphy_methods, - sizeof(struct usbphy_softc) -}; +PRIVATE_DEFINE_CLASSN(usbphy, usbphy_driver, usbphy_methods, + sizeof(struct usbphy_softc)); /* * This driver needs to start before the ehci driver, but later than the usual diff --git a/sys/arm/freescale/imx/imx_epit.c b/sys/arm/freescale/imx/imx_epit.c index 3ea6b642fc8887..27ad49c0beafbe 100644 --- a/sys/arm/freescale/imx/imx_epit.c +++ b/sys/arm/freescale/imx/imx_epit.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include @@ -477,10 +477,7 @@ static device_method_t epit_methods[] = { DEVMETHOD_END }; -static driver_t epit_driver = { - "imx_epit", - epit_methods, - sizeof(struct epit_softc), -}; +PRIVATE_DEFINE_CLASSN(imx_epit, epit_driver, epit_methods, + sizeof(struct epit_softc)); EARLY_DRIVER_MODULE(imx_epit, simplebus, epit_driver, 0, 0, BUS_PASS_TIMER); diff --git a/sys/arm/freescale/imx/imx_gpio.c b/sys/arm/freescale/imx/imx_gpio.c index 7610d28af90e99..b25a83349bea3f 100644 --- a/sys/arm/freescale/imx/imx_gpio.c +++ b/sys/arm/freescale/imx/imx_gpio.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include @@ -64,9 +64,7 @@ #include "gpio_if.h" -#ifdef INTRNG #include "pic_if.h" -#endif #define WRITE4(_sc, _r, _v) \ bus_space_write_4((_sc)->sc_iot, (_sc)->sc_ioh, (_r), (_v)) @@ -93,23 +91,17 @@ #define IMX_GPIO_ISR_REG 0x018 /* Interrupt Status Register */ #define IMX_GPIO_EDGE_REG 0x01C /* Edge Detect Register */ -#ifdef INTRNG #define DEFAULT_CAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | \ GPIO_INTR_LEVEL_LOW | GPIO_INTR_LEVEL_HIGH | GPIO_INTR_EDGE_RISING | \ GPIO_INTR_EDGE_FALLING | GPIO_INTR_EDGE_BOTH) -#else -#define DEFAULT_CAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT) -#endif #define NGPIO 32 -#ifdef INTRNG struct gpio_irqsrc { struct intr_irqsrc gi_isrc; u_int gi_irq; uint32_t gi_mode; }; -#endif struct imx51_gpio_softc { device_t dev; @@ -121,9 +113,7 @@ struct imx51_gpio_softc { bus_space_handle_t sc_ioh; int gpio_npins; struct gpio_pin gpio_pins[NGPIO]; -#ifdef INTRNG struct gpio_irqsrc gpio_pic_irqsrc[NGPIO]; -#endif #ifdef IMX_ENABLE_CLOCKS clk_t clk; #endif @@ -173,7 +163,6 @@ static int imx51_gpio_pin_set(device_t, uint32_t, unsigned int); static int imx51_gpio_pin_get(device_t, uint32_t, unsigned int *); static int imx51_gpio_pin_toggle(device_t, uint32_t pin); -#ifdef INTRNG static int gpio_pic_map_fdt(struct imx51_gpio_softc *sc, struct intr_map_data_fdt *daf, u_int *irqp, uint32_t *modep) @@ -509,7 +498,6 @@ gpio_pic_register_isrcs(struct imx51_gpio_softc *sc) } return (0); } -#endif /* * @@ -835,7 +823,6 @@ imx51_gpio_attach(device_t dev) */ WRITE4(sc, IMX_GPIO_IMR_REG, 0); for (irq = 0; irq < 2; irq++) { -#ifdef INTRNG if ((bus_setup_intr(dev, sc->sc_res[1 + irq], INTR_TYPE_CLK, gpio_pic_filter, NULL, sc, &sc->gpio_ih[irq]))) { device_printf(dev, @@ -843,7 +830,6 @@ imx51_gpio_attach(device_t dev) imx51_gpio_detach(dev); return (ENXIO); } -#endif } unit = device_get_unit(dev); @@ -857,10 +843,8 @@ imx51_gpio_attach(device_t dev) "GPIO%d_IO%02d", unit + 1, i); } -#ifdef INTRNG gpio_pic_register_isrcs(sc); intr_pic_register(dev, OF_xref_from_node(ofw_bus_get_node(dev))); -#endif sc->sc_busdev = gpiobus_attach_bus(dev); if (sc->sc_busdev == NULL) { @@ -916,17 +900,17 @@ static device_method_t imx51_gpio_methods[] = { DEVMETHOD(device_attach, imx51_gpio_attach), DEVMETHOD(device_detach, imx51_gpio_detach), -#ifdef INTRNG + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, gpio_pic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, gpio_pic_post_ithread), + DEVMETHOD(intr_event_post_filter, gpio_pic_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_disable_intr, gpio_pic_disable_intr), DEVMETHOD(pic_enable_intr, gpio_pic_enable_intr), DEVMETHOD(pic_map_intr, gpio_pic_map_intr), DEVMETHOD(pic_setup_intr, gpio_pic_setup_intr), DEVMETHOD(pic_teardown_intr, gpio_pic_teardown_intr), - DEVMETHOD(pic_post_filter, gpio_pic_post_filter), - DEVMETHOD(pic_post_ithread, gpio_pic_post_ithread), - DEVMETHOD(pic_pre_ithread, gpio_pic_pre_ithread), -#endif /* OFW methods */ DEVMETHOD(ofw_bus_get_node, imx51_gpio_get_node), @@ -943,14 +927,12 @@ static device_method_t imx51_gpio_methods[] = { DEVMETHOD(gpio_pin_toggle, imx51_gpio_pin_toggle), DEVMETHOD(gpio_pin_access_32, imx51_gpio_pin_access_32), DEVMETHOD(gpio_pin_config_32, imx51_gpio_pin_config_32), - {0, 0}, -}; -static driver_t imx51_gpio_driver = { - "gpio", - imx51_gpio_methods, - sizeof(struct imx51_gpio_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(gpio, imx51_gpio_driver, imx51_gpio_methods, + sizeof(struct imx51_gpio_softc), pic_base_class); + EARLY_DRIVER_MODULE(imx51_gpio, simplebus, imx51_gpio_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/freescale/imx/imx_gpt.c b/sys/arm/freescale/imx/imx_gpt.c index 59d43b828dd826..8e6140416aa029 100644 --- a/sys/arm/freescale/imx/imx_gpt.c +++ b/sys/arm/freescale/imx/imx_gpt.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include /* For arm_set_delay */ #include @@ -385,11 +385,8 @@ static device_method_t imx_gpt_methods[] = { DEVMETHOD_END }; -static driver_t imx_gpt_driver = { - "imx_gpt", - imx_gpt_methods, - sizeof(struct imx_gpt_softc), -}; +PRIVATE_DEFINE_CLASSN(imx_gpt, imx_gpt_driver, imx_gpt_methods, + sizeof(struct imx_gpt_softc)); EARLY_DRIVER_MODULE(imx_gpt, simplebus, imx_gpt_driver, 0, 0, BUS_PASS_TIMER); diff --git a/sys/arm/freescale/imx/imx_i2c.c b/sys/arm/freescale/imx/imx_i2c.c index 3190ec294ab404..c6c4669be63fbd 100644 --- a/sys/arm/freescale/imx/imx_i2c.c +++ b/sys/arm/freescale/imx/imx_i2c.c @@ -192,11 +192,8 @@ static device_method_t i2c_methods[] = { DEVMETHOD_END }; -static driver_t i2c_driver = { - "imx_i2c", - i2c_methods, - sizeof(struct i2c_softc), -}; +PRIVATE_DEFINE_CLASSN(imx_i2c, i2c_driver, i2c_methods, + sizeof(struct i2c_softc)); DRIVER_MODULE(imx_i2c, simplebus, i2c_driver, 0, 0); DRIVER_MODULE(ofw_iicbus, imx_i2c, ofw_iicbus_driver, 0, 0); diff --git a/sys/arm/freescale/imx/imx_iomux.c b/sys/arm/freescale/imx/imx_iomux.c index 44393076a9e3f3..4863c5c79f2d32 100644 --- a/sys/arm/freescale/imx/imx_iomux.c +++ b/sys/arm/freescale/imx/imx_iomux.c @@ -316,11 +316,8 @@ static device_method_t imx_iomux_methods[] = { DEVMETHOD_END }; -static driver_t imx_iomux_driver = { - "imx_iomux", - imx_iomux_methods, - sizeof(struct iomux_softc), -}; +PRIVATE_DEFINE_CLASSN(imx_iomux, imx_iomux_driver, imx_iomux_methods, + sizeof(struct iomux_softc)); EARLY_DRIVER_MODULE(imx_iomux, simplebus, imx_iomux_driver, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/freescale/imx/imx_spi.c b/sys/arm/freescale/imx/imx_spi.c index dac42a800e9e73..0a3a7608e003c3 100644 --- a/sys/arm/freescale/imx/imx_spi.c +++ b/sys/arm/freescale/imx/imx_spi.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include @@ -593,11 +593,8 @@ static device_method_t spi_methods[] = { DEVMETHOD_END }; -static driver_t spi_driver = { - "imx_spi", - spi_methods, - sizeof(struct spi_softc), -}; +PRIVATE_DEFINE_CLASSN(imx_spi, spi_driver, spi_methods, + sizeof(struct spi_softc)); DRIVER_MODULE(imx_spi, simplebus, spi_driver, 0, 0); DRIVER_MODULE(ofw_spibus, imx_spi, ofw_spibus_driver, 0, 0); diff --git a/sys/arm/freescale/imx/imx_wdog.c b/sys/arm/freescale/imx/imx_wdog.c index 5bd6fabc3fe700..50cb2e03de8c95 100644 --- a/sys/arm/freescale/imx/imx_wdog.c +++ b/sys/arm/freescale/imx/imx_wdog.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include @@ -244,14 +244,12 @@ imx_wdog_attach(device_t dev) static device_method_t imx_wdog_methods[] = { DEVMETHOD(device_probe, imx_wdog_probe), DEVMETHOD(device_attach, imx_wdog_attach), + DEVMETHOD_END }; -static driver_t imx_wdog_driver = { - "imx_wdog", - imx_wdog_methods, - sizeof(struct imx_wdog_softc), -}; +PRIVATE_DEFINE_CLASSN(imx_wdog, imx_wdog_driver, imx_wdog_methods, + sizeof(struct imx_wdog_softc)); EARLY_DRIVER_MODULE(imx_wdog, simplebus, imx_wdog_driver, 0, 0, BUS_PASS_TIMER); SIMPLEBUS_PNP_INFO(compat_data); diff --git a/sys/arm/freescale/vybrid/vf_adc.c b/sys/arm/freescale/vybrid/vf_adc.c index cca30517dc20b2..5f69aa4722309d 100644 --- a/sys/arm/freescale/vybrid/vf_adc.c +++ b/sys/arm/freescale/vybrid/vf_adc.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include @@ -223,13 +223,10 @@ adc_attach(device_t dev) static device_method_t adc_methods[] = { DEVMETHOD(device_probe, adc_probe), DEVMETHOD(device_attach, adc_attach), - { 0, 0 } -}; -static driver_t adc_driver = { - "adc", - adc_methods, - sizeof(struct adc_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(adc, adc_driver, adc_methods, sizeof(struct adc_softc)); + DRIVER_MODULE(adc, simplebus, adc_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_anadig.c b/sys/arm/freescale/vybrid/vf_anadig.c index 17688a40604fa7..ca102e9d90b894 100644 --- a/sys/arm/freescale/vybrid/vf_anadig.c +++ b/sys/arm/freescale/vybrid/vf_anadig.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include @@ -229,13 +229,11 @@ anadig_attach(device_t dev) static device_method_t anadig_methods[] = { DEVMETHOD(device_probe, anadig_probe), DEVMETHOD(device_attach, anadig_attach), - { 0, 0 } -}; -static driver_t anadig_driver = { - "anadig", - anadig_methods, - sizeof(struct anadig_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(anadig, anadig_driver, anadig_methods, + sizeof(struct anadig_softc)); + DRIVER_MODULE(anadig, simplebus, anadig_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_ccm.c b/sys/arm/freescale/vybrid/vf_ccm.c index 35faf4bb735b86..f41f6f90f30b49 100644 --- a/sys/arm/freescale/vybrid/vf_ccm.c +++ b/sys/arm/freescale/vybrid/vf_ccm.c @@ -49,7 +49,7 @@ #include #include -#include +#include #include @@ -484,13 +484,10 @@ ccm_attach(device_t dev) static device_method_t ccm_methods[] = { DEVMETHOD(device_probe, ccm_probe), DEVMETHOD(device_attach, ccm_attach), - { 0, 0 } -}; -static driver_t ccm_driver = { - "ccm", - ccm_methods, - sizeof(struct ccm_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(ccm, ccm_driver, ccm_methods, sizeof(struct ccm_softc)); + DRIVER_MODULE(ccm, simplebus, ccm_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_dcu4.c b/sys/arm/freescale/vybrid/vf_dcu4.c index eae381de85561f..811efa171b37b6 100644 --- a/sys/arm/freescale/vybrid/vf_dcu4.c +++ b/sys/arm/freescale/vybrid/vf_dcu4.c @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include "fb_if.h" @@ -454,13 +454,10 @@ static device_method_t dcu_methods[] = { /* Framebuffer service methods */ DEVMETHOD(fb_getinfo, dcu4_fb_getinfo), - { 0, 0 } -}; -static driver_t dcu_driver = { - "fb", - dcu_methods, - sizeof(struct dcu_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(fb, dcu_driver, dcu_methods, sizeof(struct dcu_softc)); + DRIVER_MODULE(fb, simplebus, dcu_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_dmamux.c b/sys/arm/freescale/vybrid/vf_dmamux.c index 19891c6af98051..6b1346c2178d36 100644 --- a/sys/arm/freescale/vybrid/vf_dmamux.c +++ b/sys/arm/freescale/vybrid/vf_dmamux.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include @@ -138,13 +138,11 @@ dmamux_attach(device_t dev) static device_method_t dmamux_methods[] = { DEVMETHOD(device_probe, dmamux_probe), DEVMETHOD(device_attach, dmamux_attach), - { 0, 0 } -}; -static driver_t dmamux_driver = { - "dmamux", - dmamux_methods, - sizeof(struct dmamux_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(dmamux, dmamux_driver, dmamux_methods, + sizeof(struct dmamux_softc)); + DRIVER_MODULE(dmamux, simplebus, dmamux_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_edma.c b/sys/arm/freescale/vybrid/vf_edma.c index 5b8b7eaab7763d..7494aad5ff34f1 100644 --- a/sys/arm/freescale/vybrid/vf_edma.c +++ b/sys/arm/freescale/vybrid/vf_edma.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include @@ -323,13 +323,11 @@ edma_attach(device_t dev) static device_method_t edma_methods[] = { DEVMETHOD(device_probe, edma_probe), DEVMETHOD(device_attach, edma_attach), - { 0, 0 } -}; -static driver_t edma_driver = { - "edma", - edma_methods, - sizeof(struct edma_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(edma, edma_driver, edma_methods, + sizeof(struct edma_softc)); + DRIVER_MODULE(edma, simplebus, edma_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_ehci.c b/sys/arm/freescale/vybrid/vf_ehci.c index 3a8b4800844982..1f55c96adc7b12 100644 --- a/sys/arm/freescale/vybrid/vf_ehci.c +++ b/sys/arm/freescale/vybrid/vf_ehci.c @@ -151,15 +151,12 @@ static device_method_t ehci_methods[] = { /* Bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), - { 0, 0 } + + DEVMETHOD_END }; /* kobj_class definition */ -static driver_t ehci_driver = { - "ehci", - ehci_methods, - sizeof(ehci_softc_t) -}; +PRIVATE_DEFINE_CLASSN(ehci, ehci_driver, ehci_methods, sizeof(ehci_softc_t)); DRIVER_MODULE(vybrid_ehci, simplebus, ehci_driver, 0, 0); MODULE_DEPEND(vybrid_ehci, usb, 1, 1, 1); diff --git a/sys/arm/freescale/vybrid/vf_gpio.c b/sys/arm/freescale/vybrid/vf_gpio.c index c81524a8a27e0e..ef26ed441da40e 100644 --- a/sys/arm/freescale/vybrid/vf_gpio.c +++ b/sys/arm/freescale/vybrid/vf_gpio.c @@ -51,7 +51,7 @@ #include #include -#include +#include #include "gpio_if.h" @@ -369,13 +369,11 @@ static device_method_t vf_gpio_methods[] = { DEVMETHOD(gpio_pin_toggle, vf_gpio_pin_toggle), DEVMETHOD(gpio_pin_setflags, vf_gpio_pin_setflags), DEVMETHOD(gpio_pin_set, vf_gpio_pin_set), - { 0, 0 } -}; -static driver_t vf_gpio_driver = { - "gpio", - vf_gpio_methods, - sizeof(struct vf_gpio_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(gpio, vf_gpio_driver, vf_gpio_methods, + sizeof(struct vf_gpio_softc)); + DRIVER_MODULE(vf_gpio, simplebus, vf_gpio_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_iomuxc.c b/sys/arm/freescale/vybrid/vf_iomuxc.c index 3e90761513c6a6..7a498f4357a9a2 100644 --- a/sys/arm/freescale/vybrid/vf_iomuxc.c +++ b/sys/arm/freescale/vybrid/vf_iomuxc.c @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include @@ -195,13 +195,11 @@ iomuxc_attach(device_t dev) static device_method_t iomuxc_methods[] = { DEVMETHOD(device_probe, iomuxc_probe), DEVMETHOD(device_attach, iomuxc_attach), - { 0, 0 } -}; -static driver_t iomuxc_driver = { - "iomuxc", - iomuxc_methods, - sizeof(struct iomuxc_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(iomuxc, iomuxc_driver, iomuxc_methods, + sizeof(struct iomuxc_softc)); + DRIVER_MODULE(iomuxc, simplebus, iomuxc_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_machdep.c b/sys/arm/freescale/vybrid/vf_machdep.c index 2ab14f5154eb04..3a3cc2be49fa7f 100644 --- a/sys/arm/freescale/vybrid/vf_machdep.c +++ b/sys/arm/freescale/vybrid/vf_machdep.c @@ -79,7 +79,7 @@ static platform_method_t vf_methods[] = { PLATFORMMETHOD(platform_devmap_init, vf_devmap_init), PLATFORMMETHOD(platform_cpu_reset, vf_cpu_reset), - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(vf, "vybrid", 0, "freescale,vybrid", 200); diff --git a/sys/arm/freescale/vybrid/vf_mscm.c b/sys/arm/freescale/vybrid/vf_mscm.c index 5f986050ae9da6..d7c72a919ba10f 100644 --- a/sys/arm/freescale/vybrid/vf_mscm.c +++ b/sys/arm/freescale/vybrid/vf_mscm.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include @@ -109,13 +109,11 @@ mscm_attach(device_t dev) static device_method_t mscm_methods[] = { DEVMETHOD(device_probe, mscm_probe), DEVMETHOD(device_attach, mscm_attach), - { 0, 0 } -}; -static driver_t mscm_driver = { - "mscm", - mscm_methods, - sizeof(struct mscm_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(mscm, mscm_driver, mscm_methods, + sizeof(struct mscm_softc)); + DRIVER_MODULE(mscm, simplebus, mscm_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_port.c b/sys/arm/freescale/vybrid/vf_port.c index 215b66b346699c..154710740517df 100644 --- a/sys/arm/freescale/vybrid/vf_port.c +++ b/sys/arm/freescale/vybrid/vf_port.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include @@ -232,13 +232,11 @@ port_attach(device_t dev) static device_method_t port_methods[] = { DEVMETHOD(device_probe, port_probe), DEVMETHOD(device_attach, port_attach), - { 0, 0 } -}; -static driver_t port_driver = { - "port", - port_methods, - sizeof(struct port_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(port, port_driver, port_methods, + sizeof(struct port_softc)); + DRIVER_MODULE(port, simplebus, port_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_sai.c b/sys/arm/freescale/vybrid/vf_sai.c index e895529c481042..768869462e8fde 100644 --- a/sys/arm/freescale/vybrid/vf_sai.c +++ b/sys/arm/freescale/vybrid/vf_sai.c @@ -51,7 +51,7 @@ #include #include -#include +#include #include #include @@ -786,15 +786,12 @@ sai_attach(device_t dev) static device_method_t sai_pcm_methods[] = { DEVMETHOD(device_probe, sai_probe), DEVMETHOD(device_attach, sai_attach), - { 0, 0 } -}; -static driver_t sai_pcm_driver = { - "pcm", - sai_pcm_methods, - PCM_SOFTC_SIZE, + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(pcm, sai_pcm_driver, sai_pcm_methods, PCM_SOFTC_SIZE); + DRIVER_MODULE(sai, simplebus, sai_pcm_driver, 0, 0); MODULE_DEPEND(sai, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER); MODULE_VERSION(sai, 1); diff --git a/sys/arm/freescale/vybrid/vf_spi.c b/sys/arm/freescale/vybrid/vf_spi.c index 12dbaabe987ea4..cec90a5ede0b99 100644 --- a/sys/arm/freescale/vybrid/vf_spi.c +++ b/sys/arm/freescale/vybrid/vf_spi.c @@ -51,7 +51,7 @@ #include #include -#include +#include #include @@ -275,15 +275,13 @@ static device_method_t spi_methods[] = { /* Device interface */ DEVMETHOD(device_probe, spi_probe), DEVMETHOD(device_attach, spi_attach), + /* SPI interface */ DEVMETHOD(spibus_transfer, spi_transfer), - { 0, 0 } -}; -static driver_t spi_driver = { - "spi", - spi_methods, - sizeof(struct spi_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(spi, spi_driver, spi_methods, sizeof(struct spi_softc)); + DRIVER_MODULE(spi, simplebus, spi_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_src.c b/sys/arm/freescale/vybrid/vf_src.c index c038c816d0dedc..5599c26b4a6026 100644 --- a/sys/arm/freescale/vybrid/vf_src.c +++ b/sys/arm/freescale/vybrid/vf_src.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include @@ -133,13 +133,10 @@ src_attach(device_t dev) static device_method_t src_methods[] = { DEVMETHOD(device_probe, src_probe), DEVMETHOD(device_attach, src_attach), - { 0, 0 } -}; -static driver_t src_driver = { - "src", - src_methods, - sizeof(struct src_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(src, src_driver, src_methods, sizeof(struct src_softc)); + DRIVER_MODULE(src, simplebus, src_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_tcon.c b/sys/arm/freescale/vybrid/vf_tcon.c index f66f37383bd602..c116f4bbeb1a1d 100644 --- a/sys/arm/freescale/vybrid/vf_tcon.c +++ b/sys/arm/freescale/vybrid/vf_tcon.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include @@ -118,13 +118,11 @@ tcon_attach(device_t dev) static device_method_t tcon_methods[] = { DEVMETHOD(device_probe, tcon_probe), DEVMETHOD(device_attach, tcon_attach), - { 0, 0 } -}; -static driver_t tcon_driver = { - "tcon", - tcon_methods, - sizeof(struct tcon_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(tcon, tcon_driver, tcon_methods, + sizeof(struct tcon_softc)); + DRIVER_MODULE(tcon, simplebus, tcon_driver, 0, 0); diff --git a/sys/arm/freescale/vybrid/vf_uart.c b/sys/arm/freescale/vybrid/vf_uart.c index 855eabd31b943b..2407ab89b57499 100644 --- a/sys/arm/freescale/vybrid/vf_uart.c +++ b/sys/arm/freescale/vybrid/vf_uart.c @@ -267,7 +267,8 @@ static kobj_method_t vf_uart_methods[] = { KOBJMETHOD(uart_receive, vf_uart_bus_receive), KOBJMETHOD(uart_setsig, vf_uart_bus_setsig), KOBJMETHOD(uart_transmit, vf_uart_bus_transmit), - { 0, 0 } + + KOBJMETHOD_END }; static struct uart_class uart_vybrid_class = { diff --git a/sys/arm/include/intr.h b/sys/arm/include/interrupt.h similarity index 94% rename from sys/arm/include/intr.h rename to sys/arm/include/interrupt.h index 71e853c93ce24e..e48b06f76a8274 100644 --- a/sys/arm/include/intr.h +++ b/sys/arm/include/interrupt.h @@ -36,13 +36,11 @@ * */ -#ifndef _MACHINE_INTR_H_ -#define _MACHINE_INTR_H_ +#ifndef __MACHINE_INTERRUPT_H__ +#define __MACHINE_INTERRUPT_H__ #ifndef LOCORE -#ifdef FDT -#include -#endif +#include void arm_irq_memory_barrier(uintptr_t); #endif /* !LOCORE */ @@ -54,4 +52,4 @@ void arm_irq_memory_barrier(uintptr_t); #define INTR_ROOT_IRQ 0 #define INTR_ROOT_COUNT 1 -#endif /* _MACHINE_INTR_H */ +#endif /* __MACHINE_INTERRUPT_H__ */ diff --git a/sys/arm/mv/a37x0_gpio.c b/sys/arm/mv/a37x0_gpio.c index 86110ff87ab12b..28cb54c3b4b77b 100644 --- a/sys/arm/mv/a37x0_gpio.c +++ b/sys/arm/mv/a37x0_gpio.c @@ -328,11 +328,8 @@ static device_method_t a37x0_gpio_methods[] = { DEVMETHOD_END }; -static driver_t a37x0_gpio_driver = { - "gpio", - a37x0_gpio_methods, - sizeof(struct a37x0_gpio_softc), -}; +PRIVATE_DEFINE_CLASSN(gpio, a37x0_gpio_driver, a37x0_gpio_methods, + sizeof(struct a37x0_gpio_softc)); EARLY_DRIVER_MODULE(a37x0_gpio, simple_mfd, a37x0_gpio_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST); diff --git a/sys/arm/mv/a37x0_iic.c b/sys/arm/mv/a37x0_iic.c index 7d71cac23a400c..55475f883da203 100644 --- a/sys/arm/mv/a37x0_iic.c +++ b/sys/arm/mv/a37x0_iic.c @@ -469,11 +469,8 @@ static device_method_t a37x0_iic_methods[] = { DEVMETHOD_END }; -static driver_t a37x0_iic_driver = { - "iichb", - a37x0_iic_methods, - sizeof(struct a37x0_iic_softc), -}; +PRIVATE_DEFINE_CLASSN(iichb, a37x0_iic_driver, a37x0_iic_methods, + sizeof(struct a37x0_iic_softc)); DRIVER_MODULE(iicbus, a37x0_iic, iicbus_driver, 0, 0); DRIVER_MODULE(a37x0_iic, simplebus, a37x0_iic_driver, 0, 0); diff --git a/sys/arm/mv/a37x0_spi.c b/sys/arm/mv/a37x0_spi.c index 027dd57677a3d3..61e5c08c2a8a82 100644 --- a/sys/arm/mv/a37x0_spi.c +++ b/sys/arm/mv/a37x0_spi.c @@ -32,8 +32,8 @@ #include #include +#include #include -#include #include #include @@ -481,10 +481,7 @@ static device_method_t a37x0_spi_methods[] = { DEVMETHOD_END }; -static driver_t a37x0_spi_driver = { - "spi", - a37x0_spi_methods, - sizeof(struct a37x0_spi_softc), -}; +PRIVATE_DEFINE_CLASSN(spi, a37x0_spi_driver, a37x0_spi_methods, + sizeof(struct a37x0_spi_softc)); DRIVER_MODULE(a37x0_spi, simplebus, a37x0_spi_driver, 0, 0); diff --git a/sys/arm/mv/armada/thermal.c b/sys/arm/mv/armada/thermal.c index 3c97a1d3617b80..1193d586781eab 100644 --- a/sys/arm/mv/armada/thermal.c +++ b/sys/arm/mv/armada/thermal.c @@ -93,14 +93,6 @@ static int armada_thermal_probe(device_t); static int armada_thermal_attach(device_t); static int armada_thermal_detach(device_t); -static device_method_t armada_thermal_methods[] = { - DEVMETHOD(device_probe, armada_thermal_probe), - DEVMETHOD(device_attach, armada_thermal_attach), - DEVMETHOD(device_detach, armada_thermal_detach), - - DEVMETHOD_END -}; - struct armada_thermal_softc { device_t dev; @@ -115,12 +107,17 @@ struct armada_thermal_softc { u_long chip_temperature; }; -static driver_t armada_thermal_driver = { - "armada_thermal", - armada_thermal_methods, - sizeof(struct armada_thermal_softc) +static device_method_t armada_thermal_methods[] = { + DEVMETHOD(device_probe, armada_thermal_probe), + DEVMETHOD(device_attach, armada_thermal_attach), + DEVMETHOD(device_detach, armada_thermal_detach), + + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(armada_thermal, armada_thermal_driver, + armada_thermal_methods, sizeof(struct armada_thermal_softc)); + DRIVER_MODULE(armada_thermal, simplebus, armada_thermal_driver, 0, 0); DRIVER_MODULE(armada_thermal, ofwbus, armada_thermal_driver, 0, 0); diff --git a/sys/arm/mv/armada/wdt.c b/sys/arm/mv/armada/wdt.c index 6e2e22907c6820..3924a258b23e70 100644 --- a/sys/arm/mv/armada/wdt.c +++ b/sys/arm/mv/armada/wdt.c @@ -129,15 +129,13 @@ static void mv_watchdog_event(void *, unsigned int, int *); static device_method_t mv_wdt_methods[] = { DEVMETHOD(device_probe, mv_wdt_probe), DEVMETHOD(device_attach, mv_wdt_attach), - { 0, 0 } -}; -static driver_t mv_wdt_driver = { - "wdt", - mv_wdt_methods, - sizeof(struct mv_wdt_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(wdt, mv_wdt_driver, mv_wdt_methods, + sizeof(struct mv_wdt_softc)); + DRIVER_MODULE(wdt, simplebus, mv_wdt_driver, 0, 0); static int diff --git a/sys/arm/mv/armada38x/armada38x_mp.c b/sys/arm/mv/armada38x/armada38x_mp.c index 69e2df36eaec88..fb50255aa365fc 100644 --- a/sys/arm/mv/armada38x/armada38x_mp.c +++ b/sys/arm/mv/armada38x/armada38x_mp.c @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include diff --git a/sys/arm/mv/armada38x/armada38x_rtc.c b/sys/arm/mv/armada38x/armada38x_rtc.c index 7ad873d6414218..7dff9009dc1b15 100644 --- a/sys/arm/mv/armada38x/armada38x_rtc.c +++ b/sys/arm/mv/armada38x/armada38x_rtc.c @@ -127,14 +127,11 @@ static device_method_t mv_rtc_methods[] = { DEVMETHOD(clock_gettime, mv_rtc_gettime), DEVMETHOD(clock_settime, mv_rtc_settime), - { 0, 0 }, + DEVMETHOD_END }; -static driver_t mv_rtc_driver = { - "rtc", - mv_rtc_methods, - sizeof(struct mv_rtc_softc), -}; +PRIVATE_DEFINE_CLASSN(rtc, mv_rtc_driver, mv_rtc_methods, + sizeof(struct mv_rtc_softc)); #define RTC_A38X 1 #define RTC_A8K 2 diff --git a/sys/arm/mv/armada38x/pmsu.c b/sys/arm/mv/armada38x/pmsu.c index daddef876aa64f..4096f35464c661 100644 --- a/sys/arm/mv/armada38x/pmsu.c +++ b/sys/arm/mv/armada38x/pmsu.c @@ -66,15 +66,13 @@ static device_method_t pmsu_methods[] = { DEVMETHOD(device_probe, pmsu_probe), DEVMETHOD(device_attach, pmsu_attach), DEVMETHOD(device_detach, pmsu_detach), - { 0, 0 } -}; -static driver_t pmsu_driver = { - "pmsu", - pmsu_methods, - sizeof(struct pmsu_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(pmsu, pmsu_driver, pmsu_methods, + sizeof(struct pmsu_softc)); + DRIVER_MODULE(pmsu, simplebus, pmsu_driver, 0, 0); DRIVER_MODULE(pmsu, ofwbus, pmsu_driver, 0, 0); diff --git a/sys/arm/mv/clk/a37x0_nb_periph_clk_driver.c b/sys/arm/mv/clk/a37x0_nb_periph_clk_driver.c index b102f05d25c171..37c4815493e4f1 100644 --- a/sys/arm/mv/clk/a37x0_nb_periph_clk_driver.c +++ b/sys/arm/mv/clk/a37x0_nb_periph_clk_driver.c @@ -126,11 +126,8 @@ static device_method_t a37x0_nb_periph_clk_methods[] = { DEVMETHOD_END }; -static driver_t a37x0_nb_periph_driver = { - "a37x0_nb_periph_driver", - a37x0_nb_periph_clk_methods, - sizeof(struct a37x0_periph_clk_softc) -}; +PRIVATE_DEFINE_CLASSN(a37x0_nb_periph_driver, a37x0_nb_periph_driver, + a37x0_nb_periph_clk_methods, sizeof(struct a37x0_periph_clk_softc)); EARLY_DRIVER_MODULE(a37x0_nb_periph, simplebus, a37x0_nb_periph_driver, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/mv/clk/a37x0_sb_periph_clk_driver.c b/sys/arm/mv/clk/a37x0_sb_periph_clk_driver.c index 910525411c7fb3..8de32557269f7a 100644 --- a/sys/arm/mv/clk/a37x0_sb_periph_clk_driver.c +++ b/sys/arm/mv/clk/a37x0_sb_periph_clk_driver.c @@ -95,11 +95,8 @@ static device_method_t a37x0_sb_periph_clk_methods[] = { DEVMETHOD_END }; -static driver_t a37x0_sb_periph_driver = { - "a37x0_sb_periph_driver", - a37x0_sb_periph_clk_methods, - sizeof(struct a37x0_periph_clk_softc) -}; +PRIVATE_DEFINE_CLASSN(a37x0_sb_periph_driver, a37x0_sb_periph_driver, + a37x0_sb_periph_clk_methods, sizeof(struct a37x0_periph_clk_softc)); EARLY_DRIVER_MODULE(a37x0_sb_periph, simplebus, a37x0_sb_periph_driver, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/mv/clk/a37x0_tbg.c b/sys/arm/mv/clk/a37x0_tbg.c index 32ec1c83b102bc..4894d1ccf2fd98 100644 --- a/sys/arm/mv/clk/a37x0_tbg.c +++ b/sys/arm/mv/clk/a37x0_tbg.c @@ -103,11 +103,8 @@ static device_method_t a37x0_tbg_methods [] = { DEVMETHOD_END }; -static driver_t a37x0_tbg_driver = { - "a37x0_tbg", - a37x0_tbg_methods, - sizeof(struct a37x0_tbg_softc) -}; +PRIVATE_DEFINE_CLASSN(a37x0_tbg, a37x0_tbg_driver, a37x0_tbg_methods, + sizeof(struct a37x0_tbg_softc)); EARLY_DRIVER_MODULE(a37x0_tbg, simplebus, a37x0_tbg_driver, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/mv/clk/a37x0_xtal.c b/sys/arm/mv/clk/a37x0_xtal.c index 195c26259e6357..6df6b1a1d54eec 100644 --- a/sys/arm/mv/clk/a37x0_xtal.c +++ b/sys/arm/mv/clk/a37x0_xtal.c @@ -62,14 +62,12 @@ static device_method_t a37x0_xtal_methods [] = { DEVMETHOD(device_probe, a37x0_xtal_probe), DEVMETHOD(device_attach, a37x0_xtal_attach), DEVMETHOD(device_detach, a37x0_xtal_detach), + DEVMETHOD_END }; -static driver_t a37x0_xtal_driver = { - "a37x0-xtal", - a37x0_xtal_methods, - sizeof(struct a37x0_xtal_softc) -}; +PRIVATE_DEFINE_CLASSN(a37x0-xtal, a37x0_xtal_driver, a37x0_xtal_methods, + sizeof(struct a37x0_xtal_softc)); EARLY_DRIVER_MODULE(a37x0_xtal, simplebus, a37x0_xtal_driver, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_EARLY); diff --git a/sys/arm/mv/clk/armada38x_coreclk.c b/sys/arm/mv/clk/armada38x_coreclk.c index f0f7767397b50f..ffb564edcfb0a2 100644 --- a/sys/arm/mv/clk/armada38x_coreclk.c +++ b/sys/arm/mv/clk/armada38x_coreclk.c @@ -209,11 +209,8 @@ static device_method_t amada38x_coreclk_methods[] = { DEVMETHOD_END }; -static driver_t armada38x_coreclk_driver = { - "armada38x_coreclk", - amada38x_coreclk_methods, - sizeof(struct armada38x_coreclk_softc), -}; +PRIVATE_DEFINE_CLASSN(armada38x_coreclk, armada38x_coreclk_driver, + amada38x_coreclk_methods, sizeof(struct armada38x_coreclk_softc)); EARLY_DRIVER_MODULE(armada38x_coreclk, simplebus, armada38x_coreclk_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/mv/clk/armada38x_gateclk.c b/sys/arm/mv/clk/armada38x_gateclk.c index 24355d9c9dac96..6a26da9d4c4d57 100644 --- a/sys/arm/mv/clk/armada38x_gateclk.c +++ b/sys/arm/mv/clk/armada38x_gateclk.c @@ -226,11 +226,8 @@ static device_method_t armada38x_gateclk_methods[] = { DEVMETHOD_END }; -static driver_t armada38x_gateclk_driver = { - "armada38x_gateclk", - armada38x_gateclk_methods, - sizeof(struct armada38x_gateclk_softc), -}; +PRIVATE_DEFINE_CLASSN(armada38x_gateclk, armada38x_gateclk_driver, + armada38x_gateclk_methods, sizeof(struct armada38x_gateclk_softc)); EARLY_DRIVER_MODULE(armada38x_gateclk, simplebus, armada38x_gateclk_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE + 1); diff --git a/sys/arm/mv/gpio.c b/sys/arm/mv/gpio.c index 934c00236153af..86d669041ae30d 100644 --- a/sys/arm/mv/gpio.c +++ b/sys/arm/mv/gpio.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -45,8 +44,9 @@ #include #include #include + #include -#include +#include #include #include @@ -77,7 +77,9 @@ struct mv_gpio_softc { int mem_rid; struct resource * irq_res[GPIO_MAX_INTR_COUNT]; int irq_rid[GPIO_MAX_INTR_COUNT]; +#if 0 struct intr_event * gpio_events[MV_GPIO_MAX_NPINS]; +#endif void *ih_cookie[GPIO_MAX_INTR_COUNT]; bus_space_tag_t bst; bus_space_handle_t bsh; @@ -103,11 +105,15 @@ static int mv_gpio_probe(device_t); static int mv_gpio_attach(device_t); static int mv_gpio_intr(device_t, void *); +#if 0 static void mv_gpio_double_edge_init(device_t, int); +#endif static int mv_gpio_debounce_setup(device_t, int); static int mv_gpio_debounce_prepare(device_t, int); +#if 0 static int mv_gpio_debounce_init(device_t, int); +#endif static void mv_gpio_debounce_start(device_t, int); static void mv_gpio_debounce(void *); static void mv_gpio_debounced_state_set(device_t, int, uint8_t); @@ -122,23 +128,35 @@ static void mv_gpio_reg_clear(device_t, uint32_t, uint32_t); static void mv_gpio_blink(device_t, uint32_t, uint8_t); static void mv_gpio_polarity(device_t, uint32_t, uint8_t, uint8_t); +#if 0 static void mv_gpio_level(device_t, uint32_t, uint8_t); +#endif +#if 0 static void mv_gpio_edge(device_t, uint32_t, uint8_t); +#endif static void mv_gpio_out_en(device_t, uint32_t, uint8_t); static void mv_gpio_int_ack(struct mv_gpio_pindev *); static void mv_gpio_value_set(device_t, uint32_t, uint8_t); static uint32_t mv_gpio_value_get(device_t, uint32_t, uint8_t); +#if 0 static void mv_gpio_intr_mask(struct mv_gpio_pindev *); +#endif +#if 0 static void mv_gpio_intr_unmask(struct mv_gpio_pindev *); +#endif -void mv_gpio_finish_intrhandler(struct mv_gpio_pindev *); -int mv_gpio_setup_intrhandler(device_t, const char *, +#if 0 +static void mv_gpio_finish_intrhandler(struct mv_gpio_pindev *); +#endif +#if 0 +static int mv_gpio_setup_intrhandler(device_t, const char *, driver_filter_t *, void (*)(void *), void *, int, int, void **); -int mv_gpio_configure(device_t, uint32_t, uint32_t, uint32_t); -void mv_gpio_out(device_t, uint32_t, uint8_t, uint8_t); -uint8_t mv_gpio_in(device_t, uint32_t); +#endif +static int mv_gpio_configure(device_t, uint32_t, uint32_t, uint32_t); +static void mv_gpio_out(device_t, uint32_t, uint8_t, uint8_t); +static uint8_t mv_gpio_in(device_t, uint32_t); /* * GPIO interface @@ -178,11 +196,8 @@ static device_method_t mv_gpio_methods[] = { DEVMETHOD_END }; -static driver_t mv_gpio_driver = { - "gpio", - mv_gpio_methods, - sizeof(struct mv_gpio_softc), -}; +PRIVATE_DEFINE_CLASSN(gpio, mv_gpio_driver, mv_gpio_methods, + sizeof(struct mv_gpio_softc)); EARLY_DRIVER_MODULE(mv_gpio, simplebus, mv_gpio_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST); @@ -385,7 +400,8 @@ mv_gpio_intr(device_t dev, void *arg) * GPIO interrupt handling */ -void +#if 0 +static void mv_gpio_finish_intrhandler(struct mv_gpio_pindev *s) { /* When we acheive full interrupt support @@ -399,8 +415,10 @@ mv_gpio_finish_intrhandler(struct mv_gpio_pindev *s) */ free(s, M_DEVBUF); } +#endif -int +#if 0 +static int mv_gpio_setup_intrhandler(device_t dev, const char *name, driver_filter_t *filt, void (*hand)(void *), void *arg, int pin, int flags, void **cookiep) { @@ -425,6 +443,7 @@ mv_gpio_setup_intrhandler(device_t dev, const char *name, driver_filter_t *filt, } else if (sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_IRQ_DOUBLE_EDGE) mv_gpio_double_edge_init(dev, pin); MV_GPIO_UNLOCK(); +#error "This is very suspicious." error = intr_event_create(&event, (void *)s, 0, pin, (void (*)(void *))mv_gpio_intr_mask, (void (*)(void *))mv_gpio_intr_unmask, @@ -436,11 +455,14 @@ mv_gpio_setup_intrhandler(device_t dev, const char *name, driver_filter_t *filt, sc->gpio_events[pin] = event; } +#error "This fails to update interrupt names, as INTRNG isn't informed." intr_event_add_handler(event, name, filt, hand, arg, intr_priority(flags), flags, cookiep); return (0); } +#endif +#if 0 static void mv_gpio_intr_mask(struct mv_gpio_pindev *s) { @@ -470,7 +492,9 @@ mv_gpio_intr_mask(struct mv_gpio_pindev *s) return; } +#endif +#if 0 static void mv_gpio_intr_unmask(struct mv_gpio_pindev *s) { @@ -492,6 +516,7 @@ mv_gpio_intr_unmask(struct mv_gpio_pindev *s) return; } +#endif static void mv_gpio_exec_intr_handlers(device_t dev, uint32_t status, int high) @@ -522,25 +547,29 @@ mv_gpio_exec_intr_handlers(device_t dev, uint32_t status, int high) static void mv_gpio_intr_handler(device_t dev, int pin) { +#if 0 struct intr_irqsrc isrc; +#endif struct mv_gpio_softc *sc; sc = (struct mv_gpio_softc *)device_get_softc(dev); MV_GPIO_ASSERT_LOCKED(); +#if 0 #ifdef INTR_SOLO isrc.isrc_filter = NULL; #endif +#error "No known invoked functions modify ->gpio_events, therefore NOP." isrc.isrc_event = sc->gpio_events[pin]; - if (isrc.isrc_event == NULL || - CK_SLIST_EMPTY(&isrc.isrc_event->ie_handlers)) + if (CK_SLIST_EMPTY(&isrc.isrc_event.ie_handlers)) return; intr_isrc_dispatch(&isrc, NULL); +#endif } -int +static int mv_gpio_configure(device_t dev, uint32_t pin, uint32_t flags, uint32_t mask) { int error; @@ -596,6 +625,7 @@ mv_gpio_configure(device_t dev, uint32_t pin, uint32_t flags, uint32_t mask) return (0); } +#if 0 static void mv_gpio_double_edge_init(device_t dev, int pin) { @@ -612,6 +642,7 @@ mv_gpio_double_edge_init(device_t dev, int pin) else mv_gpio_polarity(dev, pin, 0, 0); } +#endif static int mv_gpio_debounce_setup(device_t dev, int pin) @@ -656,6 +687,7 @@ mv_gpio_debounce_prepare(device_t dev, int pin) return (0); } +#if 0 static int mv_gpio_debounce_init(device_t dev, int pin) { @@ -681,6 +713,7 @@ mv_gpio_debounce_init(device_t dev, int pin) return (0); } +#endif static void mv_gpio_debounce_start(device_t dev, int pin) @@ -819,7 +852,7 @@ mv_gpio_debounced_state_get(device_t dev, int pin) return (*state & (1 << pin)); } -void +static void mv_gpio_out(device_t dev, uint32_t pin, uint8_t val, uint8_t enable) { struct mv_gpio_softc *sc; @@ -833,7 +866,7 @@ mv_gpio_out(device_t dev, uint32_t pin, uint8_t val, uint8_t enable) MV_GPIO_UNLOCK(); } -uint8_t +static uint8_t mv_gpio_in(device_t dev, uint32_t pin) { uint8_t state; @@ -956,6 +989,7 @@ mv_gpio_polarity(device_t dev, uint32_t pin, uint8_t enable, uint8_t toggle) mv_gpio_reg_clear(dev, reg, pin); } +#if 0 static void mv_gpio_level(device_t dev, uint32_t pin, uint8_t enable) { @@ -973,7 +1007,9 @@ mv_gpio_level(device_t dev, uint32_t pin, uint8_t enable) else mv_gpio_reg_clear(dev, reg, pin); } +#endif +#if 0 static void mv_gpio_edge(device_t dev, uint32_t pin, uint8_t enable) { @@ -991,6 +1027,7 @@ mv_gpio_edge(device_t dev, uint32_t pin, uint8_t enable) else mv_gpio_reg_clear(dev, reg, pin); } +#endif static void mv_gpio_int_ack(struct mv_gpio_pindev *s) diff --git a/sys/arm/mv/ic.c b/sys/arm/mv/ic.c index aaea59ae2ca62a..44ac22c9c21f98 100644 --- a/sys/arm/mv/ic.c +++ b/sys/arm/mv/ic.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include @@ -134,15 +134,13 @@ mv_ic_attach(device_t dev) static device_method_t mv_ic_methods[] = { DEVMETHOD(device_probe, mv_ic_probe), DEVMETHOD(device_attach, mv_ic_attach), - { 0, 0 } -}; -static driver_t mv_ic_driver = { - "ic", - mv_ic_methods, - sizeof(struct mv_ic_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(ic, mv_ic_driver, mv_ic_methods, + sizeof(struct mv_ic_softc)); + DRIVER_MODULE(ic, simplebus, mv_ic_driver, 0, 0); int diff --git a/sys/arm/mv/mpic.c b/sys/arm/mv/mpic.c index 232eb85569484e..592785429d5f91 100644 --- a/sys/arm/mv/mpic.c +++ b/sys/arm/mv/mpic.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include @@ -377,22 +377,22 @@ static device_method_t mv_mpic_methods[] = { DEVMETHOD(device_probe, mv_mpic_probe), DEVMETHOD(device_attach, mv_mpic_attach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, mpic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, mpic_post_ithread), + DEVMETHOD(intr_event_post_filter, mpic_post_filter), + DEVMETHOD(pic_disable_intr, mpic_disable_intr), DEVMETHOD(pic_enable_intr, mpic_enable_intr), DEVMETHOD(pic_map_intr, mpic_map_intr), - DEVMETHOD(pic_post_filter, mpic_post_filter), - DEVMETHOD(pic_post_ithread, mpic_post_ithread), - DEVMETHOD(pic_pre_ithread, mpic_pre_ithread), DEVMETHOD(pic_ipi_send, mpic_ipi_send), - { 0, 0 } -}; -static driver_t mv_mpic_driver = { - "mpic", - mv_mpic_methods, - sizeof(struct mv_mpic_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(mpic, mv_mpic_driver, mv_mpic_methods, + sizeof(struct mv_mpic_softc), pic_base_class); + EARLY_DRIVER_MODULE(mpic, simplebus, mv_mpic_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/mv/mv_ap806_clock.c b/sys/arm/mv/mv_ap806_clock.c index 6d15d5687088f6..7977e0e8d50fd1 100644 --- a/sys/arm/mv/mv_ap806_clock.c +++ b/sys/arm/mv/mv_ap806_clock.c @@ -36,8 +36,8 @@ #include #include +#include #include -#include #include #include @@ -216,11 +216,8 @@ static device_method_t mv_ap806_clock_methods[] = { DEVMETHOD_END }; -static driver_t mv_ap806_clock_driver = { - "mv_ap806_clock", - mv_ap806_clock_methods, - sizeof(struct mv_ap806_clock_softc), -}; +PRIVATE_DEFINE_CLASSN(mv_ap806_clock, mv_ap806_clock_driver, + mv_ap806_clock_methods, sizeof(struct mv_ap806_clock_softc)); EARLY_DRIVER_MODULE(mv_ap806_clock, simplebus, mv_ap806_clock_driver, 0, 0, BUS_PASS_RESOURCE + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/mv/mv_ap806_gicp.c b/sys/arm/mv/mv_ap806_gicp.c index 5a2ff8faddab48..91c70cf03ff107 100644 --- a/sys/arm/mv/mv_ap806_gicp.c +++ b/sys/arm/mv/mv_ap806_gicp.c @@ -37,8 +37,8 @@ #include #include +#include #include -#include #include @@ -311,7 +311,7 @@ mv_ap806_gicp_pre_ithread(device_t dev, struct intr_irqsrc *isrc) sc = device_get_softc(dev); - PIC_PRE_ITHREAD(sc->parent, isrc); + INTR_EVENT_PRE_ITHREAD(sc->parent, isrc); } static void @@ -321,7 +321,7 @@ mv_ap806_gicp_post_ithread(device_t dev, struct intr_irqsrc *isrc) sc = device_get_softc(dev); - PIC_POST_ITHREAD(sc->parent, isrc); + INTR_EVENT_POST_ITHREAD(sc->parent, isrc); } static void @@ -331,7 +331,7 @@ mv_ap806_gicp_post_filter(device_t dev, struct intr_irqsrc *isrc) sc = device_get_softc(dev); - PIC_POST_FILTER(sc->parent, isrc); + INTR_EVENT_POST_FILTER(sc->parent, isrc); } static int @@ -370,7 +370,7 @@ mv_ap806_gicp_alloc_msi(device_t dev, device_t child, int count, int maxcount, if (ret != 0) goto fail; - srcs[i]->isrc_dev = dev; + srcs[i]->isrc_event.ie_pic = dev; } return (0); @@ -390,7 +390,7 @@ mv_ap806_gicp_release_msi(device_t dev, device_t child, int count, for (i = 0; i < count; i++) { BIT_SET(sc->msi_bitmap_size, - mv_ap806_gicp_irq_to_msi(sc, srcs[i]->isrc_irq), + mv_ap806_gicp_irq_to_msi(sc, srcs[i]->isrc_event.ie_irq), sc->msi_bitmap); } @@ -406,7 +406,7 @@ mv_ap806_gicp_map_msi(device_t dev, device_t child, struct intr_irqsrc *isrc, sc = device_get_softc(dev); *addr = rman_get_start(sc->res); - *data = mv_ap806_gicp_irq_to_msi(sc, isrc->isrc_irq); + *data = mv_ap806_gicp_irq_to_msi(sc, isrc->isrc_event.ie_irq); return (0); } @@ -417,6 +417,11 @@ static device_method_t mv_ap806_gicp_methods[] = { DEVMETHOD(device_attach, mv_ap806_gicp_attach), DEVMETHOD(device_detach, mv_ap806_gicp_detach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, mv_ap806_gicp_pre_ithread), + DEVMETHOD(intr_event_post_ithread, mv_ap806_gicp_post_ithread), + DEVMETHOD(intr_event_post_filter, mv_ap806_gicp_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_activate_intr, mv_ap806_gicp_activate_intr), DEVMETHOD(pic_disable_intr, mv_ap806_gicp_disable_intr), @@ -425,9 +430,6 @@ static device_method_t mv_ap806_gicp_methods[] = { DEVMETHOD(pic_deactivate_intr, mv_ap806_gicp_deactivate_intr), DEVMETHOD(pic_setup_intr, mv_ap806_gicp_setup_intr), DEVMETHOD(pic_teardown_intr, mv_ap806_gicp_teardown_intr), - DEVMETHOD(pic_post_filter, mv_ap806_gicp_post_filter), - DEVMETHOD(pic_post_ithread, mv_ap806_gicp_post_ithread), - DEVMETHOD(pic_pre_ithread, mv_ap806_gicp_pre_ithread), /* MSI interface */ DEVMETHOD(msi_alloc_msi, mv_ap806_gicp_alloc_msi), @@ -437,11 +439,8 @@ static device_method_t mv_ap806_gicp_methods[] = { DEVMETHOD_END }; -static driver_t mv_ap806_gicp_driver = { - "mv_ap806_gicp", - mv_ap806_gicp_methods, - sizeof(struct mv_ap806_gicp_softc), -}; +PRIVATE_DEFINE_CLASSN(mv_ap806_gicp, mv_ap806_gicp_driver, + mv_ap806_gicp_methods, sizeof(struct mv_ap806_gicp_softc), pic_base_class); EARLY_DRIVER_MODULE(mv_ap806_gicp, simplebus, mv_ap806_gicp_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/mv/mv_ap806_sei.c b/sys/arm/mv/mv_ap806_sei.c index d711c646395620..1bce3cef975f1b 100644 --- a/sys/arm/mv/mv_ap806_sei.c +++ b/sys/arm/mv/mv_ap806_sei.c @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include @@ -450,7 +450,7 @@ mv_ap806_sei_release_msi(device_t dev, device_t child, int count, struct intr_ir for (i = 0; i < count; i++) { BIT_SET(MV_AP806_SEI_CP_SIZE, - srcs[i]->isrc_irq - MV_AP806_SEI_CP_FIRST, + srcs[i]->isrc_event.ie_irq - MV_AP806_SEI_CP_FIRST, &sc->msi_bitmap); } @@ -466,7 +466,7 @@ mv_ap806_sei_map_msi(device_t dev, device_t child, struct intr_irqsrc *isrc, sc = device_get_softc(dev); *addr = rman_get_start(sc->mem_res) + MV_AP806_SEI_SETSPI_OFFSET; - *data = isrc->isrc_irq; + *data = isrc->isrc_event.ie_irq; return (0); } @@ -477,15 +477,17 @@ static device_method_t mv_ap806_sei_methods[] = { DEVMETHOD(device_attach, mv_ap806_sei_attach), DEVMETHOD(device_detach, mv_ap806_sei_detach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, mv_ap806_sei_pre_ithread), + DEVMETHOD(intr_event_post_ithread, mv_ap806_sei_post_ithread), + DEVMETHOD(intr_event_post_filter, mv_ap806_sei_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_disable_intr, mv_ap806_sei_disable_intr), DEVMETHOD(pic_enable_intr, mv_ap806_sei_enable_intr), DEVMETHOD(pic_map_intr, mv_ap806_sei_map_intr), DEVMETHOD(pic_setup_intr, mv_ap806_sei_setup_intr), DEVMETHOD(pic_teardown_intr, mv_ap806_sei_teardown_intr), - DEVMETHOD(pic_post_filter, mv_ap806_sei_post_filter), - DEVMETHOD(pic_post_ithread, mv_ap806_sei_post_ithread), - DEVMETHOD(pic_pre_ithread, mv_ap806_sei_pre_ithread), /* MSI interface */ DEVMETHOD(msi_alloc_msi, mv_ap806_sei_alloc_msi), @@ -495,11 +497,8 @@ static device_method_t mv_ap806_sei_methods[] = { DEVMETHOD_END }; -static driver_t mv_ap806_sei_driver = { - "mv_ap806_sei", - mv_ap806_sei_methods, - sizeof(struct mv_ap806_sei_softc), -}; +PRIVATE_DEFINE_CLASSN(mv_ap806_sei, mv_ap806_sei_driver, mv_ap806_sei_methods, + sizeof(struct mv_ap806_sei_softc), pic_base_class); EARLY_DRIVER_MODULE(mv_ap806_sei, simplebus, mv_ap806_sei_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/mv/mv_armv7_machdep.c b/sys/arm/mv/mv_armv7_machdep.c index 4fe59d2fe7df7e..09a0af6667a702 100644 --- a/sys/arm/mv/mv_armv7_machdep.c +++ b/sys/arm/mv/mv_armv7_machdep.c @@ -457,7 +457,7 @@ static platform_method_t mv_a38x_methods[] = { PLATFORMMETHOD(platform_mp_setmaxid, mv_a38x_platform_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(mv_a38x, "mv_a38x", 0, "marvell,armada380", 100); #endif @@ -474,6 +474,6 @@ static platform_method_t mv_axp_methods[] = { PLATFORMMETHOD(platform_mp_setmaxid, mv_axp_platform_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(mv_axp, "mv_axp", 0, "marvell,armadaxp", 100); diff --git a/sys/arm/mv/mv_common.c b/sys/arm/mv/mv_common.c index 5bfe4c08d7622a..7a539fd2745eff 100644 --- a/sys/arm/mv/mv_common.c +++ b/sys/arm/mv/mv_common.c @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/arm/mv/mv_cp110_clock.c b/sys/arm/mv/mv_cp110_clock.c index 9edc01e95074fe..ff4053f716392e 100644 --- a/sys/arm/mv/mv_cp110_clock.c +++ b/sys/arm/mv/mv_cp110_clock.c @@ -36,8 +36,8 @@ #include #include +#include #include -#include #include #include @@ -353,11 +353,8 @@ static device_method_t mv_cp110_clock_methods[] = { DEVMETHOD_END }; -static driver_t mv_cp110_clock_driver = { - "mv_cp110_clock", - mv_cp110_clock_methods, - sizeof(struct mv_cp110_clock_softc), -}; +PRIVATE_DEFINE_CLASSN(mv_cp110_clock, mv_cp110_clock_driver, + mv_cp110_clock_methods, sizeof(struct mv_cp110_clock_softc)); EARLY_DRIVER_MODULE(mv_cp110_clock, simplebus, mv_cp110_clock_driver, 0, 0, BUS_PASS_RESOURCE + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/mv/mv_cp110_icu.c b/sys/arm/mv/mv_cp110_icu.c index 25ec19bee57593..76fb5acb25279a 100644 --- a/sys/arm/mv/mv_cp110_icu.c +++ b/sys/arm/mv/mv_cp110_icu.c @@ -36,8 +36,8 @@ #include #include +#include #include -#include #include @@ -330,7 +330,7 @@ mv_cp110_icu_map_intr(device_t dev, struct intr_map_data *data, if (irq_no == ICU_INT_SATA1) WR4(sc, ICU_INT_CFG(ICU_INT_SATA0), vector); - (*isrcp)->isrc_dev = sc->dev; + (*isrcp)->isrc_event.ie_pic = sc->dev; return (ret); fail: @@ -406,7 +406,7 @@ mv_cp110_icu_pre_ithread(device_t dev, struct intr_irqsrc *isrc) sc = device_get_softc(dev); - PIC_PRE_ITHREAD(sc->parent, isrc); + INTR_EVENT_PRE_ITHREAD(sc->parent, isrc); } static void @@ -416,7 +416,7 @@ mv_cp110_icu_post_ithread(device_t dev, struct intr_irqsrc *isrc) sc = device_get_softc(dev); - PIC_POST_ITHREAD(sc->parent, isrc); + INTR_EVENT_POST_ITHREAD(sc->parent, isrc); } static void @@ -426,7 +426,7 @@ mv_cp110_icu_post_filter(device_t dev, struct intr_irqsrc *isrc) sc = device_get_softc(dev); - PIC_POST_FILTER(sc->parent, isrc); + INTR_EVENT_POST_FILTER(sc->parent, isrc); } static device_method_t mv_cp110_icu_methods[] = { @@ -435,6 +435,11 @@ static device_method_t mv_cp110_icu_methods[] = { DEVMETHOD(device_attach, mv_cp110_icu_attach), DEVMETHOD(device_detach, mv_cp110_icu_detach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, mv_cp110_icu_pre_ithread), + DEVMETHOD(intr_event_post_ithread, mv_cp110_icu_post_ithread), + DEVMETHOD(intr_event_post_filter, mv_cp110_icu_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_activate_intr, mv_cp110_icu_activate_intr), DEVMETHOD(pic_disable_intr, mv_cp110_icu_disable_intr), @@ -443,18 +448,12 @@ static device_method_t mv_cp110_icu_methods[] = { DEVMETHOD(pic_deactivate_intr, mv_cp110_icu_deactivate_intr), DEVMETHOD(pic_setup_intr, mv_cp110_icu_setup_intr), DEVMETHOD(pic_teardown_intr, mv_cp110_icu_teardown_intr), - DEVMETHOD(pic_post_filter, mv_cp110_icu_post_filter), - DEVMETHOD(pic_post_ithread, mv_cp110_icu_post_ithread), - DEVMETHOD(pic_pre_ithread, mv_cp110_icu_pre_ithread), DEVMETHOD_END }; -static driver_t mv_cp110_icu_driver = { - "mv_cp110_icu", - mv_cp110_icu_methods, - sizeof(struct mv_cp110_icu_softc), -}; +PRIVATE_DEFINE_CLASSN(mv_cp110_icu, mv_cp110_icu_driver, mv_cp110_icu_methods, + sizeof(struct mv_cp110_icu_softc), pic_base_class); EARLY_DRIVER_MODULE(mv_cp110_icu, mv_cp110_icu_bus, mv_cp110_icu_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST); diff --git a/sys/arm/mv/mv_pci.c b/sys/arm/mv/mv_pci.c index 5983076d6be807..df7d1e314b6d39 100644 --- a/sys/arm/mv/mv_pci.c +++ b/sys/arm/mv/mv_pci.c @@ -54,7 +54,7 @@ #include #include -#include +#include #include #include @@ -410,11 +410,8 @@ static device_method_t mv_pcib_methods[] = { DEVMETHOD_END }; -static driver_t mv_pcib_driver = { - "pcib", - mv_pcib_methods, - sizeof(struct mv_pcib_softc), -}; +PRIVATE_DEFINE_CLASSN(pcib, mv_pcib_driver, mv_pcib_methods, + sizeof(struct mv_pcib_softc)); DRIVER_MODULE(mv_pcib, ofwbus, mv_pcib_driver, 0, 0); DRIVER_MODULE(mv_pcib, pcib_ctrl, mv_pcib_driver, 0, 0); diff --git a/sys/arm/mv/mv_pci_ctrl.c b/sys/arm/mv/mv_pci_ctrl.c index 902c0e129dbb83..a21a9ead156875 100644 --- a/sys/arm/mv/mv_pci_ctrl.c +++ b/sys/arm/mv/mv_pci_ctrl.c @@ -84,6 +84,13 @@ static int mv_pcib_ctrl_fill_ranges(phandle_t, struct mv_pcib_ctrl_softc *); /* * Bus interface definitions */ +static struct ofw_compat_data mv_pcib_ctrl_compat[] = { + {"mrvl,pcie-ctrl", (uintptr_t)&ofw_bus_reg_to_rl}, + {"marvell,armada-370-pcie", + (uintptr_t)&ofw_bus_assigned_addresses_to_rl}, + {NULL, (uintptr_t)NULL}, +}; + static device_method_t mv_pcib_ctrl_methods[] = { /* Device interface */ DEVMETHOD(device_probe, mv_pcib_ctrl_probe), @@ -108,18 +115,8 @@ static device_method_t mv_pcib_ctrl_methods[] = { DEVMETHOD_END }; -static struct ofw_compat_data mv_pcib_ctrl_compat[] = { - {"mrvl,pcie-ctrl", (uintptr_t)&ofw_bus_reg_to_rl}, - {"marvell,armada-370-pcie", - (uintptr_t)&ofw_bus_assigned_addresses_to_rl}, - {NULL, (uintptr_t)NULL}, -}; - -static driver_t mv_pcib_ctrl_driver = { - "pcib_ctrl", - mv_pcib_ctrl_methods, - sizeof(struct mv_pcib_ctrl_softc), -}; +PRIVATE_DEFINE_CLASSN(pcib_ctrl, mv_pcib_ctrl_driver, mv_pcib_ctrl_methods, + sizeof(struct mv_pcib_ctrl_softc)); DRIVER_MODULE(pcib_ctrl, simplebus, mv_pcib_ctrl_driver, 0, 0); diff --git a/sys/arm/mv/mv_spi.c b/sys/arm/mv/mv_spi.c index 1f9c8ebf238038..f79cb2abe44da2 100644 --- a/sys/arm/mv/mv_spi.c +++ b/sys/arm/mv/mv_spi.c @@ -35,8 +35,8 @@ #include #include +#include #include -#include #include #include @@ -395,10 +395,7 @@ static device_method_t mv_spi_methods[] = { DEVMETHOD_END }; -static driver_t mv_spi_driver = { - "spi", - mv_spi_methods, - sizeof(struct mv_spi_softc), -}; +PRIVATE_DEFINE_CLASSN(spi, mv_spi_driver, mv_spi_methods, + sizeof(struct mv_spi_softc)); DRIVER_MODULE(mv_spi, simplebus, mv_spi_driver, 0, 0); diff --git a/sys/arm/mv/mv_thermal.c b/sys/arm/mv/mv_thermal.c index 9240666ec726cc..622a9114b06072 100644 --- a/sys/arm/mv/mv_thermal.c +++ b/sys/arm/mv/mv_thermal.c @@ -37,8 +37,8 @@ #include #include +#include #include -#include #include #include @@ -358,10 +358,7 @@ static device_method_t mv_thermal_methods[] = { DEVMETHOD_END }; -static driver_t mv_thermal_driver = { - "mv_thermal", - mv_thermal_methods, - sizeof(struct mv_thermal_softc), -}; +PRIVATE_DEFINE_CLASSN(mv_thermal, mv_thermal_driver, mv_thermal_methods, + sizeof(struct mv_thermal_softc)); DRIVER_MODULE(mv_thermal, simplebus, mv_thermal_driver, 0, 0); diff --git a/sys/arm/mv/mvebu_gpio.c b/sys/arm/mv/mvebu_gpio.c index 681cf20f7f9f54..ebcc5afd4e2194 100644 --- a/sys/arm/mv/mvebu_gpio.c +++ b/sys/arm/mv/mvebu_gpio.c @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include @@ -839,15 +839,17 @@ static device_method_t mvebu_gpio_methods[] = { DEVMETHOD(device_attach, mvebu_gpio_attach), DEVMETHOD(device_detach, mvebu_gpio_detach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, mvebu_gpio_pic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, mvebu_gpio_pic_post_ithread), + DEVMETHOD(intr_event_post_filter, mvebu_gpio_pic_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_disable_intr, mvebu_gpio_pic_disable_intr), DEVMETHOD(pic_enable_intr, mvebu_gpio_pic_enable_intr), DEVMETHOD(pic_map_intr, mvebu_gpio_pic_map_intr), DEVMETHOD(pic_setup_intr, mvebu_gpio_pic_setup_intr), DEVMETHOD(pic_teardown_intr, mvebu_gpio_pic_teardown_intr), - DEVMETHOD(pic_post_filter, mvebu_gpio_pic_post_filter), - DEVMETHOD(pic_post_ithread, mvebu_gpio_pic_post_ithread), - DEVMETHOD(pic_pre_ithread, mvebu_gpio_pic_pre_ithread), /* GPIO protocol */ DEVMETHOD(gpio_get_bus, mvebu_gpio_get_bus), @@ -867,7 +869,7 @@ static device_method_t mvebu_gpio_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(gpio, mvebu_gpio_driver, mvebu_gpio_methods, - sizeof(struct mvebu_gpio_softc)); +PRIVATE_DEFINE_CLASSN(gpio, mvebu_gpio_driver, mvebu_gpio_methods, + sizeof(struct mvebu_gpio_softc), pic_base_class); EARLY_DRIVER_MODULE(mvebu_gpio, simplebus, mvebu_gpio_driver, NULL, NULL, BUS_PASS_TIMER + BUS_PASS_ORDER_LAST); diff --git a/sys/arm/mv/mvebu_pinctrl.c b/sys/arm/mv/mvebu_pinctrl.c index 7e9ecda1a67a3f..2813ab3176d983 100644 --- a/sys/arm/mv/mvebu_pinctrl.c +++ b/sys/arm/mv/mvebu_pinctrl.c @@ -36,8 +36,8 @@ #include #include +#include #include -#include #include @@ -219,11 +219,8 @@ static device_method_t mv_pinctrl_methods[] = { DEVMETHOD_END }; -static driver_t mv_pinctrl_driver = { - "mv_pinctrl", - mv_pinctrl_methods, - sizeof(struct mv_pinctrl_softc), -}; +PRIVATE_DEFINE_CLASSN(mv_pinctrl, mv_pinctrl_driver, mv_pinctrl_methods, + sizeof(struct mv_pinctrl_softc)); EARLY_DRIVER_MODULE(mv_pinctrl, simplebus, mv_pinctrl_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/mv/rtc.c b/sys/arm/mv/rtc.c index cb8e4b6db62617..5c00f1a648ef8b 100644 --- a/sys/arm/mv/rtc.c +++ b/sys/arm/mv/rtc.c @@ -81,14 +81,11 @@ static device_method_t mv_rtc_methods[] = { DEVMETHOD(clock_gettime, mv_rtc_gettime), DEVMETHOD(clock_settime, mv_rtc_settime), - { 0, 0 }, + DEVMETHOD_END }; -static driver_t mv_rtc_driver = { - "rtc", - mv_rtc_methods, - sizeof(struct mv_rtc_softc), -}; +PRIVATE_DEFINE_CLASSN(rtc, mv_rtc_driver, mv_rtc_methods, + sizeof(struct mv_rtc_softc)); DRIVER_MODULE(mv_rtc, simplebus, mv_rtc_driver, 0, 0); diff --git a/sys/arm/mv/timer.c b/sys/arm/mv/timer.c index 8b5306fc7a94dc..2fdef9c25aad7c 100644 --- a/sys/arm/mv/timer.c +++ b/sys/arm/mv/timer.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include @@ -284,15 +284,13 @@ mv_hardclock(void *arg) static device_method_t mv_timer_methods[] = { DEVMETHOD(device_probe, mv_timer_probe), DEVMETHOD(device_attach, mv_timer_attach), - { 0, 0 } -}; -static driver_t mv_timer_driver = { - "timer", - mv_timer_methods, - sizeof(struct mv_timer_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(timer, mv_timer_driver, mv_timer_methods, + sizeof(struct mv_timer_softc)); + DRIVER_MODULE(timer_mv, simplebus, mv_timer_driver, 0, 0); static unsigned diff --git a/sys/arm/nvidia/as3722.c b/sys/arm/nvidia/as3722.c index 55cdc5111a1559..39318168aa05c5 100644 --- a/sys/arm/nvidia/as3722.c +++ b/sys/arm/nvidia/as3722.c @@ -402,6 +402,6 @@ static device_method_t as3722_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(gpio, as3722_driver, as3722_methods, +PRIVATE_DEFINE_CLASSN(gpio, as3722_driver, as3722_methods, sizeof(struct as3722_softc)); EARLY_DRIVER_MODULE(as3722, iicbus, as3722_driver, NULL, NULL, 74); diff --git a/sys/arm/nvidia/tegra124/tegra124_car.c b/sys/arm/nvidia/tegra124/tegra124_car.c index 57d7760494a6fc..444d14eb4331e0 100644 --- a/sys/arm/nvidia/tegra124/tegra124_car.c +++ b/sys/arm/nvidia/tegra124/tegra124_car.c @@ -593,7 +593,7 @@ static device_method_t tegra124_car_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(car, tegra124_car_driver, tegra124_car_methods, +PRIVATE_DEFINE_CLASSN(car, tegra124_car_driver, tegra124_car_methods, sizeof(struct tegra124_car_softc)); EARLY_DRIVER_MODULE(tegra124_car, simplebus, tegra124_car_driver, NULL, NULL, BUS_PASS_TIMER); diff --git a/sys/arm/nvidia/tegra124/tegra124_coretemp.c b/sys/arm/nvidia/tegra124/tegra124_coretemp.c index 42ed02de4f86a4..14a1d9deef416f 100644 --- a/sys/arm/nvidia/tegra124/tegra124_coretemp.c +++ b/sys/arm/nvidia/tegra124/tegra124_coretemp.c @@ -255,6 +255,6 @@ static device_method_t tegra124_coretemp_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(tegra124_coretemp, tegra124_coretemp_driver, +PRIVATE_DEFINE_CLASSN(tegra124_coretemp, tegra124_coretemp_driver, tegra124_coretemp_methods, sizeof(struct tegra124_coretemp_softc)); DRIVER_MODULE(tegra124_coretemp, cpu, tegra124_coretemp_driver, NULL, NULL); diff --git a/sys/arm/nvidia/tegra124/tegra124_cpufreq.c b/sys/arm/nvidia/tegra124/tegra124_cpufreq.c index a537d9397722c4..e4cd206cc4b729 100644 --- a/sys/arm/nvidia/tegra124/tegra124_cpufreq.c +++ b/sys/arm/nvidia/tegra124/tegra124_cpufreq.c @@ -583,6 +583,6 @@ static device_method_t tegra124_cpufreq_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(tegra124_cpufreq, tegra124_cpufreq_driver, +PRIVATE_DEFINE_CLASSN(tegra124_cpufreq, tegra124_cpufreq_driver, tegra124_cpufreq_methods, sizeof(struct tegra124_cpufreq_softc)); DRIVER_MODULE(tegra124_cpufreq, cpu, tegra124_cpufreq_driver, NULL, NULL); diff --git a/sys/arm/nvidia/tegra124/tegra124_machdep.c b/sys/arm/nvidia/tegra124/tegra124_machdep.c index 4f06622d1dacfe..e7b4f6cf7b6bf4 100644 --- a/sys/arm/nvidia/tegra124/tegra124_machdep.c +++ b/sys/arm/nvidia/tegra124/tegra124_machdep.c @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include @@ -146,7 +146,7 @@ static platform_method_t tegra124_methods[] = { PLATFORMMETHOD(platform_mp_start_ap, tegra124_mp_start_ap), PLATFORMMETHOD(platform_mp_setmaxid, tegra124_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(tegra124, "Nvidia Jetson-TK1", 0, "nvidia,jetson-tk1", 120); diff --git a/sys/arm/nvidia/tegra124/tegra124_mp.c b/sys/arm/nvidia/tegra124/tegra124_mp.c index 7764d6f36b31ce..ae91b4821abc3c 100644 --- a/sys/arm/nvidia/tegra124/tegra124_mp.c +++ b/sys/arm/nvidia/tegra124/tegra124_mp.c @@ -35,8 +35,8 @@ #include #include -#include #include +#include #include #include #include diff --git a/sys/arm/nvidia/tegra124/tegra124_pmc.c b/sys/arm/nvidia/tegra124/tegra124_pmc.c index 83bd0a1e698323..d7537f1d53cdc4 100644 --- a/sys/arm/nvidia/tegra124/tegra124_pmc.c +++ b/sys/arm/nvidia/tegra124/tegra124_pmc.c @@ -553,7 +553,7 @@ static device_method_t tegra124_pmc_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(pmc, tegra124_pmc_driver, tegra124_pmc_methods, +PRIVATE_DEFINE_CLASSN(pmc, tegra124_pmc_driver, tegra124_pmc_methods, sizeof(struct tegra124_pmc_softc)); EARLY_DRIVER_MODULE(tegra124_pmc, simplebus, tegra124_pmc_driver, NULL, NULL, 70); diff --git a/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c b/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c index b03fb9e0c3bf56..bb48c9a217f0a1 100644 --- a/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c +++ b/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c @@ -1196,7 +1196,7 @@ static device_method_t tegra_xusbpadctl_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(xusbpadctl, tegra_xusbpadctl_driver, +PRIVATE_DEFINE_CLASSN(xusbpadctl, tegra_xusbpadctl_driver, tegra_xusbpadctl_methods, sizeof(struct padctl_softc)); EARLY_DRIVER_MODULE(tegra_xusbpadctl, simplebus, tegra_xusbpadctl_driver, NULL, NULL, 73); diff --git a/sys/arm/nvidia/tegra_abpmisc.c b/sys/arm/nvidia/tegra_abpmisc.c index 7f219b79990efd..0968afa56a2cde 100644 --- a/sys/arm/nvidia/tegra_abpmisc.c +++ b/sys/arm/nvidia/tegra_abpmisc.c @@ -190,7 +190,7 @@ static device_method_t tegra_abpmisc_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(abpmisc, tegra_abpmisc_driver, tegra_abpmisc_methods, +PRIVATE_DEFINE_CLASSN(abpmisc, tegra_abpmisc_driver, tegra_abpmisc_methods, sizeof(struct tegra_abpmisc_softc)); EARLY_DRIVER_MODULE(tegra_abpmisc, simplebus, tegra_abpmisc_driver, NULL, NULL, BUS_PASS_TIMER); diff --git a/sys/arm/nvidia/tegra_ahci.c b/sys/arm/nvidia/tegra_ahci.c index 30e28dd332357c..e6c9031b46f9e1 100644 --- a/sys/arm/nvidia/tegra_ahci.c +++ b/sys/arm/nvidia/tegra_ahci.c @@ -776,6 +776,6 @@ static device_method_t tegra_ahci_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(ahci, tegra_ahci_driver, tegra_ahci_methods, +PRIVATE_DEFINE_CLASSN(ahci, tegra_ahci_driver, tegra_ahci_methods, sizeof(struct tegra_ahci_sc)); DRIVER_MODULE(tegra_ahci, simplebus, tegra_ahci_driver, NULL, NULL); diff --git a/sys/arm/nvidia/tegra_efuse.c b/sys/arm/nvidia/tegra_efuse.c index a756f9681e9270..58c5500efbb006 100644 --- a/sys/arm/nvidia/tegra_efuse.c +++ b/sys/arm/nvidia/tegra_efuse.c @@ -527,7 +527,7 @@ static device_method_t tegra_efuse_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(efuse, tegra_efuse_driver, tegra_efuse_methods, +PRIVATE_DEFINE_CLASSN(efuse, tegra_efuse_driver, tegra_efuse_methods, sizeof(struct tegra_efuse_softc)); EARLY_DRIVER_MODULE(tegra_efuse, simplebus, tegra_efuse_driver, NULL, NULL, BUS_PASS_TIMER); diff --git a/sys/arm/nvidia/tegra_ehci.c b/sys/arm/nvidia/tegra_ehci.c index 59bf8646385a58..845f0bd664ea82 100644 --- a/sys/arm/nvidia/tegra_ehci.c +++ b/sys/arm/nvidia/tegra_ehci.c @@ -309,7 +309,7 @@ static device_method_t ehci_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(ehci, ehci_driver, ehci_methods, +PRIVATE_DEFINE_CLASSN(ehci, ehci_driver, ehci_methods, sizeof(struct tegra_ehci_softc)); DRIVER_MODULE(tegra_ehci, simplebus, ehci_driver, NULL, NULL); MODULE_DEPEND(tegra_ehci, usb, 1, 1, 1); diff --git a/sys/arm/nvidia/tegra_gpio.c b/sys/arm/nvidia/tegra_gpio.c index 16e1ef94d6a961..6bc843b68cf295 100644 --- a/sys/arm/nvidia/tegra_gpio.c +++ b/sys/arm/nvidia/tegra_gpio.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include @@ -853,15 +853,17 @@ static device_method_t tegra_gpio_methods[] = { DEVMETHOD(device_attach, tegra_gpio_attach), DEVMETHOD(device_detach, tegra_gpio_detach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, tegra_gpio_pic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, tegra_gpio_pic_post_ithread), + DEVMETHOD(intr_event_post_filter, tegra_gpio_pic_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_disable_intr, tegra_gpio_pic_disable_intr), DEVMETHOD(pic_enable_intr, tegra_gpio_pic_enable_intr), DEVMETHOD(pic_map_intr, tegra_gpio_pic_map_intr), DEVMETHOD(pic_setup_intr, tegra_gpio_pic_setup_intr), DEVMETHOD(pic_teardown_intr, tegra_gpio_pic_teardown_intr), - DEVMETHOD(pic_post_filter, tegra_gpio_pic_post_filter), - DEVMETHOD(pic_post_ithread, tegra_gpio_pic_post_ithread), - DEVMETHOD(pic_pre_ithread, tegra_gpio_pic_pre_ithread), /* GPIO protocol */ DEVMETHOD(gpio_get_bus, tegra_gpio_get_bus), @@ -881,6 +883,6 @@ static device_method_t tegra_gpio_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(gpio, tegra_gpio_driver, tegra_gpio_methods, - sizeof(struct tegra_gpio_softc)); +PRIVATE_DEFINE_CLASSN(gpio, tegra_gpio_driver, tegra_gpio_methods, + sizeof(struct tegra_gpio_softc), pic_base_class); EARLY_DRIVER_MODULE(tegra_gpio, simplebus, tegra_gpio_driver, NULL, NULL, 70); diff --git a/sys/arm/nvidia/tegra_i2c.c b/sys/arm/nvidia/tegra_i2c.c index 6c4d20cb78ff66..0d9572c463684e 100644 --- a/sys/arm/nvidia/tegra_i2c.c +++ b/sys/arm/nvidia/tegra_i2c.c @@ -796,6 +796,6 @@ static device_method_t tegra_i2c_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(iichb, tegra_i2c_driver, tegra_i2c_methods, +PRIVATE_DEFINE_CLASSN(iichb, tegra_i2c_driver, tegra_i2c_methods, sizeof(struct tegra_i2c_softc)); EARLY_DRIVER_MODULE(tegra_iic, simplebus, tegra_i2c_driver, NULL, NULL, 73); diff --git a/sys/arm/nvidia/tegra_lic.c b/sys/arm/nvidia/tegra_lic.c index e1d64163535162..052006ce857187 100644 --- a/sys/arm/nvidia/tegra_lic.c +++ b/sys/arm/nvidia/tegra_lic.c @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include @@ -152,7 +152,7 @@ tegra_lic_pre_ithread(device_t dev, struct intr_irqsrc *isrc) { struct tegra_lic_sc *sc = device_get_softc(dev); - PIC_PRE_ITHREAD(sc->parent, isrc); + INTR_EVENT_PRE_ITHREAD(sc->parent, isrc); } static void @@ -160,7 +160,7 @@ tegra_lic_post_ithread(device_t dev, struct intr_irqsrc *isrc) { struct tegra_lic_sc *sc = device_get_softc(dev); - PIC_POST_ITHREAD(sc->parent, isrc); + INTR_EVENT_POST_ITHREAD(sc->parent, isrc); } static void @@ -168,7 +168,7 @@ tegra_lic_post_filter(device_t dev, struct intr_irqsrc *isrc) { struct tegra_lic_sc *sc = device_get_softc(dev); - PIC_POST_FILTER(sc->parent, isrc); + INTR_EVENT_POST_FILTER(sc->parent, isrc); } #ifdef SMP @@ -262,6 +262,11 @@ static device_method_t tegra_lic_methods[] = { DEVMETHOD(device_attach, tegra_lic_attach), DEVMETHOD(device_detach, tegra_lic_detach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, tegra_lic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, tegra_lic_post_ithread), + DEVMETHOD(intr_event_post_filter, tegra_lic_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_activate_intr, tegra_lic_activate_intr), DEVMETHOD(pic_disable_intr, tegra_lic_disable_intr), @@ -270,16 +275,14 @@ static device_method_t tegra_lic_methods[] = { DEVMETHOD(pic_deactivate_intr, tegra_lic_deactivate_intr), DEVMETHOD(pic_setup_intr, tegra_lic_setup_intr), DEVMETHOD(pic_teardown_intr, tegra_lic_teardown_intr), - DEVMETHOD(pic_pre_ithread, tegra_lic_pre_ithread), - DEVMETHOD(pic_post_ithread, tegra_lic_post_ithread), - DEVMETHOD(pic_post_filter, tegra_lic_post_filter), #ifdef SMP DEVMETHOD(pic_bind_intr, tegra_lic_bind_intr), #endif + DEVMETHOD_END }; -static DEFINE_CLASS_0(lic, tegra_lic_driver, tegra_lic_methods, - sizeof(struct tegra_lic_sc)); +PRIVATE_DEFINE_CLASSN(lic, tegra_lic_driver, tegra_lic_methods, + sizeof(struct tegra_lic_sc), pic_base_class); EARLY_DRIVER_MODULE(tegra_lic, simplebus, tegra_lic_driver, NULL, NULL, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE + 1); diff --git a/sys/arm/nvidia/tegra_mc.c b/sys/arm/nvidia/tegra_mc.c index 2568ff8324af2b..20714bc8c73e49 100644 --- a/sys/arm/nvidia/tegra_mc.c +++ b/sys/arm/nvidia/tegra_mc.c @@ -308,6 +308,6 @@ static device_method_t tegra_mc_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(mc, tegra_mc_driver, tegra_mc_methods, +PRIVATE_DEFINE_CLASSN(mc, tegra_mc_driver, tegra_mc_methods, sizeof(struct tegra_mc_softc)); DRIVER_MODULE(tegra_mc, simplebus, tegra_mc_driver, NULL, NULL); diff --git a/sys/arm/nvidia/tegra_pcie.c b/sys/arm/nvidia/tegra_pcie.c index b76e74da4f7ddb..a6ff68ce703cf2 100644 --- a/sys/arm/nvidia/tegra_pcie.c +++ b/sys/arm/nvidia/tegra_pcie.c @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include @@ -1595,6 +1595,11 @@ static device_method_t tegra_pcib_methods[] = { DEVMETHOD(pcib_request_feature, pcib_request_feature_allow), #ifdef TEGRA_PCIB_MSI_ENABLE + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, tegra_pcib_msi_pre_ithread), + DEVMETHOD(intr_event_post_ithread, tegra_pcib_msi_post_ithread), + DEVMETHOD(intr_event_post_filter, tegra_pcib_msi_post_filter), + /* MSI/MSI-X */ DEVMETHOD(msi_alloc_msi, tegra_pcib_msi_alloc_msi), DEVMETHOD(msi_release_msi, tegra_pcib_msi_release_msi), @@ -1605,9 +1610,6 @@ static device_method_t tegra_pcib_methods[] = { DEVMETHOD(pic_enable_intr, tegra_pcib_msi_enable_intr), DEVMETHOD(pic_setup_intr, tegra_pcib_msi_setup_intr), DEVMETHOD(pic_teardown_intr, tegra_pcib_msi_teardown_intr), - DEVMETHOD(pic_post_filter, tegra_pcib_msi_post_filter), - DEVMETHOD(pic_post_ithread, tegra_pcib_msi_post_ithread), - DEVMETHOD(pic_pre_ithread, tegra_pcib_msi_pre_ithread), #endif /* OFW bus interface */ @@ -1620,6 +1622,6 @@ static device_method_t tegra_pcib_methods[] = { DEVMETHOD_END }; -DEFINE_CLASS_1(pcib, tegra_pcib_driver, tegra_pcib_methods, - sizeof(struct tegra_pcib_softc), ofw_pcib_driver); +DEFINE_CLASSN(pcib, tegra_pcib_driver, tegra_pcib_methods, + sizeof(struct tegra_pcib_softc), pic_base_class, ofw_pcib_driver); DRIVER_MODULE(tegra_pcib, simplebus, tegra_pcib_driver, NULL, NULL); diff --git a/sys/arm/nvidia/tegra_pinmux.c b/sys/arm/nvidia/tegra_pinmux.c index 4d396d4364b36e..8bb979af814cd5 100644 --- a/sys/arm/nvidia/tegra_pinmux.c +++ b/sys/arm/nvidia/tegra_pinmux.c @@ -786,7 +786,7 @@ static device_method_t tegra_pinmux_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(pinmux, tegra_pinmux_driver, tegra_pinmux_methods, +PRIVATE_DEFINE_CLASSN(pinmux, tegra_pinmux_driver, tegra_pinmux_methods, sizeof(struct pinmux_softc)); EARLY_DRIVER_MODULE(tegra_pinmux, simplebus, tegra_pinmux_driver, NULL, NULL, 71); diff --git a/sys/arm/nvidia/tegra_rtc.c b/sys/arm/nvidia/tegra_rtc.c index b94ee24e81a5b1..f64f17d46c89cb 100644 --- a/sys/arm/nvidia/tegra_rtc.c +++ b/sys/arm/nvidia/tegra_rtc.c @@ -298,6 +298,6 @@ static device_method_t tegra_rtc_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(rtc, tegra_rtc_driver, tegra_rtc_methods, +PRIVATE_DEFINE_CLASSN(rtc, tegra_rtc_driver, tegra_rtc_methods, sizeof(struct tegra_rtc_softc)); DRIVER_MODULE(tegra_rtc, simplebus, tegra_rtc_driver, NULL, NULL); diff --git a/sys/arm/nvidia/tegra_sdhci.c b/sys/arm/nvidia/tegra_sdhci.c index fa6810b655c624..8484ce8ae6fe9a 100644 --- a/sys/arm/nvidia/tegra_sdhci.c +++ b/sys/arm/nvidia/tegra_sdhci.c @@ -45,8 +45,8 @@ #include #include +#include #include -#include #include #include @@ -467,7 +467,7 @@ static device_method_t tegra_sdhci_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(sdhci, tegra_sdhci_driver, tegra_sdhci_methods, +PRIVATE_DEFINE_CLASSN(sdhci, tegra_sdhci_driver, tegra_sdhci_methods, sizeof(struct tegra_sdhci_softc)); DRIVER_MODULE(sdhci_tegra, simplebus, tegra_sdhci_driver, NULL, NULL); SDHCI_DEPEND(sdhci_tegra); diff --git a/sys/arm/nvidia/tegra_soctherm.c b/sys/arm/nvidia/tegra_soctherm.c index 630287adb13777..c0496ca7be1ddd 100644 --- a/sys/arm/nvidia/tegra_soctherm.c +++ b/sys/arm/nvidia/tegra_soctherm.c @@ -836,7 +836,7 @@ static device_method_t tegra_soctherm_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(soctherm, tegra_soctherm_driver, tegra_soctherm_methods, +PRIVATE_DEFINE_CLASSN(soctherm, tegra_soctherm_driver, tegra_soctherm_methods, sizeof(struct soctherm_softc)); EARLY_DRIVER_MODULE(tegra_soctherm, simplebus, tegra_soctherm_driver, NULL, NULL, 79); diff --git a/sys/arm/nvidia/tegra_uart.c b/sys/arm/nvidia/tegra_uart.c index 9c518997e85cdf..bf2c000ed775e1 100644 --- a/sys/arm/nvidia/tegra_uart.c +++ b/sys/arm/nvidia/tegra_uart.c @@ -238,6 +238,7 @@ static device_method_t tegra_uart_bus_methods[] = { DEVMETHOD(device_probe, tegra_uart_probe), DEVMETHOD(device_attach, uart_bus_attach), DEVMETHOD(device_detach, tegra_uart_detach), + DEVMETHOD_END }; diff --git a/sys/arm/nvidia/tegra_usbphy.c b/sys/arm/nvidia/tegra_usbphy.c index cdf6f7f5833fb3..8231af95a3d25c 100644 --- a/sys/arm/nvidia/tegra_usbphy.c +++ b/sys/arm/nvidia/tegra_usbphy.c @@ -842,7 +842,7 @@ static device_method_t tegra_usbphy_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(usbphy, tegra_usbphy_driver, tegra_usbphy_methods, +PRIVATE_DEFINE_CLASSN(usbphy, tegra_usbphy_driver, tegra_usbphy_methods, sizeof(struct usbphy_softc)); EARLY_DRIVER_MODULE(tegra_usbphy, simplebus, tegra_usbphy_driver, NULL, NULL, 79); diff --git a/sys/arm/nvidia/tegra_xhci.c b/sys/arm/nvidia/tegra_xhci.c index 474e31981770dc..9e6ab225f73f53 100644 --- a/sys/arm/nvidia/tegra_xhci.c +++ b/sys/arm/nvidia/tegra_xhci.c @@ -1120,7 +1120,7 @@ static device_method_t xhci_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(xhci, xhci_driver, xhci_methods, +PRIVATE_DEFINE_CLASSN(xhci, xhci_driver, xhci_methods, sizeof(struct tegra_xhci_softc)); DRIVER_MODULE(tegra_xhci, simplebus, xhci_driver, NULL, NULL); MODULE_DEPEND(tegra_xhci, usb, 1, 1, 1); diff --git a/sys/arm/qemu/virt_machdep.c b/sys/arm/qemu/virt_machdep.c index 72f426084e1770..8e32b49a491ca0 100644 --- a/sys/arm/qemu/virt_machdep.c +++ b/sys/arm/qemu/virt_machdep.c @@ -59,7 +59,7 @@ static platform_method_t virt_methods[] = { PLATFORMMETHOD(platform_mp_start_ap, virt_mp_start_ap), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(virt, "virt", 0, "linux,dummy-virt", 1); @@ -75,7 +75,7 @@ gem5_devmap_init(platform_t plat) static platform_method_t gem5_methods[] = { PLATFORMMETHOD(platform_devmap_init, gem5_devmap_init), - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(gem5, "gem5", 0, "arm,vexpress", 1); diff --git a/sys/arm/qemu/virt_mp.c b/sys/arm/qemu/virt_mp.c index a3471b1eb76468..0aa7f1f8c3cf6c 100644 --- a/sys/arm/qemu/virt_mp.c +++ b/sys/arm/qemu/virt_mp.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include diff --git a/sys/arm/qualcomm/ipq4018_machdep.c b/sys/arm/qualcomm/ipq4018_machdep.c index 49dd2ff0193adf..c3b562a031402b 100644 --- a/sys/arm/qualcomm/ipq4018_machdep.c +++ b/sys/arm/qualcomm/ipq4018_machdep.c @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include @@ -226,7 +226,7 @@ static platform_method_t ipq4018_methods[] = { PLATFORMMETHOD(platform_mp_setmaxid, ipq4018_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF2(ipq4018, ipq4018_ac58u, "ASUS RT-AC58U", 0, diff --git a/sys/arm/qualcomm/ipq4018_mp.c b/sys/arm/qualcomm/ipq4018_mp.c index cdcc0dfb95502f..12a2217ebc73f3 100644 --- a/sys/arm/qualcomm/ipq4018_mp.c +++ b/sys/arm/qualcomm/ipq4018_mp.c @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/arm/qualcomm/ipq4018_usb_hs_phy.c b/sys/arm/qualcomm/ipq4018_usb_hs_phy.c index 5ed964abf0ecad..f51691f31ef3eb 100644 --- a/sys/arm/qualcomm/ipq4018_usb_hs_phy.c +++ b/sys/arm/qualcomm/ipq4018_usb_hs_phy.c @@ -219,10 +219,11 @@ static device_method_t ipq4018_usb_hs_usbphy_methods[] = { DEVMETHOD(device_probe, ipq4018_usb_hs_usbphy_probe), DEVMETHOD(device_attach, ipq4018_usb_hs_usbphy_attach), DEVMETHOD(device_detach, ipq4018_usb_hs_usbphy_detach), + DEVMETHOD_END }; -static DEFINE_CLASS_0(ipq4018_usb_hs_usbphy, ipq4018_usb_hs_usbphy_driver, +PRIVATE_DEFINE_CLASSN(ipq4018_usb_hs_usbphy, ipq4018_usb_hs_usbphy_driver, ipq4018_usb_hs_usbphy_methods, sizeof(struct ipq4018_usb_hs_phy_softc)); EARLY_DRIVER_MODULE(ipq4018_usb_hs_usbphy, simplebus, diff --git a/sys/arm/qualcomm/ipq4018_usb_ss_phy.c b/sys/arm/qualcomm/ipq4018_usb_ss_phy.c index ef8a315e390655..daba3c2d86b3ec 100644 --- a/sys/arm/qualcomm/ipq4018_usb_ss_phy.c +++ b/sys/arm/qualcomm/ipq4018_usb_ss_phy.c @@ -199,10 +199,11 @@ static device_method_t ipq4018_usb_ss_usbphy_methods[] = { DEVMETHOD(device_probe, ipq4018_usb_ss_usbphy_probe), DEVMETHOD(device_attach, ipq4018_usb_ss_usbphy_attach), DEVMETHOD(device_detach, ipq4018_usb_ss_usbphy_detach), + DEVMETHOD_END }; -static DEFINE_CLASS_0(ipq4018_usb_ss_usbphy, ipq4018_usb_ss_usbphy_driver, +PRIVATE_DEFINE_CLASSN(ipq4018_usb_ss_usbphy, ipq4018_usb_ss_usbphy_driver, ipq4018_usb_ss_usbphy_methods, sizeof(struct ipq4018_usb_ss_phy_softc)); EARLY_DRIVER_MODULE(ipq4018_usb_ss_usbphy, simplebus, diff --git a/sys/arm/qualcomm/qcom_cpu_kpssv2.c b/sys/arm/qualcomm/qcom_cpu_kpssv2.c index c265f0f897e2ad..2e03939d7e085b 100644 --- a/sys/arm/qualcomm/qcom_cpu_kpssv2.c +++ b/sys/arm/qualcomm/qcom_cpu_kpssv2.c @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/arm/qualcomm/qcom_scm_legacy.c b/sys/arm/qualcomm/qcom_scm_legacy.c index b614843b1ce87d..f5e55b4c37928e 100644 --- a/sys/arm/qualcomm/qcom_scm_legacy.c +++ b/sys/arm/qualcomm/qcom_scm_legacy.c @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include diff --git a/sys/arm/rockchip/rk32xx_machdep.c b/sys/arm/rockchip/rk32xx_machdep.c index 56410a0f47248e..d04121b0d821d1 100644 --- a/sys/arm/rockchip/rk32xx_machdep.c +++ b/sys/arm/rockchip/rk32xx_machdep.c @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include @@ -117,7 +117,7 @@ static platform_method_t rk32xx_methods[] = { PLATFORMMETHOD(platform_mp_start_ap, rk32xx_mp_start_ap), PLATFORMMETHOD(platform_mp_setmaxid, rk32xx_mp_setmaxid), #endif - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF2(rk32xx, rk3288, "RK3288", 0, "rockchip,rk3288", 200); FDT_PLATFORM_DEF2(rk32xx, rk3288w, "RK3288W", 0, "rockchip,rk3288w", 200); diff --git a/sys/arm/ti/aintc.c b/sys/arm/ti/aintc.c index b822a2038211b2..79c6eb0b19c6ba 100644 --- a/sys/arm/ti/aintc.c +++ b/sys/arm/ti/aintc.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include @@ -286,21 +286,21 @@ static device_method_t ti_aintc_methods[] = { DEVMETHOD(device_probe, ti_aintc_probe), DEVMETHOD(device_attach, ti_aintc_attach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, ti_aintc_pre_ithread), + DEVMETHOD(intr_event_post_ithread, ti_aintc_post_ithread), + DEVMETHOD(intr_event_post_filter, ti_aintc_post_filter), + DEVMETHOD(pic_disable_intr, ti_aintc_disable_intr), DEVMETHOD(pic_enable_intr, ti_aintc_enable_intr), DEVMETHOD(pic_map_intr, ti_aintc_map_intr), - DEVMETHOD(pic_post_filter, ti_aintc_post_filter), - DEVMETHOD(pic_post_ithread, ti_aintc_post_ithread), - DEVMETHOD(pic_pre_ithread, ti_aintc_pre_ithread), - { 0, 0 } -}; -static driver_t ti_aintc_driver = { - "ti_aintc", - ti_aintc_methods, - sizeof(struct ti_aintc_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(ti_aintc, ti_aintc_driver, ti_aintc_methods, + sizeof(struct ti_aintc_softc), pic_base_class); + EARLY_DRIVER_MODULE(ti_aintc, simplebus, ti_aintc_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); SIMPLEBUS_PNP_INFO(compat_data); diff --git a/sys/arm/ti/am335x/am335x_dmtimer.c b/sys/arm/ti/am335x/am335x_dmtimer.c index 7b97e0f611f9bf..dd7414c37314d1 100644 --- a/sys/arm/ti/am335x/am335x_dmtimer.c +++ b/sys/arm/ti/am335x/am335x_dmtimer.c @@ -365,15 +365,13 @@ am335x_dmtimer_attach(device_t dev) static device_method_t am335x_dmtimer_methods[] = { DEVMETHOD(device_probe, am335x_dmtimer_probe), DEVMETHOD(device_attach, am335x_dmtimer_attach), - { 0, 0 } -}; -static driver_t am335x_dmtimer_driver = { - "am335x_dmtimer", - am335x_dmtimer_methods, - sizeof(struct am335x_dmtimer_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(am335x_dmtimer, am335x_dmtimer_driver, + am335x_dmtimer_methods, sizeof(struct am335x_dmtimer_softc)); + DRIVER_MODULE(am335x_dmtimer, simplebus, am335x_dmtimer_driver, 0, 0); MODULE_DEPEND(am335x_dmtimer, ti_sysc, 1, 1, 1); diff --git a/sys/arm/ti/am335x/am335x_dmtpps.c b/sys/arm/ti/am335x/am335x_dmtpps.c index 32f975a310dec5..4d82f7977fee4e 100644 --- a/sys/arm/ti/am335x/am335x_dmtpps.c +++ b/sys/arm/ti/am335x/am335x_dmtpps.c @@ -601,14 +601,12 @@ static device_method_t dmtpps_methods[] = { DEVMETHOD(device_probe, dmtpps_probe), DEVMETHOD(device_attach, dmtpps_attach), DEVMETHOD(device_detach, dmtpps_detach), - { 0, 0 } -}; -static driver_t dmtpps_driver = { - "am335x_dmtpps", - dmtpps_methods, - sizeof(struct dmtpps_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(am335x_dmtpps, dmtpps_driver, dmtpps_methods, + sizeof(struct dmtpps_softc)); + DRIVER_MODULE(am335x_dmtpps, simplebus, dmtpps_driver, 0, 0); MODULE_DEPEND(am335x_dmtpps, ti_sysc, 1, 1, 1); diff --git a/sys/arm/ti/am335x/am335x_ecap.c b/sys/arm/ti/am335x/am335x_ecap.c index f1df54af6e18ad..d590aacf6ac93a 100644 --- a/sys/arm/ti/am335x/am335x_ecap.c +++ b/sys/arm/ti/am335x/am335x_ecap.c @@ -93,11 +93,8 @@ static device_method_t am335x_ecap_methods[] = { DEVMETHOD_END }; -static driver_t am335x_ecap_driver = { - "am335x_ecap", - am335x_ecap_methods, - sizeof(struct am335x_ecap_softc), -}; +PRIVATE_DEFINE_CLASSN(am335x_ecap, am335x_ecap_driver, am335x_ecap_methods, + sizeof(struct am335x_ecap_softc)); /* * API function to set period/duty cycles for ECAPx diff --git a/sys/arm/ti/am335x/am335x_ehrpwm.c b/sys/arm/ti/am335x/am335x_ehrpwm.c index 59ef0931439dde..065b3c703fd5dc 100644 --- a/sys/arm/ti/am335x/am335x_ehrpwm.c +++ b/sys/arm/ti/am335x/am335x_ehrpwm.c @@ -584,11 +584,8 @@ static device_method_t am335x_ehrpwm_methods[] = { DEVMETHOD_END }; -static driver_t am335x_ehrpwm_driver = { - "pwm", - am335x_ehrpwm_methods, - sizeof(struct am335x_ehrpwm_softc), -}; +PRIVATE_DEFINE_CLASSN(pwm, am335x_ehrpwm_driver, am335x_ehrpwm_methods, + sizeof(struct am335x_ehrpwm_softc)); DRIVER_MODULE(am335x_ehrpwm, am335x_pwmss, am335x_ehrpwm_driver, 0, 0); MODULE_VERSION(am335x_ehrpwm, 1); diff --git a/sys/arm/ti/am335x/am335x_gpio.c b/sys/arm/ti/am335x/am335x_gpio.c index 78665b19857ab8..f71c3a426ed5ab 100644 --- a/sys/arm/ti/am335x/am335x_gpio.c +++ b/sys/arm/ti/am335x/am335x_gpio.c @@ -36,8 +36,8 @@ #include #include +#include #include -#include #include #include diff --git a/sys/arm/ti/am335x/am335x_lcd.c b/sys/arm/ti/am335x/am335x_lcd.c index 9bef1df0c64c70..9bc4762e0deedb 100644 --- a/sys/arm/ti/am335x/am335x_lcd.c +++ b/sys/arm/ti/am335x/am335x_lcd.c @@ -1088,11 +1088,8 @@ static device_method_t am335x_lcd_methods[] = { DEVMETHOD_END }; -static driver_t am335x_lcd_driver = { - "fb", - am335x_lcd_methods, - sizeof(struct am335x_lcd_softc), -}; +PRIVATE_DEFINE_CLASSN(fb, am335x_lcd_driver, am335x_lcd_methods, + sizeof(struct am335x_lcd_softc)); DRIVER_MODULE(am335x_lcd, simplebus, am335x_lcd_driver, 0, 0); MODULE_VERSION(am335x_lcd, 1); diff --git a/sys/arm/ti/am335x/am335x_lcd_syscons.c b/sys/arm/ti/am335x/am335x_lcd_syscons.c index 09505adac8f39d..77ea40ad700dd7 100644 --- a/sys/arm/ti/am335x/am335x_lcd_syscons.c +++ b/sys/arm/ti/am335x/am335x_lcd_syscons.c @@ -44,8 +44,8 @@ #include #include +#include #include -#include #include #include diff --git a/sys/arm/ti/am335x/am335x_musb.c b/sys/arm/ti/am335x/am335x_musb.c index 24a204e42c9cb4..ecd299064c1d1b 100644 --- a/sys/arm/ti/am335x/am335x_musb.c +++ b/sys/arm/ti/am335x/am335x_musb.c @@ -448,11 +448,8 @@ static device_method_t musbotg_methods[] = { DEVMETHOD_END }; -static driver_t musbotg_driver = { - .name = "musbotg", - .methods = musbotg_methods, - .size = sizeof(struct musbotg_super_softc), -}; +PRIVATE_DEFINE_CLASSN(musbotg, musbotg_driver, musbotg_methods, + sizeof(struct musbotg_super_softc)); DRIVER_MODULE(musbotg, ti_sysc, musbotg_driver, 0, 0); MODULE_DEPEND(musbotg, ti_sysc, 1, 1, 1); diff --git a/sys/arm/ti/am335x/am335x_pmic.c b/sys/arm/ti/am335x/am335x_pmic.c index 5d569ae9c5ad91..fff76a89464e8b 100644 --- a/sys/arm/ti/am335x/am335x_pmic.c +++ b/sys/arm/ti/am335x/am335x_pmic.c @@ -311,15 +311,13 @@ am335x_pmic_shutdown(void *xdev, int howto) static device_method_t am335x_pmic_methods[] = { DEVMETHOD(device_probe, am335x_pmic_probe), DEVMETHOD(device_attach, am335x_pmic_attach), - {0, 0}, -}; -static driver_t am335x_pmic_driver = { - "am335x_pmic", - am335x_pmic_methods, - sizeof(struct am335x_pmic_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(am335x_pmic, am335x_pmic_driver, am335x_pmic_methods, + sizeof(struct am335x_pmic_softc)); + DRIVER_MODULE(am335x_pmic, iicbus, am335x_pmic_driver, 0, 0); MODULE_VERSION(am335x_pmic, 1); MODULE_DEPEND(am335x_pmic, iicbus, 1, 1, 1); diff --git a/sys/arm/ti/am335x/am335x_rtc.c b/sys/arm/ti/am335x/am335x_rtc.c index 7ac8ce06179622..158ae872d32fe2 100644 --- a/sys/arm/ti/am335x/am335x_rtc.c +++ b/sys/arm/ti/am335x/am335x_rtc.c @@ -196,11 +196,8 @@ static device_method_t am335x_rtc_methods[] = { DEVMETHOD_END }; -static driver_t am335x_rtc_driver = { - "am335x_rtc", - am335x_rtc_methods, - sizeof(struct am335x_rtc_softc), -}; +PRIVATE_DEFINE_CLASSN(am335x_rtc, am335x_rtc_driver, am335x_rtc_methods, + sizeof(struct am335x_rtc_softc)); DRIVER_MODULE(am335x_rtc, simplebus, am335x_rtc_driver, 0, 0); MODULE_VERSION(am335x_rtc, 1); diff --git a/sys/arm/ti/am335x/am335x_scm.c b/sys/arm/ti/am335x/am335x_scm.c index 8245f35617ad64..f54941a52f1b1d 100644 --- a/sys/arm/ti/am335x/am335x_scm.c +++ b/sys/arm/ti/am335x/am335x_scm.c @@ -182,11 +182,8 @@ static device_method_t am335x_scm_methods[] = { DEVMETHOD_END }; -static driver_t am335x_scm_driver = { - "am335x_scm", - am335x_scm_methods, - sizeof(struct am335x_scm_softc), -}; +PRIVATE_DEFINE_CLASSN(am335x_scm, am335x_scm_driver, am335x_scm_methods, + sizeof(struct am335x_scm_softc)); DRIVER_MODULE(am335x_scm, ti_scm, am335x_scm_driver, 0, 0); MODULE_VERSION(am335x_scm, 1); diff --git a/sys/arm/ti/am335x/am335x_scm_padconf.c b/sys/arm/ti/am335x/am335x_scm_padconf.c index 1d28a8003d551e..e0dfe29d4411ae 100644 --- a/sys/arm/ti/am335x/am335x_scm_padconf.c +++ b/sys/arm/ti/am335x/am335x_scm_padconf.c @@ -37,8 +37,8 @@ #include #include +#include #include -#include #include #include diff --git a/sys/arm/ti/am335x/tda19988.c b/sys/arm/ti/am335x/tda19988.c index 9d5bf9a40087b6..e74ca39d4998c8 100644 --- a/sys/arm/ti/am335x/tda19988.c +++ b/sys/arm/ti/am335x/tda19988.c @@ -784,15 +784,13 @@ static device_method_t tda_methods[] = { /* CRTC methods */ DEVMETHOD(crtc_get_edid, tda19988_get_edid), DEVMETHOD(crtc_set_videomode, tda19988_set_videomode), - {0, 0}, -}; -static driver_t tda_driver = { - "tda", - tda_methods, - sizeof(struct tda19988_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(tda, tda_driver, tda_methods, + sizeof(struct tda19988_softc)); + DRIVER_MODULE(tda, iicbus, tda_driver, 0, 0); MODULE_VERSION(tda, 1); MODULE_DEPEND(tda, iicbus, 1, 1, 1); diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c index ea8f9c18490e0a..ac29ed4a5f438d 100644 --- a/sys/arm/ti/cpsw/if_cpsw.c +++ b/sys/arm/ti/cpsw/if_cpsw.c @@ -181,10 +181,13 @@ static device_method_t cpsw_methods[] = { DEVMETHOD(device_shutdown, cpsw_shutdown), DEVMETHOD(device_suspend, cpsw_suspend), DEVMETHOD(device_resume, cpsw_resume), + /* Bus interface */ DEVMETHOD(bus_add_child, device_add_child_ordered), + /* OFW methods */ DEVMETHOD(ofw_bus_get_node, cpsw_get_node), + #ifdef CPSW_ETHERSWITCH /* etherswitch interface */ DEVMETHOD(etherswitch_getinfo, cpsw_getinfo), @@ -198,14 +201,12 @@ static device_method_t cpsw_methods[] = { DEVMETHOD(etherswitch_setvgroup, cpsw_setvgroup), DEVMETHOD(etherswitch_getconf, cpsw_getconf), #endif + DEVMETHOD_END }; -static driver_t cpsw_driver = { - "cpswss", - cpsw_methods, - sizeof(struct cpsw_softc), -}; +PRIVATE_DEFINE_CLASSN(cpswss, cpsw_driver, cpsw_methods, + sizeof(struct cpsw_softc)); DRIVER_MODULE(cpswss, simplebus, cpsw_driver, 0, 0); @@ -215,18 +216,17 @@ static device_method_t cpswp_methods[] = { DEVMETHOD(device_probe, cpswp_probe), DEVMETHOD(device_attach, cpswp_attach), DEVMETHOD(device_detach, cpswp_detach), + /* MII interface */ DEVMETHOD(miibus_readreg, cpswp_miibus_readreg), DEVMETHOD(miibus_writereg, cpswp_miibus_writereg), DEVMETHOD(miibus_statchg, cpswp_miibus_statchg), + DEVMETHOD_END }; -static driver_t cpswp_driver = { - "cpsw", - cpswp_methods, - sizeof(struct cpswp_softc), -}; +PRIVATE_DEFINE_CLASSN(cpsw, cpswp_driver, cpswp_methods, + sizeof(struct cpswp_softc)); #ifdef CPSW_ETHERSWITCH DRIVER_MODULE(etherswitch, cpswss, etherswitch_driver, 0, 0); diff --git a/sys/arm/ti/omap4/omap4_gpio.c b/sys/arm/ti/omap4/omap4_gpio.c index 08c878107b486f..a6277bcfb43afc 100644 --- a/sys/arm/ti/omap4/omap4_gpio.c +++ b/sys/arm/ti/omap4/omap4_gpio.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include diff --git a/sys/arm/ti/omap4/omap4_mp.c b/sys/arm/ti/omap4/omap4_mp.c index 1affd08583dbd1..c9c7030845e393 100644 --- a/sys/arm/ti/omap4/omap4_mp.c +++ b/sys/arm/ti/omap4/omap4_mp.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/arm/ti/omap4/omap4_prcm_clks.c b/sys/arm/ti/omap4/omap4_prcm_clks.c index 63c679f178bc08..7a121dc2631b1f 100644 --- a/sys/arm/ti/omap4/omap4_prcm_clks.c +++ b/sys/arm/ti/omap4/omap4_prcm_clks.c @@ -40,8 +40,8 @@ #include #include +#include #include -#include #include #include @@ -1485,14 +1485,11 @@ static device_method_t omap4_prcm_methods[] = { /* Bus interface */ DEVMETHOD(bus_new_pass, omap4_prcm_new_pass), - {0, 0}, + DEVMETHOD_END }; -static driver_t omap4_prcm_driver = { - "omap4_prcm", - omap4_prcm_methods, - sizeof(struct omap4_prcm_softc), -}; +PRIVATE_DEFINE_CLASSN(omap4_prcm, omap4_prcm_driver, omap4_prcm_methods, + sizeof(struct omap4_prcm_softc)); EARLY_DRIVER_MODULE(omap4_prcm, simplebus, omap4_prcm_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm/ti/omap4/omap4_wugen.c b/sys/arm/ti/omap4/omap4_wugen.c index d9264e60efc977..a188ed83fd0f5a 100644 --- a/sys/arm/ti/omap4/omap4_wugen.c +++ b/sys/arm/ti/omap4/omap4_wugen.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include @@ -222,6 +222,11 @@ static device_method_t omap4_wugen_methods[] = { DEVMETHOD(device_attach, omap4_wugen_attach), DEVMETHOD(device_detach, omap4_wugen_detach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, omap4_wugen_pre_ithread), + DEVMETHOD(intr_event_post_ithread, omap4_wugen_post_ithread), + DEVMETHOD(intr_event_post_filter, omap4_wugen_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_activate_intr, omap4_wugen_activate_intr), DEVMETHOD(pic_disable_intr, omap4_wugen_disable_intr), @@ -230,16 +235,14 @@ static device_method_t omap4_wugen_methods[] = { DEVMETHOD(pic_deactivate_intr, omap4_wugen_deactivate_intr), DEVMETHOD(pic_setup_intr, omap4_wugen_setup_intr), DEVMETHOD(pic_teardown_intr, omap4_wugen_teardown_intr), - DEVMETHOD(pic_pre_ithread, omap4_wugen_pre_ithread), - DEVMETHOD(pic_post_ithread, omap4_wugen_post_ithread), - DEVMETHOD(pic_post_filter, omap4_wugen_post_filter), #ifdef SMP DEVMETHOD(pic_bind_intr, omap4_wugen_bind_intr), #endif + DEVMETHOD_END }; -DEFINE_CLASS_0(omap4_wugen, omap4_wugen_driver, omap4_wugen_methods, - sizeof(struct omap4_wugen_sc)); +DEFINE_CLASSN(omap4_wugen, omap4_wugen_driver, omap4_wugen_methods, + sizeof(struct omap4_wugen_sc), pic_base_class); EARLY_DRIVER_MODULE(omap4_wugen, simplebus, omap4_wugen_driver, NULL, NULL, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE + 1); diff --git a/sys/arm/ti/ti_adc.c b/sys/arm/ti/ti_adc.c index d13dd87001de9c..0579de20b71e4e 100644 --- a/sys/arm/ti/ti_adc.c +++ b/sys/arm/ti/ti_adc.c @@ -954,11 +954,8 @@ static device_method_t ti_adc_methods[] = { DEVMETHOD_END }; -static driver_t ti_adc_driver = { - "ti_adc", - ti_adc_methods, - sizeof(struct ti_adc_softc), -}; +PRIVATE_DEFINE_CLASSN(ti_adc, ti_adc_driver, ti_adc_methods, + sizeof(struct ti_adc_softc)); DRIVER_MODULE(ti_adc, simplebus, ti_adc_driver, 0, 0); MODULE_VERSION(ti_adc, 1); diff --git a/sys/arm/ti/ti_cpuid.c b/sys/arm/ti/ti_cpuid.c index b2e7e61c287b81..c688c4565c5e77 100644 --- a/sys/arm/ti/ti_cpuid.c +++ b/sys/arm/ti/ti_cpuid.c @@ -40,8 +40,8 @@ #include #include #include +#include #include -#include #include #include diff --git a/sys/arm/ti/ti_edma3.c b/sys/arm/ti/ti_edma3.c index 3e4b17c847fb09..737b245aafe098 100644 --- a/sys/arm/ti/ti_edma3.c +++ b/sys/arm/ti/ti_edma3.c @@ -205,15 +205,13 @@ ti_edma3_attach(device_t dev) static device_method_t ti_edma3_methods[] = { DEVMETHOD(device_probe, ti_edma3_probe), DEVMETHOD(device_attach, ti_edma3_attach), - {0, 0}, -}; -static driver_t ti_edma3_driver = { - "ti_edma3", - ti_edma3_methods, - sizeof(struct ti_edma3_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(ti_edma3, ti_edma3_driver, ti_edma3_methods, + sizeof(struct ti_edma3_softc)); + DRIVER_MODULE(ti_edma3, simplebus, ti_edma3_driver, 0, 0); MODULE_DEPEND(ti_edma3, ti_sysc, 1, 1, 1); diff --git a/sys/arm/ti/ti_gpio.c b/sys/arm/ti/ti_gpio.c index 68561b96bad217..2d54032b0cadd0 100644 --- a/sys/arm/ti/ti_gpio.c +++ b/sys/arm/ti/ti_gpio.c @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include @@ -1089,6 +1089,11 @@ static device_method_t ti_gpio_methods[] = { DEVMETHOD(device_attach, ti_gpio_attach), DEVMETHOD(device_detach, ti_gpio_detach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, ti_gpio_pic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, ti_gpio_pic_post_ithread), + DEVMETHOD(intr_event_post_filter, ti_gpio_pic_post_filter), + /* GPIO protocol */ DEVMETHOD(gpio_get_bus, ti_gpio_get_bus), DEVMETHOD(gpio_pin_max, ti_gpio_pin_max), @@ -1106,18 +1111,12 @@ static device_method_t ti_gpio_methods[] = { DEVMETHOD(pic_map_intr, ti_gpio_pic_map_intr), DEVMETHOD(pic_setup_intr, ti_gpio_pic_setup_intr), DEVMETHOD(pic_teardown_intr, ti_gpio_pic_teardown_intr), - DEVMETHOD(pic_post_filter, ti_gpio_pic_post_filter), - DEVMETHOD(pic_post_ithread, ti_gpio_pic_post_ithread), - DEVMETHOD(pic_pre_ithread, ti_gpio_pic_pre_ithread), /* ofw_bus interface */ DEVMETHOD(ofw_bus_get_node, ti_gpio_get_node), - {0, 0}, + DEVMETHOD_END }; -driver_t ti_gpio_driver = { - "gpio", - ti_gpio_methods, - sizeof(struct ti_gpio_softc), -}; +PRIVATE_DEFINE_CLASSN(gpio, ti_gpio_driver, ti_gpio_methods, + sizeof(struct ti_gpio_softc), pic_base_class); diff --git a/sys/arm/ti/ti_i2c.c b/sys/arm/ti/ti_i2c.c index e2f1145050154b..efaedc07709f0d 100644 --- a/sys/arm/ti/ti_i2c.c +++ b/sys/arm/ti/ti_i2c.c @@ -955,11 +955,8 @@ static device_method_t ti_i2c_methods[] = { DEVMETHOD_END }; -static driver_t ti_i2c_driver = { - "iichb", - ti_i2c_methods, - sizeof(struct ti_i2c_softc), -}; +PRIVATE_DEFINE_CLASSN(iichb, ti_i2c_driver, ti_i2c_methods, + sizeof(struct ti_i2c_softc)); DRIVER_MODULE(ti_iic, simplebus, ti_i2c_driver, 0, 0); DRIVER_MODULE(iicbus, ti_iic, iicbus_driver, 0, 0); diff --git a/sys/arm/ti/ti_machdep.c b/sys/arm/ti/ti_machdep.c index c4547609b3bbf6..03f268772d7045 100644 --- a/sys/arm/ti/ti_machdep.c +++ b/sys/arm/ti/ti_machdep.c @@ -145,7 +145,7 @@ static platform_method_t omap4_methods[] = { PLATFORMMETHOD(platform_pl310_write_ctrl, omap4_pl310_write_ctrl), PLATFORMMETHOD(platform_pl310_write_debug, omap4_pl310_write_debug), - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(omap4, "omap4", 0, "ti,omap4430", 200); #endif @@ -156,7 +156,7 @@ static platform_method_t am335x_methods[] = { PLATFORMMETHOD(platform_devmap_init, ti_am335x_devmap_init), PLATFORMMETHOD(platform_cpu_reset, ti_plat_cpu_reset), - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(am335x, "am335x", 0, "ti,am33xx", 200); diff --git a/sys/arm/ti/ti_mbox.c b/sys/arm/ti/ti_mbox.c index d844d3b86dec1e..f9b4e47c2d8348 100644 --- a/sys/arm/ti/ti_mbox.c +++ b/sys/arm/ti/ti_mbox.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include @@ -91,11 +91,8 @@ static device_method_t ti_mbox_methods[] = { DEVMETHOD_END }; -static driver_t ti_mbox_driver = { - "ti_mbox", - ti_mbox_methods, - sizeof(struct ti_mbox_softc) -}; +PRIVATE_DEFINE_CLASSN(ti_mbox, ti_mbox_driver, ti_mbox_methods, + sizeof(struct ti_mbox_softc)); DRIVER_MODULE(ti_mbox, simplebus, ti_mbox_driver, 0, 0); MODULE_DEPEND(ti_mbox, ti_sysc, 1, 1, 1); diff --git a/sys/arm/ti/ti_pinmux.c b/sys/arm/ti/ti_pinmux.c index 7f6b5a1889bc70..cd98b73dc848f4 100644 --- a/sys/arm/ti/ti_pinmux.c +++ b/sys/arm/ti/ti_pinmux.c @@ -442,15 +442,13 @@ static device_method_t ti_pinmux_methods[] = { /* fdt_pinctrl interface */ DEVMETHOD(fdt_pinctrl_configure, ti_pinmux_configure_pins), - { 0, 0 } -}; -static driver_t ti_pinmux_driver = { - "ti_pinmux", - ti_pinmux_methods, - sizeof(struct ti_pinmux_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(ti_pinmux, ti_pinmux_driver, ti_pinmux_methods, + sizeof(struct ti_pinmux_softc)); + DRIVER_MODULE(ti_pinmux, simplebus, ti_pinmux_driver, 0, 0); MODULE_VERSION(ti_pinmux, 1); MODULE_DEPEND(ti_pinmux, ti_scm, 1, 1, 1); diff --git a/sys/arm/ti/ti_prcm.c b/sys/arm/ti/ti_prcm.c index 3fc1fef1fdfb09..003d93cb0fe4bd 100644 --- a/sys/arm/ti/ti_prcm.c +++ b/sys/arm/ti/ti_prcm.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/arm/ti/ti_pruss.c b/sys/arm/ti/ti_pruss.c index 4e9f2022240ccb..9dcf0820e111e5 100644 --- a/sys/arm/ti/ti_pruss.c +++ b/sys/arm/ti/ti_pruss.c @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include @@ -153,11 +153,8 @@ static device_method_t ti_pruss_methods[] = { DEVMETHOD_END }; -static driver_t ti_pruss_driver = { - "ti_pruss", - ti_pruss_methods, - sizeof(struct ti_pruss_softc) -}; +PRIVATE_DEFINE_CLASSN(ti_pruss, ti_pruss_driver, ti_pruss_methods, + sizeof(struct ti_pruss_softc)); DRIVER_MODULE(ti_pruss, simplebus, ti_pruss_driver, 0, 0); MODULE_DEPEND(ti_pruss, ti_sysc, 1, 1, 1); diff --git a/sys/arm/ti/ti_sdhci.c b/sys/arm/ti/ti_sdhci.c index e6d4ef542a4d62..f41caf174adc31 100644 --- a/sys/arm/ti/ti_sdhci.c +++ b/sys/arm/ti/ti_sdhci.c @@ -59,8 +59,8 @@ #include "sdhci_if.h" #include +#include #include -#include #include "opt_mmccam.h" @@ -750,11 +750,8 @@ static device_method_t ti_sdhci_methods[] = { DEVMETHOD_END }; -static driver_t ti_sdhci_driver = { - "sdhci_ti", - ti_sdhci_methods, - sizeof(struct ti_sdhci_softc), -}; +PRIVATE_DEFINE_CLASSN(sdhci_ti, ti_sdhci_driver, ti_sdhci_methods, + sizeof(struct ti_sdhci_softc)); DRIVER_MODULE(sdhci_ti, simplebus, ti_sdhci_driver, NULL, NULL); MODULE_DEPEND(sdhci_ti, ti_sysc, 1, 1, 1); diff --git a/sys/arm/ti/ti_sdma.c b/sys/arm/ti/ti_sdma.c index e89a5c7b4f3c39..0ac18d27133e06 100644 --- a/sys/arm/ti/ti_sdma.c +++ b/sys/arm/ti/ti_sdma.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include @@ -1231,14 +1231,12 @@ ti_sdma_attach(device_t dev) static device_method_t ti_sdma_methods[] = { DEVMETHOD(device_probe, ti_sdma_probe), DEVMETHOD(device_attach, ti_sdma_attach), - {0, 0}, -}; -static driver_t ti_sdma_driver = { - "ti_sdma", - ti_sdma_methods, - sizeof(struct ti_sdma_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(ti_sdma, ti_sdma_driver, ti_sdma_methods, + sizeof(struct ti_sdma_softc)); + DRIVER_MODULE(ti_sdma, simplebus, ti_sdma_driver, 0, 0); MODULE_DEPEND(ti_sdma, ti_sysc, 1, 1, 1); diff --git a/sys/arm/ti/ti_spi.c b/sys/arm/ti/ti_spi.c index fd0e0b0853638c..632d92627958e6 100644 --- a/sys/arm/ti/ti_spi.c +++ b/sys/arm/ti/ti_spi.c @@ -37,8 +37,8 @@ #include #include +#include #include -#include #include #include @@ -567,11 +567,8 @@ static device_method_t ti_spi_methods[] = { DEVMETHOD_END }; -static driver_t ti_spi_driver = { - "spi", - ti_spi_methods, - sizeof(struct ti_spi_softc), -}; +PRIVATE_DEFINE_CLASSN(spi, ti_spi_driver, ti_spi_methods, + sizeof(struct ti_spi_softc)); DRIVER_MODULE(ti_spi, simplebus, ti_spi_driver, 0, 0); MODULE_DEPEND(ti_spi, ti_sysc, 1, 1, 1); diff --git a/sys/arm/ti/ti_wdt.c b/sys/arm/ti/ti_wdt.c index db580cd17cdfe6..773192f65cc69f 100644 --- a/sys/arm/ti/ti_wdt.c +++ b/sys/arm/ti/ti_wdt.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include @@ -81,11 +81,8 @@ static device_method_t ti_wdt_methods[] = { DEVMETHOD_END }; -static driver_t ti_wdt_driver = { - "ti_wdt", - ti_wdt_methods, - sizeof(struct ti_wdt_softc) -}; +PRIVATE_DEFINE_CLASSN(ti_wdt, ti_wdt_driver, ti_wdt_methods, + sizeof(struct ti_wdt_softc)); DRIVER_MODULE(ti_wdt, simplebus, ti_wdt_driver, 0, 0); MODULE_DEPEND(ti_wdt, ti_sysc, 1, 1, 1); diff --git a/sys/arm/ti/twl/twl.c b/sys/arm/ti/twl/twl.c index ee54b0ea1f2c67..41cc54b711e3c4 100644 --- a/sys/arm/ti/twl/twl.c +++ b/sys/arm/ti/twl/twl.c @@ -57,8 +57,8 @@ #include #include +#include #include -#include #include #include @@ -443,14 +443,10 @@ static device_method_t twl_methods[] = { DEVMETHOD(device_attach, twl_attach), DEVMETHOD(device_detach, twl_detach), - {0, 0}, + DEVMETHOD_END }; -static driver_t twl_driver = { - "twl", - twl_methods, - sizeof(struct twl_softc), -}; +PRIVATE_DEFINE_CLASSN(twl, twl_driver, twl_methods, sizeof(struct twl_softc)); DRIVER_MODULE(twl, iicbus, twl_driver, 0, 0); MODULE_VERSION(twl, 1); diff --git a/sys/arm/ti/twl/twl_clks.c b/sys/arm/ti/twl/twl_clks.c index 30dec7bcfc3729..7feb40b90950f2 100644 --- a/sys/arm/ti/twl/twl_clks.c +++ b/sys/arm/ti/twl/twl_clks.c @@ -62,8 +62,8 @@ #include #include +#include #include -#include #include #include @@ -634,14 +634,11 @@ static device_method_t twl_clks_methods[] = { DEVMETHOD(device_attach, twl_clks_attach), DEVMETHOD(device_detach, twl_clks_detach), - {0, 0}, + DEVMETHOD_END }; -static driver_t twl_clks_driver = { - "twl_clks", - twl_clks_methods, - sizeof(struct twl_clks_softc), -}; +PRIVATE_DEFINE_CLASSN(twl_clks, twl_clks_driver, twl_clks_methods, + sizeof(struct twl_clks_softc)); DRIVER_MODULE(twl_clks, twl, twl_clks_driver, 0, 0); MODULE_VERSION(twl_clks, 1); diff --git a/sys/arm/ti/twl/twl_vreg.c b/sys/arm/ti/twl/twl_vreg.c index 7609ed9a9c4f67..ac2b7f84b5068a 100644 --- a/sys/arm/ti/twl/twl_vreg.c +++ b/sys/arm/ti/twl/twl_vreg.c @@ -63,8 +63,8 @@ #include #include +#include #include -#include #include #include @@ -1013,14 +1013,11 @@ static device_method_t twl_vreg_methods[] = { DEVMETHOD(device_attach, twl_vreg_attach), DEVMETHOD(device_detach, twl_vreg_detach), - {0, 0}, + DEVMETHOD_END }; -static driver_t twl_vreg_driver = { - "twl_vreg", - twl_vreg_methods, - sizeof(struct twl_vreg_softc), -}; +PRIVATE_DEFINE_CLASSN(twl_vreg, twl_vreg_driver, twl_vreg_methods, + sizeof(struct twl_vreg_softc)); DRIVER_MODULE(twl_vreg, twl, twl_vreg_driver, 0, 0); MODULE_VERSION(twl_vreg, 1); diff --git a/sys/arm/ti/usb/omap_ehci.c b/sys/arm/ti/usb/omap_ehci.c index 224c786bf9facb..541e494968c642 100644 --- a/sys/arm/ti/usb/omap_ehci.c +++ b/sys/arm/ti/usb/omap_ehci.c @@ -454,13 +454,11 @@ static device_method_t ehci_methods[] = { /* Bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), - {0, 0} -}; -static driver_t ehci_driver = { - "ehci", - ehci_methods, - sizeof(struct omap_ehci_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(ehci, ehci_driver, ehci_methods, + sizeof(struct omap_ehci_softc)); + DRIVER_MODULE(omap_ehci, omap_uhh, ehci_driver, 0, 0); diff --git a/sys/arm/ti/usb/omap_tll.c b/sys/arm/ti/usb/omap_tll.c index 08fbd2344e4994..e313aa693feee9 100644 --- a/sys/arm/ti/usb/omap_tll.c +++ b/sys/arm/ti/usb/omap_tll.c @@ -344,13 +344,11 @@ static device_method_t omap_tll_methods[] = { DEVMETHOD(device_suspend, bus_generic_suspend), DEVMETHOD(device_resume, bus_generic_resume), DEVMETHOD(device_shutdown, bus_generic_shutdown), - {0, 0} -}; -static driver_t omap_tll_driver = { - "omap_tll", - omap_tll_methods, - sizeof(struct omap_tll_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(omap_tll, omap_tll_driver, omap_tll_methods, + sizeof(struct omap_tll_softc)); + DRIVER_MODULE(omap_tll, simplebus, omap_tll_driver, 0, 0); diff --git a/sys/arm/xilinx/zy7_devcfg.c b/sys/arm/xilinx/zy7_devcfg.c index 6df0fba1f56a94..c29ee1f7369cb8 100644 --- a/sys/arm/xilinx/zy7_devcfg.c +++ b/sys/arm/xilinx/zy7_devcfg.c @@ -835,11 +835,8 @@ static device_method_t zy7_devcfg_methods[] = { DEVMETHOD_END }; -static driver_t zy7_devcfg_driver = { - "zy7_devcfg", - zy7_devcfg_methods, - sizeof(struct zy7_devcfg_softc), -}; +PRIVATE_DEFINE_CLASSN(zy7_devcfg, zy7_devcfg_driver, zy7_devcfg_methods, + sizeof(struct zy7_devcfg_softc)); DRIVER_MODULE(zy7_devcfg, simplebus, zy7_devcfg_driver, 0, 0); MODULE_DEPEND(zy7_devcfg, zy7_slcr, 1, 1, 1); diff --git a/sys/arm/xilinx/zy7_ehci.c b/sys/arm/xilinx/zy7_ehci.c index 545e2a9bce1683..e30e961f386d3e 100644 --- a/sys/arm/xilinx/zy7_ehci.c +++ b/sys/arm/xilinx/zy7_ehci.c @@ -358,11 +358,8 @@ static device_method_t ehci_methods[] = { DEVMETHOD_END }; -static driver_t ehci_driver = { - "ehci", - ehci_methods, - sizeof(struct ehci_softc), -}; +PRIVATE_DEFINE_CLASSN(ehci, ehci_driver, ehci_methods, + sizeof(struct ehci_softc)); DRIVER_MODULE(zy7_ehci, simplebus, ehci_driver, NULL, NULL); MODULE_DEPEND(zy7_ehci, usb, 1, 1, 1); diff --git a/sys/arm/xilinx/zy7_gpio.c b/sys/arm/xilinx/zy7_gpio.c index 091237014c6f33..1065ba9d6dadda 100644 --- a/sys/arm/xilinx/zy7_gpio.c +++ b/sys/arm/xilinx/zy7_gpio.c @@ -488,11 +488,8 @@ static device_method_t zy7_gpio_methods[] = { DEVMETHOD_END }; -static driver_t zy7_gpio_driver = { - "gpio", - zy7_gpio_methods, - sizeof(struct zy7_gpio_softc), -}; +PRIVATE_DEFINE_CLASSN(gpio, zy7_gpio_driver, zy7_gpio_methods, + sizeof(struct zy7_gpio_softc)); EARLY_DRIVER_MODULE(zy7_gpio, simplebus, zy7_gpio_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); diff --git a/sys/arm/xilinx/zy7_machdep.c b/sys/arm/xilinx/zy7_machdep.c index 723c3f3b2d7368..17dfd856071ce9 100644 --- a/sys/arm/xilinx/zy7_machdep.c +++ b/sys/arm/xilinx/zy7_machdep.c @@ -93,7 +93,7 @@ static platform_method_t zynq7_methods[] = { PLATFORMMETHOD(platform_pl310_init, zynq7_pl310_init), - PLATFORMMETHOD_END, + PLATFORMMETHOD_END }; FDT_PLATFORM_DEF(zynq7, "zynq7", 0, "xlnx,zynq-7000", 200); diff --git a/sys/arm/xilinx/zy7_mp.c b/sys/arm/xilinx/zy7_mp.c index def950cadf0be6..f506bebf31ac83 100644 --- a/sys/arm/xilinx/zy7_mp.c +++ b/sys/arm/xilinx/zy7_mp.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/arm/xilinx/zy7_qspi.c b/sys/arm/xilinx/zy7_qspi.c index 49d4cafd8d614e..7a7d44f8b3733c 100644 --- a/sys/arm/xilinx/zy7_qspi.c +++ b/sys/arm/xilinx/zy7_qspi.c @@ -737,11 +737,8 @@ static device_method_t zy7_qspi_methods[] = { DEVMETHOD_END }; -static driver_t zy7_qspi_driver = { - "zy7_qspi", - zy7_qspi_methods, - sizeof(struct zy7_qspi_softc), -}; +PRIVATE_DEFINE_CLASSN(zy7_qspi, zy7_qspi_driver, zy7_qspi_methods, + sizeof(struct zy7_qspi_softc)); DRIVER_MODULE(zy7_qspi, simplebus, zy7_qspi_driver, 0, 0); DRIVER_MODULE(ofw_spibus, zy7_qspi, ofw_spibus_driver, 0, 0); diff --git a/sys/arm/xilinx/zy7_slcr.c b/sys/arm/xilinx/zy7_slcr.c index a46ccb59a07b94..a1634f1da60012 100644 --- a/sys/arm/xilinx/zy7_slcr.c +++ b/sys/arm/xilinx/zy7_slcr.c @@ -701,11 +701,8 @@ static device_method_t zy7_slcr_methods[] = { DEVMETHOD_END }; -static driver_t zy7_slcr_driver = { - "zy7_slcr", - zy7_slcr_methods, - sizeof(struct zy7_slcr_softc), -}; +PRIVATE_DEFINE_CLASSN(zy7_slcr, zy7_slcr_driver, zy7_slcr_methods, + sizeof(struct zy7_slcr_softc)); DRIVER_MODULE(zy7_slcr, simplebus, zy7_slcr_driver, 0, 0); MODULE_VERSION(zy7_slcr, 1); diff --git a/sys/arm/xilinx/zy7_spi.c b/sys/arm/xilinx/zy7_spi.c index bb5bb7f4676707..43ffebf863dbae 100644 --- a/sys/arm/xilinx/zy7_spi.c +++ b/sys/arm/xilinx/zy7_spi.c @@ -576,11 +576,8 @@ static device_method_t zy7_spi_methods[] = { DEVMETHOD_END }; -static driver_t zy7_spi_driver = { - "zy7_spi", - zy7_spi_methods, - sizeof(struct zy7_spi_softc), -}; +PRIVATE_DEFINE_CLASSN(zy7_spi, zy7_spi_driver, zy7_spi_methods, + sizeof(struct zy7_spi_softc)); DRIVER_MODULE(zy7_spi, simplebus, zy7_spi_driver, 0, 0); DRIVER_MODULE(ofw_spibus, zy7_spi, ofw_spibus_driver, 0, 0); diff --git a/sys/arm64/acpica/acpi_iort.c b/sys/arm64/acpica/acpi_iort.c index a0e24788b7754d..4779970501f5b1 100644 --- a/sys/arm64/acpica/acpi_iort.c +++ b/sys/arm64/acpica/acpi_iort.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include diff --git a/sys/arm64/apple/apple_aic.c b/sys/arm64/apple/apple_aic.c index c9ce3b4d21659a..bd7d5f26e0a112 100644 --- a/sys/arm64/apple/apple_aic.c +++ b/sys/arm64/apple/apple_aic.c @@ -41,7 +41,7 @@ #include #include #ifdef SMP -#include +#include #include #endif @@ -152,9 +152,9 @@ static pic_enable_intr_t apple_aic_enable_intr; static pic_map_intr_t apple_aic_map_intr; static pic_setup_intr_t apple_aic_setup_intr; static pic_teardown_intr_t apple_aic_teardown_intr; -static pic_post_filter_t apple_aic_post_filter; -static pic_post_ithread_t apple_aic_post_ithread; -static pic_pre_ithread_t apple_aic_pre_ithread; +static intr_event_post_filter_t apple_aic_post_filter; +static intr_event_post_ithread_t apple_aic_post_ithread; +static intr_event_pre_ithread_t apple_aic_pre_ithread; #ifdef SMP static pic_bind_intr_t apple_aic_bind_intr; static pic_init_secondary_t apple_aic_init_secondary; @@ -753,15 +753,17 @@ static device_method_t apple_aic_methods[] = { DEVMETHOD(device_probe, apple_aic_probe), DEVMETHOD(device_attach, apple_aic_attach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_post_filter, apple_aic_post_filter), + DEVMETHOD(intr_event_post_ithread, apple_aic_post_ithread), + DEVMETHOD(intr_event_pre_ithread, apple_aic_pre_ithread), + /* Interrupt controller interface */ DEVMETHOD(pic_disable_intr, apple_aic_disable_intr), DEVMETHOD(pic_enable_intr, apple_aic_enable_intr), DEVMETHOD(pic_map_intr, apple_aic_map_intr), DEVMETHOD(pic_setup_intr, apple_aic_setup_intr), DEVMETHOD(pic_teardown_intr, apple_aic_teardown_intr), - DEVMETHOD(pic_post_filter, apple_aic_post_filter), - DEVMETHOD(pic_post_ithread, apple_aic_post_ithread), - DEVMETHOD(pic_pre_ithread, apple_aic_pre_ithread), #ifdef SMP DEVMETHOD(pic_bind_intr, apple_aic_bind_intr), DEVMETHOD(pic_init_secondary, apple_aic_init_secondary), @@ -773,8 +775,8 @@ static device_method_t apple_aic_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(aic, apple_aic_driver, apple_aic_methods, - sizeof(struct apple_aic_softc)); +PRIVATE_DEFINE_CLASSN(aic, apple_aic_driver, apple_aic_methods, + sizeof(struct apple_aic_softc), pic_base_class); EARLY_DRIVER_MODULE(aic, simplebus, apple_aic_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm64/apple/apple_wdog.c b/sys/arm64/apple/apple_wdog.c index aaa8992985710f..9a43e87e505632 100644 --- a/sys/arm64/apple/apple_wdog.c +++ b/sys/arm64/apple/apple_wdog.c @@ -225,10 +225,7 @@ static device_method_t apple_wdog_methods[] = { DEVMETHOD_END }; -static driver_t apple_wdog_driver = { - "apple_wdog", - apple_wdog_methods, - sizeof(struct apple_wdog_softc), -}; +PRIVATE_DEFINE_CLASSN(apple_wdog, apple_wdog_driver, apple_wdog_methods, + sizeof(struct apple_wdog_softc)); DRIVER_MODULE(apple_wdog, simplebus, apple_wdog_driver, 0, 0); diff --git a/sys/arm64/arm64/autoconf.c b/sys/arm64/arm64/autoconf.c index 2c914e94c7e91e..9042fe2ba01a55 100644 --- a/sys/arm64/arm64/autoconf.c +++ b/sys/arm64/arm64/autoconf.c @@ -43,7 +43,7 @@ #include #include -#include +#include static void configure_first(void *); static void configure(void *); diff --git a/sys/arm64/arm64/busdma_bounce.c b/sys/arm64/arm64/busdma_bounce.c index abfd5c195857e9..e7581a091bb3e3 100644 --- a/sys/arm64/arm64/busdma_bounce.c +++ b/sys/arm64/arm64/busdma_bounce.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -55,6 +54,7 @@ #include #include +#include #include #include diff --git a/sys/arm64/arm64/cmn600.c b/sys/arm64/arm64/cmn600.c index 530cdcdc3d0636..b0ef6562535c44 100644 --- a/sys/arm64/arm64/cmn600.c +++ b/sys/arm64/arm64/cmn600.c @@ -811,11 +811,8 @@ static device_method_t cmn600_acpi_methods[] = { DEVMETHOD_END }; -static driver_t cmn600_acpi_driver = { - "cmn600", - cmn600_acpi_methods, - sizeof(struct cmn600_softc), -}; +PRIVATE_DEFINE_CLASSN(cmn600, cmn600_acpi_driver, cmn600_acpi_methods, + sizeof(struct cmn600_softc)); DRIVER_MODULE(cmn600, acpi, cmn600_acpi_driver, 0, 0); MODULE_VERSION(cmn600, 1); diff --git a/sys/arm64/arm64/exception.S b/sys/arm64/arm64/exception.S index 13095def8b00ee..11f586071a1bbf 100644 --- a/sys/arm64/arm64/exception.S +++ b/sys/arm64/arm64/exception.S @@ -29,9 +29,9 @@ #include #include +#include #include "assym.inc" -#include .text diff --git a/sys/arm64/arm64/gic_v3.c b/sys/arm64/arm64/gic_v3.c index 201cdae6de09e6..e52d159854f9d9 100644 --- a/sys/arm64/arm64/gic_v3.c +++ b/sys/arm64/arm64/gic_v3.c @@ -47,14 +47,13 @@ #include #include #include -#include #include #include #include #include -#include +#include #ifdef FDT #include @@ -85,9 +84,9 @@ static pic_enable_intr_t gic_v3_enable_intr; static pic_map_intr_t gic_v3_map_intr; static pic_setup_intr_t gic_v3_setup_intr; static pic_teardown_intr_t gic_v3_teardown_intr; -static pic_post_filter_t gic_v3_post_filter; -static pic_post_ithread_t gic_v3_post_ithread; -static pic_pre_ithread_t gic_v3_pre_ithread; +static intr_event_post_filter_t gic_v3_post_filter; +static intr_event_post_ithread_t gic_v3_post_ithread; +static intr_event_pre_ithread_t gic_v3_pre_ithread; static pic_bind_intr_t gic_v3_bind_intr; #ifdef SMP static pic_init_secondary_t gic_v3_init_secondary; @@ -125,15 +124,17 @@ static device_method_t gic_v3_methods[] = { DEVMETHOD(bus_alloc_resource, gic_v3_alloc_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, gic_v3_pre_ithread), + DEVMETHOD(intr_event_post_ithread, gic_v3_post_ithread), + DEVMETHOD(intr_event_post_filter, gic_v3_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_disable_intr, gic_v3_disable_intr), DEVMETHOD(pic_enable_intr, gic_v3_enable_intr), DEVMETHOD(pic_map_intr, gic_v3_map_intr), DEVMETHOD(pic_setup_intr, gic_v3_setup_intr), DEVMETHOD(pic_teardown_intr, gic_v3_teardown_intr), - DEVMETHOD(pic_post_filter, gic_v3_post_filter), - DEVMETHOD(pic_post_ithread, gic_v3_post_ithread), - DEVMETHOD(pic_pre_ithread, gic_v3_pre_ithread), #ifdef SMP DEVMETHOD(pic_bind_intr, gic_v3_bind_intr), DEVMETHOD(pic_init_secondary, gic_v3_init_secondary), @@ -159,8 +160,8 @@ static device_method_t gic_v3_methods[] = { DEVMETHOD_END }; -DEFINE_CLASS_0(gic, gic_v3_driver, gic_v3_methods, - sizeof(struct gic_v3_softc)); +DEFINE_CLASSN(gic, gic_v3_driver, gic_v3_methods, + sizeof(struct gic_v3_softc), pic_base_class); /* * Driver-specific definitions. diff --git a/sys/arm64/arm64/gic_v3_acpi.c b/sys/arm64/arm64/gic_v3_acpi.c index 7c3495fd442bc4..9478e8b48d466b 100644 --- a/sys/arm64/arm64/gic_v3_acpi.c +++ b/sys/arm64/arm64/gic_v3_acpi.c @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include diff --git a/sys/arm64/arm64/gic_v3_fdt.c b/sys/arm64/arm64/gic_v3_fdt.c index 9c034b417624bd..3b8fd7044b84bf 100644 --- a/sys/arm64/arm64/gic_v3_fdt.c +++ b/sys/arm64/arm64/gic_v3_fdt.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c index 4b554f2dc30add..b8e396b301397c 100644 --- a/sys/arm64/arm64/gicv3_its.c +++ b/sys/arm64/arm64/gicv3_its.c @@ -61,7 +61,7 @@ #include #include -#include +#include #include #include @@ -328,9 +328,9 @@ static pic_disable_intr_t gicv3_its_disable_intr; static pic_enable_intr_t gicv3_its_enable_intr; static pic_map_intr_t gicv3_its_map_intr; static pic_setup_intr_t gicv3_its_setup_intr; -static pic_post_filter_t gicv3_its_post_filter; -static pic_post_ithread_t gicv3_its_post_ithread; -static pic_pre_ithread_t gicv3_its_pre_ithread; +static intr_event_post_filter_t gicv3_its_post_filter; +static intr_event_post_ithread_t gicv3_its_post_ithread; +static intr_event_pre_ithread_t gicv3_its_pre_ithread; static pic_bind_intr_t gicv3_its_bind_intr; #ifdef SMP static pic_init_secondary_t gicv3_its_init_secondary; @@ -356,14 +356,16 @@ static device_method_t gicv3_its_methods[] = { /* Device interface */ DEVMETHOD(device_detach, gicv3_its_detach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, gicv3_its_pre_ithread), + DEVMETHOD(intr_event_post_ithread, gicv3_its_post_ithread), + DEVMETHOD(intr_event_post_filter, gicv3_its_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_disable_intr, gicv3_its_disable_intr), DEVMETHOD(pic_enable_intr, gicv3_its_enable_intr), DEVMETHOD(pic_map_intr, gicv3_its_map_intr), DEVMETHOD(pic_setup_intr, gicv3_its_setup_intr), - DEVMETHOD(pic_post_filter, gicv3_its_post_filter), - DEVMETHOD(pic_post_ithread, gicv3_its_post_ithread), - DEVMETHOD(pic_pre_ithread, gicv3_its_pre_ithread), #ifdef SMP DEVMETHOD(pic_bind_intr, gicv3_its_bind_intr), DEVMETHOD(pic_init_secondary, gicv3_its_init_secondary), @@ -384,8 +386,8 @@ static device_method_t gicv3_its_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(gic, gicv3_its_driver, gicv3_its_methods, - sizeof(struct gicv3_its_softc)); +PRIVATE_DEFINE_CLASSN(gic, gicv3_its_driver, gicv3_its_methods, + sizeof(struct gicv3_its_softc), pic_base_class); static void gicv3_its_cmdq_init(struct gicv3_its_softc *sc) diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c index 636f26fba9390e..6303d85b6f0d70 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -57,7 +57,7 @@ #include #include #include -#include +#include #include #ifdef VFP #include diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c index 8d7489b844ae90..40ab1a7435971e 100644 --- a/sys/arm64/arm64/nexus.c +++ b/sys/arm64/arm64/nexus.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -54,7 +53,7 @@ #include #include -#include +#include #include #include #include @@ -153,11 +152,7 @@ static device_method_t nexus_methods[] = { DEVMETHOD_END }; -static driver_t nexus_driver = { - "nexus", - nexus_methods, - 1 /* no softc */ -}; +PRIVATE_DEFINE_CLASSN(nexus, nexus_driver, nexus_methods, 0 /* no softc */); static int nexus_attach(device_t dev) @@ -442,7 +437,7 @@ static device_method_t nexus_fdt_methods[] = { /* OFW interface */ DEVMETHOD(ofw_bus_map_intr, nexus_ofw_map_intr), - DEVMETHOD_END, + DEVMETHOD_END }; #define nexus_baseclasses nexus_fdt_baseclasses @@ -533,7 +528,7 @@ static device_method_t nexus_acpi_methods[] = { /* ACPI interface */ DEVMETHOD(acpi_bus_map_intr, nexus_acpi_map_intr), - DEVMETHOD_END, + DEVMETHOD_END }; #define nexus_baseclasses nexus_acpi_baseclasses diff --git a/sys/arm64/broadcom/genet/if_genet.c b/sys/arm64/broadcom/genet/if_genet.c index 0602f076b25760..88088ef59b9b26 100644 --- a/sys/arm64/broadcom/genet/if_genet.c +++ b/sys/arm64/broadcom/genet/if_genet.c @@ -1814,11 +1814,7 @@ static device_method_t gen_methods[] = { DEVMETHOD_END }; -static driver_t gen_driver = { - "genet", - gen_methods, - sizeof(struct gen_softc), -}; +PRIVATE_DEFINE_CLASSN(genet, gen_driver, gen_methods, sizeof(struct gen_softc)); DRIVER_MODULE(genet, simplebus, gen_driver, 0, 0); DRIVER_MODULE(miibus, genet, miibus_driver, 0, 0); diff --git a/sys/arm64/cavium/thunder_pcie_common.c b/sys/arm64/cavium/thunder_pcie_common.c index 1fe6b1a683be4b..0d777e5eeaabe0 100644 --- a/sys/arm64/cavium/thunder_pcie_common.c +++ b/sys/arm64/cavium/thunder_pcie_common.c @@ -40,7 +40,7 @@ #include #include -#include +#include #ifdef FDT #include diff --git a/sys/arm64/cavium/thunder_pcie_pem.c b/sys/arm64/cavium/thunder_pcie_pem.c index b01dfecb347e31..b246e748415f41 100644 --- a/sys/arm64/cavium/thunder_pcie_pem.c +++ b/sys/arm64/cavium/thunder_pcie_pem.c @@ -55,9 +55,9 @@ #include #include +#include #include #include -#include #include #include diff --git a/sys/arm64/cavium/thunder_pcie_pem_fdt.c b/sys/arm64/cavium/thunder_pcie_pem_fdt.c index 74c9f0e5572830..fb85c8b8567020 100644 --- a/sys/arm64/cavium/thunder_pcie_pem_fdt.c +++ b/sys/arm64/cavium/thunder_pcie_pem_fdt.c @@ -49,7 +49,7 @@ #include #include -#include +#include #include "thunder_pcie_common.h" #include "thunder_pcie_pem.h" diff --git a/sys/arm64/coresight/coresight_cpu_debug.c b/sys/arm64/coresight/coresight_cpu_debug.c index 5dc80bad9b7699..04dcabf69790b0 100644 --- a/sys/arm64/coresight/coresight_cpu_debug.c +++ b/sys/arm64/coresight/coresight_cpu_debug.c @@ -145,14 +145,12 @@ static device_method_t debug_methods[] = { /* Coresight interface */ DEVMETHOD(coresight_init, debug_init), + DEVMETHOD_END }; -static driver_t debug_driver = { - "debug", - debug_methods, - sizeof(struct debug_softc), -}; +PRIVATE_DEFINE_CLASSN(debug, debug_driver, debug_methods, + sizeof(struct debug_softc)); EARLY_DRIVER_MODULE(debug, simplebus, debug_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_LATE); diff --git a/sys/arm64/freescale/imx/imx7gpc.c b/sys/arm64/freescale/imx/imx7gpc.c index b3edb0c51adf55..3b575d761401f2 100644 --- a/sys/arm64/freescale/imx/imx7gpc.c +++ b/sys/arm64/freescale/imx/imx7gpc.c @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include @@ -122,7 +122,7 @@ imx7gpc_pre_ithread(device_t dev, struct intr_irqsrc *isrc) { struct imx7gpc_softc *sc = device_get_softc(dev); - PIC_PRE_ITHREAD(sc->parent, isrc); + INTR_EVENT_PRE_ITHREAD(sc->parent, isrc); } static void @@ -130,7 +130,7 @@ imx7gpc_post_ithread(device_t dev, struct intr_irqsrc *isrc) { struct imx7gpc_softc *sc = device_get_softc(dev); - PIC_POST_ITHREAD(sc->parent, isrc); + INTR_EVENT_POST_ITHREAD(sc->parent, isrc); } static void @@ -138,7 +138,7 @@ imx7gpc_post_filter(device_t dev, struct intr_irqsrc *isrc) { struct imx7gpc_softc *sc = device_get_softc(dev); - PIC_POST_FILTER(sc->parent, isrc); + INTR_EVENT_POST_FILTER(sc->parent, isrc); } #ifdef SMP @@ -212,6 +212,11 @@ static device_method_t imx7gpc_methods[] = { DEVMETHOD(device_probe, imx7gpc_probe), DEVMETHOD(device_attach, imx7gpc_attach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, imx7gpc_pre_ithread), + DEVMETHOD(intr_event_post_ithread, imx7gpc_post_ithread), + DEVMETHOD(intr_event_post_filter, imx7gpc_post_filter), + /* Interrupt controller interface */ DEVMETHOD(pic_activate_intr, imx7gpc_activate_intr), DEVMETHOD(pic_disable_intr, imx7gpc_disable_intr), @@ -220,9 +225,6 @@ static device_method_t imx7gpc_methods[] = { DEVMETHOD(pic_deactivate_intr, imx7gpc_deactivate_intr), DEVMETHOD(pic_setup_intr, imx7gpc_setup_intr), DEVMETHOD(pic_teardown_intr, imx7gpc_teardown_intr), - DEVMETHOD(pic_pre_ithread, imx7gpc_pre_ithread), - DEVMETHOD(pic_post_ithread, imx7gpc_post_ithread), - DEVMETHOD(pic_post_filter, imx7gpc_post_filter), #ifdef SMP DEVMETHOD(pic_bind_intr, imx7gpc_bind_intr), #endif @@ -230,11 +232,8 @@ static device_method_t imx7gpc_methods[] = { DEVMETHOD_END }; -static driver_t imx7gpc_driver = { - "imx7gpc", - imx7gpc_methods, - sizeof(struct imx7gpc_softc), -}; +PRIVATE_DEFINE_CLASSN(imx7gpc, imx7gpc_driver, imx7gpc_methods, + sizeof(struct imx7gpc_softc), pic_base_class); EARLY_DRIVER_MODULE(imx7gpc, ofwbus, imx7gpc_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm64/include/intr.h b/sys/arm64/include/interrupt.h similarity index 93% rename from sys/arm64/include/intr.h rename to sys/arm64/include/interrupt.h index ef7fe56e3a13f6..ff40581eee05ab 100644 --- a/sys/arm64/include/intr.h +++ b/sys/arm64/include/interrupt.h @@ -24,13 +24,11 @@ * SUCH DAMAGE. */ -#ifndef _MACHINE_INTR_H_ -#define _MACHINE_INTR_H_ +#ifndef __MACHINE_INTERRUPT_H__ +#define __MACHINE_INTERRUPT_H__ #ifndef LOCORE -#ifdef FDT -#include -#endif +#include static inline void arm_irq_memory_barrier(uintptr_t irq) @@ -52,4 +50,4 @@ arm_irq_memory_barrier(uintptr_t irq) #define INTR_ROOT_FIQ 1 #define INTR_ROOT_COUNT 2 -#endif /* _MACHINE_INTR_H */ +#endif /* __MACHINE_INTERRUPT_H__ */ diff --git a/sys/arm64/intel/stratix10-soc-fpga-mgr.c b/sys/arm64/intel/stratix10-soc-fpga-mgr.c index baa35b9a85a6c8..b416f5f2177fe2 100644 --- a/sys/arm64/intel/stratix10-soc-fpga-mgr.c +++ b/sys/arm64/intel/stratix10-soc-fpga-mgr.c @@ -58,7 +58,7 @@ #include #include -#include +#include #define SVC_BUF_SIZE (512 * 1024) @@ -308,13 +308,11 @@ static device_method_t fpgamgr_s10_methods[] = { DEVMETHOD(device_probe, fpgamgr_s10_probe), DEVMETHOD(device_attach, fpgamgr_s10_attach), DEVMETHOD(device_detach, fpgamgr_s10_detach), - { 0, 0 } -}; -static driver_t fpgamgr_s10_driver = { - "fpgamgr_s10", - fpgamgr_s10_methods, - sizeof(struct fpgamgr_s10_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(fpgamgr_s10, fpgamgr_s10_driver, fpgamgr_s10_methods, + sizeof(struct fpgamgr_s10_softc)); + DRIVER_MODULE(fpgamgr_s10, simplebus, fpgamgr_s10_driver, 0, 0); diff --git a/sys/arm64/intel/stratix10-svc.c b/sys/arm64/intel/stratix10-svc.c index d06d8d27e13dad..249ea7b139a191 100644 --- a/sys/arm64/intel/stratix10-svc.c +++ b/sys/arm64/intel/stratix10-svc.c @@ -60,7 +60,7 @@ #include #include -#include +#include struct s10_svc_softc { device_t dev; @@ -253,14 +253,12 @@ s10_svc_attach(device_t dev) static device_method_t s10_svc_methods[] = { DEVMETHOD(device_probe, s10_svc_probe), DEVMETHOD(device_attach, s10_svc_attach), - { 0, 0 } -}; -static driver_t s10_svc_driver = { - "s10_svc", - s10_svc_methods, - sizeof(struct s10_svc_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(s10_svc, s10_svc_driver, s10_svc_methods, + sizeof(struct s10_svc_softc)); + EARLY_DRIVER_MODULE(s10_svc, simplebus, s10_svc_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm64/nvidia/tegra210/max77620.c b/sys/arm64/nvidia/tegra210/max77620.c index d9c7736bd4c304..50219e59df1248 100644 --- a/sys/arm64/nvidia/tegra210/max77620.c +++ b/sys/arm64/nvidia/tegra210/max77620.c @@ -505,6 +505,6 @@ static device_method_t max77620_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(gpio, max77620_driver, max77620_methods, +PRIVATE_DEFINE_CLASSN(gpio, max77620_driver, max77620_methods, sizeof(struct max77620_softc)); EARLY_DRIVER_MODULE(max77620, iicbus, max77620_driver, NULL, NULL, 74); diff --git a/sys/arm64/nvidia/tegra210/max77620_rtc.c b/sys/arm64/nvidia/tegra210/max77620_rtc.c index 77d38c347d14df..086e8c530db6ea 100644 --- a/sys/arm64/nvidia/tegra210/max77620_rtc.c +++ b/sys/arm64/nvidia/tegra210/max77620_rtc.c @@ -420,6 +420,6 @@ static device_method_t max77620_rtc_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(rtc, max77620_rtc_driver, max77620_rtc_methods, +PRIVATE_DEFINE_CLASSN(rtc, max77620_rtc_driver, max77620_rtc_methods, sizeof(struct max77620_rtc_softc)); EARLY_DRIVER_MODULE(max77620rtc_, iicbus, max77620_rtc_driver, NULL, NULL, 74); diff --git a/sys/arm64/nvidia/tegra210/tegra210_car.c b/sys/arm64/nvidia/tegra210/tegra210_car.c index bff91024192f91..39888665886b36 100644 --- a/sys/arm64/nvidia/tegra210/tegra210_car.c +++ b/sys/arm64/nvidia/tegra210/tegra210_car.c @@ -591,7 +591,7 @@ static device_method_t tegra210_car_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(car, tegra210_car_driver, tegra210_car_methods, +PRIVATE_DEFINE_CLASSN(car, tegra210_car_driver, tegra210_car_methods, sizeof(struct tegra210_car_softc)); EARLY_DRIVER_MODULE(tegra210_car, simplebus, tegra210_car_driver, NULL, NULL, BUS_PASS_TIMER); diff --git a/sys/arm64/nvidia/tegra210/tegra210_coretemp.c b/sys/arm64/nvidia/tegra210/tegra210_coretemp.c index ac037d4ac385ad..4245f3eacfd51b 100644 --- a/sys/arm64/nvidia/tegra210/tegra210_coretemp.c +++ b/sys/arm64/nvidia/tegra210/tegra210_coretemp.c @@ -259,6 +259,6 @@ static device_method_t tegra210_coretemp_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(tegra210_coretemp, tegra210_coretemp_driver, +PRIVATE_DEFINE_CLASSN(tegra210_coretemp, tegra210_coretemp_driver, tegra210_coretemp_methods, sizeof(struct tegra210_coretemp_softc)); DRIVER_MODULE(tegra210_coretemp, cpu, tegra210_coretemp_driver, NULL, NULL); diff --git a/sys/arm64/nvidia/tegra210/tegra210_cpufreq.c b/sys/arm64/nvidia/tegra210/tegra210_cpufreq.c index 9b248a09bd5892..91ff9f5e063590 100644 --- a/sys/arm64/nvidia/tegra210/tegra210_cpufreq.c +++ b/sys/arm64/nvidia/tegra210/tegra210_cpufreq.c @@ -491,6 +491,6 @@ static device_method_t tegra210_cpufreq_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(tegra210_cpufreq, tegra210_cpufreq_driver, +PRIVATE_DEFINE_CLASSN(tegra210_cpufreq, tegra210_cpufreq_driver, tegra210_cpufreq_methods, sizeof(struct tegra210_cpufreq_softc)); DRIVER_MODULE(tegra210_cpufreq, cpu, tegra210_cpufreq_driver, NULL, NULL); diff --git a/sys/arm64/nvidia/tegra210/tegra210_pinmux.c b/sys/arm64/nvidia/tegra210/tegra210_pinmux.c index 9c74ade4e66067..38191926f2dda9 100644 --- a/sys/arm64/nvidia/tegra210/tegra210_pinmux.c +++ b/sys/arm64/nvidia/tegra210/tegra210_pinmux.c @@ -748,7 +748,7 @@ static device_method_t tegra210_pinmux_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(pinmux, tegra210_pinmux_driver, tegra210_pinmux_methods, +PRIVATE_DEFINE_CLASSN(pinmux, tegra210_pinmux_driver, tegra210_pinmux_methods, sizeof(struct pinmux_softc)); EARLY_DRIVER_MODULE(tegra210_pinmux, simplebus, tegra210_pinmux_driver, NULL, NULL, 71); diff --git a/sys/arm64/nvidia/tegra210/tegra210_pmc.c b/sys/arm64/nvidia/tegra210/tegra210_pmc.c index b8b95ca32c40ed..74ee9a38a39896 100644 --- a/sys/arm64/nvidia/tegra210/tegra210_pmc.c +++ b/sys/arm64/nvidia/tegra210/tegra210_pmc.c @@ -618,7 +618,7 @@ static device_method_t tegra210_pmc_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(pmc, tegra210_pmc_driver, tegra210_pmc_methods, +PRIVATE_DEFINE_CLASSN(pmc, tegra210_pmc_driver, tegra210_pmc_methods, sizeof(struct tegra210_pmc_softc)); EARLY_DRIVER_MODULE(tegra210_pmc, simplebus, tegra210_pmc_driver, NULL, NULL, 70); diff --git a/sys/arm64/nvidia/tegra210/tegra210_xusbpadctl.c b/sys/arm64/nvidia/tegra210/tegra210_xusbpadctl.c index 4b9b566a79b7b4..3dc025c0f90669 100644 --- a/sys/arm64/nvidia/tegra210/tegra210_xusbpadctl.c +++ b/sys/arm64/nvidia/tegra210/tegra210_xusbpadctl.c @@ -1951,7 +1951,7 @@ static device_method_t tegra_xusbpadctl_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(xusbpadctl, tegra_xusbpadctl_driver, +PRIVATE_DEFINE_CLASSN(xusbpadctl, tegra_xusbpadctl_driver, tegra_xusbpadctl_methods, sizeof(struct padctl_softc)); EARLY_DRIVER_MODULE(tegra_xusbpadctl, simplebus, tegra_xusbpadctl_driver, NULL, NULL, 73); diff --git a/sys/arm64/qoriq/clk/ls1028a_flexspi_clk.c b/sys/arm64/qoriq/clk/ls1028a_flexspi_clk.c index e8635b35fe5f73..4c4fe00e526db2 100644 --- a/sys/arm64/qoriq/clk/ls1028a_flexspi_clk.c +++ b/sys/arm64/qoriq/clk/ls1028a_flexspi_clk.c @@ -301,7 +301,7 @@ static device_method_t ls1028a_flexspi_clk_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(fspi_clk, ls1028a_flexspi_clk_driver, ls1028a_flexspi_clk_methods, - sizeof(struct ls1028a_flexspi_clk_softc)); +PRIVATE_DEFINE_CLASSN(fspi_clk, ls1028a_flexspi_clk_driver, + ls1028a_flexspi_clk_methods, sizeof(struct ls1028a_flexspi_clk_softc)); EARLY_DRIVER_MODULE(ls1028a_flexspi_clk, simple_mfd, ls1028a_flexspi_clk_driver, NULL, NULL, BUS_PASS_TIMER); diff --git a/sys/arm64/qoriq/qoriq_dw_pci.c b/sys/arm64/qoriq/qoriq_dw_pci.c index 2492130e4b4255..ee72e7ec3cf184 100644 --- a/sys/arm64/qoriq/qoriq_dw_pci.c +++ b/sys/arm64/qoriq/qoriq_dw_pci.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include diff --git a/sys/arm64/qoriq/qoriq_gpio_pic.c b/sys/arm64/qoriq/qoriq_gpio_pic.c index ec84d2a14ae7ae..280e3668464949 100644 --- a/sys/arm64/qoriq/qoriq_gpio_pic.c +++ b/sys/arm64/qoriq/qoriq_gpio_pic.c @@ -415,19 +415,21 @@ static device_method_t qoriq_gpio_pic_methods[] = { DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, qoriq_gpio_pic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, qoriq_gpio_pic_post_ithread), + DEVMETHOD(intr_event_post_filter, qoriq_gpio_pic_post_filter), + DEVMETHOD(pic_disable_intr, qoriq_gpio_pic_disable_intr), DEVMETHOD(pic_enable_intr, qoriq_gpio_pic_enable_intr), DEVMETHOD(pic_map_intr, qoriq_gpio_pic_map_intr), DEVMETHOD(pic_setup_intr, qoriq_gpio_pic_setup_intr), DEVMETHOD(pic_teardown_intr, qoriq_gpio_pic_teardown_intr), - DEVMETHOD(pic_post_filter, qoriq_gpio_pic_post_filter), - DEVMETHOD(pic_post_ithread, qoriq_gpio_pic_post_ithread), - DEVMETHOD(pic_pre_ithread, qoriq_gpio_pic_pre_ithread), DEVMETHOD_END }; -DEFINE_CLASS_1(gpio, qoriq_gpio_pic_driver, qoriq_gpio_pic_methods, - sizeof(struct qoriq_gpio_pic_softc), qoriq_gpio_driver); +DEFINE_CLASSN(gpio, qoriq_gpio_pic_driver, qoriq_gpio_pic_methods, + sizeof(struct qoriq_gpio_pic_softc), pic_base_class, qoriq_gpio_driver); EARLY_DRIVER_MODULE(qoriq_gpio_pic, simplebus, qoriq_gpio_pic_driver, NULL, NULL, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); diff --git a/sys/arm64/qoriq/qoriq_therm.c b/sys/arm64/qoriq/qoriq_therm.c index 72c0e6ff0fa2ab..6228ab8bfc3e3e 100644 --- a/sys/arm64/qoriq/qoriq_therm.c +++ b/sys/arm64/qoriq/qoriq_therm.c @@ -512,6 +512,6 @@ static device_method_t qoriq_qoriq_therm_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(soctherm, qoriq_qoriq_therm_driver, qoriq_qoriq_therm_methods, - sizeof(struct qoriq_therm_softc)); +PRIVATE_DEFINE_CLASSN(soctherm, qoriq_qoriq_therm_driver, + qoriq_qoriq_therm_methods, sizeof(struct qoriq_therm_softc)); DRIVER_MODULE(qoriq_soctherm, simplebus, qoriq_qoriq_therm_driver, NULL, NULL); diff --git a/sys/arm64/qualcomm/qcom_gcc.c b/sys/arm64/qualcomm/qcom_gcc.c index 3f08577f4d3ccf..f088314927d2da 100644 --- a/sys/arm64/qualcomm/qcom_gcc.c +++ b/sys/arm64/qualcomm/qcom_gcc.c @@ -132,11 +132,8 @@ static device_method_t qcom_gcc_methods[] = { DEVMETHOD_END }; -static driver_t qcom_gcc_driver = { - "qcom_gcc", - qcom_gcc_methods, - sizeof(struct qcom_gcc_softc), -}; +PRIVATE_DEFINE_CLASSN(qcom_gcc, qcom_gcc_driver, qcom_gcc_methods, + sizeof(struct qcom_gcc_softc)); EARLY_DRIVER_MODULE(qcom_gcc, simplebus, qcom_gcc_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm64/rockchip/rk3328_codec.c b/sys/arm64/rockchip/rk3328_codec.c index 480a1087ea2df9..99869f567c04b1 100644 --- a/sys/arm64/rockchip/rk3328_codec.c +++ b/sys/arm64/rockchip/rk3328_codec.c @@ -581,11 +581,8 @@ static device_method_t rkcodec_methods[] = { DEVMETHOD_END }; -static driver_t rkcodec_driver = { - "rk3328codec", - rkcodec_methods, - sizeof(struct rkcodec_softc), -}; +PRIVATE_DEFINE_CLASSN(rk3328codec, rkcodec_driver, rkcodec_methods, + sizeof(struct rkcodec_softc)); DRIVER_MODULE(rkcodec, simplebus, rkcodec_driver, 0, 0); SIMPLEBUS_PNP_INFO(compat_data); diff --git a/sys/arm64/rockchip/rk3399_emmcphy.c b/sys/arm64/rockchip/rk3399_emmcphy.c index 97b2123e89fdd7..d795a6ecc12699 100644 --- a/sys/arm64/rockchip/rk3399_emmcphy.c +++ b/sys/arm64/rockchip/rk3399_emmcphy.c @@ -326,11 +326,8 @@ static device_method_t rk_emmcphy_methods[] = { DEVMETHOD_END }; -static driver_t rk_emmcphy_driver = { - "rk_emmcphy", - rk_emmcphy_methods, - sizeof(struct rk_emmcphy_softc) -}; +PRIVATE_DEFINE_CLASSN(rk_emmcphy, rk_emmcphy_driver, rk_emmcphy_methods, + sizeof(struct rk_emmcphy_softc)); EARLY_DRIVER_MODULE(rk_emmcphy, simplebus, rk_emmcphy_driver, 0, 0, BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm64/rockchip/rk3568_pcie.c b/sys/arm64/rockchip/rk3568_pcie.c index 9e3a1fa054cc73..996bfc6f163830 100644 --- a/sys/arm64/rockchip/rk3568_pcie.c +++ b/sys/arm64/rockchip/rk3568_pcie.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -55,7 +54,6 @@ #include #include -#include #include #include diff --git a/sys/arm64/rockchip/rk_gpio.c b/sys/arm64/rockchip/rk_gpio.c index a86392f1662406..f3a013126209ef 100644 --- a/sys/arm64/rockchip/rk_gpio.c +++ b/sys/arm64/rockchip/rk_gpio.c @@ -40,8 +40,8 @@ #include #include +#include #include -#include #include #include @@ -804,11 +804,8 @@ static device_method_t rk_gpio_methods[] = { DEVMETHOD_END }; -static driver_t rk_gpio_driver = { - "gpio", - rk_gpio_methods, - sizeof(struct rk_gpio_softc), -}; +PRIVATE_DEFINE_CLASSN(gpio, rk_gpio_driver, rk_gpio_methods, + sizeof(struct rk_gpio_softc)); /* * GPIO driver is always a child of rk_pinctrl driver and should be probed diff --git a/sys/arm64/rockchip/rk_i2s.c b/sys/arm64/rockchip/rk_i2s.c index 3d6aaf523c4a38..9bd904b7a69cc2 100644 --- a/sys/arm64/rockchip/rk_i2s.c +++ b/sys/arm64/rockchip/rk_i2s.c @@ -639,11 +639,8 @@ static device_method_t rk_i2s_methods[] = { DEVMETHOD_END }; -static driver_t rk_i2s_driver = { - "i2s", - rk_i2s_methods, - sizeof(struct rk_i2s_softc), -}; +PRIVATE_DEFINE_CLASSN(i2s, rk_i2s_driver, rk_i2s_methods, + sizeof(struct rk_i2s_softc)); DRIVER_MODULE(rk_i2s, simplebus, rk_i2s_driver, 0, 0); SIMPLEBUS_PNP_INFO(compat_data); diff --git a/sys/arm64/rockchip/rk_iodomain.c b/sys/arm64/rockchip/rk_iodomain.c index ed61b99481f2ff..9a87d30f1b7a16 100644 --- a/sys/arm64/rockchip/rk_iodomain.c +++ b/sys/arm64/rockchip/rk_iodomain.c @@ -291,11 +291,8 @@ static device_method_t rk_iodomain_methods[] = { DEVMETHOD_END }; -static driver_t rk_iodomain_driver = { - "rk_iodomain", - rk_iodomain_methods, - sizeof(struct rk_iodomain_softc), -}; +PRIVATE_DEFINE_CLASSN(rk_iodomain, rk_iodomain_driver, rk_iodomain_methods, + sizeof(struct rk_iodomain_softc)); EARLY_DRIVER_MODULE(rk_iodomain, simplebus, rk_iodomain_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST); diff --git a/sys/arm64/rockchip/rk_pcie.c b/sys/arm64/rockchip/rk_pcie.c index f22cfcf19defdf..5b31113ec3eefb 100644 --- a/sys/arm64/rockchip/rk_pcie.c +++ b/sys/arm64/rockchip/rk_pcie.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include diff --git a/sys/arm64/rockchip/rk_pinctrl.c b/sys/arm64/rockchip/rk_pinctrl.c index f38601742142a8..8201fba39e8557 100644 --- a/sys/arm64/rockchip/rk_pinctrl.c +++ b/sys/arm64/rockchip/rk_pinctrl.c @@ -38,8 +38,8 @@ #include #include +#include #include -#include #include diff --git a/sys/arm64/rockchip/rk_tsadc.c b/sys/arm64/rockchip/rk_tsadc.c index e6cbad36f697b3..2de5c49669dc13 100644 --- a/sys/arm64/rockchip/rk_tsadc.c +++ b/sys/arm64/rockchip/rk_tsadc.c @@ -875,7 +875,7 @@ static device_method_t rk_tsadc_methods[] = { DEVMETHOD_END }; -static DEFINE_CLASS_0(rk_tsadc, rk_tsadc_driver, rk_tsadc_methods, +PRIVATE_DEFINE_CLASSN(rk_tsadc, rk_tsadc_driver, rk_tsadc_methods, sizeof(struct tsadc_softc)); EARLY_DRIVER_MODULE(rk_tsadc, simplebus, rk_tsadc_driver, NULL, NULL, BUS_PASS_TIMER + BUS_PASS_ORDER_LAST); diff --git a/sys/arm64/rockchip/rk_typec_phy.c b/sys/arm64/rockchip/rk_typec_phy.c index 07b3ed9d93c87e..3ec4d749b37af9 100644 --- a/sys/arm64/rockchip/rk_typec_phy.c +++ b/sys/arm64/rockchip/rk_typec_phy.c @@ -459,11 +459,8 @@ static device_method_t rk_typec_phy_methods[] = { DEVMETHOD_END }; -static driver_t rk_typec_phy_driver = { - "rk_typec_phy", - rk_typec_phy_methods, - sizeof(struct rk_typec_phy_softc) -}; +PRIVATE_DEFINE_CLASSN(rk_typec_phy, rk_typec_phy_driver, rk_typec_phy_methods, + sizeof(struct rk_typec_phy_softc)); EARLY_DRIVER_MODULE(rk_typec_phy, simplebus, rk_typec_phy_driver, 0, 0, BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm64/rockchip/rk_usb2phy.c b/sys/arm64/rockchip/rk_usb2phy.c index 3f6c0b19f10a13..dce98816a98633 100644 --- a/sys/arm64/rockchip/rk_usb2phy.c +++ b/sys/arm64/rockchip/rk_usb2phy.c @@ -419,11 +419,8 @@ static device_method_t rk_usb2phy_methods[] = { DEVMETHOD_END }; -static driver_t rk_usb2phy_driver = { - "rk_usb2phy", - rk_usb2phy_methods, - sizeof(struct rk_usb2phy_softc) -}; +PRIVATE_DEFINE_CLASSN(rk_usb2phy, rk_usb2phy_driver, rk_usb2phy_methods, + sizeof(struct rk_usb2phy_softc)); EARLY_DRIVER_MODULE(rk_usb2phy, simplebus, rk_usb2phy_driver, 0, 0, BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/arm64/rockchip/rk_usbphy.c b/sys/arm64/rockchip/rk_usbphy.c index 5db6cbb827dd75..65f8ed20f0e926 100644 --- a/sys/arm64/rockchip/rk_usbphy.c +++ b/sys/arm64/rockchip/rk_usbphy.c @@ -292,10 +292,11 @@ static device_method_t rk_usbphy_methods[] = { DEVMETHOD(device_probe, rk_usbphy_probe), DEVMETHOD(device_attach, rk_usbphy_attach), DEVMETHOD(device_detach, rk_usbphy_detach), + DEVMETHOD_END }; -static DEFINE_CLASS_0(rk_usbphy, rk_usbphy_driver, rk_usbphy_methods, +PRIVATE_DEFINE_CLASSN(rk_usbphy, rk_usbphy_driver, rk_usbphy_methods, sizeof(struct rk_usbphy_softc)); EARLY_DRIVER_MODULE(rk_usbphy, simplebus, rk_usbphy_driver, NULL, NULL, BUS_PASS_TIMER + BUS_PASS_ORDER_LAST); diff --git a/sys/arm64/vmm/io/vgic_v3.c b/sys/arm64/vmm/io/vgic_v3.c index 67afb3374815ca..b2ee35098f725e 100644 --- a/sys/arm64/vmm/io/vgic_v3.c +++ b/sys/arm64/vmm/io/vgic_v3.c @@ -52,11 +52,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include #include diff --git a/sys/cam/mmc/mmc_xpt.c b/sys/cam/mmc/mmc_xpt.c index 0947e0addf59d7..c55cda057c87be 100644 --- a/sys/cam/mmc/mmc_xpt.c +++ b/sys/cam/mmc/mmc_xpt.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -58,6 +57,7 @@ #include #include +#include #include /* for xpt_print below */ #include /* for PRIu64 */ diff --git a/sys/compat/linuxkpi/common/include/linux/hardirq.h b/sys/compat/linuxkpi/common/include/linux/hardirq.h index f79451dd0d35a6..dfc960f4ea2e82 100644 --- a/sys/compat/linuxkpi/common/include/linux/hardirq.h +++ b/sys/compat/linuxkpi/common/include/linux/hardirq.h @@ -34,7 +34,8 @@ #include #include -#include + +#include #define synchronize_irq(irq) _intr_drain((irq)) diff --git a/sys/compat/linuxkpi/common/include/linux/interrupt.h b/sys/compat/linuxkpi/common/include/linux/interrupt.h index dfd9816da8bee7..baeeccd6ed10ac 100644 --- a/sys/compat/linuxkpi/common/include/linux/interrupt.h +++ b/sys/compat/linuxkpi/common/include/linux/interrupt.h @@ -36,7 +36,8 @@ #include #include -#include + +#include typedef irqreturn_t (*irq_handler_t)(int, void *); diff --git a/sys/compat/linuxkpi/common/src/linux_kthread.c b/sys/compat/linuxkpi/common/src/linux_kthread.c index 2fba700fa28366..648861e283d7b4 100644 --- a/sys/compat/linuxkpi/common/src/linux_kthread.c +++ b/sys/compat/linuxkpi/common/src/linux_kthread.c @@ -31,9 +31,10 @@ #include #include -#include #include +#include + enum { KTHREAD_SHOULD_STOP_MASK = (1 << 0), KTHREAD_SHOULD_PARK_MASK = (1 << 1), diff --git a/sys/conf/files b/sys/conf/files index a02174f3d9548b..92c39b516d2188 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -3777,6 +3777,7 @@ kern/imgact_elf32.c optional compat_freebsd32 kern/imgact_shell.c standard kern/init_main.c standard kern/init_sysent.c standard +kern/intr_event_if.m standard kern/ksched.c optional _kposix_priority_scheduling kern/kern_acct.c standard kern/kern_alq.c optional alq diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index ed251b7ae0d72c..854dd449e475ee 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -620,7 +620,6 @@ arm/mv/a37x0_spi.c optional a37x0_spi spibus fdt arm/mv/clk/a37x0_tbg.c optional a37x0_tbg clk fdt syscon arm/mv/clk/a37x0_xtal.c optional a37x0_xtal clk fdt syscon arm/mv/armada38x/armada38x_rtc.c optional mv_rtc fdt -arm/mv/gpio.c optional mv_gpio fdt arm/mv/mvebu_gpio.c optional mv_gpio fdt arm/mv/mvebu_pinctrl.c optional mvebu_pinctrl fdt arm/mv/mv_ap806_clock.c optional soc_marvell_8k fdt diff --git a/sys/conf/files.x86 b/sys/conf/files.x86 index df206b314b38c5..426db8f76148b2 100644 --- a/sys/conf/files.x86 +++ b/sys/conf/files.x86 @@ -382,6 +382,7 @@ x86/x86/mca.c standard x86/x86/x86_mem.c optional mem x86/x86/mp_x86.c optional smp x86/x86/nexus.c standard +x86/x86/pic_if.m standard x86/x86/pvclock.c optional kvm_clock | xenhvm x86/x86/sdt_machdep.c optional kdtrace_hooks x86/x86/stack_machdep.c optional ddb | stack diff --git a/sys/contrib/ncsw/user/env/xx.c b/sys/contrib/ncsw/user/env/xx.c index ecfe052e59664e..68445c8222c8fc 100644 --- a/sys/contrib/ncsw/user/env/xx.c +++ b/sys/contrib/ncsw/user/env/xx.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include diff --git a/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c b/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c index 190b6d16781e29..bbb4e021de7cf0 100644 --- a/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c +++ b/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include diff --git a/sys/dev/acpica/acpi_apei.c b/sys/dev/acpica/acpi_apei.c index 9cfd46c974300c..27a8dcdd65c15a 100644 --- a/sys/dev/acpica/acpi_apei.c +++ b/sys/dev/acpica/acpi_apei.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -42,6 +41,8 @@ #include #include +#include + #include #include #include diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index 668d0b51a1f355..0811e158dee536 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -34,9 +34,6 @@ #include "acpi_if.h" #include "bus_if.h" #include -#ifdef INTRNG -#include -#endif #include #include #include @@ -45,6 +42,9 @@ #include #include +#ifdef INTRNG +#include +#endif #include struct apm_clone_data; diff --git a/sys/dev/amdgpio/amdgpio.c b/sys/dev/amdgpio/amdgpio.c index f39006d9580508..66211d2437535f 100644 --- a/sys/dev/amdgpio/amdgpio.c +++ b/sys/dev/amdgpio/amdgpio.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -43,6 +42,7 @@ #include #include +#include #include #include diff --git a/sys/dev/cesa/cesa.c b/sys/dev/cesa/cesa.c index 2dcdb0258844d7..a8d05c640e6812 100644 --- a/sys/dev/cesa/cesa.c +++ b/sys/dev/cesa/cesa.c @@ -52,7 +52,7 @@ #include #include -#include +#include #include #include diff --git a/sys/dev/clk/starfive/jh7110_clk.c b/sys/dev/clk/starfive/jh7110_clk.c index adb5707b3f6407..4070114751b96b 100644 --- a/sys/dev/clk/starfive/jh7110_clk.c +++ b/sys/dev/clk/starfive/jh7110_clk.c @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include diff --git a/sys/dev/fdt/fdt_pinctrl_if.m b/sys/dev/fdt/fdt_pinctrl_if.m index a20e4122997718..99e866554583b3 100644 --- a/sys/dev/fdt/fdt_pinctrl_if.m +++ b/sys/dev/fdt/fdt_pinctrl_if.m @@ -25,16 +25,18 @@ # # -#include -#include -#include - # # This is the interface that fdt_pinctrl drivers provide to other drivers. # INTERFACE fdt_pinctrl; +HEADER { + #include + #include + #include +}; + CODE { static int fdt_pinctrl_default_is_gpio(device_t pinctrl, device_t gpio, bool *is_gpio) diff --git a/sys/dev/gpio/dwgpio/dwgpio.c b/sys/dev/gpio/dwgpio/dwgpio.c index 5acb99ca591e36..411cf62e865560 100644 --- a/sys/dev/gpio/dwgpio/dwgpio.c +++ b/sys/dev/gpio/dwgpio/dwgpio.c @@ -56,7 +56,7 @@ #include #include -#include +#include #include "gpio_if.h" #include "dwgpio_if.h" diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c index e053adacf4571a..b672a78100b332 100644 --- a/sys/dev/gpio/gpiobus.c +++ b/sys/dev/gpio/gpiobus.c @@ -30,9 +30,6 @@ #include #include #include -#ifdef INTRNG -#include -#endif #include #include #include diff --git a/sys/dev/gpio/gpiobusvar.h b/sys/dev/gpio/gpiobusvar.h index 74783e112f891e..b07b7f98922fde 100644 --- a/sys/dev/gpio/gpiobusvar.h +++ b/sys/dev/gpio/gpiobusvar.h @@ -36,12 +36,13 @@ #include #include -#ifdef FDT -#include +#ifdef INTRNG +/* touched by LINT-ACPI */ +#include #endif -#ifdef INTRNG -#include +#ifdef FDT +#include #endif #include "gpio_if.h" diff --git a/sys/dev/gpio/pl061.c b/sys/dev/gpio/pl061.c index cc39790322b6b1..af11fc7fd488cf 100644 --- a/sys/dev/gpio/pl061.c +++ b/sys/dev/gpio/pl061.c @@ -36,10 +36,9 @@ #include #include #include -#include #include -#include +#include #include #include @@ -547,6 +546,11 @@ static device_method_t pl061_methods[] = { DEVMETHOD(device_attach, pl061_attach), DEVMETHOD(device_detach, pl061_detach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, pl061_pic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, pl061_pic_post_ithread), + DEVMETHOD(intr_event_post_filter, pl061_pic_post_filter), + /* Bus interface */ DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), @@ -569,11 +573,9 @@ static device_method_t pl061_methods[] = { DEVMETHOD(pic_map_intr, pl061_pic_map_intr), DEVMETHOD(pic_setup_intr, pl061_pic_setup_intr), DEVMETHOD(pic_teardown_intr, pl061_pic_teardown_intr), - DEVMETHOD(pic_post_filter, pl061_pic_post_filter), - DEVMETHOD(pic_post_ithread, pl061_pic_post_ithread), - DEVMETHOD(pic_pre_ithread, pl061_pic_pre_ithread), DEVMETHOD_END }; -DEFINE_CLASS_0(gpio, pl061_driver, pl061_methods, sizeof(struct pl061_softc)); +DEFINE_CLASSN(gpio, pl061_driver, pl061_methods, sizeof(struct pl061_softc), + pic_base_class); diff --git a/sys/dev/gpio/pl061_acpi.c b/sys/dev/gpio/pl061_acpi.c index f5885025083e2e..88e38d43c43a73 100644 --- a/sys/dev/gpio/pl061_acpi.c +++ b/sys/dev/gpio/pl061_acpi.c @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c index 83784b93718ed0..27453e43007ee9 100644 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/dev/hwpmc/hwpmc_uncore.c b/sys/dev/hwpmc/hwpmc_uncore.c index 6a7ffac370b740..604d8946ac9304 100644 --- a/sys/dev/hwpmc/hwpmc_uncore.c +++ b/sys/dev/hwpmc/hwpmc_uncore.c @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/dev/hwpmc/hwpmc_x86.c b/sys/dev/hwpmc/hwpmc_x86.c index 2903c25ef5c964..001957cc5d0734 100644 --- a/sys/dev/hwpmc/hwpmc_x86.c +++ b/sys/dev/hwpmc/hwpmc_x86.c @@ -40,7 +40,7 @@ #include #include -#include /* For x86/apicvar.h */ +#include /* For x86/apicvar.h */ #include #include #include diff --git a/sys/dev/hyperv/pcib/vmbus_pcib.c b/sys/dev/hyperv/pcib/vmbus_pcib.c index 7b755e5f9c639d..2449a22dfd8b39 100644 --- a/sys/dev/hyperv/pcib/vmbus_pcib.c +++ b/sys/dev/hyperv/pcib/vmbus_pcib.c @@ -49,7 +49,7 @@ #include #if defined(__aarch64__) -#include +#include #endif #include #include @@ -64,7 +64,7 @@ #include #include "pcib_if.h" #if defined(__i386__) || defined(__amd64__) -#include +#include #include #include #endif diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c index 1c620a1f5d8474..3abe896c706dbd 100644 --- a/sys/dev/hyperv/vmbus/vmbus.c +++ b/sys/dev/hyperv/vmbus/vmbus.c @@ -57,7 +57,7 @@ #else #include #include -#include +#include #include #endif #include diff --git a/sys/dev/hyperv/vmbus/x86/vmbus_x86.c b/sys/dev/hyperv/vmbus/x86/vmbus_x86.c index 0ed3b1b5f9d97c..a94205efde3afa 100644 --- a/sys/dev/hyperv/vmbus/x86/vmbus_x86.c +++ b/sys/dev/hyperv/vmbus/x86/vmbus_x86.c @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/dev/iicbus/controller/vybrid/vf_i2c.c b/sys/dev/iicbus/controller/vybrid/vf_i2c.c index 4735a95cf5cd2f..048cc4b81d3ddd 100644 --- a/sys/dev/iicbus/controller/vybrid/vf_i2c.c +++ b/sys/dev/iicbus/controller/vybrid/vf_i2c.c @@ -55,7 +55,7 @@ #include #include -#include +#include #include diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c index 6856b0551dde74..5628943293bd18 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -57,10 +56,12 @@ #include #include #include + #include #include -#include +#include #include +#include #include /* diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c index d97bdee47b2800..711005a50ed1ef 100644 --- a/sys/dev/iommu/iommu_gas.c +++ b/sys/dev/iommu/iommu_gas.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -63,6 +62,7 @@ #include #include #include +#include #include #include diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c index 9e41464a7a2aa8..d8a85f5e6004fd 100644 --- a/sys/dev/mfi/mfi.c +++ b/sys/dev/mfi/mfi.c @@ -75,12 +75,12 @@ #include #include +#include #include #include #include #include -#include #include static int mfi_alloc_commands(struct mfi_softc *); diff --git a/sys/dev/mlx5/mlx5_en/en_rl.h b/sys/dev/mlx5/mlx5_en/en_rl.h index 09819b6ef56edf..35c03f8f766b0a 100644 --- a/sys/dev/mlx5/mlx5_en/en_rl.h +++ b/sys/dev/mlx5/mlx5_en/en_rl.h @@ -32,11 +32,12 @@ #include #include #include -#include #include #include +#include + #define MLX5E_RL_MAX_WORKERS 128 /* limited by Toeplitz hash */ #define MLX5E_RL_MAX_TX_RATES (64 * 1024) /* software limit */ #define MLX5E_RL_DEF_SQ_PER_WORKER (12 * 1024) /* software limit */ diff --git a/sys/dev/mmc/host/dwmmc.c b/sys/dev/mmc/host/dwmmc.c index 51709bcbb7e967..20940554cfb538 100644 --- a/sys/dev/mmc/host/dwmmc.c +++ b/sys/dev/mmc/host/dwmmc.c @@ -58,7 +58,7 @@ #include #include -#include +#include #include diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c index d4852917085d74..5c3895b8b48c47 100644 --- a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c +++ b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -56,7 +55,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_plx.c b/sys/dev/ntb/ntb_hw/ntb_hw_plx.c index 9066601160679d..3a33251d509d96 100644 --- a/sys/dev/ntb/ntb_hw/ntb_hw_plx.c +++ b/sys/dev/ntb/ntb_hw/ntb_hw_plx.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -44,7 +43,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/dev/ofw/ofw_bus_subr.h b/sys/dev/ofw/ofw_bus_subr.h index 1a33d7655f77fc..0be71fd404e453 100644 --- a/sys/dev/ofw/ofw_bus_subr.h +++ b/sys/dev/ofw/ofw_bus_subr.h @@ -33,7 +33,7 @@ #include #ifdef INTRNG -#include +#include #endif #include diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 0b02d873c5a190..bbfec01db8538b 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -61,7 +61,7 @@ #include #if defined(__i386__) || defined(__amd64__) || defined(__powerpc__) -#include +#include #endif #include diff --git a/sys/dev/pci/pci_dw.c b/sys/dev/pci/pci_dw.c index cf67d1ab06cf3a..10f73e0f3970bd 100644 --- a/sys/dev/pci/pci_dw.c +++ b/sys/dev/pci/pci_dw.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include diff --git a/sys/dev/pci/pci_dw_mv.c b/sys/dev/pci/pci_dw_mv.c index d7eada39a6d6e3..9efa8292aa3331 100644 --- a/sys/dev/pci/pci_dw_mv.c +++ b/sys/dev/pci/pci_dw_mv.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c index 884ab25548ce40..c0d828cf33eb1b 100644 --- a/sys/dev/pci/pci_host_generic.c +++ b/sys/dev/pci/pci_host_generic.c @@ -48,7 +48,7 @@ #include #include -#include +#include #include "pcib_if.h" diff --git a/sys/dev/pci/pci_host_generic_acpi.c b/sys/dev/pci/pci_host_generic_acpi.c index f12632e7205b6f..e480cfa33b5943 100644 --- a/sys/dev/pci/pci_host_generic_acpi.c +++ b/sys/dev/pci/pci_host_generic_acpi.c @@ -59,7 +59,7 @@ #include #include -#include +#include #include "pcib_if.h" #include "acpi_bus_if.h" diff --git a/sys/dev/pci/pci_host_generic_fdt.c b/sys/dev/pci/pci_host_generic_fdt.c index 73c6201dc14b20..cdf28fd31d0ae6 100644 --- a/sys/dev/pci/pci_host_generic_fdt.c +++ b/sys/dev/pci/pci_host_generic_fdt.c @@ -44,9 +44,7 @@ #include #include -#if defined(INTRNG) -#include -#endif +#include #include #include @@ -59,8 +57,6 @@ #include #include -#include - #include "pcib_if.h" #define SPACE_CODE_SHIFT 24 diff --git a/sys/dev/ppc/ppc.c b/sys/dev/ppc/ppc.c index 9870379e2ebaa1..08df8d3412d308 100644 --- a/sys/dev/ppc/ppc.c +++ b/sys/dev/ppc/ppc.c @@ -35,13 +35,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include diff --git a/sys/dev/proto/proto_core.c b/sys/dev/proto/proto_core.c index 2a7fe3bf9f3380..6cd49b4fe4fdd4 100644 --- a/sys/dev/proto/proto_core.c +++ b/sys/dev/proto/proto_core.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -41,6 +40,8 @@ #include #include #include + +#include #include #include diff --git a/sys/dev/qat/qat_common/adf_vf_isr.c b/sys/dev/qat/qat_common/adf_vf_isr.c index a34e23b8fb4b89..bd5f0686e4382c 100644 --- a/sys/dev/qat/qat_common/adf_vf_isr.c +++ b/sys/dev/qat/qat_common/adf_vf_isr.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/dev/sdhci/fsl_sdhci.c b/sys/dev/sdhci/fsl_sdhci.c index 2f3f89f3d925af..3cd7d1f23f3b37 100644 --- a/sys/dev/sdhci/fsl_sdhci.c +++ b/sys/dev/sdhci/fsl_sdhci.c @@ -53,7 +53,7 @@ #include #include #ifdef __arm__ -#include +#include #include #endif diff --git a/sys/dev/sound/macio/davbus.c b/sys/dev/sound/macio/davbus.c index 9dc3676a37a0e5..6ea73365d86659 100644 --- a/sys/dev/sound/macio/davbus.c +++ b/sys/dev/sound/macio/davbus.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include diff --git a/sys/dev/sound/macio/i2s.c b/sys/dev/sound/macio/i2s.c index 647d66c27bba64..28c936d4ec864c 100644 --- a/sys/dev/sound/macio/i2s.c +++ b/sys/dev/sound/macio/i2s.c @@ -66,7 +66,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/dev/sound/macio/onyx.c b/sys/dev/sound/macio/onyx.c index d13f3da92db61f..817063b4d2348e 100644 --- a/sys/dev/sound/macio/onyx.c +++ b/sys/dev/sound/macio/onyx.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/dev/sound/macio/snapper.c b/sys/dev/sound/macio/snapper.c index 0b31bded928fa4..c7da48c2c70f8b 100644 --- a/sys/dev/sound/macio/snapper.c +++ b/sys/dev/sound/macio/snapper.c @@ -66,7 +66,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/dev/sound/macio/tumbler.c b/sys/dev/sound/macio/tumbler.c index 505fb7ba15b138..7c1246d001681f 100644 --- a/sys/dev/sound/macio/tumbler.c +++ b/sys/dev/sound/macio/tumbler.c @@ -66,7 +66,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/dev/tpm/tpm_isa.c b/sys/dev/tpm/tpm_isa.c index 311246c16b4974..2ec1633a5d16f6 100644 --- a/sys/dev/tpm/tpm_isa.c +++ b/sys/dev/tpm/tpm_isa.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include diff --git a/sys/dev/uart/uart_core.c b/sys/dev/uart/uart_core.c index e608d6c95eadc7..f77ff028fd51a9 100644 --- a/sys/dev/uart/uart_core.c +++ b/sys/dev/uart/uart_core.c @@ -32,15 +32,16 @@ #include #include #include -#include #include #include #include #include #include +#include #include + #include -#include +#include #include #include diff --git a/sys/dev/uart/uart_tty.c b/sys/dev/uart/uart_tty.c index faae077916f382..7c666bff383649 100644 --- a/sys/dev/uart/uart_tty.c +++ b/sys/dev/uart/uart_tty.c @@ -32,13 +32,14 @@ #include #include #include -#include #include #include #include #include #include #include + +#include #include #include diff --git a/sys/dev/usb/usb_process.h b/sys/dev/usb/usb_process.h index 745d214d210697..44f7dd32332672 100644 --- a/sys/dev/usb/usb_process.h +++ b/sys/dev/usb/usb_process.h @@ -29,9 +29,10 @@ #define _USB_PROCESS_H_ #ifndef USB_GLOBAL_INCLUDE_FILE -#include #include #include + +#include #endif /* defines */ diff --git a/sys/dev/vmd/vmd.c b/sys/dev/vmd/vmd.c index 0595a6c5be1603..2ae8dcbdde9958 100644 --- a/sys/dev/vmd/vmd.c +++ b/sys/dev/vmd/vmd.c @@ -39,8 +39,8 @@ #include #include +#include #include -#include #include #include #include diff --git a/sys/dev/wdatwd/wdatwd.c b/sys/dev/wdatwd/wdatwd.c index c67e3728130796..32897d20c05ac1 100644 --- a/sys/dev/wdatwd/wdatwd.c +++ b/sys/dev/wdatwd/wdatwd.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -41,9 +40,12 @@ #include #include #include + #include #include +#include + #include #include #include diff --git a/sys/dev/xen/bus/xen_intr.c b/sys/dev/xen/bus/xen_intr.c index bfe080b16f0307..ada8dc2f38ef16 100644 --- a/sys/dev/xen/bus/xen_intr.c +++ b/sys/dev/xen/bus/xen_intr.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -49,6 +48,7 @@ #include #include +#include #include #include diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c index 123df49928949f..ba8f5ffdb136d3 100644 --- a/sys/dev/xen/control/control.c +++ b/sys/dev/xen/control/control.c @@ -96,7 +96,7 @@ #include #if defined(__amd64__) || defined(__i386__) -#include +#include #include #endif diff --git a/sys/dev/xen/pcifront/pcifront.c b/sys/dev/xen/pcifront/pcifront.c index 76339cd3d361cc..764ce7f46e695f 100644 --- a/sys/dev/xen/pcifront/pcifront.c +++ b/sys/dev/xen/pcifront/pcifront.c @@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include diff --git a/sys/dev/xilinx/axi_quad_spi.c b/sys/dev/xilinx/axi_quad_spi.c index eba3207316596f..4b0ec8883cf323 100644 --- a/sys/dev/xilinx/axi_quad_spi.c +++ b/sys/dev/xilinx/axi_quad_spi.c @@ -59,7 +59,7 @@ #include #include -#include +#include #define READ4(_sc, _reg) \ bus_space_read_4(_sc->bst, _sc->bsh, _reg) diff --git a/sys/dev/xilinx/xlnx_pcib.c b/sys/dev/xilinx/xlnx_pcib.c index d549ec445ea942..9c43e83ddd0402 100644 --- a/sys/dev/xilinx/xlnx_pcib.c +++ b/sys/dev/xilinx/xlnx_pcib.c @@ -46,8 +46,8 @@ #include #include -#include #include +#include #include #include @@ -761,6 +761,11 @@ static device_method_t xlnx_pcib_fdt_methods[] = { DEVMETHOD(pcib_release_msi, xlnx_pcib_release_msi), DEVMETHOD(pcib_map_msi, xlnx_pcib_map_msi), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, xlnx_pcib_msi_pre_ithread), + DEVMETHOD(intr_event_post_ithread, xlnx_pcib_msi_post_ithread), + DEVMETHOD(intr_event_post_filter, xlnx_pcib_msi_post_filter), + /* MSI interface */ DEVMETHOD(msi_alloc_msi, xlnx_pcib_msi_alloc_msi), DEVMETHOD(msi_release_msi, xlnx_pcib_msi_release_msi), @@ -771,16 +776,13 @@ static device_method_t xlnx_pcib_fdt_methods[] = { DEVMETHOD(pic_enable_intr, xlnx_pcib_msi_enable_intr), DEVMETHOD(pic_setup_intr, xlnx_pcib_msi_setup_intr), DEVMETHOD(pic_teardown_intr, xlnx_pcib_msi_teardown_intr), - DEVMETHOD(pic_post_filter, xlnx_pcib_msi_post_filter), - DEVMETHOD(pic_post_ithread, xlnx_pcib_msi_post_ithread), - DEVMETHOD(pic_pre_ithread, xlnx_pcib_msi_pre_ithread), /* End */ DEVMETHOD_END }; -DEFINE_CLASS_1(pcib, xlnx_pcib_fdt_driver, xlnx_pcib_fdt_methods, - sizeof(struct xlnx_pcib_softc), generic_pcie_fdt_driver); +DEFINE_CLASSN(pcib, xlnx_pcib_fdt_driver, xlnx_pcib_fdt_methods, + sizeof(struct xlnx_pcib_softc), pic_base_class, generic_pcie_fdt_driver); DRIVER_MODULE(xlnx_pcib, simplebus, xlnx_pcib_fdt_driver, 0, 0); DRIVER_MODULE(xlnx_pcib, ofwbus, xlnx_pcib_fdt_driver, 0, 0); diff --git a/sys/i386/acpica/acpi_wakeup.c b/sys/i386/acpica/acpi_wakeup.c index 2d60d5e037a07e..47ca59bfcd29c5 100644 --- a/sys/i386/acpica/acpi_wakeup.c +++ b/sys/i386/acpica/acpi_wakeup.c @@ -47,7 +47,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 008d67017f687f..c8d33f6caef9fa 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -118,7 +118,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/i386/i386/npx.c b/sys/i386/i386/npx.c index a81413c291b346..99882a5db14246 100644 --- a/sys/i386/i386/npx.c +++ b/sys/i386/i386/npx.c @@ -65,7 +65,7 @@ #include #include -#include +#include #ifdef DEV_ISA #include diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 57ba48d399c361..1c90578d4d73d6 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -142,7 +142,7 @@ #ifdef DEV_APIC #include -#include +#include #include #endif #include diff --git a/sys/i386/i386/pmap_base.c b/sys/i386/i386/pmap_base.c index f6252a7ca5dac6..f7931dae9b9cb2 100644 --- a/sys/i386/i386/pmap_base.c +++ b/sys/i386/i386/pmap_base.c @@ -98,7 +98,7 @@ #include #ifdef DEV_APIC #include -#include +#include #include #endif #include diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index a8b7df42a2837f..0db0492c924a15 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -83,7 +83,7 @@ PMC_SOFT_DEFINE( , , page_fault, write); #include #include -#include +#include #include #include #include diff --git a/sys/i386/include/interrupt.h b/sys/i386/include/interrupt.h new file mode 100644 index 00000000000000..dd637fb908a7a2 --- /dev/null +++ b/sys/i386/include/interrupt.h @@ -0,0 +1,10 @@ +/*- + * This file is in the public domain. + */ + +#ifndef __MACHINE_INTERRUPT_H__ +#define __MACHINE_INTERRUPT_H__ + +#include + +#endif /* !__MACHINE_INTERRUPT_H__ */ diff --git a/sys/i386/include/intr_machdep.h b/sys/i386/include/intr_machdep.h deleted file mode 100644 index dc9ab793cee560..00000000000000 --- a/sys/i386/include/intr_machdep.h +++ /dev/null @@ -1,5 +0,0 @@ -/*- - * This file is in the public domain. - */ - -#include diff --git a/sys/i386/include/smp.h b/sys/i386/include/smp.h index 7d107da2d93efa..db08124c0c6796 100644 --- a/sys/i386/include/smp.h +++ b/sys/i386/include/smp.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include diff --git a/sys/kern/intr_event_if.m b/sys/kern/intr_event_if.m new file mode 100644 index 00000000000000..914b632198b87f --- /dev/null +++ b/sys/kern/intr_event_if.m @@ -0,0 +1,51 @@ +#- +# Copyright © 2024 Elliott Mitchell +# +# 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. +# + +INTERFACE intr_event; + +HEADER { + #include +} + +METHOD void pre_ithread { + device_t pic; + interrupt_t *intr; +}; + +METHOD void post_ithread { + device_t pic; + interrupt_t *intr; +}; + +METHOD void post_filter { + device_t pic; + interrupt_t *intr; +}; + +METHOD int assign_cpu { + device_t pic; + interrupt_t *intr; + u_int cpu; +}; diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index b11c0d235139e4..2a92d3610f7381 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -66,7 +66,6 @@ #include #include #include -#include #include #include @@ -78,6 +77,8 @@ PMC_SOFT_DEFINE_EX( , , clock, prof, \ cpu_startprofclock, cpu_stopprofclock); #endif +#include + #ifdef DEVICE_POLLING extern void hardclock_device_poll(void); #endif /* DEVICE_POLLING */ diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index 5d9e2f2f326be5..630745e94775cc 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -59,7 +59,6 @@ #include #include #include -#include #include #include @@ -73,6 +72,8 @@ #include #include +#include + #ifdef DDB #include #endif /* DDB */ diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index ad0cc135167e70..007f9893de3d1f 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -58,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -66,6 +66,8 @@ #include #endif +#include "intr_event_if.h" + /* * Describe an interrupt thread. There is one of these per interrupt event. */ @@ -275,43 +277,194 @@ intr_event_update(struct intr_event *ie) CTR2(KTR_INTR, "%s: updated %s", __func__, ie->ie_fullname); } -int -intr_event_create(struct intr_event **event, void *source, int flags, u_int irq, - void (*pre_ithread)(void *), void (*post_ithread)(void *), - void (*post_filter)(void *), int (*assign_cpu)(void *, int), - const char *fmt, ...) +static int +#ifndef INTR_EVENT_SOURCE_POINTERS +intr_event_initv(struct intr_event *ie, device_t pic, u_int irq, int flags, + const char *fmt, __va_list ap) +#else +intr_event_initv(struct intr_event *ie, device_t pic, interrupt_t *source, + u_int irq, int flags, const char *fmt, __va_list ap) +#endif { - struct intr_event *ie; - va_list ap; /* The only valid flag during creation is IE_SOFT. */ if ((flags & ~IE_SOFT) != 0) return (EINVAL); - ie = malloc(sizeof(struct intr_event), M_ITHREAD, M_WAITOK | M_ZERO); + ie->ie_pic = pic; +#ifdef INTR_EVENT_SOURCE_POINTERS ie->ie_source = source; - ie->ie_pre_ithread = pre_ithread; - ie->ie_post_ithread = post_ithread; - ie->ie_post_filter = post_filter; - ie->ie_assign_cpu = assign_cpu; +#endif ie->ie_flags = flags; ie->ie_irq = irq; ie->ie_cpu = NOCPU; CK_SLIST_INIT(&ie->ie_handlers); mtx_init(&ie->ie_lock, "intr event", NULL, MTX_DEF); - va_start(ap, fmt); vsnprintf(ie->ie_name, sizeof(ie->ie_name), fmt, ap); - va_end(ap); strlcpy(ie->ie_fullname, ie->ie_name, sizeof(ie->ie_fullname)); mtx_lock(&event_lock); TAILQ_INSERT_TAIL(&event_list, ie, ie_list); mtx_unlock(&event_lock); - if (event != NULL) - *event = ie; CTR2(KTR_INTR, "%s: created %s", __func__, ie->ie_name); return (0); } +int +#ifndef INTR_EVENT_SOURCE_POINTERS +intr_event_init(struct intr_event *ie, device_t pic, u_int irq, int flags, + const char *fmt, ...) +#else +intr_event_init(struct intr_event *ie, device_t pic, interrupt_t *source, + u_int irq, int flags, const char *fmt, ...) +#endif +{ + va_list ap; + int res; + + va_start(ap, fmt); +#ifndef INTR_EVENT_SOURCE_POINTERS + res = intr_event_initv(ie, pic, irq, flags, fmt, ap); +#else + res = intr_event_initv(ie, pic, source, irq, flags, fmt, ap); +#endif + va_end(ap); + + return (res); +} + +#ifdef INTR_EVENT_SOURCE_POINTERS +int +intr_event_create_device(struct intr_event **event, device_t pic, + interrupt_t *source, u_int irq, int flags, const char *fmt, ...) +{ + struct intr_event *ie; + va_list ap; + int res; + + ie = malloc(sizeof(struct intr_event), M_ITHREAD, M_WAITOK | M_ZERO); + va_start(ap, fmt); + res = intr_event_initv(ie, pic, source, irq, flags, fmt, ap); + va_end(ap); + + if (res != 0) { + free(ie, M_ITHREAD); + return (res); + } + + if (event != NULL) + *event = ie; + return (res); +} +#endif + +struct intr_event_compat { + struct intr_event ie; + void (*ie_pre_ithread)(void *); + void (*ie_post_ithread)(void *); + void (*ie_post_filter)(void *); + int (*ie_assign_cpu)(void *, int); + void *source; +}; + +static void +event_compat_pre_ithread(device_t pic, interrupt_t *intr) +{ + struct intr_event_compat *compat = (struct intr_event_compat *)intr; + void (*func)(void *) = compat->ie_pre_ithread; + + if (func != NULL) + func(compat->source); +} +static void +event_compat_post_ithread(device_t pic, interrupt_t *intr) +{ + struct intr_event_compat *compat = (struct intr_event_compat *)intr; + void (*func)(void *) = compat->ie_post_ithread; + + if (func != NULL) + func(compat->source); +} +static void +event_compat_post_filter(device_t pic, interrupt_t *intr) +{ + struct intr_event_compat *compat = (struct intr_event_compat *)intr; + void (*func)(void *) = compat->ie_post_filter; + + if (func != NULL) + func(compat->source); +} +static int +event_compat_assign_cpu(device_t pic, interrupt_t *intr, u_int cpu) +{ + struct intr_event_compat *compat = (struct intr_event_compat *)intr; + int (*func)(void *, int) = compat->ie_assign_cpu; + + return (func != NULL ? func(compat->source, cpu) : EOPNOTSUPP); +} + +static device_method_t event_compat_funcs[] = { + DEVMETHOD(intr_event_pre_ithread, event_compat_pre_ithread), + DEVMETHOD(intr_event_post_ithread, event_compat_post_ithread), + DEVMETHOD(intr_event_post_filter, event_compat_post_filter), + DEVMETHOD(intr_event_assign_cpu, event_compat_assign_cpu), + DEVMETHOD_END +}; + +DEFINE_CLASS(event_compat, event_compat_funcs, 0); + +int +intr_event_create(struct intr_event **event, void *source, int flags, u_int irq, + void (*pre_ithread)(void *), void (*post_ithread)(void *), + void (*post_filter)(void *), int (*assign_cpu)(void *, int), + const char *fmt, ...) +{ + static device_t handler = NULL; + + struct intr_event *ie; + struct intr_event_compat *compat; + va_list ap; + int res; + + if (handler == NULL) { + device_t root = device_lookup_by_name("root0"); + handler = bus_generic_add_child(root, BUS_PASS_ORDER_FIRST, + "event-compat", 0); + device_set_driver(handler, &event_compat_class); + } + + compat = malloc(sizeof(struct intr_event_compat), M_ITHREAD, M_WAITOK | M_ZERO); + ie = &compat->ie; + compat->ie_pre_ithread = pre_ithread; + compat->ie_post_ithread = post_ithread; + compat->ie_post_filter = post_filter; + compat->ie_assign_cpu = assign_cpu; + compat->source = source; + + va_start(ap, fmt); +#ifndef INTR_EVENT_SOURCE_POINTERS + res = intr_event_initv(ie, handler, irq, flags, fmt, ap); +#else + res = intr_event_initv(ie, handler, (interrupt_t *)compat, irq, flags, + fmt, ap); +#endif + va_end(ap); + + if (res != 0) { + free(ie, M_ITHREAD); + return (res); + } + + if (event != NULL) + *event = ie; + return (res); +} + +#ifndef INTR_EVENT_SOURCE_POINTERS +#define IE_SOURCE(ie) ((interrupt_t *)(ie)) +#else +#define IE_SOURCE(ie) ((ie)->ie_source) +#endif + /* * Bind an interrupt event to the specified CPU. Note that not all * platforms support binding an interrupt to a CPU. For those @@ -328,9 +481,6 @@ _intr_event_bind(struct intr_event *ie, int cpu, bool bindirq, bool bindithread) if (cpu != NOCPU && CPU_ABSENT(cpu)) return (EINVAL); - if (ie->ie_assign_cpu == NULL) - return (EOPNOTSUPP); - error = priv_check(curthread, PRIV_SCHED_CPUSET_INTR); if (error) return (error); @@ -351,7 +501,7 @@ _intr_event_bind(struct intr_event *ie, int cpu, bool bindirq, bool bindithread) mtx_unlock(&ie->ie_lock); } if (bindirq) - error = ie->ie_assign_cpu(ie->ie_source, cpu); + error = INTR_EVENT_ASSIGN_CPU(ie->ie_pic, IE_SOURCE(ie), cpu); if (error) { if (bindithread) { mtx_lock(&ie->ie_lock); @@ -529,10 +679,23 @@ intr_getaffinity(int irq, int mode, void *m) int intr_event_destroy(struct intr_event *ie) { + int res; if (ie == NULL) return (EINVAL); + res = intr_event_shutdown(ie); + if (res == 0) + free(ie, M_ITHREAD); + return (res); +} + +int +intr_event_shutdown(struct intr_event *ie) +{ + + MPASS(mtx_initialized(&ie->ie_lock)); + mtx_lock(&event_lock); mtx_lock(&ie->ie_lock); if (!CK_SLIST_EMPTY(&ie->ie_handlers)) { @@ -546,7 +709,6 @@ intr_event_destroy(struct intr_event *ie) ithread_destroy(ie->ie_thread); mtx_unlock(&ie->ie_lock); mtx_destroy(&ie->ie_lock); - free(ie, M_ITHREAD); return (0); } @@ -745,7 +907,7 @@ intr_handler_source(void *cookie) KASSERT(ie != NULL, ("interrupt handler \"%s\" has a NULL interrupt event", ih->ih_name)); - return (ie->ie_source); + return (IE_SOURCE(ie)); } /* @@ -1224,8 +1386,7 @@ ithread_execute_handlers(struct proc *p, struct intr_event *ie) * Now that all the handlers have had a chance to run, reenable * the interrupt source. */ - if (ie->ie_post_ithread != NULL) - ie->ie_post_ithread(ie->ie_source); + INTR_EVENT_POST_ITHREAD(ie->ie_pic, IE_SOURCE(ie)); } /* @@ -1426,13 +1587,10 @@ intr_event_handle(struct intr_event *ie, struct trapframe *frame) td->td_intr_frame = oldframe; - if (thread) { - if (ie->ie_pre_ithread != NULL) - ie->ie_pre_ithread(ie->ie_source); - } else { - if (ie->ie_post_filter != NULL) - ie->ie_post_filter(ie->ie_source); - } + if (thread) + INTR_EVENT_PRE_ITHREAD(ie->ie_pic, IE_SOURCE(ie)); + else + INTR_EVENT_POST_FILTER(ie->ie_pic, IE_SOURCE(ie)); /* Schedule the ithread if needed. */ if (thread) { diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 0fa1af6ef5a76f..a0702af8cedd6c 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -70,6 +69,7 @@ #ifdef SMP #include #endif +#include DPCPU_DECLARE(sbintime_t, hardclocktime); diff --git a/sys/kern/pic_if.m b/sys/kern/pic_if.m index f78e787594c5bc..e6860438ccc5cf 100644 --- a/sys/kern/pic_if.m +++ b/sys/kern/pic_if.m @@ -29,10 +29,15 @@ #include #include #include -#include + +#include INTERFACE pic; +HEADER { + #include "intr_event_if.h" +}; + CODE { static int dflt_pic_bind_intr(device_t dev, struct intr_irqsrc *isrc) @@ -140,21 +145,6 @@ struct intr_map_data *data; } DEFAULT null_pic_teardown_intr; -METHOD void post_filter { - device_t dev; - struct intr_irqsrc *isrc; -}; - -METHOD void post_ithread { - device_t dev; - struct intr_irqsrc *isrc; -}; - -METHOD void pre_ithread { - device_t dev; - struct intr_irqsrc *isrc; -}; - METHOD void init_secondary { device_t dev; uint32_t rootnum; diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 0df0b883a32de8..f0a352d62d8df4 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -53,13 +53,11 @@ #include #include #include -#ifdef INTRNG -#include -#endif #include #include +#include #include #include @@ -172,7 +170,6 @@ EVENTHANDLER_LIST_DEFINE(device_detach); EVENTHANDLER_LIST_DEFINE(device_nomatch); EVENTHANDLER_LIST_DEFINE(dev_lookup); -static void devctl2_init(void); static bool device_frozen; #define DRIVERNAME(d) ((d)? d->name : "no driver") @@ -395,7 +392,8 @@ device_sysctl_fini(device_t dev) dev->sysctl_tree = NULL; } -static struct device_list bus_data_devices; +static struct device_list bus_data_devices = + TAILQ_HEAD_INITIALIZER(bus_data_devices); static int bus_data_generation = 1; static kobj_method_t null_methods[] = { @@ -5212,7 +5210,6 @@ root_bus_module_handler(module_t mod, int what, void* arg) { switch (what) { case MOD_LOAD: - TAILQ_INIT(&bus_data_devices); kobj_class_compile((kobj_class_t) &root_driver); root_bus = make_device(NULL, "root", 0); root_bus->desc = "System root bus"; @@ -5220,7 +5217,6 @@ root_bus_module_handler(module_t mod, int what, void* arg) root_bus->driver = &root_driver; root_bus->state = DS_ATTACHED; root_devclass = devclass_find_internal("root", NULL, FALSE); - devctl2_init(); return (0); case MOD_SHUTDOWN: @@ -5238,7 +5234,7 @@ static moduledata_t root_bus_mod = { root_bus_module_handler, NULL }; -DECLARE_MODULE(rootbus, root_bus_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); +DECLARE_MODULE(rootbus, root_bus_mod, SI_SUB_INTR, SI_ORDER_FIRST); /** * @brief Automatically configure devices @@ -6049,11 +6045,12 @@ static struct cdevsw devctl2_cdevsw = { }; static void -devctl2_init(void) +devctl2_init(void *unused) { make_dev_credf(MAKEDEV_ETERNAL, &devctl2_cdevsw, 0, NULL, UID_ROOT, GID_WHEEL, 0644, "devctl2"); } +SYSINIT(devctl2_init, SI_SUB_DRIVERS, SI_ORDER_FIRST, devctl2_init, NULL); /* * For maintaining device 'at' location info to avoid recomputing it diff --git a/sys/kern/subr_intr.c b/sys/kern/subr_intr.c index b7cb088f58c717..a6738e02101ff6 100644 --- a/sys/kern/subr_intr.c +++ b/sys/kern/subr_intr.c @@ -50,8 +50,6 @@ #include #include #include -#include -#include #include #include #include @@ -73,6 +71,7 @@ #include #include +#include #include #include @@ -238,7 +237,7 @@ intrcnt_updatename(struct intr_irqsrc *isrc) /* QQQ: What about stray counter name? */ mtx_assert(&isrc_table_lock, MA_OWNED); - intrcnt_setname(isrc->isrc_event->ie_fullname, isrc->isrc_index); + intrcnt_setname(isrc->isrc_event.ie_fullname, isrc->isrc_index); } /* @@ -404,10 +403,8 @@ intr_isrc_dispatch(struct intr_irqsrc *isrc, struct trapframe *tf) return (0); } else #endif - if (isrc->isrc_event != NULL) { - if (intr_event_handle(isrc->isrc_event, tf) == 0) - return (0); - } + if (intr_event_handle(&isrc->isrc_event, tf) == 0) + return (0); if ((isrc->isrc_flags & INTR_ISRCF_IPI) == 0) isrc_increment_straycount(isrc); @@ -425,9 +422,10 @@ intr_isrc_dispatch(struct intr_irqsrc *isrc, struct trapframe *tf) * constantly... */ static inline int -isrc_alloc_irq(struct intr_irqsrc *isrc) +isrc_alloc_irq(struct intr_irqsrc *isrc, device_t dev) { u_int irq; + int error; mtx_assert(&isrc_table_lock, MA_OWNED); @@ -447,7 +445,11 @@ isrc_alloc_irq(struct intr_irqsrc *isrc) return (ENOSPC); found: - isrc->isrc_irq = irq; + error = intr_event_init(&isrc->isrc_event, dev, irq, 0, + "%s:", isrc->isrc_name); + if (error != 0) + return (error); + irq_sources[irq] = isrc; irq_next_free = irq + 1; @@ -465,13 +467,13 @@ isrc_free_irq(struct intr_irqsrc *isrc) mtx_assert(&isrc_table_lock, MA_OWNED); - if (isrc->isrc_irq >= intr_nirq) + if (isrc->isrc_event.ie_irq >= intr_nirq) return (EINVAL); - if (irq_sources[isrc->isrc_irq] != isrc) + if (irq_sources[isrc->isrc_event.ie_irq] != isrc) return (EINVAL); - irq_sources[isrc->isrc_irq] = NULL; - isrc->isrc_irq = INTR_IRQ_INVALID; /* just to be safe */ + irq_sources[isrc->isrc_event.ie_irq] = NULL; + isrc->isrc_event.ie_irq = INTR_IRQ_INVALID; /* just to be safe */ /* * If we are recovering from the state irq_sources table is full, @@ -504,8 +506,7 @@ intr_isrc_register(struct intr_irqsrc *isrc, device_t dev, u_int flags, va_list ap; bzero(isrc, sizeof(struct intr_irqsrc)); - isrc->isrc_dev = dev; - isrc->isrc_irq = INTR_IRQ_INVALID; /* just to be safe */ + isrc->isrc_event.ie_irq = INTR_IRQ_INVALID; /* just to be safe */ isrc->isrc_flags = flags; va_start(ap, fmt); @@ -513,7 +514,7 @@ intr_isrc_register(struct intr_irqsrc *isrc, device_t dev, u_int flags, va_end(ap); mtx_lock(&isrc_table_lock); - error = isrc_alloc_irq(isrc); + error = isrc_alloc_irq(isrc, dev); if (error != 0) { mtx_unlock(&isrc_table_lock); return (error); @@ -535,12 +536,16 @@ intr_isrc_register(struct intr_irqsrc *isrc, device_t dev, u_int flags, int intr_isrc_deregister(struct intr_irqsrc *isrc) { - int error; + int error = 0; mtx_lock(&isrc_table_lock); - if ((isrc->isrc_flags & INTR_ISRCF_IPI) == 0) - isrc_release_counters(isrc); - error = isrc_free_irq(isrc); + if (mtx_initialized(&isrc->isrc_event.ie_lock)) + error = intr_event_shutdown(&isrc->isrc_event); + if (error == 0) { + if ((isrc->isrc_flags & INTR_ISRCF_IPI) == 0) + isrc_release_counters(isrc); + error = isrc_free_irq(isrc); + } mtx_unlock(&isrc_table_lock); return (error); } @@ -602,47 +607,45 @@ iscr_setup_filter(struct intr_irqsrc *isrc, const char *name, } #endif +#if defined(WITNESS) || defined(INVARIANTS) /* * Interrupt source pre_ithread method for MI interrupt framework. */ static void -intr_isrc_pre_ithread(void *arg) +intr_isrc_pre_ithread(device_t pic, interrupt_t *isrc) { - struct intr_irqsrc *isrc = arg; - PIC_PRE_ITHREAD(isrc->isrc_dev, isrc); + device_printf(pic, "%s() called due to missing handler!", __func__); } /* * Interrupt source post_ithread method for MI interrupt framework. */ static void -intr_isrc_post_ithread(void *arg) +intr_isrc_post_ithread(device_t pic, interrupt_t *isrc) { - struct intr_irqsrc *isrc = arg; - PIC_POST_ITHREAD(isrc->isrc_dev, isrc); + device_printf(pic, "%s() called due to missing handler!", __func__); } /* * Interrupt source post_filter method for MI interrupt framework. */ static void -intr_isrc_post_filter(void *arg) +intr_isrc_post_filter(device_t pic, interrupt_t *isrc) { - struct intr_irqsrc *isrc = arg; - PIC_POST_FILTER(isrc->isrc_dev, isrc); + device_printf(pic, "%s() called due to missing handler!", __func__); } +#endif /* * Interrupt source assign_cpu method for MI interrupt framework. */ static int -intr_isrc_assign_cpu(void *arg, int cpu) +intr_isrc_assign_cpu(device_t pic, interrupt_t *isrc, u_int cpu) { #ifdef SMP - struct intr_irqsrc *isrc = arg; int error; mtx_lock(&isrc_table_lock); @@ -661,7 +664,7 @@ intr_isrc_assign_cpu(void *arg, int cpu) * informed if the call is successful. */ if (irq_assign_cpu) { - error = PIC_BIND_INTR(isrc->isrc_dev, isrc); + error = PIC_BIND_INTR(isrc->isrc_event.ie_pic, isrc); if (error) { CPU_ZERO(&isrc->isrc_cpu); mtx_unlock(&isrc_table_lock); @@ -675,58 +678,19 @@ intr_isrc_assign_cpu(void *arg, int cpu) #endif } -/* - * Create interrupt event for interrupt source. - */ -static int -isrc_event_create(struct intr_irqsrc *isrc) -{ - struct intr_event *ie; - int error; - - error = intr_event_create(&ie, isrc, 0, isrc->isrc_irq, - intr_isrc_pre_ithread, intr_isrc_post_ithread, intr_isrc_post_filter, - intr_isrc_assign_cpu, "%s:", isrc->isrc_name); - if (error) - return (error); - - mtx_lock(&isrc_table_lock); - /* - * Make sure that we do not mix the two ways - * how we handle interrupt sources. Let contested event wins. - */ -#ifdef INTR_SOLO - if (isrc->isrc_filter != NULL || isrc->isrc_event != NULL) { -#else - if (isrc->isrc_event != NULL) { +static device_method_t pic_base_funcs[] = { +#if defined(WITNESS) || defined(INVARIANTS) + DEVMETHOD(intr_event_pre_ithread, intr_isrc_pre_ithread), + DEVMETHOD(intr_event_post_ithread, intr_isrc_post_ithread), + DEVMETHOD(intr_event_post_filter, intr_isrc_post_filter), #endif - mtx_unlock(&isrc_table_lock); - intr_event_destroy(ie); - return (isrc->isrc_event != NULL ? EBUSY : 0); - } - isrc->isrc_event = ie; - mtx_unlock(&isrc_table_lock); + DEVMETHOD(intr_event_assign_cpu, intr_isrc_assign_cpu), - return (0); -} -#ifdef notyet -/* - * Destroy interrupt event for interrupt source. - */ -static void -isrc_event_destroy(struct intr_irqsrc *isrc) -{ - struct intr_event *ie; + DEVMETHOD_END +}; - mtx_lock(&isrc_table_lock); - ie = isrc->isrc_event; - isrc->isrc_event = NULL; - mtx_unlock(&isrc_table_lock); +PUBLIC_DEFINE_CLASS(pic_base, pic_base_funcs, 0); - if (ie != NULL) - intr_event_destroy(ie); -} -#endif /* * Add handler to interrupt source. */ @@ -737,13 +701,7 @@ isrc_add_handler(struct intr_irqsrc *isrc, const char *name, { int error; - if (isrc->isrc_event == NULL) { - error = isrc_event_create(isrc); - if (error) - return (error); - } - - error = intr_event_add_handler(isrc->isrc_event, name, filter, handler, + error = intr_event_add_handler(&isrc->isrc_event, name, filter, handler, arg, intr_priority(flags), flags, cookiep); if (error == 0) { mtx_lock(&isrc_table_lock); @@ -1045,7 +1003,7 @@ intr_activate_irq(device_t dev, struct resource *res) } intr_map_set_isrc(res_id, isrc); rman_set_virtual(res, data); - return (PIC_ACTIVATE_INTR(isrc->isrc_dev, isrc, res, data)); + return (PIC_ACTIVATE_INTR(isrc->isrc_event.ie_pic, isrc, res, data)); } int @@ -1066,7 +1024,7 @@ intr_deactivate_irq(device_t dev, struct resource *res) res_id); data = rman_get_virtual(res); - error = PIC_DEACTIVATE_INTR(isrc->isrc_dev, isrc, res, data); + error = PIC_DEACTIVATE_INTR(isrc->isrc_event.ie_pic, isrc, res, data); intr_map_set_isrc(res_id, NULL); rman_set_virtual(res, NULL); free(data, M_INTRNG); @@ -1122,17 +1080,18 @@ intr_setup_irq(device_t dev, struct resource *res, driver_filter_t filt, { error = isrc_add_handler(isrc, name, filt, hand, arg, flags, cookiep); - debugf("irq %u add handler error %d on %s\n", isrc->isrc_irq, error, name); + debugf("irq %u add handler error %d on %s\n", + isrc->isrc_event.ie_irq, error, name); } if (error != 0) return (error); mtx_lock(&isrc_table_lock); - error = PIC_SETUP_INTR(isrc->isrc_dev, isrc, res, data); + error = PIC_SETUP_INTR(isrc->isrc_event.ie_pic, isrc, res, data); if (error == 0) { isrc->isrc_handlers++; if (isrc->isrc_handlers == 1) - PIC_ENABLE_INTR(isrc->isrc_dev, isrc); + PIC_ENABLE_INTR(isrc->isrc_event.ie_pic, isrc); } mtx_unlock(&isrc_table_lock); if (error != 0) @@ -1182,8 +1141,8 @@ intr_teardown_irq(device_t dev, struct resource *res, void *cookie) mtx_lock(&isrc_table_lock); isrc->isrc_handlers--; if (isrc->isrc_handlers == 0) - PIC_DISABLE_INTR(isrc->isrc_dev, isrc); - PIC_TEARDOWN_INTR(isrc->isrc_dev, isrc, res, data); + PIC_DISABLE_INTR(isrc->isrc_event.ie_pic, isrc); + PIC_TEARDOWN_INTR(isrc->isrc_event.ie_pic, isrc, res, data); intrcnt_updatename(isrc); mtx_unlock(&isrc_table_lock); } @@ -1216,7 +1175,7 @@ intr_describe_irq(device_t dev, struct resource *res, void *cookie, return (0); } #endif - error = intr_event_describe_handler(isrc->isrc_event, cookie, descr); + error = intr_event_describe_handler(&isrc->isrc_event, cookie, descr); if (error == 0) { mtx_lock(&isrc_table_lock); intrcnt_updatename(isrc); @@ -1243,7 +1202,7 @@ intr_bind_irq(device_t dev, struct resource *res, int cpu) if (isrc->isrc_filter != NULL) return (intr_isrc_assign_cpu(isrc, cpu)); #endif - return (intr_event_bind(isrc->isrc_event, cpu)); + return (intr_event_bind(&isrc->isrc_event, cpu)); } /* @@ -1295,9 +1254,8 @@ intr_irq_shuffle(void *arg __unused) isrc->isrc_flags & (INTR_ISRCF_PPI | INTR_ISRCF_IPI)) continue; - if (isrc->isrc_event != NULL && - isrc->isrc_flags & INTR_ISRCF_BOUND && - isrc->isrc_event->ie_cpu != CPU_FFS(&isrc->isrc_cpu) - 1) + if (isrc->isrc_flags & INTR_ISRCF_BOUND && + isrc->isrc_event.ie_cpu != CPU_FFS(&isrc->isrc_cpu) - 1) panic("%s: CPU inconsistency", __func__); if ((isrc->isrc_flags & INTR_ISRCF_BOUND) == 0) @@ -1308,7 +1266,7 @@ intr_irq_shuffle(void *arg __unused) * for bound ISRC. The best thing we can do is to clear * isrc_cpu so inconsistency with ie_cpu will be detectable. */ - if (PIC_BIND_INTR(isrc->isrc_dev, isrc) != 0) + if (PIC_BIND_INTR(isrc->isrc_event.ie_pic, isrc) != 0) CPU_ZERO(&isrc->isrc_cpu); } mtx_unlock(&isrc_table_lock); diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c index c4146922edc595..6eba22115ca632 100644 --- a/sys/kern/subr_taskqueue.c +++ b/sys/kern/subr_taskqueue.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -44,6 +43,8 @@ #include #include #include + +#include #include static MALLOC_DEFINE(M_TASKQUEUE, "taskqueue", "Task Queues"); diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index 7051e31565d4d6..5d0890b56bb368 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -60,6 +59,8 @@ #include #include +#include + #include #include #include diff --git a/sys/net/netisr.c b/sys/net/netisr.c index 4ae1aa9ab89d20..9d4b22d0666b78 100644 --- a/sys/net/netisr.c +++ b/sys/net/netisr.c @@ -71,7 +71,6 @@ #include #include #include -#include #include #include #include @@ -84,6 +83,8 @@ #include #include +#include + #ifdef DDB #include #endif diff --git a/sys/netinet/tcp_hpts.c b/sys/netinet/tcp_hpts.c index 5b39c94e0e58c7..daaf0ae6fbbf6f 100644 --- a/sys/netinet/tcp_hpts.c +++ b/sys/netinet/tcp_hpts.c @@ -100,7 +100,6 @@ #include #include -#include #include #include #include @@ -123,6 +122,8 @@ #include #include +#include + #include #include diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index 60bfb05d157061..dbc6884f13ecec 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -67,7 +67,6 @@ #include #include #include -#include #include #include #include @@ -81,6 +80,8 @@ #include #include +#include + #include #include #include diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 335b192d454d49..e2e928a1b5379b 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -63,6 +62,8 @@ #include #include +#include + #include #include #include diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 188681329b43e9..9f37a0d119d1f6 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -68,6 +67,8 @@ #include #include +#include + #include #include #include diff --git a/sys/netpfil/pf/pflow.c b/sys/netpfil/pf/pflow.c index 8741d55b622ce3..f833e3dc0408fe 100644 --- a/sys/netpfil/pf/pflow.c +++ b/sys/netpfil/pf/pflow.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -38,6 +37,8 @@ #include #include +#include + #include #include #include diff --git a/sys/powerpc/aim/mp_cpudep.c b/sys/powerpc/aim/mp_cpudep.c index 98acfc1a5c3759..b42ed6e3edd84e 100644 --- a/sys/powerpc/aim/mp_cpudep.c +++ b/sys/powerpc/aim/mp_cpudep.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/powerpc/amigaone/cpld_a1222.c b/sys/powerpc/amigaone/cpld_a1222.c index 87c7143e9b1b15..17508da9f86576 100644 --- a/sys/powerpc/amigaone/cpld_a1222.c +++ b/sys/powerpc/amigaone/cpld_a1222.c @@ -118,11 +118,8 @@ static device_method_t cpld_methods[] = { DEVMETHOD_END }; -static driver_t cpld_driver = { - "cpld", - cpld_methods, - sizeof(struct cpld_softc) -}; +PRIVATE_DEFINE_CLASSN(cpld, cpld_driver, cpld_methods, + sizeof(struct cpld_softc)); DRIVER_MODULE(cpld, lbc, cpld_driver, 0, 0); diff --git a/sys/powerpc/amigaone/cpld_x5000.c b/sys/powerpc/amigaone/cpld_x5000.c index cf4a4680c6d53f..5a51af37eb24f9 100644 --- a/sys/powerpc/amigaone/cpld_x5000.c +++ b/sys/powerpc/amigaone/cpld_x5000.c @@ -105,11 +105,8 @@ static device_method_t cpld_methods[] = { DEVMETHOD_END }; -static driver_t cpld_driver = { - "cpld", - cpld_methods, - sizeof(struct cpld_softc) -}; +PRIVATE_DEFINE_CLASSN(cpld, cpld_driver, cpld_methods, + sizeof(struct cpld_softc)); DRIVER_MODULE(cpld, lbc, cpld_driver, 0, 0); diff --git a/sys/powerpc/amigaone/platform_amigaone.c b/sys/powerpc/amigaone/platform_amigaone.c index d9ff3f85987cec..a118b45fd50104 100644 --- a/sys/powerpc/amigaone/platform_amigaone.c +++ b/sys/powerpc/amigaone/platform_amigaone.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include diff --git a/sys/powerpc/cpufreq/dfs.c b/sys/powerpc/cpufreq/dfs.c index 247ddcaa9c6bc5..ceebbefd57463a 100644 --- a/sys/powerpc/cpufreq/dfs.c +++ b/sys/powerpc/cpufreq/dfs.c @@ -59,15 +59,12 @@ static device_method_t dfs_methods[] = { DEVMETHOD(cpufreq_drv_get, dfs_get), DEVMETHOD(cpufreq_drv_type, dfs_type), DEVMETHOD(cpufreq_drv_settings, dfs_settings), - {0, 0} -}; -static driver_t dfs_driver = { - "dfs", - dfs_methods, - sizeof(struct dfs_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(dfs, dfs_driver, dfs_methods, sizeof(struct dfs_softc)); + DRIVER_MODULE(dfs, cpu, dfs_driver, 0, 0); /* diff --git a/sys/powerpc/cpufreq/mpc85xx_jog.c b/sys/powerpc/cpufreq/mpc85xx_jog.c index 2d66fa05e942fa..ab02cd592a6236 100644 --- a/sys/powerpc/cpufreq/mpc85xx_jog.c +++ b/sys/powerpc/cpufreq/mpc85xx_jog.c @@ -85,15 +85,13 @@ static device_method_t mpc85xx_jog_methods[] = { DEVMETHOD(cpufreq_drv_get, mpc85xx_jog_get), DEVMETHOD(cpufreq_drv_type, mpc85xx_jog_type), DEVMETHOD(cpufreq_drv_settings, mpc85xx_jog_settings), - {0, 0} -}; -static driver_t mpc85xx_jog_driver = { - "jog", - mpc85xx_jog_methods, - sizeof(struct mpc85xx_jog_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(jog, mpc85xx_jog_driver, mpc85xx_jog_methods, + sizeof(struct mpc85xx_jog_softc)); + DRIVER_MODULE(mpc85xx_jog, cpu, mpc85xx_jog_driver, 0, 0); struct mpc85xx_constraints { diff --git a/sys/powerpc/cpufreq/pcr.c b/sys/powerpc/cpufreq/pcr.c index 235f2d1553572b..c3463562ef0651 100644 --- a/sys/powerpc/cpufreq/pcr.c +++ b/sys/powerpc/cpufreq/pcr.c @@ -62,15 +62,12 @@ static device_method_t pcr_methods[] = { DEVMETHOD(cpufreq_drv_get, pcr_get), DEVMETHOD(cpufreq_drv_type, pcr_type), DEVMETHOD(cpufreq_drv_settings, pcr_settings), - {0, 0} -}; -static driver_t pcr_driver = { - "pcr", - pcr_methods, - sizeof(struct pcr_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(pcr, pcr_driver, pcr_methods, sizeof(struct pcr_softc)); + DRIVER_MODULE(pcr, cpu, pcr_driver, 0, 0); /* diff --git a/sys/powerpc/cpufreq/pmcr.c b/sys/powerpc/cpufreq/pmcr.c index 8dd57079e3bd47..9adb6796070f3a 100644 --- a/sys/powerpc/cpufreq/pmcr.c +++ b/sys/powerpc/cpufreq/pmcr.c @@ -99,15 +99,13 @@ static device_method_t pmcr_methods[] = { DEVMETHOD(cpufreq_drv_get, pmcr_get), DEVMETHOD(cpufreq_drv_type, pmcr_type), DEVMETHOD(cpufreq_drv_settings, pmcr_settings), - {0, 0} -}; -static driver_t pmcr_driver = { - "pmcr", - pmcr_methods, - sizeof(struct pmcr_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(pmcr, pmcr_driver, pmcr_methods, + sizeof(struct pmcr_softc)); + DRIVER_MODULE(pmcr, cpu, pmcr_driver, 0, 0); static void diff --git a/sys/powerpc/cpufreq/pmufreq.c b/sys/powerpc/cpufreq/pmufreq.c index 5c8f413539b451..2226363ddb7fab 100644 --- a/sys/powerpc/cpufreq/pmufreq.c +++ b/sys/powerpc/cpufreq/pmufreq.c @@ -67,15 +67,13 @@ static device_method_t pmufreq_methods[] = { DEVMETHOD(cpufreq_drv_get, pmufreq_get), DEVMETHOD(cpufreq_drv_type, pmufreq_type), DEVMETHOD(cpufreq_drv_settings, pmufreq_settings), - {0, 0} -}; -static driver_t pmufreq_driver = { - "pmufreq", - pmufreq_methods, - sizeof(struct pmufreq_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(pmufreq, pmufreq_driver, pmufreq_methods, + sizeof(struct pmufreq_softc)); + DRIVER_MODULE(pmufreq, cpu, pmufreq_driver, 0, 0); static void diff --git a/sys/powerpc/include/intr_machdep.h b/sys/powerpc/include/interrupt.h similarity index 88% rename from sys/powerpc/include/intr_machdep.h rename to sys/powerpc/include/interrupt.h index e46e2b5f9ba97e..c455630e3634fa 100644 --- a/sys/powerpc/include/intr_machdep.h +++ b/sys/powerpc/include/interrupt.h @@ -25,8 +25,18 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _MACHINE_INTR_MACHDEP_H_ -#define _MACHINE_INTR_MACHDEP_H_ +#ifndef __MACHINE_INTERRUPT_H__ +#define __MACHINE_INTERRUPT_H__ + +/* FreeBSD standard interrupt controller interface */ + +typedef struct powerpc_intr interrupt_t; + +#include + +/* FreeBSD standard interrupt controller interface */ + +DECLARE_CLASS(pic_hw_class); #define INTR_VECTORS 256 @@ -61,4 +71,4 @@ int powerpc_fw_config_intr(int irq, int sense_code); void powerpc_intr_mask(u_int irq); void powerpc_intr_unmask(u_int irq); -#endif /* _MACHINE_INTR_MACHDEP_H_ */ +#endif /* __MACHINE_INTERRUPT_H__ */ diff --git a/sys/powerpc/include/openpicvar.h b/sys/powerpc/include/openpicvar.h index 3a170a8a35fe2b..8827484291b78d 100644 --- a/sys/powerpc/include/openpicvar.h +++ b/sys/powerpc/include/openpicvar.h @@ -28,6 +28,8 @@ #ifndef _POWERPC_OPENPICVAR_H_ #define _POWERPC_OPENPICVAR_H_ +#include + #define OPENPIC_DEVSTR "OpenPIC Interrupt Controller" #define OPENPIC_IRQMAX 256 /* h/w allows more */ @@ -75,16 +77,6 @@ int openpic_common_attach(device_t, uint32_t); /* * PIC interface. */ -void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **); -void openpic_config(device_t, u_int, enum intr_trigger, enum intr_polarity); -void openpic_dispatch(device_t, struct trapframe *); -void openpic_enable(device_t, u_int, u_int, void **); -void openpic_eoi(device_t, u_int, void *); -void openpic_ipi(device_t, u_int); -void openpic_mask(device_t, u_int, void *); -void openpic_unmask(device_t, u_int, void *); - -int openpic_suspend(device_t dev); -int openpic_resume(device_t dev); +DECLARE_CLASS(openpic_class); #endif /* _POWERPC_OPENPICVAR_H_ */ diff --git a/sys/powerpc/include/platformvar.h b/sys/powerpc/include/platformvar.h index 64b01697248479..b9be36988d5eac 100644 --- a/sys/powerpc/include/platformvar.h +++ b/sys/powerpc/include/platformvar.h @@ -40,7 +40,8 @@ * PLATFORMMETHOD(platform_mem_regions, ofw_mem_regions), * ... * PLATFORMMETHOD(platform_smp_first_cpu, chrp_smp_first_cpu), - * { 0, 0 } + * + * PLATFORMMETHOD_END * }; * * static platform_def_t chrp_platform = { diff --git a/sys/powerpc/mambo/mambo.c b/sys/powerpc/mambo/mambo.c index 2e4dbf49c477e4..d31e2fe7dcf9ec 100644 --- a/sys/powerpc/mambo/mambo.c +++ b/sys/powerpc/mambo/mambo.c @@ -66,11 +66,7 @@ static device_method_t mambobus_methods[] = { DEVMETHOD_END }; -static driver_t mambobus_driver = { - "mambo", - mambobus_methods, - 0 -}; +PRIVATE_DEFINE_CLASSN(mambo, mambobus_driver, mambobus_methods, 0); DRIVER_MODULE(mambo, ofwbus, mambobus_driver, 0, 0); diff --git a/sys/powerpc/mambo/mambo_disk.c b/sys/powerpc/mambo/mambo_disk.c index d24652f15885f7..e9cd126b30062d 100644 --- a/sys/powerpc/mambo/mambo_disk.c +++ b/sys/powerpc/mambo/mambo_disk.c @@ -263,13 +263,11 @@ static device_method_t mambodisk_methods[] = { DEVMETHOD(device_probe, mambodisk_probe), DEVMETHOD(device_attach, mambodisk_attach), DEVMETHOD(device_detach, mambodisk_detach), - {0, 0}, -}; -static driver_t mambodisk_driver = { - "mambodisk", - mambodisk_methods, - sizeof(struct mambodisk_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(mambodisk, mambodisk_driver, mambodisk_methods, + sizeof(struct mambodisk_softc)); + DRIVER_MODULE(mambodisk, mambo, mambodisk_driver, 0, 0); diff --git a/sys/powerpc/mikrotik/rb_led.c b/sys/powerpc/mikrotik/rb_led.c index 9814b3940603f6..2b5284a901b5ff 100644 --- a/sys/powerpc/mikrotik/rb_led.c +++ b/sys/powerpc/mikrotik/rb_led.c @@ -58,11 +58,8 @@ static device_method_t rbled_methods[] = { DEVMETHOD_END }; -static driver_t rbled_driver = { - "rbled", - rbled_methods, - sizeof(struct rbled_softc), -}; +PRIVATE_DEFINE_CLASSN(rbled, rbled_driver, rbled_methods, + sizeof(struct rbled_softc)); DRIVER_MODULE(rbled, simplebus, rbled_driver, 0, 0); diff --git a/sys/powerpc/mpc85xx/atpic.c b/sys/powerpc/mpc85xx/atpic.c index 8c69af8b4b4d23..eeb0ccc95ead9e 100644 --- a/sys/powerpc/mpc85xx/atpic.c +++ b/sys/powerpc/mpc85xx/atpic.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include @@ -98,14 +98,11 @@ static device_method_t atpic_isa_methods[] = { DEVMETHOD(pic_translate_code, atpic_ofw_translate_code), - { 0, 0 }, + DEVMETHOD_END }; -static driver_t atpic_isa_driver = { - "atpic", - atpic_isa_methods, - sizeof(struct atpic_softc) -}; +PRIVATE_DEFINE_CLASSN(atpic, atpic_isa_driver, atpic_isa_methods, + sizeof(struct atpic_softc), pic_hw_class); static struct isa_pnp_id atpic_ids[] = { { 0x0000d041 /* PNP0000 */, "AT interrupt controller" }, diff --git a/sys/powerpc/mpc85xx/ds1553_bus_fdt.c b/sys/powerpc/mpc85xx/ds1553_bus_fdt.c index 2457ca2ca98eb4..2aaab71096030a 100644 --- a/sys/powerpc/mpc85xx/ds1553_bus_fdt.c +++ b/sys/powerpc/mpc85xx/ds1553_bus_fdt.c @@ -60,15 +60,13 @@ static device_method_t rtc_methods[] = { /* clock interface */ DEVMETHOD(clock_gettime, ds1553_gettime), DEVMETHOD(clock_settime, ds1553_settime), - { 0, 0 } -}; -static driver_t rtc_driver = { - "rtc", - rtc_methods, - sizeof(struct ds1553_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(rtc, rtc_driver, rtc_methods, + sizeof(struct ds1553_softc)); + DRIVER_MODULE(rtc, lbc, rtc_driver, 0, 0); static int diff --git a/sys/powerpc/mpc85xx/fsl_diu.c b/sys/powerpc/mpc85xx/fsl_diu.c index 97803e29b6cec1..c1184721ebd3b1 100644 --- a/sys/powerpc/mpc85xx/fsl_diu.c +++ b/sys/powerpc/mpc85xx/fsl_diu.c @@ -450,13 +450,10 @@ static device_method_t diu_methods[] = { /* Framebuffer service methods */ DEVMETHOD(fb_getinfo, diu_fb_getinfo), - { 0, 0 } -}; -static driver_t diu_driver = { - "fb", - diu_methods, - sizeof(struct diu_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(fb, diu_driver, diu_methods, sizeof(struct diu_softc)); + DRIVER_MODULE(fb, simplebus, diu_driver, 0, 0); diff --git a/sys/powerpc/mpc85xx/fsl_espi.c b/sys/powerpc/mpc85xx/fsl_espi.c index 7f8378083d6332..30da9a34755fec 100644 --- a/sys/powerpc/mpc85xx/fsl_espi.c +++ b/sys/powerpc/mpc85xx/fsl_espi.c @@ -421,10 +421,7 @@ static device_method_t fsl_espi_methods[] = { DEVMETHOD_END }; -static driver_t fsl_espi_driver = { - "spi", - fsl_espi_methods, - sizeof(struct fsl_espi_softc), -}; +PRIVATE_DEFINE_CLASSN(spi, fsl_espi_driver, fsl_espi_methods, + sizeof(struct fsl_espi_softc)); DRIVER_MODULE(fsl_espi, simplebus, fsl_espi_driver, 0, 0); diff --git a/sys/powerpc/mpc85xx/fsl_sata.c b/sys/powerpc/mpc85xx/fsl_sata.c index 18fd8e438cd4ec..17de1392924e90 100644 --- a/sys/powerpc/mpc85xx/fsl_sata.c +++ b/sys/powerpc/mpc85xx/fsl_sata.c @@ -546,14 +546,12 @@ static device_method_t fsl_satach_methods[] = { DEVMETHOD(device_detach, fsl_sata_detach), DEVMETHOD(device_suspend, fsl_sata_suspend), DEVMETHOD(device_resume, fsl_sata_resume), + DEVMETHOD_END }; -static driver_t fsl_satach_driver = { - "fslsata", - fsl_satach_methods, - sizeof(struct fsl_sata_channel) -}; +PRIVATE_DEFINE_CLASSN(fslsata, fsl_satach_driver, fsl_satach_methods, + sizeof(struct fsl_sata_channel)); DRIVER_MODULE(fsl_satach, simplebus, fsl_satach_driver, NULL, NULL); diff --git a/sys/powerpc/mpc85xx/i2c.c b/sys/powerpc/mpc85xx/i2c.c index a4f8265fd4b16d..7ba7397dc4d2b2 100644 --- a/sys/powerpc/mpc85xx/i2c.c +++ b/sys/powerpc/mpc85xx/i2c.c @@ -111,15 +111,12 @@ static device_method_t i2c_methods[] = { DEVMETHOD(iicbus_write, i2c_write), DEVMETHOD(iicbus_transfer, iicbus_transfer_gen), DEVMETHOD(ofw_bus_get_node, i2c_get_node), - { 0, 0 } -}; -static driver_t i2c_driver = { - "iichb", - i2c_methods, - sizeof(struct i2c_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(iichb, i2c_driver, i2c_methods, sizeof(struct i2c_softc)); + DRIVER_MODULE(i2c, simplebus, i2c_driver, 0, 0); DRIVER_MODULE(iicbus, i2c, iicbus_driver, 0, 0); diff --git a/sys/powerpc/mpc85xx/isa.c b/sys/powerpc/mpc85xx/isa.c index d730ecb6f3e9d4..d3880704dad7bb 100644 --- a/sys/powerpc/mpc85xx/isa.c +++ b/sys/powerpc/mpc85xx/isa.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include diff --git a/sys/powerpc/mpc85xx/lbc.c b/sys/powerpc/mpc85xx/lbc.c index 1399ecf206b9dd..74618a1d226372 100644 --- a/sys/powerpc/mpc85xx/lbc.c +++ b/sys/powerpc/mpc85xx/lbc.c @@ -116,15 +116,12 @@ static device_method_t lbc_methods[] = { DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - { 0, 0 } -}; -static driver_t lbc_driver = { - "lbc", - lbc_methods, - sizeof(struct lbc_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(lbc, lbc_driver, lbc_methods, sizeof(struct lbc_softc)); + EARLY_DRIVER_MODULE(lbc, ofwbus, lbc_driver, 0, 0, BUS_PASS_BUS); /* diff --git a/sys/powerpc/mpc85xx/mpc85xx_cache.c b/sys/powerpc/mpc85xx/mpc85xx_cache.c index e5104cb20fa823..49dd19224263c8 100644 --- a/sys/powerpc/mpc85xx/mpc85xx_cache.c +++ b/sys/powerpc/mpc85xx/mpc85xx_cache.c @@ -147,11 +147,8 @@ static device_method_t mpc85xx_cache_methods[] = { DEVMETHOD_END }; -static driver_t mpc85xx_cache_driver = { - "cache", - mpc85xx_cache_methods, - sizeof(struct mpc85xx_cache_softc), -}; +PRIVATE_DEFINE_CLASSN(cache, mpc85xx_cache_driver, mpc85xx_cache_methods, + sizeof(struct mpc85xx_cache_softc)); EARLY_DRIVER_MODULE(mpc85xx_cache, simplebus, mpc85xx_cache_driver, NULL, NULL, BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/powerpc/mpc85xx/mpc85xx_gpio.c b/sys/powerpc/mpc85xx/mpc85xx_gpio.c index 22c35261f7b808..5e8fce31de6ce6 100644 --- a/sys/powerpc/mpc85xx/mpc85xx_gpio.c +++ b/sys/powerpc/mpc85xx/mpc85xx_gpio.c @@ -279,11 +279,8 @@ static device_method_t mpc85xx_gpio_methods[] = { DEVMETHOD_END }; -static driver_t mpc85xx_gpio_driver = { - "gpio", - mpc85xx_gpio_methods, - sizeof(struct mpc85xx_gpio_softc), -}; +PRIVATE_DEFINE_CLASSN(gpio, mpc85xx_gpio_driver, mpc85xx_gpio_methods, + sizeof(struct mpc85xx_gpio_softc)); EARLY_DRIVER_MODULE(mpc85xx_gpio, simplebus, mpc85xx_gpio_driver, NULL, NULL, BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/powerpc/mpc85xx/pci_mpc85xx.c b/sys/powerpc/mpc85xx/pci_mpc85xx.c index 8e349df03a51fd..85a01c35e6baca 100644 --- a/sys/powerpc/mpc85xx/pci_mpc85xx.c +++ b/sys/powerpc/mpc85xx/pci_mpc85xx.c @@ -70,7 +70,7 @@ #include #include -#include +#include #include @@ -253,8 +253,8 @@ static device_method_t fsl_pcib_methods[] = { DEVMETHOD_END }; -DEFINE_CLASS_1(pcib, fsl_pcib_driver, fsl_pcib_methods, - sizeof(struct fsl_pcib_softc), ofw_pcib_driver); +PRIVATE_DEFINE_CLASSN(pcib, fsl_pcib_driver, fsl_pcib_methods, + sizeof(struct fsl_pcib_softc), pic_hw_class, ofw_pcib_driver); EARLY_DRIVER_MODULE(pcib, ofwbus, fsl_pcib_driver, 0, 0, BUS_PASS_BUS); static void @@ -947,11 +947,8 @@ static device_method_t fsl_msi_methods[] = { DEVMETHOD_END }; -static driver_t fsl_msi_driver = { - "fsl_msi", - fsl_msi_methods, - sizeof(struct fsl_msi_softc) -}; +PRIVATE_DEFINE_CLASSN(fsl_msi, fsl_msi_driver, fsl_msi_methods, + sizeof(struct fsl_msi_softc), pic_hw_class); EARLY_DRIVER_MODULE(fsl_msi, simplebus, fsl_msi_driver, 0, 0, BUS_PASS_INTERRUPT + 1); diff --git a/sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c b/sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c index a70df6e1c92229..399b1983bcb720 100644 --- a/sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c +++ b/sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c @@ -56,7 +56,7 @@ #include #include -#include +#include #include "pcib_if.h" diff --git a/sys/powerpc/mpc85xx/platform_mpc85xx.c b/sys/powerpc/mpc85xx/platform_mpc85xx.c index 6653c40b01a36e..11cfd8469ab6ad 100644 --- a/sys/powerpc/mpc85xx/platform_mpc85xx.c +++ b/sys/powerpc/mpc85xx/platform_mpc85xx.c @@ -617,14 +617,12 @@ mpc85xx_rcpm_attach(device_t dev) static device_method_t mpc85xx_rcpm_methods[] = { DEVMETHOD(device_probe, mpc85xx_rcpm_probe), DEVMETHOD(device_attach, mpc85xx_rcpm_attach), + DEVMETHOD_END }; -static driver_t mpc85xx_rcpm_driver = { - "rcpm", - mpc85xx_rcpm_methods, - sizeof(struct mpc85xx_rcpm_softc) -}; +PRIVATE_DEFINE_CLASSN(rcpm, mpc85xx_rcpm_driver, mpc85xx_rcpm_methods, + sizeof(struct mpc85xx_rcpm_softc)); EARLY_DRIVER_MODULE(mpc85xx_rcpm, simplebus, mpc85xx_rcpm_driver, 0, 0, BUS_PASS_BUS); @@ -691,14 +689,12 @@ mpc85xx_guts_attach(device_t dev) static device_method_t mpc85xx_guts_methods[] = { DEVMETHOD(device_probe, mpc85xx_guts_probe), DEVMETHOD(device_attach, mpc85xx_guts_attach), + DEVMETHOD_END }; -static driver_t mpc85xx_guts_driver = { - "guts", - mpc85xx_guts_methods, - sizeof(struct mpc85xx_guts_softc) -}; +PRIVATE_DEFINE_CLASSN(guts, mpc85xx_guts_driver, mpc85xx_guts_methods, + sizeof(struct mpc85xx_guts_softc)); EARLY_DRIVER_MODULE(mpc85xx_guts, simplebus, mpc85xx_guts_driver, 0, 0, BUS_PASS_BUS); diff --git a/sys/powerpc/ofw/ofw_pcib_pci.c b/sys/powerpc/ofw/ofw_pcib_pci.c index 055aab9cf4c631..576067cc9e7329 100644 --- a/sys/powerpc/ofw/ofw_pcib_pci.c +++ b/sys/powerpc/ofw/ofw_pcib_pci.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include "pcib_if.h" diff --git a/sys/powerpc/ofw/ofw_pcibus.c b/sys/powerpc/ofw/ofw_pcibus.c index ff0fe39592e2bf..dc8641b488c777 100644 --- a/sys/powerpc/ofw/ofw_pcibus.c +++ b/sys/powerpc/ofw/ofw_pcibus.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include #include diff --git a/sys/powerpc/ofw/ofw_syscons.c b/sys/powerpc/ofw/ofw_syscons.c index 652d68ce7440dd..7d20c0ea9640cf 100644 --- a/sys/powerpc/ofw/ofw_syscons.c +++ b/sys/powerpc/ofw/ofw_syscons.c @@ -1032,15 +1032,13 @@ static device_method_t ofwfb_sc_methods[] = { DEVMETHOD(device_identify, ofwfb_scidentify), DEVMETHOD(device_probe, ofwfb_scprobe), DEVMETHOD(device_attach, ofwfb_scattach), - { 0, 0 } -}; -static driver_t ofwfb_sc_driver = { - SC_DRIVER_NAME, - ofwfb_sc_methods, - sizeof(sc_softc_t), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(SC_DRIVER_NAME, ofwfb_sc_driver, ofwfb_sc_methods, + sizeof(sc_softc_t)); + DRIVER_MODULE(ofwfb, nexus, ofwfb_sc_driver, 0, 0); /* diff --git a/sys/powerpc/ofw/openpic_ofw.c b/sys/powerpc/ofw/openpic_ofw.c index fdab55fb30f56b..febd7bc87cbe8d 100644 --- a/sys/powerpc/ofw/openpic_ofw.c +++ b/sys/powerpc/ofw/openpic_ofw.c @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include #include @@ -68,29 +68,15 @@ static device_method_t openpic_ofw_methods[] = { /* Device interface */ DEVMETHOD(device_probe, openpic_ofw_probe), DEVMETHOD(device_attach, openpic_ofw_attach), - DEVMETHOD(device_suspend, openpic_suspend), - DEVMETHOD(device_resume, openpic_resume), /* PIC interface */ - DEVMETHOD(pic_bind, openpic_bind), - DEVMETHOD(pic_config, openpic_config), - DEVMETHOD(pic_dispatch, openpic_dispatch), - DEVMETHOD(pic_enable, openpic_enable), - DEVMETHOD(pic_eoi, openpic_eoi), - DEVMETHOD(pic_ipi, openpic_ipi), - DEVMETHOD(pic_mask, openpic_mask), - DEVMETHOD(pic_unmask, openpic_unmask), - DEVMETHOD(pic_translate_code, openpic_ofw_translate_code), DEVMETHOD_END }; -static driver_t openpic_ofw_driver = { - "openpic", - openpic_ofw_methods, - sizeof(struct openpic_softc), -}; +PRIVATE_DEFINE_CLASSN(openpic, openpic_ofw_driver, openpic_ofw_methods, + sizeof(struct openpic_softc), openpic_class); EARLY_DRIVER_MODULE(openpic, ofwbus, openpic_ofw_driver, 0, 0, BUS_PASS_INTERRUPT); diff --git a/sys/powerpc/powermac/ata_kauai.c b/sys/powerpc/powermac/ata_kauai.c index 1c1c85ef9b44d9..cd0471ec9aaf50 100644 --- a/sys/powerpc/powermac/ata_kauai.c +++ b/sys/powerpc/powermac/ata_kauai.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include @@ -98,6 +98,7 @@ static device_method_t ata_kauai_methods[] = { /* ATA interface */ DEVMETHOD(ata_setmode, ata_kauai_setmode), + DEVMETHOD_END }; @@ -113,11 +114,8 @@ struct ata_kauai_softc { uint32_t pioconf[2]; }; -static driver_t ata_kauai_driver = { - "ata", - ata_kauai_methods, - sizeof(struct ata_kauai_softc), -}; +PRIVATE_DEFINE_CLASSN(ata, ata_kauai_driver, ata_kauai_methods, + sizeof(struct ata_kauai_softc)); DRIVER_MODULE(ata, pci, ata_kauai_driver, NULL, NULL); MODULE_DEPEND(ata, ata, 1, 1, 1); diff --git a/sys/powerpc/powermac/ata_macio.c b/sys/powerpc/powermac/ata_macio.c index 5363fb1c5854a2..56dcb8f541aa4b 100644 --- a/sys/powerpc/powermac/ata_macio.c +++ b/sys/powerpc/powermac/ata_macio.c @@ -126,6 +126,7 @@ static device_method_t ata_macio_methods[] = { /* ATA interface */ DEVMETHOD(ata_setmode, ata_macio_setmode), + DEVMETHOD_END }; @@ -141,11 +142,8 @@ struct ata_macio_softc { uint32_t pioconf[2]; }; -static driver_t ata_macio_driver = { - "ata", - ata_macio_methods, - sizeof(struct ata_macio_softc), -}; +PRIVATE_DEFINE_CLASSN(ata, ata_macio_driver, ata_macio_methods, + sizeof(struct ata_macio_softc)); DRIVER_MODULE(ata, macio, ata_macio_driver, NULL, NULL); MODULE_DEPEND(ata, ata, 1, 1, 1); diff --git a/sys/powerpc/powermac/atibl.c b/sys/powerpc/powermac/atibl.c index 1bc521f8bfad5f..7e7e38c44cd52f 100644 --- a/sys/powerpc/powermac/atibl.c +++ b/sys/powerpc/powermac/atibl.c @@ -89,15 +89,13 @@ static device_method_t atibl_methods[] = { DEVMETHOD(device_attach, atibl_attach), DEVMETHOD(device_suspend, atibl_suspend), DEVMETHOD(device_resume, atibl_resume), - {0, 0}, -}; -static driver_t atibl_driver = { - "backlight", - atibl_methods, - sizeof(struct atibl_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(backlight, atibl_driver, atibl_methods, + sizeof(struct atibl_softc)); + DRIVER_MODULE(atibl, vgapci, atibl_driver, 0, 0); static void diff --git a/sys/powerpc/powermac/cpcht.c b/sys/powerpc/powermac/cpcht.c index 138aefda5cdb34..e26c70d549d253 100644 --- a/sys/powerpc/powermac/cpcht.c +++ b/sys/powerpc/powermac/cpcht.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include #include @@ -113,7 +113,7 @@ static device_method_t cpcht_methods[] = { struct cpcht_irq { enum { IRQ_NONE, IRQ_HT, IRQ_MSI, IRQ_INTERNAL - } irq_type; + } irq_type; int ht_source; @@ -287,7 +287,7 @@ cpcht_configure_htbridge(device_t dev, phandle_t child) sc->htirq_map[irq].irq_type = IRQ_HT; sc->htirq_map[irq].ht_source = i; - sc->htirq_map[irq].ht_base = sc->sc_data + + sc->htirq_map[irq].ht_base = sc->sc_data + (((((s & 0x1f) << 3) | (f & 0x07)) << 8) | (ptr)); PCIB_WRITE_CONFIG(dev, b, s, f, @@ -298,13 +298,13 @@ cpcht_configure_htbridge(device_t dev, phandle_t child) /* * Apple uses a non-compliant IO/APIC that differs - * in how we signal EOIs. Check if this device was + * in how we signal EOIs. Check if this device was * made by Apple, and act accordingly. */ vend = PCIB_READ_CONFIG(dev, b, s, f, PCIR_DEVVENDOR, 4); if ((vend & 0xffff) == 0x106b) - sc->htirq_map[irq].apple_eoi = + sc->htirq_map[irq].apple_eoi = (sc->htirq_map[irq].ht_base - ptr) + 0x60; } } @@ -318,7 +318,7 @@ cpcht_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, vm_offset_t caoff; sc = device_get_softc(dev); - caoff = sc->sc_data + + caoff = sc->sc_data + (((((slot & 0x1f) << 3) | (func & 0x07)) << 8) | reg); if (bus == 0 && (!(sc->sc_populated_slots & (1 << slot)) || func > 0)) @@ -350,7 +350,7 @@ cpcht_write_config(device_t dev, u_int bus, u_int slot, u_int func, vm_offset_t caoff; sc = device_get_softc(dev); - caoff = sc->sc_data + + caoff = sc->sc_data + (((((slot & 0x1f) << 3) | (func & 0x07)) << 8) | reg); if (bus == 0 && (!(sc->sc_populated_slots & (1 << slot)) || func > 0)) @@ -520,16 +520,11 @@ static device_method_t openpic_cpcht_methods[] = { DEVMETHOD(device_attach, openpic_cpcht_attach), /* PIC interface */ - DEVMETHOD(pic_bind, openpic_bind), DEVMETHOD(pic_config, openpic_cpcht_config), - DEVMETHOD(pic_dispatch, openpic_dispatch), DEVMETHOD(pic_enable, openpic_cpcht_enable), DEVMETHOD(pic_eoi, openpic_cpcht_eoi), - DEVMETHOD(pic_ipi, openpic_ipi), - DEVMETHOD(pic_mask, openpic_mask), - DEVMETHOD(pic_unmask, openpic_cpcht_unmask), - { 0, 0 }, + DEVMETHOD_END }; struct openpic_cpcht_softc { @@ -538,11 +533,8 @@ struct openpic_cpcht_softc { struct mtx sc_ht_mtx; }; -static driver_t openpic_cpcht_driver = { - "htpic", - openpic_cpcht_methods, - sizeof(struct openpic_cpcht_softc), -}; +PRIVATE_DEFINE_CLASSN(htpic, openpic_cpcht_driver, openpic_cpcht_methods, + sizeof(struct openpic_cpcht_softc), openpic_class); EARLY_DRIVER_MODULE(openpic, unin, openpic_cpcht_driver, 0, 0, BUS_PASS_INTERRUPT); @@ -565,6 +557,7 @@ openpic_cpcht_attach(device_t dev) struct openpic_cpcht_softc *sc; phandle_t node; int err, irq; + pic_config_t *openpic_config; node = ofw_bus_get_node(dev); err = openpic_common_attach(dev, node); @@ -582,10 +575,11 @@ openpic_cpcht_attach(device_t dev) * Interrupts 0-3 are internally sourced and are level triggered * active low. Interrupts 4-123 are connected to a pulse generator * and should be programmed as edge triggered low-to-high. - * + * * IBM CPC945 Manual, Section 9.3. */ + openpic_config = KOBJOPLOOKUP(openpic_class.ops, pic_config); for (irq = 0; irq < 4; irq++) openpic_config(dev, irq, INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW); for (irq = 4; irq < 124; irq++) @@ -631,7 +625,7 @@ openpic_cpcht_config(device_t dev, u_int irq, enum intr_trigger trig, /* Mask the IRQ while we fiddle settings */ out32rb(cpcht_irqmap[irq].ht_base + 4, ht_irq | HTAPIC_MASK); - + /* Program the interrupt sense */ ht_irq &= ~(HTAPIC_TRIGGER_LEVEL | HTAPIC_REQUEST_EOI); if (trig == INTR_TRIGGER_EDGE) { @@ -652,7 +646,7 @@ openpic_cpcht_enable(device_t dev, u_int irq, u_int vec, void **priv) struct openpic_cpcht_softc *sc; uint32_t ht_irq; - openpic_enable(dev, irq, vec, priv); + KOBJOPLOOKUP(openpic_class.ops, pic_enable)(dev, irq, vec, priv); sc = device_get_softc(dev); @@ -671,7 +665,7 @@ openpic_cpcht_enable(device_t dev, u_int irq, u_int vec, void **priv) mtx_unlock_spin(&sc->sc_ht_mtx); } - + openpic_cpcht_eoi(dev, irq, *priv); } @@ -681,7 +675,7 @@ openpic_cpcht_unmask(device_t dev, u_int irq, void *priv) struct openpic_cpcht_softc *sc; uint32_t ht_irq; - openpic_unmask(dev, irq, priv); + KOBJOPLOOKUP(openpic_class.ops, pic_unmask)(dev, irq, priv); sc = device_get_softc(dev); @@ -735,5 +729,5 @@ openpic_cpcht_eoi(device_t dev, u_int irq, void *priv) } } - openpic_eoi(dev, irq, priv); + KOBJOPLOOKUP(openpic_class.ops, pic_eoi)(dev, irq, priv); } diff --git a/sys/powerpc/powermac/cuda.c b/sys/powerpc/powermac/cuda.c index d4c3472e5a5e60..077de90a1acd10 100644 --- a/sys/powerpc/powermac/cuda.c +++ b/sys/powerpc/powermac/cuda.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include #include @@ -104,11 +104,8 @@ static device_method_t cuda_methods[] = { DEVMETHOD_END }; -static driver_t cuda_driver = { - "cuda", - cuda_methods, - sizeof(struct cuda_softc), -}; +PRIVATE_DEFINE_CLASSN(cuda, cuda_driver, cuda_methods, + sizeof(struct cuda_softc)); DRIVER_MODULE(cuda, macio, cuda_driver, 0, 0); DRIVER_MODULE(adb, cuda, adb_driver, 0, 0); diff --git a/sys/powerpc/powermac/fcu.c b/sys/powerpc/powermac/fcu.c index 0b3ee6f375be38..8c1034ebe6f91f 100644 --- a/sys/powerpc/powermac/fcu.c +++ b/sys/powerpc/powermac/fcu.c @@ -118,15 +118,12 @@ static device_method_t fcu_methods[] = { /* Device interface */ DEVMETHOD(device_probe, fcu_probe), DEVMETHOD(device_attach, fcu_attach), - { 0, 0 }, -}; -static driver_t fcu_driver = { - "fcu", - fcu_methods, - sizeof(struct fcu_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(fcu, fcu_driver, fcu_methods, sizeof(struct fcu_softc)); + DRIVER_MODULE(fcu, iicbus, fcu_driver, 0, 0); static MALLOC_DEFINE(M_FCU, "fcu", "FCU Sensor Information"); diff --git a/sys/powerpc/powermac/grackle.c b/sys/powerpc/powermac/grackle.c index cddf66e6d5f13c..f88c2e4e108135 100644 --- a/sys/powerpc/powermac/grackle.c +++ b/sys/powerpc/powermac/grackle.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include #include @@ -305,13 +305,10 @@ static device_method_t grackle_hb_methods[] = { /* Device interface */ DEVMETHOD(device_probe, grackle_hb_probe), DEVMETHOD(device_attach, grackle_hb_attach), - { 0, 0 } -}; -static driver_t grackle_hb_driver = { - "grackle_hb", - grackle_hb_methods, - 1, + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(grackle_hb, grackle_hb_driver, grackle_hb_methods, 1); + DRIVER_MODULE(grackle_hb, pci, grackle_hb_driver, 0, 0); diff --git a/sys/powerpc/powermac/hrowpic.c b/sys/powerpc/powermac/hrowpic.c index cd1a1f17694f8c..8b66f0419b8d87 100644 --- a/sys/powerpc/powermac/hrowpic.c +++ b/sys/powerpc/powermac/hrowpic.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include #include @@ -83,14 +83,11 @@ static device_method_t hrowpic_methods[] = { DEVMETHOD(pic_mask, hrowpic_mask), DEVMETHOD(pic_unmask, hrowpic_unmask), - { 0, 0 }, + DEVMETHOD_END }; -static driver_t hrowpic_driver = { - "hrowpic", - hrowpic_methods, - sizeof(struct hrowpic_softc) -}; +PRIVATE_DEFINE_CLASSN(hrowpic, hrowpic_driver, hrowpic_methods, + sizeof(struct hrowpic_softc), pic_hw_class); DRIVER_MODULE(hrowpic, macio, hrowpic_driver, 0, 0); diff --git a/sys/powerpc/powermac/kiic.c b/sys/powerpc/powermac/kiic.c index 1948b3248db775..76299948af8cdc 100644 --- a/sys/powerpc/powermac/kiic.c +++ b/sys/powerpc/powermac/kiic.c @@ -135,15 +135,13 @@ static device_method_t kiic_methods[] = { /* ofw_bus interface */ DEVMETHOD(ofw_bus_get_node, kiic_get_node), - { 0, 0 } -}; -static driver_t kiic_driver = { - "iichb", - kiic_methods, - sizeof(struct kiic_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(iichb, kiic_driver, kiic_methods, + sizeof(struct kiic_softc)); + DRIVER_MODULE(kiic, macio, kiic_driver, 0, 0); DRIVER_MODULE(kiic, unin, kiic_driver, 0, 0); diff --git a/sys/powerpc/powermac/macgpio.c b/sys/powerpc/powermac/macgpio.c index b17ba3f64128c5..6e4cb07b097aed 100644 --- a/sys/powerpc/powermac/macgpio.c +++ b/sys/powerpc/powermac/macgpio.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include @@ -111,15 +111,13 @@ static device_method_t macgpio_methods[] = { DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - { 0, 0 } -}; -static driver_t macgpio_pci_driver = { - "macgpio", - macgpio_methods, - sizeof(struct macgpio_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(macgpio, macgpio_pci_driver, macgpio_methods, + sizeof(struct macgpio_softc)); + EARLY_DRIVER_MODULE(macgpio, macio, macgpio_pci_driver, 0, 0, BUS_PASS_BUS); struct macgpio_devinfo { diff --git a/sys/powerpc/powermac/macio.c b/sys/powerpc/powermac/macio.c index fbd99a1ac87d90..e20c42ad8dd6da 100644 --- a/sys/powerpc/powermac/macio.c +++ b/sys/powerpc/powermac/macio.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include @@ -137,15 +137,13 @@ static device_method_t macio_methods[] = { DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - { 0, 0 } -}; -static driver_t macio_pci_driver = { - "macio", - macio_methods, - sizeof(struct macio_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(macio, macio_pci_driver, macio_methods, + sizeof(struct macio_softc)); + EARLY_DRIVER_MODULE(macio, pci, macio_pci_driver, 0, 0, BUS_PASS_BUS); /* diff --git a/sys/powerpc/powermac/nvbl.c b/sys/powerpc/powermac/nvbl.c index 79e41c66b34d50..16dcf544519946 100644 --- a/sys/powerpc/powermac/nvbl.c +++ b/sys/powerpc/powermac/nvbl.c @@ -67,15 +67,13 @@ static device_method_t nvbl_methods[] = { DEVMETHOD(device_identify, nvbl_identify), DEVMETHOD(device_probe, nvbl_probe), DEVMETHOD(device_attach, nvbl_attach), - {0, 0}, -}; -static driver_t nvbl_driver = { - "backlight", - nvbl_methods, - sizeof(struct nvbl_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(backlight, nvbl_driver, nvbl_methods, + sizeof(struct nvbl_softc)); + DRIVER_MODULE(nvbl, vgapci, nvbl_driver, 0, 0); static void diff --git a/sys/powerpc/powermac/pmu.c b/sys/powerpc/powermac/pmu.c index de1f09805396a0..39e61255d23924 100644 --- a/sys/powerpc/powermac/pmu.c +++ b/sys/powerpc/powermac/pmu.c @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include #include @@ -145,11 +145,7 @@ static device_method_t pmu_methods[] = { DEVMETHOD_END }; -static driver_t pmu_driver = { - "pmu", - pmu_methods, - sizeof(struct pmu_softc), -}; +PRIVATE_DEFINE_CLASSN(pmu, pmu_driver, pmu_methods, sizeof(struct pmu_softc)); EARLY_DRIVER_MODULE(pmu, macio, pmu_driver, 0, 0, BUS_PASS_RESOURCE); DRIVER_MODULE(adb, pmu, adb_driver, 0, 0); @@ -161,15 +157,12 @@ static device_method_t pmuextint_methods[] = { /* Device interface */ DEVMETHOD(device_probe, pmuextint_probe), DEVMETHOD(device_attach, pmuextint_attach), - {0,0} -}; -static driver_t pmuextint_driver = { - "pmuextint", - pmuextint_methods, - 0 + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(pmuextint, pmuextint_driver, pmuextint_methods, 0); + EARLY_DRIVER_MODULE(pmuextint, macgpio, pmuextint_driver, 0, 0, BUS_PASS_RESOURCE); diff --git a/sys/powerpc/powermac/pswitch.c b/sys/powerpc/powermac/pswitch.c index 2ca732f362b4ab..219a6da71722e2 100644 --- a/sys/powerpc/powermac/pswitch.c +++ b/sys/powerpc/powermac/pswitch.c @@ -59,15 +59,13 @@ static device_method_t pswitch_methods[] = { /* Device interface */ DEVMETHOD(device_probe, pswitch_probe), DEVMETHOD(device_attach, pswitch_attach), - { 0, 0 } -}; -static driver_t pswitch_driver = { - "pswitch", - pswitch_methods, - sizeof(struct pswitch_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(pswitch, pswitch_driver, pswitch_methods, + sizeof(struct pswitch_softc)); + EARLY_DRIVER_MODULE(pswitch, macgpio, pswitch_driver, 0, 0, BUS_PASS_RESOURCE); static int diff --git a/sys/powerpc/powermac/smu.c b/sys/powerpc/powermac/smu.c index 8107ef8ef79025..d199565f08d0c3 100644 --- a/sys/powerpc/powermac/smu.c +++ b/sys/powerpc/powermac/smu.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include @@ -201,14 +201,10 @@ static device_method_t smu_methods[] = { DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - { 0, 0 }, + DEVMETHOD_END }; -static driver_t smu_driver = { - "smu", - smu_methods, - sizeof(struct smu_softc) -}; +PRIVATE_DEFINE_CLASSN(smu, smu_driver, smu_methods, sizeof(struct smu_softc)); DRIVER_MODULE(smu, ofwbus, smu_driver, 0, 0); static MALLOC_DEFINE(M_SMU, "smu", "SMU Sensor Information"); @@ -618,15 +614,12 @@ static device_method_t doorbell_methods[] = { /* Device interface */ DEVMETHOD(device_probe, doorbell_probe), DEVMETHOD(device_attach, doorbell_attach), - { 0, 0 }, -}; -static driver_t doorbell_driver = { - "smudoorbell", - doorbell_methods, - 0 + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(smudoorbell, doorbell_driver, doorbell_methods, 0); + EARLY_DRIVER_MODULE(smudoorbell, macgpio, doorbell_driver, 0, 0, BUS_PASS_SUPPORTDEV); @@ -1397,7 +1390,8 @@ static device_method_t smuiic_methods[] = { /* ofw_bus interface */ DEVMETHOD(ofw_bus_get_node, smuiic_get_node), - { 0, 0 } + + DEVMETHOD_END }; struct smuiic_softc { @@ -1406,11 +1400,8 @@ struct smuiic_softc { int sc_busno; }; -static driver_t smuiic_driver = { - "iichb", - smuiic_methods, - sizeof(struct smuiic_softc) -}; +PRIVATE_DEFINE_CLASSN(iichb, smuiic_driver, smuiic_methods, + sizeof(struct smuiic_softc)); DRIVER_MODULE(smuiic, smu, smuiic_driver, 0, 0); diff --git a/sys/powerpc/powermac/smusat.c b/sys/powerpc/powermac/smusat.c index 5639daa2850104..7bafb8e65da4fb 100644 --- a/sys/powerpc/powermac/smusat.c +++ b/sys/powerpc/powermac/smusat.c @@ -68,7 +68,8 @@ static device_method_t smusat_methods[] = { /* Device interface */ DEVMETHOD(device_probe, smusat_probe), DEVMETHOD(device_attach, smusat_attach), - { 0, 0 }, + + DEVMETHOD_END }; struct smusat_softc { @@ -79,11 +80,8 @@ struct smusat_softc { time_t sc_last_update; }; -static driver_t smusat_driver = { - "smusat", - smusat_methods, - sizeof(struct smusat_softc) -}; +PRIVATE_DEFINE_CLASSN(smusat, smusat_driver, smusat_methods, + sizeof(struct smusat_softc)); DRIVER_MODULE(smusat, iicbus, smusat_driver, 0, 0); diff --git a/sys/powerpc/powermac/tbgpio.c b/sys/powerpc/powermac/tbgpio.c index e4a680ceee813a..c83093c0e84206 100644 --- a/sys/powerpc/powermac/tbgpio.c +++ b/sys/powerpc/powermac/tbgpio.c @@ -47,6 +47,7 @@ static device_method_t tbgpio_methods[] = { /* Device interface */ DEVMETHOD(device_probe, tbgpio_probe), DEVMETHOD(device_attach, tbgpio_attach), + DEVMETHOD_END }; @@ -55,11 +56,8 @@ struct tbgpio_softc { uint32_t sc_mask; }; -static driver_t tbgpio_driver = { - "tbgpio", - tbgpio_methods, - sizeof(struct tbgpio_softc) -}; +PRIVATE_DEFINE_CLASSN(tbgpio, tbgpio_driver, tbgpio_methods, + sizeof(struct tbgpio_softc)); EARLY_DRIVER_MODULE(tbgpio, macgpio, tbgpio_driver, 0, 0, BUS_PASS_CPU); diff --git a/sys/powerpc/powermac/uninorth.c b/sys/powerpc/powermac/uninorth.c index 8f3d567202c7fa..d5b3cc98b41648 100644 --- a/sys/powerpc/powermac/uninorth.c +++ b/sys/powerpc/powermac/uninorth.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include #include @@ -136,15 +136,13 @@ static device_method_t unin_chip_methods[] = { DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - { 0, 0 } -}; -static driver_t unin_chip_driver = { - "unin", - unin_chip_methods, - sizeof(struct unin_chip_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(unin, unin_chip_driver, unin_chip_methods, + sizeof(struct unin_chip_softc)); + /* * Assume there is only one unin chip in a PowerMac, so that pmu.c functions can * suspend the chip after the whole rest of the device tree is suspended, not diff --git a/sys/powerpc/powermac/uninorthpci.c b/sys/powerpc/powermac/uninorthpci.c index 3df853080f0fdb..022610c86a90f3 100644 --- a/sys/powerpc/powermac/uninorthpci.c +++ b/sys/powerpc/powermac/uninorthpci.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/powerpc/powermac/vcoregpio.c b/sys/powerpc/powermac/vcoregpio.c index a3ec85989f7115..62bfb79a5ecc33 100644 --- a/sys/powerpc/powermac/vcoregpio.c +++ b/sys/powerpc/powermac/vcoregpio.c @@ -51,15 +51,12 @@ static device_method_t vcoregpio_methods[] = { /* Device interface */ DEVMETHOD(device_probe, vcoregpio_probe), DEVMETHOD(device_attach, vcoregpio_attach), - { 0, 0 }, -}; -static driver_t vcoregpio_driver = { - "vcoregpio", - vcoregpio_methods, - 0 + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(vcoregpio, vcoregpio_driver, vcoregpio_methods, 0); + DRIVER_MODULE(vcoregpio, macgpio, vcoregpio_driver, 0, 0); static int diff --git a/sys/powerpc/powernv/opal_console.c b/sys/powerpc/powernv/opal_console.c index d284ad1342c8ea..9b58d43dff821c 100644 --- a/sys/powerpc/powernv/opal_console.c +++ b/sys/powerpc/powernv/opal_console.c @@ -104,11 +104,8 @@ static device_method_t uart_opal_methods[] = { DEVMETHOD_END }; -static driver_t uart_opal_driver = { - "uart", - uart_opal_methods, - sizeof(struct uart_opal_softc), -}; +PRIVATE_DEFINE_CLASSN(uart, uart_opal_driver, uart_opal_methods, + sizeof(struct uart_opal_softc)); DRIVER_MODULE(uart_opal, opalcons, uart_opal_driver, 0, 0); @@ -604,10 +601,6 @@ static device_method_t opalcons_methods[] = { DEVMETHOD_END }; -static driver_t opalcons_driver = { - "opalcons", - opalcons_methods, - 0 -}; +PRIVATE_DEFINE_CLASSN(opalcons, opalcons_driver, opalcons_methods, 0); DRIVER_MODULE(opalcons, opal, opalcons_driver, 0, 0); diff --git a/sys/powerpc/powernv/opal_dev.c b/sys/powerpc/powernv/opal_dev.c index ab94e0ac8e3679..675eac76e0a3cc 100644 --- a/sys/powerpc/powernv/opal_dev.c +++ b/sys/powerpc/powernv/opal_dev.c @@ -85,11 +85,7 @@ static device_method_t opaldev_methods[] = { DEVMETHOD_END }; -static driver_t opaldev_driver = { - "opal", - opaldev_methods, - 0 -}; +PRIVATE_DEFINE_CLASSN(opal, opaldev_driver, opaldev_methods, 0); EARLY_DRIVER_MODULE(opaldev, ofwbus, opaldev_driver, 0, 0, BUS_PASS_BUS); diff --git a/sys/powerpc/powernv/opal_flash.c b/sys/powerpc/powernv/opal_flash.c index 144de20da5d3bd..c8976e17e920f4 100644 --- a/sys/powerpc/powernv/opal_flash.c +++ b/sys/powerpc/powernv/opal_flash.c @@ -89,11 +89,8 @@ static device_method_t opalflash_methods[] = { DEVMETHOD_END }; -static driver_t opalflash_driver = { - "opalflash", - opalflash_methods, - sizeof(struct opalflash_softc) -}; +PRIVATE_DEFINE_CLASSN(opalflash, opalflash_driver, opalflash_methods, + sizeof(struct opalflash_softc)); DRIVER_MODULE(opalflash, opal, opalflash_driver, 0, 0); diff --git a/sys/powerpc/powernv/opal_i2c.c b/sys/powerpc/powernv/opal_i2c.c index 4e3bc4a7384a74..bd2b67203ef106 100644 --- a/sys/powerpc/powernv/opal_i2c.c +++ b/sys/powerpc/powernv/opal_i2c.c @@ -105,11 +105,8 @@ static device_method_t opal_i2c_methods[] = { mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->dev), \ "i2c", MTX_DEF) -static driver_t opal_i2c_driver = { - "iichb", - opal_i2c_methods, - sizeof(struct opal_i2c_softc), -}; +PRIVATE_DEFINE_CLASSN(iichb, opal_i2c_driver, opal_i2c_methods, + sizeof(struct opal_i2c_softc)); static int opal_i2c_probe(device_t dev) diff --git a/sys/powerpc/powernv/opal_nvram.c b/sys/powerpc/powernv/opal_nvram.c index 571dc82fbc9197..95aee1297f1f7b 100644 --- a/sys/powerpc/powernv/opal_nvram.c +++ b/sys/powerpc/powernv/opal_nvram.c @@ -82,15 +82,13 @@ static device_method_t opal_nvram_methods[] = { DEVMETHOD(device_probe, opal_nvram_probe), DEVMETHOD(device_attach, opal_nvram_attach), DEVMETHOD(device_detach, opal_nvram_detach), - { 0, 0 } -}; -static driver_t opal_nvram_driver = { - "opal_nvram", - opal_nvram_methods, - sizeof(struct opal_nvram_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(opal_nvram, opal_nvram_driver, opal_nvram_methods, + sizeof(struct opal_nvram_softc)); + DRIVER_MODULE(opal_nvram, opal, opal_nvram_driver, 0, 0); /* diff --git a/sys/powerpc/powernv/opal_pci.c b/sys/powerpc/powernv/opal_pci.c index 8dee2c45c089d7..7916ac7ea245a4 100644 --- a/sys/powerpc/powernv/opal_pci.c +++ b/sys/powerpc/powernv/opal_pci.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include @@ -165,8 +165,8 @@ struct opalpci_softc { struct resource *r_reg; }; -DEFINE_CLASS_1(pcib, opalpci_driver, opalpci_methods, - sizeof(struct opalpci_softc), ofw_pcib_driver); +PRIVATE_DEFINE_CLASSN(pcib, opalpci_driver, opalpci_methods, + sizeof(struct opalpci_softc), pic_hw_class, ofw_pcib_driver); EARLY_DRIVER_MODULE(opalpci, ofwbus, opalpci_driver, 0, 0, BUS_PASS_BUS); static int diff --git a/sys/powerpc/powernv/opal_sensor.c b/sys/powerpc/powernv/opal_sensor.c index 5e99884e83e07e..2cd4f3ba880ef8 100644 --- a/sys/powerpc/powernv/opal_sensor.c +++ b/sys/powerpc/powernv/opal_sensor.c @@ -248,11 +248,8 @@ static device_method_t opal_sensor_methods[] = { DEVMETHOD_END }; -static driver_t opal_sensor_driver = { - "opal_sensor", - opal_sensor_methods, - sizeof(struct opal_sensor_softc) -}; +PRIVATE_DEFINE_CLASSN(opal_sensor, opal_sensor_driver, opal_sensor_methods, + sizeof(struct opal_sensor_softc)); DRIVER_MODULE(opal_sensor, opalsens, opal_sensor_driver, NULL, NULL); @@ -318,10 +315,6 @@ static device_method_t opalsens_methods[] = { DEVMETHOD_END }; -static driver_t opalsens_driver = { - "opalsens", - opalsens_methods, - 0 -}; +PRIVATE_DEFINE_CLASSN(opalsens, opalsens_driver, opalsens_methods, 0); DRIVER_MODULE(opalsens, opal, opalsens_driver, NULL, NULL); diff --git a/sys/powerpc/powernv/platform_powernv.c b/sys/powerpc/powernv/platform_powernv.c index 50af24794e6932..5ca839f31d49bf 100644 --- a/sys/powerpc/powernv/platform_powernv.c +++ b/sys/powerpc/powernv/platform_powernv.c @@ -99,7 +99,8 @@ static platform_method_t powernv_methods[] = { PLATFORMMETHOD(platform_node_numa_domain, powernv_node_numa_domain), PLATFORMMETHOD(platform_reset, powernv_reset), - { 0, 0 } + + PLATFORMMETHOD_END }; static platform_def_t powernv_platform = { diff --git a/sys/powerpc/powernv/xive.c b/sys/powerpc/powernv/xive.c index 384ff4ef20d262..429c824819404c 100644 --- a/sys/powerpc/powernv/xive.c +++ b/sys/powerpc/powernv/xive.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include #include @@ -188,17 +188,10 @@ struct xive_cpu { uint32_t chip; }; -static driver_t xive_driver = { - "xive", - xive_methods, - sizeof(struct xive_softc) -}; +PRIVATE_DEFINE_CLASSN(xive, xive_driver, xive_methods, + sizeof(struct xive_softc), pic_hw_class); -static driver_t xics_driver = { - "xivevc", - xics_methods, - 0 -}; +PRIVATE_DEFINE_CLASSN(xivevc, xics_driver, xics_methods, 0, pic_hw_class); EARLY_DRIVER_MODULE(xive, ofwbus, xive_driver, 0, 0, BUS_PASS_INTERRUPT - 1); EARLY_DRIVER_MODULE(xivevc, ofwbus, xics_driver, 0, 0, BUS_PASS_INTERRUPT); diff --git a/sys/powerpc/powerpc/autoconf.c b/sys/powerpc/powerpc/autoconf.c index a2f48c2da49c36..d84ddbc3eb7aea 100644 --- a/sys/powerpc/powerpc/autoconf.c +++ b/sys/powerpc/powerpc/autoconf.c @@ -34,7 +34,7 @@ #include #include -#include +#include #ifdef DEV_ISA extern void isa_probe_children(device_t dev); diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c index 34dcea8de9ee83..9ead5212d8b08c 100644 --- a/sys/powerpc/powerpc/busdma_machdep.c +++ b/sys/powerpc/powerpc/busdma_machdep.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -53,6 +52,7 @@ #include #include #include +#include #include #include "iommu_if.h" diff --git a/sys/powerpc/powerpc/clock.c b/sys/powerpc/powerpc/clock.c index b294563706dd47..2d5ae284690c7f 100644 --- a/sys/powerpc/powerpc/clock.c +++ b/sys/powerpc/powerpc/clock.c @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -72,7 +71,7 @@ #include #include -#include +#include #include #include diff --git a/sys/powerpc/powerpc/interrupt.c b/sys/powerpc/powerpc/interrupt.c index c2e79761e1d7cb..90eb5677525451 100644 --- a/sys/powerpc/powerpc/interrupt.c +++ b/sys/powerpc/powerpc/interrupt.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -57,7 +56,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/powerpc/powerpc/intr_machdep.c b/sys/powerpc/powerpc/intr_machdep.c index 6e8cb4febf2882..488bab4992ac06 100644 --- a/sys/powerpc/powerpc/intr_machdep.c +++ b/sys/powerpc/powerpc/intr_machdep.c @@ -66,7 +66,6 @@ #include #include #include -#include #include #include #include @@ -78,7 +77,7 @@ #include #include -#include +#include #include #include #include @@ -88,10 +87,9 @@ static MALLOC_DEFINE(M_INTR, "intr", "interrupt handler data"); struct powerpc_intr { - struct intr_event *event; + struct intr_event event; long *cntp; void *priv; /* PIC-private data */ - device_t pic; u_int irq; u_int intline; u_int vector; @@ -144,6 +142,8 @@ u_int num_io_irqs = 256; device_t root_pic; #ifdef SMP +device_t ipi_pic; + static void *ipi_cookie; #endif @@ -194,17 +194,70 @@ intr_init_sources(void *arg __unused) SYSINIT(intr_init_sources, SI_SUB_KLD, SI_ORDER_ANY, intr_init_sources, NULL); #ifdef SMP +static void +powerpc_ipi_eoi(device_t pic, interrupt_t *i) +{ + + /* see 0c50edff52f2, skip for IPIs */ +} + +static void +powerpc_ipi_pre_ithread(device_t pic, interrupt_t *i) +{ + + PIC_MASK(root_pic, i->intline, i->priv); + PIC_EOI(root_pic, i->intline, i->priv); +} + +static void +powerpc_ipi_post_ithread(device_t pic, interrupt_t *i) +{ + + PIC_UNMASK(root_pic, i->intline, i->priv); +} + +static int +powerpc_ipi_assign_intr_cpu(device_t pic, interrupt_t *i, u_int cpu) +{ + + return (EOPNOTSUPP); +} + +static device_method_t pic_ipi_funcs[] = { + DEVMETHOD(intr_event_pre_ithread, powerpc_ipi_pre_ithread), + DEVMETHOD(intr_event_post_ithread, powerpc_ipi_post_ithread), + DEVMETHOD(intr_event_post_filter, powerpc_ipi_eoi), + DEVMETHOD(intr_event_assign_cpu, powerpc_ipi_assign_intr_cpu), + + DEVMETHOD_END +}; + +DEFINE_CLASS_0(pic_ipi, pic_ipi_class, pic_ipi_funcs, 0); + static void smp_intr_init(void *dummy __unused) { struct powerpc_intr *i; - int vector; + device_t root; + int vector, error; for (vector = 0; vector < nvectors; vector++) { i = powerpc_intrs[vector]; - if (i != NULL && i->event != NULL && i->pic == root_pic) - PIC_BIND(i->pic, i->intline, i->pi_cpuset, &i->priv); + if (i != NULL && !CK_SLIST_EMPTY(&i->event.ie_handlers) && + i->event.ie_pic == root_pic) + PIC_BIND(i->event.ie_pic, i->intline, i->pi_cpuset, &i->priv); } + + root = device_lookup_by_name("root0"); + if (root == NULL) + panic("%s: unable to find root bus", __func__); + ipi_pic = bus_generic_add_child(root, BUS_PASS_ORDER_FIRST, "ipi", 0); + if (ipi_pic == NULL) + panic("%s: failed to create IPI device \"ipi0\"", __func__); + error = device_set_driver(ipi_pic, &pic_ipi_class); + if (error != 0) + panic("%s: failed to set IPI driver for ipi0 error=%d", + __func__, error); } SYSINIT(smp_intr_init, SI_SUB_SMP, SI_ORDER_ANY, smp_intr_init, NULL); #endif @@ -226,7 +279,7 @@ intr_lookup(u_int irq) { char intrname[16]; struct powerpc_intr *i, *iscan; - int vector; + int vector, error; mtx_lock(&intr_table_lock); for (vector = 0; vector < nvectors; vector++) { @@ -243,13 +296,11 @@ intr_lookup(u_int irq) return (NULL); } - i->event = NULL; i->cntp = NULL; i->priv = NULL; i->trig = INTR_TRIGGER_CONFORM; i->pol = INTR_POLARITY_CONFORM; i->irq = irq; - i->pic = NULL; i->vector = -1; i->fwcode = 0; i->ipi = 0; @@ -271,12 +322,17 @@ intr_lookup(u_int irq) } if (iscan == NULL && i->vector != -1) { - powerpc_intrs[i->vector] = i; - i->cntindex = atomic_fetchadd_int(&intrcnt_index, 1); - i->cntp = &intrcnt[i->cntindex]; - sprintf(intrname, "irq%u:", i->irq); - intrcnt_setname(intrname, i->cntindex); - nvectors++; + error = intr_event_init(&i->event, NULL, irq, 0, + "irq%u:", irq); + if (error == 0) { + powerpc_intrs[i->vector] = i; + i->cntindex = atomic_fetchadd_int(&intrcnt_index, 1); + i->cntp = &intrcnt[i->cntindex]; + sprintf(intrname, "irq%u:", i->irq); + intrcnt_setname(intrname, i->cntindex); + nvectors++; + } else + i->vector = -1; } mtx_unlock(&intr_table_lock); @@ -305,53 +361,49 @@ powerpc_map_irq(struct powerpc_intr *i) return (EINVAL); i->intline = i->irq - p->base; - i->pic = p->dev; + i->event.ie_pic = p->dev; /* Try a best guess if that failed */ - if (i->pic == NULL) - i->pic = root_pic; + if (i->event.ie_pic == NULL) + i->event.ie_pic = root_pic; return (0); } static void -powerpc_intr_eoi(void *arg) +powerpc_intr_eoi(device_t pic, interrupt_t *i) { - struct powerpc_intr *i = arg; - PIC_EOI(i->pic, i->intline, i->priv); + PIC_EOI(i->event.ie_pic, i->intline, i->priv); } static void -powerpc_intr_pre_ithread(void *arg) +powerpc_intr_pre_ithread(device_t pic, interrupt_t *i) { - struct powerpc_intr *i = arg; - PIC_MASK(i->pic, i->intline, i->priv); - PIC_EOI(i->pic, i->intline, i->priv); + PIC_MASK(i->event.ie_pic, i->intline, i->priv); + PIC_EOI(i->event.ie_pic, i->intline, i->priv); } static void -powerpc_intr_post_ithread(void *arg) +powerpc_intr_post_ithread(device_t pic, interrupt_t *i) { - struct powerpc_intr *i = arg; - PIC_UNMASK(i->pic, i->intline, i->priv); + PIC_UNMASK(i->event.ie_pic, i->intline, i->priv); } static int -powerpc_assign_intr_cpu(void *arg, int cpu) +powerpc_assign_intr_cpu(device_t pic, interrupt_t *i, u_int cpu) { #ifdef SMP - struct powerpc_intr *i = arg; if (cpu == NOCPU) i->pi_cpuset = all_cpus; else CPU_SETOF(cpu, &i->pi_cpuset); - if (!cold && i->pic != NULL && i->pic == root_pic) - PIC_BIND(i->pic, i->intline, i->pi_cpuset, &i->priv); + if (!cold && i->event.ie_pic != NULL && i->event.ie_pic == root_pic) + PIC_BIND(i->event.ie_pic, i->intline, i->pi_cpuset, &i->priv); return (0); #else @@ -359,6 +411,24 @@ powerpc_assign_intr_cpu(void *arg, int cpu) #endif } +static device_method_t pic_base_methods[] = { + DEVMETHOD(intr_event_pre_ithread, powerpc_intr_pre_ithread), + + DEVMETHOD_END +}; + +PUBLIC_DEFINE_CLASSN(pic_base, pic_base_class, pic_base_methods, 0); + +static device_method_t pic_hw_methods[] = { + DEVMETHOD(intr_event_post_ithread, powerpc_intr_post_ithread), + DEVMETHOD(intr_event_post_filter, powerpc_intr_eoi), + DEVMETHOD(intr_event_assign_cpu, powerpc_assign_intr_cpu), + + DEVMETHOD_END +}; + +PUBLIC_DEFINE_CLASSN(pic_hw, pic_hw_class, pic_hw_methods, 0, pic_base_class); + u_int powerpc_register_pic(device_t dev, uint32_t node, u_int irqs, u_int ipis, u_int atpic) @@ -490,14 +560,14 @@ powerpc_enable_intr(void) continue; if (i->trig == INTR_TRIGGER_INVALID) - PIC_TRANSLATE_CODE(i->pic, i->intline, i->fwcode, + PIC_TRANSLATE_CODE(i->event.ie_pic, i->intline, i->fwcode, &i->trig, &i->pol); if (i->trig != INTR_TRIGGER_CONFORM || i->pol != INTR_POLARITY_CONFORM) - PIC_CONFIG(i->pic, i->intline, i->trig, i->pol); + PIC_CONFIG(i->event.ie_pic, i->intline, i->trig, i->pol); - if (i->event != NULL) - PIC_ENABLE(i->pic, i->intline, vector, &i->priv); + if (!CK_SLIST_EMPTY(&i->event.ie_handlers)) + PIC_ENABLE(i->event.ie_pic, i->intline, vector, &i->priv); } return (0); @@ -526,19 +596,15 @@ powerpc_setup_intr_int(const char *name, u_int irq, driver_filter_t filter, if (i == NULL) return (ENOMEM); - if (i->event == NULL) { - error = intr_event_create(&i->event, (void *)i, 0, irq, - powerpc_intr_pre_ithread, powerpc_intr_post_ithread, - (ipi ? NULL : powerpc_intr_eoi), powerpc_assign_intr_cpu, - "irq%u:", irq); - if (error) - return (error); + if (CK_SLIST_EMPTY(&i->event.ie_handlers)) { + if (ipi) + i->event.ie_pic = ipi_pic; enable = 1; } i->ipi = ipi; - error = intr_event_add_handler(i->event, name, filter, handler, arg, + error = intr_event_add_handler(&i->event, name, filter, handler, arg, intr_priority(flags), flags, cookiep); if (error) return (error); @@ -548,7 +614,7 @@ powerpc_setup_intr_int(const char *name, u_int irq, driver_filter_t filter, CPU_COPY(&cpuset_domain[domain], &i->pi_cpuset); } mtx_lock(&intr_table_lock); - intrcnt_setname(i->event->ie_fullname, i->cntindex); + intrcnt_setname(i->event.ie_fullname, i->cntindex); mtx_unlock(&intr_table_lock); if (!cold) { @@ -556,18 +622,18 @@ powerpc_setup_intr_int(const char *name, u_int irq, driver_filter_t filter, if (!error) { if (i->trig == INTR_TRIGGER_INVALID) - PIC_TRANSLATE_CODE(i->pic, i->intline, + PIC_TRANSLATE_CODE(i->event.ie_pic, i->intline, i->fwcode, &i->trig, &i->pol); if (i->trig != INTR_TRIGGER_CONFORM || i->pol != INTR_POLARITY_CONFORM) - PIC_CONFIG(i->pic, i->intline, i->trig, i->pol); + PIC_CONFIG(i->event.ie_pic, i->intline, i->trig, i->pol); - if (i->pic == root_pic) - PIC_BIND(i->pic, i->intline, i->pi_cpuset, &i->priv); + if (i->event.ie_pic == root_pic) + PIC_BIND(i->event.ie_pic, i->intline, i->pi_cpuset, &i->priv); if (enable) - PIC_ENABLE(i->pic, i->intline, i->vector, + PIC_ENABLE(i->event.ie_pic, i->intline, i->vector, &i->priv); } } @@ -591,7 +657,7 @@ powerpc_bind_intr(u_int irq, u_char cpu) if (i == NULL) return (ENOMEM); - return (intr_event_bind(i->event, cpu)); + return (intr_event_bind(&i->event, cpu)); } #endif @@ -608,10 +674,10 @@ powerpc_fw_config_intr(int irq, int sense_code) i->pol = INTR_POLARITY_CONFORM; i->fwcode = sense_code; - if (!cold && i->pic != NULL) { - PIC_TRANSLATE_CODE(i->pic, i->intline, i->fwcode, &i->trig, + if (!cold && i->event.ie_pic != NULL) { + PIC_TRANSLATE_CODE(i->event.ie_pic, i->intline, i->fwcode, &i->trig, &i->pol); - PIC_CONFIG(i->pic, i->intline, i->trig, i->pol); + PIC_CONFIG(i->event.ie_pic, i->intline, i->trig, i->pol); } return (0); @@ -629,8 +695,8 @@ powerpc_config_intr(int irq, enum intr_trigger trig, enum intr_polarity pol) i->trig = trig; i->pol = pol; - if (!cold && i->pic != NULL) - PIC_CONFIG(i->pic, i->intline, trig, pol); + if (!cold && i->event.ie_pic != NULL) + PIC_CONFIG(i->event.ie_pic, i->intline, trig, pol); return (0); } @@ -647,15 +713,16 @@ powerpc_dispatch_intr(u_int vector, struct trapframe *tf) (*i->cntp)++; - ie = i->event; - KASSERT(ie != NULL, ("%s: interrupt without an event", __func__)); + ie = &i->event; + KASSERT(mtx_initialized(&ie->ie_lock), + ("%s: interrupt without an event", __func__)); /* * IPIs are magical and need to be EOI'ed before filtering. * This prevents races in IPI handling. */ if (i->ipi) - PIC_EOI(i->pic, i->intline, i->priv); + PIC_EOI(i->event.ie_pic, i->intline, i->priv); if (intr_event_handle(ie, tf) != 0) { goto stray; @@ -672,7 +739,7 @@ powerpc_dispatch_intr(u_int vector, struct trapframe *tf) } } if (i != NULL) - PIC_MASK(i->pic, i->intline, i->priv); + PIC_MASK(i->event.ie_pic, i->intline, i->priv); } void @@ -681,10 +748,10 @@ powerpc_intr_mask(u_int irq) struct powerpc_intr *i; i = intr_lookup(irq); - if (i == NULL || i->pic == NULL) + if (i == NULL || i->event.ie_pic == NULL) return; - PIC_MASK(i->pic, i->intline, i->priv); + PIC_MASK(i->event.ie_pic, i->intline, i->priv); } void @@ -693,8 +760,8 @@ powerpc_intr_unmask(u_int irq) struct powerpc_intr *i; i = intr_lookup(irq); - if (i == NULL || i->pic == NULL) + if (i == NULL || i->event.ie_pic == NULL) return; - PIC_UNMASK(i->pic, i->intline, i->priv); + PIC_UNMASK(i->event.ie_pic, i->intline, i->priv); } diff --git a/sys/powerpc/powerpc/mp_machdep.c b/sys/powerpc/powerpc/mp_machdep.c index d6d140aa0ea294..bca0960d7333a4 100644 --- a/sys/powerpc/powerpc/mp_machdep.c +++ b/sys/powerpc/powerpc/mp_machdep.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/powerpc/powerpc/nexus.c b/sys/powerpc/powerpc/nexus.c index 18b8fc57114f80..d3194418b4419d 100644 --- a/sys/powerpc/powerpc/nexus.c +++ b/sys/powerpc/powerpc/nexus.c @@ -54,7 +54,7 @@ #include #include -#include +#include #include #include diff --git a/sys/powerpc/powerpc/openpic.c b/sys/powerpc/powerpc/openpic.c index 0c717aaf6060c2..5d999aaa1b2867 100644 --- a/sys/powerpc/powerpc/openpic.c +++ b/sys/powerpc/powerpc/openpic.c @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include #include @@ -225,7 +225,7 @@ openpic_common_attach(device_t dev, uint32_t node) * PIC I/F methods */ -void +static void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **priv __unused) { struct openpic_softc *sc; @@ -260,7 +260,7 @@ openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **priv __unused) openpic_write(sc, OPENPIC_IDEST(irq), mask); } -void +static void openpic_config(device_t dev, u_int irq, enum intr_trigger trig, enum intr_polarity pol) { @@ -280,18 +280,7 @@ openpic_config(device_t dev, u_int irq, enum intr_trigger trig, openpic_write(sc, OPENPIC_SRC_VECTOR(irq), x); } -static int -openpic_intr(void *arg) -{ - device_t dev = (device_t)(arg); - - /* XXX Cascaded PICs do not pass non-NULL trapframes! */ - openpic_dispatch(dev, NULL); - - return (FILTER_HANDLED); -} - -void +static void openpic_dispatch(device_t dev, struct trapframe *tf) { struct openpic_softc *sc; @@ -311,7 +300,17 @@ openpic_dispatch(device_t dev, struct trapframe *tf) } } -void +static int +openpic_intr(void *arg) +{ + device_t dev = (device_t)(arg); + + openpic_dispatch(dev, curthread->td_intr_frame); + + return (FILTER_HANDLED); +} + +static void openpic_enable(device_t dev, u_int irq, u_int vector, void **priv __unused) { struct openpic_softc *sc; @@ -331,7 +330,7 @@ openpic_enable(device_t dev, u_int irq, u_int vector, void **priv __unused) } } -void +static void openpic_eoi(device_t dev, u_int irq __unused, void *priv __unused) { struct openpic_softc *sc; @@ -343,7 +342,7 @@ openpic_eoi(device_t dev, u_int irq __unused, void *priv __unused) openpic_write(sc, OPENPIC_PCPU_EOI(cpuid), 0); } -void +static void openpic_ipi(device_t dev, u_int cpu) { struct openpic_softc *sc; @@ -357,7 +356,7 @@ openpic_ipi(device_t dev, u_int cpu) sched_unpin(); } -void +static void openpic_mask(device_t dev, u_int irq, void *priv __unused) { struct openpic_softc *sc; @@ -375,7 +374,7 @@ openpic_mask(device_t dev, u_int irq, void *priv __unused) } } -void +static void openpic_unmask(device_t dev, u_int irq, void *priv __unused) { struct openpic_softc *sc; @@ -393,7 +392,7 @@ openpic_unmask(device_t dev, u_int irq, void *priv __unused) } } -int +static int openpic_suspend(device_t dev) { struct openpic_softc *sc; @@ -424,7 +423,7 @@ openpic_suspend(device_t dev) return (0); } -int +static int openpic_resume(device_t dev) { struct openpic_softc *sc; @@ -453,3 +452,24 @@ openpic_resume(device_t dev) return (0); } + +static device_method_t openpic_methods[] = { + /* Device interface */ + DEVMETHOD(device_suspend, openpic_suspend), + DEVMETHOD(device_resume, openpic_resume), + + /* PIC interface */ + DEVMETHOD(pic_bind, openpic_bind), + DEVMETHOD(pic_config, openpic_config), + DEVMETHOD(pic_dispatch, openpic_dispatch), + DEVMETHOD(pic_enable, openpic_enable), + DEVMETHOD(pic_eoi, openpic_eoi), + DEVMETHOD(pic_ipi, openpic_ipi), + DEVMETHOD(pic_mask, openpic_mask), + DEVMETHOD(pic_unmask, openpic_unmask), + + DEVMETHOD_END +}; + +PUBLIC_DEFINE_CLASSN(openpic, openpic_class, openpic_methods, + sizeof(struct openpic_softc), pic_hw_class); diff --git a/sys/powerpc/powerpc/pic_if.m b/sys/powerpc/powerpc/pic_if.m index 59187be9d935fe..c74c872b2d3cfa 100644 --- a/sys/powerpc/powerpc/pic_if.m +++ b/sys/powerpc/powerpc/pic_if.m @@ -29,9 +29,14 @@ #include #include #include +#include INTERFACE pic; +HEADER { + #include "intr_event_if.h" +}; + CODE { static pic_translate_code_t pic_translate_code_default; diff --git a/sys/powerpc/ps3/ehci_ps3.c b/sys/powerpc/ps3/ehci_ps3.c index d42d8e96d3f7ec..1b8b9d90117941 100644 --- a/sys/powerpc/ps3/ehci_ps3.c +++ b/sys/powerpc/ps3/ehci_ps3.c @@ -165,11 +165,8 @@ static device_method_t ehci_ps3_methods[] = { DEVMETHOD_END }; -static driver_t ehci_ps3_driver = { - .name = "ehci", - .methods = ehci_ps3_methods, - .size = sizeof(ehci_softc_t), -}; +PRIVATE_DEFINE_CLASSN(ehci, ehci_ps3_driver, ehci_ps3_methods, + sizeof(ehci_softc_t)); DRIVER_MODULE(ehci_ps3, ps3bus, ehci_ps3_driver, 0, 0); MODULE_DEPEND(ehci_ps3, usb, 1, 1, 1); diff --git a/sys/powerpc/ps3/if_glc.c b/sys/powerpc/ps3/if_glc.c index 70a6633a03f40e..ba5b9f79d6beae 100644 --- a/sys/powerpc/ps3/if_glc.c +++ b/sys/powerpc/ps3/if_glc.c @@ -81,15 +81,12 @@ static device_method_t glc_methods[] = { /* Device interface */ DEVMETHOD(device_probe, glc_probe), DEVMETHOD(device_attach, glc_attach), - { 0, 0 } -}; -static driver_t glc_driver = { - "glc", - glc_methods, - sizeof(struct glc_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(glc, glc_driver, glc_methods, sizeof(struct glc_softc)); + DRIVER_MODULE(glc, ps3bus, glc_driver, 0, 0); static int diff --git a/sys/powerpc/ps3/ohci_ps3.c b/sys/powerpc/ps3/ohci_ps3.c index 7920568ffb726f..00ded5b8dc38c1 100644 --- a/sys/powerpc/ps3/ohci_ps3.c +++ b/sys/powerpc/ps3/ohci_ps3.c @@ -157,11 +157,8 @@ static device_method_t ohci_ps3_methods[] = { DEVMETHOD_END }; -static driver_t ohci_ps3_driver = { - .name = "ohci", - .methods = ohci_ps3_methods, - .size = sizeof(ohci_softc_t), -}; +PRIVATE_DEFINE_CLASSN(ohci, ohci_ps3_driver, ohci_ps3_methods, + sizeof(ohci_softc_t)); DRIVER_MODULE(ohci_ps3, ps3bus, ohci_ps3_driver, 0, 0); MODULE_DEPEND(ohci_ps3, usb, 1, 1, 1); diff --git a/sys/powerpc/ps3/ps3bus.c b/sys/powerpc/ps3/ps3bus.c index 8aa0a806f1163c..8120648434e1f9 100644 --- a/sys/powerpc/ps3/ps3bus.c +++ b/sys/powerpc/ps3/ps3bus.c @@ -143,11 +143,8 @@ struct ps3bus_softc { int rcount; }; -static driver_t ps3bus_driver = { - "ps3bus", - ps3bus_methods, - sizeof(struct ps3bus_softc) -}; +PRIVATE_DEFINE_CLASSN(ps3bus, ps3bus_driver, ps3bus_methods, + sizeof(struct ps3bus_softc)); DRIVER_MODULE(ps3bus, nexus, ps3bus_driver, 0, 0); diff --git a/sys/powerpc/ps3/ps3cdrom.c b/sys/powerpc/ps3/ps3cdrom.c index f40cb8710d5afd..7b7fc9ef7abec1 100644 --- a/sys/powerpc/ps3/ps3cdrom.c +++ b/sys/powerpc/ps3/ps3cdrom.c @@ -693,14 +693,12 @@ static device_method_t ps3cdrom_methods[] = { DEVMETHOD(device_probe, ps3cdrom_probe), DEVMETHOD(device_attach, ps3cdrom_attach), DEVMETHOD(device_detach, ps3cdrom_detach), - {0, 0}, -}; -static driver_t ps3cdrom_driver = { - "ps3cdrom", - ps3cdrom_methods, - sizeof(struct ps3cdrom_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(ps3cdrom, ps3cdrom_driver, ps3cdrom_methods, + sizeof(struct ps3cdrom_softc)); + DRIVER_MODULE(ps3cdrom, ps3bus, ps3cdrom_driver, 0, 0); MODULE_DEPEND(ps3cdrom, cam, 1, 1, 1); diff --git a/sys/powerpc/ps3/ps3disk.c b/sys/powerpc/ps3/ps3disk.c index 0931e6aad58ba1..d219c4bd3d0683 100644 --- a/sys/powerpc/ps3/ps3disk.c +++ b/sys/powerpc/ps3/ps3disk.c @@ -686,13 +686,11 @@ static device_method_t ps3disk_methods[] = { DEVMETHOD(device_probe, ps3disk_probe), DEVMETHOD(device_attach, ps3disk_attach), DEVMETHOD(device_detach, ps3disk_detach), - {0, 0}, -}; -static driver_t ps3disk_driver = { - "ps3disk", - ps3disk_methods, - sizeof(struct ps3disk_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(ps3disk, ps3disk_driver, ps3disk_methods, + sizeof(struct ps3disk_softc)); + DRIVER_MODULE(ps3disk, ps3bus, ps3disk_driver, 0, 0); diff --git a/sys/powerpc/ps3/ps3pic.c b/sys/powerpc/ps3/ps3pic.c index c947b3e3e502f6..150f3ea959a8bf 100644 --- a/sys/powerpc/ps3/ps3pic.c +++ b/sys/powerpc/ps3/ps3pic.c @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include @@ -80,14 +80,11 @@ static device_method_t ps3pic_methods[] = { DEVMETHOD(pic_mask, ps3pic_mask), DEVMETHOD(pic_unmask, ps3pic_unmask), - { 0, 0 }, + DEVMETHOD_END }; -static driver_t ps3pic_driver = { - "ps3pic", - ps3pic_methods, - sizeof(struct ps3pic_softc) -}; +PRIVATE_DEFINE_CLASSN(ps3pic, ps3pic_driver ps3pic_methods, + sizeof(struct ps3pic_softc), pic_hw_class); DRIVER_MODULE(ps3pic, nexus, ps3pic_driver, 0, 0); diff --git a/sys/powerpc/pseries/phyp_console.c b/sys/powerpc/pseries/phyp_console.c index b75f9a020c470c..4a13dd73fded9d 100644 --- a/sys/powerpc/pseries/phyp_console.c +++ b/sys/powerpc/pseries/phyp_console.c @@ -102,11 +102,8 @@ static device_method_t uart_phyp_methods[] = { DEVMETHOD_END }; -static driver_t uart_phyp_driver = { - "uart", - uart_phyp_methods, - sizeof(struct uart_phyp_softc), -}; +PRIVATE_DEFINE_CLASSN(uart, uart_phyp_driver, uart_phyp_methods, + sizeof(struct uart_phyp_softc)); DRIVER_MODULE(uart_phyp, vdevice, uart_phyp_driver, 0, 0); diff --git a/sys/powerpc/pseries/phyp_llan.c b/sys/powerpc/pseries/phyp_llan.c index 4ba4549a9cf5f1..23e8424837340d 100644 --- a/sys/powerpc/pseries/phyp_llan.c +++ b/sys/powerpc/pseries/phyp_llan.c @@ -131,11 +131,8 @@ static device_method_t llan_methods[] = { DEVMETHOD_END }; -static driver_t llan_driver = { - "llan", - llan_methods, - sizeof(struct llan_softc) -}; +PRIVATE_DEFINE_CLASSN(llan, llan_driver, llan_methods, + sizeof(struct llan_softc)); DRIVER_MODULE(llan, vdevice, llan_driver, 0, 0); diff --git a/sys/powerpc/pseries/phyp_vscsi.c b/sys/powerpc/pseries/phyp_vscsi.c index e18d584e7b246d..f73b6b5cea99aa 100644 --- a/sys/powerpc/pseries/phyp_vscsi.c +++ b/sys/powerpc/pseries/phyp_vscsi.c @@ -255,11 +255,8 @@ static device_method_t vscsi_methods[] = { DEVMETHOD_END }; -static driver_t vscsi_driver = { - "vscsi", - vscsi_methods, - sizeof(struct vscsi_softc) -}; +PRIVATE_DEFINE_CLASSN(vscsi, vscsi_driver, vscsi_methods, + sizeof(struct vscsi_softc)); DRIVER_MODULE(vscsi, vdevice, vscsi_driver, 0, 0); MALLOC_DEFINE(M_VSCSI, "vscsi", "CAM device queue for VSCSI"); diff --git a/sys/powerpc/pseries/platform_chrp.c b/sys/powerpc/pseries/platform_chrp.c index b2686674a522d6..292f9bc7511edd 100644 --- a/sys/powerpc/pseries/platform_chrp.c +++ b/sys/powerpc/pseries/platform_chrp.c @@ -108,7 +108,8 @@ static platform_method_t chrp_methods[] = { #endif PLATFORMMETHOD(platform_reset, chrp_reset), - { 0, 0 } + + PLATFORMMETHOD_END }; static platform_def_t chrp_platform = { diff --git a/sys/powerpc/pseries/rtas_dev.c b/sys/powerpc/pseries/rtas_dev.c index 09e851f445f151..fdfec12bb8a1c3 100644 --- a/sys/powerpc/pseries/rtas_dev.c +++ b/sys/powerpc/pseries/rtas_dev.c @@ -62,14 +62,10 @@ static device_method_t rtasdev_methods[] = { DEVMETHOD(clock_gettime, rtas_gettime), DEVMETHOD(clock_settime, rtas_settime), - { 0, 0 }, + DEVMETHOD_END }; -static driver_t rtasdev_driver = { - "rtas", - rtasdev_methods, - 0 -}; +PRIVATE_DEFINE_CLASSN(rtas, rtasdev_driver, rtasdev_methods, 0); DRIVER_MODULE(rtasdev, ofwbus, rtasdev_driver, 0, 0); diff --git a/sys/powerpc/pseries/rtas_pci.c b/sys/powerpc/pseries/rtas_pci.c index 02d1a559e7dd16..a782afcd6f2b27 100644 --- a/sys/powerpc/pseries/rtas_pci.c +++ b/sys/powerpc/pseries/rtas_pci.c @@ -44,7 +44,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/powerpc/pseries/vdevice.c b/sys/powerpc/pseries/vdevice.c index 9763922e60287c..6b725e2dc71c59 100644 --- a/sys/powerpc/pseries/vdevice.c +++ b/sys/powerpc/pseries/vdevice.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -94,11 +94,8 @@ static device_method_t vdevice_methods[] = { DEVMETHOD_END }; -static driver_t vdevice_driver = { - "vdevice", - vdevice_methods, - 0 -}; +PRIVATE_DEFINE_CLASSN(vdevice, vdevice_driver, vdevice_methods, 0, + pic_hw_class); DRIVER_MODULE(vdevice, ofwbus, vdevice_driver, 0, 0); diff --git a/sys/powerpc/pseries/xics.c b/sys/powerpc/pseries/xics.c index 6195307114b750..c58a4fd930f074 100644 --- a/sys/powerpc/pseries/xics.c +++ b/sys/powerpc/pseries/xics.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include @@ -128,17 +128,10 @@ struct xicp_softc { bool xics_emu; }; -static driver_t xicp_driver = { - "xicp", - xicp_methods, - sizeof(struct xicp_softc) -}; +PRIVATE_DEFINE_CLASSN(xicp, xicp_driver, xicp_methods, + sizeof(struct xicp_softc), pic_hw_class); -static driver_t xics_driver = { - "xics", - xics_methods, - 0 -}; +PRIVATE_DEFINE_CLASSN(xics, xics_driver, xics_methods, 0, pic_hw_class); #ifdef POWERNV /* We can only pass physical addresses into OPAL. Kernel stacks are in the KVA, diff --git a/sys/powerpc/psim/ata_iobus.c b/sys/powerpc/psim/ata_iobus.c index 4ca9ecafc99c19..f55f4e3c4284d0 100644 --- a/sys/powerpc/psim/ata_iobus.c +++ b/sys/powerpc/psim/ata_iobus.c @@ -64,7 +64,7 @@ struct resource *ata_iobus_alloc_resource(device_t, device_t, int, int *, static int ata_iobus_release_resource(device_t, device_t, struct resource *); static device_method_t ata_iobus_methods[] = { - /* Device interface */ + /* Device interface */ DEVMETHOD(device_probe, ata_iobus_probe), DEVMETHOD(device_attach, ata_iobus_attach), DEVMETHOD(device_shutdown, bus_generic_shutdown), @@ -83,11 +83,7 @@ static device_method_t ata_iobus_methods[] = { DEVMETHOD_END }; -static driver_t ata_iobus_driver = { - "ataiobus", - ata_iobus_methods, - 0, -}; +PRIVATE_DEFINE_CLASSN(ataiobus, ata_iobus_driver, ata_iobus_methods, 0); DRIVER_MODULE(ataiobus, iobus, ata_iobus_driver, NULL, NULL); MODULE_DEPEND(ata, ata, 1, 1, 1); @@ -218,11 +214,8 @@ static device_method_t ata_iobus_sub_methods[] = { DEVMETHOD_END }; -static driver_t ata_iobus_sub_driver = { - "ata", - ata_iobus_sub_methods, - sizeof(struct ata_channel), -}; +PRIVATE_DEFINE_CLASSN(ata, ata_iobus_sub_driver, ata_iobus_sub_methods, + sizeof(struct ata_channel)); DRIVER_MODULE(ata, ataiobus, ata_iobus_sub_driver, NULL, NULL); diff --git a/sys/powerpc/psim/iobus.c b/sys/powerpc/psim/iobus.c index 288d85effcc2d6..32cf0eb1991bce 100644 --- a/sys/powerpc/psim/iobus.c +++ b/sys/powerpc/psim/iobus.c @@ -89,39 +89,37 @@ static int iobus_release_resource(device_t, device_t, struct resource *); * Bus interface definition */ static device_method_t iobus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, iobus_probe), - DEVMETHOD(device_attach, iobus_attach), - DEVMETHOD(device_detach, bus_generic_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, iobus_print_child), - DEVMETHOD(bus_probe_nomatch, iobus_probe_nomatch), - DEVMETHOD(bus_read_ivar, iobus_read_ivar), - DEVMETHOD(bus_write_ivar, iobus_write_ivar), - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + /* Device interface */ + DEVMETHOD(device_probe, iobus_probe), + DEVMETHOD(device_attach, iobus_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, iobus_print_child), + DEVMETHOD(bus_probe_nomatch, iobus_probe_nomatch), + DEVMETHOD(bus_read_ivar, iobus_read_ivar), + DEVMETHOD(bus_write_ivar, iobus_write_ivar), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), DEVMETHOD(bus_get_rman, iobus_get_rman), - DEVMETHOD(bus_alloc_resource, iobus_alloc_resource), + DEVMETHOD(bus_alloc_resource, iobus_alloc_resource), DEVMETHOD(bus_adjust_resource, iobus_adjust_resource), - DEVMETHOD(bus_release_resource, iobus_release_resource), - DEVMETHOD(bus_activate_resource, iobus_activate_resource), - DEVMETHOD(bus_deactivate_resource, iobus_deactivate_resource), + DEVMETHOD(bus_release_resource, iobus_release_resource), + DEVMETHOD(bus_activate_resource, iobus_activate_resource), + DEVMETHOD(bus_deactivate_resource, iobus_deactivate_resource), DEVMETHOD(bus_map_resource, iobus_map_resource), DEVMETHOD(bus_unmap_resource, iobus_unmap_resource), - { 0, 0 } -}; -static driver_t iobus_driver = { - "iobus", - iobus_methods, - sizeof(struct iobus_softc) + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(iobus, iobus_driver, iobus_methods, + sizeof(struct iobus_softc)); + DRIVER_MODULE(iobus, ofwbus, iobus_driver, 0, 0); static int diff --git a/sys/powerpc/psim/openpic_iobus.c b/sys/powerpc/psim/openpic_iobus.c index bf5bd8235a6c6f..c5247c2babe462 100644 --- a/sys/powerpc/psim/openpic_iobus.c +++ b/sys/powerpc/psim/openpic_iobus.c @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include #include @@ -69,22 +69,11 @@ static device_method_t openpic_iobus_methods[] = { DEVMETHOD(device_probe, openpic_iobus_probe), DEVMETHOD(device_attach, openpic_iobus_attach), - /* PIC interface */ - DEVMETHOD(pic_config, openpic_config), - DEVMETHOD(pic_dispatch, openpic_dispatch), - DEVMETHOD(pic_enable, openpic_enable), - DEVMETHOD(pic_eoi, openpic_eoi), - DEVMETHOD(pic_ipi, openpic_ipi), - DEVMETHOD(pic_mask, openpic_mask), - DEVMETHOD(pic_unmask, openpic_unmask), - { 0, 0 } + DEVMETHOD_END }; -static driver_t openpic_iobus_driver = { - "openpic", - openpic_iobus_methods, - sizeof(struct openpic_softc) -}; +PRIVATE_DEFINE_CLASSN(openpic, openpic_iobus_driver, openpic_iobus_methods, + sizeof(struct openpic_softc), openpic_class); DRIVER_MODULE(openpic, iobus, openpic_iobus_driver, 0, 0); diff --git a/sys/powerpc/psim/uart_iobus.c b/sys/powerpc/psim/uart_iobus.c index c1a177cd0f0230..81ee60b54ec3c2 100644 --- a/sys/powerpc/psim/uart_iobus.c +++ b/sys/powerpc/psim/uart_iobus.c @@ -52,19 +52,17 @@ static int uart_iobus_probe(device_t dev); static device_method_t uart_iobus_methods[] = { - /* Device interface */ + /* Device interface */ DEVMETHOD(device_probe, uart_iobus_probe), DEVMETHOD(device_attach, uart_bus_attach), DEVMETHOD(device_detach, uart_bus_detach), - { 0, 0 } -}; -static driver_t uart_iobus_driver = { - uart_driver_name, - uart_iobus_methods, - sizeof(struct uart_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(uart_driver_name, uart_iobus_driver, uart_iobus_methods, + sizeof(struct uart_softc)); + static int uart_iobus_probe(device_t dev) { diff --git a/sys/riscv/eswin/eswin_reset.c b/sys/riscv/eswin/eswin_reset.c index 13139e0c85ea80..b41c9b291f3736 100644 --- a/sys/riscv/eswin/eswin_reset.c +++ b/sys/riscv/eswin/eswin_reset.c @@ -180,11 +180,8 @@ static device_method_t eswin_rst_methods[] = { DEVMETHOD_END }; -static driver_t eswin_rst_driver = { - "eswin_rst", - eswin_rst_methods, - sizeof(struct eswin_rst_softc) -}; +PRIVATE_DEFINE_CLASSN(eswin_rst, eswin_rst_driver, eswin_rst_methods, + sizeof(struct eswin_rst_softc)); EARLY_DRIVER_MODULE(eswin_rst, simplebus, eswin_rst_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_LATE); diff --git a/sys/riscv/include/intr.h b/sys/riscv/include/interrupt.h similarity index 94% rename from sys/riscv/include/intr.h rename to sys/riscv/include/interrupt.h index da5d420f7e6d00..d0fc3041ee6519 100644 --- a/sys/riscv/include/intr.h +++ b/sys/riscv/include/interrupt.h @@ -32,8 +32,10 @@ * SUCH DAMAGE. */ -#ifndef _MACHINE_INTR_MACHDEP_H_ -#define _MACHINE_INTR_MACHDEP_H_ +#ifndef __MACHINE_INTERRUPT_H__ +#define __MACHINE_INTERRUPT_H__ + +#include #ifndef NIRQ #define NIRQ 1024 @@ -59,4 +61,4 @@ enum { #define INTR_ROOT_IRQ 0 #define INTR_ROOT_COUNT 1 -#endif /* !_MACHINE_INTR_MACHDEP_H_ */ +#endif /* !__MACHINE_INTERRUPT_H__ */ diff --git a/sys/riscv/riscv/aplic.c b/sys/riscv/riscv/aplic.c index 6550b7ba36d138..3f468ceedd572e 100644 --- a/sys/riscv/riscv/aplic.c +++ b/sys/riscv/riscv/aplic.c @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include @@ -54,8 +54,8 @@ static pic_disable_intr_t aplic_disable_intr; static pic_enable_intr_t aplic_enable_intr; static pic_map_intr_t aplic_map_intr; static pic_setup_intr_t aplic_setup_intr; -static pic_post_ithread_t aplic_post_ithread; -static pic_pre_ithread_t aplic_pre_ithread; +static intr_event_post_ithread_t aplic_post_ithread; +static intr_event_pre_ithread_t aplic_pre_ithread; static pic_bind_intr_t aplic_bind_intr; struct aplic_irqsrc { @@ -540,19 +540,22 @@ static device_method_t aplic_methods[] = { DEVMETHOD(device_probe, aplic_probe), DEVMETHOD(device_attach, aplic_attach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, aplic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, aplic_post_ithread), + DEVMETHOD(intr_event_post_filter, aplic_post_ithread), + DEVMETHOD(pic_disable_intr, aplic_disable_intr), DEVMETHOD(pic_enable_intr, aplic_enable_intr), DEVMETHOD(pic_map_intr, aplic_map_intr), - DEVMETHOD(pic_pre_ithread, aplic_pre_ithread), - DEVMETHOD(pic_post_ithread, aplic_post_ithread), - DEVMETHOD(pic_post_filter, aplic_post_ithread), DEVMETHOD(pic_setup_intr, aplic_setup_intr), DEVMETHOD(pic_bind_intr, aplic_bind_intr), DEVMETHOD_END }; -DEFINE_CLASS_0(aplic, aplic_driver, aplic_methods, sizeof(struct aplic_softc)); +DEFINE_CLASSN(aplic, aplic_driver, aplic_methods, sizeof(struct aplic_softc), + pic_base_class); EARLY_DRIVER_MODULE(aplic, simplebus, aplic_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/riscv/riscv/busdma_bounce.c b/sys/riscv/riscv/busdma_bounce.c index f652f08bf5dc0e..917a529602d9cc 100644 --- a/sys/riscv/riscv/busdma_bounce.c +++ b/sys/riscv/riscv/busdma_bounce.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -53,8 +52,9 @@ #include #include -#include #include +#include +#include #define MAX_BPAGES 4096 diff --git a/sys/riscv/riscv/intc.c b/sys/riscv/riscv/intc.c index 248175e8bea39f..a71d576b755a55 100644 --- a/sys/riscv/riscv/intc.c +++ b/sys/riscv/riscv/intc.c @@ -42,14 +42,13 @@ #include #include #include -#include #include #include #include #include #include -#include +#include #include diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index c0d4b7cc27262d..33ccb85c7e4d04 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -81,7 +81,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c index 235bee15ca2967..bb3cfe36440c66 100644 --- a/sys/riscv/riscv/mp_machdep.c +++ b/sys/riscv/riscv/mp_machdep.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -60,6 +59,7 @@ #include #include +#include #include #include diff --git a/sys/riscv/riscv/nexus.c b/sys/riscv/riscv/nexus.c index 6eb194f863907d..119676c9692744 100644 --- a/sys/riscv/riscv/nexus.c +++ b/sys/riscv/riscv/nexus.c @@ -45,14 +45,13 @@ #include #include #include -#include #include #include #include +#include #include -#include #ifdef FDT #include @@ -128,11 +127,7 @@ static device_method_t nexus_methods[] = { DEVMETHOD_END }; -static driver_t nexus_fdt_driver = { - "nexus", - nexus_methods, - 1 /* no softc */ -}; +PRIVATE_DEFINE_CLASSN(nexus, nexus_fdt_driver, nexus_methods, 0 /* no softc */); EARLY_DRIVER_MODULE(nexus_fdt, root, nexus_fdt_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_FIRST); diff --git a/sys/riscv/riscv/plic.c b/sys/riscv/riscv/plic.c index b7dda1d19daf9c..6b5e80b71c22c5 100644 --- a/sys/riscv/riscv/plic.c +++ b/sys/riscv/riscv/plic.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include @@ -77,8 +77,8 @@ static pic_disable_intr_t plic_disable_intr; static pic_enable_intr_t plic_enable_intr; static pic_map_intr_t plic_map_intr; static pic_setup_intr_t plic_setup_intr; -static pic_post_ithread_t plic_post_ithread; -static pic_pre_ithread_t plic_pre_ithread; +static intr_event_post_ithread_t plic_post_ithread; +static intr_event_pre_ithread_t plic_pre_ithread; static pic_bind_intr_t plic_bind_intr; struct plic_irqsrc { @@ -519,23 +519,22 @@ static device_method_t plic_methods[] = { DEVMETHOD(device_probe, plic_probe), DEVMETHOD(device_attach, plic_attach), + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, plic_pre_ithread), + DEVMETHOD(intr_event_post_ithread, plic_post_ithread), + DEVMETHOD(intr_event_post_filter, plic_post_ithread), + DEVMETHOD(pic_disable_intr, plic_disable_intr), DEVMETHOD(pic_enable_intr, plic_enable_intr), DEVMETHOD(pic_map_intr, plic_map_intr), - DEVMETHOD(pic_pre_ithread, plic_pre_ithread), - DEVMETHOD(pic_post_ithread, plic_post_ithread), - DEVMETHOD(pic_post_filter, plic_post_ithread), DEVMETHOD(pic_setup_intr, plic_setup_intr), DEVMETHOD(pic_bind_intr, plic_bind_intr), DEVMETHOD_END }; -static driver_t plic_driver = { - "plic", - plic_methods, - sizeof(struct plic_softc), -}; +PRIVATE_DEFINE_CLASSN(plic, plic_driver, plic_methods, + sizeof(struct plic_softc), pic_base_class); EARLY_DRIVER_MODULE(plic, simplebus, plic_driver, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/riscv/riscv/riscv_console.c b/sys/riscv/riscv/riscv_console.c index 9fb027a5f0fcbf..92dcf84b98e14f 100644 --- a/sys/riscv/riscv/riscv_console.c +++ b/sys/riscv/riscv/riscv_console.c @@ -59,7 +59,7 @@ #include #include -#include +#include #include #include #include @@ -255,10 +255,7 @@ static device_method_t rcons_methods[] = { DEVMETHOD_END }; -static driver_t rcons_driver = { - "rcons", - rcons_methods, - sizeof(struct rcons_softc) -}; +PRIVATE_DEFINE_CLASSN(rcons, rcons_driver, rcons_methods, + sizeof(struct rcons_softc)); DRIVER_MODULE(rcons, nexus, rcons_driver, 0, 0); diff --git a/sys/riscv/riscv/sbi_ipi.c b/sys/riscv/riscv/sbi_ipi.c index fac5c0c39b997e..c8400cd2dfd391 100644 --- a/sys/riscv/riscv/sbi_ipi.c +++ b/sys/riscv/riscv/sbi_ipi.c @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include diff --git a/sys/riscv/riscv/timer.c b/sys/riscv/riscv/timer.c index dc909082edae90..3219cbc87d0821 100644 --- a/sys/riscv/riscv/timer.c +++ b/sys/riscv/riscv/timer.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -51,6 +50,7 @@ #include #include +#include #include #include @@ -262,15 +262,13 @@ riscv_timer_attach(device_t dev) static device_method_t riscv_timer_methods[] = { DEVMETHOD(device_probe, riscv_timer_probe), DEVMETHOD(device_attach, riscv_timer_attach), - { 0, 0 } -}; -static driver_t riscv_timer_driver = { - "timer", - riscv_timer_methods, - sizeof(struct riscv_timer_softc), + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(timer, riscv_timer_driver, riscv_timer_methods, + sizeof(struct riscv_timer_softc)); + EARLY_DRIVER_MODULE(timer, nexus, riscv_timer_driver, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c index a1a30eb582206f..72d58843e597ca 100644 --- a/sys/riscv/riscv/trap.c +++ b/sys/riscv/riscv/trap.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -63,6 +62,7 @@ #include #include +#include #include #ifdef KDTRACE_HOOKS diff --git a/sys/riscv/sifive/fe310_aon.c b/sys/riscv/sifive/fe310_aon.c index d64cf12ff456a0..519c77fb86375a 100644 --- a/sys/riscv/sifive/fe310_aon.c +++ b/sys/riscv/sifive/fe310_aon.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include "clock_if.h" @@ -304,10 +304,7 @@ static device_method_t feaon_methods[] = { DEVMETHOD_END }; -static driver_t feaon_driver = { - "fe310aon", - feaon_methods, - sizeof(struct feaon_softc) -}; +PRIVATE_DEFINE_CLASSN(fe310aon, feaon_driver, feaon_methods, + sizeof(struct feaon_softc)); DRIVER_MODULE(fe310aon, simplebus, feaon_driver, 0, 0); diff --git a/sys/riscv/sifive/fu740_pci_dw.c b/sys/riscv/sifive/fu740_pci_dw.c index 2c8068775637d6..abeee6fc62aebe 100644 --- a/sys/riscv/sifive/fu740_pci_dw.c +++ b/sys/riscv/sifive/fu740_pci_dw.c @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include diff --git a/sys/riscv/sifive/sifive_ccache.c b/sys/riscv/sifive/sifive_ccache.c index 9006d02aa85ed2..e80b7dd4c0ba22 100644 --- a/sys/riscv/sifive/sifive_ccache.c +++ b/sys/riscv/sifive/sifive_ccache.c @@ -163,14 +163,12 @@ static device_method_t ccache_methods[] = { /* Device interface */ DEVMETHOD(device_probe, ccache_probe), DEVMETHOD(device_attach, ccache_attach), + DEVMETHOD_END }; -static driver_t ccache_driver = { - "ccache", - ccache_methods, - sizeof(struct ccache_softc), -}; +PRIVATE_DEFINE_CLASSN(ccache, ccache_driver, ccache_methods, + sizeof(struct ccache_softc)); EARLY_DRIVER_MODULE(ccache, simplebus, ccache_driver, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_FIRST); diff --git a/sys/riscv/sifive/sifive_prci.c b/sys/riscv/sifive/sifive_prci.c index ecfaf936e51678..3b89e80b079fb0 100644 --- a/sys/riscv/sifive/sifive_prci.c +++ b/sys/riscv/sifive/sifive_prci.c @@ -684,11 +684,8 @@ static device_method_t prci_methods[] = { DEVMETHOD_END }; -static driver_t prci_driver = { - "sifive_prci", - prci_methods, - sizeof(struct prci_softc) -}; +PRIVATE_DEFINE_CLASSN(sifive_prci, prci_driver, prci_methods, + sizeof(struct prci_softc)); /* * hfclk and rtcclk appear later in the device tree than prci, so we must diff --git a/sys/riscv/sifive/sifive_spi.c b/sys/riscv/sifive/sifive_spi.c index 486cf4209c1082..3524e629d84ff0 100644 --- a/sys/riscv/sifive/sifive_spi.c +++ b/sys/riscv/sifive/sifive_spi.c @@ -389,11 +389,8 @@ static device_method_t sfspi_methods[] = { DEVMETHOD_END }; -static driver_t sfspi_driver = { - "sifive_spi", - sfspi_methods, - sizeof(struct sfspi_softc) -}; +PRIVATE_DEFINE_CLASSN(sifive_spi, sfspi_driver, sfspi_methods, + sizeof(struct sfspi_softc)); DRIVER_MODULE(sifive_spi, simplebus, sfspi_driver, 0, 0); DRIVER_MODULE(ofw_spibus, sifive_spi, ofw_spibus_driver, 0, 0); diff --git a/sys/riscv/vmm/vmm_riscv.c b/sys/riscv/vmm/vmm_riscv.c index 6ac945dfa1d0c3..ff3c9cf2072d82 100644 --- a/sys/riscv/vmm/vmm_riscv.c +++ b/sys/riscv/vmm/vmm_riscv.c @@ -62,7 +62,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/sys/_types_interrupt.h b/sys/sys/_types_interrupt.h new file mode 100644 index 00000000000000..053d7bd770a37a --- /dev/null +++ b/sys/sys/_types_interrupt.h @@ -0,0 +1,123 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright © 1998,2003,2004 Doug Rabson + * All rights reserved. + * Copyright © 2001 David E. O'Brien + * Copyright © 2003 Marcel Moolenaar + * Copyright © 2007 Paolo Pisati + * Copyright © 2011 Marius Strobl + * Copyright © 2022 Mitchell Horne + * + * 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. + */ + +#if !defined(_SYS__TYPES_INTERRUPT_H_) && defined(_KERNEL) +#define _SYS__TYPES_INTERRUPT_H_ + +/** + * @brief Driver interrupt filter return values + * + * If a driver provides an interrupt filter routine it must return an + * integer consisting of oring together zero or more of the following + * flags: + * + * FILTER_STRAY - this device did not trigger the interrupt + * FILTER_HANDLED - the interrupt has been fully handled and can be EOId + * FILTER_SCHEDULE_THREAD - the threaded interrupt handler should be + * scheduled to execute + * + * If the driver does not provide a filter, then the interrupt code will + * act is if the filter had returned FILTER_SCHEDULE_THREAD. Note that it + * is illegal to specify any other flag with FILTER_STRAY and that it is + * illegal to not specify either of FILTER_HANDLED or FILTER_SCHEDULE_THREAD + * if FILTER_STRAY is not specified. + */ +#define FILTER_STRAY 0x01 +#define FILTER_HANDLED 0x02 +#define FILTER_SCHEDULE_THREAD 0x04 + +/** + * @brief Driver interrupt service routines + * + * The filter routine is run in primary interrupt context and may not + * block or use regular mutexes. It may only use spin mutexes for + * synchronization. The filter may either completely handle the + * interrupt or it may perform some of the work and defer more + * expensive work to the regular interrupt handler. If a filter + * routine is not registered by the driver, then the regular interrupt + * handler is always used to handle interrupts from this device. + * + * The regular interrupt handler executes in its own thread context + * and may use regular mutexes. However, it is prohibited from + * sleeping on a sleep queue. + */ +typedef int driver_filter_t(void*); +typedef void driver_intr_t(void*); + +/** + * @brief Interrupt type bits. + * + * These flags may be passed by drivers to bus_setup_intr(9) when + * registering a new interrupt handler. The field is overloaded to + * specify both the interrupt's type and any special properties. + * + * The INTR_TYPE* bits will be passed to intr_priority(9) to determine + * the scheduling priority of the handler's ithread. Historically, each + * type was assigned a unique scheduling preference, but now only + * INTR_TYPE_CLK receives a default priority higher than other + * interrupts. See sys/priority.h. + * + * Buses may choose to modify or augment these flags as appropriate, + * e.g. nexus may apply INTR_EXCL. + */ +enum intr_type { + INTR_TYPE_TTY = 1, + INTR_TYPE_BIO = 2, + INTR_TYPE_NET = 4, + INTR_TYPE_CAM = 8, + INTR_TYPE_MISC = 16, + INTR_TYPE_CLK = 32, + INTR_TYPE_AV = 64, + INTR_EXCL = 256, /* exclusive interrupt */ + INTR_MPSAFE = 512, /* this interrupt is SMP safe */ + INTR_ENTROPY = 1024, /* this interrupt provides entropy */ + INTR_MD1 = 4096, /* flag reserved for MD use */ + INTR_MD2 = 8192, /* flag reserved for MD use */ + INTR_MD3 = 16384, /* flag reserved for MD use */ + INTR_MD4 = 32768 /* flag reserved for MD use */ +}; + +enum intr_trigger { + INTR_TRIGGER_INVALID = -1, + INTR_TRIGGER_CONFORM = 0, + INTR_TRIGGER_EDGE = 1, + INTR_TRIGGER_LEVEL = 2 +}; + +enum intr_polarity { + INTR_POLARITY_CONFORM = 0, + INTR_POLARITY_HIGH = 1, + INTR_POLARITY_LOW = 2 +}; + +#endif /* !defined(_SYS__TYPES_INTERRUPT_H_) && defined(_KERNEL) */ diff --git a/sys/sys/bus.h b/sys/sys/bus.h index 01031ae3ef2882..5cbc354daef2a8 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -32,6 +32,7 @@ #include #include #include +#include #include /** @@ -210,92 +211,6 @@ typedef struct devclass *devclass_t; */ #define device_method_t kobj_method_t -/** - * @brief Driver interrupt filter return values - * - * If a driver provides an interrupt filter routine it must return an - * integer consisting of oring together zero or more of the following - * flags: - * - * FILTER_STRAY - this device did not trigger the interrupt - * FILTER_HANDLED - the interrupt has been fully handled and can be EOId - * FILTER_SCHEDULE_THREAD - the threaded interrupt handler should be - * scheduled to execute - * - * If the driver does not provide a filter, then the interrupt code will - * act is if the filter had returned FILTER_SCHEDULE_THREAD. Note that it - * is illegal to specify any other flag with FILTER_STRAY and that it is - * illegal to not specify either of FILTER_HANDLED or FILTER_SCHEDULE_THREAD - * if FILTER_STRAY is not specified. - */ -#define FILTER_STRAY 0x01 -#define FILTER_HANDLED 0x02 -#define FILTER_SCHEDULE_THREAD 0x04 - -/** - * @brief Driver interrupt service routines - * - * The filter routine is run in primary interrupt context and may not - * block or use regular mutexes. It may only use spin mutexes for - * synchronization. The filter may either completely handle the - * interrupt or it may perform some of the work and defer more - * expensive work to the regular interrupt handler. If a filter - * routine is not registered by the driver, then the regular interrupt - * handler is always used to handle interrupts from this device. - * - * The regular interrupt handler executes in its own thread context - * and may use regular mutexes. However, it is prohibited from - * sleeping on a sleep queue. - */ -typedef int driver_filter_t(void*); -typedef void driver_intr_t(void*); - -/** - * @brief Interrupt type bits. - * - * These flags may be passed by drivers to bus_setup_intr(9) when - * registering a new interrupt handler. The field is overloaded to - * specify both the interrupt's type and any special properties. - * - * The INTR_TYPE* bits will be passed to intr_priority(9) to determine - * the scheduling priority of the handler's ithread. Historically, each - * type was assigned a unique scheduling preference, but now only - * INTR_TYPE_CLK receives a default priority higher than other - * interrupts. See sys/priority.h. - * - * Buses may choose to modify or augment these flags as appropriate, - * e.g. nexus may apply INTR_EXCL. - */ -enum intr_type { - INTR_TYPE_TTY = 1, - INTR_TYPE_BIO = 2, - INTR_TYPE_NET = 4, - INTR_TYPE_CAM = 8, - INTR_TYPE_MISC = 16, - INTR_TYPE_CLK = 32, - INTR_TYPE_AV = 64, - INTR_EXCL = 256, /* exclusive interrupt */ - INTR_MPSAFE = 512, /* this interrupt is SMP safe */ - INTR_ENTROPY = 1024, /* this interrupt provides entropy */ - INTR_MD1 = 4096, /* flag reserved for MD use */ - INTR_MD2 = 8192, /* flag reserved for MD use */ - INTR_MD3 = 16384, /* flag reserved for MD use */ - INTR_MD4 = 32768 /* flag reserved for MD use */ -}; - -enum intr_trigger { - INTR_TRIGGER_INVALID = -1, - INTR_TRIGGER_CONFORM = 0, - INTR_TRIGGER_EDGE = 1, - INTR_TRIGGER_LEVEL = 2 -}; - -enum intr_polarity { - INTR_POLARITY_CONFORM = 0, - INTR_POLARITY_HIGH = 1, - INTR_POLARITY_LOW = 2 -}; - /** * CPU sets supported by bus_get_cpus(). Note that not all sets may be * supported for a given device. If a request is not supported by a diff --git a/sys/sys/interrupt.h b/sys/sys/interrupt.h index 899d65e386e0ab..2cccf927f34d06 100644 --- a/sys/sys/interrupt.h +++ b/sys/sys/interrupt.h @@ -29,14 +29,29 @@ #ifndef _SYS_INTERRUPT_H_ #define _SYS_INTERRUPT_H_ +#ifndef __MACHINE_INTERRUPT_H__ +#error "sys/interrupt.h included without architecture interrupt header!" +#endif + #include #include +#include #include +#include +#include +#include struct intr_event; struct intr_thread; struct trapframe; +/* + * Common base class for PICs. All FreeBSD architectures provide this, + * so present in this header. + */ + +DECLARE_CLASS(pic_base_class); + /* * Describe a hardware interrupt handler. * @@ -110,12 +125,11 @@ struct intr_event { char ie_name[MAXCOMLEN + 1]; /* Individual event name. */ char ie_fullname[MAXCOMLEN + 1]; struct mtx ie_lock; - void *ie_source; /* Cookie used by MD code. */ +#ifdef INTR_EVENT_SOURCE_POINTERS + interrupt_t *ie_source; /* Cookie used by MD code. */ +#endif struct intr_thread *ie_thread; /* Thread we are connected to. */ - void (*ie_pre_ithread)(void *); - void (*ie_post_ithread)(void *); - void (*ie_post_filter)(void *); - int (*ie_assign_cpu)(void *, int); + device_t ie_pic; int ie_flags; int ie_hflags; /* Cumulative flags of all handlers. */ int ie_count; /* Loop counter. */ @@ -174,6 +188,18 @@ int intr_event_bind_ithread(struct intr_event *ie, int cpu); struct _cpuset; int intr_event_bind_ithread_cpuset(struct intr_event *ie, struct _cpuset *mask); +#ifndef INTR_EVENT_SOURCE_POINTERS +int intr_event_init(struct intr_event *event, device_t pic, u_int irq, + int flags, const char *fmt, ...) __printflike(5, 6) + __result_use_check; +#else +int intr_event_init(struct intr_event *event, device_t pic, + interrupt_t *source, u_int irq, int flags, const char *fmt, ...) + __printflike(6, 7) __result_use_check; +int intr_event_create_device(struct intr_event **event, device_t pic, + interrupt_t *source, u_int irq, int flags, const char *fmt, ...) + __printflike(6, 7) __result_use_check; +#endif int intr_event_create(struct intr_event **event, void *source, int flags, u_int irq, void (*pre_ithread)(void *), void (*post_ithread)(void *), void (*post_filter)(void *), @@ -181,6 +207,7 @@ int intr_event_create(struct intr_event **event, void *source, __printflike(9, 10); int intr_event_describe_handler(struct intr_event *ie, void *cookie, const char *descr); +int intr_event_shutdown(struct intr_event *ie) __result_use_check; int intr_event_destroy(struct intr_event *ie); int intr_event_handle(struct intr_event *ie, struct trapframe *frame); int intr_event_remove_handler(void *cookie); diff --git a/sys/sys/intr.h b/sys/sys/intr.h index 77daf5a35f3249..9565b4d87e9cce 100644 --- a/sys/sys/intr.h +++ b/sys/sys/intr.h @@ -33,11 +33,25 @@ #error Need INTRNG for this file #endif -#include +#ifndef __MACHINE_INTERRUPT_H__ +#error "sys/intr.h included without architecture interrupt header!" +#endif + +/* FreeBSD standard interrupt controller interface */ + +typedef struct intr_irqsrc interrupt_t; + +#include + +/* FreeBSD standard interrupt controller interface */ + +#include #define INTR_IRQ_INVALID 0xFFFFFFFF #ifndef LOCORE +struct resource; +struct trapframe; enum intr_map_data_type { INTR_MAP_DATA_ACPI = 0, @@ -81,15 +95,13 @@ struct intr_pic; /* Interrupt source definition. */ struct intr_irqsrc { - device_t isrc_dev; /* where isrc is mapped */ - u_int isrc_irq; /* unique identificator */ + struct intr_event isrc_event; u_int isrc_flags; char isrc_name[INTR_ISRC_NAMELEN]; cpuset_t isrc_cpu; /* on which CPUs is enabled */ u_int isrc_index; u_long * isrc_count; u_int isrc_handlers; - struct intr_event * isrc_event; #ifdef INTR_SOLO intr_irq_filter_t * isrc_filter; void * isrc_arg; diff --git a/sys/sys/kobj.h b/sys/sys/kobj.h index 7adc01c1f1f383..b026c158c617bc 100644 --- a/sys/sys/kobj.h +++ b/sys/sys/kobj.h @@ -29,6 +29,8 @@ #ifndef _SYS_KOBJ_H_ #define _SYS_KOBJ_H_ +#include + /* * Forward declarations */ @@ -54,9 +56,9 @@ struct kobj_method { #define KOBJ_CLASS_FIELDS \ const char *name; /* class name */ \ kobj_method_t *methods; /* method table */ \ - size_t size; /* object size */ \ + __size_t size; /* object size */ \ kobj_class_t *baseclasses; /* base classes */ \ - u_int refs; /* reference count */ \ + unsigned int refs; /* reference count */ \ kobj_ops_t ops /* compiled method table */ struct kobj_class { @@ -131,14 +133,8 @@ struct kobj_class classvar = { \ * DEFINE_CLASS_1(foo, foo_class, foo_methods, sizeof(foo_softc), * bar); */ -#define DEFINE_CLASS_1(name, classvar, methods, size, \ - base1) \ - \ -static kobj_class_t name ## _baseclasses[] = \ - { &base1, NULL }; \ -struct kobj_class classvar = { \ - #name, methods, size, name ## _baseclasses \ -} +#define DEFINE_CLASS_1(name, classvar, methods, size, base1) \ + DEFINE_CLASSN(name, classvar, methods, size, base1) /* * Define a class inheriting two base classes. Use like this: @@ -146,15 +142,8 @@ struct kobj_class classvar = { \ * DEFINE_CLASS_2(foo, foo_class, foo_methods, sizeof(foo_softc), * bar, baz); */ -#define DEFINE_CLASS_2(name, classvar, methods, size, \ - base1, base2) \ - \ -static kobj_class_t name ## _baseclasses[] = \ - { &base1, \ - &base2, NULL }; \ -struct kobj_class classvar = { \ - #name, methods, size, name ## _baseclasses \ -} +#define DEFINE_CLASS_2(name, classvar, methods, size, base1, base2) \ + DEFINE_CLASSN(name, classvar, methods, size, base1, base2) /* * Define a class inheriting three base classes. Use like this: @@ -162,17 +151,70 @@ struct kobj_class classvar = { \ * DEFINE_CLASS_3(foo, foo_class, foo_methods, sizeof(foo_softc), * bar, baz, foobar); */ -#define DEFINE_CLASS_3(name, classvar, methods, size, \ - base1, base2, base3) \ - \ -static kobj_class_t name ## _baseclasses[] = \ - { &base1, \ - &base2, \ - &base3, NULL }; \ -struct kobj_class classvar = { \ - #name, methods, size, name ## _baseclasses \ +#define DEFINE_CLASS_3(name, classvar, methods, size, base1, base2, base3) \ + DEFINE_CLASSN(name, classvar, methods, size, base1, base2, base3) + +/* + * Define a class with unspecified visibility (presently public) + * inheriting any number (including zero) base classes. Use like this: + * + * DEFINE_CLASSN(foo, foo_class, foo_methods, sizeof(foo_softc)[, + * bar[, baz[, foobar]]]); + */ +#define DEFINE_CLASSN(_name, _classvar, _methods, _size, ...) \ + \ +__VA_OPT__(static kobj_class_t _name ## _baseclasses[] = { \ + __DEFINE_CLASSN_BASE_EXPANDER(__VA_ARGS__), NULL }); \ +struct kobj_class _classvar = { \ + .name = #_name, \ + .methods = _methods, \ + .size = _size, \ + __VA_OPT__(.baseclasses = _name ## _baseclasses,) \ } +/* + * Define a public class inheriting any number (including zero) base + * classes. Use like this: + * + * PUBLIC_DEFINE_CLASSN(foo, foo_class, foo_methods, sizeof(foo_softc)[, + * bar[, baz[, foobar]]]); + */ +#define PUBLIC_DEFINE_CLASSN(_name, _classvar, _methods, _size, ...) \ + \ +__VA_OPT__(static kobj_class_t _name ## _baseclasses[] = { \ + __DEFINE_CLASSN_BASE_EXPANDER(__VA_ARGS__), NULL }); \ +struct kobj_class _classvar = { \ + .name = #_name, \ + .methods = _methods, \ + .size = _size, \ + __VA_OPT__(.baseclasses = _name ## _baseclasses,) \ +} + +/* + * Define a private class inheriting any number (including zero) base + * classes. Use like this: + * + * PRIVATE_DEFINE_CLASSN(foo, foo_class, foo_methods, sizeof(foo_softc)[, + * bar[, baz[, foobar]]]); + */ +#define PRIVATE_DEFINE_CLASSN(_name, _classvar, _methods, _size, ...) \ + \ +__VA_OPT__(static kobj_class_t _name ## _baseclasses[] = { \ + __DEFINE_CLASSN_BASE_EXPANDER(__VA_ARGS__), NULL }); \ +static struct kobj_class _classvar = { \ + .name = #_name, \ + .methods = _methods, \ + .size = _size, \ + __VA_OPT__(.baseclasses = _name ## _baseclasses,) \ +} + +/* Helper macros for the above, adding ampersands to parent class names */ +#define __DEFINE_CLASSN_BASE_EXPANDER(_base, ...) \ + &_base __VA_OPT__(, ___DEFINE_CLASSN_BASE_EXPANDER(__VA_ARGS__)) + +#define ___DEFINE_CLASSN_BASE_EXPANDER(_base, ...) \ + &_base __VA_OPT__(, __DEFINE_CLASSN_BASE_EXPANDER(__VA_ARGS__)) + /* * Compile the method table in a class. */ @@ -211,8 +253,8 @@ void kobj_delete(kobj_t obj, struct malloc_type *mtype); * Maintain stats on hits/misses in lookup caches. */ #ifdef KOBJ_STATS -extern u_int kobj_lookup_hits; -extern u_int kobj_lookup_misses; +extern unsigned int kobj_lookup_hits; +extern unsigned int kobj_lookup_misses; #endif /* @@ -220,7 +262,7 @@ extern u_int kobj_lookup_misses; * slow way. */ #ifdef KOBJ_STATS -#define KOBJOPLOOKUP(OPS,OP) do { \ +#define KOBJOPLOOKUP(OPS, OP) __extension__ ({ \ kobjop_desc_t _desc = &OP##_##desc; \ kobj_method_t **_cep = \ &OPS->cache[_desc->id & (KOBJ_CACHE_SIZE-1)]; \ @@ -231,10 +273,10 @@ extern u_int kobj_lookup_misses; kobj_lookup_misses++; \ } else \ kobj_lookup_hits++; \ - _m = _ce->func; \ -} while (0) + (OP##_t *)(_ce->func); \ +}) #else -#define KOBJOPLOOKUP(OPS,OP) do { \ +#define KOBJOPLOOKUP(OPS, OP) __extension__ ({ \ kobjop_desc_t _desc = &OP##_##desc; \ kobj_method_t **_cep = \ &OPS->cache[_desc->id & (KOBJ_CACHE_SIZE-1)]; \ @@ -242,8 +284,8 @@ extern u_int kobj_lookup_misses; if (_ce->desc != _desc) \ _ce = kobj_lookup_method(OPS->cls, \ _cep, _desc); \ - _m = _ce->func; \ -} while (0) + (OP##_t *)(_ce->func); \ +}) #endif kobj_method_t* kobj_lookup_method(kobj_class_t cls, diff --git a/sys/tools/makeobjops.awk b/sys/tools/makeobjops.awk index 5ea658c5a3b327..ca729a3033da7a 100644 --- a/sys/tools/makeobjops.awk +++ b/sys/tools/makeobjops.awk @@ -320,16 +320,16 @@ function handle_method (static, doc) line_width, length(prototype))); } printh("{"); - printh("\tkobjop_t _m;"); + printh("\t" mname "_t *_m;"); if (ret != "void") printh("\t" ret " rc;"); if (!static) firstvar = "((kobj_t)" firstvar ")"; if (prolog != "") printh(prolog); - printh("\tKOBJOPLOOKUP(" firstvar "->ops," mname ");"); + printh("\t_m = KOBJOPLOOKUP(" firstvar "->ops, " mname ");"); rceq = (ret != "void") ? "rc = " : ""; - printh("\t" rceq "((" mname "_t *) _m)(" varname_list ");"); + printh("\t" rceq "_m(" varname_list ");"); if (epilog != "") printh(epilog); if (ret != "void") diff --git a/sys/x86/acpica/madt.c b/sys/x86/acpica/madt.c index a593028ffb5ab9..4d5ddb84b3f4d7 100644 --- a/sys/x86/acpica/madt.c +++ b/sys/x86/acpica/madt.c @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include #include diff --git a/sys/x86/include/intr_machdep.h b/sys/x86/include/interrupt.h similarity index 81% rename from sys/x86/include/intr_machdep.h rename to sys/x86/include/interrupt.h index 9e913440c71268..4867b03a5c79ad 100644 --- a/sys/x86/include/intr_machdep.h +++ b/sys/x86/include/interrupt.h @@ -30,6 +30,18 @@ #ifdef _KERNEL +/* FreeBSD standard interrupt controller interface */ + +typedef struct intsrc interrupt_t; + +#include + +/* FreeBSD standard interrupt controller interface */ + +#include + +typedef struct { device_t next, prev; } pic_base_softc_t; + /* * Values used in determining the allocation of IRQ values among * different types of I/O interrupts. These values are used as @@ -66,37 +78,6 @@ typedef void inthand_t(void); #define IDTVEC(name) __CONCAT(X,name) -struct intsrc; - -/* - * Methods that a PIC provides to mask/unmask a given interrupt source, - * "turn on" the interrupt on the CPU side by setting up an IDT entry, and - * return the vector associated with this source. - */ -struct pic { - void (*pic_register_sources)(struct pic *); - void (*pic_enable_source)(struct intsrc *); - void (*pic_disable_source)(struct intsrc *, int); - void (*pic_eoi_source)(struct intsrc *); - void (*pic_enable_intr)(struct intsrc *); - void (*pic_disable_intr)(struct intsrc *); - int (*pic_vector)(struct intsrc *); - int (*pic_source_pending)(struct intsrc *); - void (*pic_suspend)(struct pic *); - void (*pic_resume)(struct pic *, bool suspend_cancelled); - int (*pic_config_intr)(struct intsrc *, enum intr_trigger, - enum intr_polarity); - int (*pic_assign_cpu)(struct intsrc *, u_int apic_id); - void (*pic_reprogram_pin)(struct intsrc *); - TAILQ_ENTRY(pic) pics; -}; - -/* Flags for pic_disable_source() */ -enum { - PIC_EOI, - PIC_NO_EOI, -}; - /* * An interrupt source. The upper-layer code uses the PIC methods to * control a given source. The lower-layer PIC drivers can store additional @@ -104,8 +85,7 @@ enum { * or an I/O APIC pointer. */ struct intsrc { - struct pic *is_pic; - struct intr_event *is_event; + struct intr_event is_event; u_long *is_count; u_long *is_straycount; u_int is_index; @@ -145,8 +125,10 @@ int intr_describe(struct intsrc *isrc, void *ih, const char *descr); void intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame); u_int intr_next_cpu(int domain); struct intsrc *intr_lookup_source(int vector); -int intr_register_pic(struct pic *pic); -int intr_register_source(struct intsrc *isrc); +device_t intr_create_pic(const char *name, u_int unit, + struct kobj_class *driver); +void intr_register_pic(device_t pic); +int intr_register_source(u_int vector, struct intsrc *isrc, device_t pic); int intr_remove_handler(void *cookie); void intr_resume(bool suspend_cancelled); void intr_suspend(void); diff --git a/sys/x86/include/x86_smp.h b/sys/x86/include/x86_smp.h index 8b9eb2ec9b6629..ae43d6d5f8b965 100644 --- a/sys/x86/include/x86_smp.h +++ b/sys/x86/include/x86_smp.h @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include diff --git a/sys/x86/include/xen/arch-intr.h b/sys/x86/include/xen/arch-intr.h index 5ce0ca06e925c1..288357f09a1c75 100644 --- a/sys/x86/include/xen/arch-intr.h +++ b/sys/x86/include/xen/arch-intr.h @@ -29,12 +29,11 @@ #ifndef _MACHINE__XEN_ARCH_INTR_H_ #define _MACHINE__XEN_ARCH_INTR_H_ -#include +#include #include typedef struct { struct intsrc intsrc; /* @TOP -> *xen_arch_isrc */ - u_int vector; /* Global isrc vector number */ } xen_arch_isrc_t; #include @@ -89,7 +88,7 @@ static inline int xen_arch_intr_event_bind(struct xenisrc *isrc, u_int cpu) { - return (intr_event_bind(isrc->xi_arch.intsrc.is_event, cpu)); + return (intr_event_bind(&isrc->xi_arch.intsrc.is_event, cpu)); } #endif /* _MACHINE__XEN_ARCH_INTR_H_ */ diff --git a/sys/x86/iommu/amd_ctx.c b/sys/x86/iommu/amd_ctx.c index 7e41ecf2dc04ca..b3d67f946aaeaf 100644 --- a/sys/x86/iommu/amd_ctx.c +++ b/sys/x86/iommu/amd_ctx.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/sys/x86/iommu/amd_drv.c b/sys/x86/iommu/amd_drv.c index 77c4c68765c9f2..6001f75c6372da 100644 --- a/sys/x86/iommu/amd_drv.c +++ b/sys/x86/iommu/amd_drv.c @@ -60,7 +60,7 @@ #include #include #include "pcib_if.h" -#include +#include #include #include #include diff --git a/sys/x86/iommu/amd_event.c b/sys/x86/iommu/amd_event.c index 4a52e42260c232..325c3f576365eb 100644 --- a/sys/x86/iommu/amd_event.c +++ b/sys/x86/iommu/amd_event.c @@ -58,7 +58,7 @@ #include #include #include "pcib_if.h" -#include +#include #include #include #include diff --git a/sys/x86/iommu/amd_idpgtbl.c b/sys/x86/iommu/amd_idpgtbl.c index 7809a4d5792639..d3fa3940c0d681 100644 --- a/sys/x86/iommu/amd_idpgtbl.c +++ b/sys/x86/iommu/amd_idpgtbl.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/sys/x86/iommu/amd_intrmap.c b/sys/x86/iommu/amd_intrmap.c index a4c1a783626844..ffd8aa81a19952 100644 --- a/sys/x86/iommu/amd_intrmap.c +++ b/sys/x86/iommu/amd_intrmap.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -63,7 +62,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c index b4ea1e82696b4a..b3503540048b2b 100644 --- a/sys/x86/iommu/intel_ctx.c +++ b/sys/x86/iommu/intel_ctx.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -60,6 +59,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index dd2a3d1a631f0f..cfb904b8b78bce 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -75,7 +75,7 @@ #ifdef DEV_APIC #include "pcib_if.h" -#include +#include #include #include #endif diff --git a/sys/x86/iommu/intel_idpgtbl.c b/sys/x86/iommu/intel_idpgtbl.c index b133dc875515fd..34484b317c2292 100644 --- a/sys/x86/iommu/intel_idpgtbl.c +++ b/sys/x86/iommu/intel_idpgtbl.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -60,6 +59,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/x86/iommu/intel_intrmap.c b/sys/x86/iommu/intel_intrmap.c index 06e41523624b89..0ae2bfbc859f0d 100644 --- a/sys/x86/iommu/intel_intrmap.c +++ b/sys/x86/iommu/intel_intrmap.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/x86/iommu/intel_utils.c b/sys/x86/iommu/intel_utils.c index 287b5fe9376ab3..e327f21ed44615 100644 --- a/sys/x86/iommu/intel_utils.c +++ b/sys/x86/iommu/intel_utils.c @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/x86/iommu/iommu_utils.c b/sys/x86/iommu/iommu_utils.c index 2db02a98ca914e..f9c5db5f33c9f3 100644 --- a/sys/x86/iommu/iommu_utils.c +++ b/sys/x86/iommu/iommu_utils.c @@ -69,7 +69,7 @@ #include #ifdef DEV_APIC #include "pcib_if.h" -#include +#include #include #include #endif diff --git a/sys/x86/isa/atpic.c b/sys/x86/isa/atpic.c index 56566ef8d64db2..e38bfcbcab1fa9 100644 --- a/sys/x86/isa/atpic.c +++ b/sys/x86/isa/atpic.c @@ -37,15 +37,15 @@ #include #include #include -#include #include #include #include #include +#include #include #include -#include +#include #include #include #include @@ -55,6 +55,8 @@ #include #include +#include "pic_if.h" + #ifdef __amd64__ #define SDT_ATPIC SDT_SYSIGT #define GSEL_ATPIC 0 @@ -90,22 +92,7 @@ inthand_t IDTVEC(atpic_intr12_pti), IDTVEC(atpic_intr13_pti), IDTVEC(atpic_intr14_pti), IDTVEC(atpic_intr15_pti); -#define IRQ(ap, ai) ((ap)->at_irqbase + (ai)->at_irq) - -#define ATPIC(io, base, eoi) { \ - .at_pic = { \ - .pic_register_sources = atpic_register_sources, \ - .pic_enable_source = atpic_enable_source, \ - .pic_disable_source = atpic_disable_source, \ - .pic_eoi_source = (eoi), \ - .pic_enable_intr = atpic_enable_intr, \ - .pic_disable_intr = atpic_disable_intr, \ - .pic_vector = atpic_vector, \ - .pic_source_pending = atpic_source_pending, \ - .pic_resume = atpic_resume, \ - .pic_config_intr = atpic_config_intr, \ - .pic_assign_cpu = atpic_assign_cpu \ - }, \ +#define ATPIC(io, base) { \ .at_ioaddr = (io), \ .at_irqbase = (base), \ .at_intbase = IDT_IO_INTS + (base), \ @@ -114,19 +101,21 @@ inthand_t #define INTSRC(irq) \ { \ - .at_intsrc = { &atpics[(irq) / 8].at_pic }, \ .at_intr = IDTVEC(atpic_intr ## irq ), \ .at_intr_pti = IDTVEC(atpic_intr ## irq ## _pti), \ .at_irq = (irq) % 8, \ } struct atpic { - struct pic at_pic; + pic_base_softc_t pic_base_softc; + device_t at_pic; int at_ioaddr; int at_irqbase; uint8_t at_intbase; uint8_t at_imen; }; +_Static_assert(offsetof(struct atpic, pic_base_softc) == 0, + ".pic_base_softc misaligned from structure!"); struct atpic_intsrc { struct intsrc at_intsrc; @@ -137,24 +126,52 @@ struct atpic_intsrc { u_long at_straycount; }; -static void atpic_register_sources(struct pic *pic); -static void atpic_enable_source(struct intsrc *isrc); -static void atpic_disable_source(struct intsrc *isrc, int eoi); -static void atpic_eoi_master(struct intsrc *isrc); -static void atpic_eoi_slave(struct intsrc *isrc); -static void atpic_enable_intr(struct intsrc *isrc); -static void atpic_disable_intr(struct intsrc *isrc); -static int atpic_vector(struct intsrc *isrc); -static void atpic_resume(struct pic *pic, bool suspend_cancelled); -static int atpic_source_pending(struct intsrc *isrc); -static int atpic_config_intr(struct intsrc *isrc, enum intr_trigger trig, - enum intr_polarity pol); -static int atpic_assign_cpu(struct intsrc *isrc, u_int apic_id); +static pic_register_sources_t atpic_register_sources; +static intr_event_post_ithread_t atpic_enable_source; +static intr_event_pre_ithread_t atpic_disable_source; +static intr_event_post_filter_t atpic_eoi; +static pic_enable_intr_t atpic_enable_intr; +static pic_disable_intr_t atpic_disable_intr; +static pic_resume_t atpic_resume; +static pic_source_pending_t atpic_source_pending; +static pic_config_intr_t atpic_config_intr; +static pic_assign_cpu_t atpic_assign_cpu; static void i8259_init(struct atpic *pic, int slave); +#ifdef DEV_ISA +static int atpic_probe(device_t dev); +static int atpic_attach(device_t dev); +#endif /* DEV_ISA */ + +static const device_method_t atpic_methods[] = { +#ifdef DEV_ISA + /* Device interface */ + DEVMETHOD(device_probe, atpic_probe), + DEVMETHOD(device_attach, atpic_attach), +#endif /* DEV_ISA */ + + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, atpic_disable_source), + DEVMETHOD(intr_event_post_ithread, atpic_enable_source), + DEVMETHOD(intr_event_post_filter, atpic_eoi), + + /* Interrupt controller interface */ + DEVMETHOD(pic_register_sources, atpic_register_sources), + DEVMETHOD(pic_enable_intr, atpic_enable_intr), + DEVMETHOD(pic_disable_intr, atpic_disable_intr), + DEVMETHOD(pic_source_pending, atpic_source_pending), + DEVMETHOD(pic_resume, atpic_resume), + DEVMETHOD(pic_config_intr, atpic_config_intr), + DEVMETHOD(pic_assign_cpu, atpic_assign_cpu), + + DEVMETHOD_END +}; + +PRIVATE_DEFINE_CLASSN(atpic, atpic_driver, atpic_methods, 0, pic_base_class); + static struct atpic atpics[] = { - ATPIC(IO_ICU1, 0, atpic_eoi_master), - ATPIC(IO_ICU2, 8, atpic_eoi_slave) + ATPIC(IO_ICU1, 0), + ATPIC(IO_ICU2, 8) }; static struct atpic_intsrc atintrs[] = { @@ -182,7 +199,7 @@ static __inline void _atpic_eoi_master(struct intsrc *isrc) { - KASSERT(isrc->is_pic == &atpics[MASTER].at_pic, + KASSERT(isrc->is_event.ie_pic == atpics[MASTER].at_pic, ("%s: mismatched pic", __func__)); #ifndef AUTO_EOI_1 outb(atpics[MASTER].at_ioaddr, OCW2_EOI); @@ -197,7 +214,7 @@ static __inline void _atpic_eoi_slave(struct intsrc *isrc) { - KASSERT(isrc->is_pic == &atpics[SLAVE].at_pic, + KASSERT(isrc->is_event.ie_pic == atpics[SLAVE].at_pic, ("%s: mismatched pic", __func__)); #ifndef AUTO_EOI_2 outb(atpics[SLAVE].at_ioaddr, OCW2_EOI); @@ -208,9 +225,9 @@ _atpic_eoi_slave(struct intsrc *isrc) } static void -atpic_register_sources(struct pic *pic) +atpic_register_sources(device_t pic) { - struct atpic *ap = (struct atpic *)pic; + struct atpic *ap = device_get_softc(pic); struct atpic_intsrc *ai; int i; @@ -237,17 +254,19 @@ atpic_register_sources(struct pic *pic) /* Loop through all interrupt sources and add them. */ for (i = 0, ai = atintrs; i < NUM_ISA_IRQS; i++, ai++) { - if (i == ICU_SLAVEID) + if (i == ICU_SLAVEID) { + ai->at_intsrc.is_event.ie_pic = atpics[i / 8].at_pic; continue; - intr_register_source(&ai->at_intsrc); + } + intr_register_source(i, &ai->at_intsrc, atpics[i / 8].at_pic); } } static void -atpic_enable_source(struct intsrc *isrc) +atpic_enable_source(device_t pic, struct intsrc *isrc) { struct atpic_intsrc *ai = (struct atpic_intsrc *)isrc; - struct atpic *ap = (struct atpic *)isrc->is_pic; + struct atpic *ap = device_get_softc(isrc->is_event.ie_pic); spinlock_enter(); if (ap->at_imen & IMEN_MASK(ai)) { @@ -258,10 +277,10 @@ atpic_enable_source(struct intsrc *isrc) } static void -atpic_disable_source(struct intsrc *isrc, int eoi) +atpic_disable_source(device_t pic, struct intsrc *isrc) { struct atpic_intsrc *ai = (struct atpic_intsrc *)isrc; - struct atpic *ap = (struct atpic *)isrc->is_pic; + struct atpic *ap = device_get_softc(isrc->is_event.ie_pic); spinlock_enter(); if (ai->at_trigger != INTR_TRIGGER_EDGE) { @@ -274,68 +293,65 @@ atpic_disable_source(struct intsrc *isrc, int eoi) * a function pointer. All of the referenced variables should * still be hot in the cache. */ - if (eoi == PIC_EOI) { - if (isrc->is_pic == &atpics[MASTER].at_pic) - _atpic_eoi_master(isrc); - else - _atpic_eoi_slave(isrc); - } + if (isrc->is_event.ie_pic == atpics[MASTER].at_pic) + _atpic_eoi_master(isrc); + else + _atpic_eoi_slave(isrc); spinlock_exit(); } static void -atpic_eoi_master(struct intsrc *isrc) +atpic_eoi(device_t pic, struct intsrc *isrc) { + /* Reference the above comment (atpic_disable_source()) */ + if (isrc->is_event.ie_pic == atpics[MASTER].at_pic) { #ifndef AUTO_EOI_1 - spinlock_enter(); - _atpic_eoi_master(isrc); - spinlock_exit(); + spinlock_enter(); + _atpic_eoi_master(isrc); + spinlock_exit(); #endif -} - -static void -atpic_eoi_slave(struct intsrc *isrc) -{ + } else { #ifndef AUTO_EOI_2 - spinlock_enter(); - _atpic_eoi_slave(isrc); - spinlock_exit(); + spinlock_enter(); + _atpic_eoi_slave(isrc); + spinlock_exit(); #endif + } } static void -atpic_enable_intr(struct intsrc *isrc) +atpic_enable_intr(device_t pic, struct intsrc *isrc) { } static void -atpic_disable_intr(struct intsrc *isrc) -{ -} - -static int -atpic_vector(struct intsrc *isrc) +atpic_disable_intr(device_t pic, struct intsrc *isrc) { struct atpic_intsrc *ai = (struct atpic_intsrc *)isrc; - struct atpic *ap = (struct atpic *)isrc->is_pic; + struct atpic *ap = device_get_softc(isrc->is_event.ie_pic); - return (IRQ(ap, ai)); + spinlock_enter(); + if (ai->at_trigger != INTR_TRIGGER_EDGE) { + ap->at_imen |= IMEN_MASK(ai); + outb(ap->at_ioaddr + ICU_IMR_OFFSET, ap->at_imen); + } + spinlock_exit(); } static int -atpic_source_pending(struct intsrc *isrc) +atpic_source_pending(device_t pic, struct intsrc *isrc) { struct atpic_intsrc *ai = (struct atpic_intsrc *)isrc; - struct atpic *ap = (struct atpic *)isrc->is_pic; + struct atpic *ap = device_get_softc(isrc->is_event.ie_pic); return (inb(ap->at_ioaddr) & IMEN_MASK(ai)); } static void -atpic_resume(struct pic *pic, bool suspend_cancelled) +atpic_resume(device_t pic, bool suspend_cancelled) { - struct atpic *ap = (struct atpic *)pic; + struct atpic *ap = device_get_softc(pic); i8259_init(ap, ap == &atpics[SLAVE]); if (ap == &atpics[SLAVE] && elcr_found) @@ -343,18 +359,18 @@ atpic_resume(struct pic *pic, bool suspend_cancelled) } static int -atpic_config_intr(struct intsrc *isrc, enum intr_trigger trig, +atpic_config_intr(device_t pic, struct intsrc *isrc, enum intr_trigger trig, enum intr_polarity pol) { struct atpic_intsrc *ai = (struct atpic_intsrc *)isrc; - u_int vector; + struct atpic *ap = device_get_softc(isrc->is_event.ie_pic); + const u_int vector = ap->at_irqbase + ai->at_irq; /* Map conforming values to edge/hi and sanity check the values. */ if (trig == INTR_TRIGGER_CONFORM) trig = INTR_TRIGGER_EDGE; if (pol == INTR_POLARITY_CONFORM) pol = INTR_POLARITY_HIGH; - vector = atpic_vector(isrc); if ((trig == INTR_TRIGGER_EDGE && pol == INTR_POLARITY_LOW) || (trig == INTR_TRIGGER_LEVEL && pol == INTR_POLARITY_HIGH)) { printf( @@ -392,14 +408,14 @@ atpic_config_intr(struct intsrc *isrc, enum intr_trigger trig, printf("atpic: Programming IRQ%u as %s\n", vector, trig == INTR_TRIGGER_EDGE ? "edge/high" : "level/low"); spinlock_enter(); - elcr_write_trigger(atpic_vector(isrc), trig); + elcr_write_trigger(vector, trig); ai->at_trigger = trig; spinlock_exit(); return (0); } static int -atpic_assign_cpu(struct intsrc *isrc, u_int apic_id) +atpic_assign_cpu(device_t pic, struct intsrc *isrc, u_int apic_id) { /* @@ -455,12 +471,14 @@ void atpic_startup(void) { struct atpic_intsrc *ai; + struct intsrc *isrc; int i; /* Start off with all interrupts disabled. */ i8259_init(&atpics[MASTER], 0); i8259_init(&atpics[SLAVE], 1); - atpic_enable_source((struct intsrc *)&atintrs[ICU_SLAVEID]); + isrc = &atintrs[ICU_SLAVEID].at_intsrc; + atpic_enable_source(isrc->is_event.ie_pic, isrc); /* Install low-level interrupt handlers for all of our IRQs. */ for (i = 0, ai = atintrs; i < NUM_ISA_IRQS; i++, ai++) { @@ -468,7 +486,7 @@ atpic_startup(void) continue; ai->at_intsrc.is_count = &ai->at_count; ai->at_intsrc.is_straycount = &ai->at_straycount; - setidt(((struct atpic *)ai->at_intsrc.is_pic)->at_intbase + + setidt(((struct atpic *)device_get_softc(ai->at_intsrc.is_event.ie_pic))->at_intbase + ai->at_irq, pti ? ai->at_intr_pti : ai->at_intr, SDT_ATPIC, SEL_KPL, GSEL_ATPIC); } @@ -507,14 +525,18 @@ atpic_startup(void) static void atpic_init(void *dummy __unused) { + int i; /* * Register our PICs, even if we aren't going to use any of their * pins so that they are suspended and resumed. */ - if (intr_register_pic(&atpics[0].at_pic) != 0 || - intr_register_pic(&atpics[1].at_pic) != 0) - panic("Unable to register ATPICs"); + for (i = 0; i < nitems(atpics); ++i) { + struct atpic *ap = atpics + i; + ap->at_pic = intr_create_pic("atpic", i, &atpic_driver); + device_set_softc(ap->at_pic, ap); + intr_register_pic(ap->at_pic); + } if (num_io_irqs == 0) num_io_irqs = NUM_ISA_IRQS; @@ -537,14 +559,15 @@ atpic_handle_intr(u_int vector, struct trapframe *frame) * If we don't have an event, see if this is a spurious * interrupt. */ - if (isrc->is_event == NULL && (vector == 7 || vector == 15)) { + if (!mtx_initialized(&isrc->is_event.ie_lock) && + (vector == 7 || vector == 15)) { int port, isr; /* * Read the ISR register to see if IRQ 7/15 is really * pending. Reset read register back to IRR when done. */ - port = ((struct atpic *)isrc->is_pic)->at_ioaddr; + port = ((struct atpic *)device_get_softc(isrc->is_event.ie_pic))->at_ioaddr; spinlock_enter(); outb(port, OCW3_SEL | OCW3_RR | OCW3_RIS); isr = inb(port); @@ -599,19 +622,6 @@ atpic_attach(device_t dev) return (0); } -static device_method_t atpic_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, atpic_probe), - DEVMETHOD(device_attach, atpic_attach), - { 0, 0 } -}; - -static driver_t atpic_driver = { - "atpic", - atpic_methods, - 1, /* no softc */ -}; - DRIVER_MODULE(atpic, isa, atpic_driver, 0, 0); DRIVER_MODULE(atpic, acpi, atpic_driver, 0, 0); ISA_PNP_INFO(atpic_ids); diff --git a/sys/x86/isa/atrtc.c b/sys/x86/isa/atrtc.c index 63f41d866679cc..3e753aba31b9e1 100644 --- a/sys/x86/isa/atrtc.c +++ b/sys/x86/isa/atrtc.c @@ -50,7 +50,7 @@ #include #include #endif -#include +#include #include "clock_if.h" #ifdef DEV_ACPI #include diff --git a/sys/x86/isa/clock.c b/sys/x86/isa/clock.c index 68d6085d5891e0..fdfee14ccc5960 100644 --- a/sys/x86/isa/clock.c +++ b/sys/x86/isa/clock.c @@ -61,10 +61,11 @@ #include #include #include +#include #include #include -#include +#include #include #include #include @@ -76,6 +77,8 @@ #include #endif +#include "pic_if.h" + int clkintr_pending; #ifndef TIMER_FREQ #define TIMER_FREQ 1193182 @@ -89,7 +92,7 @@ static struct mtx clock_lock; static struct intsrc *i8254_intsrc; static uint16_t i8254_lastcount; static uint16_t i8254_offset; -static int (*i8254_pending)(struct intsrc *); +static pic_source_pending_t *i8254_pending; static int i8254_ticked; struct attimer_softc { @@ -491,7 +494,8 @@ i8254_get_timecount(struct timecounter *tc) (!i8254_ticked && (clkintr_pending || ((count < 20 || (!(flags & PSL_I) && count < i8254_max_count / 2u)) && - i8254_pending != NULL && i8254_pending(i8254_intsrc))))) { + i8254_pending != NULL && + i8254_pending(i8254_intsrc->is_event.ie_pic, i8254_intsrc))))) { i8254_ticked = 1; i8254_offset += i8254_max_count; } @@ -515,7 +519,7 @@ attimer_start(struct eventtimer *et, sbintime_t first, sbintime_t period) sc->period = first; } if (!sc->intr_en) { - i8254_intsrc->is_pic->pic_enable_source(i8254_intsrc); + INTR_EVENT_POST_ITHREAD(i8254_intsrc->is_event.ie_pic, i8254_intsrc); sc->intr_en = 1; } set_i8254_freq(sc->mode, sc->period); @@ -571,7 +575,7 @@ attimer_attach(device_t dev) device_printf(dev,"Warning: Couldn't map I/O.\n"); i8254_intsrc = intr_lookup_source(0); if (i8254_intsrc != NULL) - i8254_pending = i8254_intsrc->is_pic->pic_source_pending; + i8254_pending = KOBJOPLOOKUP(((kobj_t)(i8254_intsrc->is_event.ie_pic))->ops, pic_source_pending); resource_int_value(device_get_name(dev), device_get_unit(dev), "timecounter", &i8254_timecounter); set_i8254_freq(MODE_STOP, 0); @@ -606,7 +610,7 @@ attimer_attach(device_t dev) return (0); } i8254_intsrc->is_handlers--; - i8254_intsrc->is_pic->pic_enable_intr(i8254_intsrc); + PIC_ENABLE_INTR(i8254_intsrc->is_event.ie_pic, i8254_intsrc); sc->et.et_name = "i8254"; sc->et.et_flags = ET_FLAGS_PERIODIC; if (!i8254_timecounter) diff --git a/sys/x86/isa/elcr.c b/sys/x86/isa/elcr.c index 6d400fefafa360..fadd5a54e7aad5 100644 --- a/sys/x86/isa/elcr.c +++ b/sys/x86/isa/elcr.c @@ -47,7 +47,7 @@ #include #include #include -#include +#include #define ELCR_PORT 0x4d0 #define ELCR_MASK(irq) (1 << (irq)) diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c index 0401741131044b..8e765f83fc3eb8 100644 --- a/sys/x86/x86/busdma_bounce.c +++ b/sys/x86/x86/busdma_bounce.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -50,6 +49,7 @@ #include #include +#include #include #include #include diff --git a/sys/x86/x86/identcpu.c b/sys/x86/x86/identcpu.c index 3f8f11fda01186..7800fa77f5c8ee 100644 --- a/sys/x86/x86/identcpu.c +++ b/sys/x86/x86/identcpu.c @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/x86/x86/intr_machdep.c b/sys/x86/x86/intr_machdep.c index 023c3df22580de..3b9422b3b55e31 100644 --- a/sys/x86/x86/intr_machdep.c +++ b/sys/x86/x86/intr_machdep.c @@ -39,7 +39,6 @@ #include #include -#include #include #include #include @@ -55,9 +54,11 @@ #include #include #include + #include -#include +#include #include + #ifdef DDB #include #endif @@ -72,7 +73,7 @@ #include -typedef void (*mask_fn)(void *); +#include "pic_if.h" static int intrcnt_index; static struct intsrc **interrupt_sources; @@ -86,7 +87,7 @@ static struct timeout_task intrbalance_task; static struct sx intrsrc_lock; static struct mtx intrpic_lock; static struct mtx intrcnt_lock; -static TAILQ_HEAD(pics_head, pic) pics; +static pic_base_softc_t pics = { NULL, NULL }; u_int num_io_irqs; #if defined(SMP) && !defined(EARLY_AP_STARTUP) @@ -102,10 +103,14 @@ int nintrcnt; static MALLOC_DEFINE(M_INTR, "intr", "Interrupt Sources"); -static int intr_assign_cpu(void *arg, int cpu); -static void intr_disable_src(void *arg); +static intr_event_assign_cpu_t intr_assign_cpu; +#if defined(WITNESS) || defined(INVARIANTS) +static intr_event_pre_ithread_t intr_disable_src; +static intr_event_post_ithread_t intr_enable_source; +static intr_event_post_filter_t intr_eoi_source; +#endif static void intr_init(void *__dummy); -static int intr_pic_registered(struct pic *pic); +static int intr_pic_registered(device_t pic); static void intrcnt_setname(const char *name, int index); static void intrcnt_updatename(struct intsrc *is); static void intrcnt_register(struct intsrc *is); @@ -113,7 +118,7 @@ static void intrcnt_register(struct intsrc *is); /* * SYSINIT levels for SI_SUB_INTR: * - * SI_ORDER_FIRST: Initialize locks and pics TAILQ, xen_hvm_cpu_init + * SI_ORDER_FIRST: Initialize locks and pics list, xen_hvm_cpu_init * SI_ORDER_SECOND: Xen PICs * SI_ORDER_THIRD: Add I/O APIC PICs, alloc MSI and Xen IRQ ranges * SI_ORDER_FOURTH: Add 8259A PICs @@ -123,37 +128,76 @@ static void intrcnt_register(struct intsrc *is); */ static int -intr_pic_registered(struct pic *pic) +intr_pic_registered(device_t pic) { - struct pic *p; + device_t p = pics.next; - TAILQ_FOREACH(p, &pics, pics) { +/* TAILQ_FOREACH(p, &pics, pics) { */ + while (p) { if (p == pic) return (1); + p = ((pic_base_softc_t *)device_get_softc(p))->next; } return (0); } +/* + * Create a new PIC device. This is a helper function meant to handle setup + * steps used by many PIC devices. This can then passed to intr_register_pic() + * for use as an interrupt source. + */ +device_t +intr_create_pic(const char *name, u_int unit, driver_t *driver) +{ + device_t pic, root; + int error; + + root = device_lookup_by_name("root0"); + if (root == NULL) + panic("%s: unable to find root bus", __func__); + pic = bus_generic_add_child(root, BUS_PASS_ORDER_FIRST, name, unit); + if (pic == NULL) + panic("%s: failed to create PIC device \"%s%u\"", __func__, + name, unit); + error = device_set_driver(pic, driver); + if (error != 0) + panic("%s: failed to set PIC driver for %s%u error=%d", + __func__, name, unit, error); + + return (pic); +} + /* * Register a new interrupt controller (PIC). This is to support suspend * and resume where we suspend/resume controllers rather than individual * sources. This also allows controllers with no active sources (such as * 8259As in a system using the APICs) to participate in suspend and resume. */ -int -intr_register_pic(struct pic *pic) +void +intr_register_pic(device_t pic) { - int error; mtx_lock(&intrpic_lock); - if (intr_pic_registered(pic)) - error = EBUSY; + if (__predict_false(intr_pic_registered(pic))) +#if defined(WITNESS) || defined(INVARIANTS) + panic +#else + printf +#endif + ("ERROR: %s: called with already registered PIC", + __func__); else { - TAILQ_INSERT_TAIL(&pics, pic, pics); - error = 0; + device_t p = pics.prev; + pic_base_softc_t *softc = device_get_softc(pic); + softc->next = NULL; + softc->prev = p; + if (p != NULL) + ((pic_base_softc_t *)device_get_softc(p))->next = pic; + else + pics.next = pic; + pics.prev = pic; } mtx_unlock(&intrpic_lock); - return (error); } /* @@ -163,7 +207,7 @@ intr_register_pic(struct pic *pic) static void intr_init_sources(void *arg) { - struct pic *pic; + device_t pic = pics.next; MPASS(num_io_irqs > 0); @@ -202,9 +246,9 @@ intr_init_sources(void *arg) * single-threaded at this point in startup so the list of * PICs shouldn't change. */ - TAILQ_FOREACH(pic, &pics, pics) { - if (pic->pic_register_sources != NULL) - pic->pic_register_sources(pic); + while (pic) { + PIC_REGISTER_SOURCES(pic); + pic = ((pic_base_softc_t *)device_get_softc(pic))->next; } } SYSINIT(intr_init_sources, SI_SUB_INTR, SI_ORDER_FOURTH + 1, intr_init_sources, @@ -216,27 +260,22 @@ SYSINIT(intr_init_sources, SI_SUB_INTR, SI_ORDER_FOURTH + 1, intr_init_sources, * called. */ int -intr_register_source(struct intsrc *isrc) +intr_register_source(u_int vector, struct intsrc *isrc, device_t pic) { - int error, vector; + int error; - KASSERT(intr_pic_registered(isrc->is_pic), ("unregistered PIC")); - vector = isrc->is_pic->pic_vector(isrc); + KASSERT(intr_pic_registered(pic), ("unregistered PIC")); KASSERT(vector < num_io_irqs, ("IRQ %d too large (%u irqs)", vector, num_io_irqs)); - if (interrupt_sources[vector] != NULL) - return (EEXIST); - error = intr_event_create(&isrc->is_event, isrc, 0, vector, - intr_disable_src, (mask_fn)isrc->is_pic->pic_enable_source, - (mask_fn)isrc->is_pic->pic_eoi_source, intr_assign_cpu, "irq%d:", - vector); - if (error) - return (error); sx_xlock(&intrsrc_lock); - if (interrupt_sources[vector] != NULL) { + if (interrupt_sources[vector] == NULL) + error = intr_event_init(&isrc->is_event, pic, vector, 0, + "irq%d:", vector); + else + error = EEXIST; + if (error) { sx_xunlock(&intrsrc_lock); - intr_event_destroy(isrc->is_event); - return (EEXIST); + return (error); } intrcnt_register(isrc); interrupt_sources[vector] = isrc; @@ -261,7 +300,7 @@ intr_add_handler(struct intsrc *isrc, const char *name, driver_filter_t filter, { int error; - error = intr_event_add_handler(isrc->is_event, name, filter, handler, + error = intr_event_add_handler(&isrc->is_event, name, filter, handler, arg, intr_priority(flags), flags, cookiep); if (error == 0) { sx_xlock(&intrsrc_lock); @@ -269,8 +308,8 @@ intr_add_handler(struct intsrc *isrc, const char *name, driver_filter_t filter, isrc->is_handlers++; if (isrc->is_handlers == 1) { isrc->is_domain = domain; - isrc->is_pic->pic_enable_intr(isrc); - isrc->is_pic->pic_enable_source(isrc); + PIC_ENABLE_INTR(isrc->is_event.ie_pic, isrc); + INTR_EVENT_POST_ITHREAD(isrc->is_event.ie_pic, isrc); } sx_xunlock(&intrsrc_lock); } @@ -288,10 +327,8 @@ intr_remove_handler(void *cookie) if (error == 0) { sx_xlock(&intrsrc_lock); isrc->is_handlers--; - if (isrc->is_handlers == 0) { - isrc->is_pic->pic_disable_source(isrc, PIC_NO_EOI); - isrc->is_pic->pic_disable_intr(isrc); - } + if (isrc->is_handlers == 0) + PIC_DISABLE_INTR(isrc->is_event.ie_pic, isrc); intrcnt_updatename(isrc); sx_xunlock(&intrsrc_lock); } @@ -303,18 +340,32 @@ intr_config_intr(struct intsrc *isrc, enum intr_trigger trig, enum intr_polarity pol) { - return (isrc->is_pic->pic_config_intr(isrc, trig, pol)); + return (PIC_CONFIG_INTR(isrc->is_event.ie_pic, isrc, trig, pol)); } +#if defined(WITNESS) || defined(INVARIANTS) static void -intr_disable_src(void *arg) +intr_disable_src(device_t pic, interrupt_t *isrc) { - struct intsrc *isrc; - isrc = arg; - isrc->is_pic->pic_disable_source(isrc, PIC_EOI); + device_printf(pic, "%s() called due to missing handler!", __func__); } +static void +intr_enable_source(device_t pic, interrupt_t *isrc) +{ + + device_printf(pic, "%s() called due to missing handler!", __func__); +} + +static void +intr_eoi_source(device_t pic, interrupt_t *isrc) +{ + + device_printf(pic, "%s() called due to missing handler!", __func__); +} +#endif + void intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame) { @@ -330,13 +381,13 @@ intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame) (*isrc->is_count)++; VM_CNT_INC(v_intr); - ie = isrc->is_event; + ie = &isrc->is_event; /* * XXX: We assume that IRQ 0 is only used for the ISA timer * device (clk). */ - vector = isrc->is_pic->pic_vector(isrc); + vector = ie->ie_irq; if (vector == 0) clkintr_pending = 1; @@ -345,7 +396,7 @@ intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame) * stray count, and log the condition. */ if (intr_event_handle(ie, frame) != 0) { - isrc->is_pic->pic_disable_source(isrc, PIC_EOI); + INTR_EVENT_PRE_ITHREAD(isrc->is_event.ie_pic, isrc); (*isrc->is_straycount)++; if (*isrc->is_straycount < INTR_STRAY_LOG_MAX) log(LOG_ERR, "stray irq%d\n", vector); @@ -359,15 +410,15 @@ intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame) void intr_resume(bool suspend_cancelled) { - struct pic *pic; + device_t pic = pics.next; #ifndef DEV_ATPIC atpic_reset(); #endif mtx_lock(&intrpic_lock); - TAILQ_FOREACH(pic, &pics, pics) { - if (pic->pic_resume != NULL) - pic->pic_resume(pic, suspend_cancelled); + while (pic) { + PIC_RESUME(pic, suspend_cancelled); + pic = ((pic_base_softc_t *)device_get_softc(pic))->next; } mtx_unlock(&intrpic_lock); } @@ -375,30 +426,28 @@ intr_resume(bool suspend_cancelled) void intr_suspend(void) { - struct pic *pic; + device_t pic = pics.prev; mtx_lock(&intrpic_lock); - TAILQ_FOREACH_REVERSE(pic, &pics, pics_head, pics) { - if (pic->pic_suspend != NULL) - pic->pic_suspend(pic); + while (pic) { + PIC_SUSPEND(pic); + pic = ((pic_base_softc_t *)device_get_softc(pic))->prev; } mtx_unlock(&intrpic_lock); } static int -intr_assign_cpu(void *arg, int cpu) +intr_assign_cpu(device_t pic, interrupt_t *isrc, u_int cpu) { #ifdef SMP - struct intsrc *isrc; int error; MPASS(mp_ncpus == 1 || smp_started); /* Nothing to do if there is only a single CPU. */ if (mp_ncpus > 1 && cpu != NOCPU) { - isrc = arg; sx_xlock(&intrsrc_lock); - error = isrc->is_pic->pic_assign_cpu(isrc, cpu_apic_ids[cpu]); + error = PIC_ASSIGN_CPU(isrc->is_event.ie_pic, isrc, cpu_apic_ids[cpu]); if (error == 0) isrc->is_cpu = cpu; sx_xunlock(&intrsrc_lock); @@ -410,6 +459,20 @@ intr_assign_cpu(void *arg, int cpu) #endif } +static device_method_t pic_base_methods[] = { +#if defined(WITNESS) || defined(INVARIANTS) || defined(DDB) + DEVMETHOD(intr_event_pre_ithread, intr_disable_src), + DEVMETHOD(intr_event_post_ithread, intr_enable_source), + DEVMETHOD(intr_event_post_filter, intr_eoi_source), +#endif + DEVMETHOD(intr_event_assign_cpu, intr_assign_cpu), + + DEVMETHOD_END +}; + +PUBLIC_DEFINE_CLASSN(pic_base, pic_base_class, pic_base_methods, + sizeof(pic_base_softc_t)); + static void intrcnt_setname(const char *name, int index) { @@ -422,7 +485,7 @@ static void intrcnt_updatename(struct intsrc *is) { - intrcnt_setname(is->is_event->ie_fullname, is->is_index); + intrcnt_setname(is->is_event.ie_fullname, is->is_index); } static void @@ -430,13 +493,12 @@ intrcnt_register(struct intsrc *is) { char straystr[INTRNAME_LEN]; - KASSERT(is->is_event != NULL, ("%s: isrc with no event", __func__)); mtx_lock_spin(&intrcnt_lock); MPASS(intrcnt_index + 2 <= nintrcnt); is->is_index = intrcnt_index; intrcnt_index += 2; snprintf(straystr, sizeof(straystr), "stray irq%d", - is->is_pic->pic_vector(is)); + is->is_event.ie_irq); intrcnt_updatename(is); is->is_count = &intrcnt[is->is_index]; intrcnt_setname(straystr, is->is_index + 1); @@ -460,7 +522,6 @@ static void intr_init(void *dummy __unused) { - TAILQ_INIT(&pics); mtx_init(&intrpic_lock, "intrpic", NULL, MTX_DEF); sx_init(&intrsrc_lock, "intrsrc"); mtx_init(&intrcnt_lock, "intrcnt", NULL, MTX_SPIN); @@ -510,7 +571,7 @@ intr_describe(struct intsrc *isrc, void *ih, const char *descr) { int error; - error = intr_event_describe_handler(isrc->is_event, ih, descr); + error = intr_event_describe_handler(&isrc->is_event, ih, descr); if (error) return (error); intrcnt_updatename(isrc); @@ -528,8 +589,7 @@ intr_reprogram(void) is = interrupt_sources[v]; if (is == NULL) continue; - if (is->is_pic->pic_reprogram_pin != NULL) - is->is_pic->pic_reprogram_pin(is); + PIC_REPROGRAM_PIN(is->is_event.ie_pic, is); } sx_xunlock(&intrsrc_lock); } @@ -551,7 +611,7 @@ DB_SHOW_COMMAND(irqs, db_show_irqs) isrc = interrupt_sources; for (i = 0; i < num_io_irqs && !db_pager_quit; i++, isrc++) if (*isrc != NULL) - db_dump_intr_event((*isrc)->is_event, verbose); + db_dump_intr_event(&(*isrc)->is_event, verbose); } #endif @@ -669,7 +729,7 @@ sysctl_hw_intrs(SYSCTL_HANDLER_ARGS) if (isrc == NULL) continue; sbuf_printf(&sbuf, "%s:%d @cpu%d(domain%d): %ld\n", - isrc->is_event->ie_fullname, + isrc->is_event.ie_fullname, isrc->is_index, isrc->is_cpu, isrc->is_domain, @@ -741,13 +801,12 @@ intr_balance(void *dummy __unused, int pending __unused) */ for (i = num_io_irqs - 1; i >= 0; i--) { isrc = interrupt_sorted[i]; - if (isrc == NULL || isrc->is_event->ie_cpu != NOCPU) + if (isrc == NULL || isrc->is_event.ie_cpu != NOCPU) continue; cpu = current_cpu[isrc->is_domain]; intr_next_cpu(isrc->is_domain); if (isrc->is_cpu != cpu && - isrc->is_pic->pic_assign_cpu(isrc, - cpu_apic_ids[cpu]) == 0) + PIC_ASSIGN_CPU(isrc->is_event.ie_pic, isrc, cpu_apic_ids[cpu]) == 0) isrc->is_cpu = cpu; } sx_xunlock(&intrsrc_lock); diff --git a/sys/x86/x86/io_apic.c b/sys/x86/x86/io_apic.c index d0f47f82011ac1..abc89e6988db17 100644 --- a/sys/x86/x86/io_apic.c +++ b/sys/x86/x86/io_apic.c @@ -49,12 +49,14 @@ #include #include -#include +#include #include #include #include #include +#include "pic_if.h" + #define IOAPIC_ISA_INTS 16 #define IOAPIC_MEM_REGION 32 #define IOAPIC_REDTBL_LO(i) (IOAPIC_REDTBL + (i) * 2) @@ -91,7 +93,7 @@ struct ioapic_intsrc { }; struct ioapic { - struct pic io_pic; + pic_base_softc_t pic_base_softc; u_int io_id:8; /* logical ID */ u_int io_apic_id:8; /* Id as enumerated by MADT */ u_int io_hw_apic_id:8; /* Content of APIC ID register */ @@ -104,45 +106,52 @@ struct ioapic { device_t pci_dev; /* matched pci device, if found */ struct resource *pci_wnd; /* BAR 0, should be same or alias to io_paddr */ - struct ioapic_intsrc io_pins[0]; + struct ioapic_intsrc io_pins[]; }; +_Static_assert(offsetof(struct ioapic, pic_base_softc) == 0, + ".pic_base_softc misaligned from struct ioapic!"); static u_int ioapic_read(volatile ioapic_t *apic, int reg); static void ioapic_write(volatile ioapic_t *apic, int reg, u_int val); static const char *ioapic_bus_string(int bus_type); static void ioapic_print_irq(struct ioapic_intsrc *intpin); -static void ioapic_register_sources(struct pic *pic); -static void ioapic_enable_source(struct intsrc *isrc); -static void ioapic_disable_source(struct intsrc *isrc, int eoi); -static void ioapic_eoi_source(struct intsrc *isrc); -static void ioapic_enable_intr(struct intsrc *isrc); -static void ioapic_disable_intr(struct intsrc *isrc); -static int ioapic_vector(struct intsrc *isrc); -static int ioapic_source_pending(struct intsrc *isrc); -static int ioapic_config_intr(struct intsrc *isrc, enum intr_trigger trig, - enum intr_polarity pol); -static void ioapic_resume(struct pic *pic, bool suspend_cancelled); -static int ioapic_assign_cpu(struct intsrc *isrc, u_int apic_id); -static void ioapic_program_intpin(struct ioapic_intsrc *intpin); -static void ioapic_reprogram_intpin(struct intsrc *isrc); +static pic_register_sources_t ioapic_register_sources; +static intr_event_post_ithread_t ioapic_enable_source; +static intr_event_pre_ithread_t ioapic_disable_source; +static intr_event_post_filter_t ioapic_eoi_source; +static pic_enable_intr_t ioapic_enable_intr; +static pic_disable_intr_t ioapic_disable_intr; +static pic_source_pending_t ioapic_source_pending; +static pic_config_intr_t ioapic_config_intr; +static pic_resume_t ioapic_resume; +static pic_assign_cpu_t ioapic_assign_cpu; +static void ioapic_program_intpin(struct ioapic *pic, + struct ioapic_intsrc *intpin); +static pic_reprogram_pin_t ioapic_reprogram_intpin; static STAILQ_HEAD(,ioapic) ioapic_list = STAILQ_HEAD_INITIALIZER(ioapic_list); -struct pic ioapic_template = { - .pic_register_sources = ioapic_register_sources, - .pic_enable_source = ioapic_enable_source, - .pic_disable_source = ioapic_disable_source, - .pic_eoi_source = ioapic_eoi_source, - .pic_enable_intr = ioapic_enable_intr, - .pic_disable_intr = ioapic_disable_intr, - .pic_vector = ioapic_vector, - .pic_source_pending = ioapic_source_pending, - .pic_suspend = NULL, - .pic_resume = ioapic_resume, - .pic_config_intr = ioapic_config_intr, - .pic_assign_cpu = ioapic_assign_cpu, - .pic_reprogram_pin = ioapic_reprogram_intpin, +static const device_method_t ioapic_template[] = { + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, ioapic_disable_source), + DEVMETHOD(intr_event_post_ithread, ioapic_enable_source), + DEVMETHOD(intr_event_post_filter, ioapic_eoi_source), + + /* Interrupt controller interface */ + DEVMETHOD(pic_register_sources, ioapic_register_sources), + DEVMETHOD(pic_enable_intr, ioapic_enable_intr), + DEVMETHOD(pic_disable_intr, ioapic_disable_intr), + DEVMETHOD(pic_source_pending, ioapic_source_pending), + DEVMETHOD(pic_resume, ioapic_resume), + DEVMETHOD(pic_config_intr, ioapic_config_intr), + DEVMETHOD(pic_assign_cpu, ioapic_assign_cpu), + DEVMETHOD(pic_reprogram_pin, ioapic_reprogram_intpin), + + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(io_apic, io_apic_class, ioapic_template, 0, + pic_base_class); + static u_int next_ioapic_base; static u_int next_id; @@ -151,20 +160,16 @@ SYSCTL_INT(_hw_apic, OID_AUTO, enable_extint, CTLFLAG_RDTUN, &enable_extint, 0, "Enable the ExtINT pin in the first I/O APIC"); static void -_ioapic_eoi_source(struct intsrc *isrc, int locked) +_ioapic_eoi_source(struct ioapic *io, struct ioapic_intsrc *src) { - struct ioapic_intsrc *src; - struct ioapic *io; volatile uint32_t *apic_eoi; uint32_t low1; lapic_eoi(); if (!lapic_eoi_suppression) return; - src = (struct ioapic_intsrc *)isrc; if (src->io_edgetrigger) return; - io = (struct ioapic *)isrc->is_pic; /* * Handle targeted EOI for level-triggered pins, if broadcast @@ -179,6 +184,7 @@ _ioapic_eoi_source(struct intsrc *isrc, int locked) io->io_addr + IOAPIC_EOIR); *apic_eoi = src->io_vector; } else { + bool locked = mtx_owned(&icu_lock); /* * Otherwise, if IO-APIC is too old to provide EOIR, * do what Intel did for the Linux kernel. Temporary @@ -260,10 +266,10 @@ ioapic_print_irq(struct ioapic_intsrc *intpin) } static void -ioapic_enable_source(struct intsrc *isrc) +ioapic_enable_source(device_t pic, struct intsrc *isrc) { struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc; - struct ioapic *io = (struct ioapic *)isrc->is_pic; + struct ioapic *io = device_get_softc(isrc->is_event.ie_pic); uint32_t flags; mtx_lock_spin(&icu_lock); @@ -277,10 +283,10 @@ ioapic_enable_source(struct intsrc *isrc) } static void -ioapic_disable_source(struct intsrc *isrc, int eoi) +ioapic_disable_source(device_t pic, struct intsrc *isrc) { struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc; - struct ioapic *io = (struct ioapic *)isrc->is_pic; + struct ioapic *io = device_get_softc(isrc->is_event.ie_pic); uint32_t flags; mtx_lock_spin(&icu_lock); @@ -291,17 +297,17 @@ ioapic_disable_source(struct intsrc *isrc, int eoi) intpin->io_masked = 1; } - if (eoi == PIC_EOI) - _ioapic_eoi_source(isrc, 1); + _ioapic_eoi_source(io, intpin); mtx_unlock_spin(&icu_lock); } static void -ioapic_eoi_source(struct intsrc *isrc) +ioapic_eoi_source(device_t pic, struct intsrc *isrc) { + struct ioapic *io = device_get_softc(isrc->is_event.ie_pic); - _ioapic_eoi_source(isrc, 0); + _ioapic_eoi_source(io, (struct ioapic_intsrc *)isrc); } /* @@ -309,9 +315,8 @@ ioapic_eoi_source(struct intsrc *isrc) * structure. */ static void -ioapic_program_intpin(struct ioapic_intsrc *intpin) +ioapic_program_intpin(struct ioapic *io, struct ioapic_intsrc *intpin) { - struct ioapic *io = (struct ioapic *)intpin->io_intsrc.is_pic; uint32_t low, high; #ifdef IOMMU int error; @@ -406,19 +411,21 @@ ioapic_program_intpin(struct ioapic_intsrc *intpin) } static void -ioapic_reprogram_intpin(struct intsrc *isrc) +ioapic_reprogram_intpin(device_t pic, struct intsrc *isrc) { + struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc; + struct ioapic *io = device_get_softc(isrc->is_event.ie_pic); mtx_lock_spin(&icu_lock); - ioapic_program_intpin((struct ioapic_intsrc *)isrc); + ioapic_program_intpin(io, intpin); mtx_unlock_spin(&icu_lock); } static int -ioapic_assign_cpu(struct intsrc *isrc, u_int apic_id) +ioapic_assign_cpu(device_t pic, struct intsrc *isrc, u_int apic_id) { struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc; - struct ioapic *io = (struct ioapic *)isrc->is_pic; + struct ioapic *io = device_get_softc(isrc->is_event.ie_pic); u_int old_vector, new_vector; u_int old_id; @@ -482,7 +489,7 @@ ioapic_assign_cpu(struct intsrc *isrc, u_int apic_id) printf(") to lapic %u vector %u\n", intpin->io_cpu, intpin->io_vector); } - ioapic_program_intpin(intpin); + ioapic_program_intpin(io, intpin); mtx_unlock_spin(&icu_lock); /* @@ -498,23 +505,34 @@ ioapic_assign_cpu(struct intsrc *isrc, u_int apic_id) } static void -ioapic_enable_intr(struct intsrc *isrc) +ioapic_enable_intr(device_t pic, struct intsrc *isrc) { struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc; if (intpin->io_vector == 0) - if (ioapic_assign_cpu(isrc, intr_next_cpu(isrc->is_domain)) != 0) + if (ioapic_assign_cpu(pic, isrc, intr_next_cpu(isrc->is_domain)) != 0) panic("Couldn't find an APIC vector for IRQ %d", intpin->io_irq); apic_enable_vector(intpin->io_cpu, intpin->io_vector); } static void -ioapic_disable_intr(struct intsrc *isrc) +ioapic_disable_intr(device_t pic, struct intsrc *isrc) { struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc; + struct ioapic *io = device_get_softc(isrc->is_event.ie_pic); + uint32_t flags; u_int vector; + mtx_lock_spin(&icu_lock); + if (!intpin->io_masked && !intpin->io_edgetrigger) { + flags = intpin->io_lowreg | IOART_INTMSET; + ioapic_write(io->io_addr, IOAPIC_REDTBL_LO(intpin->io_intpin), + flags); + intpin->io_masked = 1; + } + mtx_unlock_spin(&icu_lock); + if (intpin->io_vector != 0) { /* Mask this interrupt pin and free its APIC vector. */ vector = intpin->io_vector; @@ -522,23 +540,14 @@ ioapic_disable_intr(struct intsrc *isrc) mtx_lock_spin(&icu_lock); intpin->io_masked = 1; intpin->io_vector = 0; - ioapic_program_intpin(intpin); + ioapic_program_intpin(io, intpin); mtx_unlock_spin(&icu_lock); apic_free_vector(intpin->io_cpu, vector, intpin->io_irq); } } static int -ioapic_vector(struct intsrc *isrc) -{ - struct ioapic_intsrc *pin; - - pin = (struct ioapic_intsrc *)isrc; - return (pin->io_irq); -} - -static int -ioapic_source_pending(struct intsrc *isrc) +ioapic_source_pending(device_t pic, struct intsrc *isrc) { struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc; @@ -548,11 +557,11 @@ ioapic_source_pending(struct intsrc *isrc) } static int -ioapic_config_intr(struct intsrc *isrc, enum intr_trigger trig, +ioapic_config_intr(device_t pic, struct intsrc *isrc, enum intr_trigger trig, enum intr_polarity pol) { struct ioapic_intsrc *intpin = (struct ioapic_intsrc *)isrc; - struct ioapic *io = (struct ioapic *)isrc->is_pic; + struct ioapic *io = device_get_softc(isrc->is_event.ie_pic); int changed; KASSERT(!(trig == INTR_TRIGGER_CONFORM || pol == INTR_POLARITY_CONFORM), @@ -586,20 +595,20 @@ ioapic_config_intr(struct intsrc *isrc, enum intr_trigger trig, changed++; } if (changed) - ioapic_program_intpin(intpin); + ioapic_program_intpin(io, intpin); mtx_unlock_spin(&icu_lock); return (0); } static void -ioapic_resume(struct pic *pic, bool suspend_cancelled) +ioapic_resume(device_t pic, bool suspend_cancelled) { - struct ioapic *io = (struct ioapic *)pic; + struct ioapic *io = device_get_softc(pic); int i; mtx_lock_spin(&icu_lock); for (i = 0; i < io->io_numintr; i++) - ioapic_program_intpin(&io->io_pins[i]); + ioapic_program_intpin(io, &io->io_pins[i]); mtx_unlock_spin(&icu_lock); } @@ -612,6 +621,7 @@ ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase) struct ioapic *io; struct ioapic_intsrc *intpin; ioapic_t *apic; + device_t io_pic; u_int numintr, i; uint32_t value; @@ -631,7 +641,7 @@ ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase) numintr = ((value & IOART_VER_MAXREDIR) >> MAXREDIRSHIFT) + 1; io = malloc(sizeof(struct ioapic) + numintr * sizeof(struct ioapic_intsrc), M_IOAPIC, M_WAITOK); - io->io_pic = ioapic_template; + io->pci_dev = NULL; io->pci_wnd = NULL; mtx_lock_spin(&icu_lock); @@ -657,6 +667,9 @@ ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase) io->io_addr = apic; io->io_paddr = addr; + io_pic = intr_create_pic("ioapic-pic", io->io_id, &io_apic_class); + device_set_softc(io_pic, io); + if (bootverbose) { printf("ioapic%u: ver 0x%02x maxredir 0x%02x\n", io->io_id, (value & IOART_VER_VERSION), (value & IOART_VER_MAXREDIR) @@ -680,8 +693,9 @@ ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase) */ bzero(io->io_pins, sizeof(struct ioapic_intsrc) * numintr); mtx_lock_spin(&icu_lock); + /* stash for intr_register_pic() and intr_register_source() calls */ + io->io_pins->io_intsrc.is_event.ie_pic = io_pic; for (i = 0, intpin = io->io_pins; i < numintr; i++, intpin++) { - intpin->io_intsrc.is_pic = (struct pic *)io; intpin->io_intpin = i; intpin->io_irq = intbase + i; @@ -899,10 +913,10 @@ ioapic_register(ioapic_drv_t io) int i; apic = io->io_addr; + intr_register_pic(io->io_pins->io_intsrc.is_event.ie_pic); mtx_lock_spin(&icu_lock); flags = ioapic_read(apic, IOAPIC_VER) & IOART_VER_VERSION; STAILQ_INSERT_TAIL(&ioapic_list, io, io_next); - mtx_unlock_spin(&icu_lock); printf("ioapic%u irqs %u-%u\n", io->io_id, flags >> 4, flags & 0xf, io->io_intbase, io->io_intbase + io->io_numintr - 1); @@ -911,25 +925,26 @@ ioapic_register(ioapic_drv_t io) * Reprogram pins to handle special case pins (such as NMI and * SMI) and disable normal pins until a handler is registered. */ - intr_register_pic(&io->io_pic); for (i = 0, pin = io->io_pins; i < io->io_numintr; i++, pin++) - ioapic_reprogram_intpin(&pin->io_intsrc); + ioapic_program_intpin(io, pin); + mtx_unlock_spin(&icu_lock); } /* * Add interrupt sources for I/O APIC interrupt pins. */ static void -ioapic_register_sources(struct pic *pic) +ioapic_register_sources(device_t pic) { struct ioapic_intsrc *pin; - struct ioapic *io; + struct ioapic *io = device_get_softc(pic); + device_t io_pic = io->io_pins->io_intsrc.is_event.ie_pic; int i; - io = (struct ioapic *)pic; for (i = 0, pin = io->io_pins; i < io->io_numintr; i++, pin++) { if (pin->io_irq >= 0) - intr_register_source(&pin->io_intsrc); + intr_register_source(pin->io_irq, &pin->io_intsrc, + io_pic); } } @@ -1036,7 +1051,8 @@ static device_method_t ioapic_pci_methods[] = { DEVMETHOD_END }; -DEFINE_CLASS_0(ioapic, ioapic_pci_driver, ioapic_pci_methods, 0); +PRIVATE_DEFINE_CLASSN(ioapic, ioapic_pci_driver, ioapic_pci_methods, 0, + io_apic_class); DRIVER_MODULE(ioapic, pci, ioapic_pci_driver, 0, 0); @@ -1143,7 +1159,7 @@ static device_method_t apic_methods[] = { DEVMETHOD_END }; -DEFINE_CLASS_0(apic, apic_driver, apic_methods, 0); +PRIVATE_DEFINE_CLASSN(apic, apic_driver, apic_methods, 0, io_apic_class); DRIVER_MODULE(apic, nexus, apic_driver, 0, 0); diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index 86cbe9a050dcc7..c799a8537de281 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -65,7 +65,7 @@ #include #include #include -#include +#include #include #include #include @@ -78,6 +78,8 @@ #include #endif +#include "pic_if.h" + #ifdef __amd64__ #define SDT_APIC SDT_SYSIGT #define GSEL_APIC 0 @@ -338,7 +340,7 @@ lapic_is_x2apic(void) } static void lapic_enable(void); -static void lapic_resume(struct pic *pic, bool suspend_cancelled); +static pic_resume_t lapic_resume; static void lapic_timer_oneshot(struct lapic *); static void lapic_timer_oneshot_nointr(struct lapic *, uint32_t); static void lapic_timer_periodic(struct lapic *); @@ -352,7 +354,16 @@ static int lapic_et_stop(struct eventtimer *et); static u_int apic_idt_to_irq(u_int apic_id, u_int vector); static void lapic_set_tpr(u_int vector); -struct pic lapic_pic = { .pic_resume = lapic_resume }; +static const device_method_t lapic_methods[] = { + /* Interrupt controller interface */ + DEVMETHOD(pic_resume, lapic_resume), + DEVMETHOD_END +}; + +PRIVATE_DEFINE_CLASSN(lapic, lapic_class, lapic_methods, + sizeof(pic_base_softc_t), pic_base_class); + +static device_t lapic_pic; static uint32_t lvt_mode_impl(struct lapic *la, struct lvt *lvt, u_int pin, uint32_t value) @@ -1062,7 +1073,7 @@ lapic_enable(void) /* Reset the local APIC on the BSP during resume. */ static void -lapic_resume(struct pic *pic, bool suspend_cancelled) +lapic_resume(device_t pic, bool suspend_cancelled) { lapic_setup(0); @@ -1726,7 +1737,7 @@ DB_SHOW_COMMAND_FLAGS(apic, db_show_apic, DB_CMD_MEMSAFE) if (isrc == NULL || verbose == 0) db_printf("IRQ %u\n", irq); else - db_dump_intr_event(isrc->is_event, + db_dump_intr_event(&isrc->is_event, verbose == 2); } else db_printf("IRQ %u ???\n", irq); @@ -1929,7 +1940,8 @@ apic_setup_io(void *dummy __unused) * Local APIC must be registered before other PICs and pseudo PICs * for proper suspend/resume order. */ - intr_register_pic(&lapic_pic); + lapic_pic = intr_create_pic("lapic", 0, &lapic_class); + intr_register_pic(lapic_pic); retval = best_enum->apic_setup_io(); if (retval != 0) diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c index b293fcedbd8418..3bde8340d1a4b3 100644 --- a/sys/x86/x86/mca.c +++ b/sys/x86/x86/mca.c @@ -40,7 +40,6 @@ #include #include -#include #include #include #include @@ -51,7 +50,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index c0da41a4d2229b..23cd4d20b721ea 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -45,7 +45,6 @@ #include /* cngetc() */ #include #include -#include #include #include #include @@ -70,6 +69,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/x86/x86/mptable.c b/sys/x86/x86/mptable.c index 4f078fd05ec607..d5e351a524f8f5 100644 --- a/sys/x86/x86/mptable.c +++ b/sys/x86/x86/mptable.c @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/x86/x86/msi.c b/sys/x86/x86/msi.c index 9d5a51f9753c2b..d8eb1395d03413 100644 --- a/sys/x86/x86/msi.c +++ b/sys/x86/x86/msi.c @@ -54,12 +54,14 @@ #include #include #include -#include +#include #include #include #include #include +#include "pic_if.h" + /* Fields in address for Intel MSI messages. */ #define MSI_INTEL_ADDR_DEST 0x000ff000 #define MSI_INTEL_ADDR_RH 0x00000008 @@ -115,7 +117,6 @@ struct msi_intsrc { device_t msi_dev; /* Owning device. (g) */ struct msi_intsrc *msi_first; /* First source in group. */ u_int *msi_irqs; /* Group's IRQ list. (g) */ - u_int msi_irq; /* IRQ cookie. */ u_int msi_cpu; /* Local APIC ID. (g) */ u_int msi_remap_cookie; /* IOMMU cookie. */ u_int msi_vector:8; /* IDT vector. */ @@ -126,32 +127,31 @@ struct msi_intsrc { }; static void msi_create_source(void); -static void msi_enable_source(struct intsrc *isrc); -static void msi_disable_source(struct intsrc *isrc, int eoi); -static void msi_eoi_source(struct intsrc *isrc); -static void msi_enable_intr(struct intsrc *isrc); -static void msi_disable_intr(struct intsrc *isrc); -static int msi_vector(struct intsrc *isrc); -static int msi_source_pending(struct intsrc *isrc); -static int msi_config_intr(struct intsrc *isrc, enum intr_trigger trig, - enum intr_polarity pol); -static int msi_assign_cpu(struct intsrc *isrc, u_int apic_id); - -struct pic msi_pic = { - .pic_enable_source = msi_enable_source, - .pic_disable_source = msi_disable_source, - .pic_eoi_source = msi_eoi_source, - .pic_enable_intr = msi_enable_intr, - .pic_disable_intr = msi_disable_intr, - .pic_vector = msi_vector, - .pic_source_pending = msi_source_pending, - .pic_suspend = NULL, - .pic_resume = NULL, - .pic_config_intr = msi_config_intr, - .pic_assign_cpu = msi_assign_cpu, - .pic_reprogram_pin = NULL, +static intr_event_post_ithread_t msi_enable_source; +static intr_event_post_filter_t msi_eoi_source; +static pic_enable_intr_t msi_enable_intr; +static pic_disable_intr_t msi_disable_intr; +static pic_assign_cpu_t msi_assign_cpu; + +static const device_method_t msi_methods[] = { + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, msi_eoi_source), + DEVMETHOD(intr_event_post_ithread, msi_enable_source), + DEVMETHOD(intr_event_post_filter, msi_eoi_source), + + /* Interrupt controller interface */ + DEVMETHOD(pic_enable_intr, msi_enable_intr), + DEVMETHOD(pic_disable_intr, msi_disable_intr), + DEVMETHOD(pic_assign_cpu, msi_assign_cpu), + + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(msi, msi_class, msi_methods, sizeof(pic_base_softc_t), + pic_base_class); + +static device_t msi_pic; + u_int first_msi_irq; SYSCTL_UINT(_machdep, OID_AUTO, first_msi_irq, CTLFLAG_RD, &first_msi_irq, 0, "Number of first IRQ reserved for MSI and MSI-X interrupts"); @@ -181,27 +181,19 @@ static u_int msi_last_irq; static struct mtx msi_lock; static void -msi_enable_source(struct intsrc *isrc) +msi_enable_source(device_t pic, struct intsrc *isrc) { } static void -msi_disable_source(struct intsrc *isrc, int eoi) -{ - - if (eoi == PIC_EOI) - lapic_eoi(); -} - -static void -msi_eoi_source(struct intsrc *isrc) +msi_eoi_source(device_t pic, struct intsrc *isrc) { lapic_eoi(); } static void -msi_enable_intr(struct intsrc *isrc) +msi_enable_intr(device_t pic, struct intsrc *isrc) { struct msi_intsrc *msi = (struct msi_intsrc *)isrc; @@ -214,7 +206,7 @@ msi_enable_intr(struct intsrc *isrc) } static void -msi_disable_intr(struct intsrc *isrc) +msi_disable_intr(device_t pic, struct intsrc *isrc) { struct msi_intsrc *msi = (struct msi_intsrc *)isrc; @@ -227,30 +219,7 @@ msi_disable_intr(struct intsrc *isrc) } static int -msi_vector(struct intsrc *isrc) -{ - struct msi_intsrc *msi = (struct msi_intsrc *)isrc; - - return (msi->msi_irq); -} - -static int -msi_source_pending(struct intsrc *isrc) -{ - - return (0); -} - -static int -msi_config_intr(struct intsrc *isrc, enum intr_trigger trig, - enum intr_polarity pol) -{ - - return (ENODEV); -} - -static int -msi_assign_cpu(struct intsrc *isrc, u_int apic_id) +msi_assign_cpu(device_t pic, struct intsrc *isrc, u_int apic_id) { struct msi_intsrc *sib, *msi = (struct msi_intsrc *)isrc; int old_vector; @@ -281,7 +250,8 @@ msi_assign_cpu(struct intsrc *isrc, u_int apic_id) vector = apic_alloc_vectors(apic_id, msi->msi_irqs, msi->msi_count, msi->msi_maxcount); } else - vector = apic_alloc_vector(apic_id, msi->msi_irq); + vector = apic_alloc_vector(apic_id, + msi->msi_intsrc.is_event.ie_irq); if (vector == 0) return (ENOSPC); @@ -293,11 +263,12 @@ msi_assign_cpu(struct intsrc *isrc, u_int apic_id) apic_enable_vector(apic_id, vector + i); } error = BUS_REMAP_INTR(device_get_parent(msi->msi_dev), msi->msi_dev, - msi->msi_irq); + msi->msi_intsrc.is_event.ie_irq); if (error == 0) { if (bootverbose) { printf("msi: Assigning %s IRQ %d to local APIC %u vector %u\n", - msi->msi_msix ? "MSI-X" : "MSI", msi->msi_irq, + msi->msi_msix ? "MSI-X" : "MSI", + msi->msi_intsrc.is_event.ie_irq, msi->msi_cpu, msi->msi_vector); } for (i = 1; i < msi->msi_count; i++) { @@ -307,13 +278,13 @@ msi_assign_cpu(struct intsrc *isrc, u_int apic_id) sib->msi_vector = vector + i; if (bootverbose) printf("msi: Assigning MSI IRQ %d to local APIC %u vector %u\n", - sib->msi_irq, sib->msi_cpu, - sib->msi_vector); + sib->msi_intsrc.is_event.ie_irq, + sib->msi_cpu, sib->msi_vector); } } else { device_printf(msi->msi_dev, "remap irq %u to APIC ID %u failed (error %d)\n", - msi->msi_irq, apic_id, error); + msi->msi_intsrc.is_event.ie_irq, apic_id, error); msi->msi_cpu = old_id; msi->msi_vector = old_vector; old_id = apic_id; @@ -329,7 +300,7 @@ msi_assign_cpu(struct intsrc *isrc, u_int apic_id) for (i = 0; i < msi->msi_count; i++) apic_disable_vector(old_id, old_vector + i); } - apic_free_vector(old_id, old_vector, msi->msi_irq); + apic_free_vector(old_id, old_vector, msi->msi_intsrc.is_event.ie_irq); for (i = 1; i < msi->msi_count; i++) apic_free_vector(old_id, old_vector + i, msi->msi_irqs[i]); return (error); @@ -370,7 +341,8 @@ msi_init(void) num_io_irqs = first_msi_irq + num_msi_irqs; msi_enabled = 1; - intr_register_pic(&msi_pic); + msi_pic = intr_create_pic("msi_pic", 0, &msi_class); + intr_register_pic(msi_pic); mtx_init(&msi_lock, "msi", NULL, MTX_DEF); } @@ -390,9 +362,7 @@ msi_create_source(void) mtx_unlock(&msi_lock); msi = malloc(sizeof(struct msi_intsrc), M_MSI, M_WAITOK | M_ZERO); - msi->msi_intsrc.is_pic = &msi_pic; - msi->msi_irq = irq; - intr_register_source(&msi->msi_intsrc); + intr_register_source(irq, &msi->msi_intsrc, msi_pic); nexus_add_irq(irq); } @@ -500,7 +470,8 @@ msi_alloc(device_t dev, int count, int maxcount, int *irqs) if (bootverbose) printf( "msi: routing MSI IRQ %d to local APIC %u vector %u\n", - msi->msi_irq, msi->msi_cpu, msi->msi_vector); + msi->msi_intsrc.is_event.ie_irq, msi->msi_cpu, + msi->msi_vector); msi->msi_first = fsrc; KASSERT(msi->msi_intsrc.is_handlers == 0, ("dead MSI has handlers")); @@ -561,7 +532,8 @@ msi_release(int *irqs, int count) #endif msi->msi_first = NULL; msi->msi_dev = NULL; - apic_free_vector(msi->msi_cpu, msi->msi_vector, msi->msi_irq); + apic_free_vector(msi->msi_cpu, msi->msi_vector, + msi->msi_intsrc.is_event.ie_irq); msi->msi_vector = 0; } @@ -573,7 +545,8 @@ msi_release(int *irqs, int count) #endif first->msi_first = NULL; first->msi_dev = NULL; - apic_free_vector(first->msi_cpu, first->msi_vector, first->msi_irq); + apic_free_vector(first->msi_cpu, first->msi_vector, + first->msi_intsrc.is_event.ie_irq); first->msi_vector = 0; first->msi_count = 0; first->msi_maxcount = 0; @@ -624,7 +597,7 @@ msi_map(int irq, uint64_t *addr, uint32_t *data) if (!msi->msi_msix) { for (k = msi->msi_count - 1, i = first_msi_irq; k > 0 && i < first_msi_irq + num_msi_irqs; i++) { - if (i == msi->msi_irq) + if (i == msi->msi_intsrc.is_event.ie_irq) continue; msi1 = (struct msi_intsrc *)intr_lookup_source(i); if (!msi1->msi_msix && msi1->msi_first == msi) { @@ -731,7 +704,7 @@ msix_alloc(device_t dev, int *irq) if (bootverbose) printf("msi: routing MSI-X IRQ %d to local APIC %u vector %u\n", - msi->msi_irq, cpu, vector); + msi->msi_intsrc.is_event.ie_irq, cpu, vector); /* Setup source. */ msi->msi_cpu = cpu; @@ -777,7 +750,8 @@ msix_release(int irq) #endif msi->msi_first = NULL; msi->msi_dev = NULL; - apic_free_vector(msi->msi_cpu, msi->msi_vector, msi->msi_irq); + apic_free_vector(msi->msi_cpu, msi->msi_vector, + msi->msi_intsrc.is_event.ie_irq); msi->msi_vector = 0; msi->msi_msix = false; msi->msi_count = 0; diff --git a/sys/x86/x86/nexus.c b/sys/x86/x86/nexus.c index 625cd49c7c1bca..d7db30b0d9ca96 100644 --- a/sys/x86/x86/nexus.c +++ b/sys/x86/x86/nexus.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -65,7 +64,7 @@ #include #include -#include +#include #include #include #include @@ -520,7 +519,7 @@ nexus_bind_intr(device_t dev, device_t child, struct resource *irq, int cpu) isrc = intr_lookup_source(rman_get_start(irq)); if (isrc == NULL) return (EINVAL); - return (intr_event_bind(isrc->is_event, cpu)); + return (intr_event_bind(&isrc->is_event, cpu)); } #endif diff --git a/sys/x86/x86/pic_if.m b/sys/x86/x86/pic_if.m new file mode 100644 index 00000000000000..8732da76a5972c --- /dev/null +++ b/sys/x86/x86/pic_if.m @@ -0,0 +1,107 @@ +#- +# Copyright © 2024 Elliott Mitchell +# +# 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. +# + +INTERFACE pic; + +HEADER { + #include + #include + #include + #include + + #include + + #include "intr_event_if.h" +}; + +CODE { + static void + null_pic_generic(device_t pic) + { + } + + static void + null_pic_resume(device_t pic, bool suspend_cancelled) + { + } + + static int + nodev_config_intr(device_t pic, struct intsrc *isrc, + enum intr_trigger trigger, enum intr_polarity polarity) + { + return (ENODEV); + } + + static void + null_pic_reprogram_pin(device_t pic, struct intsrc *isrc) + { + } +} + +METHOD void register_sources { + device_t pic; +} DEFAULT null_pic_generic; + +METHOD void enable_intr { + device_t pic; + struct intsrc *isrc; +}; + +METHOD void disable_intr { + device_t pic; + struct intsrc *isrc; +}; + +METHOD int source_pending { + device_t pic; + struct intsrc *isrc; +} + +METHOD void suspend { + device_t pic; +} DEFAULT null_pic_generic; + +METHOD void resume { + device_t pic; + bool suspend_cancelled; +} DEFAULT null_pic_resume; + +METHOD int config_intr { + device_t pic; + struct intsrc *isrc; + enum intr_trigger trigger; + enum intr_polarity polarity; +} DEFAULT nodev_config_intr; + +METHOD int assign_cpu { + device_t pic; + struct intsrc *isrc; + u_int apic_id; +}; + +METHOD void reprogram_pin { + device_t pic; + struct intsrc *isrc; +} DEFAULT null_pic_reprogram_pin; diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index 388543d6425410..4c0fc9079957dd 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -59,13 +59,12 @@ #include #include -#include +#include #include #include #include #include #include -#include #include #include #include diff --git a/sys/x86/xen/xen_apic.c b/sys/x86/xen/xen_apic.c index 994dc3e0804c3f..9c01d3a3336f0f 100644 --- a/sys/x86/xen/xen_apic.c +++ b/sys/x86/xen/xen_apic.c @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include diff --git a/sys/x86/xen/xen_arch_intr.c b/sys/x86/xen/xen_arch_intr.c index dcf8b4aa35f160..78b7e9bf2dcc55 100644 --- a/sys/x86/xen/xen_arch_intr.c +++ b/sys/x86/xen/xen_arch_intr.c @@ -37,18 +37,21 @@ #include #include #include -#include #include #include #include #include +#include + #include #include #include #include +#include "pic_if.h" + /************************ Xen x86 interrupt interface ************************/ /* @@ -144,7 +147,7 @@ xen_intr_alloc_irqs(void) } static void -xen_intr_pic_enable_source(struct intsrc *isrc) +xen_intr_pic_enable_source(device_t pic, struct intsrc *isrc) { _Static_assert(offsetof(struct xenisrc, xi_arch.intsrc) == 0, @@ -158,7 +161,7 @@ xen_intr_pic_enable_source(struct intsrc *isrc) * \param isrc The interrupt source to EOI. */ static void -xen_intr_pic_disable_source(struct intsrc *isrc, int eoi) +xen_intr_pic_disable_source(device_t pic, struct intsrc *isrc) { _Static_assert(offsetof(struct xenisrc, xi_arch.intsrc) == 0, @@ -167,14 +170,14 @@ xen_intr_pic_disable_source(struct intsrc *isrc, int eoi) } static void -xen_intr_pic_eoi_source(struct intsrc *isrc) +xen_intr_pic_eoi_source(device_t pic, struct intsrc *isrc) { /* Nothing to do on end-of-interrupt */ } static void -xen_intr_pic_enable_intr(struct intsrc *isrc) +xen_intr_pic_enable_intr(device_t pic, struct intsrc *isrc) { _Static_assert(offsetof(struct xenisrc, xi_arch.intsrc) == 0, @@ -183,88 +186,26 @@ xen_intr_pic_enable_intr(struct intsrc *isrc) } static void -xen_intr_pic_disable_intr(struct intsrc *isrc) +xen_intr_pic_disable_intr(device_t pic, struct intsrc *isrc) { _Static_assert(offsetof(struct xenisrc, xi_arch.intsrc) == 0, "xi_arch MUST be at top of xenisrc for x86"); + xen_intr_disable_source((struct xenisrc *)isrc); xen_intr_disable_intr((struct xenisrc *)isrc); } -/** - * Determine the global interrupt vector number for - * a Xen interrupt source. - * - * \param isrc The interrupt source to query. - * - * \return The vector number corresponding to the given interrupt source. - */ -static int -xen_intr_pic_vector(struct intsrc *isrc) -{ - - _Static_assert(offsetof(struct xenisrc, xi_arch.intsrc) == 0, - "xi_arch MUST be at top of xenisrc for x86"); - - return (((struct xenisrc *)isrc)->xi_arch.vector); -} - -/** - * Determine whether or not interrupt events are pending on the - * the given interrupt source. - * - * \param isrc The interrupt source to query. - * - * \returns 0 if no events are pending, otherwise non-zero. - */ -static int -xen_intr_pic_source_pending(struct intsrc *isrc) -{ - /* - * EventChannels are edge triggered and never masked. - * There can be no pending events. - */ - return (0); -} - -/** - * Prepare this PIC for system suspension. - */ static void -xen_intr_pic_suspend(struct pic *pic) -{ - - /* Nothing to do on suspend */ -} - -static void -xen_intr_pic_resume(struct pic *pic, bool suspend_cancelled) +xen_intr_pic_resume(device_t pic, bool suspend_cancelled) { if (!suspend_cancelled) xen_intr_resume(); } -/** - * Perform configuration of an interrupt source. - * - * \param isrc The interrupt source to configure. - * \param trig Edge or level. - * \param pol Active high or low. - * - * \returns 0 if no events are pending, otherwise non-zero. - */ -static int -xen_intr_pic_config_intr(struct intsrc *isrc, enum intr_trigger trig, - enum intr_polarity pol) -{ - /* Configuration is only possible via the evtchn apis. */ - return (ENODEV); -} - static int -xen_intr_pic_assign_cpu(struct intsrc *isrc, u_int apic_id) +xen_intr_pic_assign_cpu(device_t pic, struct intsrc *isrc, u_int apic_id) { _Static_assert(offsetof(struct xenisrc, xi_arch.intsrc) == 0, @@ -276,33 +217,36 @@ xen_intr_pic_assign_cpu(struct intsrc *isrc, u_int apic_id) /** * PIC interface for all event channel port types except physical IRQs. */ -static struct pic xen_intr_pic = { - .pic_enable_source = xen_intr_pic_enable_source, - .pic_disable_source = xen_intr_pic_disable_source, - .pic_eoi_source = xen_intr_pic_eoi_source, - .pic_enable_intr = xen_intr_pic_enable_intr, - .pic_disable_intr = xen_intr_pic_disable_intr, - .pic_vector = xen_intr_pic_vector, - .pic_source_pending = xen_intr_pic_source_pending, - .pic_suspend = xen_intr_pic_suspend, - .pic_resume = xen_intr_pic_resume, - .pic_config_intr = xen_intr_pic_config_intr, - .pic_assign_cpu = xen_intr_pic_assign_cpu, +static const device_method_t xen_intr_methods[] = { + /* Interrupt event interface */ + DEVMETHOD(intr_event_pre_ithread, xen_intr_pic_disable_source), + DEVMETHOD(intr_event_post_ithread, xen_intr_pic_enable_source), + DEVMETHOD(intr_event_post_filter, xen_intr_pic_eoi_source), + + /* Interrupt controller interface */ + DEVMETHOD(pic_enable_intr, xen_intr_pic_enable_intr), + DEVMETHOD(pic_disable_intr, xen_intr_pic_disable_intr), + DEVMETHOD(pic_resume, xen_intr_pic_resume), + DEVMETHOD(pic_assign_cpu, xen_intr_pic_assign_cpu), + + DEVMETHOD_END }; +PRIVATE_DEFINE_CLASSN(xen_intr, xen_intr_class, xen_intr_methods, + sizeof(pic_base_softc_t), pic_base_class); + +static device_t xen_intr_pic; + /******************************* ARCH wrappers *******************************/ void xen_arch_intr_init(void) { - int error; mtx_init(&xen_intr_x86_lock, "xen-x86-table-lock", NULL, MTX_DEF); - error = intr_register_pic(&xen_intr_pic); - if (error != 0) - panic("%s(): failed registering Xen/x86 PIC, error=%d\n", - __func__, error); + xen_intr_pic = intr_create_pic("xen_intr", 0, &xen_intr_class); + intr_register_pic(xen_intr_pic); } /** @@ -327,7 +271,7 @@ xen_arch_intr_alloc(void) SLIST_REMOVE_HEAD(&avail_list, free); mtx_unlock(&xen_intr_x86_lock); - KASSERT(isrc->xi_arch.intsrc.is_pic == &xen_intr_pic, + KASSERT(isrc->xi_arch.intsrc.is_event.ie_pic == xen_intr_pic, ("interrupt not owned by Xen code?")); KASSERT(isrc->xi_arch.intsrc.is_handlers == 0, @@ -353,9 +297,7 @@ xen_arch_intr_alloc(void) mtx_unlock(&xen_intr_x86_lock); isrc = malloc(sizeof(*isrc), M_XENINTR, M_WAITOK | M_ZERO); - isrc->xi_arch.intsrc.is_pic = &xen_intr_pic; - isrc->xi_arch.vector = vector; - error = intr_register_source(&isrc->xi_arch.intsrc); + error = intr_register_source(vector, &isrc->xi_arch.intsrc, xen_intr_pic); if (error != 0) panic("%s(): failed registering interrupt %u, error=%d\n", __func__, vector, error);