sched/addrenv: Remove up_addrenv_restore

The function is not relevant any longer, remove it. Also remove
save_addrenv_t, the parameter taken by up_addrenv_restore.

Implement addrenv_select() / addrenv_restore() to handle the temporary
instantiation of address environments, e.g. when a process is being
created.
This commit is contained in:
Ville Juven
2023-01-27 13:45:03 +02:00
committed by Xiang Xiao
parent 09e7987121
commit f4b82b6405
29 changed files with 213 additions and 424 deletions
+11 -10
View File
@@ -31,6 +31,7 @@
#include <debug.h>
#include <errno.h>
#include <nuttx/addrenv.h>
#include <nuttx/arch.h>
#include <nuttx/kmalloc.h>
#include <nuttx/sched.h>
@@ -110,13 +111,13 @@ static void exec_ctors(FAR void *arg)
*
****************************************************************************/
int exec_module(FAR const struct binary_s *binp,
int exec_module(FAR struct binary_s *binp,
FAR const char *filename, FAR char * const *argv,
FAR char * const *envp)
{
FAR struct task_tcb_s *tcb;
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
save_addrenv_t oldenv;
FAR struct arch_addrenv_s *addrenv = &binp->addrenv.addrenv;
FAR void *vheap;
#endif
FAR void *stackaddr = NULL;
@@ -164,14 +165,14 @@ int exec_module(FAR const struct binary_s *binp,
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
/* Instantiate the address environment containing the user heap */
ret = up_addrenv_select(&binp->addrenv, &oldenv);
ret = addrenv_select(&binp->addrenv);
if (ret < 0)
{
berr("ERROR: up_addrenv_select() failed: %d\n", ret);
berr("ERROR: addrenv_select() failed: %d\n", ret);
goto errout_with_envp;
}
ret = up_addrenv_vheap(&binp->addrenv, &vheap);
ret = up_addrenv_vheap(addrenv, &vheap);
if (ret < 0)
{
berr("ERROR: up_addrenv_vheap() failed: %d\n", ret);
@@ -179,8 +180,8 @@ int exec_module(FAR const struct binary_s *binp,
}
binfo("Initialize the user heap (heapsize=%zu)\n",
up_addrenv_heapsize(&binp->addrenv));
umm_initialize(vheap, up_addrenv_heapsize(&binp->addrenv));
up_addrenv_heapsize(addrenv));
umm_initialize(vheap, up_addrenv_heapsize(addrenv));
#endif
/* Note that tcb->flags are not modified. 0=normal task */
@@ -272,10 +273,10 @@ int exec_module(FAR const struct binary_s *binp,
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
/* Restore the address environment of the caller */
ret = up_addrenv_restore(&oldenv);
ret = addrenv_restore();
if (ret < 0)
{
berr("ERROR: up_addrenv_restore() failed: %d\n", ret);
berr("ERROR: addrenv_restore() failed: %d\n", ret);
goto errout_with_tcbinit;
}
#endif
@@ -291,7 +292,7 @@ errout_with_tcbinit:
errout_with_addrenv:
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
up_addrenv_restore(&oldenv);
addrenv_restore();
errout_with_envp:
#endif
binfmt_freeenv(envp);