CHDK_DE Vorschauversion  Trunk Rev. 5842
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
exmem_inspector.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 "cachebit.h"
#include "exmem.h"
#include "time.h"
#include "gui_mbox.h"
#include "keyboard.h"
+ Include-Abhängigkeitsdiagramm für exmem_inspector.c:

gehe zum Quellcode dieser Datei

Datenstrukturen

struct  exmemlog_s
 

Makrodefinitionen

#define LOG_LEN   128
 

Funktionen

int basic_module_init ()
 
int _run ()
 
int _module_can_unload ()
 
int _module_exit_alt ()
 
int sampling_proc_ARM (int, int)
 
void __attribute__ ((naked, noinline))
 
int sampling_proc (__attribute__((unused)) int ttime, __attribute__((unused)) int param)
 
void write_log ()
 
void gui_exmem_menu_kbd_process ()
 
int gui_exmem_kbd_process ()
 
void gui_exmem_draw ()
 

Variablen

static int running = 0
 
static int sampling = 0
 
static int shandle = 0
 
libsimple_sym _librun
 
ModuleInfo _module_info
 
static exmemlog_s exl [LOG_LEN]
 
static int exlpnt = 0
 
static unsigned int extypcnt = 0
 
static exmem_alloc_info exm_prev [42]
 
static exmem_alloc_info eaitmp
 
static int speriod = 2000
 
gui_handler GUI_MODE_EXMEM_INSPECTOR
 
static unsigned int log_disp_start = 0
 
static int exmeminspect_mode = 0
 
static int exmeminspect_column = 0
 
static int disph = 0
 
int exmeminspect_redraw
 
gui_handlerexmeminspect_old_guimode
 

Makro-Dokumentation

#define LOG_LEN   128

Definiert in Zeile 102 der Datei exmem_inspector.c.

Dokumentation der Funktionen

void __attribute__ ( (naked, noinline)  )

Definiert in Zeile 79 der Datei exmem_inspector.c.

79  {
80  asm volatile (
81  ".code 32\n"
82 "sampling_proc_ARM:\n"
83  "adr r3, sapr_thumb+1\n"
84  "bx r3\n"
85  ".code 16\n"
86 "sapr_thumb:\n"
87  "push {lr}\n"
88  "bl sampling_proc\n"
89  "pop {pc}\n"
90  );
91 }
int _module_can_unload ( )

Definiert in Zeile 31 der Datei exmem_inspector.c.

32 {
33  return (running==0 && shandle==0 && sampling==0);
34 }
int _module_exit_alt ( )

Definiert in Zeile 36 der Datei exmem_inspector.c.

37 {
38  //running = 0;
39  return 0;
40 }
int _run ( )

Definiert in Zeile 24 der Datei exmem_inspector.c.

25 {
27 
28  return 0;
29 }
int basic_module_init ( )
void gui_exmem_draw ( )

Definiert in Zeile 279 der Datei exmem_inspector.c.

280 {
281  unsigned int idx, idxmax, showidx;
282 
283  if (exmeminspect_redraw) {
284 
285  if (exmeminspect_redraw == 2)
286  {
289  draw_string(camera_screen.disp_left, FONT_HEIGHT, sampling?"SET-stop MENU-exit RIGHT-viewmode LEFT-save":"SET-start MENU-exit RIGHT-viewmode LEFT-save", MAKE_COLOR(COLOR_BLACK, COLOR_WHITE));
290  if (exmeminspect_mode == 0) {
292  if (exmeminspect_column == 0) {
294  }
295  else {
297  }
298  }
299  else {
301  if (exmeminspect_column == 0) {
303  }
304  else {
306  }
307  }
308  }
309 
310  showidx=3*FONT_HEIGHT;
311  if (exmeminspect_mode == 0)
312  {
313  idxmax = extypcnt;
314  for ( idx=0; idx<idxmax; idx++)
315  {
316  char *s = get_exmem_type_name(idx);
317  if (!s)
318  continue;
319  exmem_alloc_info eai;
320  if (!get_exmem_type_status(idx, &eai) || !eai.addr)
321  continue;
322 
323  char txt[50], name[18];
324  s += 6; // chop off 'EXMEM_'
325  strncpy(name, s, 17); name[17] = 0;
326  if (exmeminspect_column == 0) {
327  sprintf(txt,"%02d: %-17s %08x %8x", idx, name, (unsigned int)eai.addr, eai.len);
328  }
329  else {
330  sprintf(txt,"%02d: %-17s %08x %08x", idx, name, (unsigned int)eai.addr, (unsigned int)eai.addr+eai.len);
331  }
333  showidx += FONT_HEIGHT;
334  }
335  }
336  else
337  {
338  idx = log_disp_start;
339  while (showidx < (unsigned)camera_screen.height)
340  {
341  if (idx >= LOG_LEN || exl[idx].tim == 0)
342  {
344  " ",
346  }
347  else
348  {
349  char *s = get_exmem_type_name(exl[idx].typ);
350  if (!s)
351  s = " -";
352 
353  char txt[50], name[18];
354  s += 6; // chop off 'EXMEM_'
355  strncpy(name, s, 17); name[17] = 0;
356  if (exmeminspect_column == 0) {
357  sprintf(txt,"%06d: %-17s %08x %8x", exl[idx].tim, name, (unsigned int)exl[idx].adr, exl[idx].len);
358  }
359  else {
360  sprintf(txt,"%06d: %-17s %08x %08x", exl[idx].tim, name, (unsigned int)exl[idx].adr, (unsigned int)exl[idx].adr+exl[idx].len);
361  }
363  }
364  showidx += FONT_HEIGHT;
365  idx++;
366  }
367  }
368  }
369 
371 }
int gui_exmem_kbd_process ( )

Definiert in Zeile 210 der Datei exmem_inspector.c.

211 {
212  switch (kbd_get_autoclicked_key())
213  {
214  case KEY_SET:
215  sampling = !sampling;
216  if (sampling) {
217  // memset, reset, etc
218  memset(exm_prev, 0, sizeof(exmem_alloc_info)*42);
219  memset(exl, 0, sizeof(exmemlog_s)*LOG_LEN);
220  exlpnt = 0;
221  }
222  sampling_proc(0,0); // TODO: could execute parallel to timer
224  break;
225  case KEY_UP:
226  if (log_disp_start > 0) log_disp_start--;
228  break;
229  case KEY_DOWN:
232  break;
233  case KEY_SHOOT_HALF:
236  break;
237  case KEY_LEFT:
238  if (exlpnt>0)
239  write_log();
241  break;
242  case KEY_RIGHT:
245  break;
246  }
247  return 0;
248 }
void gui_exmem_menu_kbd_process ( )

Definiert in Zeile 267 der Datei exmem_inspector.c.

268 {
269  running = 0;
270  sampling = 0;
271  if (shandle) {
273  shandle = 0;
274  }
275 
277 }
int sampling_proc ( __attribute__((unused)) int  ttime,
__attribute__((unused)) int  param 
)

Definiert in Zeile 110 der Datei exmem_inspector.c.

110  {
111  // check if sampling is still enabled, return if not
112  if (!sampling) {
113  shandle = 0;
114  return 0;
115  }
116  // set timer immediately
117 #ifndef THUMB_FW
119 #else
121 #endif
122  // now look for changes
123  int gtc = get_tick_count();
124  unsigned int n;
125  for (n=0; n<extypcnt; n++) {
127  if (exm_prev[n].addr!=eaitmp.addr || exm_prev[n].len!=eaitmp.len) {
128  if (exlpnt<LOG_LEN) {
129  exl[exlpnt].tim = gtc;
130  exl[exlpnt].typ = n;
131  exl[exlpnt].adr = eaitmp.addr;
132  exl[exlpnt].len = eaitmp.len;
133  exlpnt++;
134  }
135  }
138  }
139  return 0;
140 }
int sampling_proc_ARM ( int  ,
int   
)
void write_log ( )

Definiert in Zeile 143 der Datei exmem_inspector.c.

144 {
145  FILE *f = NULL;
146  char txt[80], name[18];
147  int n = 0;
148  do {
149  sprintf(txt, "A/CHDK/LOGS/EXM_%04d.LOG", n++);
150  if (stat(txt,0) != 0) {
151  f=fopen(txt, "wb");
152  break;
153  }
154  } while(n<9999);
155 
156  if (!f)
157  return;
158 
159  struct tm *tms;
160  time_t t;
161  t = time(NULL);
162  tms = localtime(&t);
163  sprintf(txt,"%04d-%02d-%02d %02d:%02d:%02d\n",tms->tm_year+1900,tms->tm_mon+1,tms->tm_mday,
164  tms->tm_hour,tms->tm_min,tms->tm_sec);
165  fwrite(txt,1,strlen(txt),f);
167  fwrite(txt,1,strlen(txt),f);
168  sprintf(txt,"TIME,TYPE,ADDRESS,SIZE\n");
169  fwrite(txt,1,strlen(txt),f);
170  for (n=0; n<LOG_LEN; n++)
171  {
172  char *s = get_exmem_type_name(exl[n].typ);
173  if (!s)
174  {
175  strcpy(name, "-");
176  }
177  else
178  {
179  s += 6; // chop off 'EXMEM_'
180  strncpy(name, s, 17); name[17] = 0;
181  }
182  if (exl[n].tim)
183  {
184  sprintf(txt,"%d,%s,%08x,%08x\n", exl[n].tim, name, (unsigned int)exl[n].adr, exl[n].len);
185  fwrite(txt,1,strlen(txt),f);
186  }
187  }
188  fclose(f);
189 }

Variablen-Dokumentation

libsimple_sym _librun
Initialisierung:

Definiert in Zeile 44 der Datei exmem_inspector.c.

ModuleInfo _module_info
Initialisierung:

Definiert in Zeile 51 der Datei exmem_inspector.c.

int disph = 0
static

Definiert in Zeile 206 der Datei exmem_inspector.c.

exmem_alloc_info eaitmp
static

Definiert in Zeile 107 der Datei exmem_inspector.c.

exmemlog_s exl[LOG_LEN]
static

Definiert in Zeile 103 der Datei exmem_inspector.c.

int exlpnt = 0
static

Definiert in Zeile 104 der Datei exmem_inspector.c.

exmem_alloc_info exm_prev[42]
static

Definiert in Zeile 106 der Datei exmem_inspector.c.

int exmeminspect_column = 0
static

Definiert in Zeile 205 der Datei exmem_inspector.c.

int exmeminspect_mode = 0
static

Definiert in Zeile 204 der Datei exmem_inspector.c.

gui_handler* exmeminspect_old_guimode

Definiert in Zeile 208 der Datei exmem_inspector.c.

int exmeminspect_redraw

Definiert in Zeile 207 der Datei exmem_inspector.c.

unsigned int extypcnt = 0
static

Definiert in Zeile 105 der Datei exmem_inspector.c.

gui_handler GUI_MODE_EXMEM_INSPECTOR
Initialisierung:

Definiert in Zeile 200 der Datei exmem_inspector.c.

unsigned int log_disp_start = 0
static

Definiert in Zeile 203 der Datei exmem_inspector.c.

int running = 0
static

Definiert in Zeile 14 der Datei exmem_inspector.c.

int sampling = 0
static

Definiert in Zeile 15 der Datei exmem_inspector.c.

int shandle = 0
static

Definiert in Zeile 16 der Datei exmem_inspector.c.

int speriod = 2000
static

Definiert in Zeile 108 der Datei exmem_inspector.c.