annotate target-utils/libcommon/cmd_w32.c @ 903:312778104f54

lcdemu started, compiles and runs w/o actual functionality
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 07 Sep 2015 08:34:37 +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 * w32 hexaddr xxxxxxxx -- write a 32-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_w32(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 & 3) {
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], 8, &data) < 0) {
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 printf("ERROR: arg2 must be a valid 32-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 u32 *)addr = data;
4c78fc688127 w8/w16/w32 implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 }