diff --git a/Makefile.dep b/Makefile.dep index 5c468b343c..5fafcc774e 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -30,6 +30,10 @@ ifneq (,$(filter mpu_stack_guard,$(USEMODULE))) FEATURES_REQUIRED += cortexm_mpu endif +ifneq (,$(filter auto_init_gnrc_netif,$(USEMODULE))) + USEMODULE += gnrc_netif_init_devs +endif + ifneq (,$(filter csma_sender,$(USEMODULE))) USEMODULE += random USEMODULE += xtimer diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 2dd7267fd0..0f66cfd87d 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -210,7 +210,6 @@ PSEUDOMODULES += crypto_aes_unroll PSEUDOMODULES += auto_init_% NO_PSEUDOMODULES += auto_init_can NO_PSEUDOMODULES += auto_init_loramac -NO_PSEUDOMODULES += auto_init_gnrc_netif NO_PSEUDOMODULES += auto_init_saul NO_PSEUDOMODULES += auto_init_security NO_PSEUDOMODULES += auto_init_storage diff --git a/sys/auto_init/Makefile b/sys/auto_init/Makefile index 5fedf1d828..3736bf1e52 100644 --- a/sys/auto_init/Makefile +++ b/sys/auto_init/Makefile @@ -1,4 +1,4 @@ -ifneq (,$(filter auto_init_gnrc_netif,$(USEMODULE))) +ifneq (,$(filter gnrc_netif_init,$(USEMODULE))) DIRS += netif endif diff --git a/sys/auto_init/auto_init.c b/sys/auto_init/auto_init.c index f5f338296f..bc8dd5e571 100644 --- a/sys/auto_init/auto_init.c +++ b/sys/auto_init/auto_init.c @@ -26,134 +26,6 @@ #include "kernel_defines.h" #include "log.h" -/** - * @brief Initializes network devices - */ -static void _auto_init_gnrc_netif(void) -{ - if (IS_USED(MODULE_STM32_ETH)) { - extern void auto_init_stm32_eth(void); - auto_init_stm32_eth(); - } - - if (IS_USED(MODULE_AUTO_INIT_AT86RF2XX)) { - extern void auto_init_at86rf2xx(void); - auto_init_at86rf2xx(); - } - - if (IS_USED(MODULE_MRF24J40)) { - extern void auto_init_mrf24j40(void); - auto_init_mrf24j40(); - } - - if (IS_USED(MODULE_CC110X)) { - extern void auto_init_cc110x(void); - auto_init_cc110x(); - } - - if (IS_USED(MODULE_CC2420)) { - extern void auto_init_cc2420(void); - auto_init_cc2420(); - } - - if (IS_USED(MODULE_ENCX24J600)) { - extern void auto_init_encx24j600(void); - auto_init_encx24j600(); - } - - if (IS_USED(MODULE_ENC28J60)) { - extern void auto_init_enc28j60(void); - auto_init_enc28j60(); - } - - if (IS_USED(MODULE_ESP_ETH)) { - extern void auto_init_esp_eth(void); - auto_init_esp_eth(); - } - - /* don't change the order of auto_init_esp_now and auto_init_esp_wifi */ - if (IS_USED(MODULE_ESP_NOW)) { - extern void auto_init_esp_now(void); - auto_init_esp_now(); - } - - /* don't change the order of auto_init_esp_now and auto_init_esp_wifi */ - if (IS_USED(MODULE_ESP_WIFI)) { - extern void auto_init_esp_wifi(void); - auto_init_esp_wifi(); - } - - if (IS_USED(MODULE_ETHOS)) { - extern void auto_init_ethos(void); - auto_init_ethos(); - } - - if (IS_USED(MODULE_DOSE)) { - extern void auto_init_dose(void); - auto_init_dose(); - } - - if (IS_USED(MODULE_SLIPDEV)) { - extern void auto_init_slipdev(void); - auto_init_slipdev(); - } - - if (IS_USED(MODULE_CC2538_RF)) { - extern void auto_init_cc2538_rf(void); - auto_init_cc2538_rf(); - } - - if (IS_USED(MODULE_XBEE)) { - extern void auto_init_xbee(void); - auto_init_xbee(); - } - - if (IS_USED(MODULE_KW2XRF)) { - extern void auto_init_kw2xrf(void); - auto_init_kw2xrf(); - } - - if (IS_USED(MODULE_USBUS_CDC_ECM)) { - extern void auto_init_netdev_cdcecm(void); - auto_init_netdev_cdcecm(); - } - - if (IS_USED(MODULE_NETDEV_TAP)) { - extern void auto_init_netdev_tap(void); - auto_init_netdev_tap(); - } - - if (IS_USED(MODULE_SOCKET_ZEP)) { - extern void auto_init_socket_zep(void); - auto_init_socket_zep(); - } - - if (IS_USED(MODULE_NORDIC_SOFTDEVICE_BLE)) { - extern void gnrc_nordic_ble_6lowpan_init(void); - gnrc_nordic_ble_6lowpan_init(); - } - - if (IS_USED(MODULE_NRFMIN)) { - extern void gnrc_nrfmin_init(void); - gnrc_nrfmin_init(); - } - - if (IS_USED(MODULE_W5100)) { - extern void auto_init_w5100(void); - auto_init_w5100(); - } - - if (IS_USED(MODULE_SX127X) && !IS_USED(MODULE_SEMTECH_LORAMAC)) { - extern void auto_init_sx127x(void); - auto_init_sx127x(); - } - - if (IS_USED(MODULE_NRF802154)) { - extern void auto_init_nrf802154(void); - auto_init_nrf802154(); - } -} - /** * @brief Initializes sensors and actuators for SAUL */ @@ -519,7 +391,8 @@ void auto_init(void) /* initialize network devices */ if (IS_USED(MODULE_AUTO_INIT_GNRC_NETIF)) { LOG_DEBUG("Auto init gnrc_netif.\n"); - _auto_init_gnrc_netif(); + extern void gnrc_netif_init_devs(void); + gnrc_netif_init_devs(); } if (IS_USED(MODULE_AUTO_INIT_GNRC_UHCPC)) { diff --git a/sys/include/net/gnrc/netif.h b/sys/include/net/gnrc/netif.h index f85e867e60..1ec02886ad 100644 --- a/sys/include/net/gnrc/netif.h +++ b/sys/include/net/gnrc/netif.h @@ -233,6 +233,16 @@ struct gnrc_netif_ops { void (*msg_handler)(gnrc_netif_t *netif, msg_t *msg); }; +/** + * @brief Initialize all available network interfaces. + * This function is called automatically if the auto_init_gnrc_netif + * module is used. + * If only the gnrc_netif_init module is used instead, you can call + * this function to manually set up the network interfaces at a later + * time. + */ +void gnrc_netif_init_devs(void); + /** * @brief Creates a network interface * diff --git a/sys/net/gnrc/netif/Makefile b/sys/net/gnrc/netif/Makefile index 872b604667..ca2ce0eb12 100644 --- a/sys/net/gnrc/netif/Makefile +++ b/sys/net/gnrc/netif/Makefile @@ -6,6 +6,9 @@ endif ifneq (,$(filter gnrc_netif_ieee802154,$(USEMODULE))) DIRS += ieee802154 endif +ifneq (,$(filter gnrc_netif_init_devs,$(USEMODULE))) + DIRS += init_devs +endif ifneq (,$(filter gnrc_netif_hdr,$(USEMODULE))) DIRS += hdr endif diff --git a/sys/auto_init/netif/Makefile b/sys/net/gnrc/netif/init_devs/Makefile similarity index 53% rename from sys/auto_init/netif/Makefile rename to sys/net/gnrc/netif/init_devs/Makefile index c1e60318c2..360285603a 100644 --- a/sys/auto_init/netif/Makefile +++ b/sys/net/gnrc/netif/init_devs/Makefile @@ -1,3 +1,3 @@ -MODULE = auto_init_gnrc_netif +MODULE = gnrc_netif_init_devs include $(RIOTBASE)/Makefile.base diff --git a/sys/auto_init/netif/auto_init_at86rf2xx.c b/sys/net/gnrc/netif/init_devs/auto_init_at86rf2xx.c similarity index 100% rename from sys/auto_init/netif/auto_init_at86rf2xx.c rename to sys/net/gnrc/netif/init_devs/auto_init_at86rf2xx.c diff --git a/sys/auto_init/netif/auto_init_cc110x.c b/sys/net/gnrc/netif/init_devs/auto_init_cc110x.c similarity index 100% rename from sys/auto_init/netif/auto_init_cc110x.c rename to sys/net/gnrc/netif/init_devs/auto_init_cc110x.c diff --git a/sys/auto_init/netif/auto_init_cc2420.c b/sys/net/gnrc/netif/init_devs/auto_init_cc2420.c similarity index 100% rename from sys/auto_init/netif/auto_init_cc2420.c rename to sys/net/gnrc/netif/init_devs/auto_init_cc2420.c diff --git a/sys/auto_init/netif/auto_init_cc2538_rf.c b/sys/net/gnrc/netif/init_devs/auto_init_cc2538_rf.c similarity index 100% rename from sys/auto_init/netif/auto_init_cc2538_rf.c rename to sys/net/gnrc/netif/init_devs/auto_init_cc2538_rf.c diff --git a/sys/auto_init/netif/auto_init_cdcecm.c b/sys/net/gnrc/netif/init_devs/auto_init_cdcecm.c similarity index 100% rename from sys/auto_init/netif/auto_init_cdcecm.c rename to sys/net/gnrc/netif/init_devs/auto_init_cdcecm.c diff --git a/sys/auto_init/netif/auto_init_dose.c b/sys/net/gnrc/netif/init_devs/auto_init_dose.c similarity index 100% rename from sys/auto_init/netif/auto_init_dose.c rename to sys/net/gnrc/netif/init_devs/auto_init_dose.c diff --git a/sys/auto_init/netif/auto_init_enc28j60.c b/sys/net/gnrc/netif/init_devs/auto_init_enc28j60.c similarity index 100% rename from sys/auto_init/netif/auto_init_enc28j60.c rename to sys/net/gnrc/netif/init_devs/auto_init_enc28j60.c diff --git a/sys/auto_init/netif/auto_init_encx24j600.c b/sys/net/gnrc/netif/init_devs/auto_init_encx24j600.c similarity index 100% rename from sys/auto_init/netif/auto_init_encx24j600.c rename to sys/net/gnrc/netif/init_devs/auto_init_encx24j600.c diff --git a/sys/auto_init/netif/auto_init_ethos.c b/sys/net/gnrc/netif/init_devs/auto_init_ethos.c similarity index 100% rename from sys/auto_init/netif/auto_init_ethos.c rename to sys/net/gnrc/netif/init_devs/auto_init_ethos.c diff --git a/sys/auto_init/netif/auto_init_kw2xrf.c b/sys/net/gnrc/netif/init_devs/auto_init_kw2xrf.c similarity index 100% rename from sys/auto_init/netif/auto_init_kw2xrf.c rename to sys/net/gnrc/netif/init_devs/auto_init_kw2xrf.c diff --git a/sys/auto_init/netif/auto_init_mrf24j40.c b/sys/net/gnrc/netif/init_devs/auto_init_mrf24j40.c similarity index 100% rename from sys/auto_init/netif/auto_init_mrf24j40.c rename to sys/net/gnrc/netif/init_devs/auto_init_mrf24j40.c diff --git a/sys/auto_init/netif/auto_init_netdev_tap.c b/sys/net/gnrc/netif/init_devs/auto_init_netdev_tap.c similarity index 100% rename from sys/auto_init/netif/auto_init_netdev_tap.c rename to sys/net/gnrc/netif/init_devs/auto_init_netdev_tap.c diff --git a/sys/auto_init/netif/auto_init_nrf802154.c b/sys/net/gnrc/netif/init_devs/auto_init_nrf802154.c similarity index 100% rename from sys/auto_init/netif/auto_init_nrf802154.c rename to sys/net/gnrc/netif/init_devs/auto_init_nrf802154.c diff --git a/sys/auto_init/netif/auto_init_slipdev.c b/sys/net/gnrc/netif/init_devs/auto_init_slipdev.c similarity index 100% rename from sys/auto_init/netif/auto_init_slipdev.c rename to sys/net/gnrc/netif/init_devs/auto_init_slipdev.c diff --git a/sys/auto_init/netif/auto_init_socket_zep.c b/sys/net/gnrc/netif/init_devs/auto_init_socket_zep.c similarity index 100% rename from sys/auto_init/netif/auto_init_socket_zep.c rename to sys/net/gnrc/netif/init_devs/auto_init_socket_zep.c diff --git a/sys/auto_init/netif/auto_init_stm32_eth.c b/sys/net/gnrc/netif/init_devs/auto_init_stm32_eth.c similarity index 100% rename from sys/auto_init/netif/auto_init_stm32_eth.c rename to sys/net/gnrc/netif/init_devs/auto_init_stm32_eth.c diff --git a/sys/auto_init/netif/auto_init_sx127x.c b/sys/net/gnrc/netif/init_devs/auto_init_sx127x.c similarity index 100% rename from sys/auto_init/netif/auto_init_sx127x.c rename to sys/net/gnrc/netif/init_devs/auto_init_sx127x.c diff --git a/sys/auto_init/netif/auto_init_w5100.c b/sys/net/gnrc/netif/init_devs/auto_init_w5100.c similarity index 100% rename from sys/auto_init/netif/auto_init_w5100.c rename to sys/net/gnrc/netif/init_devs/auto_init_w5100.c diff --git a/sys/auto_init/netif/auto_init_xbee.c b/sys/net/gnrc/netif/init_devs/auto_init_xbee.c similarity index 100% rename from sys/auto_init/netif/auto_init_xbee.c rename to sys/net/gnrc/netif/init_devs/auto_init_xbee.c diff --git a/sys/net/gnrc/netif/init_devs/init.c b/sys/net/gnrc/netif/init_devs/init.c new file mode 100644 index 0000000000..7ca10c5697 --- /dev/null +++ b/sys/net/gnrc/netif/init_devs/init.c @@ -0,0 +1,151 @@ +/** + * Auto initialization for network devices + * + * Copyright (C) 2020 Freie Universität Berlin + * 2020 Kaspar Schleiser + * 2013 INRIA. + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + * + * @ingroup sys_auto_init + * @{ + * @file + * @brief initializes any used network interface that has a trivial init function + * @author Oliver Hahm + * @author Hauke Petersen + * @author Kaspar Schleiser + * @author Martine S. Lenders + * @} + */ + +#include "kernel_defines.h" + +/** + * @brief Initializes network devices + */ +void gnrc_netif_init_devs(void) +{ + if (IS_USED(MODULE_STM32_ETH)) { + extern void auto_init_stm32_eth(void); + auto_init_stm32_eth(); + } + + if (IS_USED(MODULE_AUTO_INIT_AT86RF2XX)) { + extern void auto_init_at86rf2xx(void); + auto_init_at86rf2xx(); + } + + if (IS_USED(MODULE_MRF24J40)) { + extern void auto_init_mrf24j40(void); + auto_init_mrf24j40(); + } + + if (IS_USED(MODULE_CC110X)) { + extern void auto_init_cc110x(void); + auto_init_cc110x(); + } + + if (IS_USED(MODULE_CC2420)) { + extern void auto_init_cc2420(void); + auto_init_cc2420(); + } + + if (IS_USED(MODULE_ENCX24J600)) { + extern void auto_init_encx24j600(void); + auto_init_encx24j600(); + } + + if (IS_USED(MODULE_ENC28J60)) { + extern void auto_init_enc28j60(void); + auto_init_enc28j60(); + } + + if (IS_USED(MODULE_ESP_ETH)) { + extern void auto_init_esp_eth(void); + auto_init_esp_eth(); + } + + /* don't change the order of auto_init_esp_now and auto_init_esp_wifi */ + if (IS_USED(MODULE_ESP_NOW)) { + extern void auto_init_esp_now(void); + auto_init_esp_now(); + } + + /* don't change the order of auto_init_esp_now and auto_init_esp_wifi */ + if (IS_USED(MODULE_ESP_WIFI)) { + extern void auto_init_esp_wifi(void); + auto_init_esp_wifi(); + } + + if (IS_USED(MODULE_ETHOS)) { + extern void auto_init_ethos(void); + auto_init_ethos(); + } + + if (IS_USED(MODULE_DOSE)) { + extern void auto_init_dose(void); + auto_init_dose(); + } + + if (IS_USED(MODULE_SLIPDEV)) { + extern void auto_init_slipdev(void); + auto_init_slipdev(); + } + + if (IS_USED(MODULE_CC2538_RF)) { + extern void auto_init_cc2538_rf(void); + auto_init_cc2538_rf(); + } + + if (IS_USED(MODULE_XBEE)) { + extern void auto_init_xbee(void); + auto_init_xbee(); + } + + if (IS_USED(MODULE_KW2XRF)) { + extern void auto_init_kw2xrf(void); + auto_init_kw2xrf(); + } + + if (IS_USED(MODULE_USBUS_CDC_ECM)) { + extern void auto_init_netdev_cdcecm(void); + auto_init_netdev_cdcecm(); + } + + if (IS_USED(MODULE_NETDEV_TAP)) { + extern void auto_init_netdev_tap(void); + auto_init_netdev_tap(); + } + + if (IS_USED(MODULE_SOCKET_ZEP)) { + extern void auto_init_socket_zep(void); + auto_init_socket_zep(); + } + + if (IS_USED(MODULE_NORDIC_SOFTDEVICE_BLE)) { + extern void gnrc_nordic_ble_6lowpan_init(void); + gnrc_nordic_ble_6lowpan_init(); + } + + if (IS_USED(MODULE_NRFMIN)) { + extern void gnrc_nrfmin_init(void); + gnrc_nrfmin_init(); + } + + if (IS_USED(MODULE_W5100)) { + extern void auto_init_w5100(void); + auto_init_w5100(); + } + + if (IS_USED(MODULE_SX127X) && !IS_USED(MODULE_SEMTECH_LORAMAC)) { + extern void auto_init_sx127x(void); + auto_init_sx127x(); + } + + if (IS_USED(MODULE_NRF802154)) { + extern void auto_init_nrf802154(void); + auto_init_nrf802154(); + } +}