root/modules/cpuinfo.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. regperm_str
  2. cpuinfo_write_file
  3. basic_module_init
  4. cpuinfo_finish

   1 #include "stdlib.h"
   2 #include "gui_mbox.h"
   3 #include "gui.h"
   4 #include "gui_lang.h"
   5 #include "lang.h"
   6 
   7 struct cpuinfo_bitfield_desc_s {
   8     unsigned bits;
   9     const char *name;
  10     const char *(*desc_fn)(unsigned val);
  11 };
  12 
  13 struct cpuinfo_word_desc_s {
  14     const char *name;
  15     const struct cpuinfo_bitfield_desc_s *fields;
  16 };
  17 
  18 const struct cpuinfo_bitfield_desc_s cpuinf_id[] = {
  19     {4,"Revision"},
  20     {12,"Part"},
  21     {4,"ARM Arch"},
  22     {4,"Variant"},
  23     {8,"Implementor"},
  24     {}
  25 };
  26 
  27 static const char *reg_sizes[] = {
  28     "4K", "8K", "16K", "32K", "64K", "128K", "256K", "512K", 
  29     "1M", "2M", "4M", "8M", "16M", "32M", "64M", "128M", "256M", "512M",
  30     "1G", "2G", "4G",
  31 };
  32 
  33 static const char *regperm_str(unsigned val) {
  34     switch(val) {
  35         case 0: return "P:-- U:--";
  36         case 1: return "P:RW U:--";
  37         case 2: return "P:RW U:R-";
  38         case 3: return "P:RW U:RW";
  39         case 5: return "P:R- U:--";
  40         case 6: return "P:R- U:R-";
  41         default:
  42             return "P:?? U:??";
  43     }
  44 }
  45 
  46 #ifdef THUMB_FW
  47     #include "cpuinfo_v7.c"
  48 #else
  49     #include "cpuinfo_v5.c"
  50 #endif
  51 
  52 // note, this is how many we know, nothing to do with how many debug_read_cpuinfo knows
  53 #define NUM_CPUINFO_WORDS ((sizeof(cpuinfo_desc)/sizeof(cpuinfo_desc[0])) - 1)
  54 
  55 void cpuinfo_finish(unsigned dummy);
  56 void cpuinfo_get_info(unsigned *results);
  57 
  58 void cpuinfo_write_file(void) {
  59     unsigned cpuinfo[NUM_CPUINFO_WORDS];
  60     int i,j;
  61     unsigned fieldval,wordval;
  62     unsigned mask,bits;
  63     FILE *finfo;
  64     char buf[100];
  65     char *p;
  66     cpuinfo_get_info(cpuinfo);
  67     finfo=fopen("A/CPUINFO.TXT", "wb");
  68     for(i = 0; cpuinfo_desc[i].name; i++) {
  69         wordval = cpuinfo[i];
  70         sprintf(buf,"%-10s 0x%08X\n",cpuinfo_desc[i].name,wordval);
  71         fwrite(buf,1,strlen(buf),finfo);
  72         for(j=0; cpuinfo_desc[i].fields[j].name; j++) {
  73             p=buf;
  74             bits = cpuinfo_desc[i].fields[j].bits;
  75             mask = ~(0xFFFFFFFF << bits);
  76             fieldval = wordval & mask;
  77             p+=sprintf(p,"  %-20s 0x%X %d",cpuinfo_desc[i].fields[j].name,fieldval,fieldval);
  78             if(cpuinfo_desc[i].fields[j].desc_fn) {
  79                 p+=sprintf(p," [%s]",cpuinfo_desc[i].fields[j].desc_fn(fieldval));
  80             }
  81             strcat(p,"\n");
  82             fwrite(buf,1,strlen(buf),finfo);
  83             wordval >>= bits;
  84         }
  85     }
  86     fclose(finfo);
  87     sprintf(buf, lang_str(LANG_CPUINFO_WROTE), "A/CPUINFO.TXT");
  88     gui_mbox_init(LANG_MENU_DEBUG_CPU_INFO,(int)buf,MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, cpuinfo_finish);
  89 }
  90 
  91 int basic_module_init() {
  92     cpuinfo_write_file();
  93     return 1;
  94 }
  95 // =========  MODULE INIT =================
  96 #include "simple_module.c"
  97 void cpuinfo_finish(unsigned dummy) {
  98     running=0;
  99 }
 100 
 101 ModuleInfo _module_info =
 102 {
 103     MODULEINFO_V1_MAGICNUM,
 104     sizeof(ModuleInfo),
 105     SIMPLE_MODULE_VERSION,                      // Module version
 106 
 107     ANY_CHDK_BRANCH, 0, OPT_ARCHITECTURE,                       // Requirements of CHDK version
 108     ANY_PLATFORM_ALLOWED,               // Specify platform dependency
 109 
 110     -LANG_MENU_DEBUG_CPU_INFO,  // Module name
 111     MTYPE_TOOL,             //Read CPU and cache information from CP15
 112 
 113     &_librun.base,
 114 
 115     ANY_VERSION,                // CONF version
 116     ANY_VERSION,                // CAM SCREEN version
 117     ANY_VERSION,                // CAM SENSOR version
 118     ANY_VERSION,                // CAM INFO version
 119 };
 120 
 121 /*************** END OF AUXILARY PART *******************/
 122 

/* [<][>][^][v][top][bottom][index][help] */