CHDK_DE Vorschauversion  Trunk Rev. 5575
 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 "gui_mbox.h"
#include "keyboard.h"
#include "stdlib.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 (int ttime, 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 98 der Datei exmem_inspector.c.

Dokumentation der Funktionen

void __attribute__ ( (naked, noinline)  )

Definiert in Zeile 75 der Datei exmem_inspector.c.

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

Definiert in Zeile 29 der Datei exmem_inspector.c.

30 {
31  return (running==0 && shandle==0 && sampling==0);
32 }
int _module_exit_alt ( )

Definiert in Zeile 34 der Datei exmem_inspector.c.

35 {
36  //running = 0;
37  return 0;
38 }
int _run ( )

Definiert in Zeile 22 der Datei exmem_inspector.c.

23 {
25 
26  return 0;
27 }
int basic_module_init ( )
void gui_exmem_draw ( )

Definiert in Zeile 276 der Datei exmem_inspector.c.

277 {
278  unsigned int idx, idxmax, showidx;
279 
280  if (exmeminspect_redraw) {
281 
282  if (exmeminspect_redraw == 2)
283  {
286  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));
287  if (exmeminspect_mode == 0) {
289  if (exmeminspect_column == 0) {
291  }
292  else {
294  }
295  }
296  else {
298  if (exmeminspect_column == 0) {
300  }
301  else {
303  }
304  }
305  }
306 
307  showidx=3*FONT_HEIGHT;
308  if (exmeminspect_mode == 0)
309  {
310  idxmax = extypcnt;
311  for ( idx=0; idx<idxmax; idx++)
312  {
313  char *s = get_exmem_type_name(idx);
314  if (!s)
315  continue;
316  exmem_alloc_info eai;
317  if (!get_exmem_type_status(idx, &eai) || !eai.addr)
318  continue;
319 
320  char txt[50], name[18];
321  s += 6; // chop off 'EXMEM_'
322  strncpy(name, s, 17); name[17] = 0;
323  if (exmeminspect_column == 0) {
324  sprintf(txt,"%02d: %-17s %08x %8x", idx, name, (unsigned int)eai.addr, eai.len);
325  }
326  else {
327  sprintf(txt,"%02d: %-17s %08x %08x", idx, name, (unsigned int)eai.addr, (unsigned int)eai.addr+eai.len);
328  }
330  showidx += FONT_HEIGHT;
331  }
332  }
333  else
334  {
335  idx = log_disp_start;
336  while (showidx < camera_screen.height)
337  {
338  if (idx >= LOG_LEN || exl[idx].tim == 0)
339  {
341  " ",
343  }
344  else
345  {
346  char *s = get_exmem_type_name(exl[idx].typ);
347  if (!s)
348  s = " -";
349 
350  char txt[50], name[18];
351  s += 6; // chop off 'EXMEM_'
352  strncpy(name, s, 17); name[17] = 0;
353  if (exmeminspect_column == 0) {
354  sprintf(txt,"%06d: %-17s %08x %8x", exl[idx].tim, name, (unsigned int)exl[idx].adr, exl[idx].len);
355  }
356  else {
357  sprintf(txt,"%06d: %-17s %08x %08x", exl[idx].tim, name, (unsigned int)exl[idx].adr, (unsigned int)exl[idx].adr+exl[idx].len);
358  }
360  }
361  showidx += FONT_HEIGHT;
362  idx++;
363  }
364  }
365  }
366 
368 }
int gui_exmem_kbd_process ( )

Definiert in Zeile 207 der Datei exmem_inspector.c.

208 {
209  switch (kbd_get_autoclicked_key())
210  {
211  case KEY_SET:
212  sampling = !sampling;
213  if (sampling) {
214  // memset, reset, etc
215  memset(exm_prev, 0, sizeof(exmem_alloc_info)*42);
216  memset(exl, 0, sizeof(exmemlog_s)*LOG_LEN);
217  exlpnt = 0;
218  }
219  sampling_proc(0,0); // TODO: could execute parallel to timer
221  break;
222  case KEY_UP:
223  if (log_disp_start > 0) log_disp_start--;
225  break;
226  case KEY_DOWN:
229  break;
230  case KEY_SHOOT_HALF:
233  break;
234  case KEY_LEFT:
235  if (exlpnt>0)
236  write_log();
238  break;
239  case KEY_RIGHT:
242  break;
243  }
244  return 0;
245 }
void gui_exmem_menu_kbd_process ( )

Definiert in Zeile 264 der Datei exmem_inspector.c.

265 {
266  running = 0;
267  sampling = 0;
268  if (shandle) {
270  shandle = 0;
271  }
272 
274 }
int sampling_proc ( int  ttime,
int  param 
)

Definiert in Zeile 106 der Datei exmem_inspector.c.

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

Definiert in Zeile 139 der Datei exmem_inspector.c.

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

Variablen-Dokumentation

libsimple_sym _librun
Initialisierung:

Definiert in Zeile 42 der Datei exmem_inspector.c.

ModuleInfo _module_info
Initialisierung:

Definiert in Zeile 49 der Datei exmem_inspector.c.

int disph = 0
static

Definiert in Zeile 203 der Datei exmem_inspector.c.

exmem_alloc_info eaitmp
static

Definiert in Zeile 103 der Datei exmem_inspector.c.

exmemlog_s exl[LOG_LEN]
static

Definiert in Zeile 99 der Datei exmem_inspector.c.

int exlpnt = 0
static

Definiert in Zeile 100 der Datei exmem_inspector.c.

exmem_alloc_info exm_prev[42]
static

Definiert in Zeile 102 der Datei exmem_inspector.c.

int exmeminspect_column = 0
static

Definiert in Zeile 202 der Datei exmem_inspector.c.

int exmeminspect_mode = 0
static

Definiert in Zeile 201 der Datei exmem_inspector.c.

gui_handler* exmeminspect_old_guimode

Definiert in Zeile 205 der Datei exmem_inspector.c.

int exmeminspect_redraw

Definiert in Zeile 204 der Datei exmem_inspector.c.

unsigned int extypcnt = 0
static

Definiert in Zeile 101 der Datei exmem_inspector.c.

gui_handler GUI_MODE_EXMEM_INSPECTOR
Initialisierung:

Definiert in Zeile 197 der Datei exmem_inspector.c.

unsigned int log_disp_start = 0
static

Definiert in Zeile 200 der Datei exmem_inspector.c.

int running = 0
static

Definiert in Zeile 12 der Datei exmem_inspector.c.

int sampling = 0
static

Definiert in Zeile 13 der Datei exmem_inspector.c.

int shandle = 0
static

Definiert in Zeile 14 der Datei exmem_inspector.c.

int speriod = 2000
static

Definiert in Zeile 104 der Datei exmem_inspector.c.