mm: Remove mm_heap_impl_s struct

it's more simple to make mm_heap_s opaque outside of mm

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I5c8e435f6baba6d22b10c5f7e8d9191104fb5af2
This commit is contained in:
Xiang Xiao
2021-07-03 22:16:25 +08:00
committed by David Sidrane
parent 441b03c61c
commit 76cdd5c329
47 changed files with 271 additions and 308 deletions
+1 -1
View File
@@ -32,7 +32,7 @@
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
struct mm_heap_s g_ccm_heap; FAR struct mm_heap_s *g_ccm_heap;
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
+9 -9
View File
@@ -69,25 +69,25 @@
*/ */
#define ccm_initialize() \ #define ccm_initialize() \
mm_initialize(&g_ccm_heap, "ccm", (FAR void *)CCM_START, CCM_END-CCM_START) g_ccm_heap = mm_initialize("ccm", (FAR void *)CCM_START, CCM_END-CCM_START)
/* The ccm_addregion interface could be used if, for example, you want to /* The ccm_addregion interface could be used if, for example, you want to
* add some other memory region to the CCM heap. I don't really know why * add some other memory region to the CCM heap. I don't really know why
* you might want to do that, but the functionality is essentially free. * you might want to do that, but the functionality is essentially free.
*/ */
#define ccm_addregion(b,s) mm_addregion(&g_ccm_heap, b, s); #define ccm_addregion(b,s) mm_addregion(g_ccm_heap, b, s);
/* Then, once g_ccm_heap has been setup by ccm_initialize(), these memory /* Then, once g_ccm_heap has been setup by ccm_initialize(), these memory
* allocators can be used just like the standard memory allocators. * allocators can be used just like the standard memory allocators.
*/ */
#define ccm_malloc(s) mm_malloc(&g_ccm_heap, s) #define ccm_malloc(s) mm_malloc(g_ccm_heap, s)
#define ccm_zalloc(s) mm_zalloc(&g_ccm_heap, s) #define ccm_zalloc(s) mm_zalloc(g_ccm_heap, s)
#define ccm_calloc(n,s) mm_calloc(&g_ccm_heap, n,s) #define ccm_calloc(n,s) mm_calloc(g_ccm_heap, n,s)
#define ccm_free(p) mm_free(&g_ccm_heap, p) #define ccm_free(p) mm_free(g_ccm_heap, p)
#define ccm_realloc(p,s) mm_realloc(&g_ccm_heap, p, s) #define ccm_realloc(p,s) mm_realloc(g_ccm_heap, p, s)
#define ccm_memalign(a,s) mm_memalign(&g_ccm_heap, a, s) #define ccm_memalign(a,s) mm_memalign(g_ccm_heap, a, s)
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
@@ -107,7 +107,7 @@ extern "C"
#define EXTERN extern #define EXTERN extern
#endif #endif
EXTERN struct mm_heap_s g_ccm_heap; EXTERN FAR struct mm_heap_s *g_ccm_heap;
/**************************************************************************** /****************************************************************************
* Public Function Prototypes * Public Function Prototypes
+1 -1
View File
@@ -32,7 +32,7 @@
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
struct mm_heap_s g_dtcm_heap; FAR struct mm_heap_s *g_dtcm_heap;
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
+9 -9
View File
@@ -69,25 +69,25 @@
*/ */
#define dtcm_initialize() \ #define dtcm_initialize() \
mm_initialize(&g_dtcm_heap, "dtcm", (FAR void *)DTCM_START, DTCM_END-DTCM_START) g_dtcm_heap = mm_initialize("dtcm", (FAR void *)DTCM_START, DTCM_END-DTCM_START)
/* The dtcm_addregion interface could be used if, for example, you want to /* The dtcm_addregion interface could be used if, for example, you want to
* add some other memory region to the DTCM heap. I don't really know why * add some other memory region to the DTCM heap. I don't really know why
* you might want to do that, but the functionality is essentially free. * you might want to do that, but the functionality is essentially free.
*/ */
#define dtcm_addregion(b,s) mm_addregion(&g_dtcm_heap, b, s); #define dtcm_addregion(b,s) mm_addregion(g_dtcm_heap, b, s);
/* Then, once g_dtcm_heap has been setup by dtcm_initialize(), these memory /* Then, once g_dtcm_heap has been setup by dtcm_initialize(), these memory
* allocators can be used just like the standard memory allocators. * allocators can be used just like the standard memory allocators.
*/ */
#define dtcm_malloc(s) mm_malloc(&g_dtcm_heap, s) #define dtcm_malloc(s) mm_malloc(g_dtcm_heap, s)
#define dtcm_zalloc(s) mm_zalloc(&g_dtcm_heap, s) #define dtcm_zalloc(s) mm_zalloc(g_dtcm_heap, s)
#define dtcm_calloc(n,s) mm_calloc(&g_dtcm_heap, n,s) #define dtcm_calloc(n,s) mm_calloc(g_dtcm_heap, n,s)
#define dtcm_free(p) mm_free(&g_dtcm_heap, p) #define dtcm_free(p) mm_free(g_dtcm_heap, p)
#define dtcm_realloc(p,s) mm_realloc(&g_dtcm_heap, p, s) #define dtcm_realloc(p,s) mm_realloc(g_dtcm_heap, p, s)
#define dtcm_memalign(a,s) mm_memalign(&g_dtcm_heap, a, s) #define dtcm_memalign(a,s) mm_memalign(g_dtcm_heap, a, s)
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
@@ -107,7 +107,7 @@ extern "C"
#define EXTERN extern #define EXTERN extern
#endif #endif
EXTERN struct mm_heap_s g_dtcm_heap; EXTERN FAR struct mm_heap_s *g_dtcm_heap;
/**************************************************************************** /****************************************************************************
* Public Function Prototypes * Public Function Prototypes
+1 -1
View File
@@ -40,7 +40,7 @@
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
struct mm_heap_s g_dtcm_heap; FAR struct mm_heap_s *g_dtcm_heap;
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
+9 -9
View File
@@ -61,25 +61,25 @@
*/ */
#define dtcm_initialize() \ #define dtcm_initialize() \
mm_initialize(&g_dtcm_heap, "dtcm", (FAR void *)DTCM_START, DTCM_END-DTCM_START) g_dtcm_heap = mm_initialize("dtcm", (FAR void *)DTCM_START, DTCM_END-DTCM_START)
/* The dtcm_addregion interface could be used if, for example, you want to /* The dtcm_addregion interface could be used if, for example, you want to
* add some other memory region to the DTCM heap. I don't really know why * add some other memory region to the DTCM heap. I don't really know why
* you might want to do that, but the functionality is essentially free. * you might want to do that, but the functionality is essentially free.
*/ */
#define dtcm_addregion(b,s) mm_addregion(&g_dtcm_heap, b, s); #define dtcm_addregion(b,s) mm_addregion(g_dtcm_heap, b, s);
/* Then, once g_dtcm_heap has been setup by dtcm_initialize(), these memory /* Then, once g_dtcm_heap has been setup by dtcm_initialize(), these memory
* allocators can be used just like the standard memory allocators. * allocators can be used just like the standard memory allocators.
*/ */
#define dtcm_malloc(s) mm_malloc(&g_dtcm_heap, s) #define dtcm_malloc(s) mm_malloc(g_dtcm_heap, s)
#define dtcm_zalloc(s) mm_zalloc(&g_dtcm_heap, s) #define dtcm_zalloc(s) mm_zalloc(g_dtcm_heap, s)
#define dtcm_calloc(n,s) mm_calloc(&g_dtcm_heap, n,s) #define dtcm_calloc(n,s) mm_calloc(g_dtcm_heap, n,s)
#define dtcm_free(p) mm_free(&g_dtcm_heap, p) #define dtcm_free(p) mm_free(g_dtcm_heap, p)
#define dtcm_realloc(p,s) mm_realloc(&g_dtcm_heap, p, s) #define dtcm_realloc(p,s) mm_realloc(g_dtcm_heap, p, s)
#define dtcm_memalign(a,s) mm_memalign(&g_dtcm_heap, a, s) #define dtcm_memalign(a,s) mm_memalign(g_dtcm_heap, a, s)
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
@@ -99,7 +99,7 @@ extern "C"
#define EXTERN extern #define EXTERN extern
#endif #endif
EXTERN struct mm_heap_s g_dtcm_heap; EXTERN FAR struct mm_heap_s *g_dtcm_heap;
/**************************************************************************** /****************************************************************************
* Public Function Prototypes * Public Function Prototypes
+10 -10
View File
@@ -34,7 +34,7 @@
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
static struct mm_heap_s g_rtcheap; static FAR struct mm_heap_s *g_rtcheap;
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@@ -62,7 +62,7 @@ void esp32c3_rtcheap_initialize(void)
start = (FAR void *)&_srtcheap; start = (FAR void *)&_srtcheap;
size = (size_t)((uintptr_t)&_ertcheap - (uintptr_t)&_srtcheap); size = (size_t)((uintptr_t)&_ertcheap - (uintptr_t)&_srtcheap);
mm_initialize(&g_rtcheap, "rtcheap", start, size); g_rtcheap = mm_initialize("rtcheap", start, size);
} }
/**************************************************************************** /****************************************************************************
@@ -75,7 +75,7 @@ void esp32c3_rtcheap_initialize(void)
void *esp32c3_rtcheap_malloc(size_t size) void *esp32c3_rtcheap_malloc(size_t size)
{ {
return mm_malloc(&g_rtcheap, size); return mm_malloc(g_rtcheap, size);
} }
/**************************************************************************** /****************************************************************************
@@ -89,7 +89,7 @@ void *esp32c3_rtcheap_malloc(size_t size)
void *esp32c3_rtcheap_calloc(size_t n, size_t elem_size) void *esp32c3_rtcheap_calloc(size_t n, size_t elem_size)
{ {
return mm_calloc(&g_rtcheap, n, elem_size); return mm_calloc(g_rtcheap, n, elem_size);
} }
/**************************************************************************** /****************************************************************************
@@ -102,7 +102,7 @@ void *esp32c3_rtcheap_calloc(size_t n, size_t elem_size)
void *esp32c3_rtcheap_realloc(void *ptr, size_t size) void *esp32c3_rtcheap_realloc(void *ptr, size_t size)
{ {
return mm_realloc(&g_rtcheap, ptr, size); return mm_realloc(g_rtcheap, ptr, size);
} }
/**************************************************************************** /****************************************************************************
@@ -115,7 +115,7 @@ void *esp32c3_rtcheap_realloc(void *ptr, size_t size)
void *esp32c3_rtcheap_zalloc(size_t size) void *esp32c3_rtcheap_zalloc(size_t size)
{ {
return mm_zalloc(&g_rtcheap, size); return mm_zalloc(g_rtcheap, size);
} }
/**************************************************************************** /****************************************************************************
@@ -128,7 +128,7 @@ void *esp32c3_rtcheap_zalloc(size_t size)
void esp32c3_rtcheap_free(FAR void *mem) void esp32c3_rtcheap_free(FAR void *mem)
{ {
mm_free(&g_rtcheap, mem); mm_free(g_rtcheap, mem);
} }
/**************************************************************************** /****************************************************************************
@@ -146,7 +146,7 @@ void esp32c3_rtcheap_free(FAR void *mem)
void *esp32c3_rtcheap_memalign(size_t alignment, size_t size) void *esp32c3_rtcheap_memalign(size_t alignment, size_t size)
{ {
return mm_memalign(&g_rtcheap, alignment, size); return mm_memalign(g_rtcheap, alignment, size);
} }
/**************************************************************************** /****************************************************************************
@@ -165,7 +165,7 @@ void *esp32c3_rtcheap_memalign(size_t alignment, size_t size)
bool esp32c3_rtcheap_heapmember(FAR void *mem) bool esp32c3_rtcheap_heapmember(FAR void *mem)
{ {
return mm_heapmember(&g_rtcheap, mem); return mm_heapmember(g_rtcheap, mem);
} }
/**************************************************************************** /****************************************************************************
@@ -179,5 +179,5 @@ bool esp32c3_rtcheap_heapmember(FAR void *mem)
int esp32c3_rtcheap_mallinfo(FAR struct mallinfo *info) int esp32c3_rtcheap_mallinfo(FAR struct mallinfo *info)
{ {
return mm_mallinfo(&g_rtcheap, info); return mm_mallinfo(g_rtcheap, info);
} }
@@ -2429,16 +2429,9 @@ static int32_t esp_event_post_wrap(esp_event_base_t event_base,
uint32_t esp_get_free_heap_size(void) uint32_t esp_get_free_heap_size(void)
{ {
int ret;
struct mallinfo info; struct mallinfo info;
ret = mm_mallinfo(&g_mmheap, &info); info = kmm_mallinfo();
if (ret)
{
wlerr("ERROR: Failed to create task\n");
return 0;
}
return info.fordblks; return info.fordblks;
} }
+16 -15
View File
@@ -48,7 +48,7 @@ struct mm_delaynode_s
FAR struct mm_delaynode_s *flink; FAR struct mm_delaynode_s *flink;
}; };
struct mm_heap_impl_s struct mm_heap_s
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
struct mm_delaynode_s *mm_delaylist[CONFIG_SMP_NCPUS]; struct mm_delaynode_s *mm_delaylist[CONFIG_SMP_NCPUS];
@@ -75,8 +75,8 @@ static void mm_add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem)
flags = enter_critical_section(); flags = enter_critical_section();
tmp->flink = heap->mm_impl->mm_delaylist[up_cpu_index()]; tmp->flink = heap->mm_delaylist[up_cpu_index()];
heap->mm_impl->mm_delaylist[up_cpu_index()] = tmp; heap->mm_delaylist[up_cpu_index()] = tmp;
leave_critical_section(flags); leave_critical_section(flags);
} }
@@ -93,8 +93,8 @@ static void mm_free_delaylist(FAR struct mm_heap_s *heap)
flags = enter_critical_section(); flags = enter_critical_section();
tmp = heap->mm_impl->mm_delaylist[up_cpu_index()]; tmp = heap->mm_delaylist[up_cpu_index()];
heap->mm_impl->mm_delaylist[up_cpu_index()] = NULL; heap->mm_delaylist[up_cpu_index()] = NULL;
leave_critical_section(flags); leave_critical_section(flags);
@@ -141,23 +141,24 @@ static void mm_free_delaylist(FAR struct mm_heap_s *heap)
* *
****************************************************************************/ ****************************************************************************/
void mm_initialize(FAR struct mm_heap_s *heap, FAR const char *name, FAR struct mm_heap_s *mm_initialize(FAR const char *name,
FAR void *heap_start, size_t heap_size) FAR void *heap_start, size_t heap_size)
{ {
FAR struct mm_heap_impl_s *impl; FAR struct mm_heap_s *heap;
impl = host_memalign(sizeof(FAR void *), sizeof(*impl)); heap = host_memalign(sizeof(FAR void *), sizeof(*heap));
DEBUGASSERT(impl); DEBUGASSERT(heap);
memset(impl, 0, sizeof(struct mm_heap_impl_s)); memset(heap, 0, sizeof(struct mm_heap_s));
heap->mm_impl = impl;
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO) #if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
impl->mm_procfs.name = name; heap->mm_procfs.name = name;
impl->mm_procfs.mallinfo = (FAR void *)mm_mallinfo; heap->mm_procfs.mallinfo = (FAR void *)mm_mallinfo;
impl->mm_procfs.user_data = heap; heap->mm_procfs.user_data = heap;
procfs_register_meminfo(&impl->mm_procfs); procfs_register_meminfo(&heap->mm_procfs);
#endif #endif
return heap;
} }
/**************************************************************************** /****************************************************************************
+10 -10
View File
@@ -41,7 +41,7 @@
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
struct mm_heap_s g_iheap; FAR struct mm_heap_s *g_iheap;
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@@ -62,7 +62,7 @@ void xtensa_imm_initialize(void)
start = (FAR void *)ESP32_IMEM_START; start = (FAR void *)ESP32_IMEM_START;
size = CONFIG_XTENSA_IMEM_REGION_SIZE; size = CONFIG_XTENSA_IMEM_REGION_SIZE;
mm_initialize(&g_iheap, "esp32-imem", start, size); g_iheap = mm_initialize("esp32-imem", start, size);
} }
/**************************************************************************** /****************************************************************************
@@ -75,7 +75,7 @@ void xtensa_imm_initialize(void)
void *xtensa_imm_malloc(size_t size) void *xtensa_imm_malloc(size_t size)
{ {
return mm_malloc(&g_iheap, size); return mm_malloc(g_iheap, size);
} }
/**************************************************************************** /****************************************************************************
@@ -89,7 +89,7 @@ void *xtensa_imm_malloc(size_t size)
void *xtensa_imm_calloc(size_t n, size_t elem_size) void *xtensa_imm_calloc(size_t n, size_t elem_size)
{ {
return mm_calloc(&g_iheap, n, elem_size); return mm_calloc(g_iheap, n, elem_size);
} }
/**************************************************************************** /****************************************************************************
@@ -102,7 +102,7 @@ void *xtensa_imm_calloc(size_t n, size_t elem_size)
void *xtensa_imm_realloc(void *ptr, size_t size) void *xtensa_imm_realloc(void *ptr, size_t size)
{ {
return mm_realloc(&g_iheap, ptr, size); return mm_realloc(g_iheap, ptr, size);
} }
/**************************************************************************** /****************************************************************************
@@ -115,7 +115,7 @@ void *xtensa_imm_realloc(void *ptr, size_t size)
void *xtensa_imm_zalloc(size_t size) void *xtensa_imm_zalloc(size_t size)
{ {
return mm_zalloc(&g_iheap, size); return mm_zalloc(g_iheap, size);
} }
/**************************************************************************** /****************************************************************************
@@ -128,7 +128,7 @@ void *xtensa_imm_zalloc(size_t size)
void xtensa_imm_free(FAR void *mem) void xtensa_imm_free(FAR void *mem)
{ {
mm_free(&g_iheap, mem); mm_free(g_iheap, mem);
} }
/**************************************************************************** /****************************************************************************
@@ -146,7 +146,7 @@ void xtensa_imm_free(FAR void *mem)
void *xtensa_imm_memalign(size_t alignment, size_t size) void *xtensa_imm_memalign(size_t alignment, size_t size)
{ {
return mm_memalign(&g_iheap, alignment, size); return mm_memalign(g_iheap, alignment, size);
} }
/**************************************************************************** /****************************************************************************
@@ -165,7 +165,7 @@ void *xtensa_imm_memalign(size_t alignment, size_t size)
bool xtensa_imm_heapmember(FAR void *mem) bool xtensa_imm_heapmember(FAR void *mem)
{ {
return mm_heapmember(&g_iheap, mem); return mm_heapmember(g_iheap, mem);
} }
/**************************************************************************** /****************************************************************************
@@ -179,7 +179,7 @@ bool xtensa_imm_heapmember(FAR void *mem)
int xtensa_imm_mallinfo(FAR struct mallinfo *info) int xtensa_imm_mallinfo(FAR struct mallinfo *info)
{ {
return mm_mallinfo(&g_iheap, info); return mm_mallinfo(g_iheap, info);
} }
#endif /* CONFIG_XTENSA_IMEM_USE_SEPARATE_HEAP */ #endif /* CONFIG_XTENSA_IMEM_USE_SEPARATE_HEAP */
+10 -10
View File
@@ -34,7 +34,7 @@
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
static struct mm_heap_s g_iramheap; static struct mm_heap_s *g_iramheap;
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@@ -60,7 +60,7 @@ void esp32_iramheap_initialize(void)
start = (void *)&_siramheap; start = (void *)&_siramheap;
size = (size_t)((uintptr_t)&_eiramheap - (uintptr_t)&_siramheap); size = (size_t)((uintptr_t)&_eiramheap - (uintptr_t)&_siramheap);
mm_initialize(&g_iramheap, "iramheap", start, size); g_iramheap = mm_initialize("iramheap", start, size);
} }
/**************************************************************************** /****************************************************************************
@@ -73,7 +73,7 @@ void esp32_iramheap_initialize(void)
void *esp32_iramheap_malloc(size_t size) void *esp32_iramheap_malloc(size_t size)
{ {
return mm_malloc(&g_iramheap, size); return mm_malloc(g_iramheap, size);
} }
/**************************************************************************** /****************************************************************************
@@ -87,7 +87,7 @@ void *esp32_iramheap_malloc(size_t size)
void *esp32_iramheap_calloc(size_t n, size_t elem_size) void *esp32_iramheap_calloc(size_t n, size_t elem_size)
{ {
return mm_calloc(&g_iramheap, n, elem_size); return mm_calloc(g_iramheap, n, elem_size);
} }
/**************************************************************************** /****************************************************************************
@@ -100,7 +100,7 @@ void *esp32_iramheap_calloc(size_t n, size_t elem_size)
void *esp32_iramheap_realloc(void *ptr, size_t size) void *esp32_iramheap_realloc(void *ptr, size_t size)
{ {
return mm_realloc(&g_iramheap, ptr, size); return mm_realloc(g_iramheap, ptr, size);
} }
/**************************************************************************** /****************************************************************************
@@ -113,7 +113,7 @@ void *esp32_iramheap_realloc(void *ptr, size_t size)
void *esp32_iramheap_zalloc(size_t size) void *esp32_iramheap_zalloc(size_t size)
{ {
return mm_zalloc(&g_iramheap, size); return mm_zalloc(g_iramheap, size);
} }
/**************************************************************************** /****************************************************************************
@@ -126,7 +126,7 @@ void *esp32_iramheap_zalloc(size_t size)
void esp32_iramheap_free(void *mem) void esp32_iramheap_free(void *mem)
{ {
mm_free(&g_iramheap, mem); mm_free(g_iramheap, mem);
} }
/**************************************************************************** /****************************************************************************
@@ -144,7 +144,7 @@ void esp32_iramheap_free(void *mem)
void *esp32_iramheap_memalign(size_t alignment, size_t size) void *esp32_iramheap_memalign(size_t alignment, size_t size)
{ {
return mm_memalign(&g_iramheap, alignment, size); return mm_memalign(g_iramheap, alignment, size);
} }
/**************************************************************************** /****************************************************************************
@@ -163,7 +163,7 @@ void *esp32_iramheap_memalign(size_t alignment, size_t size)
bool esp32_iramheap_heapmember(void *mem) bool esp32_iramheap_heapmember(void *mem)
{ {
return mm_heapmember(&g_iramheap, mem); return mm_heapmember(g_iramheap, mem);
} }
/**************************************************************************** /****************************************************************************
@@ -177,5 +177,5 @@ bool esp32_iramheap_heapmember(void *mem)
int esp32_iramheap_mallinfo(struct mallinfo *info) int esp32_iramheap_mallinfo(struct mallinfo *info)
{ {
return mm_mallinfo(&g_iramheap, info); return mm_mallinfo(g_iramheap, info);
} }
+10 -10
View File
@@ -34,7 +34,7 @@
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
static struct mm_heap_s g_rtcheap; static struct mm_heap_s *g_rtcheap;
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@@ -60,7 +60,7 @@ void esp32_rtcheap_initialize(void)
start = (void *)&_srtcheap; start = (void *)&_srtcheap;
size = (size_t)((uintptr_t)&_ertcheap - (uintptr_t)&_srtcheap); size = (size_t)((uintptr_t)&_ertcheap - (uintptr_t)&_srtcheap);
mm_initialize(&g_rtcheap, "rtcheap", start, size); g_rtcheap = mm_initialize("rtcheap", start, size);
} }
/**************************************************************************** /****************************************************************************
@@ -76,7 +76,7 @@ void esp32_rtcheap_initialize(void)
void *esp32_rtcheap_malloc(size_t size) void *esp32_rtcheap_malloc(size_t size)
{ {
return mm_malloc(&g_rtcheap, size); return mm_malloc(g_rtcheap, size);
} }
/**************************************************************************** /****************************************************************************
@@ -90,7 +90,7 @@ void *esp32_rtcheap_malloc(size_t size)
void *esp32_rtcheap_calloc(size_t n, size_t elem_size) void *esp32_rtcheap_calloc(size_t n, size_t elem_size)
{ {
return mm_calloc(&g_rtcheap, n, elem_size); return mm_calloc(g_rtcheap, n, elem_size);
} }
/**************************************************************************** /****************************************************************************
@@ -103,7 +103,7 @@ void *esp32_rtcheap_calloc(size_t n, size_t elem_size)
void *esp32_rtcheap_realloc(void *ptr, size_t size) void *esp32_rtcheap_realloc(void *ptr, size_t size)
{ {
return mm_realloc(&g_rtcheap, ptr, size); return mm_realloc(g_rtcheap, ptr, size);
} }
/**************************************************************************** /****************************************************************************
@@ -116,7 +116,7 @@ void *esp32_rtcheap_realloc(void *ptr, size_t size)
void *esp32_rtcheap_zalloc(size_t size) void *esp32_rtcheap_zalloc(size_t size)
{ {
return mm_zalloc(&g_rtcheap, size); return mm_zalloc(g_rtcheap, size);
} }
/**************************************************************************** /****************************************************************************
@@ -129,7 +129,7 @@ void *esp32_rtcheap_zalloc(size_t size)
void esp32_rtcheap_free(void *mem) void esp32_rtcheap_free(void *mem)
{ {
mm_free(&g_rtcheap, mem); mm_free(g_rtcheap, mem);
} }
/**************************************************************************** /****************************************************************************
@@ -151,7 +151,7 @@ void esp32_rtcheap_free(void *mem)
void *esp32_rtcheap_memalign(size_t alignment, size_t size) void *esp32_rtcheap_memalign(size_t alignment, size_t size)
{ {
return mm_memalign(&g_rtcheap, alignment, size); return mm_memalign(g_rtcheap, alignment, size);
} }
/**************************************************************************** /****************************************************************************
@@ -170,7 +170,7 @@ void *esp32_rtcheap_memalign(size_t alignment, size_t size)
bool esp32_rtcheap_heapmember(void *mem) bool esp32_rtcheap_heapmember(void *mem)
{ {
return mm_heapmember(&g_rtcheap, mem); return mm_heapmember(g_rtcheap, mem);
} }
/**************************************************************************** /****************************************************************************
@@ -187,5 +187,5 @@ bool esp32_rtcheap_heapmember(void *mem)
int esp32_rtcheap_mallinfo(struct mallinfo *info) int esp32_rtcheap_mallinfo(struct mallinfo *info)
{ {
return mm_mallinfo(&g_rtcheap, info); return mm_mallinfo(g_rtcheap, info);
} }
+1 -8
View File
@@ -2310,16 +2310,9 @@ int32_t esp_event_post(esp_event_base_t event_base,
uint32_t esp_get_free_heap_size(void) uint32_t esp_get_free_heap_size(void)
{ {
int ret;
struct mallinfo info; struct mallinfo info;
ret = mm_mallinfo(&g_mmheap, &info); info = kmm_mallinfo();
if (ret)
{
wlerr("Failed to create task\n");
return 0;
}
return info.fordblks; return info.fordblks;
} }
+1 -1
View File
@@ -250,7 +250,7 @@ typedef CODE void (*addrenv_sigtramp_t)(_sa_sigaction_t sighand, int signo,
struct addrenv_reserve_s struct addrenv_reserve_s
{ {
addrenv_sigtramp_t ar_sigtramp; /* Signal trampoline */ addrenv_sigtramp_t ar_sigtramp; /* Signal trampoline */
struct mm_heap_s ar_usrheap; /* User space heap structure */ struct mm_heap_s *ar_usrheap; /* User space heap structure */
}; };
/* Each instance of this structure resides at the beginning of the user- /* Each instance of this structure resides at the beginning of the user-
+4 -10
View File
@@ -96,13 +96,7 @@
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/
struct mm_heap_impl_s; /* Forward reference */ struct mm_heap_s; /* Forward reference */
struct mm_heap_s
{
struct mm_heap_impl_s *mm_impl;
};
#define MM_IS_VALID(heap) ((heap) != NULL && (heap)->mm_impl != NULL)
/**************************************************************************** /****************************************************************************
* Public Data * Public Data
@@ -143,13 +137,13 @@ extern "C"
#if defined(CONFIG_BUILD_FLAT) || !defined(__KERNEL__) #if defined(CONFIG_BUILD_FLAT) || !defined(__KERNEL__)
/* Otherwise, the user heap data structures are in common .bss */ /* Otherwise, the user heap data structures are in common .bss */
EXTERN struct mm_heap_s g_mmheap; EXTERN FAR struct mm_heap_s *g_mmheap;
#endif #endif
#ifdef CONFIG_MM_KERNEL_HEAP #ifdef CONFIG_MM_KERNEL_HEAP
/* This is the kernel heap */ /* This is the kernel heap */
EXTERN struct mm_heap_s g_kmmheap; EXTERN FAR struct mm_heap_s *g_kmmheap;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -158,7 +152,7 @@ EXTERN struct mm_heap_s g_kmmheap;
/* Functions contained in mm_initialize.c ***********************************/ /* Functions contained in mm_initialize.c ***********************************/
void mm_initialize(FAR struct mm_heap_s *heap, FAR const char *name, FAR struct mm_heap_s *mm_initialize(FAR const char *name,
FAR void *heap_start, size_t heap_size); FAR void *heap_start, size_t heap_size);
void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart, void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
size_t heapsize); size_t heapsize);
+1 -1
View File
@@ -98,7 +98,7 @@ struct userspace_s
/* Memory manager heap structure */ /* Memory manager heap structure */
FAR struct mm_heap_s *us_heap; FAR struct mm_heap_s **us_heap;
/* Task startup routine */ /* Task startup routine */
+2 -2
View File
@@ -45,11 +45,11 @@ This directory contains the NuttX memory management logic. This include:
in memory: in memory:
include <nuttx/mm/mm.h> include <nuttx/mm/mm.h>
static struct mm_heap_s g_myheap; static struct mm_heap_s *g_myheap;
Then initialize the heap using: Then initialize the heap using:
mm_initialize(&g_myheap, myheap_start, myheap_size); g_myheap = mm_initialize(myheap_start, myheap_size);
Where mm_initialize() and all related interfaces are prototyped in the Where mm_initialize() and all related interfaces are prototyped in the
header file include/nuttx/mm/mm.h. header file include/nuttx/mm/mm.h.
+1 -1
View File
@@ -49,7 +49,7 @@
void kmm_addregion(FAR void *heap_start, size_t heap_size) void kmm_addregion(FAR void *heap_start, size_t heap_size)
{ {
return mm_addregion(&g_kmmheap, heap_start, heap_size); mm_addregion(g_kmmheap, heap_start, heap_size);
} }
#endif /* CONFIG_MM_KERNEL_HEAP */ #endif /* CONFIG_MM_KERNEL_HEAP */
+1 -1
View File
@@ -44,7 +44,7 @@
FAR void *kmm_brkaddr(int region) FAR void *kmm_brkaddr(int region)
{ {
return mm_brkaddr(&g_kmmheap, region); return mm_brkaddr(g_kmmheap, region);
} }
#endif /* CONFIG_MM_KERNEL_HEAP */ #endif /* CONFIG_MM_KERNEL_HEAP */
+1 -1
View File
@@ -42,7 +42,7 @@
FAR void *kmm_calloc(size_t n, size_t elem_size) FAR void *kmm_calloc(size_t n, size_t elem_size)
{ {
return mm_calloc(&g_kmmheap, n, elem_size); return mm_calloc(g_kmmheap, n, elem_size);
} }
#endif /* CONFIG_MM_KERNEL_HEAP */ #endif /* CONFIG_MM_KERNEL_HEAP */
+1 -1
View File
@@ -42,7 +42,7 @@
void kmm_checkcorruption(void) void kmm_checkcorruption(void)
{ {
mm_checkcorruption(&g_kmmheap); mm_checkcorruption(g_kmmheap);
} }
#endif /* CONFIG_MM_KERNEL_HEAP */ #endif /* CONFIG_MM_KERNEL_HEAP */
+1 -1
View File
@@ -43,7 +43,7 @@
void kmm_extend(FAR void *mem, size_t size, int region) void kmm_extend(FAR void *mem, size_t size, int region)
{ {
mm_extend(&g_kmmheap, mem, size, region); mm_extend(g_kmmheap, mem, size, region);
} }
#endif /* CONFIG_MM_KERNEL_HEAP */ #endif /* CONFIG_MM_KERNEL_HEAP */
+1 -1
View File
@@ -53,7 +53,7 @@
void kmm_free(FAR void *mem) void kmm_free(FAR void *mem)
{ {
DEBUGASSERT(kmm_heapmember(mem)); DEBUGASSERT(kmm_heapmember(mem));
mm_free(&g_kmmheap, mem); mm_free(g_kmmheap, mem);
} }
#endif /* CONFIG_MM_KERNEL_HEAP */ #endif /* CONFIG_MM_KERNEL_HEAP */
+1 -1
View File
@@ -52,7 +52,7 @@
bool kmm_heapmember(FAR void *mem) bool kmm_heapmember(FAR void *mem)
{ {
return mm_heapmember(&g_kmmheap, mem); return mm_heapmember(g_kmmheap, mem);
} }
#endif /* CONFIG_MM_KERNEL_HEAP */ #endif /* CONFIG_MM_KERNEL_HEAP */
+2 -2
View File
@@ -34,7 +34,7 @@
/* This is the kernel heap */ /* This is the kernel heap */
struct mm_heap_s g_kmmheap; FAR struct mm_heap_s *g_kmmheap;
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@@ -58,7 +58,7 @@ struct mm_heap_s g_kmmheap;
void kmm_initialize(FAR void *heap_start, size_t heap_size) void kmm_initialize(FAR void *heap_start, size_t heap_size)
{ {
mm_initialize(&g_kmmheap, "Kmem", heap_start, heap_size); g_kmmheap = mm_initialize("Kmem", heap_start, heap_size);
} }
#endif /* CONFIG_MM_KERNEL_HEAP */ #endif /* CONFIG_MM_KERNEL_HEAP */
+1 -1
View File
@@ -46,7 +46,7 @@
struct mallinfo kmm_mallinfo(void) struct mallinfo kmm_mallinfo(void)
{ {
struct mallinfo info; struct mallinfo info;
mm_mallinfo(&g_kmmheap, &info); mm_mallinfo(g_kmmheap, &info);
return info; return info;
} }
+1 -1
View File
@@ -48,7 +48,7 @@
FAR void *kmm_malloc(size_t size) FAR void *kmm_malloc(size_t size)
{ {
return mm_malloc(&g_kmmheap, size); return mm_malloc(g_kmmheap, size);
} }
#endif /* CONFIG_MM_KERNEL_HEAP */ #endif /* CONFIG_MM_KERNEL_HEAP */
+1 -1
View File
@@ -51,7 +51,7 @@
FAR void *kmm_memalign(size_t alignment, size_t size) FAR void *kmm_memalign(size_t alignment, size_t size)
{ {
return mm_memalign(&g_kmmheap, alignment, size); return mm_memalign(g_kmmheap, alignment, size);
} }
#endif /* CONFIG_MM_KERNEL_HEAP */ #endif /* CONFIG_MM_KERNEL_HEAP */
+1 -1
View File
@@ -49,7 +49,7 @@
FAR void *kmm_realloc(FAR void *oldmem, size_t newsize) FAR void *kmm_realloc(FAR void *oldmem, size_t newsize)
{ {
return mm_realloc(&g_kmmheap, oldmem, newsize); return mm_realloc(g_kmmheap, oldmem, newsize);
} }
#endif /* CONFIG_MM_KERNEL_HEAP */ #endif /* CONFIG_MM_KERNEL_HEAP */
+1 -1
View File
@@ -48,7 +48,7 @@
FAR void *kmm_zalloc(size_t size) FAR void *kmm_zalloc(size_t size)
{ {
return mm_zalloc(&g_kmmheap, size); return mm_zalloc(g_kmmheap, size);
} }
#endif /* CONFIG_MM_KERNEL_HEAP */ #endif /* CONFIG_MM_KERNEL_HEAP */
+1 -3
View File
@@ -113,8 +113,6 @@
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/
struct mm_heap_s;
/* Determines the size of the chunk size/offset type */ /* Determines the size of the chunk size/offset type */
#ifdef CONFIG_MM_SMALL #ifdef CONFIG_MM_SMALL
@@ -172,7 +170,7 @@ struct mm_delaynode_s
/* This describes one heap (possibly with multiple regions) */ /* This describes one heap (possibly with multiple regions) */
struct mm_heap_impl_s struct mm_heap_s
{ {
/* Mutually exclusive access to this data set is enforced with /* Mutually exclusive access to this data set is enforced with
* the following un-named semaphore. * the following un-named semaphore.
+2 -6
View File
@@ -46,25 +46,21 @@
void mm_addfreechunk(FAR struct mm_heap_s *heap, void mm_addfreechunk(FAR struct mm_heap_s *heap,
FAR struct mm_freenode_s *node) FAR struct mm_freenode_s *node)
{ {
FAR struct mm_heap_impl_s *heap_impl;
FAR struct mm_freenode_s *next; FAR struct mm_freenode_s *next;
FAR struct mm_freenode_s *prev; FAR struct mm_freenode_s *prev;
int ndx; int ndx;
DEBUGASSERT(MM_IS_VALID(heap));
DEBUGASSERT(node->size >= SIZEOF_MM_FREENODE); DEBUGASSERT(node->size >= SIZEOF_MM_FREENODE);
DEBUGASSERT((node->preceding & MM_ALLOC_BIT) == 0); DEBUGASSERT((node->preceding & MM_ALLOC_BIT) == 0);
heap_impl = heap->mm_impl;
/* Convert the size to a nodelist index */ /* Convert the size to a nodelist index */
ndx = mm_size2ndx(node->size); ndx = mm_size2ndx(node->size);
/* Now put the new node into the next */ /* Now put the new node into the next */
for (prev = &heap_impl->mm_nodelist[ndx], for (prev = &heap->mm_nodelist[ndx],
next = heap_impl->mm_nodelist[ndx].flink; next = heap->mm_nodelist[ndx].flink;
next && next->size && next->size < node->size; next && next->size && next->size < node->size;
prev = next, next = next->flink); prev = next, next = next->flink);
+2 -6
View File
@@ -45,18 +45,14 @@
FAR void *mm_brkaddr(FAR struct mm_heap_s *heap, int region) FAR void *mm_brkaddr(FAR struct mm_heap_s *heap, int region)
{ {
FAR struct mm_heap_impl_s *heap_impl;
uintptr_t brkaddr; uintptr_t brkaddr;
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
#if CONFIG_MM_REGIONS > 1 #if CONFIG_MM_REGIONS > 1
DEBUGASSERT(heap && region < heap_impl->mm_nregions); DEBUGASSERT(heap && region < heap->mm_nregions);
#else #else
DEBUGASSERT(heap && region == 0); DEBUGASSERT(heap && region == 0);
#endif #endif
brkaddr = (uintptr_t)heap_impl->mm_heapend[region]; brkaddr = (uintptr_t)heap->mm_heapend[region];
return brkaddr ? (FAR void *)(brkaddr + SIZEOF_MM_ALLOCNODE) : 0; return brkaddr ? (FAR void *)(brkaddr + SIZEOF_MM_ALLOCNODE) : 0;
} }
+4 -8
View File
@@ -47,13 +47,9 @@
void mm_checkcorruption(FAR struct mm_heap_s *heap) void mm_checkcorruption(FAR struct mm_heap_s *heap)
{ {
FAR struct mm_heap_impl_s *heap_impl;
FAR struct mm_allocnode_s *node; FAR struct mm_allocnode_s *node;
FAR struct mm_allocnode_s *prev; FAR struct mm_allocnode_s *prev;
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
#if CONFIG_MM_REGIONS > 1 #if CONFIG_MM_REGIONS > 1
int region; int region;
#else #else
@@ -63,7 +59,7 @@ void mm_checkcorruption(FAR struct mm_heap_s *heap)
/* Visit each region */ /* Visit each region */
#if CONFIG_MM_REGIONS > 1 #if CONFIG_MM_REGIONS > 1
for (region = 0; region < heap_impl->mm_nregions; region++) for (region = 0; region < heap->mm_nregions; region++)
#endif #endif
{ {
prev = NULL; prev = NULL;
@@ -88,8 +84,8 @@ void mm_checkcorruption(FAR struct mm_heap_s *heap)
mm_takesemaphore(heap); mm_takesemaphore(heap);
} }
for (node = heap_impl->mm_heapstart[region]; for (node = heap->mm_heapstart[region];
node < heap_impl->mm_heapend[region]; node < heap->mm_heapend[region];
node = (FAR struct mm_allocnode_s *) node = (FAR struct mm_allocnode_s *)
((FAR char *)node + node->size)) ((FAR char *)node + node->size))
{ {
@@ -116,7 +112,7 @@ void mm_checkcorruption(FAR struct mm_heap_s *heap)
prev = node; prev = node;
} }
assert(node == heap_impl->mm_heapend[region]); assert(node == heap->mm_heapend[region]);
mm_givesemaphore(heap); mm_givesemaphore(heap);
} }
+3 -7
View File
@@ -52,21 +52,17 @@
void mm_extend(FAR struct mm_heap_s *heap, FAR void *mem, size_t size, void mm_extend(FAR struct mm_heap_s *heap, FAR void *mem, size_t size,
int region) int region)
{ {
FAR struct mm_heap_impl_s *heap_impl;
FAR struct mm_allocnode_s *oldnode; FAR struct mm_allocnode_s *oldnode;
FAR struct mm_allocnode_s *newnode; FAR struct mm_allocnode_s *newnode;
uintptr_t blockstart; uintptr_t blockstart;
uintptr_t blockend; uintptr_t blockend;
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
/* Make sure that we were passed valid parameters */ /* Make sure that we were passed valid parameters */
DEBUGASSERT(heap && mem); DEBUGASSERT(heap && mem);
#if CONFIG_MM_REGIONS > 1 #if CONFIG_MM_REGIONS > 1
DEBUGASSERT(size >= MIN_EXTEND && DEBUGASSERT(size >= MIN_EXTEND &&
(size_t)region < (size_t)heap_impl->mm_nregions); (size_t)region < (size_t)heap->mm_nregions);
#else #else
DEBUGASSERT(size >= MIN_EXTEND && region == 0); DEBUGASSERT(size >= MIN_EXTEND && region == 0);
#endif #endif
@@ -87,7 +83,7 @@ void mm_extend(FAR struct mm_heap_s *heap, FAR void *mem, size_t size,
* immediately follow this node. * immediately follow this node.
*/ */
oldnode = heap_impl->mm_heapend[region]; oldnode = heap->mm_heapend[region];
DEBUGASSERT((uintptr_t)oldnode + SIZEOF_MM_ALLOCNODE == (uintptr_t)mem); DEBUGASSERT((uintptr_t)oldnode + SIZEOF_MM_ALLOCNODE == (uintptr_t)mem);
/* The size of the old node now extends to the new terminal node. /* The size of the old node now extends to the new terminal node.
@@ -109,7 +105,7 @@ void mm_extend(FAR struct mm_heap_s *heap, FAR void *mem, size_t size,
newnode->size = SIZEOF_MM_ALLOCNODE; newnode->size = SIZEOF_MM_ALLOCNODE;
newnode->preceding = oldnode->size | MM_ALLOC_BIT; newnode->preceding = oldnode->size | MM_ALLOC_BIT;
heap_impl->mm_heapend[region] = newnode; heap->mm_heapend[region] = newnode;
mm_givesemaphore(heap); mm_givesemaphore(heap);
/* Finally "free" the new block of memory where the old terminal node was /* Finally "free" the new block of memory where the old terminal node was
+2 -6
View File
@@ -39,19 +39,15 @@
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) #if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
static void mm_add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem) static void mm_add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem)
{ {
FAR struct mm_heap_impl_s *heap_impl;
FAR struct mm_delaynode_s *tmp = mem; FAR struct mm_delaynode_s *tmp = mem;
irqstate_t flags; irqstate_t flags;
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
/* Delay the deallocation until a more appropriate time. */ /* Delay the deallocation until a more appropriate time. */
flags = enter_critical_section(); flags = enter_critical_section();
tmp->flink = heap_impl->mm_delaylist[up_cpu_index()]; tmp->flink = heap->mm_delaylist[up_cpu_index()];
heap_impl->mm_delaylist[up_cpu_index()] = tmp; heap->mm_delaylist[up_cpu_index()] = tmp;
leave_critical_section(flags); leave_critical_section(flags);
} }
+5 -10
View File
@@ -54,11 +54,6 @@
bool mm_heapmember(FAR struct mm_heap_s *heap, FAR void *mem) bool mm_heapmember(FAR struct mm_heap_s *heap, FAR void *mem)
{ {
FAR struct mm_heap_impl_s *heap_impl;
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
#if CONFIG_MM_REGIONS > 1 #if CONFIG_MM_REGIONS > 1
int i; int i;
@@ -66,10 +61,10 @@ bool mm_heapmember(FAR struct mm_heap_s *heap, FAR void *mem)
* between the region's two guard nodes. * between the region's two guard nodes.
*/ */
for (i = 0; i < heap_impl->mm_nregions; i++) for (i = 0; i < heap->mm_nregions; i++)
{ {
if (mem > (FAR void *)heap_impl->mm_heapstart[i] && if (mem > (FAR void *)heap->mm_heapstart[i] &&
mem < (FAR void *)heap_impl->mm_heapend[i]) mem < (FAR void *)heap->mm_heapend[i])
{ {
return true; return true;
} }
@@ -84,8 +79,8 @@ bool mm_heapmember(FAR struct mm_heap_s *heap, FAR void *mem)
* two guard nodes. * two guard nodes.
*/ */
if (mem > (FAR void *)heap_impl->mm_heapstart[0] && if (mem > (FAR void *)heap->mm_heapstart[0] &&
mem < (FAR void *)heap_impl->mm_heapend[0]) mem < (FAR void *)heap->mm_heapend[0])
{ {
return true; return true;
} }
+27 -31
View File
@@ -57,16 +57,13 @@
void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart, void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
size_t heapsize) size_t heapsize)
{ {
FAR struct mm_heap_impl_s *heap_impl;
FAR struct mm_freenode_s *node; FAR struct mm_freenode_s *node;
uintptr_t heapbase; uintptr_t heapbase;
uintptr_t heapend; uintptr_t heapend;
#if CONFIG_MM_REGIONS > 1 #if CONFIG_MM_REGIONS > 1
int IDX; int IDX;
DEBUGASSERT(MM_IS_VALID(heap)); IDX = heap->mm_nregions;
heap_impl = heap->mm_impl;
IDX = heap_impl->mm_nregions;
/* Writing past CONFIG_MM_REGIONS would have catastrophic consequences */ /* Writing past CONFIG_MM_REGIONS would have catastrophic consequences */
@@ -78,9 +75,6 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
#else #else
# define IDX 0 # define IDX 0
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
#endif #endif
#if defined(CONFIG_MM_SMALL) && !defined(CONFIG_SMALL_MEMORY) #if defined(CONFIG_MM_SMALL) && !defined(CONFIG_SMALL_MEMORY)
@@ -106,7 +100,7 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
/* Add the size of this region to the total size of the heap */ /* Add the size of this region to the total size of the heap */
heap_impl->mm_heapsize += heapsize; heap->mm_heapsize += heapsize;
/* Create two "allocated" guard nodes at the beginning and end of /* Create two "allocated" guard nodes at the beginning and end of
* the heap. These only serve to keep us from allocating outside * the heap. These only serve to keep us from allocating outside
@@ -116,23 +110,23 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
* all available memory. * all available memory.
*/ */
heap_impl->mm_heapstart[IDX] = (FAR struct mm_allocnode_s *) heap->mm_heapstart[IDX] = (FAR struct mm_allocnode_s *)
heapbase; heapbase;
heap_impl->mm_heapstart[IDX]->size = SIZEOF_MM_ALLOCNODE; heap->mm_heapstart[IDX]->size = SIZEOF_MM_ALLOCNODE;
heap_impl->mm_heapstart[IDX]->preceding = MM_ALLOC_BIT; heap->mm_heapstart[IDX]->preceding = MM_ALLOC_BIT;
node = (FAR struct mm_freenode_s *) node = (FAR struct mm_freenode_s *)
(heapbase + SIZEOF_MM_ALLOCNODE); (heapbase + SIZEOF_MM_ALLOCNODE);
node->size = heapsize - 2*SIZEOF_MM_ALLOCNODE; node->size = heapsize - 2*SIZEOF_MM_ALLOCNODE;
node->preceding = SIZEOF_MM_ALLOCNODE; node->preceding = SIZEOF_MM_ALLOCNODE;
heap_impl->mm_heapend[IDX] = (FAR struct mm_allocnode_s *) heap->mm_heapend[IDX] = (FAR struct mm_allocnode_s *)
(heapend - SIZEOF_MM_ALLOCNODE); (heapend - SIZEOF_MM_ALLOCNODE);
heap_impl->mm_heapend[IDX]->size = SIZEOF_MM_ALLOCNODE; heap->mm_heapend[IDX]->size = SIZEOF_MM_ALLOCNODE;
heap_impl->mm_heapend[IDX]->preceding = node->size | MM_ALLOC_BIT; heap->mm_heapend[IDX]->preceding = node->size | MM_ALLOC_BIT;
#undef IDX #undef IDX
#if CONFIG_MM_REGIONS > 1 #if CONFIG_MM_REGIONS > 1
heap_impl->mm_nregions++; heap->mm_nregions++;
#endif #endif
/* Add the single, large free node to the nodelist */ /* Add the single, large free node to the nodelist */
@@ -150,21 +144,22 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
* heap region. * heap region.
* *
* Input Parameters: * Input Parameters:
* name - The heap procfs name
* heap - The selected heap * heap - The selected heap
* heapstart - Start of the initial heap region * heapstart - Start of the initial heap region
* heapsize - Size of the initial heap region * heapsize - Size of the initial heap region
* *
* Returned Value: * Returned Value:
* None * Return the address of a new heap instance.
* *
* Assumptions: * Assumptions:
* *
****************************************************************************/ ****************************************************************************/
void mm_initialize(FAR struct mm_heap_s *heap, FAR const char *name, FAR struct mm_heap_s *mm_initialize(FAR const char *name,
FAR void *heapstart, size_t heapsize) FAR void *heapstart, size_t heapsize)
{ {
FAR struct mm_heap_impl_s *heap_impl; FAR struct mm_heap_s *heap;
uintptr_t heap_adj; uintptr_t heap_adj;
int i; int i;
@@ -175,13 +170,12 @@ void mm_initialize(FAR struct mm_heap_s *heap, FAR const char *name,
heap_adj = MM_ALIGN_UP((uintptr_t)heapstart); heap_adj = MM_ALIGN_UP((uintptr_t)heapstart);
heapsize -= heap_adj - (uintptr_t)heapstart; heapsize -= heap_adj - (uintptr_t)heapstart;
/* Reserve a block space for mm_heap_impl_s context */ /* Reserve a block space for mm_heap_s context */
DEBUGASSERT(heapsize > sizeof(struct mm_heap_impl_s)); DEBUGASSERT(heapsize > sizeof(struct mm_heap_s));
heap->mm_impl = (FAR struct mm_heap_impl_s *)heap_adj; heap = (FAR struct mm_heap_s *)heap_adj;
heap_impl = heap->mm_impl; heapsize -= sizeof(struct mm_heap_s);
heapsize -= sizeof(struct mm_heap_impl_s); heapstart = (FAR char *)heap_adj + sizeof(struct mm_heap_s);
heapstart = (FAR char *)heap_adj + sizeof(struct mm_heap_impl_s);
/* The following two lines have cause problems for some older ZiLog /* The following two lines have cause problems for some older ZiLog
* compilers in the past (but not the more recent). Life is easier if we * compilers in the past (but not the more recent). Life is easier if we
@@ -197,14 +191,14 @@ void mm_initialize(FAR struct mm_heap_s *heap, FAR const char *name,
/* Set up global variables */ /* Set up global variables */
memset(heap_impl, 0, sizeof(struct mm_heap_impl_s)); memset(heap, 0, sizeof(struct mm_heap_s));
/* Initialize the node array */ /* Initialize the node array */
for (i = 1; i < MM_NNODES; i++) for (i = 1; i < MM_NNODES; i++)
{ {
heap_impl->mm_nodelist[i - 1].flink = &heap_impl->mm_nodelist[i]; heap->mm_nodelist[i - 1].flink = &heap->mm_nodelist[i];
heap_impl->mm_nodelist[i].blink = &heap_impl->mm_nodelist[i - 1]; heap->mm_nodelist[i].blink = &heap->mm_nodelist[i - 1];
} }
/* Initialize the malloc semaphore to one (to support one-at- /* Initialize the malloc semaphore to one (to support one-at-
@@ -219,10 +213,12 @@ void mm_initialize(FAR struct mm_heap_s *heap, FAR const char *name,
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO) #if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) #if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
heap_impl->mm_procfs.name = name; heap->mm_procfs.name = name;
heap_impl->mm_procfs.mallinfo = (FAR void *)mm_mallinfo; heap->mm_procfs.mallinfo = (FAR void *)mm_mallinfo;
heap_impl->mm_procfs.user_data = heap; heap->mm_procfs.user_data = heap;
procfs_register_meminfo(&heap_impl->mm_procfs); procfs_register_meminfo(&heap->mm_procfs);
#endif #endif
#endif #endif
return heap;
} }
+7 -10
View File
@@ -46,7 +46,6 @@
int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info) int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
{ {
FAR struct mm_heap_impl_s *heap_impl;
FAR struct mm_allocnode_s *node; FAR struct mm_allocnode_s *node;
FAR struct mm_allocnode_s *prev; FAR struct mm_allocnode_s *prev;
size_t mxordblk = 0; size_t mxordblk = 0;
@@ -61,13 +60,11 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
#endif #endif
DEBUGASSERT(info); DEBUGASSERT(info);
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
/* Visit each region */ /* Visit each region */
#if CONFIG_MM_REGIONS > 1 #if CONFIG_MM_REGIONS > 1
for (region = 0; region < heap_impl->mm_nregions; region++) for (region = 0; region < heap->mm_nregions; region++)
#endif #endif
{ {
prev = NULL; prev = NULL;
@@ -78,8 +75,8 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
mm_takesemaphore(heap); mm_takesemaphore(heap);
for (node = heap_impl->mm_heapstart[region]; for (node = heap->mm_heapstart[region];
node < heap_impl->mm_heapend[region]; node < heap->mm_heapend[region];
node = (FAR struct mm_allocnode_s *) node = (FAR struct mm_allocnode_s *)
((FAR char *)node + node->size)) ((FAR char *)node + node->size))
{ {
@@ -122,8 +119,8 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
} }
minfo("region=%d node=%p heapend=%p\n", minfo("region=%d node=%p heapend=%p\n",
region, node, heap_impl->mm_heapend[region]); region, node, heap->mm_heapend[region]);
DEBUGASSERT(node == heap_impl->mm_heapend[region]); DEBUGASSERT(node == heap->mm_heapend[region]);
mm_givesemaphore(heap); mm_givesemaphore(heap);
@@ -131,9 +128,9 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
} }
#undef region #undef region
DEBUGASSERT(uordblks + fordblks == heap_impl->mm_heapsize); DEBUGASSERT(uordblks + fordblks == heap->mm_heapsize);
info->arena = heap_impl->mm_heapsize; info->arena = heap->mm_heapsize;
info->ordblks = ordblks; info->ordblks = ordblks;
info->aordblks = aordblks; info->aordblks = aordblks;
info->mxordblk = mxordblk; info->mxordblk = mxordblk;
+3 -11
View File
@@ -48,19 +48,15 @@
static void mm_free_delaylist(FAR struct mm_heap_s *heap) static void mm_free_delaylist(FAR struct mm_heap_s *heap)
{ {
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) #if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
FAR struct mm_heap_impl_s *heap_impl;
FAR struct mm_delaynode_s *tmp; FAR struct mm_delaynode_s *tmp;
irqstate_t flags; irqstate_t flags;
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
/* Move the delay list to local */ /* Move the delay list to local */
flags = enter_critical_section(); flags = enter_critical_section();
tmp = heap_impl->mm_delaylist[up_cpu_index()]; tmp = heap->mm_delaylist[up_cpu_index()];
heap_impl->mm_delaylist[up_cpu_index()] = NULL; heap->mm_delaylist[up_cpu_index()] = NULL;
leave_critical_section(flags); leave_critical_section(flags);
@@ -101,15 +97,11 @@ static void mm_free_delaylist(FAR struct mm_heap_s *heap)
FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
{ {
FAR struct mm_heap_impl_s *heap_impl;
FAR struct mm_freenode_s *node; FAR struct mm_freenode_s *node;
size_t alignsize; size_t alignsize;
FAR void *ret = NULL; FAR void *ret = NULL;
int ndx; int ndx;
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
/* Firstly, free mm_delaylist */ /* Firstly, free mm_delaylist */
mm_free_delaylist(heap); mm_free_delaylist(heap);
@@ -160,7 +152,7 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
* other mm_nodelist[] entries. * other mm_nodelist[] entries.
*/ */
for (node = heap_impl->mm_nodelist[ndx].flink; for (node = heap->mm_nodelist[ndx].flink;
node && node->size < alignsize; node && node->size < alignsize;
node = node->flink) node = node->flink)
{ {
+23 -41
View File
@@ -72,19 +72,14 @@
void mm_seminitialize(FAR struct mm_heap_s *heap) void mm_seminitialize(FAR struct mm_heap_s *heap)
{ {
FAR struct mm_heap_impl_s *heap_impl;
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
/* Initialize the MM semaphore to one (to support one-at-a-time access to /* Initialize the MM semaphore to one (to support one-at-a-time access to
* private data sets). * private data sets).
*/ */
_SEM_INIT(&heap_impl->mm_semaphore, 0, 1); _SEM_INIT(&heap->mm_semaphore, 0, 1);
heap_impl->mm_holder = NO_HOLDER; heap->mm_holder = NO_HOLDER;
heap_impl->mm_counts_held = 0; heap->mm_counts_held = 0;
} }
/**************************************************************************** /****************************************************************************
@@ -100,7 +95,6 @@ void mm_seminitialize(FAR struct mm_heap_s *heap)
int mm_trysemaphore(FAR struct mm_heap_s *heap) int mm_trysemaphore(FAR struct mm_heap_s *heap)
{ {
FAR struct mm_heap_impl_s *heap_impl;
pid_t my_pid = getpid(); pid_t my_pid = getpid();
int ret; int ret;
@@ -133,9 +127,6 @@ int mm_trysemaphore(FAR struct mm_heap_s *heap)
* 'else', albeit with a nonsensical PID value. * 'else', albeit with a nonsensical PID value.
*/ */
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
if (my_pid < 0) if (my_pid < 0)
{ {
ret = my_pid; ret = my_pid;
@@ -146,20 +137,20 @@ int mm_trysemaphore(FAR struct mm_heap_s *heap)
* task actually running? * task actually running?
*/ */
if (heap_impl->mm_holder == my_pid) if (heap->mm_holder == my_pid)
{ {
/* Yes, just increment the number of references held by the current /* Yes, just increment the number of references held by the current
* task. * task.
*/ */
heap_impl->mm_counts_held++; heap->mm_counts_held++;
ret = OK; ret = OK;
} }
else else
{ {
/* Try to take the semaphore */ /* Try to take the semaphore */
ret = _SEM_TRYWAIT(&heap_impl->mm_semaphore); ret = _SEM_TRYWAIT(&heap->mm_semaphore);
if (ret < 0) if (ret < 0)
{ {
ret = _SEM_ERRVAL(ret); ret = _SEM_ERRVAL(ret);
@@ -168,8 +159,8 @@ int mm_trysemaphore(FAR struct mm_heap_s *heap)
/* We have it. Claim the heap for the current task and return */ /* We have it. Claim the heap for the current task and return */
heap_impl->mm_holder = my_pid; heap->mm_holder = my_pid;
heap_impl->mm_counts_held = 1; heap->mm_counts_held = 1;
ret = OK; ret = OK;
} }
@@ -188,21 +179,17 @@ errout:
void mm_takesemaphore(FAR struct mm_heap_s *heap) void mm_takesemaphore(FAR struct mm_heap_s *heap)
{ {
FAR struct mm_heap_impl_s *heap_impl;
pid_t my_pid = getpid(); pid_t my_pid = getpid();
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
/* Does the current task already hold the semaphore? */ /* Does the current task already hold the semaphore? */
if (heap_impl->mm_holder == my_pid) if (heap->mm_holder == my_pid)
{ {
/* Yes, just increment the number of references held by the current /* Yes, just increment the number of references held by the current
* task. * task.
*/ */
heap_impl->mm_counts_held++; heap->mm_counts_held++;
} }
else else
{ {
@@ -213,7 +200,7 @@ void mm_takesemaphore(FAR struct mm_heap_s *heap)
mseminfo("PID=%d taking\n", my_pid); mseminfo("PID=%d taking\n", my_pid);
do do
{ {
ret = _SEM_WAIT(&heap_impl->mm_semaphore); ret = _SEM_WAIT(&heap->mm_semaphore);
/* The only case that an error should occur here is if the wait /* The only case that an error should occur here is if the wait
* was awakened by a signal. * was awakened by a signal.
@@ -231,12 +218,12 @@ void mm_takesemaphore(FAR struct mm_heap_s *heap)
* the semaphore for the current task and return. * the semaphore for the current task and return.
*/ */
heap_impl->mm_holder = my_pid; heap->mm_holder = my_pid;
heap_impl->mm_counts_held = 1; heap->mm_counts_held = 1;
} }
mseminfo("Holder=%d count=%d\n", heap_impl->mm_holder, mseminfo("Holder=%d count=%d\n", heap->mm_holder,
heap_impl->mm_counts_held); heap->mm_counts_held);
} }
/**************************************************************************** /****************************************************************************
@@ -249,26 +236,21 @@ void mm_takesemaphore(FAR struct mm_heap_s *heap)
void mm_givesemaphore(FAR struct mm_heap_s *heap) void mm_givesemaphore(FAR struct mm_heap_s *heap)
{ {
FAR struct mm_heap_impl_s *heap_impl;
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
/* The current task should be holding at least one reference to the /* The current task should be holding at least one reference to the
* semaphore. * semaphore.
*/ */
DEBUGASSERT(heap_impl->mm_holder == getpid()); DEBUGASSERT(heap->mm_holder == getpid());
/* Does the current task hold multiple references to the semaphore */ /* Does the current task hold multiple references to the semaphore */
if (heap_impl->mm_counts_held > 1) if (heap->mm_counts_held > 1)
{ {
/* Yes, just release one count and return */ /* Yes, just release one count and return */
heap_impl->mm_counts_held--; heap->mm_counts_held--;
mseminfo("Holder=%d count=%d\n", heap_impl->mm_holder, mseminfo("Holder=%d count=%d\n", heap->mm_holder,
heap_impl->mm_counts_held); heap->mm_counts_held);
} }
else else
{ {
@@ -276,8 +258,8 @@ void mm_givesemaphore(FAR struct mm_heap_s *heap)
mseminfo("PID=%d giving\n", getpid()); mseminfo("PID=%d giving\n", getpid());
heap_impl->mm_holder = NO_HOLDER; heap->mm_holder = NO_HOLDER;
heap_impl->mm_counts_held = 0; heap->mm_counts_held = 0;
DEBUGVERIFY(_SEM_POST(&heap_impl->mm_semaphore)); DEBUGVERIFY(_SEM_POST(&heap->mm_semaphore));
} }
} }
+1 -1
View File
@@ -49,7 +49,7 @@
#else #else
/* Otherwise, the user heap data structures are in common .bss */ /* Otherwise, the user heap data structures are in common .bss */
struct mm_heap_s g_mmheap; FAR struct mm_heap_s *g_mmheap;
#endif #endif
/**************************************************************************** /****************************************************************************
+11 -3
View File
@@ -43,7 +43,7 @@
* ARCH_DATA_RESERVE_SIZE * ARCH_DATA_RESERVE_SIZE
*/ */
# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) # define USR_HEAP (ARCH_DATA_RESERVE->ar_usrheap)
#elif defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) #elif defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)
/* In the protected mode, there are two heaps: A kernel heap and a single /* In the protected mode, there are two heaps: A kernel heap and a single
@@ -51,12 +51,20 @@
* structure from the userspace interface. * structure from the userspace interface.
*/ */
# define USR_HEAP (USERSPACE->us_heap) # define USR_HEAP (*USERSPACE->us_heap)
#else #else
/* Otherwise, the user heap data structures are in common .bss */ /* Otherwise, the user heap data structures are in common .bss */
# define USR_HEAP &g_mmheap # define USR_HEAP g_mmheap
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
void umm_try_initialize(void);
#endif #endif
#endif /* __MM_UMM_HEAP_UMM_HEAP_H */ #endif /* __MM_UMM_HEAP_UMM_HEAP_H */
+41 -1
View File
@@ -81,5 +81,45 @@
void umm_initialize(FAR void *heap_start, size_t heap_size) void umm_initialize(FAR void *heap_start, size_t heap_size)
{ {
mm_initialize(USR_HEAP, "Umem", heap_start, heap_size); USR_HEAP = mm_initialize("Umem", heap_start, heap_size);
} }
/****************************************************************************
* Name: umm_try_initialize
*
* Description:
* Allocate and initialize the user heap if not yet.
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
void umm_try_initialize(void)
{
uintptr_t allocbase;
/* Return if the user heap is already initialized. */
if (USR_HEAP != NULL)
{
return;
}
/* Allocate one page. If we provide a zero brkaddr to pgalloc(),
* it will create the first block in the correct virtual address
* space and return the start address of that block.
*/
allocbase = pgalloc(0, 1);
DEBUGASSERT(allocbase != 0);
/* Let umm_initialize do the real work. */
umm_initialize((FAR void *)allocbase, CONFIG_MM_PGSIZE);
}
#endif
+4
View File
@@ -54,6 +54,10 @@ FAR void *memalign(size_t alignment, size_t size)
FAR void *brkaddr; FAR void *brkaddr;
FAR void *mem; FAR void *mem;
/* Initialize the user heap if it wasn't yet */
umm_try_initialize();
/* Loop until we successfully allocate the memory or until an error /* Loop until we successfully allocate the memory or until an error
* occurs. If we fail to allocate memory on the first pass, then call * occurs. If we fail to allocate memory on the first pass, then call
* sbrk to extend the heap by one page. This may require several * sbrk to extend the heap by one page. This may require several
+4
View File
@@ -62,6 +62,10 @@ FAR void *realloc(FAR void *oldmem, size_t size)
return NULL; return NULL;
} }
/* Initialize the user heap if it wasn't yet */
umm_try_initialize();
/* Loop until we successfully allocate the memory or until an error /* Loop until we successfully allocate the memory or until an error
* occurs. If we fail to allocate memory on the first pass, then call * occurs. If we fail to allocate memory on the first pass, then call
* sbrk to extend the heap by one page. This may require several * sbrk to extend the heap by one page. This may require several
+7 -21
View File
@@ -85,10 +85,11 @@ FAR void *sbrk(intptr_t incr)
goto errout; goto errout;
} }
/* Get the current break address (NOTE: assumes region 0). If /* Initialize the user heap if it wasn't yet */
* the memory manager is uninitialized, mm_brkaddr() will return
* zero. umm_try_initialize();
*/
/* Get the current break address (NOTE: assumes region 0). */
brkaddr = (uintptr_t)mm_brkaddr(USR_HEAP, 0); brkaddr = (uintptr_t)mm_brkaddr(USR_HEAP, 0);
if (incr > 0) if (incr > 0)
@@ -98,9 +99,7 @@ FAR void *sbrk(intptr_t incr)
pgincr = MM_NPAGES(incr); pgincr = MM_NPAGES(incr);
/* Allocate the requested number of pages and map them to the /* Allocate the requested number of pages and map them to the
* break address. If we provide a zero brkaddr to pgalloc(), it * break address.
* will create the first block in the correct virtual address
* space and return the start address of that block.
*/ */
allocbase = pgalloc(brkaddr, pgincr); allocbase = pgalloc(brkaddr, pgincr);
@@ -110,24 +109,11 @@ FAR void *sbrk(intptr_t incr)
goto errout; goto errout;
} }
/* Has the been been initialized? brkaddr will be zero if the
* memory manager has not yet been initialized.
*/
bytesize = pgincr << MM_PGSHIFT;
if (brkaddr == 0)
{
/* No... then initialize it now */
mm_initialize(USR_HEAP, "Umem", (FAR void *)allocbase, bytesize);
}
else
{
/* Extend the heap (region 0) */ /* Extend the heap (region 0) */
bytesize = pgincr << MM_PGSHIFT;
mm_extend(USR_HEAP, (FAR void *)allocbase, bytesize, 0); mm_extend(USR_HEAP, (FAR void *)allocbase, bytesize, 0);
} }
}
return (FAR void *)brkaddr; return (FAR void *)brkaddr;