mirror of
https://github.com/apache/nuttx.git
synced 2025-12-10 20:24:51 +08:00
Rename MODULE_TEXT to TEXT_HEAP as the latter is more generic.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
committed by
Xiang Xiao
parent
79e9347551
commit
af5e0c620f
10
arch/Kconfig
10
arch/Kconfig
@@ -259,7 +259,7 @@ config ARCH_NEED_ADDRENV_MAPPING
|
|||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
|
|
||||||
config ARCH_HAVE_MODULE_TEXT
|
config ARCH_HAVE_TEXT_HEAP
|
||||||
bool "Special memory region for dynamic code loading"
|
bool "Special memory region for dynamic code loading"
|
||||||
default n
|
default n
|
||||||
|
|
||||||
@@ -371,12 +371,12 @@ config ARCH_USE_MPU
|
|||||||
is enabled by other, platform-specific logic. In those cases, this
|
is enabled by other, platform-specific logic. In those cases, this
|
||||||
selection will always be forced.
|
selection will always be forced.
|
||||||
|
|
||||||
config ARCH_USE_MODULE_TEXT
|
config ARCH_USE_TEXT_HEAP
|
||||||
bool "Enable module text allocator"
|
bool "Enable separate text heap for dynamic code loading"
|
||||||
default n
|
default n
|
||||||
depends on ARCH_HAVE_MODULE_TEXT
|
depends on ARCH_HAVE_TEXT_HEAP
|
||||||
---help---
|
---help---
|
||||||
This option enable architecture-sepecific memory allocator
|
This option enables architecture-sepecific memory allocator
|
||||||
for dynamic code loading. For example, ESP32 has a separate memory
|
for dynamic code loading. For example, ESP32 has a separate memory
|
||||||
regions for instruction and data and the memory region used for
|
regions for instruction and data and the memory region used for
|
||||||
usual malloc doesn't work for instruction.
|
usual malloc doesn't work for instruction.
|
||||||
|
|||||||
@@ -456,7 +456,7 @@ config ARCH_CHIP_CXD56XX
|
|||||||
select ARCH_HAVE_FPU
|
select ARCH_HAVE_FPU
|
||||||
select ARCH_HAVE_HEAPCHECK
|
select ARCH_HAVE_HEAPCHECK
|
||||||
select ARCH_HAVE_MULTICPU
|
select ARCH_HAVE_MULTICPU
|
||||||
select ARCH_HAVE_MODULE_TEXT
|
select ARCH_HAVE_TEXT_HEAP
|
||||||
select ARCH_HAVE_SDIO if MMCSD
|
select ARCH_HAVE_SDIO if MMCSD
|
||||||
select ARCH_HAVE_MATH_H
|
select ARCH_HAVE_MATH_H
|
||||||
---help---
|
---help---
|
||||||
|
|||||||
@@ -1344,7 +1344,7 @@ endif
|
|||||||
config CXD56_USE_SYSBUS
|
config CXD56_USE_SYSBUS
|
||||||
bool "Use the system bus for the data section"
|
bool "Use the system bus for the data section"
|
||||||
default y
|
default y
|
||||||
select ARCH_USE_MODULE_TEXT if ELF
|
select ARCH_USE_TEXT_HEAP if ELF
|
||||||
---help---
|
---help---
|
||||||
To make ldrex/strex work correctly, this option must be enabled
|
To make ldrex/strex work correctly, this option must be enabled
|
||||||
endmenu
|
endmenu
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ CHIP_CSRCS += cxd56_testset.c
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ARCH_USE_MODULE_TEXT), y)
|
ifeq ($(CONFIG_ARCH_USE_TEXT_HEAP), y)
|
||||||
CHIP_CSRCS += cxd56_modtext.c
|
CHIP_CSRCS += cxd56_textheap.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_CXD56_UART0),y)
|
ifeq ($(CONFIG_CXD56_UART0),y)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/cxd56xx/cxd56_modtext.c
|
* arch/arm/src/cxd56xx/cxd56_textheap.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -44,18 +44,18 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_module_text_init()
|
* Name: up_textheap_init()
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_module_text_init()
|
void up_textheap_init()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_module_text_memalign()
|
* Name: up_textheap_memalign()
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR void *up_module_text_memalign(size_t align, size_t size)
|
FAR void *up_textheap_memalign(size_t align, size_t size)
|
||||||
{
|
{
|
||||||
FAR void *ret;
|
FAR void *ret;
|
||||||
ret = (FAR void *)kmm_malloc(size);
|
ret = (FAR void *)kmm_malloc(size);
|
||||||
@@ -80,10 +80,10 @@ FAR void *up_module_text_memalign(size_t align, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_module_text_free()
|
* Name: up_textheap_free()
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_module_text_free(FAR void *p)
|
void up_textheap_free(FAR void *p)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_CXD56_USE_SYSBUS
|
#ifdef CONFIG_CXD56_USE_SYSBUS
|
||||||
if (p)
|
if (p)
|
||||||
@@ -50,7 +50,7 @@ config ARCH_CHIP_ESP32C3
|
|||||||
select LIBC_ARCH_MEMCCMP
|
select LIBC_ARCH_MEMCCMP
|
||||||
select LIBC_ARCH_MEMMOVE
|
select LIBC_ARCH_MEMMOVE
|
||||||
select LIBC_ARCH_MEMSET
|
select LIBC_ARCH_MEMSET
|
||||||
select ARCH_HAVE_MODULE_TEXT
|
select ARCH_HAVE_TEXT_HEAP
|
||||||
---help---
|
---help---
|
||||||
Espressif ESP32-C3 (RV32IMC).
|
Espressif ESP32-C3 (RV32IMC).
|
||||||
|
|
||||||
|
|||||||
@@ -156,8 +156,8 @@ CHIP_CSRCS += esp32c3_efuse_table.c
|
|||||||
CHIP_CSRCS += esp32c3_efuse_lowerhalf.c
|
CHIP_CSRCS += esp32c3_efuse_lowerhalf.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ARCH_USE_MODULE_TEXT),y)
|
ifeq ($(CONFIG_ARCH_USE_TEXT_HEAP),y)
|
||||||
CHIP_CSRCS += esp32c3_modtext.c
|
CHIP_CSRCS += esp32c3_textheap.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_RTC_DRIVER),y)
|
ifeq ($(CONFIG_RTC_DRIVER),y)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/risc-v/src/esp32c3/esp32c3_modtext.c
|
* arch/risc-v/src/esp32c3/esp32c3_textheap.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -50,10 +50,10 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_module_text_init()
|
* Name: up_textheap_init()
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_module_text_init()
|
void up_textheap_init()
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_ESP32C3_RTC_HEAP
|
#ifdef CONFIG_ESP32C3_RTC_HEAP
|
||||||
/* Initialize the RTC heap */
|
/* Initialize the RTC heap */
|
||||||
@@ -63,14 +63,14 @@ void up_module_text_init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_module_text_memalign()
|
* Name: up_textheap_memalign()
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate memory for module text with the specified alignment.
|
* Allocate memory for module text with the specified alignment.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR void *up_module_text_memalign(size_t align, size_t size)
|
FAR void *up_textheap_memalign(size_t align, size_t size)
|
||||||
{
|
{
|
||||||
FAR void *ret = NULL;
|
FAR void *ret = NULL;
|
||||||
|
|
||||||
@@ -99,14 +99,14 @@ FAR void *up_module_text_memalign(size_t align, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_module_text_free()
|
* Name: up_textheap_free()
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Free memory for module text.
|
* Free memory for module text.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_module_text_free(FAR void *p)
|
void up_textheap_free(FAR void *p)
|
||||||
{
|
{
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
@@ -454,7 +454,7 @@ void up_allocate_heap(void **heap_start, size_t *heap_size)
|
|||||||
|
|
||||||
/* We make the entire heap executable here to keep
|
/* We make the entire heap executable here to keep
|
||||||
* the sim simpler. If it turns out to be a problem, the
|
* the sim simpler. If it turns out to be a problem, the
|
||||||
* ARCH_HAVE_MODULE_TEXT mechanism can be an alternative.
|
* ARCH_HAVE_TEXT_HEAP mechanism can be an alternative.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t *sim_heap = host_alloc_heap(SIM_HEAP_SIZE);
|
uint8_t *sim_heap = host_alloc_heap(SIM_HEAP_SIZE);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ config ARCH_CHIP_ESP32
|
|||||||
select ARCH_FAMILY_LX6
|
select ARCH_FAMILY_LX6
|
||||||
select XTENSA_HAVE_INTERRUPTS
|
select XTENSA_HAVE_INTERRUPTS
|
||||||
select ARCH_HAVE_MULTICPU
|
select ARCH_HAVE_MULTICPU
|
||||||
select ARCH_HAVE_MODULE_TEXT
|
select ARCH_HAVE_TEXT_HEAP
|
||||||
select ARCH_HAVE_SDRAM
|
select ARCH_HAVE_SDRAM
|
||||||
select ARCH_HAVE_RESET
|
select ARCH_HAVE_RESET
|
||||||
select ARCH_TOOLCHAIN_GNU
|
select ARCH_TOOLCHAIN_GNU
|
||||||
@@ -41,7 +41,7 @@ config ARCH_CHIP_ESP32S2
|
|||||||
bool "Espressif ESP32-S2"
|
bool "Espressif ESP32-S2"
|
||||||
select ARCH_FAMILY_LX7
|
select ARCH_FAMILY_LX7
|
||||||
select XTENSA_HAVE_INTERRUPTS
|
select XTENSA_HAVE_INTERRUPTS
|
||||||
select ARCH_HAVE_MODULE_TEXT
|
select ARCH_HAVE_TEXT_HEAP
|
||||||
select ARCH_HAVE_SDRAM
|
select ARCH_HAVE_SDRAM
|
||||||
select ARCH_HAVE_RESET
|
select ARCH_HAVE_RESET
|
||||||
select ARCH_TOOLCHAIN_GNU
|
select ARCH_TOOLCHAIN_GNU
|
||||||
|
|||||||
@@ -180,8 +180,8 @@ CHIP_CSRCS += esp32_wdt_lowerhalf.c
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ARCH_USE_MODULE_TEXT),y)
|
ifeq ($(CONFIG_ARCH_USE_TEXT_HEAP),y)
|
||||||
CHIP_CSRCS += esp32_modtext.c
|
CHIP_CSRCS += esp32_textheap.c
|
||||||
CMN_ASRCS += xtensa_loadstore.S
|
CMN_ASRCS += xtensa_loadstore.S
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/xtensa/src/esp32/esp32_modtext.c
|
* arch/xtensa/src/esp32/esp32_textheap.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -34,63 +34,63 @@
|
|||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
extern uint32_t _smodtext;
|
extern uint32_t _stextheap;
|
||||||
extern uint32_t _emodtext;
|
extern uint32_t _etextheap;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
struct mm_heap_s g_module_text;
|
struct mm_heap_s g_textheap;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_module_text_init
|
* Name: up_textheap_init
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize the module text allocator
|
* Initialize the text heap.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_module_text_init()
|
void up_textheap_init()
|
||||||
{
|
{
|
||||||
mm_initialize(&g_module_text, &_smodtext, &_emodtext - &_smodtext);
|
mm_initialize(&g_textheap, &_stextheap, &_etextheap - &_stextheap);
|
||||||
|
|
||||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||||
static struct procfs_meminfo_entry_s g_modtext_procfs;
|
static struct procfs_meminfo_entry_s g_textheap_procfs;
|
||||||
|
|
||||||
g_modtext_procfs.name = "modtext";
|
g_textheap_procfs.name = "textheap";
|
||||||
g_modtext_procfs.mallinfo = (void *)mm_mallinfo;
|
g_textheap_procfs.mallinfo = (void *)mm_mallinfo;
|
||||||
g_modtext_procfs.user_data = &g_module_text;
|
g_textheap_procfs.user_data = &g_textheap;
|
||||||
procfs_register_meminfo(&g_modtext_procfs);
|
procfs_register_meminfo(&g_textheap_procfs);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_module_text_memalign
|
* Name: up_textheap_memalign
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate memory for module text with the specified alignment.
|
* Allocate memory from the text heap with the specified alignment.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR void *up_module_text_memalign(size_t align, size_t size)
|
FAR void *up_textheap_memalign(size_t align, size_t size)
|
||||||
{
|
{
|
||||||
return mm_memalign(&g_module_text, align, size);
|
return mm_memalign(&g_textheap, align, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_module_text_free
|
* Name: up_textheap_free
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Free memory for module text.
|
* Free memory from the text heap.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_module_text_free(FAR void *p)
|
void up_textheap_free(FAR void *p)
|
||||||
{
|
{
|
||||||
return mm_free(&g_module_text, p);
|
return mm_free(&g_textheap, p);
|
||||||
}
|
}
|
||||||
@@ -38,9 +38,9 @@
|
|||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USE_MODULE_TEXT
|
#ifdef CONFIG_ARCH_USE_TEXT_HEAP
|
||||||
extern uint32_t _smodtext;
|
extern uint32_t _stextheap;
|
||||||
extern uint32_t _emodtext;
|
extern uint32_t _etextheap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -51,7 +51,7 @@ extern uint32_t _emodtext;
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USE_MODULE_TEXT
|
#ifdef CONFIG_ARCH_USE_TEXT_HEAP
|
||||||
#ifdef CONFIG_ENDIAN_BIG
|
#ifdef CONFIG_ENDIAN_BIG
|
||||||
#error not implemented
|
#error not implemented
|
||||||
#endif
|
#endif
|
||||||
@@ -323,7 +323,7 @@ static void advance_pc(uint32_t *regs, int diff)
|
|||||||
|
|
||||||
uint32_t *xtensa_user(int exccause, uint32_t *regs)
|
uint32_t *xtensa_user(int exccause, uint32_t *regs)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_ARCH_USE_MODULE_TEXT
|
#ifdef CONFIG_ARCH_USE_TEXT_HEAP
|
||||||
/* Emulate byte access for module text.
|
/* Emulate byte access for module text.
|
||||||
*
|
*
|
||||||
* ESP32 only allows word-aligned accesses to the instruction memory
|
* ESP32 only allows word-aligned accesses to the instruction memory
|
||||||
@@ -338,8 +338,8 @@ uint32_t *xtensa_user(int exccause, uint32_t *regs)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (exccause == XCHAL_EXCCAUSE_LOAD_STORE_ERROR &&
|
if (exccause == XCHAL_EXCCAUSE_LOAD_STORE_ERROR &&
|
||||||
(uintptr_t)&_smodtext <= regs[REG_EXCVADDR] &&
|
(uintptr_t)&_stextheap <= regs[REG_EXCVADDR] &&
|
||||||
(uintptr_t)&_emodtext > regs[REG_EXCVADDR])
|
(uintptr_t)&_etextheap > regs[REG_EXCVADDR])
|
||||||
{
|
{
|
||||||
uint8_t *pc = (uint8_t *)regs[REG_PC];
|
uint8_t *pc = (uint8_t *)regs[REG_PC];
|
||||||
uint8_t imm8;
|
uint8_t imm8;
|
||||||
|
|||||||
@@ -79,8 +79,3 @@ ifeq ($(CONFIG_ESP32S2_UART),y)
|
|||||||
CMN_CSRCS += esp32s2_serial.c
|
CMN_CSRCS += esp32s2_serial.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ARCH_USE_MODULE_TEXT),y)
|
|
||||||
CHIP_CSRCS += esp32s2_modtext.c
|
|
||||||
CMN_ASRCS += xtensa_loadstore.S
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,9 +38,9 @@
|
|||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USE_MODULE_TEXT
|
#ifdef CONFIG_ARCH_USE_TEXT_HEAP
|
||||||
extern uint32_t _smodtext;
|
extern uint32_t _stextheap;
|
||||||
extern uint32_t _emodtext;
|
extern uint32_t _etextheap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -51,7 +51,7 @@ extern uint32_t _emodtext;
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USE_MODULE_TEXT
|
#ifdef CONFIG_ARCH_USE_TEXT_HEAP
|
||||||
#ifdef CONFIG_ENDIAN_BIG
|
#ifdef CONFIG_ENDIAN_BIG
|
||||||
#error not implemented
|
#error not implemented
|
||||||
#endif
|
#endif
|
||||||
@@ -293,7 +293,7 @@ static void advance_pc(uint32_t *regs, int diff)
|
|||||||
|
|
||||||
uint32_t *xtensa_user(int exccause, uint32_t *regs)
|
uint32_t *xtensa_user(int exccause, uint32_t *regs)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_ARCH_USE_MODULE_TEXT
|
#ifdef CONFIG_ARCH_USE_TEXT_HEAP
|
||||||
/* Emulate byte access for module text.
|
/* Emulate byte access for module text.
|
||||||
*
|
*
|
||||||
* ESP32S2 only allows word-aligned accesses to the instruction memory
|
* ESP32S2 only allows word-aligned accesses to the instruction memory
|
||||||
@@ -308,8 +308,8 @@ uint32_t *xtensa_user(int exccause, uint32_t *regs)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (exccause == XCHAL_EXCCAUSE_LOAD_STORE_ERROR &&
|
if (exccause == XCHAL_EXCCAUSE_LOAD_STORE_ERROR &&
|
||||||
(uintptr_t)&_smodtext <= regs[REG_EXCVADDR] &&
|
(uintptr_t)&_stextheap <= regs[REG_EXCVADDR] &&
|
||||||
(uintptr_t)&_emodtext > regs[REG_EXCVADDR])
|
(uintptr_t)&_etextheap > regs[REG_EXCVADDR])
|
||||||
{
|
{
|
||||||
uint8_t *pc = (uint8_t *)regs[REG_PC];
|
uint8_t *pc = (uint8_t *)regs[REG_PC];
|
||||||
uint8_t imm8;
|
uint8_t imm8;
|
||||||
|
|||||||
@@ -166,8 +166,8 @@ int unload_module(FAR struct binary_s *binp)
|
|||||||
if (binp->alloc[i])
|
if (binp->alloc[i])
|
||||||
{
|
{
|
||||||
binfo("Freeing alloc[%d]: %p\n", i, binp->alloc[i]);
|
binfo("Freeing alloc[%d]: %p\n", i, binp->alloc[i]);
|
||||||
#if defined(CONFIG_ARCH_USE_MODULE_TEXT)
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
up_module_text_free((FAR void *)binp->alloc[i]);
|
up_textheap_free((FAR void *)binp->alloc[i]);
|
||||||
#else
|
#else
|
||||||
kumm_free((FAR void *)binp->alloc[i]);
|
kumm_free((FAR void *)binp->alloc[i]);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -117,10 +117,10 @@ int elf_addrenv_alloc(FAR struct elf_loadinfo_s *loadinfo, size_t textsize,
|
|||||||
#else
|
#else
|
||||||
/* Allocate memory to hold the ELF image */
|
/* Allocate memory to hold the ELF image */
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_USE_MODULE_TEXT)
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
loadinfo->textalloc = (uintptr_t)
|
loadinfo->textalloc = (uintptr_t)
|
||||||
up_module_text_memalign(loadinfo->textalign,
|
up_textheap_memalign(loadinfo->textalign,
|
||||||
textsize);
|
textsize);
|
||||||
#else
|
#else
|
||||||
loadinfo->textalloc = (uintptr_t)kumm_malloc(textsize + datasize);
|
loadinfo->textalloc = (uintptr_t)kumm_malloc(textsize + datasize);
|
||||||
#endif
|
#endif
|
||||||
@@ -130,7 +130,7 @@ int elf_addrenv_alloc(FAR struct elf_loadinfo_s *loadinfo, size_t textsize,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_USE_MODULE_TEXT)
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
loadinfo->dataalloc = (uintptr_t)kumm_malloc(datasize);
|
loadinfo->dataalloc = (uintptr_t)kumm_malloc(datasize);
|
||||||
|
|
||||||
if (0 != datasize && !loadinfo->dataalloc)
|
if (0 != datasize && !loadinfo->dataalloc)
|
||||||
@@ -177,10 +177,10 @@ void elf_addrenv_free(FAR struct elf_loadinfo_s *loadinfo)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_USE_MODULE_TEXT)
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
if (loadinfo->textalloc != 0)
|
if (loadinfo->textalloc != 0)
|
||||||
{
|
{
|
||||||
up_module_text_free((FAR void *)loadinfo->textalloc);
|
up_textheap_free((FAR void *)loadinfo->textalloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadinfo->dataalloc != 0)
|
if (loadinfo->dataalloc != 0)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ CONFIG_ARCH_CHIP_ESP32C3WROOM02=y
|
|||||||
CONFIG_ARCH_INTERRUPTSTACK=8192
|
CONFIG_ARCH_INTERRUPTSTACK=8192
|
||||||
CONFIG_ARCH_RISCV=y
|
CONFIG_ARCH_RISCV=y
|
||||||
CONFIG_ARCH_STACKDUMP=y
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
CONFIG_ARCH_USE_MODULE_TEXT=y
|
CONFIG_ARCH_USE_TEXT_HEAP=y
|
||||||
CONFIG_BOARDCTL_ROMDISK=y
|
CONFIG_BOARDCTL_ROMDISK=y
|
||||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||||
CONFIG_BUILTIN=y
|
CONFIG_BUILTIN=y
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ CONFIG_ARCH_CHIP="esp32"
|
|||||||
CONFIG_ARCH_CHIP_ESP32=y
|
CONFIG_ARCH_CHIP_ESP32=y
|
||||||
CONFIG_ARCH_CHIP_ESP32WROVER=y
|
CONFIG_ARCH_CHIP_ESP32WROVER=y
|
||||||
CONFIG_ARCH_STACKDUMP=y
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
CONFIG_ARCH_USE_MODULE_TEXT=y
|
CONFIG_ARCH_USE_TEXT_HEAP=y
|
||||||
CONFIG_ARCH_XTENSA=y
|
CONFIG_ARCH_XTENSA=y
|
||||||
CONFIG_BOARDCTL_ROMDISK=y
|
CONFIG_BOARDCTL_ROMDISK=y
|
||||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||||
|
|||||||
@@ -78,6 +78,6 @@ MEMORY
|
|||||||
|
|
||||||
_eheap = 0x40000000 - CONFIG_ESP32_TRACEMEM_RESERVE_DRAM;
|
_eheap = 0x40000000 - CONFIG_ESP32_TRACEMEM_RESERVE_DRAM;
|
||||||
|
|
||||||
/* Module text area ends at top of dram0_0_seg */
|
/* Text heap ends at top of dram0_0_seg */
|
||||||
|
|
||||||
_emodtext = 0x400a0000;
|
_etextheap = 0x400a0000;
|
||||||
|
|||||||
@@ -63,10 +63,10 @@ SECTIONS
|
|||||||
*(.phyiram .phyiram.*)
|
*(.phyiram .phyiram.*)
|
||||||
_iram_text_end = ABSOLUTE(.);
|
_iram_text_end = ABSOLUTE(.);
|
||||||
|
|
||||||
/* Module text area starts at the end of iram0_0_seg */
|
/* Text heap starts at the end of iram0_0_seg */
|
||||||
|
|
||||||
. = ALIGN (4);
|
. = ALIGN (4);
|
||||||
_smodtext = ABSOLUTE(.);
|
_stextheap = ABSOLUTE(.);
|
||||||
} > iram0_0_seg
|
} > iram0_0_seg
|
||||||
|
|
||||||
/* Shared RAM */
|
/* Shared RAM */
|
||||||
|
|||||||
@@ -70,10 +70,10 @@ SECTIONS
|
|||||||
_text_end = ABSOLUTE(.);
|
_text_end = ABSOLUTE(.);
|
||||||
_etext = .;
|
_etext = .;
|
||||||
|
|
||||||
/* Module text area starts at the end of iram0_0_seg */
|
/* Text heap starts at the end of iram0_0_seg */
|
||||||
|
|
||||||
. = ALIGN (4);
|
. = ALIGN (4);
|
||||||
_smodtext = ABSOLUTE(.);
|
_stextheap = ABSOLUTE(.);
|
||||||
} > iram0_0_seg
|
} > iram0_0_seg
|
||||||
|
|
||||||
/* Shared RAM */
|
/* Shared RAM */
|
||||||
|
|||||||
@@ -78,6 +78,6 @@ MEMORY
|
|||||||
|
|
||||||
_eheap = 0x40000000 - CONFIG_ESP32_TRACEMEM_RESERVE_DRAM;
|
_eheap = 0x40000000 - CONFIG_ESP32_TRACEMEM_RESERVE_DRAM;
|
||||||
|
|
||||||
/* Module text area ends at top of dram0_0_seg */
|
/* Text heap ends at top of dram0_0_seg */
|
||||||
|
|
||||||
_emodtext = 0x400a0000;
|
_etextheap = 0x400a0000;
|
||||||
|
|||||||
@@ -66,10 +66,10 @@ SECTIONS
|
|||||||
*(.phyiram .phyiram.*)
|
*(.phyiram .phyiram.*)
|
||||||
_iram_text_end = ABSOLUTE(.);
|
_iram_text_end = ABSOLUTE(.);
|
||||||
|
|
||||||
/* Module text area starts at the end of iram0_0_seg */
|
/* Text heap starts at the end of iram0_0_seg */
|
||||||
|
|
||||||
. = ALIGN (4);
|
. = ALIGN (4);
|
||||||
_smodtext = ABSOLUTE(.);
|
_stextheap = ABSOLUTE(.);
|
||||||
} > iram0_0_seg
|
} > iram0_0_seg
|
||||||
|
|
||||||
/* Shared RAM */
|
/* Shared RAM */
|
||||||
|
|||||||
@@ -70,10 +70,10 @@ SECTIONS
|
|||||||
_text_end = ABSOLUTE(.);
|
_text_end = ABSOLUTE(.);
|
||||||
_etext = .;
|
_etext = .;
|
||||||
|
|
||||||
/* Module text area starts at the end of iram0_0_seg */
|
/* Text heap starts at the end of iram0_0_seg */
|
||||||
|
|
||||||
. = ALIGN (4);
|
. = ALIGN (4);
|
||||||
_smodtext = ABSOLUTE(.);
|
_stextheap = ABSOLUTE(.);
|
||||||
} > iram0_0_seg
|
} > iram0_0_seg
|
||||||
|
|
||||||
/* Shared RAM */
|
/* Shared RAM */
|
||||||
|
|||||||
@@ -78,6 +78,6 @@ MEMORY
|
|||||||
|
|
||||||
_eheap = 0x40000000 - CONFIG_ESP32_TRACEMEM_RESERVE_DRAM;
|
_eheap = 0x40000000 - CONFIG_ESP32_TRACEMEM_RESERVE_DRAM;
|
||||||
|
|
||||||
/* Module text area ends at top of dram0_0_seg */
|
/* Text heap ends at top of dram0_0_seg */
|
||||||
|
|
||||||
_emodtext = 0x400a0000;
|
_etextheap = 0x400a0000;
|
||||||
|
|||||||
@@ -66,10 +66,10 @@ SECTIONS
|
|||||||
*(.phyiram .phyiram.*)
|
*(.phyiram .phyiram.*)
|
||||||
_iram_text_end = ABSOLUTE(.);
|
_iram_text_end = ABSOLUTE(.);
|
||||||
|
|
||||||
/* Module text area starts at the end of iram0_0_seg */
|
/* Text heap starts at the end of iram0_0_seg */
|
||||||
|
|
||||||
. = ALIGN (4);
|
. = ALIGN (4);
|
||||||
_smodtext = ABSOLUTE(.);
|
_stextheap = ABSOLUTE(.);
|
||||||
} > iram0_0_seg
|
} > iram0_0_seg
|
||||||
|
|
||||||
/* Shared RAM */
|
/* Shared RAM */
|
||||||
|
|||||||
@@ -70,10 +70,10 @@ SECTIONS
|
|||||||
_text_end = ABSOLUTE(.);
|
_text_end = ABSOLUTE(.);
|
||||||
_etext = .;
|
_etext = .;
|
||||||
|
|
||||||
/* Module text area starts at the end of iram0_0_seg */
|
/* Text heap starts at the end of iram0_0_seg */
|
||||||
|
|
||||||
. = ALIGN (4);
|
. = ALIGN (4);
|
||||||
_smodtext = ABSOLUTE(.);
|
_stextheap = ABSOLUTE(.);
|
||||||
} > iram0_0_seg
|
} > iram0_0_seg
|
||||||
|
|
||||||
/* Shared RAM */
|
/* Shared RAM */
|
||||||
|
|||||||
@@ -754,39 +754,39 @@ uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_module_text_init
|
* Name: up_textheap_init
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize the module text allocator
|
* Initialize the text heap.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_USE_MODULE_TEXT)
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
void up_module_text_init(void);
|
void up_textheap_init(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_module_text_memalign
|
* Name: up_textheap_memalign
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate memory for module text with the specified alignment.
|
* Allocate memory from the text heap with the specified alignment.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_USE_MODULE_TEXT)
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
FAR void *up_module_text_memalign(size_t align, size_t size);
|
FAR void *up_textheap_memalign(size_t align, size_t size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_module_text_free
|
* Name: up_textheap_free
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Free memory for module text.
|
* Free memory from the text heap.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_USE_MODULE_TEXT)
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
void up_module_text_free(FAR void *p);
|
void up_textheap_free(FAR void *p);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ struct elf_loadinfo_s
|
|||||||
uintptr_t textalloc; /* .text memory allocated when ELF file was loaded */
|
uintptr_t textalloc; /* .text memory allocated when ELF file was loaded */
|
||||||
uintptr_t dataalloc; /* .bss/.data memory allocated when ELF file was loaded */
|
uintptr_t dataalloc; /* .bss/.data memory allocated when ELF file was loaded */
|
||||||
size_t textsize; /* Size of the ELF .text memory allocation */
|
size_t textsize; /* Size of the ELF .text memory allocation */
|
||||||
#ifdef CONFIG_ARCH_USE_MODULE_TEXT
|
#ifdef CONFIG_ARCH_USE_TEXT_HEAP
|
||||||
size_t textalign; /* Necessary alignment of .text */
|
size_t textalign; /* Necessary alignment of .text */
|
||||||
#endif
|
#endif
|
||||||
size_t datasize; /* Size of the ELF .bss/.data memory allocation */
|
size_t datasize; /* Size of the ELF .bss/.data memory allocation */
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ config LIBC_MODLIB
|
|||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
select LIBC_ARCH_ELF
|
select LIBC_ARCH_ELF
|
||||||
select ARCH_USE_MODULE_TEXT if ARCH_HAVE_MODULE_TEXT
|
select ARCH_USE_TEXT_HEAP if ARCH_HAVE_TEXT_HEAP
|
||||||
|
|
||||||
menu "Module library configuration"
|
menu "Module library configuration"
|
||||||
depends on LIBC_MODLIB
|
depends on LIBC_MODLIB
|
||||||
|
|||||||
@@ -265,10 +265,10 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
|
|||||||
|
|
||||||
if (loadinfo->textsize > 0)
|
if (loadinfo->textsize > 0)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_ARCH_USE_MODULE_TEXT)
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
loadinfo->textalloc = (uintptr_t)
|
loadinfo->textalloc = (uintptr_t)
|
||||||
up_module_text_memalign(loadinfo->textalign,
|
up_textheap_memalign(loadinfo->textalign,
|
||||||
loadinfo->textsize);
|
loadinfo->textsize);
|
||||||
#else
|
#else
|
||||||
loadinfo->textalloc = (uintptr_t)lib_memalign(loadinfo->textalign,
|
loadinfo->textalloc = (uintptr_t)lib_memalign(loadinfo->textalign,
|
||||||
loadinfo->textsize);
|
loadinfo->textsize);
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ int modlib_unload(struct mod_loadinfo_s *loadinfo)
|
|||||||
|
|
||||||
if (loadinfo->textalloc != 0)
|
if (loadinfo->textalloc != 0)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_ARCH_USE_MODULE_TEXT)
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
up_module_text_free((FAR void *)loadinfo->textalloc);
|
up_textheap_free((FAR void *)loadinfo->textalloc);
|
||||||
#else
|
#else
|
||||||
lib_free((FAR void *)loadinfo->textalloc);
|
lib_free((FAR void *)loadinfo->textalloc);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1545,7 +1545,7 @@ config MODULE
|
|||||||
bool "Enable loadable OS modules"
|
bool "Enable loadable OS modules"
|
||||||
default n
|
default n
|
||||||
select LIBC_MODLIB
|
select LIBC_MODLIB
|
||||||
select ARCH_USE_MODULE_TEXT if ARCH_HAVE_MODULE_TEXT
|
select ARCH_USE_TEXT_HEAP if ARCH_HAVE_TEXT_HEAP
|
||||||
---help---
|
---help---
|
||||||
Enable support for loadable OS modules. Default: n
|
Enable support for loadable OS modules. Default: n
|
||||||
|
|
||||||
|
|||||||
@@ -572,8 +572,8 @@ void nx_start(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_USE_MODULE_TEXT
|
#ifdef CONFIG_ARCH_USE_TEXT_HEAP
|
||||||
up_module_text_init();
|
up_textheap_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_MM_IOB
|
#ifdef CONFIG_MM_IOB
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ int rmmod(FAR void *handle)
|
|||||||
* and nullify so that the memory cannot be freed again
|
* and nullify so that the memory cannot be freed again
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_USE_MODULE_TEXT)
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
up_module_text_free((FAR void *)modp->textalloc);
|
up_textheap_free((FAR void *)modp->textalloc);
|
||||||
#else
|
#else
|
||||||
kmm_free((FAR void *)modp->textalloc);
|
kmm_free((FAR void *)modp->textalloc);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user