annotate target-utils/pln-ppb-test/mode_entry.c @ 996:162d2cf394e2

fc-loadtool help: document new commands for sector lock/unlock
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Dec 2023 23:00:04 +0000
parents 6b87de9e385b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
986
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * mode-entry and mode-exit commands
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "types.h"
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 void
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 cmd_mode_entry(argbulk)
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 char *argbulk;
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 {
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 char *argv[3];
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 u_long addr, mode;
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 if (parse_args(argbulk, 2, 2, argv, 0) < 0)
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 return;
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 if (parse_hexarg(argv[0], 8, &addr) < 0) {
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 printf("ERROR: arg1 must be a valid 32-bit hex address\n");
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 return;
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 }
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 if (addr & 0xFFFF) {
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 printf("ERROR: address is not on 64 KiB boundary\n");
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 return;
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (parse_hexarg(argv[1], 4, &mode) < 0) {
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 printf("ERROR: arg2 must be a valid 16-bit hex value\n");
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 return;
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 }
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 *(volatile u16 *)(addr + 0xAAA) = 0xAA;
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 *(volatile u16 *)(addr + 0x554) = 0x55;
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 *(volatile u16 *)(addr + 0xAAA) = mode;
676203b4bf33 pln-ppb-test: implement mode-entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
987
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
33
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
34 void
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
35 cmd_mode_exit(argbulk)
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
36 char *argbulk;
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
37 {
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
38 char *argv[2];
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
39 u_long addr;
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
40
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
41 if (parse_args(argbulk, 1, 1, argv, 0) < 0)
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
42 return;
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
43 if (parse_hexarg(argv[0], 8, &addr) < 0) {
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
44 printf("ERROR: argument must be a valid 32-bit hex address\n");
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
45 return;
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
46 }
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
47 if (addr & 0xFFFF) {
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
48 printf("ERROR: address is not on 64 KiB boundary\n");
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
49 return;
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
50 }
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
51 *(volatile u16 *)addr = 0x90;
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
52 *(volatile u16 *)addr = 0x00;
6b87de9e385b pln-ppb-test: implement mode-exit
Mychaela Falconia <falcon@freecalypso.org>
parents: 986
diff changeset
53 }