#include "debug.h"
#include "common.h"
-#include <stdlib.h> /* __malloc_margin */
-#include <string.h>
-#include <ctype.h>
#include <avr/eeprom.h>
#include "command.h"
#ifdef DEBUG
-
-#if 0
-void dump_heap(void)
-{
- extern unsigned int __brkval;
-
- dump_ram(__malloc_heap_start,
- __brkval - (unsigned int) __malloc_heap_start,
- "=== Heap:");
-}
-#endif
-
-
/*
* Memory Display
* md addr {len}
*/
-command_ret_t do_dump_mem(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[])
+command_ret_t do_dump_mem(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc, char * const argv[])
{
- int (*readwhat)(uint8_t *buf, uint32_t addr, uint8_t count);
-
- (void) cmdtp; (void) flag;
+ ERRNUM (*readwhat)(uint8_t *buf, uint32_t addr, uint8_t count);
if (argc < 2)
return CMD_RET_USAGE;
struct __freelist *nx;
};
-extern char *__brkval; /* first location not yet allocated */
-extern struct __freelist *__flp; /* freelist pointer (head of freelist) */
+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)
+size_t get_freemem(void)
+{
+ return (size_t) STACK_POINTER() - __malloc_margin - (size_t) __brkval;
+}
+
void
printfreelist(const char * title)
{
int i;
unsigned int freesum = 0;
-/* TODO: printf_P */
-
if (!__flp) {
- printf("%s no free list\n", title ? title : "");
+ printf_P(PSTR("%s no free list\n"), title ? title : "");
} else {
- printf("Free list: %s\n", title ? title : "");
+ printf_P(PSTR("Free list: %s\n"), title ? title : "");
for (i = 0, fp1 = __flp; fp1; i++, fp1 = fp1->nx) {
- printf(" entry %d @ %04x: size %4u, next ",
+ printf_P(PSTR(" entry %d @ %04x: size %4u, next "),
i, (size_t)fp1, fp1->sz);
if (fp1->nx)
- printf("%04x\n", (size_t)fp1->nx);
+ printf_P(PSTR("%04x\n"), (size_t)fp1->nx);
else
- printf("NULL\n");
+ printf_P(PSTR("NULL\n"));
freesum += fp1->sz;
}
}
- freesum += (size_t) STACK_POINTER() - __malloc_margin - (size_t) __brkval;
+ freesum += get_freemem();
- printf("SP: %04x, __brkval: %04x, Total free: %04u\n",
+ printf_P(PSTR("SP: %04x, __brkval: %04x, Total free: %04u\n"),
(size_t) STACK_POINTER(), (size_t) __brkval, freesum);
}
return CMD_RET_SUCCESS;
}
+void dump_heap(void)
+{
+ //extern unsigned int __brkval;
+
+ dump_ram((uint8_t *)__malloc_heap_start, (size_t) __malloc_heap_start, __brkval - __malloc_heap_start,
+ "=== Heap:");
+}
+
+command_ret_t do_pr_heap_avr(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc UNUSED, char * const argv[] UNUSED)
+{
+ dump_heap();
+
+ return CMD_RET_SUCCESS;
+}
+
#endif /* DEBUG */