Changeset 1015


Ignore:
Timestamp:
01/02/11 10:05:19 (2 years ago)
Author:
reyalP
Message:

experimental support for alternate memory allocator, see http://chdk.setepontos.com/index.php?topic=5980.msg59128#msg59128

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/buildconf.inc

    r1000 r1015  
    1212OPT_EDGEOVERLAY=1 
    1313OPT_LUA_STRLIB=1 
    14  
     14# experimental - allocate memory from alternate heap. Default 2MB from EXMEM_RAMDISK 
     15# See exmem_malloc_init in generic/wrappers.c 
     16#OPT_EXMEM_MALLOC=1 
    1517# experimental PTP/USB interface 
    1618#OPT_PTP=1 
  • trunk/core/Makefile

    r1000 r1015  
    6161OPT_OBJS+=ptp.o  
    6262endif  
     63ifdef OPT_EXMEM_MALLOC 
     64#CFLAGS+=-DOPT_EXMEM_MALLOC 
     65OPT_OBJS+=suba.o 
     66endif 
    6367 
    6468OBJS=entry.o nothumb.o main.o gui_draw.o gui_menu.o gui_palette.o gui_mbox.o \ 
  • trunk/core/main.c

    r992 r1015  
    7070    spytask_can_start=0; 
    7171 
     72#ifdef OPT_EXMEM_MALLOC 
     73        exmem_malloc_init(); 
     74#endif 
     75 
    7276#ifdef CAM_CHDK_PTP 
    7377    init_chdk_ptp_task(); 
  • trunk/include/lolevel.h

    r994 r1015  
    289289#endif 
    290290 
    291 #endif 
     291#ifdef OPT_EXMEM_MALLOC 
     292extern void *_exmem_alloc(int pool_id,int size,int unk); 
     293#endif 
     294 
     295#endif 
  • trunk/include/platform.h

    r1007 r1015  
    548548void ExitTask(); 
    549549 
    550 #endif 
     550#ifdef OPT_EXMEM_MALLOC 
     551void exmem_malloc_init(void); 
     552#endif 
     553 
     554#endif 
  • trunk/makefile.inc

    r1008 r1015  
    405405endif 
    406406 
     407ifdef OPT_EXMEM_MALLOC 
     408CFLAGS+=-DOPT_EXMEM_MALLOC 
     409endif 
     410 
    407411ifdef OPT_WARNINGS 
    408412     ifeq ($(GCC_VERSION_MAJOR),3) 
  • trunk/platform/d10/sub/100a/stubs_entry_2.S

    r938 r1015  
    4343// useful for debugging with uart redirect or crash log 
    4444NHSTUB(LogPrintf,0xFF86EF38) 
     45// allocate from given EXMEM pool 
     46NHSTUB(exmem_alloc, 0xFF86C810) 
     47// not needed yet 
     48//NHSTUB(exmem_free, 0xFF86C7B0) 
  • trunk/platform/generic/wrappers.c

    r1010 r1015  
    484484} 
    485485 
     486#ifdef OPT_EXMEM_MALLOC 
     487// I set this up to 16 mb and it still booted... 
     488#define EXMEM_HEAP_SIZE (1024*1024*2) 
     489// these aren't currently needed elsewhere 
     490/* 
     491void * exmem_alloc(unsigned pool_id, unsigned size) 
     492{ 
     493        return _exmem_alloc(pool_id,size,0); 
     494} 
     495 
     496void exmem_free(unsigned pool_id) 
     497{ 
     498        _exmem_free(pool_id); 
     499} 
     500*/ 
     501 
     502static void *exmem_heap; 
     503 
     504void *suba_init(void *heap, unsigned size, unsigned rst, unsigned mincell); 
     505void *suba_alloc(void *heap, unsigned size, unsigned zero); 
     506int suba_free(void *heap, void *p); 
     507 
     508void exmem_malloc_init() { 
     509        // pool zero is EXMEM_RAMDISK on d10 
     510        void *mem = _exmem_alloc(0,EXMEM_HEAP_SIZE,0); 
     511        if(mem) { 
     512                exmem_heap = suba_init(mem,EXMEM_HEAP_SIZE,1,1024); 
     513        } 
     514} 
     515 
     516void *malloc(unsigned size) { 
     517        if(exmem_heap) 
     518                return suba_alloc(exmem_heap,size,0); 
     519        else 
     520                return _malloc(size); 
     521} 
     522void free(void *p) { 
     523        if(exmem_heap) 
     524                suba_free(exmem_heap,p); 
     525        else 
     526                free(p); 
     527} 
     528// regular malloc 
     529#else 
    486530void *malloc(long size) { 
    487531    return _malloc(size); 
     
    491535    return _free(p); 
    492536} 
     537#endif 
    493538 
    494539void *memcpy(void *dest, const void *src, long n) { 
     
    10171062} 
    10181063*/ 
     1064 
Note: See TracChangeset for help on using the changeset viewer.