Move nuttx/configs/stm3240g-eval/src/up_cxxinitialize.c to apps/platform/stm3240g-eval/

This commit is contained in:
Gregory Nutt 2013-12-29 15:02:51 -06:00
parent bdbd0f9b5b
commit 0b4d203c7b
6 changed files with 244 additions and 35 deletions

View File

@ -748,4 +748,7 @@
* apps/nshlib/nsh_mntcmds.c: Modified the df -h logic to eliminate * apps/nshlib/nsh_mntcmds.c: Modified the df -h logic to eliminate
truncating numbers in conversion (like 7900 -> 7M). From Ken truncating numbers in conversion (like 7900 -> 7M). From Ken
Pettit (2013-12-12). Pettit (2013-12-12).
* Moved configs/stm3240g-eval/src/up_cxxinitialize.c to
apps/platform/stm3240g-eval/up_cxxinitialize.c: Now it is available
in user-space in the kernel mode build (2013-12-29).

View File

@ -48,7 +48,7 @@ Command Overview
Where: Where:
<cmd> is any one of the simple commands listed later. <cmd> is any one of the simple commands listed later.
<file> is the full or relative path to any writable object <file> is the full or relative path to any writeable object
in the file system name space (file or character driver). in the file system name space (file or character driver).
Such objects will be referred to simply as files throughout Such objects will be referred to simply as files throughout
this README. this README.
@ -68,7 +68,7 @@ Conditional Command Execution
An if-then[-else]-fi construct is also supported in order to An if-then[-else]-fi construct is also supported in order to
support conditional execution of commands. This works from the support conditional execution of commands. This works from the
command line but is primarily intended for use within NSH scripts command line but is primarily intended for use within NSH scripts
(see the sh commnd). The syntax is as follows: (see the sh command). The syntax is as follows:
if <cmd> if <cmd>
then then
@ -198,7 +198,7 @@ NOTE:
All of the startup-behavior is contained in rcS.template. The All of the startup-behavior is contained in rcS.template. The
role of mkromfsimg.sh is to (1) apply the specific configuration role of mkromfsimg.sh is to (1) apply the specific configuration
settings to rcS.template to create the final rcS, and (2) to settings to rcS.template to create the final rcS, and (2) to
generate the header file nsh_romfsimg.h containg the ROMFS generate the header file nsh_romfsimg.h containing the ROMFS
file system image. file system image.
Simple Commands Simple Commands
@ -252,7 +252,7 @@ o base64dec [-w] [-f] <string or filepath>
o cat <path> [<path> [<path> ...]] o cat <path> [<path> [<path> ...]]
This command copies and concatentates all of the files at <path> This command copies and concatenates all of the files at <path>
to the console (or to another file if the output is redirected). to the console (or to another file if the output is redirected).
o cd [<dir-path>|-|~|..] o cd [<dir-path>|-|~|..]
@ -399,7 +399,7 @@ o get [-b|-n] [-f <local-path>] -h <ip-address> <remote-path>
The file will be saved relative to the current working directory The file will be saved relative to the current working directory
unless <local-path> is provided. unless <local-path> is provided.
-b|-n -b|-n
Selects either binary ("octect") or test ("netascii") transfer Selects either binary ("octet") or test ("netascii") transfer
mode. Default: text. mode. Default: text.
o help [-v] [<cmd>] o help [-v] [<cmd>]
@ -744,7 +744,7 @@ o put [-b|-n] [-f <remote-path>] -h <ip-address> <local-path>
The file will be saved with the same name on the host unless The file will be saved with the same name on the host unless
unless <local-path> is provided. unless <local-path> is provided.
-b|-n -b|-n
Selects either binary ("octect") or test ("netascii") transfer Selects either binary ("octet") or test ("netascii") transfer
mode. Default: text. mode. Default: text.
o pwd o pwd
@ -940,13 +940,13 @@ Command Dependencies on Configuration Settings
* NOTES: * NOTES:
1. Because of hardware padding, the actual buffersize required for put and get 1. Because of hardware padding, the actual buffersize required for put and get
operations size may be larger. operations size may be larger.
2. Special TFTP server start-up optionss will probably be required to permit 2. Special TFTP server start-up options will probably be required to permit
creation of file for the correct operation of the put command. creation of file for the correct operation of the put command.
3. CONFIG_FS_READABLE is not a user configuration but is set automatically 3. CONFIG_FS_READABLE is not a user configuration but is set automatically
if any readable file system is selected. At present, this is either CONFIG_FS_FAT if any readable file system is selected. At present, this is either CONFIG_FS_FAT
and CONFIG_FS_ROMFS. and CONFIG_FS_ROMFS.
4. CONFIG_FS_WRITABLE is not a user configuration but is set automatically 4. CONFIG_FS_WRITABLE is not a user configuration but is set automatically
if any writable filesystem is selected. At present, this is only CONFIG_FS_FAT. if any writeable file system is selected. At present, this is only CONFIG_FS_FAT.
In addition, each NSH command can be individually disabled via one of the following In addition, each NSH command can be individually disabled via one of the following
settings. All of these settings make the configuration of NSH potentially complex but settings. All of these settings make the configuration of NSH potentially complex but

View File

@ -116,7 +116,7 @@
#if defined(CONFIG_NET_UDP) && CONFIG_NFILE_DESCRIPTORS > 0 #if defined(CONFIG_NET_UDP) && CONFIG_NFILE_DESCRIPTORS > 0
struct tftpc_args_s struct tftpc_args_s
{ {
bool binary; /* true:binary ("octect") false:text ("netascii") */ bool binary; /* true:binary ("octet") false:text ("netascii") */
bool allocated; /* true: destpath is allocated */ bool allocated; /* true: destpath is allocated */
char *destpath; /* Path at destination */ char *destpath; /* Path at destination */
const char *srcpath; /* Path at src */ const char *srcpath; /* Path at src */
@ -502,6 +502,7 @@ int cmd_get(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{ {
free(args.destpath); free(args.destpath);
} }
free(fullpath); free(fullpath);
return OK; return OK;
} }
@ -596,7 +597,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
} }
/* If both the network interface name and an IP address are supplied as /* If both the network interface name and an IP address are supplied as
* arguments, then ifconfig will set the address of the ethernet device: * arguments, then ifconfig will set the address of the Ethernet device:
* *
* ifconfig nic_name ip_address * ifconfig nic_name ip_address
*/ */
@ -677,7 +678,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
return ERROR; return ERROR;
} }
/* Set Hardware ethernet MAC addr */ /* Set Hardware Ethernet MAC address */
if (hw) if (hw)
{ {
@ -915,12 +916,12 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
(ipaddr >> 16 ) & 0xff, (ipaddr >> 24 ) & 0xff, (ipaddr >> 16 ) & 0xff, (ipaddr >> 24 ) & 0xff,
DEFAULT_PING_DATALEN); DEFAULT_PING_DATALEN);
start = g_system_timer; start = clock_systimer();
for (i = 1; i <= count; i++) for (i = 1; i <= count; i++)
{ {
/* Send the ECHO request and wait for the response */ /* Send the ECHO request and wait for the response */
next = g_system_timer; next = clock_systimer();
seqno = uip_ping(ipaddr, id, i, DEFAULT_PING_DATALEN, maxwait); seqno = uip_ping(ipaddr, id, i, DEFAULT_PING_DATALEN, maxwait);
/* Was any response returned? We can tell if a non-negative sequence /* Was any response returned? We can tell if a non-negative sequence
@ -934,7 +935,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
* to an earlier request, then fudge the elpased time. * to an earlier request, then fudge the elpased time.
*/ */
elapsed = TICK2MSEC(g_system_timer - next); elapsed = TICK2MSEC(clock_systimer() - next);
if (seqno < i) if (seqno < i)
{ {
elapsed += 100 * dsec * (i - seqno); elapsed += 100 * dsec * (i - seqno);
@ -952,7 +953,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
* to the current request! * to the current request!
*/ */
elapsed = TICK2DSEC(g_system_timer - next); elapsed = TICK2DSEC(clock_systimer() - next);
if (elapsed < dsec) if (elapsed < dsec)
{ {
usleep(100000 * (dsec - elapsed)); usleep(100000 * (dsec - elapsed));
@ -961,7 +962,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
/* Get the total elapsed time */ /* Get the total elapsed time */
elapsed = TICK2MSEC(g_system_timer - start); elapsed = TICK2MSEC(clock_systimer() - start);
/* Calculate the percentage of lost packets */ /* Calculate the percentage of lost packets */
@ -1013,6 +1014,7 @@ int cmd_put(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{ {
free(args.destpath); free(args.destpath);
} }
free(fullpath); free(fullpath);
return OK; return OK;
} }
@ -1132,18 +1134,22 @@ exit:
{ {
close(fd); close(fd);
} }
if (allocfile) if (allocfile)
{ {
free(allocfile); free(allocfile);
} }
if (fullpath) if (fullpath)
{ {
free(fullpath); free(fullpath);
} }
if (buffer) if (buffer)
{ {
free(buffer); free(buffer);
} }
return ret; return ret;
errout: errout:

View File

@ -0,0 +1,8 @@
#
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
if ARCH_BOARD_STM3240G_EVAL
endif

View File

@ -0,0 +1,40 @@
############################################################################
# apps/platform/stm3240g-eval/Make.defs
#
# Copyright (C) 2013 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.
#
############################################################################
# Add platform specific sources to ASRCS and CSRCS
ifeq ($(CONFIG_HAVE_CXX),y)
CSRCS += up_cxxinitialize.c
endif

View File

@ -0,0 +1,152 @@
/************************************************************************************
* apps/platform/stm3240g-eval/src/up_cxxinitialize.c
*
* Copyright (C) 2012-2013 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 <debug.h>
#include <nuttx/arch.h>
#include <arch/stm32/chip.h>
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
/************************************************************************************
* Definitions
************************************************************************************/
/* Debug ****************************************************************************/
/* Non-standard debug that may be enabled just for testing the static constructors */
#ifndef CONFIG_DEBUG
# undef CONFIG_DEBUG_CXX
#endif
#ifdef CONFIG_DEBUG_CXX
# define cxxdbg dbg
# define cxxlldbg lldbg
# ifdef CONFIG_DEBUG_VERBOSE
# define cxxvdbg vdbg
# define cxxllvdbg llvdbg
# else
# define cxxvdbg(x...)
# define cxxllvdbg(x...)
# endif
#else
# define cxxdbg(x...)
# define cxxlldbg(x...)
# define cxxvdbg(x...)
# define cxxllvdbg(x...)
#endif
/************************************************************************************
* Private Types
************************************************************************************/
/* This type defines one entry in initialization array */
typedef void (*initializer_t)(void);
/************************************************************************************
* External references
************************************************************************************/
/* _sinit and _einit are symbols exported by the linker script that mark the
* beginning and the end of the C++ initialization section.
*/
extern initializer_t _sinit;
extern initializer_t _einit;
/* _stext and _etext are symbols exported by the linker script that mark the
* beginning and the end of text.
*/
extern uint32_t _stext;
extern uint32_t _etext;
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/****************************************************************************
* Name: up_cxxinitialize
*
* Description:
* If C++ and C++ static constructors are supported, then this function
* must be provided by board-specific logic in order to perform
* initialization of the static C++ class instances.
*
* This function should then be called in the application-specific
* user_start logic in order to perform the C++ initialization. NOTE
* that no component of the core NuttX RTOS logic is involved; This
* function defintion only provides the 'contract' between application
* specific C++ code and platform-specific toolchain support
*
***************************************************************************/
void up_cxxinitialize(void)
{
initializer_t *initp;
cxxdbg("_sinit: %p _einit: %p _stext: %p _etext: %p\n",
&_sinit, &_einit, &_stext, &_etext);
/* Visit each entry in the initialzation table */
for (initp = &_sinit; initp != &_einit; initp++)
{
initializer_t initializer = *initp;
cxxdbg("initp: %p initializer: %p\n", initp, initializer);
/* Make sure that the address is non-NULL and lies in the text region
* defined by the linker script. Some toolchains may put NULL values
* or counts in the initialization table
*/
if ((void*)initializer > (void*)&_stext && (void*)initializer < (void*)&_etext)
{
cxxdbg("Calling %p\n", initializer);
initializer();
}
}
}
#endif /* CONFIG_HAVE_CXX && CONFIG_HAVE_CXXINITIALIZE */