CHDK_DE Vorschauversion  Trunk Rev. 5541
 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 "stdlib.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 (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 55 der Datei firmware_crc.c.

Dokumentation der Funktionen

int _module_can_unload ( )

Definiert in Zeile 205 der Datei firmware_crc.c.

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

Definiert in Zeile 214 der Datei firmware_crc.c.

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

Definiert in Zeile 195 der Datei firmware_crc.c.

196 {
197  // PROBLEM: we need to be in alt mode for keyboard handling and dialogs to work,
198  // but entering alt changes gui and requires getting into the main spytask loop
199  // solution: abuse the _module_can_unload handler, which is called periodically from the main loop
200  running = 1;
201  enter_alt();
202  return 0;
203 }
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 105 der Datei firmware_crc.c.

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

Definiert in Zeile 75 der Datei firmware_crc.c.

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

Definiert in Zeile 91 der Datei firmware_crc.c.

92 {
94 }
void gui_fwc_draw ( )

Definiert in Zeile 144 der Datei firmware_crc.c.

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

Definiert in Zeile 96 der Datei firmware_crc.c.

97 {
98  if (btn == MBOX_BTN_OK) {
100  } else {
102  }
103 }

Variablen-Dokumentation

libsimple_sym _libfirmwarecrc
Initialisierung:

Definiert in Zeile 222 der Datei firmware_crc.c.

ModuleInfo _module_info
Initialisierung:

Definiert in Zeile 229 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 69 der Datei firmware_crc.c.

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

Definiert in Zeile 52 der Datei firmware_crc.c.

char out[512]
static

Definiert in Zeile 73 der Datei firmware_crc.c.

int running = 0
static

Definiert in Zeile 15 der Datei firmware_crc.c.