summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2011-05-07 19:22:15 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2011-05-07 19:22:15 +0000
commiteb796b1e3b97b01b6c1f057194171842c38159b8 (patch)
treed486856c6dafe9c6271b7808caaa4920bef63474 /apps
parent9c29dcd505d8b4a2dbb1b54b52a401d8b716f972 (diff)
Mostly cosmetic changes from Uros
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@3575 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'apps')
-rw-r--r--apps/nshlib/nsh_parse.c28
-rw-r--r--apps/vsn/free/free.c87
2 files changed, 66 insertions, 49 deletions
diff --git a/apps/nshlib/nsh_parse.c b/apps/nshlib/nsh_parse.c
index 650ef57327..ef861b2dea 100644
--- a/apps/nshlib/nsh_parse.c
+++ b/apps/nshlib/nsh_parse.c
@@ -465,6 +465,19 @@ static int nsh_execute(FAR struct nsh_vtbl_s *vtbl, int argc, char *argv[])
*/
cmd = argv[0];
+
+ /* Try to find a command in the application library.
+ */
+
+#ifdef CONFIG_NSH_BUILTIN_APPS
+ if (nsh_execapp(vtbl, cmd, argv) == OK)
+ {
+ /* The pre-built application was successfully started -- return OK. */
+
+ return OK;
+ }
+#endif
+
/* See if the command is one that we understand */
@@ -503,21 +516,6 @@ static int nsh_execute(FAR struct nsh_vtbl_s *vtbl, int argc, char *argv[])
}
}
- /* If the command was not found, then try to execute the command from
- * a list of pre-built applications.
- */
-
-#ifdef CONFIG_NSH_BUILTIN_APPS
- if (handler == cmd_unrecognized && nsh_execapp(vtbl, cmd, argv) == OK)
- {
- /* The pre-built application was successfully started -- return OK.
- * If not, then fall through to execute the cmd_nrecognized handler.
- */
-
- return OK;
- }
-#endif
-
ret = handler(vtbl, argc, argv);
return ret;
}
diff --git a/apps/vsn/free/free.c b/apps/vsn/free/free.c
index fa5288cdde..2e3908e823 100644
--- a/apps/vsn/free/free.c
+++ b/apps/vsn/free/free.c
@@ -33,61 +33,80 @@
*
****************************************************************************/
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
#include <nuttx/config.h>
+#include <nuttx/progmem.h>
#include <stdio.h>
#include <stdlib.h>
/****************************************************************************
- * Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
* Private Functions
****************************************************************************/
+
+/* \todo Max block size only works on uniform prog mem */
+
+void free_getprogmeminfo(struct mallinfo * mem)
+{
+ uint16_t page = 0, stpage = 0xFFFF;
+ uint16_t pagesize = 0;
+ int status;
+
+ mem->arena = 0;
+ mem->fordblks = 0;
+ mem->uordblks = 0;
+ mem->mxordblk = 0;
+
+ for (status=0, page=0; status >= 0; page++) {
+
+ status = up_progmem_ispageerased(page);
+ pagesize = up_progmem_pagesize(page);
+
+ mem->arena += pagesize;
+
+ /* Is this beginning of new free space section */
+ if (status == 0) {
+ if (stpage == 0xFFFF) stpage = page;
+ mem->fordblks += pagesize;
+ }
+ else if (status != 0) {
+ mem->uordblks += pagesize;
+
+ if (stpage != 0xFFFF && up_progmem_isuniform()) {
+ stpage = page - stpage;
+ if (stpage > mem->mxordblk)
+ mem->mxordblk = stpage;
+ stpage = 0xFFFF;
+ }
+ }
+ }
+
+ mem->mxordblk *= pagesize;
+}
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
/****************************************************************************
- * Name: cmd_free
+ * Public Functions
****************************************************************************/
int free_main(int argc, char **argv)
{
- struct mallinfo mem;
+ struct mallinfo data;
+ struct mallinfo prog;
#ifdef CONFIG_CAN_PASS_STRUCTS
- mem = mallinfo();
+ data = mallinfo();
#else
- (void)mallinfo(&mem);
+ (void)mallinfo(&data);
#endif
- printf(" total used free largest\n");
- printf("Mem: %11d%11d%11d%11d\n",
- mem.arena, mem.uordblks, mem.fordblks, mem.mxordblk);
+ free_getprogmeminfo(&prog);
+
+ printf(" total used free largest\n");
+ printf("Data: %11d%11d%11d%11d\n",
+ data.arena, data.uordblks, data.fordblks, data.mxordblk);
+ printf("Prog: %11d%11d%11d%11d\n",
+ prog.arena, prog.uordblks, prog.fordblks, prog.mxordblk);
return OK;
}