mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
UMM: Implement getter for address environment heap start vaddr
Using the Kconfig macro does not work for RISC-V target, as there the user heap follows .data/.bss and does not obey any Kconfig provided boundary. Added stubs for ARM and Z80 also.
This commit is contained in:
@@ -447,6 +447,33 @@ int up_addrenv_vdata(group_addrenv_t *addrenv, uintptr_t textsize,
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_addrenv_vheap
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Return the heap virtual address associated with the newly created
|
||||||
|
* address environment. This function is used by the binary loaders in
|
||||||
|
* order get an address that can be used to initialize the new task.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* addrenv - The representation of the task address environment previously
|
||||||
|
* returned by up_addrenv_create.
|
||||||
|
* vheap - The location to return the virtual address.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_BUILD_KERNEL
|
||||||
|
int up_addrenv_vheap(const group_addrenv_t *addrenv, void **vheap)
|
||||||
|
{
|
||||||
|
DEBUGASSERT(addrenv && vheap);
|
||||||
|
*vheap = (void *)CONFIG_ARCH_HEAP_VBASE;
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_addrenv_heapsize
|
* Name: up_addrenv_heapsize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -590,6 +590,33 @@ int up_addrenv_vdata(group_addrenv_t *addrenv, uintptr_t textsize,
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_addrenv_vheap
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Return the heap virtual address associated with the newly created
|
||||||
|
* address environment. This function is used by the binary loaders in
|
||||||
|
* order get an address that can be used to initialize the new task.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* addrenv - The representation of the task address environment previously
|
||||||
|
* returned by up_addrenv_create.
|
||||||
|
* vheap - The location to return the virtual address.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_BUILD_KERNEL
|
||||||
|
int up_addrenv_vheap(const group_addrenv_t *addrenv, void **vheap)
|
||||||
|
{
|
||||||
|
DEBUGASSERT(addrenv && vheap);
|
||||||
|
*vheap = (void *)addrenv->heapvbase;
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_addrenv_heapsize
|
* Name: up_addrenv_heapsize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -375,6 +375,33 @@ int up_addrenv_vdata(FAR group_addrenv_t *addrenv, uintptr_t textsize,
|
|||||||
return CONFIG_Z180_COMMON1AREA_VIRTBASE + textsize;
|
return CONFIG_Z180_COMMON1AREA_VIRTBASE + textsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_addrenv_vheap
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Return the heap virtual address associated with the newly created
|
||||||
|
* address environment. This function is used by the binary loaders in
|
||||||
|
* order get an address that can be used to initialize the new task.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* addrenv - The representation of the task address environment previously
|
||||||
|
* returned by up_addrenv_create.
|
||||||
|
* vheap - The location to return the virtual address.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_BUILD_KERNEL
|
||||||
|
int up_addrenv_vheap(FAR const group_addrenv_t *addrenv, FAR void **vheap)
|
||||||
|
{
|
||||||
|
/* Not implemented */
|
||||||
|
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_addrenv_heapsize
|
* Name: up_addrenv_heapsize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ int exec_module(FAR const struct binary_s *binp,
|
|||||||
FAR struct task_tcb_s *tcb;
|
FAR struct task_tcb_s *tcb;
|
||||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
||||||
save_addrenv_t oldenv;
|
save_addrenv_t oldenv;
|
||||||
|
FAR void *vheap;
|
||||||
#endif
|
#endif
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -173,8 +174,15 @@ int exec_module(FAR const struct binary_s *binp,
|
|||||||
goto errout_with_envp;
|
goto errout_with_envp;
|
||||||
}
|
}
|
||||||
|
|
||||||
binfo("Initialize the user heap (heapsize=%d)\n", binp->addrenv.heapsize);
|
ret = up_addrenv_vheap(&binp->addrenv, &vheap);
|
||||||
umm_initialize((FAR void *)CONFIG_ARCH_HEAP_VBASE, binp->addrenv.heapsize);
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
berr("ERROR: up_addrenv_vheap() failed: %d\n", ret);
|
||||||
|
goto errout_with_addrenv;
|
||||||
|
}
|
||||||
|
|
||||||
|
binfo("Initialize the user heap (heapsize=%zu)\n", binp->addrenv.heapsize);
|
||||||
|
umm_initialize(vheap, up_addrenv_heapsize(&binp->addrenv));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Note that tcb->flags are not modified. 0=normal task */
|
/* Note that tcb->flags are not modified. 0=normal task */
|
||||||
|
|||||||
@@ -283,6 +283,8 @@ struct addrenv_reserve_s
|
|||||||
* address environment
|
* address environment
|
||||||
* up_addrenv_vdata - Returns the virtual base address of the .bss/.data
|
* up_addrenv_vdata - Returns the virtual base address of the .bss/.data
|
||||||
* address environment
|
* address environment
|
||||||
|
* up_addrenv_vheap - Returns the virtual base address of the heap
|
||||||
|
* address environment
|
||||||
* up_addrenv_heapsize - Returns the size of the initial heap allocation.
|
* up_addrenv_heapsize - Returns the size of the initial heap allocation.
|
||||||
* up_addrenv_select - Instantiate an address environment
|
* up_addrenv_select - Instantiate an address environment
|
||||||
* up_addrenv_restore - Restore an address environment
|
* up_addrenv_restore - Restore an address environment
|
||||||
|
|||||||
@@ -831,6 +831,8 @@ void up_textheap_free(FAR void *p);
|
|||||||
* address environment
|
* address environment
|
||||||
* up_addrenv_vdata - Returns the virtual base address of the .bss/.data
|
* up_addrenv_vdata - Returns the virtual base address of the .bss/.data
|
||||||
* address environment
|
* address environment
|
||||||
|
* up_addrenv_vheap - Returns the virtual base address of the heap
|
||||||
|
* address environment
|
||||||
* up_addrenv_heapsize - Returns the size of the initial heap allocation.
|
* up_addrenv_heapsize - Returns the size of the initial heap allocation.
|
||||||
* up_addrenv_select - Instantiate an address environment
|
* up_addrenv_select - Instantiate an address environment
|
||||||
* up_addrenv_restore - Restore an address environment
|
* up_addrenv_restore - Restore an address environment
|
||||||
@@ -992,6 +994,28 @@ int up_addrenv_vdata(FAR group_addrenv_t *addrenv, uintptr_t textsize,
|
|||||||
FAR void **vdata);
|
FAR void **vdata);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_addrenv_vheap
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Return the heap virtual address associated with the newly created
|
||||||
|
* address environment. This function is used by the binary loaders in
|
||||||
|
* order get an address that can be used to initialize the new task.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* addrenv - The representation of the task address environment previously
|
||||||
|
* returned by up_addrenv_create.
|
||||||
|
* vheap - The location to return the virtual address.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
||||||
|
int up_addrenv_vheap(FAR const group_addrenv_t *addrenv, FAR void **vheap);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_addrenv_heapsize
|
* Name: up_addrenv_heapsize
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user