1#include "main-header.h"
18static struct mpm MULTI_RAM;
20extern char _Minimum_Stack_Size;
22void sc_fancy_allocator_init();
27 memset(&MULTI_RAM, 0,
sizeof(MULTI_RAM));
28 MULTI_RAM.max_commands =
sizeof(MULTI_RAM.commem) /
sizeof(MULTI_RAM.commem[0]);
29 sc_fancy_allocator_init();
31struct mpm *get_mpm() {
39 if ((MULTI_RAM.dalloc) || (
sizeof(MULTI_RAM.dynbuf) <= bytes)) {
43 return MULTI_RAM.dynbuf;
49 if (mem != MULTI_RAM.dynbuf) {
50 printf(
"inv mem free (%p vs %p)\n", mem, MULTI_RAM.dynbuf);
56int is_stack(
void *adr) {
58 void *mss = &_Minimum_Stack_Size;
60 if ((adr <= es) && (adr >= (
void *)(es - mss))) {
72#define MEMAREA_SIZE 4096
73static uint8_t MEMAREA[MEMAREA_SIZE];
75void *UMM_MALLOC_CFG_HEAP_ADDR;
76uint32_t UMM_MALLOC_CFG_HEAP_SIZE;
78void sc_fancy_allocator_init() {
79 umm_init_heap(&MEMAREA, MEMAREA_SIZE);
81void *sc_realloc(
void *ptr,
size_t size) {
82 return umm_realloc(ptr, size);
85void sc_free(
void *ptr) {
void * mpm_reserve(int bytes)
void multi_mem_init()
called very early on, even before printf works