annotate target-utils/libcommon/abbcmd.c @ 892:eed6dc6aca3c

gsm-fw/comlib/cl_imei.c: hell with TI's different return code types
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 29 Jun 2015 22:57:27 +0000
parents bb4814eb51e4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
389
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * abbr pg reg -- read ABB register
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * abbw pg reg val -- write ABB register
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/types.h>
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include "types.h"
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include "abbdefs.h"
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 extern u16 abb_reg_read();
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 extern void abb_reg_write();
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 void
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 cmd_abbr(argbulk)
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 char *argbulk;
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 {
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 char *argv[3];
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 u32 pg, reg, val;
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 if (parse_args(argbulk, 2, 2, argv, 0) < 0)
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 return;
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 pg = strtoul(argv[0], 0, 0);
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 reg = strtoul(argv[1], 0, 0);
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 if (pg > 1 || reg > 31) {
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 printf("ERROR: argument(s) out of range\n");
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 return;
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 }
390
bb4814eb51e4 target-utils abb[rw] commands: call abb_init() to avoid dead hang
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 389
diff changeset
28 abb_init();
389
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 val = abb_reg_read(PAGE(pg) | reg);
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 printf("%03X\n", val);
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 }
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 void
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 cmd_abbw(argbulk)
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 char *argbulk;
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 {
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 char *argv[4];
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 u32 pg, reg, val;
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 if (parse_args(argbulk, 3, 3, argv, 0) < 0)
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 return;
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 pg = strtoul(argv[0], 0, 0);
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 reg = strtoul(argv[1], 0, 0);
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 val = strtoul(argv[2], 0, 16);
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 if (pg > 1 || reg > 31 || val > 0x3FF) {
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 printf("ERROR: argument(s) out of range\n");
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 return;
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 }
390
bb4814eb51e4 target-utils abb[rw] commands: call abb_init() to avoid dead hang
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 389
diff changeset
49 abb_init();
389
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 abb_reg_write(PAGE(pg) | reg, val);
e60aecf23970 target-utils: ABB operations implemented (ported from OsmocomBB),
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 }