do {
z80_bus_cmd(Request);
data = z80_read(addr);
- printf("%05lx: %02x", addr, data);
+ printf_P(PSTR("%05lx: %02x"), addr, data);
z80_bus_cmd(Release);
nbytes = cli_readline(PSTR(" ? "));
/* check for ctrl-c to abort... */
if (ctrlc()) {
- my_puts("Abort\n");
+ my_puts_P(PSTR("Abort\n"));
return CMD_RET_SUCCESS;
}
}
/* check for ctrl-c to abort... */
if (ctrlc()) {
- my_puts("Abort\n");
+ my_puts_P(PSTR("Abort\n"));
return CMD_RET_SUCCESS;
}
}
/* check for ctrl-c to abort... */
if (ctrlc()) {
- my_puts("Abort\n");
+ my_puts_P(PSTR("Abort\n"));
return CMD_RET_SUCCESS;
}
}
- printf("Total of %ld byte(s) (0x%lx) were the same\n", ngood, ngood);
+ printf_P(PSTR("Total of %ld byte(s) (0x%lx) were the same\n"), ngood, ngood);
return rcode;
}
count = strtoul(argv[3], NULL, 16);
if (count == 0) {
- my_puts ("Zero length ???\n");
+ my_puts_P(PSTR("Zero length?\n"));
return CMD_RET_FAILURE;
}
/* check for ctrl-c to abort... */
if (ctrlc()) {
- my_puts("Abort\n");
+ my_puts_P(PSTR("Abort\n"));
return CMD_RET_SUCCESS;
}
}
base_address = strtoul(argv[1], NULL, 16);
}
/* Print the current base address. */
- printf("Base Address: 0x%05lx\n", base_address);
+ printf_P(PSTR("Base Address: 0x%05lx\n"), base_address);
return CMD_RET_SUCCESS;
}
*dummy = ~val; /* clear the test data off the bus */
readback = *addr;
if (readback != val) {
- printf("FAILURE (data line): "
- "expected %05lx, actual %05lx\n",
+ printf_P(PSTR("FAILURE (data line): "
+ "expected %05lx, actual %05lx\n"),
val, readback);
errs++;
if (ctrlc())
*dummy = val;
readback = *addr;
if (readback != ~val) {
- printf("FAILURE (data line): "
- "Is %05lx, should be %05lx\n",
+ printf_P(PSTR("FAILURE (data line): "
+ "Is %05lx, should be %05lx\n"),
readback, ~val);
errs++;
if (ctrlc())
for (offset = 1; offset < num_words; offset <<= 1) {
temp = addr[offset];
if (temp != pattern) {
- printf("\nFAILURE: Address bit stuck high @ 0x%.5lx:"
- " expected 0x%.5lx, actual 0x%.5lx\n",
+ printf_P(PSTR("\nFAILURE: Address bit stuck high @ 0x%.5lx:"
+ " expected 0x%.5lx, actual 0x%.5lx\n"),
start_addr + offset*sizeof(vu_long),
pattern, temp);
errs++;
for (offset = 1; offset < num_words; offset <<= 1) {
temp = addr[offset];
if ((temp != pattern) && (offset != test_offset)) {
- printf("\nFAILURE: Address bit stuck low or"
+ printf_P(PSTR("\nFAILURE: Address bit stuck low or"
" shorted @ 0x%.5lx: expected 0x%.5lx,"
- " actual 0x%.5lx\n",
+ " actual 0x%.5lx\n"),
start_addr + offset*sizeof(vu_long),
pattern, temp);
errs++;
for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
temp = addr[offset];
if (temp != pattern) {
- printf("\nFAILURE (read/write) @ 0x%.5lx:"
- " expected 0x%.5lx, actual 0x%.5lx)\n",
+ printf_P(PSTR("\nFAILURE (read/write) @ 0x%.5lx:"
+ " expected 0x%.5lx, actual 0x%.5lx)\n"),
start_addr + offset*sizeof(vu_long),
pattern, temp);
errs++;
anti_pattern = ~pattern;
temp = addr[offset];
if (temp != anti_pattern) {
- printf("\nFAILURE (read/write): @ 0x%.5lx:"
- " expected 0x%.5lx, actual 0x%.5lx)\n",
+ printf_P(PSTR("\nFAILURE (read/write): @ 0x%.5lx:"
+ " expected 0x%.5lx, actual 0x%.5lx)\n"),
start_addr + offset*sizeof(vu_long),
anti_pattern, temp);
errs++;
}
length = (end_addr - start_addr) / sizeof(uint32_t);
end = buf + length;
- printf("\rPattern %08lX Writing..."
+ printf_P(PSTR("\rPattern %08lX Writing..."
"%12s"
- "\b\b\b\b\b\b\b\b\b\b",
+ "\b\b\b\b\b\b\b\b\b\b"),
pattern, "");
for (addr = buf, val = pattern; addr < end; addr++) {
val += incr;
}
- my_puts("Reading...");
+ my_puts_P(PSTR("Reading..."));
for (addr = buf, val = pattern; addr < end; addr++) {
readback = *addr;
if (readback != val) {
uint32_t offset = addr - buf;
- printf("\nMem error @ 0x%08X: "
- "found %08lX, expected %08lX\n",
+ printf_P(PSTR("\nMem error @ 0x%08X: "
+ "found %08lX, expected %08lX\n"),
(unsigned int)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
readback, val);
errs++;
else
iteration_limit = 0;
- printf("Testing %08x ... %08x:\n", (unsigned int)start, (unsigned int)end);
+ printf_P(PSTR("Testing %08x ... %08x:\n"), (unsigned int)start, (unsigned int)end);
debug("%s:%d: start %#05lx end %#05lx\n", __func__, __LINE__,
start, end);
break;
}
- printf("Iteration: %6d\r", iteration + 1);
+ printf_P(PSTR("Iteration: %6d\r"), iteration + 1);
debug("\n");
if (alt_test) {
errs = mem_test_alt(buf, start, end, dummy);
putc('\n');
ret = 1;
} else {
- printf("Tested %d iteration(s) with %lu errors.\n",
+ printf_P(PSTR("Tested %d iteration(s) with %lu errors.\n"),
iteration, errs);
ret = errs != 0;
}
return CMD_RET_FAILURE;
}
if (count == 0) {
- debug("Zero length ???\n");
+ debug("Zero length?\n");
return CMD_RET_FAILURE;
}
}
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 */
}
+static
+uint16_t varval_getlen(uint16_t index)
+{
+ int i = 0;
+ char c;
+
+ while ((c = env_get_char (index + i)) != '\0') {
+ i++;
+ };
+
+ return i;
+}
+
static
uint16_t varval_get(char *buf, uint16_t index, int len)
{
if (ep != NULL && (flag & ENV_GET_VAL)) {
if (ep->flags & EF_V_EEP) {
char *vp;
- uint_fast8_t len;
- /* TODO: function that gets len of val,
- to get rid of xrealloc */
- vp = xmalloc(CONFIG_SYS_CBSIZE);
- len = varval_get(vp, ep->val.eep, CONFIG_SYS_CBSIZE);
- ep->val.ram = xrealloc(vp, len + 1);
- ep->flags &= ~EF_V_EEP;
+ int len;
+ len = varval_getlen(ep->val.eep);
+ if (len > CONFIG_SYS_CBSIZE)
+ len = CONFIG_SYS_CBSIZE;
+ vp = xmalloc(len + 1);
+ if (vp) {
+ varval_get(vp, ep->val.eep, len + 1);
+ ep->val.ram = vp;
+ ep->flags &= ~EF_V_EEP;
+ } else
+ printf_P(PSTR("Out of memory!\n"));
}
}