diff --git a/arch/arm/src/armv6-m/up_systemreset.c b/arch/arm/src/armv6-m/up_systemreset.c index c5cafd9b816..853b80e6b03 100644 --- a/arch/arm/src/armv6-m/up_systemreset.c +++ b/arch/arm/src/armv6-m/up_systemreset.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv6-m/up_systemreset.c * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * Darcy Gong * @@ -42,6 +42,7 @@ #include +#include #include #include "up_arch.h" @@ -79,31 +80,3 @@ void up_systemreset(void) for (; ; ); } - -/**************************************************************************** - * Name: board_reset - * - * Description: - * Reset board. This function may or may not be supported by a - * particular board architecture. - * - * Input Parameters: - * status - Status information provided with the reset event. This - * meaning of this status information is board-specific. If not used by - * a board, the value zero may be provided in calls to board_reset. - * - * Returned Value: - * If this function returns, then it was not possible to power-off the - * board due to some constraints. The return value int this case is a - * board-specific reason for the failure to shutdown. - * - ****************************************************************************/ - -#ifdef CONFIG_BOARDCTL_RESET -int board_reset(int status) -{ - up_systemreset(); - return 0; -} -#endif - diff --git a/arch/arm/src/armv7-m/up_systemreset.c b/arch/arm/src/armv7-m/up_systemreset.c index 509f7707afe..1f58755fda8 100644 --- a/arch/arm/src/armv7-m/up_systemreset.c +++ b/arch/arm/src/armv7-m/up_systemreset.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-m/up_systemreset.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * Darcy Gong * @@ -42,6 +42,7 @@ #include +#include #include #include "up_arch.h" @@ -79,31 +80,3 @@ void up_systemreset(void) for (; ; ); } - - -/**************************************************************************** - * Name: board_reset - * - * Description: - * Reset board. This function may or may not be supported by a - * particular board architecture. - * - * Input Parameters: - * status - Status information provided with the reset event. This - * meaning of this status information is board-specific. If not used by - * a board, the value zero may be provided in calls to board_reset. - * - * Returned Value: - * If this function returns, then it was not possible to power-off the - * board due to some constraints. The return value int this case is a - * board-specific reason for the failure to shutdown. - * - ****************************************************************************/ - -#ifdef CONFIG_BOARDCTL_RESET -int board_reset(int status) -{ - up_systemreset(); - return 0; -} -#endif diff --git a/arch/arm/src/common/up_internal.h b/arch/arm/src/common/up_internal.h index 1e6651a9734..51ea73f4a4e 100644 --- a/arch/arm/src/common/up_internal.h +++ b/arch/arm/src/common/up_internal.h @@ -331,10 +331,6 @@ void up_pminitialize(void); # define up_pminitialize() #endif -#if defined(CONFIG_ARCH_CORTEXM0) || defined(CONFIG_ARCH_ARMV7M) -void up_systemreset(void) noreturn_function; -#endif - /* Interrupt handling *******************************************************/ void up_irqinitialize(void); diff --git a/arch/arm/src/moxart/moxart_systemreset.c b/arch/arm/src/moxart/moxart_systemreset.c index 6e3e6704721..5d53a25340c 100644 --- a/arch/arm/src/moxart/moxart_systemreset.c +++ b/arch/arm/src/moxart/moxart_systemreset.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/moxart/moxart_systemreset.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2019 Gregory Nutt. All rights reserved. * Author: Anton D. Kachalov * * Redistribution and use in source and binary forms, with or without @@ -41,6 +41,7 @@ #include +#include #include #include "up_arch.h" @@ -79,29 +80,3 @@ void up_systemreset(void) for (; ; ); } -/**************************************************************************** - * Name: board_reset - * - * Description: - * Reset board. This function may or may not be supported by a - * particular board architecture. - * - * Input Parameters: - * status - Status information provided with the reset event. This - * meaning of this status information is board-specific. If not used by - * a board, the value zero may be provided in calls to board_reset. - * - * Returned Value: - * If this function returns, then it was not possible to power-off the - * board due to some constraints. The return value int this case is a - * board-specific reason for the failure to shutdown. - * - ****************************************************************************/ - -#ifdef CONFIG_BOARDCTL_RESET -int board_reset(int status) -{ - up_systemreset(); - return 0; -} -#endif diff --git a/arch/arm/src/samv7/sam_systemreset.c b/arch/arm/src/samv7/sam_systemreset.c index fbc9f19daf2..14ff24ecda3 100644 --- a/arch/arm/src/samv7/sam_systemreset.c +++ b/arch/arm/src/samv7/sam_systemreset.c @@ -43,6 +43,7 @@ #include #include +#include #include #include diff --git a/arch/or1k/src/common/up_internal.h b/arch/or1k/src/common/up_internal.h index 3ec2277b78a..39a1569b423 100644 --- a/arch/or1k/src/common/up_internal.h +++ b/arch/or1k/src/common/up_internal.h @@ -261,8 +261,6 @@ void up_pminitialize(void); # define up_pminitialize() #endif -void up_systemreset(void) noreturn_function; - /* Interrupt handling *******************************************************/ void up_irqinitialize(void); diff --git a/configs/freedom-k66f/src/Makefile b/configs/freedom-k66f/src/Makefile index 138882a365b..18bf1dd80df 100644 --- a/configs/freedom-k66f/src/Makefile +++ b/configs/freedom-k66f/src/Makefile @@ -1,7 +1,7 @@ ############################################################################ # configs/freedom-k66f/src/Makefile # -# Copyright (C) 2016-2017 Gregory Nutt. All rights reserved. +# Copyright (C) 2016-2017, 2019 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # David Sidrane # @@ -51,6 +51,9 @@ endif ifeq ($(CONFIG_LIB_BOARDCTL),y) CSRCS += k66_appinit.c k66_bringup.c +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += k66_reset.c +endif else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y) CSRCS += k66_bringup.c endif diff --git a/configs/freedom-k66f/src/k66_reset.c b/configs/freedom-k66f/src/k66_reset.c new file mode 100644 index 00000000000..6d0bd45f93a --- /dev/null +++ b/configs/freedom-k66f/src/k66_reset.c @@ -0,0 +1,78 @@ +/**************************************************************************** + * config/fredom-k66f/src/k66_reset.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 + * COPYRIGHT OWNER 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * Public functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + up_systemreset(); + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */ diff --git a/configs/lc823450-xgevk/src/Makefile b/configs/lc823450-xgevk/src/Makefile index 07fe5203bd4..cc280549c45 100644 --- a/configs/lc823450-xgevk/src/Makefile +++ b/configs/lc823450-xgevk/src/Makefile @@ -40,6 +40,9 @@ CSRCS = lc823450_boot.c lc823450_mux.c ifeq ($(CONFIG_LIB_BOARDCTL),y) CSRCS += lc823450_appinit.c lc823450_bringup.c +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += lc823450_reset.c +endif else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y) CSRCS += lc823450_bringup.c endif diff --git a/configs/lc823450-xgevk/src/lc823450_reset.c b/configs/lc823450-xgevk/src/lc823450_reset.c new file mode 100644 index 00000000000..ebbb77da6df --- /dev/null +++ b/configs/lc823450-xgevk/src/lc823450_reset.c @@ -0,0 +1,78 @@ +/**************************************************************************** + * configs/lc823450-xgevk/src/lc823450_reset.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 + * COPYRIGHT OWNER 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * Public functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + up_systemreset(); + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */ diff --git a/configs/moxa/src/Makefile b/configs/moxa/src/Makefile index 077c774d200..51020f5e90e 100644 --- a/configs/moxa/src/Makefile +++ b/configs/moxa/src/Makefile @@ -38,8 +38,11 @@ ASRCS = CSRCS = moxart_boot.c -ifeq ($(CONFIG_NSH_LIBRARY),y) +ifeq ($(CONFIG_LIB_BOARDCTL),y) CSRCS += moxart_appinit.c +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += moxart_reset.c +endif endif include $(TOPDIR)/configs/Board.mk diff --git a/configs/moxa/src/moxart_reset.c b/configs/moxa/src/moxart_reset.c new file mode 100644 index 00000000000..d914edffd26 --- /dev/null +++ b/configs/moxa/src/moxart_reset.c @@ -0,0 +1,78 @@ +/**************************************************************************** + * config/moxa/src/moxart_reset.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 + * COPYRIGHT OWNER 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * Public functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + up_systemreset(); + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */ diff --git a/configs/stm32f4discovery/src/Makefile b/configs/stm32f4discovery/src/Makefile index 34d59a0c7fe..8bdf43caea2 100644 --- a/configs/stm32f4discovery/src/Makefile +++ b/configs/stm32f4discovery/src/Makefile @@ -1,7 +1,7 @@ ############################################################################ # configs/stm32f4discovery/src/Makefile # -# Copyright (C) 2011-2013, 2015-2016, 2018 Gregory Nutt. All rights +# Copyright (C) 2011-2013, 2015-2016, 2018-2019 Gregory Nutt. All rights # reserved. # Author: Gregory Nutt # @@ -139,6 +139,9 @@ endif ifeq ($(CONFIG_LIB_BOARDCTL),y) CSRCS += stm32_appinit.c +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += stm32_reset.c +endif endif ifeq ($(CONFIG_ARCH_CUSTOM_PMINIT),y) diff --git a/configs/stm32f4discovery/src/stm32_reset.c b/configs/stm32f4discovery/src/stm32_reset.c new file mode 100644 index 00000000000..98c9ba9dbf3 --- /dev/null +++ b/configs/stm32f4discovery/src/stm32_reset.c @@ -0,0 +1,78 @@ +/**************************************************************************** + * config/stm32f4discovery/src/stm32_reset.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 + * COPYRIGHT OWNER 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * Public functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + up_systemreset(); + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */ diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 49b8bc77cb9..fb7b957da8b 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -98,6 +98,7 @@ #include +#include #include /**************************************************************************** @@ -189,6 +190,18 @@ EXTERN volatile bool g_rtc_enabled; void up_initialize(void); +/**************************************************************************** + * Name: up_systemreset + * + * Description: + * The function up_systemreset() will reset the MCU. Optional! + * Availability of this function is dependent upon the architecture + * support. + * + ****************************************************************************/ + +void up_systemreset(void) noreturn_function; + /**************************************************************************** * Name: up_idle * diff --git a/include/nuttx/board.h b/include/nuttx/board.h index 7b6566a2494..4a173666ac2 100644 --- a/include/nuttx/board.h +++ b/include/nuttx/board.h @@ -245,13 +245,14 @@ int board_power_off(int status); * Name: board_reset * * Description: - * Reset board. This function may or may not be supported by a - * particular board architecture. + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. * * Input Parameters: * status - Status information provided with the reset event. This - * meaning of this status information is board-specific. If not used by - * a board, the value zero may be provided in calls to board_reset. + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). * * Returned Value: * If this function returns, then it was not possible to power-off the