From 69988dc1f60ce27d2192eb2aa579962f585fffc8 Mon Sep 17 00:00:00 2001 From: Leo C Date: Thu, 21 Aug 2014 00:48:46 +0200 Subject: printf() --> printf_P(PSTR()) --- avr/debug.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'avr/debug.c') 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 */ -- cgit v1.2.3