arch: cxd56xx: Fix address mapping in cxd56_modtext.c

Summary:
- I noticed that DEBUGASSERTION() happens when executing
  an ELF application
- This commit fixes this issue by re-mapping the address
  to SYSBUS in up_module_text_free()

Impact:
- None

Testing:
- Tested with spresense (both DEBUG_ASSERTIONS=n and y)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa 2021-06-04 10:54:46 +09:00 committed by Xiang Xiao
parent 304d72ed00
commit 386946ee54

View File

@ -33,6 +33,12 @@
#include <nuttx/arch.h>
#include <nuttx/kmalloc.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define SYSBUS_ADDRESS_OFFSET 0x20000000
/****************************************************************************
* Public Functions
****************************************************************************/
@ -55,7 +61,19 @@ FAR void *up_module_text_memalign(size_t align, size_t size)
ret = (FAR void *)kmm_malloc(size);
#ifdef CONFIG_CXD56_USE_SYSBUS
ret -= 0x20000000;
if (ret)
{
binfo("** ret=%p \n", ret);
/* NOTE:
* kmm_malloc() will return the address in SYSBUS.
* So convert the address to I/D BUS.
*/
ret -= SYSBUS_ADDRESS_OFFSET;
binfo("** mapped to %p \n", ret);
}
#endif
return ret;
@ -67,5 +85,21 @@ FAR void *up_module_text_memalign(size_t align, size_t size)
void up_module_text_free(FAR void *p)
{
#ifdef CONFIG_CXD56_USE_SYSBUS
if (p)
{
binfo("** p=%p \n", p);
/* NOTE:
* The address p will be in I/D BUS.
* So convert the address to SYSBUS.
*/
p += SYSBUS_ADDRESS_OFFSET;
binfo("** mapped to %p \n", p);
}
#endif
kmm_free(p);
}