mm: Move mm_heap_s related stuff to private header file

since it will improve the modularity and reduce the inforamtion explosion

Change-Id: I085b36adb38993a979625a1f4c252d364a15afa1
This commit is contained in:
mage1
2021-03-02 16:03:00 +08:00
committed by Xiang Xiao
parent 2e887a1c22
commit 635cfadc25
16 changed files with 395 additions and 240 deletions
+12 -7
View File
@@ -30,6 +30,8 @@
#include <nuttx/mm/mm.h>
#include "mm_heap/mm.h"
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -44,6 +46,7 @@
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;
#ifdef CONFIG_DEBUG_ASSERTIONS
FAR struct mm_allocnode_s *prev;
@@ -59,11 +62,13 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
#endif
DEBUGASSERT(info);
DEBUGASSERT(MM_IS_VALID(heap));
heap_impl = heap->mm_impl;
/* Visit each region */
#if CONFIG_MM_REGIONS > 1
for (region = 0; region < heap->mm_nregions; region++)
for (region = 0; region < heap_impl->mm_nregions; region++)
#endif
{
#ifdef CONFIG_DEBUG_ASSERTIONS
@@ -75,8 +80,8 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
mm_takesemaphore(heap);
for (node = heap->mm_heapstart[region];
node < heap->mm_heapend[region];
for (node = heap_impl->mm_heapstart[region];
node < heap_impl->mm_heapend[region];
node = (FAR struct mm_allocnode_s *)
((FAR char *)node + node->size))
{
@@ -121,8 +126,8 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
}
minfo("region=%d node=%p heapend=%p\n",
region, node, heap->mm_heapend[region]);
DEBUGASSERT(node == heap->mm_heapend[region]);
region, node, heap_impl->mm_heapend[region]);
DEBUGASSERT(node == heap_impl->mm_heapend[region]);
mm_givesemaphore(heap);
@@ -130,9 +135,9 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
}
#undef region
DEBUGASSERT(uordblks + fordblks == heap->mm_heapsize);
DEBUGASSERT(uordblks + fordblks == heap_impl->mm_heapsize);
info->arena = heap->mm_heapsize;
info->arena = heap_impl->mm_heapsize;
info->ordblks = ordblks;
info->mxordblk = mxordblk;
info->uordblks = uordblks;