https://bitbucket.org/hudson/magic-lantern
Raw File
Tip revision: 859b97c84c054ec61e26ec6359c2f2801040faaa authored by g3gg0 on 12 October 2012, 18:03:24 UTC
7D: about page update
Tip revision: 859b97c
exmem.c
#include "dryos.h"

// experimental memory allocation from shooting buffer (~160MB on 5D2)

static struct semaphore * alloc_sem = 0;
static void allocCBR(int a, int b)
{
    MEM(a) = b;
    give_semaphore(alloc_sem);
}

struct memSuite
{
    char* signature; // MemSuite
    int size;
    int num_chunks;
    int first_chunk_maybe;
};

void* shoot_malloc(int size)
{
    if (!alloc_sem) alloc_sem = create_named_semaphore(0,0);
    struct memSuite * hSuite = 0;
    AllocateMemoryResource(size, allocCBR, &hSuite);
    int r = take_semaphore(alloc_sem, 1000);
    if (r) return 0;
    if (hSuite->num_chunks != 1) { beep(); return 0; }
    //~ bmp_hexdump(FONT_SMALL, 0, 100, hSuite, 32*10);
    void* hChunk = (void*) GetFirstChunkFromSuite_maybe(hSuite);
    //~ bmp_hexdump(FONT_SMALL, 0, 300, hChunk, 32*10);
    return (void*) GetMemoryAddressOfMemoryChunk(hChunk);
}
back to top