annotate target-utils/libcommon/cmd_w16.c @ 992:a7b0b426f9ca

target-utils: boot ROM UART autodetection revamped The new implementation should work with both the familiar Calypso C035 boot ROM version found in our regular targets as well as the older Calypso F741979B version found on the vintage D-Sample board.
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Wed, 30 Dec 2015 21:28:41 +0000
parents 4c78fc688127
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * w16 hexaddr xxxx -- write a 16-bit register or memory location
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include "types.h"
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 void
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 cmd_w16(argbulk)
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 char *argbulk;
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 {
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 char *argv[3];
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 u_long addr, data;
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 if (parse_args(argbulk, 2, 2, argv, 0) < 0)
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 return;
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 if (parse_hexarg(argv[0], 8, &addr) < 0) {
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 printf("ERROR: arg1 must be a valid 32-bit hex address\n");
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 return;
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 }
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 if (addr & 1) {
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 printf("ERROR: unaligned address\n");
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 return;
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 }
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 if (parse_hexarg(argv[1], 4, &data) < 0) {
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 printf("ERROR: arg2 must be a valid 16-bit hex value\n");
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 return;
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 }
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 *(volatile u16 *)addr = data;
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 }