FreeCalypso > hg > freecalypso-sw
annotate target-utils/libcommon/cmd_w16.c @ 462:6500e1817d9b
doc/Roadmap: written
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 23 Jun 2014 20:39:36 +0000 |
parents | 4c78fc688127 |
children |
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 } |