CHDK_DE Vorschauversion  Trunk Rev. 5833
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
firmware_crc.c-Dateireferenz
#include "camera_info.h"
#include "gui.h"
#include "gui_draw.h"
#include "meminfo.h"
#include "module_load.h"
#include "simple_module.h"
#include "clock.h"
#include "console.h"
#include "conf.h"
#include "lang.h"
#include "firmware_crc_types.h"
#include "gui_lang.h"
#include "gui_mbox.h"
#include "gui_fselect.h"
#include "keyboard.h"
+ Include-Abhängigkeitsdiagramm für firmware_crc.c:

gehe zum Quellcode dieser Datei

Aufzählungen

enum  {
  FWC_STATE_INIT, FWC_STATE_STARTED, FWC_STATE_CHECK, FWC_STATE_FAIL,
  FWC_STATE_DIALOG, FWC_STATE_DUMP, FWC_STATE_DUMP_OK, FWC_STATE_DUMP_FAIL,
  FWC_STATE_DONE, FWC_STATE_QUIT, FWC_STATE_END
}
 

Funktionen

unsigned long crc32_for_byte (unsigned long r)
 
void crc32 (const void *data, unsigned long n_bytes, unsigned long *crc)
 
void gui_fwc_draw ()
 
int dump_rom (void)
 
static void gui_fwc_done (__attribute__((unused)) unsigned unused)
 
static void gui_fwc_dump_dialog (unsigned btn)
 
int crc_core (const firmware_crc_desc_t *desc)
 
int _run ()
 
int _module_can_unload ()
 
int _module_exit_alt ()
 

Variablen

static int running = 0
 
gui_handler GUI_MODE_FWC
 
int fwc_state = FWC_STATE_INIT
 
const firmware_crc_desc_t firmware_crc_desc
 
static char out [512]
 
libsimple_sym _libfirmwarecrc
 
ModuleInfo _module_info
 

Dokumentation der Aufzählungstypen

anonymous enum
Aufzählungswerte
FWC_STATE_INIT 
FWC_STATE_STARTED 
FWC_STATE_CHECK 
FWC_STATE_FAIL 
FWC_STATE_DIALOG 
FWC_STATE_DUMP 
FWC_STATE_DUMP_OK 
FWC_STATE_DUMP_FAIL 
FWC_STATE_DONE 
FWC_STATE_QUIT 
FWC_STATE_END 

Definiert in Zeile 54 der Datei firmware_crc.c.

Dokumentation der Funktionen

int _module_can_unload ( )

Definiert in Zeile 204 der Datei firmware_crc.c.

205 {
206  if(fwc_state == FWC_STATE_INIT) {
209  }
210  return (running==0);
211 }
int _module_exit_alt ( )

Definiert in Zeile 213 der Datei firmware_crc.c.

214 {
215  running = 0;
216  return 0;
217 }
int _run ( )

Definiert in Zeile 194 der Datei firmware_crc.c.

195 {
196  // PROBLEM: we need to be in alt mode for keyboard handling and dialogs to work,
197  // but entering alt changes gui and requires getting into the main spytask loop
198  // solution: abuse the _module_can_unload handler, which is called periodically from the main loop
199  running = 1;
200  enter_alt(0);
201  return 0;
202 }
void crc32 ( const void *  data,
unsigned long  n_bytes,
unsigned long *  crc 
)

Definiert in Zeile 29 der Datei firmware_crc.c.

29  {
30  static unsigned long ct[0x100] = {0};
31  unsigned long i;
32  if (!ct[0]) {
33  for (i = 0; i < 0x100; i++) {
34  ct[i] = crc32_for_byte(i);
35  }
36  }
37  for (i = 0; i < n_bytes; i++) {
38  *crc = ct[(unsigned char)*crc ^ ((unsigned char*)data)[i]] ^ *crc >> 8;
39  }
40 }
unsigned long crc32_for_byte ( unsigned long  r)

Definiert in Zeile 21 der Datei firmware_crc.c.

21  {
22  unsigned long j;
23  for (j = 0; j < 8; j++) {
24  r = (r & 1? 0: (unsigned long)0xEDB88320) ^ r >> 1;
25  }
26  return r ^ (unsigned long)0xFF000000;
27 }
int crc_core ( const firmware_crc_desc_t desc)

Definiert in Zeile 104 der Datei firmware_crc.c.

105 {
106  running = 1;
107 
108  int failed = 0;
109  char *s = out;
110  unsigned i;
111  for(i=0; i < desc->sub_count; i++) {
112  if(!strcmp(desc->firmware_ver_ptr,desc->subs[i].canon_sub)) {
113  gui_browser_progress_show("ROM CRC",0);
114  s += sprintf(out,"%s\n%s %s\n%s\n",
117  unsigned b;
118  const firmware_crc_block_t *blocks = desc->subs[i].blocks;
119  for(b=0; b < desc->block_count; b++) {
120  gui_browser_progress_show("ROM CRC",100*(b+1)/desc->block_count);
121  // truncated dump could have zero sized blocks
122  if(blocks[b].size != 0) {
123  unsigned long fw_crc = 0;
124  crc32(blocks[b].start,blocks[b].size,&fw_crc);
125  if(fw_crc != blocks[b].crc) {
126  s += sprintf(s,"%8x ",blocks[b].start);
127  failed++;
128  }
129  }
130  }
132  break;
133  }
134  }
135  if(failed) {
137  } else {
139  }
140  return 0;
141 }
int dump_rom ( void  )

Definiert in Zeile 74 der Datei firmware_crc.c.

74  {
75  // match dumper script that normally skipts last word to avoid potential wraparound issues
76  unsigned dump_size = 0xfffffffc - camera_info.rombaseaddr;
77  // so far, no ROM bigger that 32MB
78  if(dump_size > 0x1fffffc) {
79  dump_size = 0x1fffffc;
80  }
81  FILE *fh = fopen("A/PRIMARY.BIN","wb");
82  if(!fh) {
83  return 0;
84  }
85  fwrite((char *)camera_info.rombaseaddr,dump_size,1,fh);
86  fclose(fh);
87  return 1;
88 }
static void gui_fwc_done ( __attribute__((unused)) unsigned  unused)
static

Definiert in Zeile 90 der Datei firmware_crc.c.

91 {
93 }
void gui_fwc_draw ( )

Definiert in Zeile 143 der Datei firmware_crc.c.

144 {
145  switch(fwc_state) {
146  case FWC_STATE_STARTED:
149  break;
150  case FWC_STATE_FAIL:
153  break;
154  case FWC_STATE_DUMP:
155  gui_browser_progress_show("Write PRIMARY.BIN",10); // LIES!
156  if(dump_rom()) {
158  } else {
160  }
161  gui_browser_progress_show("Write PRIMARY.BIN",100);
162  break;
163  case FWC_STATE_DUMP_OK:
166  break;
167  case FWC_STATE_DUMP_FAIL:
170  break;
171  case FWC_STATE_DONE:
172  // if set to only on boot, clear
173  if(conf.check_firmware_crc == 1) {
175  conf_save();
176  }
177  // force one spytask iteration delay
179  break;
180  case FWC_STATE_QUIT:
182  // exiting alt will clear gui mode, meaning draw will no longer be called, exit_alt handler will terminate module
183  exit_alt();
184  }
185 }
static void gui_fwc_dump_dialog ( unsigned  btn)
static

Definiert in Zeile 95 der Datei firmware_crc.c.

96 {
97  if (btn == MBOX_BTN_OK) {
99  } else {
101  }
102 }

Variablen-Dokumentation

libsimple_sym _libfirmwarecrc
Initialisierung:

Definiert in Zeile 221 der Datei firmware_crc.c.

ModuleInfo _module_info
Initialisierung:

Definiert in Zeile 228 der Datei firmware_crc.c.

const firmware_crc_desc_t firmware_crc_desc

Definiert in Zeile 12 der Datei firmware_crc_data.h.

int fwc_state = FWC_STATE_INIT

Definiert in Zeile 68 der Datei firmware_crc.c.

gui_handler GUI_MODE_FWC
Initialisierung:
=
{ GUI_MODE_MODULE, gui_fwc_draw, 0 , 0 , 0, 0 }

Definiert in Zeile 51 der Datei firmware_crc.c.

char out[512]
static

Definiert in Zeile 72 der Datei firmware_crc.c.

int running = 0
static

Definiert in Zeile 15 der Datei firmware_crc.c.