Move up_appinit.c to configs/sim/src where it belongs. Add logic to automatically mount the procfs file system if it is enabled.
This commit is contained in:
parent
6b9c0c7c72
commit
b9a26bae77
@ -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 <gnutt@nuttx.org>
|
||||
#
|
||||
# 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
|
||||
|
@ -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 */
|
68
configs/sim/src/sim_appinit.c
Normal file
68
configs/sim/src/sim_appinit.c
Normal file
@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
* configs/sim/src/sim_appinit.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#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 */
|
@ -38,16 +38,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#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 */
|
||||
|
||||
|
116
configs/sim/src/sim_bringup.c
Normal file
116
configs/sim/src/sim_bringup.c
Normal file
@ -0,0 +1,116 @@
|
||||
/****************************************************************************
|
||||
* configs/sim/src/sam_bringup.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/mount.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user