In current gc initialization, it is only possible to provide one range for the heap.
|
void gc_init(void *start, void *end) { |
|
// align end pointer on block boundary |
|
end = (void*)((uintptr_t)end & (~(BYTES_PER_BLOCK - 1))); |
|
DEBUG_printf("Initializing GC heap: %p..%p = " UINT_FMT " bytes\n", start, end, (byte*)end - (byte*)start); |
|
|
|
// calculate parameters for GC (T=total, A=alloc table, F=finaliser table, P=pool; all in bytes): |
|
// T = A + F + P |
|
// F = A * BLOCKS_PER_ATB / BLOCKS_PER_FTB |
|
// P = A * BLOCKS_PER_ATB * BYTES_PER_BLOCK |
|
// => T = A * (1 + BLOCKS_PER_ATB / BLOCKS_PER_FTB + BLOCKS_PER_ATB * BYTES_PER_BLOCK) |
|
size_t total_byte_len = (byte*)end - (byte*)start; |
|
#if MICROPY_ENABLE_FINALISER |
|
MP_STATE_MEM(gc_alloc_table_byte_len) = total_byte_len * BITS_PER_BYTE / (BITS_PER_BYTE + BITS_PER_BYTE * BLOCKS_PER_ATB / BLOCKS_PER_FTB + BITS_PER_BYTE * BLOCKS_PER_ATB * BYTES_PER_BLOCK); |
However, all the RAM available on a micro-controller might not be in a contiguous range because there might be different types of RAM: SRAM, SDRAM, SPI-RAM, peripheral-dedicated RAM etc.
In my particular case, there is 4K of RAM that is used by a certain peripheral but only if it's enabled but otherwise, it's free for general-purpose use.
Unfortunately, 4K is too small for (most of) my uses as a heap by itself but if I could append it to my main heap, I wouldn't be letting 4K of RAM go to waste.
What do you think?
In current
gcinitialization, it is only possible to provide one range for the heap.micropython/py/gc.c
Lines 108 to 120 in 12a3fcc
However, all the RAM available on a micro-controller might not be in a contiguous range because there might be different types of RAM: SRAM, SDRAM, SPI-RAM, peripheral-dedicated RAM etc.
In my particular case, there is 4K of RAM that is used by a certain peripheral but only if it's enabled but otherwise, it's free for general-purpose use.
Unfortunately, 4K is too small for (most of) my uses as a heap by itself but if I could append it to my main heap, I wouldn't be letting 4K of RAM go to waste.
What do you think?