diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html
index ec36ac4d11..88155b8cad 100644
--- a/Documentation/NuttxPortingGuide.html
+++ b/Documentation/NuttxPortingGuide.html
@@ -112,7 +112,7 @@
4.4.4 up_addrenv_vdata()
4.4.5 up_addrenv_select()
4.4.6 up_addrenv_restore()
- 4.4.7 up_addrenv_assign()
+ 4.4.7 up_addrenv_clone()
4.4.8 up_addrenv_attach()
4.4.9 up_addrenv_detach()
@@ -2960,8 +2960,8 @@ VxWorks provides the following comparable interface:
Restore an address environment.
- 4.4.7 up_addrenv_assign()
:
- Assign an address environment to a thread.
+ 4.4.7 up_addrenv_clone()
:
+ Copy an address environment from one location to another.
@@ -2969,7 +2969,7 @@ VxWorks provides the following comparable interface:
Tasking Support.
Other interfaces must be provided to support higher-level interfaces used by the NuttX tasking logic.
- These interfaces are* used by the functions in sched/
and all operate on the task group which as been assigned an address environment by up_addrenv_assign()
.
+ These interfaces are* used by the functions in sched/
and all operate on the task group which as been assigned an address environment by up_addrenv_clone()
.
-
@@ -3108,19 +3108,19 @@ VxWorks provides the following comparable interface:
Zero (
OK
) on success; a negated errno
value on failure.
-
+
Function Prototype:
- int up_addrenv_assign(FAR const group_addrenv_t *addrenv, FAR struct task_group_s *group);
+ int up_addrenv_clone(FAR const task_group_s *src, FAR struct task_group_s *dest);
Description:
- Assign an address environment to a new task group.
+ Duplicate an address environment. This does not copy the underlying memory, only the representation that can be used to instantiate that memory as an address environment.
Input Parameters:
- addrenv
: The representation of the group address environment previously returned by up_addrenv_create
.
- group
: The new task group to receive the address environment.
+ src
: The address environment to be copied.
+ dest
: The location to receive the copied address environment.
Returned Value:
diff --git a/arch/arm/src/armv7-a/arm_addrenv.c b/arch/arm/src/armv7-a/arm_addrenv.c
index ed3a249fdc..a9e6806192 100644
--- a/arch/arm/src/armv7-a/arm_addrenv.c
+++ b/arch/arm/src/armv7-a/arm_addrenv.c
@@ -48,11 +48,12 @@
* address environment
* up_addrenv_select - Instantiate an address environment
* up_addrenv_restore - Restore an address environment
- * up_addrenv_assign - Assign an address environment to a group
+ * up_addrenv_clone - Copy an address environment from one location to
+ * another.
*
* Higher-level interfaces used by the tasking logic. These interfaces are
* used by the functions in sched/ and all operate on the thread which whose
- * group been assigned an address environment by up_addrenv_assign().
+ * group been assigned an address environment by up_addrenv_clone().
*
* up_addrenv_attach - Clone the address environment assigned to one TCB
* to another. This operation is done when a pthread
@@ -661,30 +662,31 @@ int up_addrenv_restore(FAR const save_addrenv_t *oldenv)
}
/****************************************************************************
- * Name: up_addrenv_assign
+ * Name: up_addrenv_clone
*
* Description:
- * Assign an address environment to a new task group.
+ * Duplicate an address environment. This does not copy the underlying
+ * memory, only the representation that can be used to instantiate that
+ * memory as an address environment.
*
* Input Parameters:
- * addrenv - The representation of the task address environment previously
- * returned by up_addrenv_create().
- * group - The new task group to receive the address environment.
+ * src - The address environment to be copied.
+ * dest - The location to receive the copied address environment.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int up_addrenv_assign(FAR const group_addrenv_t *addrenv,
- FAR struct task_group_s *group)
+int up_addrenv_clone(FAR const group_addrenv_t *src,
+ FAR group_addrenv_t *dest)
{
- DEBUGASSERT(addrenv && group);
- bvdbg("addrenv=%p group->addrenv=%p\n", addrenv, &group->addrenv);
+ bvdbg("src=%p dest=%p\n", src, dest);
+ DEBUGASSERT(src && dest);
- /* Just copy the address environment into the group */
+ /* Just copy the address environment from the source to the destination */
- memcpy(&group->addrenv, addrenv, sizeof(group_addrenv_t));
+ memcpy(dest, src, sizeof(group_addrenv_t));
return OK;
}
diff --git a/arch/z80/src/z180/z180_mmu.c b/arch/z80/src/z180/z180_mmu.c
index c86c57a62c..3aeb644688 100644
--- a/arch/z80/src/z180/z180_mmu.c
+++ b/arch/z80/src/z180/z180_mmu.c
@@ -192,11 +192,12 @@ return g_physhandle ? OK : -ENOMEM;
* address environment
* up_addrenv_select - Instantiate an address environment
* up_addrenv_restore - Restore an address environment
- * up_addrenv_assign - Assign an address environment to a group
+ * up_addrenv_clone - Copy an address environment from one location to
+ * another.
*
* Higher-level interfaces used by the tasking logic. These interfaces are
* used by the functions in sched/ and all operate on the thread which whose
- * group been assigned an address environment by up_addrenv_assign().
+ * group been assigned an address environment by up_addrenv_clone().
*
* up_addrenv_attach - Clone the address environment assigned to one TCB
* to another. This operation is done when a pthread
@@ -457,33 +458,32 @@ int up_addrenv_restore(FAR const save_addrenv_t *oldenv)
}
/****************************************************************************
- * Name: up_addrenv_assign
+ * Name: up_addrenv_clone
*
* Description:
- * Assign an address environment to a task group.
+ * Duplicate an address environment. This does not copy the underlying
+ * memory, only the representation that can be used to instantiate that
+ * memory as an address environment.
*
* Input Parameters:
- * addrenv - The representation of the task address environment previously
- * returned by up_addrenv_create().
- * group - The task group to receive the address environment.
+ * src - The address environment to be copied.
+ * dest - The location to receive the copied address environment.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int up_addrenv_assign(FAR const group_addrenv_t *addrenv,
- FAR struct task_group_s *group)
+int up_addrenv_clone(FAR const group_addrenv_t *src,
+ FAR group_addrenv_t *dest);
{
- /* Make sure that there is no address environment in place on this TCB */
+ DEBUGASSERT(src && dest);
- DEBUGASSERT(addrenv && group->addrenv == NULL);
-
- /* Save the CBR structure in the group. This is an atomic operation so no
- * special precautions should be needed.
+ /* Copy the CBR structure. This is an atomic operation so no special
+ * precautions should be needed.
*/
- group->addrenv = *addrenv;
+ *dest = *src;
return OK;
}
diff --git a/binfmt/binfmt_execmodule.c b/binfmt/binfmt_execmodule.c
index f415bccacb..5d49acf747 100644
--- a/binfmt/binfmt_execmodule.c
+++ b/binfmt/binfmt_execmodule.c
@@ -163,9 +163,9 @@ int exec_module(FAR const struct binary_s *binp)
goto errout;
}
+#ifndef CONFIG_CUSTOM_STACK
/* Allocate the stack for the new task (always from the user heap) */
-#ifndef CONFIG_CUSTOM_STACK
stack = (FAR uint32_t*)kumalloc(binp->stacksize);
if (!tcb)
{
@@ -193,11 +193,11 @@ int exec_module(FAR const struct binary_s *binp)
/* Note that tcb->flags are not modified. 0=normal task */
/* tcb->flags |= TCB_FLAG_TTYPE_TASK; */
+#ifdef CONFIG_PIC
/* Add the D-Space address as the PIC base address. By convention, this
* must be the first allocated address space.
*/
-#ifdef CONFIG_PIC
tcb->cmn.dspace = binp->alloc[0];
/* Re-initialize the task's initial state to account for the new PIC base */
@@ -205,24 +205,24 @@ int exec_module(FAR const struct binary_s *binp)
up_initial_state(&tcb->cmn);
#endif
+#ifdef CONFIG_ARCH_ADDRENV
/* Assign the address environment to the new task group */
-#ifdef CONFIG_ARCH_ADDRENV
- ret = up_addrenv_assign(&binp->addrenv, tcb->cmn.group);
+ ret = up_addrenv_clone(&binp->addrenv, &tcb->cmn.group->addrenv);
if (ret < 0)
{
err = -ret;
- bdbg("ERROR: up_addrenv_assign() failed: %d\n", ret);
+ bdbg("ERROR: up_addrenv_clone() failed: %d\n", ret);
goto errout_with_stack;
}
#endif
+#ifdef CONFIG_BINFMT_CONSTRUCTORS
/* Setup a start hook that will execute all of the C++ static constructors
* on the newly created thread. The struct binary_s must persist at least
* until the new task has been started.
*/
-#ifdef CONFIG_BINFMT_CONSTRUCTORS
task_starthook(tcb, exec_ctors, (FAR void *)binp);
#endif
@@ -261,4 +261,3 @@ errout:
}
#endif /* CONFIG_BINFMT_DISABLE */
-
diff --git a/binfmt/elf.c b/binfmt/elf.c
index 98924a6a8c..2cb18fe919 100644
--- a/binfmt/elf.c
+++ b/binfmt/elf.c
@@ -1,7 +1,7 @@
/****************************************************************************
* binfmt/elf.c
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -294,11 +294,11 @@ static int elf_loadbinary(FAR struct binary_s *binp)
#endif
#ifdef CONFIG_ARCH_ADDRENV
- /* Save the address environment. This will be needed when the module is
- * executed for the up_addrenv_assign() call.
+ /* Save the address environment in the binfmt structure. This will be
+ * needed when the module is executed.
*/
- binp->addrenv = loadinfo.addrenv;
+ up_addrenv_clone(&loadinfo.addrenv, &binp->addrenv);
#endif
elf_dumpentrypt(binp, &loadinfo);
diff --git a/binfmt/nxflat.c b/binfmt/nxflat.c
index d225912e3f..a839bbc07c 100644
--- a/binfmt/nxflat.c
+++ b/binfmt/nxflat.c
@@ -206,11 +206,11 @@ static int nxflat_loadbinary(struct binary_s *binp)
#endif
#ifdef CONFIG_ARCH_ADDRENV
- /* Save the address environment. This will be needed when the module is
- * executed for the up_addrenv_assign() call.
+ /* Save the address environment in the binfmt structure. This will be
+ * needed when the module is executed.
*/
- binp->addrenv = loadinfo.addrenv;
+ up_addrenv_clone(&loadinfo.addrenv, &binp->addrenv);
#endif
nxflat_dumpbuffer("Entry code", (FAR const uint8_t*)binp->entrypt,
diff --git a/include/nuttx/addrenv.h b/include/nuttx/addrenv.h
index 44c414f42c..51bd794918 100644
--- a/include/nuttx/addrenv.h
+++ b/include/nuttx/addrenv.h
@@ -162,11 +162,12 @@
* address environment
* up_addrenv_select - Instantiate an address environment
* up_addrenv_restore - Restore an address environment
- * up_addrenv_assign - Assign an address environment to a group
+ * up_addrenv_clone - Copy an address environment from one location to
+ * another.
*
* Higher-level interfaces used by the tasking logic. These interfaces are
* used by the functions in sched/ and all operate on the thread which whose
- * group been assigned an address environment by up_addrenv_assign().
+ * group been assigned an address environment by up_addrenv_clone().
*
* up_addrenv_attach - Clone the address environment assigned to one TCB
* to another. This operation is done when a pthread
diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h
index 34ec4730e3..483ee8e94d 100644
--- a/include/nuttx/arch.h
+++ b/include/nuttx/arch.h
@@ -696,11 +696,12 @@ void up_allocate_pgheap(FAR void **heap_start, size_t *heap_size);
* address environment
* up_addrenv_select - Instantiate an address environment
* up_addrenv_restore - Restore an address environment
- * up_addrenv_assign - Assign an address environment to a group
+ * up_addrenv_clone - Copy an address environment from one location to
+ * another.
*
* Higher-level interfaces used by the tasking logic. These interfaces are
* used by the functions in sched/ and all operate on the thread which whose
- * group been assigned an address environment by up_addrenv_assign().
+ * group been assigned an address environment by up_addrenv_clone().
*
* up_addrenv_attach - Clone the address environment assigned to one TCB
* to another. This operation is done when a pthread
@@ -858,15 +859,16 @@ int up_addrenv_restore(FAR const save_addrenv_t *oldenv);
#endif
/****************************************************************************
- * Name: up_addrenv_assign
+ * Name: up_addrenv_clone
*
* Description:
- * Assign an address environment to a new task group.
+ * Duplicate an address environment. This does not copy the underlying
+ * memory, only the representation that can be used to instantiate that
+ * memory as an address environment.
*
* Input Parameters:
- * addrenv - The representation of the task address environment previously
- * returned by up_addrenv_create().
- * group - The new task group to receive the address environment.
+ * src - The address environment to be copied.
+ * dest - The location to receive the copied address environment.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
@@ -874,8 +876,8 @@ int up_addrenv_restore(FAR const save_addrenv_t *oldenv);
****************************************************************************/
#ifdef CONFIG_ARCH_ADDRENV
-int up_addrenv_assign(FAR const group_addrenv_t *addrenv,
- FAR struct task_group_s *group);
+int up_addrenv_clone(FAR const group_addrenv_t *src,
+ FAR group_addrenv_t *dest);
#endif
/****************************************************************************