diff --git a/configs/sim/src/Makefile b/configs/sim/src/Makefile index 23728049e2..9f45e7e93b 100644 --- a/configs/sim/src/Makefile +++ b/configs/sim/src/Makefile @@ -1,7 +1,7 @@ ############################################################################ # configs/sim/src/Makefile # -# Copyright (C) 2007, 2008, 2011-2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2007, 2008, 2011-2012, 2015 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -40,6 +40,19 @@ CSRCS = ifeq ($(CONFIG_BOARD_INITIALIZE),y) CSRCS += sim_boot.c +endif + +ifeq ($(CONFIG_LIB_BOARDCTL),y) + CSRCS += sim_appinit.c +endif + +ifeq ($(CONFIG_BOARD_INITIALIZE),y) + CSRCS += sim_bringup.c +ifeq ($(CONFIG_SYSTEM_ZONEINFO_ROMFS),y) + CSRCS += sim_zoneinfo.c +endif +else ifeq ($(CONFIG_LIB_BOARDCTL),y) + CSRCS += sim_bringup.c ifeq ($(CONFIG_SYSTEM_ZONEINFO_ROMFS),y) CSRCS += sim_zoneinfo.c endif diff --git a/configs/sim/src/sim.h b/configs/sim/src/sim.h index ce96c2ba01..355d085022 100644 --- a/configs/sim/src/sim.h +++ b/configs/sim/src/sim.h @@ -45,11 +45,30 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +/* procfs File System */ + +#ifdef CONFIG_FS_PROCFS +# ifdef CONFIG_NSH_PROC_MOUNTPOINT +# define SIM_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT +# else +# define SIM_PROCFS_MOUNTPOINT "/proc" +# endif +#endif /**************************************************************************** * Public Function Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: sim_bringup + * + * Description: + * Bring up simulated board features + * + ****************************************************************************/ + +int sim_bringup(void); + /**************************************************************************** * Name: sim_zoneinfo * @@ -92,5 +111,4 @@ int sim_zoneinfo(int minor); #endif - #endif /* __CONFIGS_SIM_SRC_SIM_H */ \ No newline at end of file diff --git a/configs/sim/src/sim_appinit.c b/configs/sim/src/sim_appinit.c new file mode 100644 index 0000000000..eecf0415cf --- /dev/null +++ b/configs/sim/src/sim_appinit.c @@ -0,0 +1,68 @@ +/**************************************************************************** + * configs/sim/src/sim_appinit.c + * + * Copyright (C) 2015 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 "sim.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * 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_INIT. + * + ****************************************************************************/ + +#ifdef CONFIG_LIB_BOARDCTL +int board_app_initialize(void) +{ +#ifndef CONFIG_BOARD_INITIALIZE + sim_bringup(); +#endif + + return 0; +} +#endif /* CONFIG_LIB_BOARDCTL */ diff --git a/configs/sim/src/sim_boot.c b/configs/sim/src/sim_boot.c index 68ee751c66..826ca47f90 100644 --- a/configs/sim/src/sim_boot.c +++ b/configs/sim/src/sim_boot.c @@ -38,16 +38,10 @@ ****************************************************************************/ #include -#include #include -#include "up_internal.h" #include "sim.h" -#ifdef CONFIG_GRAPHICS_TRAVELER_ROMFSDEMO -int trv_mount_world(int minor, FAR const char *mountpoint); -#endif - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -84,24 +78,6 @@ int trv_mount_world(int minor, FAR const char *mountpoint); #ifdef CONFIG_BOARD_INITIALIZE void board_initialize(void) { -#ifdef CONFIG_SYSTEM_ZONEINFO_ROMFS - /* Mount the TZ database */ - - (void)sim_zoneinfo(3); -#endif - -#ifdef CONFIG_AJOYSTICK - /* Initialize the simulated analog joystick input device */ - - sim_ajoy_initialize(); -#endif - -#ifdef CONFIG_GRAPHICS_TRAVELER_ROMFSDEMO - /* Special initialization for the Traveler game simulation */ - - (void)trv_mount_world(0, CONFIG_GRAPHICS_TRAVELER_DEFPATH); -#endif - + sim_bringup(); } #endif /* CONFIG_BOARD_INITIALIZE */ - diff --git a/configs/sim/src/sim_bringup.c b/configs/sim/src/sim_bringup.c new file mode 100644 index 0000000000..c22cd81381 --- /dev/null +++ b/configs/sim/src/sim_bringup.c @@ -0,0 +1,116 @@ +/**************************************************************************** + * configs/sim/src/sam_bringup.c + * + * Copyright (C) 2015 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 +#include +#include + +#include + +#include "up_internal.h" +#include "sim.h" + +#ifdef CONFIG_GRAPHICS_TRAVELER_ROMFSDEMO +int trv_mount_world(int minor, FAR const char *mountpoint); +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Debug ********************************************************************/ + +#ifdef CONFIG_BOARD_INITIALIZE +# define SYSLOG lldbg +#else +# define SYSLOG dbg +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sam_bringup + * + * Description: + * Bring up simulated board features + * + ****************************************************************************/ + +int sim_bringup(void) +{ +#ifdef CONFIG_FS_PROCFS + int ret; +#endif + +#ifdef CONFIG_SYSTEM_ZONEINFO_ROMFS + /* Mount the TZ database */ + + (void)sim_zoneinfo(3); +#endif + +#ifdef CONFIG_AJOYSTICK + /* Initialize the simulated analog joystick input device */ + + sim_ajoy_initialize(); +#endif + +#ifdef CONFIG_GRAPHICS_TRAVELER_ROMFSDEMO + /* Special initialization for the Traveler game simulation */ + + (void)trv_mount_world(0, CONFIG_GRAPHICS_TRAVELER_DEFPATH); +#endif + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = mount(NULL, SIM_PROCFS_MOUNTPOINT, "procfs", 0, NULL); + if (ret < 0) + { + SYSLOG("ERROR: Failed to mount procfs at %s: %d\n", + SIM_PROCFS_MOUNTPOINT, ret); + } +#endif + + return OK; +}