FreeCalypso > hg > freecalypso-tools
changeset 989:a5bff8104b45
pln-ppb-test: implement program operation
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 03 Dec 2023 00:16:17 +0000 |
parents | 5a6019ed7e72 |
children | f34261bb3355 |
files | target-utils/pln-ppb-test/Makefile target-utils/pln-ppb-test/cmdtab.c target-utils/pln-ppb-test/program.c |
diffstat | 3 files changed, 40 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/target-utils/pln-ppb-test/Makefile Sun Dec 03 00:04:18 2023 +0000 +++ b/target-utils/pln-ppb-test/Makefile Sun Dec 03 00:16:17 2023 +0000 @@ -5,7 +5,7 @@ OBJCOPY=arm-elf-objcopy PROG= pln-ppb-test -OBJS= crt0.o cmdtab.o main.o mode_entry.o read_id.o +OBJS= crt0.o cmdtab.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:04:18 2023 +0000 +++ b/target-utils/pln-ppb-test/cmdtab.c Sun Dec 03 00:16:17 2023 +0000 @@ -5,6 +5,7 @@ extern void cmd_jump(); extern void cmd_mode_entry(); extern void cmd_mode_exit(); +extern void cmd_program(); extern void cmd_r8(); extern void cmd_r16(); extern void cmd_r32(); @@ -31,6 +32,7 @@ {"mode-entry", cmd_mode_entry}, {"mode-exit", cmd_mode_exit}, {"poweroff", abb_power_off}, + {"program", cmd_program}, {"r8", cmd_r8}, {"r16", cmd_r16}, {"r32", cmd_r32},
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/target-utils/pln-ppb-test/program.c Sun Dec 03 00:16:17 2023 +0000 @@ -0,0 +1,37 @@ +/* + * program command for special modes + */ + +#include <sys/types.h> +#include "types.h" + +void +cmd_program(argbulk) + char *argbulk; +{ + char *argv[3]; + u_long addr, pdata; + u16 buf[256]; + int i; + + if (parse_args(argbulk, 2, 2, argv, 0) < 0) + return; + if (parse_hexarg(argv[0], 8, &addr) < 0) { + printf("ERROR: arg1 must be a valid 32-bit hex address\n"); + return; + } + if (addr & 1) { + printf("ERROR: unaligned address\n"); + return; + } + if (parse_hexarg(argv[1], 4, &pdata) < 0) { + printf("ERROR: arg2 must be a valid 16-bit hex value\n"); + return; + } + *(volatile u16 *)addr = 0xA0; + *(volatile u16 *)addr = pdata; + 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' : ' '); +}