Mostly cosmetic changes from Uros
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3575 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
e7cd5acf31
commit
a2ac5f8bf4
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
****************************************************************************/
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user