summaryrefslogtreecommitdiff
path: root/nuttx/examples
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-02-28 12:48:23 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-02-28 12:48:23 +0000
commit587a5b65f3f48805150f8a0d8db9ce34f9cabfda (patch)
tree84b00e127433c4255f77ad59a840ac4536c545c9 /nuttx/examples
parent75c03c950d2211049c93c1469e014d03f0ee4bc3 (diff)
downloadpx4-nuttx-587a5b65f3f48805150f8a0d8db9ce34f9cabfda.tar.gz
px4-nuttx-587a5b65f3f48805150f8a0d8db9ce34f9cabfda.tar.bz2
px4-nuttx-587a5b65f3f48805150f8a0d8db9ce34f9cabfda.zip
Rename NSH mem command to free
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3325 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples')
-rw-r--r--nuttx/examples/nsh/Makefile3
-rw-r--r--nuttx/examples/nsh/README.txt64
-rw-r--r--nuttx/examples/nsh/nsh.h4
-rw-r--r--nuttx/examples/nsh/nsh_dbgcmds.c29
-rw-r--r--nuttx/examples/nsh/nsh_main.c7
-rw-r--r--nuttx/examples/nsh/nsh_mmcmds.c95
6 files changed, 135 insertions, 67 deletions
diff --git a/nuttx/examples/nsh/Makefile b/nuttx/examples/nsh/Makefile
index 961858666..66888599b 100644
--- a/nuttx/examples/nsh/Makefile
+++ b/nuttx/examples/nsh/Makefile
@@ -37,7 +37,8 @@
-include $(TOPDIR)/Make.defs
ASRCS =
-CSRCS = nsh_main.c nsh_fscmds.c nsh_ddcmd.c nsh_proccmds.c nsh_envcmds.c nsh_dbgcmds.c
+CSRCS = nsh_main.c nsh_fscmds.c nsh_ddcmd.c nsh_proccmds.c nsh_mmcmds.c \
+ nsh_envcmds.c nsh_dbgcmds.c
ifeq ($(CONFIG_EXAMPLES_NSH_ROMFSETC),y)
CSRCS += nsh_romfsetc.c
diff --git a/nuttx/examples/nsh/README.txt b/nuttx/examples/nsh/README.txt
index bbe1429d8..ee3a42de2 100644
--- a/nuttx/examples/nsh/README.txt
+++ b/nuttx/examples/nsh/README.txt
@@ -302,6 +302,24 @@ o exit
using the 'exec' command') and you would like to have NSH out of the
way.
+o free
+
+ Show the current state of the memory allocator. For example,
+
+ nsh> free
+ free
+ total used free largest
+ Mem: 4194288 1591552 2602736 2601584
+
+ Where:
+ total - This is the total size of memory allocated for use
+ by malloc in bytes.
+ used - This is the total size of memory occupied by
+ chunks handed out by malloc.
+ free - This is the total size of memory occupied by
+ free (not in use) chunks.
+ largest - Size of the largest free (not in use) chunk
+
o get [-b|-n] [-f <local-path>] -h <ip-address> <remote-path>
Use TFTP to copy the file at <remote-address> from the host whose IP
@@ -417,28 +435,6 @@ o mw <hex-address>[=<hex-value>][ <hex-byte-count>]
14 = 0x0c1e
nsh>
-o mem
-
- Show the current state of the memory allocator. For example,
-
- nsh> mem
- arena: fe2560
- ordblks: 1
- mxordblk: fdc3e0
- uordblks: 6180
- fordblks: fdc3e0
- nsh>
-
- Where:
- arena - This is the total size of memory allocated for use
- by malloc in bytes.
- ordblks - This is the number of free (not in use) chunks.
- mxordblk - Size of the largest free (not in use) chunk
- uordblks - This is the total size of memory occupied by
- chunks handed out by malloc.
- fordblks - This is the total size of memory occupied by
- free (not in use) chunks.
-
o mkdir <path>
Create the directory at <path>. All components of of <path>
@@ -770,6 +766,7 @@ Command Dependencies on Configuration Settings
echo --
exec --
exit --
+ free --
get CONFIG_NET && CONFIG_NET_UDP && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET_BUFSIZE >= 558 (see note 1)
help --
ifconfig CONFIG_NET
@@ -777,7 +774,6 @@ Command Dependencies on Configuration Settings
losetup !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
ls CONFIG_NFILE_DESCRIPTORS > 0
mb,mh,mw ---
- mem ---
mkdir !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_WRITABLE (see note 4)
mkfatfs !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT
mkfifo CONFIG_NFILE_DESCRIPTORS > 0
@@ -814,17 +810,17 @@ In addition, each NSH command can be individually disabled via one of the follow
settings. All of these settings make the configuration of NSH potentially complex but
also allow it to squeeze into very small memory footprints.
- CONFIG_EXAMPLES_NSH_DISABLE_CAT, CONFIG_EXAMPLES_NSH_DISABLE_CD, CONFIG_EXAMPLES_NSH_DISABLE_CP,
- CONFIG_EXAMPLES_NSH_DISABLE_DD, CONFIG_EXAMPLES_NSH_DISABLE_ECHO, CONFIG_EXAMPLES_NSH_DISABLE_EXEC,
- CONFIG_EXAMPLES_NSH_DISABLE_EXIT, CONFIG_EXAMPLES_NSH_DISABLE_GET, CONFIG_EXAMPLES_NSH_DISABLE_HELP,
- CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG, CONFIG_EXAMPLES_NSH_DISABLE_KILL, CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP,
- CONFIG_EXAMPLES_NSH_DISABLE_LS, CONFIG_EXAMPLES_NSH_DISABLE_MB, CONFIG_EXAMPLES_NSH_DISABLE_MEM,
- CONFIG_EXAMPLES_NSH_DISABLE_MKDIR, CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS, CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO,
- CONFIG_EXAMPLES_NSH_DISABLE_MKRD, CONFIG_EXAMPLES_NSH_DISABLE_MH, CONFIG_EXAMPLES_NSH_DISABLE_MOUNT,
- CONFIG_EXAMPLES_NSH_DISABLE_MW, CONFIG_EXAMPLES_NSH_DISABLE_PS, CONFIG_EXAMPLES_NSH_DISABLE_PING,
- CONFIG_EXAMPLES_NSH_DISABLE_PUT, CONFIG_EXAMPLES_NSH_DISABLE_PWD, CONFIG_EXAMPLES_NSH_DISABLE_RM,
- CONFIG_EXAMPLES_NSH_DISABLE_RMDIR, CONFIG_EXAMPLES_NSH_DISABLE_SET, CONFIG_EXAMPLES_NSH_DISABLE_SH,
- CONFIG_EXAMPLES_NSH_DISABLE_SLEEP, CONFIG_EXAMPLES_NSH_DISABLE_TEST, CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT,
+ CONFIG_EXAMPLES_NSH_DISABLE_CAT, CONFIG_EXAMPLES_NSH_DISABLE_CD, CONFIG_EXAMPLES_NSH_DISABLE_CP,
+ CONFIG_EXAMPLES_NSH_DISABLE_DD, CONFIG_EXAMPLES_NSH_DISABLE_ECHO, CONFIG_EXAMPLES_NSH_DISABLE_EXEC,
+ CONFIG_EXAMPLES_NSH_DISABLE_EXIT, CONFIG_EXAMPLES_NSH_DISABLE_FREE, CONFIG_EXAMPLES_NSH_DISABLE_GET,
+ CONFIG_EXAMPLES_NSH_DISABLE_HELP, CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG, CONFIG_EXAMPLES_NSH_DISABLE_KILL,
+ CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP, CONFIG_EXAMPLES_NSH_DISABLE_LS, CONFIG_EXAMPLES_NSH_DISABLE_MB,
+ CONFIG_EXAMPLES_NSH_DISABLE_MKDIR, CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS, CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO,
+ CONFIG_EXAMPLES_NSH_DISABLE_MKRD, CONFIG_EXAMPLES_NSH_DISABLE_MH, CONFIG_EXAMPLES_NSH_DISABLE_MOUNT,
+ CONFIG_EXAMPLES_NSH_DISABLE_MW, CONFIG_EXAMPLES_NSH_DISABLE_PS, CONFIG_EXAMPLES_NSH_DISABLE_PING,
+ CONFIG_EXAMPLES_NSH_DISABLE_PUT, CONFIG_EXAMPLES_NSH_DISABLE_PWD, CONFIG_EXAMPLES_NSH_DISABLE_RM,
+ CONFIG_EXAMPLES_NSH_DISABLE_RMDIR, CONFIG_EXAMPLES_NSH_DISABLE_SET, CONFIG_EXAMPLES_NSH_DISABLE_SH,
+ CONFIG_EXAMPLES_NSH_DISABLE_SLEEP, CONFIG_EXAMPLES_NSH_DISABLE_TEST, CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT,
CONFIG_EXAMPLES_NSH_DISABLE_UNSET, CONFIG_EXAMPLES_NSH_DISABLE_USLEEP, CONFIG_EXAMPLES_NSH_DISABLE_WGET,
CONFIG_EXAMPLES_NSH_DISABLE_XD
diff --git a/nuttx/examples/nsh/nsh.h b/nuttx/examples/nsh/nsh.h
index 1fd1b3e92..ef03ddc9d 100644
--- a/nuttx/examples/nsh/nsh.h
+++ b/nuttx/examples/nsh/nsh.h
@@ -364,8 +364,8 @@ extern void nsh_dumpbuffer(FAR struct nsh_vtbl_s *vtbl, const char *msg,
#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MW
extern int cmd_mw(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
#endif
-#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MEM
- extern int cmd_mem(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
+#ifndef CONFIG_EXAMPLES_NSH_DISABLE_FREE
+ extern int cmd_free(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
#endif
#ifndef CONFIG_EXAMPLES_NSH_DISABLE_PS
extern int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
diff --git a/nuttx/examples/nsh/nsh_dbgcmds.c b/nuttx/examples/nsh/nsh_dbgcmds.c
index 5b4b89675..ef026c68a 100644
--- a/nuttx/examples/nsh/nsh_dbgcmds.c
+++ b/nuttx/examples/nsh/nsh_dbgcmds.c
@@ -1,7 +1,7 @@
/****************************************************************************
- * examples/nsh/dbg_proccmds.c
+ * examples/nsh/dbg_dbgcmds.c
*
- * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,6 @@
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
#include <errno.h>
@@ -286,30 +285,6 @@ int cmd_mw(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
#endif
/****************************************************************************
- * Name: cmd_mem
- ****************************************************************************/
-
-#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MEM
-int cmd_mem(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
-{
- struct mallinfo mem;
-
-#ifdef CONFIG_CAN_PASS_STRUCTS
- mem = mallinfo();
-#else
- (void)mallinfo(&mem);
-#endif
-
- nsh_output(vtbl, " arena: %8x\n", mem.arena);
- nsh_output(vtbl, " ordblks: %8d\n", mem.ordblks);
- nsh_output(vtbl, " mxordblk: %8x\n", mem.mxordblk);
- nsh_output(vtbl, " uordblks: %8x\n", mem.uordblks);
- nsh_output(vtbl, " fordblks: %8x\n", mem.fordblks);
- return OK;
-}
-#endif
-
-/****************************************************************************
* Name: nsh_dumpbuffer
****************************************************************************/
diff --git a/nuttx/examples/nsh/nsh_main.c b/nuttx/examples/nsh/nsh_main.c
index 2483c4919..aea823be8 100644
--- a/nuttx/examples/nsh/nsh_main.c
+++ b/nuttx/examples/nsh/nsh_main.c
@@ -173,6 +173,10 @@ static const struct cmdmap_s g_cmdmap[] =
{ "exit", cmd_exit, 1, 1, NULL },
#endif
+#ifndef CONFIG_EXAMPLES_NSH_DISABLE_FREE
+ { "free", cmd_free, 1, 1, NULL },
+#endif
+
#if defined(CONFIG_NET_UDP) && CONFIG_NFILE_DESCRIPTORS > 0
# ifndef CONFIG_EXAMPLES_NSH_DISABLE_GET
{ "get", cmd_get, 4, 7, "[-b|-n] [-f <local-path>] -h <ip-address> <remote-path>" },
@@ -210,9 +214,6 @@ static const struct cmdmap_s g_cmdmap[] =
#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MB
{ "mb", cmd_mb, 2, 3, "<hex-address>[=<hex-value>][ <hex-byte-count>]" },
#endif
-#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MEM
- { "mem", cmd_mem, 1, 1, NULL },
-#endif
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE)
# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKDIR
diff --git a/nuttx/examples/nsh/nsh_mmcmds.c b/nuttx/examples/nsh/nsh_mmcmds.c
new file mode 100644
index 000000000..f2e572eb3
--- /dev/null
+++ b/nuttx/examples/nsh/nsh_mmcmds.c
@@ -0,0 +1,95 @@
+/****************************************************************************
+ * examples/nsh/dbg_mmcmds.c
+ *
+ * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * 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 <stdlib.h>
+
+#include "nsh.h"
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: cmd_free
+ ****************************************************************************/
+
+#ifndef CONFIG_EXAMPLES_NSH_DISABLE_FREE
+int cmd_free(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
+{
+ struct mallinfo mem;
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ mem = mallinfo();
+#else
+ (void)mallinfo(&mem);
+#endif
+
+ nsh_output(vtbl, " total used free largest\n");
+ nsh_output(vtbl, "Mem: %11d%11d%11d%11d\n",
+ mem.arena, mem.uordblks, mem.fordblks, mem.mxordblk);
+
+ return OK;
+}
+#endif