FreeCalypso > hg > freecalypso-tools
changeset 990:f34261bb3355
pln-ppb-test: implement PPB erase
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 03 Dec 2023 00:20:14 +0000 |
parents | a5bff8104b45 |
children | 8aeb840bc25f |
files | target-utils/pln-ppb-test/Makefile target-utils/pln-ppb-test/cmdtab.c target-utils/pln-ppb-test/erase.c |
diffstat | 3 files changed, 36 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/target-utils/pln-ppb-test/Makefile Sun Dec 03 00:16:17 2023 +0000 +++ b/target-utils/pln-ppb-test/Makefile Sun Dec 03 00:20:14 2023 +0000 @@ -5,7 +5,7 @@ OBJCOPY=arm-elf-objcopy PROG= pln-ppb-test -OBJS= crt0.o cmdtab.o main.o mode_entry.o program.o read_id.o +OBJS= crt0.o cmdtab.o erase.o main.o mode_entry.o program.o read_id.o LIBS= ../libcommon/libcommon.a ../libprintf/libprintf.a \ ../libbase/libbase.a ../libc/libc.a LIBGCC= `${CC} -print-file-name=libgcc.a`
--- a/target-utils/pln-ppb-test/cmdtab.c Sun Dec 03 00:16:17 2023 +0000 +++ b/target-utils/pln-ppb-test/cmdtab.c Sun Dec 03 00:20:14 2023 +0000 @@ -2,6 +2,7 @@ extern void cmd_abbr(); extern void cmd_abbw(); +extern void cmd_erase(); extern void cmd_jump(); extern void cmd_mode_entry(); extern void cmd_mode_exit(); @@ -28,6 +29,7 @@ {"abbw", cmd_abbw}, {"baud", cmd_baud_switch}, {"dump", cmd_memdump_human}, + {"erase", cmd_erase}, {"jump", cmd_jump}, {"mode-entry", cmd_mode_entry}, {"mode-exit", cmd_mode_exit},
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/target-utils/pln-ppb-test/erase.c Sun Dec 03 00:20:14 2023 +0000 @@ -0,0 +1,33 @@ +/* + * erase command for PPB special mode + */ + +#include <sys/types.h> +#include "types.h" + +void +cmd_erase(argbulk) + char *argbulk; +{ + char *argv[2]; + u_long addr; + u16 buf[256]; + int i; + + if (parse_args(argbulk, 1, 1, argv, 0) < 0) + return; + if (parse_hexarg(argv[0], 8, &addr) < 0) { + printf("ERROR: argument must be a valid 32-bit hex address\n"); + return; + } + if (addr & 1) { + printf("ERROR: unaligned address\n"); + return; + } + *(volatile u16 *)addr = 0x80; + *(volatile u16 *)addr = 0x30; + for (i = 0; i < 256; i++) + buf[i] = *(volatile u16 *)addr; + for (i = 0; i < 256; i++) + printf("%04X%c", buf[i], (i & 15) == 15 ? '\n' : ' '); +}