Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arch/sim/src/sim/sim_sectionheap.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
* Private Data
****************************************************************************/

#ifdef CONFIG_ARCH_USE_TEXT_HEAP
static struct mm_heap_s *g_textheap;
#endif
static struct mm_heap_s *g_dataheap;

/****************************************************************************
Expand All @@ -48,6 +50,7 @@ static struct mm_heap_s *g_dataheap;
*
****************************************************************************/

#ifdef CONFIG_ARCH_USE_TEXT_HEAP
#ifdef CONFIG_ARCH_USE_SEPARATED_SECTION
void *up_textheap_memalign(const char *sectname, size_t align, size_t size)
#else
Expand Down Expand Up @@ -92,6 +95,7 @@ bool up_textheap_heapmember(void *p)
{
return g_textheap != NULL && mm_heapmember(g_textheap, p);
}
#endif /* CONFIG_ARCH_USE_TEXT_HEAP */

/****************************************************************************
* Name: up_dataheap_memalign
Expand Down
25 changes: 19 additions & 6 deletions include/nuttx/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,11 @@ void up_extraheaps_init(void);
* Description:
* Allocate memory for text with the specified alignment and sectname.
*
* If the architecture does not provide a separate text heap
* (CONFIG_ARCH_USE_TEXT_HEAP is not set), the text heap API falls back
* to the normal kernel heap: on flat-memory architectures the kernel
* heap is executable, so no separate allocator is needed.
*
****************************************************************************/

#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
Expand All @@ -856,6 +861,12 @@ FAR void *up_textheap_memalign(FAR const char *sectname,
# else
FAR void *up_textheap_memalign(size_t align, size_t size);
# endif
#else
# if defined(CONFIG_ARCH_USE_SEPARATED_SECTION)
# define up_textheap_memalign(s,a,z) kmm_memalign(a,z)
# else
# define up_textheap_memalign(a,z) kmm_memalign(a,z)
# endif
#endif

/****************************************************************************
Expand All @@ -868,6 +879,8 @@ FAR void *up_textheap_memalign(size_t align, size_t size);

#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
void up_textheap_free(FAR void *p);
#else
# define up_textheap_free(p) kmm_free(p)
#endif

/****************************************************************************
Expand All @@ -880,6 +893,8 @@ void up_textheap_free(FAR void *p);

#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
bool up_textheap_heapmember(FAR void *p);
#else
# define up_textheap_heapmember(p) kmm_heapmember(p)
#endif

/****************************************************************************
Expand All @@ -900,13 +915,12 @@ bool up_textheap_heapmember(FAR void *p);
*
****************************************************************************/

#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
#if defined(CONFIG_ARCH_HAVE_TEXT_HEAP_SEPARATE_DATA_ADDRESS)
#if defined(CONFIG_ARCH_USE_TEXT_HEAP) && \
defined(CONFIG_ARCH_HAVE_TEXT_HEAP_SEPARATE_DATA_ADDRESS)
FAR void *up_textheap_data_address(FAR void *p);
#else
#define up_textheap_data_address(p) ((FAR void *)p)
#endif
#endif

/****************************************************************************
* Name: up_textheap_data_sync
Expand All @@ -918,13 +932,12 @@ FAR void *up_textheap_data_address(FAR void *p);
*
****************************************************************************/

#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
#if defined(CONFIG_ARCH_HAVE_TEXT_HEAP_SEPARATE_DATA_ADDRESS)
#if defined(CONFIG_ARCH_USE_TEXT_HEAP) && \
defined(CONFIG_ARCH_HAVE_TEXT_HEAP_SEPARATE_DATA_ADDRESS)
void up_textheap_data_sync(void);
#else
#define up_textheap_data_sync() do {} while (0)
#endif
#endif

/****************************************************************************
* Name: up_dataheap_memalign
Expand Down
Loading