CHDK_DE Vorschauversion  Trunk Rev. 5779
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
memmgmt.c-Dateireferenz
#include "platform.h"
#include "core.h"
#include "conf.h"
#include "gui_draw.h"
#include "exmem.h"
#include "semaphore.h"
#include "ctype.h"
+ Include-Abhängigkeitsdiagramm für memmgmt.c:

gehe zum Quellcode dieser Datei

Datenstrukturen

struct  chdk_heap
 

Funktionen

void * suba_init (void *heap, unsigned size, unsigned mincell, char *name)
 
void * suba_alloc (void *heap, unsigned size, unsigned zero)
 
int suba_free (void *heap, void *p)
 
static void chdk_heap_init (chdk_heap *h)
 
static void * chdk_malloc (chdk_heap *h, unsigned size)
 
static int chdk_free (chdk_heap *h, void *p)
 
static int chdk_meminfo (chdk_heap *h, cam_meminfo *camera_meminfo)
 
void exmem_malloc_init ()
 
int GetExMemInfo (cam_meminfo *camera_meminfo)
 
void aram_malloc_init ()
 
int GetARamInfo (cam_meminfo *camera_meminfo)
 
void canon_malloc_init (void)
 
static void combine_meminfo (cam_meminfo *combined, cam_meminfo *m)
 
void GetCombinedMemInfo (cam_meminfo *camera_meminfo)
 
void * malloc (long size)
 
void free (void *p)
 
char * get_exmem_type_name (unsigned int type)
 
int get_exmem_type_status (unsigned int type, exmem_alloc_info *allocinf)
 

Variablen

static chdk_heap exmem_heap
 
static chdk_heap aram_heap
 
int canon_heap_sem
 

Dokumentation der Funktionen

void aram_malloc_init ( )

Definiert in Zeile 211 der Datei memmgmt.c.

212 {
214 #ifdef OPT_ARAM_MALLOC
215 #ifndef OPT_CHDK_IN_ARAM
216 #define OPT_CHDK_IN_ARAM 0
217 #endif
218 #ifndef OPT_ARAM_TESTING
219 #define OPT_ARAM_TESTING 0
220 #endif
221  chdk_heap_create(&aram_heap, (void*)ARAM_HEAP_START, ARAM_HEAP_SIZE, OPT_CHDK_IN_ARAM, OPT_ARAM_TESTING, "aram_suba");
222 #endif
223 }
void canon_malloc_init ( void  )

Definiert in Zeile 236 der Datei memmgmt.c.

236  {
237  canon_heap_sem=CreateBinarySemaphore("canonheap", 1);
238 }
static int chdk_free ( chdk_heap h,
void *  p 
)
static

Definiert in Zeile 83 der Datei memmgmt.c.

84 {
85  if (h && h->heap && (p >= h->start) && (p < h->end))
86  {
87  suba_free(h->heap,p);
88  return 1;
89  }
90  return 0;
91 }
static void chdk_heap_init ( chdk_heap h)
static

Definiert in Zeile 26 der Datei memmgmt.c.

27 {
28  h->heap = 0;
29  h->start = 0;
30  h->end = 0;
31  h->size = 0;
32 }
static void* chdk_malloc ( chdk_heap h,
unsigned  size 
)
static

Definiert in Zeile 76 der Datei memmgmt.c.

77 {
78  if (h && h->heap)
79  return suba_alloc(h->heap,size,0);
80  return 0;
81 }
static int chdk_meminfo ( chdk_heap h,
cam_meminfo camera_meminfo 
)
static

Definiert in Zeile 94 der Datei memmgmt.c.

95 {
96  if (h && h->heap)
97  {
98  extern void suba_getmeminfo(void*, int*, int*, int*, int*, int*, int*);
99 
100  camera_meminfo->start_address = (int)h->start;
101  camera_meminfo->end_address = (int)h->end;
102  camera_meminfo->total_size = h->size;
104  &camera_meminfo->allocated_size, &camera_meminfo->allocated_peak, &camera_meminfo->allocated_count,
105  &camera_meminfo->free_size, &camera_meminfo->free_block_max_size, &camera_meminfo->free_block_count);
106 
107  return 1; // return success
108  }
109  else
110  {
111  memset(camera_meminfo, 0, sizeof(cam_meminfo));
112  return 0;
113  }
114 }
static void combine_meminfo ( cam_meminfo combined,
cam_meminfo m 
)
static

Definiert in Zeile 242 der Datei memmgmt.c.

243 {
244  combined->total_size += m->total_size;
245  if(m->free_block_max_size > combined->free_block_max_size)
246  {
248  }
249  combined->free_size += m->free_size;
250  combined->free_block_count += m->free_block_count;
251  combined->allocated_size += m->allocated_size;
252  combined->allocated_peak += m->allocated_peak;
253  combined->allocated_count += m->allocated_count;
254 }
void exmem_malloc_init ( )

Definiert in Zeile 174 der Datei memmgmt.c.

175 {
177 #ifdef OPT_EXMEM_MALLOC
178 #ifndef OPT_CHDK_IN_EXMEM
179 #define OPT_CHDK_IN_EXMEM 0
180 #endif
181 #ifndef OPT_EXMEM_TESTING
182 #define OPT_EXMEM_TESTING 0
183 #endif
184  // pool zero is EXMEM_RAMDISK on d10
185  extern void *exmem_alloc_cached(unsigned int pool_id,unsigned int size,int unk,int unk2);
186  void *mem = exmem_alloc_cached(0,EXMEM_HEAP_SIZE,0,0);
187  if (mem)
188  {
189  chdk_heap_create(&exmem_heap, mem, EXMEM_BUFFER_SIZE, OPT_CHDK_IN_EXMEM, OPT_EXMEM_TESTING, "exmem_suba");
190  }
191 #endif
192 }
void free ( void *  p)

Definiert in Zeile 303 der Datei memmgmt.c.

304 {
305  extern void canon_free(void *p);
306 
307  if (!chdk_free(&aram_heap,p))
308  if (!chdk_free(&exmem_heap,p))
309  canon_free(p);
310 }
char* get_exmem_type_name ( unsigned int  type)

Definiert in Zeile 317 der Datei memmgmt.c.

318 {
319  extern char* exmem_types_table[];
320 
321  if (type<exmem_type_count) {
322  return exmem_types_table[type];
323  }
324  return 0;
325 }
int get_exmem_type_status ( unsigned int  type,
exmem_alloc_info allocinf 
)

Definiert in Zeile 329 der Datei memmgmt.c.

330 {
331  extern exmem_alloc_info exmem_alloc_table[];
332  if (type<exmem_type_count && allocinf) {
333  allocinf->addr = exmem_alloc_table[type].addr;
334  allocinf->len = exmem_alloc_table[type].len;
335  return 1;
336  }
337  return 0;
338 }
int GetARamInfo ( cam_meminfo camera_meminfo)

Definiert in Zeile 226 der Datei memmgmt.c.

227 {
228  return chdk_meminfo(&aram_heap, camera_meminfo);
229 }
void GetCombinedMemInfo ( cam_meminfo camera_meminfo)

Definiert in Zeile 259 der Datei memmgmt.c.

260 {
261  // get system meminfo, should always be available
262  GetMemInfo(camera_meminfo);
263 // some fields are set to -1 for vxworks cams
264 #if !defined(CAM_DRYOS)
265  camera_meminfo->allocated_peak = 0;
266  camera_meminfo->total_size = 0;
267 #ifdef CAM_NO_MEMPARTINFO
268  // a more useful base value than 0
269  camera_meminfo->free_size = camera_meminfo->free_block_max_size;
270  camera_meminfo->free_block_count = 0;
271  camera_meminfo->allocated_size = 0;
272  camera_meminfo->allocated_count = 0;
273 #endif
274 #endif
275 
276  // these don't make sense to combine
277  camera_meminfo->start_address = camera_meminfo->end_address = 0;
278 
279  cam_meminfo m;
280  if(GetARamInfo(&m)) {
281  combine_meminfo(camera_meminfo,&m);
282  }
283  if(GetExMemInfo(&m)) {
284  combine_meminfo(camera_meminfo,&m);
285  }
286 }
int GetExMemInfo ( cam_meminfo camera_meminfo)

Definiert in Zeile 195 der Datei memmgmt.c.

196 {
197  return chdk_meminfo(&exmem_heap, camera_meminfo);
198 }
void* malloc ( long  size)

Definiert in Zeile 288 der Datei memmgmt.c.

289 {
290  extern void *canon_malloc(long size);
291 
292  void *p = chdk_malloc(&aram_heap,size);
293 
294  if (p == 0)
295  p = chdk_malloc(&exmem_heap,size);
296 
297  if (p == 0)
298  p = canon_malloc(size);
299 
300  return p;
301 }
void* suba_alloc ( void *  heap,
unsigned  size,
unsigned  zero 
)
int suba_free ( void *  heap,
void *  p 
)
void* suba_init ( void *  heap,
unsigned  size,
unsigned  mincell,
char *  name 
)

Variablen-Dokumentation

chdk_heap aram_heap
static

Definiert in Zeile 202 der Datei memmgmt.c.

int canon_heap_sem

Definiert in Zeile 234 der Datei memmgmt.c.

chdk_heap exmem_heap
static

Definiert in Zeile 165 der Datei memmgmt.c.