comparison target-utils/pln-ppb-test/erase.c @ 990:f34261bb3355

pln-ppb-test: implement PPB erase
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Dec 2023 00:20:14 +0000
parents target-utils/pln-ppb-test/program.c@a5bff8104b45
children
comparison
equal deleted inserted replaced
989:a5bff8104b45 990:f34261bb3355
1 /*
2 * erase command for PPB special mode
3 */
4
5 #include <sys/types.h>
6 #include "types.h"
7
8 void
9 cmd_erase(argbulk)
10 char *argbulk;
11 {
12 char *argv[2];
13 u_long addr;
14 u16 buf[256];
15 int i;
16
17 if (parse_args(argbulk, 1, 1, argv, 0) < 0)
18 return;
19 if (parse_hexarg(argv[0], 8, &addr) < 0) {
20 printf("ERROR: argument must be a valid 32-bit hex address\n");
21 return;
22 }
23 if (addr & 1) {
24 printf("ERROR: unaligned address\n");
25 return;
26 }
27 *(volatile u16 *)addr = 0x80;
28 *(volatile u16 *)addr = 0x30;
29 for (i = 0; i < 256; i++)
30 buf[i] = *(volatile u16 *)addr;
31 for (i = 0; i < 256; i++)
32 printf("%04X%c", buf[i], (i & 15) == 15 ? '\n' : ' ');
33 }