CHDK_DE Vorschauversion  Trunk Rev. 5653
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
memmgmt.c-Dateireferenz
#include "platform.h"
#include "stdlib.h"
#include "core.h"
#include "conf.h"
#include "gui_draw.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 209 der Datei memmgmt.c.

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

Definiert in Zeile 234 der Datei memmgmt.c.

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

Definiert in Zeile 81 der Datei memmgmt.c.

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

Definiert in Zeile 24 der Datei memmgmt.c.

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

Definiert in Zeile 74 der Datei memmgmt.c.

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

Definiert in Zeile 92 der Datei memmgmt.c.

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

Definiert in Zeile 240 der Datei memmgmt.c.

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

Definiert in Zeile 172 der Datei memmgmt.c.

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

Definiert in Zeile 301 der Datei memmgmt.c.

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

Definiert in Zeile 315 der Datei memmgmt.c.

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

Definiert in Zeile 327 der Datei memmgmt.c.

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

Definiert in Zeile 224 der Datei memmgmt.c.

225 {
226  return chdk_meminfo(&aram_heap, camera_meminfo);
227 }
void GetCombinedMemInfo ( cam_meminfo camera_meminfo)

Definiert in Zeile 257 der Datei memmgmt.c.

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

Definiert in Zeile 193 der Datei memmgmt.c.

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

Definiert in Zeile 286 der Datei memmgmt.c.

287 {
288  extern void *canon_malloc(long size);
289 
290  void *p = chdk_malloc(&aram_heap,size);
291 
292  if (p == 0)
293  p = chdk_malloc(&exmem_heap,size);
294 
295  if (p == 0)
296  p = canon_malloc(size);
297 
298  return p;
299 }
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 200 der Datei memmgmt.c.

int canon_heap_sem

Definiert in Zeile 232 der Datei memmgmt.c.

chdk_heap exmem_heap
static

Definiert in Zeile 163 der Datei memmgmt.c.