From ca700d2e3c06a80de37c5ef8383ca550fe20c750 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 7 May 2011 19:22:15 +0000 Subject: Mostly cosmetic changes from Uros git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3575 42af7a65-404d-4744-a932-0658087f49c3 --- apps/nshlib/nsh_parse.c | 28 ++++++++-------- apps/vsn/free/free.c | 87 ++++++++++++++++++++++++++++++------------------- 2 files changed, 66 insertions(+), 49 deletions(-) (limited to 'apps') diff --git a/apps/nshlib/nsh_parse.c b/apps/nshlib/nsh_parse.c index 650ef5732..ef861b2de 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 fa5288cdd..2e3908e82 100644 --- a/apps/vsn/free/free.c +++ b/apps/vsn/free/free.c @@ -33,61 +33,80 @@ * ****************************************************************************/ -/**************************************************************************** - * Included Files - ****************************************************************************/ - #include +#include #include #include -/**************************************************************************** - * 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; } -- cgit v1.2.3