diff --git a/configs/Kconfig b/configs/Kconfig index bf7798327e..50b8c2e9ea 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -2360,6 +2360,14 @@ config LIB_BOARDCTL if LIB_BOARDCTL +config BOARDCTL_FINALINIT + bool "Enable board app final init" + default n + ---help--- + Enables support for the BOARDIOC_FINALINIT boardctl() command. + Architecture specific logic must provide board_app_finalinitialize() + interface. + config BOARDCTL_POWEROFF bool "Enable power off interfaces" default n diff --git a/configs/boardctl.c b/configs/boardctl.c index d7e6d3c4ee..cca53db3c9 100644 --- a/configs/boardctl.c +++ b/configs/boardctl.c @@ -1,7 +1,7 @@ /**************************************************************************** * configs/boardctl.c * - * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2017, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -276,6 +276,22 @@ int boardctl(unsigned int cmd, uintptr_t arg) } break; +#ifdef CONFIG_BOARDCTL_FINALINIT + /* CMD: BOARDIOC_FINALINIT + * DESCRIPTION: Perform one-time application initialization after + * start-up script. + * ARG: The argument has no meaning + * CONFIGURATION: CONFIG_BOARDCTL_FINALINIT + * DEPENDENCIES: Board logic must provide board_app_finalinitialize + */ + + case BOARDIOC_FINALINIT: + { + ret = board_app_finalinitialize(arg); + } + break; +#endif + #ifdef CONFIG_BOARDCTL_POWEROFF /* CMD: BOARDIOC_POWEROFF * DESCRIPTION: Power off the board diff --git a/include/nuttx/board.h b/include/nuttx/board.h index 5c646a48a9..d89209de39 100644 --- a/include/nuttx/board.h +++ b/include/nuttx/board.h @@ -163,6 +163,28 @@ void board_initialize(void); int board_app_initialize(uintptr_t arg); +/**************************************************************************** + * Name: board_app_finalinitialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command + * BOARDIOC_FINALINIT. + * + * Input Parameters: + * arg - The argument has no meaning. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARDCTL_FINALINIT +int board_app_finalinitialize(uintptr_t arg); +#endif + /**************************************************************************** * Name: board_power_off * diff --git a/include/sys/boardctl.h b/include/sys/boardctl.h index 907fbd6606..7d0f4b38a4 100644 --- a/include/sys/boardctl.h +++ b/include/sys/boardctl.h @@ -117,13 +117,14 @@ */ #define BOARDIOC_INIT _BOARDIOC(0x0001) -#define BOARDIOC_POWEROFF _BOARDIOC(0x0002) -#define BOARDIOC_RESET _BOARDIOC(0x0003) -#define BOARDIOC_UNIQUEID _BOARDIOC(0x0004) -#define BOARDIOC_APP_SYMTAB _BOARDIOC(0x0005) -#define BOARDIOC_OS_SYMTAB _BOARDIOC(0x0006) -#define BOARDIOC_USBDEV_CONTROL _BOARDIOC(0x0007) -#define BOARDIOC_NX_START _BOARDIOC(0x0008) +#define BOARDIOC_FINALINIT _BOARDIOC(0x0002) +#define BOARDIOC_POWEROFF _BOARDIOC(0x0003) +#define BOARDIOC_RESET _BOARDIOC(0x0004) +#define BOARDIOC_UNIQUEID _BOARDIOC(0x0005) +#define BOARDIOC_APP_SYMTAB _BOARDIOC(0x0006) +#define BOARDIOC_OS_SYMTAB _BOARDIOC(0x0007) +#define BOARDIOC_USBDEV_CONTROL _BOARDIOC(0x0008) +#define BOARDIOC_NX_START _BOARDIOC(0x0009) /* If CONFIG_BOARDCTL_IOCTL=y, then board-specific commands will be support. * In this case, all commands not recognized by boardctl() will be forwarded