FreeCalypso > hg > freecalypso-sw
annotate lcdemu/xrm.c @ 923:10b4bed10192
gsm-fw/L1: fix for the DSP patch corruption bug
The L1 code we got from the LoCosto fw contains a feature for DSP CPU load
measurement. This feature is a LoCosto-ism, i.e., not applicable to earlier
DBB chips (Calypso) with their respective earlier DSP ROMs. Most of the
code dealing with that feature is conditionalized as #if (DSP >= 38),
but one spot was missed, and the MCU code was writing into an API word
dealing with this feature. In TCS211 this DSP API word happens to be
used by the DSP code patch, hence that write was corrupting the patched
DSP code.
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 19 Oct 2015 17:13:56 +0000 |
parents | 312778104f54 |
children |
rev | line source |
---|---|
903
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * LCDemu based on HECterm by the same author |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * Xrm functions |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdlib.h> |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <string.h> |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <strings.h> |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include <X11/Xlib.h> |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include <X11/Xresource.h> |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include <X11/Xutil.h> |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "globals.h" |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 static char appdefaults_pathname[] = |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 "/usr/local/share/freecalypso/lcdemu-defaults"; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 load_resources() |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 { |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 xrmquark_topclass = XrmStringToQuark("LCDemu"); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 xrmquark_topinstance = XrmStringToQuark(proginstancename); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 xrmdb_defaults = XrmGetFileDatabase(appdefaults_pathname); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 xrmdb_displayres = |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 XrmGetStringDatabase(XResourceManagerString(mydisplay)); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 } |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 /* |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 * The following function looks up a resource in all of our databases |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 * and returns a pointer (char *) to the value in a malloced buffer that |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 * can be freed when it is no longer needed. My reading of X11R4 |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 * documentation indicates that resource values returned from Xrm functions |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 * are not necessarily NUL-terminated (no claim is made that they are |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 * and XrmValue structure has a size field), which is why I copy to |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 * my own buffer and NUL-terminate it there. |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 * |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 * Returns NULL pointer if not found in any of the databases. |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 */ |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 char * |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 xrm_lookup(instquarks, classquarks) |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 XrmQuark *instquarks, *classquarks; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 { |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 XrmRepresentation reptype; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 XrmValue value; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 register char *buf; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 if (XrmQGetResource(xrmdb_cmdline, instquarks, classquarks, &reptype, |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 &value)) |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 goto found; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 if (XrmQGetResource(xrmdb_displayres, instquarks, classquarks, &reptype, |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 &value)) |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 goto found; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 if (XrmQGetResource(xrmdb_defaults, instquarks, classquarks, &reptype, |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 &value)) |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 goto found; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 return(NULL); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 found: buf = malloc(value.size + 1); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 if (!buf) { |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 perror("malloc"); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 exit(1); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 } |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 bcopy(value.addr, buf, value.size); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 buf[value.size] = '\0'; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 return(buf); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 } |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 parse_boolean_resource(str) |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 register char *str; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 { |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 if (!strcasecmp(str, "on") || !strcasecmp(str, "true") || |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 !strcasecmp(str, "yes")) |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 return(1); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 if (!strcasecmp(str, "off") || !strcasecmp(str, "false") || |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 !strcasecmp(str, "no")) |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 return(0); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 return(atoi(str)); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 } |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 get_boolean_resource(resource, def) |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 char *resource; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 int def; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 { |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 XrmQuark instquarks[3], classquarks[3]; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 register char *cp; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 register int i; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 instquarks[0] = xrmquark_topinstance; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 classquarks[0] = xrmquark_topclass; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 classquarks[1] = instquarks[1] = XrmStringToQuark(resource); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 instquarks[2] = classquarks[2] = NULLQUARK; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 cp = xrm_lookup(instquarks, classquarks); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 if (cp) { |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 i = parse_boolean_resource(cp); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 free(cp); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 } else |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 i = def; |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 return(i); |
312778104f54
lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 } |