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
truncating numbers in conversion (like 7900 -> 7M). From Ken
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,8 +48,8 @@ Command Overview
Where:
<cmd> is any one of the simple commands listed later.
<file> is the full or relative path to any writable object
in the filesystem name space (file or character driver).
<file> is the full or relative path to any writeable object
in the file system name space (file or character driver).
Such objects will be referred to simply as files throughout
this README.
@ -68,7 +68,7 @@ Conditional Command Execution
An if-then[-else]-fi construct is also supported in order to
support conditional execution of commands. This works from the
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>
then
@ -120,14 +120,14 @@ In this default case, enabling CONFIG_NSH_ROMFSETC will cause
NSH to behave as follows at NSH startup time:
- NSH will create a read-only RAM disk (a ROM disk), containing a tiny
ROMFS filesystem containing the following:
ROMFS file system containing the following:
|--init.d/
`-- rcS
Where rcS is the NSH start-up script
- NSH will then mount the ROMFS filesystem at /etc, resulting in:
- NSH will then mount the ROMFS file system at /etc, resulting in:
|--dev/
| `-- ram0
@ -198,7 +198,7 @@ NOTE:
All of the startup-behavior is contained in rcS.template. The
role of mkromfsimg.sh is to (1) apply the specific configuration
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.
Simple Commands
@ -252,7 +252,7 @@ o base64dec [-w] [-f] <string or filepath>
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).
o cd [<dir-path>|-|~|..]
@ -280,7 +280,7 @@ o cmp <path1> <path2>
o cp <source-path> <dest-path>
Copy of the contents of the file at <source-path> to the location
in the filesystem indicated by <path-path>
in the file system indicated by <path-path>
o date [-s "MMM DD HH:MM:SS YYYY"]
@ -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
unless <local-path> is provided.
-b|-n
Selects either binary ("octect") or test ("netascii") transfer
Selects either binary ("octet") or test ("netascii") transfer
mode. Default: text.
o help [-v] [<cmd>]
@ -487,7 +487,7 @@ o losetup [-d <dev-path>] | [[-o <offset>] [-r] <ldev-path> <file-path>]
o ls [-lRs] <dir-path>
Show the contents of the directory at <dir-path>. NOTE:
<dir-path> must refer to a directory and no other filesystem
<dir-path> must refer to a directory and no other file system
object.
Options:
@ -539,10 +539,10 @@ o mkdir <path>
except the final directory name must exist on a mounted file
system; the final directory must not.
Recall that NuttX uses a pseudo filesystem for its root file system.
Recall that NuttX uses a pseudo file system for its root file system.
The mkdir command can only be used to create directories in volumes
set up with the mount command; it cannot be used to create directories
in the pseudo filesystem.
in the pseudo file system.
Example:
^^^^^^^^
@ -563,7 +563,7 @@ o mkfatfs [-F <fatsize>] <block-driver>
specified on the command line.
NSH provides this command to access the mkfatfs() NuttX API.
This block device must reside in the NuttX pseudo filesystem and
This block device must reside in the NuttX pseudo file system and
must have been created by some call to register_blockdriver() (see
include/nuttx/fs/fs.h).
@ -650,14 +650,14 @@ o mount [-t <fstype> <block-device> <dir-path>]
of this writing, vfat is the only supported value for <fstype>
Block Device. The <block-device> argument is the full or relative
path to a block driver inode in the pseudo filesystem. By convention,
path to a block driver inode in the pseudo file system. By convention,
this is a name under the /dev sub-directory. This <block-device>
must have been previously formatted with the same file system
type as specified by <fstype>
Mount Point. The mount point is the location in the pseudo file
system where the mounted volume will appear. This mount point
can only reside in the NuttX pseudo filesystem. By convention, this
can only reside in the NuttX pseudo file system. By convention, this
mount point is a subdirectory under /mnt. The mount command will
create whatever pseudo directories that may be needed to complete
the full path but the full path must not already exist.
@ -697,7 +697,7 @@ o mount [-t <fstype> <block-device> <dir-path>]
o mv <old-path> <new-path>
Rename the file object at <old-path> to <new-path>. Both paths must
reside in the same mounted filesystem.
reside in the same mounted file system.
o nfsmount <server-address> <mount-point> <remote-path>
@ -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
unless <local-path> is provided.
-b|-n
Selects either binary ("octect") or test ("netascii") transfer
Selects either binary ("octet") or test ("netascii") transfer
mode. Default: text.
o pwd
@ -765,10 +765,10 @@ o pwd
o rm <file-path>
Remove the specified <file-path> name from the mounted file system.
Recall that NuttX uses a pseudo filesystem for its root file system.
Recall that NuttX uses a pseudo file system for its root file system.
The rm command can only be used to remove (unlink) files in volumes
set up with the mount command; it cannot be used to remove names from
the pseudo filesystem.
the pseudo file system.
Example:
^^^^^^^^
@ -786,10 +786,10 @@ o rm <file-path>
o rmdir <dir-path>
Remove the specified <dir-path> directory from the mounted file system.
Recall that NuttX uses a pseudo filesystem for its root file system. The
Recall that NuttX uses a pseudo file system for its root file system. The
rmdir command can only be used to remove directories from volumes set up
with the mount command; it cannot be used to remove directories from the
pseudo filesystem.
pseudo file system.
Example:
^^^^^^^^
@ -940,13 +940,13 @@ Command Dependencies on Configuration Settings
* NOTES:
1. Because of hardware padding, the actual buffersize required for put and get
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.
3. CONFIG_FS_READABLE is not a user configuration but is set automatically
if any readable filesystem 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.
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
settings. All of these settings make the configuration of NSH potentially complex but
@ -986,7 +986,7 @@ NSH-Specific Configuration Settings
* CONFIG_NSH_FILEIOSIZE
Size of a static I/O buffer used for file access (ignored if
there is no filesystem). Default is 1024.
there is no file system). Default is 1024.
* CONFIG_NSH_STRERROR
strerror(errno) makes more readable output but strerror() is
@ -1023,7 +1023,7 @@ NSH-Specific Configuration Settings
Default is zero.
* CONFIG_NSH_ROMFSETC
Mount a ROMFS filesystem at /etc and provide a startup script
Mount a ROMFS file system at /etc and provide a startup script
at /etc/init.d/rcS. The default startup script will mount
a FAT FS RAMDISK at /tmp but the logic is easily extensible.

View File

@ -116,7 +116,7 @@
#if defined(CONFIG_NET_UDP) && CONFIG_NFILE_DESCRIPTORS > 0
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 */
char *destpath; /* Path at destination */
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(fullpath);
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
* 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
*/
@ -677,7 +678,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
return ERROR;
}
/* Set Hardware ethernet MAC addr */
/* Set Hardware Ethernet MAC address */
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,
DEFAULT_PING_DATALEN);
start = g_system_timer;
start = clock_systimer();
for (i = 1; i <= count; i++)
{
/* 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);
/* 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.
*/
elapsed = TICK2MSEC(g_system_timer - next);
elapsed = TICK2MSEC(clock_systimer() - next);
if (seqno < i)
{
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!
*/
elapsed = TICK2DSEC(g_system_timer - next);
elapsed = TICK2DSEC(clock_systimer() - next);
if (elapsed < dsec)
{
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 */
elapsed = TICK2MSEC(g_system_timer - start);
elapsed = TICK2MSEC(clock_systimer() - start);
/* 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(fullpath);
return OK;
}
@ -1123,7 +1125,7 @@ int cmd_wget(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "wget", NSH_ERRNO);
goto exit;
}
}
/* Free allocated resources */
@ -1132,18 +1134,22 @@ exit:
{
close(fd);
}
if (allocfile)
{
free(allocfile);
}
if (fullpath)
{
free(fullpath);
}
if (buffer)
{
free(buffer);
}
return ret;
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 */