FreeCalypso > hg > freecalypso-tools
comparison target-utils/pln-ppb-test/program.c @ 989:a5bff8104b45
pln-ppb-test: implement program operation
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sun, 03 Dec 2023 00:16:17 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 988:5a6019ed7e72 | 989:a5bff8104b45 |
|---|---|
| 1 /* | |
| 2 * program command for special modes | |
| 3 */ | |
| 4 | |
| 5 #include <sys/types.h> | |
| 6 #include "types.h" | |
| 7 | |
| 8 void | |
| 9 cmd_program(argbulk) | |
| 10 char *argbulk; | |
| 11 { | |
| 12 char *argv[3]; | |
| 13 u_long addr, pdata; | |
| 14 u16 buf[256]; | |
| 15 int i; | |
| 16 | |
| 17 if (parse_args(argbulk, 2, 2, argv, 0) < 0) | |
| 18 return; | |
| 19 if (parse_hexarg(argv[0], 8, &addr) < 0) { | |
| 20 printf("ERROR: arg1 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 if (parse_hexarg(argv[1], 4, &pdata) < 0) { | |
| 28 printf("ERROR: arg2 must be a valid 16-bit hex value\n"); | |
| 29 return; | |
| 30 } | |
| 31 *(volatile u16 *)addr = 0xA0; | |
| 32 *(volatile u16 *)addr = pdata; | |
| 33 for (i = 0; i < 256; i++) | |
| 34 buf[i] = *(volatile u16 *)addr; | |
| 35 for (i = 0; i < 256; i++) | |
| 36 printf("%04X%c", buf[i], (i & 15) == 15 ? '\n' : ' '); | |
| 37 } |
