This source file includes following definitions.
- regperm_str
- cpuinfo_write_file
- basic_module_init
- cpuinfo_finish
1 #include "stdlib.h"
2 #include "string.h"
3 #include "stdio.h"
4 #include "ctype.h"
5 #include "gui_mbox.h"
6 #include "gui.h"
7 #include "gui_lang.h"
8 #include "lang.h"
9
10 struct cpuinfo_bitfield_desc_s {
11 unsigned bits;
12 const char *name;
13 const char *(*desc_fn)(unsigned val);
14 };
15
16 struct cpuinfo_word_desc_s {
17 const char *name;
18 const struct cpuinfo_bitfield_desc_s *fields;
19 };
20
21 const struct cpuinfo_bitfield_desc_s cpuinf_id[] = {
22 {4,"Revision",0},
23 {12,"Part",0},
24 {4,"ARM Arch",0},
25 {4,"Variant",0},
26 {8,"Implementor",0},
27 {0}
28 };
29
30 static const char *reg_sizes[] = {
31 "4K", "8K", "16K", "32K", "64K", "128K", "256K", "512K",
32 "1M", "2M", "4M", "8M", "16M", "32M", "64M", "128M", "256M", "512M",
33 "1G", "2G", "4G",
34 };
35
36 static const char *regperm_str(unsigned val) {
37 switch(val) {
38 case 0: return "P:-- U:--";
39 case 1: return "P:RW U:--";
40 case 2: return "P:RW U:R-";
41 case 3: return "P:RW U:RW";
42 case 5: return "P:R- U:--";
43 case 6: return "P:R- U:R-";
44 default:
45 return "P:?? U:??";
46 }
47 }
48
49 #ifdef THUMB_FW
50 #include "cpuinfo_v7.c"
51
52 #define NUM_CPUINFO_WORDS (((sizeof(cpuinfo_desc_pmsa)>sizeof(cpuinfo_desc_vmsa))? \
53 sizeof(cpuinfo_desc_pmsa):sizeof(cpuinfo_desc_vmsa))/ \
54 sizeof(cpuinfo_desc_pmsa[0]) - 1)
55 #else
56 #include "cpuinfo_v5.c"
57
58 #define NUM_CPUINFO_WORDS ((sizeof(cpuinfo_desc)/sizeof(cpuinfo_desc[0])) - 1)
59 #endif
60
61 void cpuinfo_finish(unsigned dummy);
62
63 void cpuinfo_write_file(void) {
64 unsigned cpuinfo[NUM_CPUINFO_WORDS];
65 int i,j;
66 unsigned fieldval,wordval;
67 unsigned mask,bits;
68 FILE *finfo;
69 char buf[100];
70 char *p;
71 #ifdef THUMB_FW
72 struct cpuinfo_word_desc_s *cpuinfo_desc;
73 if (cpu_is_vmsa()) {
74 FILE *f=fopen("A/MMU_MAP.CSV", "wb");
75 memmapping_vmsa(f);
76 cpuinfo_get_info_vmsa(cpuinfo);
77 cpuinfo_desc = (struct cpuinfo_word_desc_s*) cpuinfo_desc_vmsa;
78 }
79 else {
80 cpuinfo_get_info_pmsa(cpuinfo);
81 cpuinfo_desc = (struct cpuinfo_word_desc_s*) cpuinfo_desc_pmsa;
82 }
83 #else
84 cpuinfo_get_info(cpuinfo);
85 #endif
86 finfo=fopen("A/CPUINFO.TXT", "wb");
87 for(i = 0; cpuinfo_desc[i].name; i++) {
88 wordval = cpuinfo[i];
89 sprintf(buf,"%-10s 0x%08X\n",cpuinfo_desc[i].name,wordval);
90 fwrite(buf,1,strlen(buf),finfo);
91 for(j=0; cpuinfo_desc[i].fields[j].name; j++) {
92 p=buf;
93 bits = cpuinfo_desc[i].fields[j].bits;
94 mask = ~(0xFFFFFFFF << bits);
95 fieldval = wordval & mask;
96 p+=sprintf(p," %-20s 0x%X %d",cpuinfo_desc[i].fields[j].name,fieldval,fieldval);
97 if(cpuinfo_desc[i].fields[j].desc_fn) {
98 p+=sprintf(p," [%s]",cpuinfo_desc[i].fields[j].desc_fn(fieldval));
99 }
100 strcat(p,"\n");
101 fwrite(buf,1,strlen(buf),finfo);
102 wordval >>= bits;
103 }
104 }
105 fclose(finfo);
106 sprintf(buf, lang_str(LANG_CPUINFO_WROTE), "A/CPUINFO.TXT");
107 gui_mbox_init(LANG_MENU_DEBUG_CPU_INFO,(int)buf,MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, cpuinfo_finish);
108 }
109
110 int basic_module_init() {
111 cpuinfo_write_file();
112 return 1;
113 }
114
115 #include "simple_module.c"
116 void cpuinfo_finish(__attribute__ ((unused))unsigned dummy) {
117 running=0;
118 }
119
120 ModuleInfo _module_info =
121 {
122 MODULEINFO_V1_MAGICNUM,
123 sizeof(ModuleInfo),
124 SIMPLE_MODULE_VERSION,
125
126 ANY_CHDK_BRANCH, 0, OPT_ARCHITECTURE,
127 ANY_PLATFORM_ALLOWED,
128
129 -LANG_MENU_DEBUG_CPU_INFO,
130 MTYPE_TOOL,
131
132 &_librun.base,
133
134 ANY_VERSION,
135 ANY_VERSION,
136 ANY_VERSION,
137 ANY_VERSION,
138
139 0,
140 };
141
142
143