diff options
author | Leo C | 2014-08-21 00:48:46 +0200 |
---|---|---|
committer | Leo C | 2014-08-21 00:48:46 +0200 |
commit | 69988dc1f60ce27d2192eb2aa579962f585fffc8 (patch) | |
tree | c0dd96fc58aebe4090d58bcba80efac1f7d7b91e /avr/debug.c | |
parent | d0581f881c4072ef0ac453167a98dc3bc0d87d86 (diff) | |
download | z180-stamp-69988dc1f60ce27d2192eb2aa579962f585fffc8.zip |
printf() --> printf_P(PSTR())
Diffstat (limited to 'avr/debug.c')
-rw-r--r-- | avr/debug.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/avr/debug.c b/avr/debug.c index 4591397..74d8ab2 100644 --- a/avr/debug.c +++ b/avr/debug.c @@ -202,7 +202,7 @@ command_ret_t do_eep_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[ return CMD_RET_FAILURE; } if (count == 0) { - debug("Zero length ???\n"); + debug("Zero length?\n"); return CMD_RET_FAILURE; } @@ -223,5 +223,48 @@ command_ret_t do_eep_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[ } return CMD_RET_SUCCESS; } + +/*------------------------------------------------------------------------------*/ + + +struct __freelist { + size_t sz; + struct __freelist *nx; +}; + +extern char *__brkval; /* first location not yet allocated */ +extern struct __freelist *__flp; /* freelist pointer (head of freelist) */ + +#define STACK_POINTER() ((char *)AVR_STACK_POINTER_REG) + +void +printfreelist(const char * title) +{ + struct __freelist *fp1; + int i; + unsigned int freesum = 0; + + if (!__flp) { + printf("%s no free list\n", title ? title : ""); + } else { + printf("Free list: %s\n", title ? title : ""); + for (i = 0, fp1 = __flp; fp1; i++, fp1 = fp1->nx) { + printf(" entry %d @ %04x: size %4u, next ", + i, (size_t)fp1, fp1->sz); + if (fp1->nx) + printf("%04x\n", (size_t)fp1->nx); + else + printf("NULL\n"); + freesum += fp1->sz; + } + } + + freesum += (size_t) STACK_POINTER() - __malloc_margin - (size_t) __brkval; + + printf("SP: %04x, __brkval: %04x, Total free: %04u\n", + (size_t) STACK_POINTER(), (size_t) __brkval, freesum); +} + + #endif /* DEBUG */ |