summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-08-26 12:16:05 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-08-26 12:16:05 -0600
commitb6ed8d1bed845fdba8ba207776dc1f7b83de57fd (patch)
tree7a50c9cc92745c0f80b8557354a836020275328f
parent690fb7b9fb8bc38f97c38cd5a36140bd8efe7bd7 (diff)
downloadnuttx-b6ed8d1bed845fdba8ba207776dc1f7b83de57fd.tar.gz
nuttx-b6ed8d1bed845fdba8ba207776dc1f7b83de57fd.tar.bz2
nuttx-b6ed8d1bed845fdba8ba207776dc1f7b83de57fd.zip
Rename up_addrenv_assign() to up_addrenv_clone() and generalize its arguments so that can be used for other purposes
-rw-r--r--nuttx/Documentation/NuttxPortingGuide.html18
-rw-r--r--nuttx/arch/arm/src/armv7-a/arm_addrenv.c28
-rw-r--r--nuttx/arch/z80/src/z180/z180_mmu.c30
-rw-r--r--nuttx/binfmt/binfmt_execmodule.c13
-rw-r--r--nuttx/binfmt/elf.c8
-rw-r--r--nuttx/binfmt/nxflat.c6
-rw-r--r--nuttx/include/nuttx/addrenv.h5
-rw-r--r--nuttx/include/nuttx/arch.h20
8 files changed, 66 insertions, 62 deletions
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html
index ec36ac4d1..88155b8ca 100644
--- a/nuttx/Documentation/NuttxPortingGuide.html
+++ b/nuttx/Documentation/NuttxPortingGuide.html
@@ -112,7 +112,7 @@
<a href="#up_addrenv_vdata">4.4.4 <code>up_addrenv_vdata()</code></a></br>
<a href="#up_addrenv_select">4.4.5 <code>up_addrenv_select()</code></a></br>
<a href="#up_addrenv_restore">4.4.6 <code>up_addrenv_restore()</code></a></br>
- <a href="#up_addrenv_assign">4.4.7 <code>up_addrenv_assign()</code></a></br>
+ <a href="#up_addrenv_clone">4.4.7 <code>up_addrenv_clone()</code></a></br>
<a href="#up_addrenv_attach">4.4.8 <code>up_addrenv_attach()</code></a></br>
<a href="#up_addrenv_detach">4.4.9 <code>up_addrenv_detach()</code></a>
</ul>
@@ -2960,8 +2960,8 @@ VxWorks provides the following comparable interface:
Restore an address environment.
</li>
<li>
- <a href="#up_addrenv_assign">4.4.7 <code>up_addrenv_assign()</code></a>:
- Assign an address environment to a thread.
+ <a href="#up_addrenv_clone">4.4.7 <code>up_addrenv_clone()</code></a>:
+ Copy an address environment from one location to another.
</li>
</ul>
</li>
@@ -2969,7 +2969,7 @@ VxWorks provides the following comparable interface:
<p>
<b>Tasking Support</b>.
Other interfaces must be provided to support higher-level interfaces used by the NuttX tasking logic.
- These interfaces are* used by the functions in <code>sched/</code> and all operate on the task group which as been assigned an address environment by <code>up_addrenv_assign()</code>.
+ These interfaces are* used by the functions in <code>sched/</code> and all operate on the task group which as been assigned an address environment by <code>up_addrenv_clone()</code>.
</p>
<ul>
<li>
@@ -3108,19 +3108,19 @@ VxWorks provides the following comparable interface:
Zero (<code>OK</code>) on success; a negated <code>errno</code> value on failure.
</ul>
-<h3><a name="up_addrenv_assign">4.4.7 <code>up_addrenv_assign()</code></a></h3>
+<h3><a name="up_addrenv_clone">4.4.7 <code>up_addrenv_clone()</code></a></h3>
<p><b>Function Prototype</b>:<p>
<ul>
- <code>int up_addrenv_assign(FAR const group_addrenv_t *addrenv, FAR struct task_group_s *group);</code>
+ <code>int up_addrenv_clone(FAR const task_group_s *src, FAR struct task_group_s *dest);</code>
</ul>
<p><b>Description</b>:</p>
<ul>
- 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.
</ul>
<p><b>Input Parameters</b>:</p>
<ul>
- <li><code>addrenv</code>: The representation of the group address environment previously returned by <code>up_addrenv_create</code>.</li>
- <li><code>group</code>: The new task group to receive the address environment.</li>
+ <li><code>src</code>: The address environment to be copied.</li>
+ <li><code>dest</code>: The location to receive the copied address environment.</li>
</ul>
<p><b>Returned Value</b>:</p>
<ul>
diff --git a/nuttx/arch/arm/src/armv7-a/arm_addrenv.c b/nuttx/arch/arm/src/armv7-a/arm_addrenv.c
index ed3a249fd..a9e680619 100644
--- a/nuttx/arch/arm/src/armv7-a/arm_addrenv.c
+++ b/nuttx/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/nuttx/arch/z80/src/z180/z180_mmu.c b/nuttx/arch/z80/src/z180/z180_mmu.c
index c86c57a62..3aeb64468 100644
--- a/nuttx/arch/z80/src/z180/z180_mmu.c
+++ b/nuttx/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(addrenv && group->addrenv == NULL);
+ DEBUGASSERT(src && dest);
- /* 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/nuttx/binfmt/binfmt_execmodule.c b/nuttx/binfmt/binfmt_execmodule.c
index f415bccac..5d49acf74 100644
--- a/nuttx/binfmt/binfmt_execmodule.c
+++ b/nuttx/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/nuttx/binfmt/elf.c b/nuttx/binfmt/elf.c
index 98924a6a8..2cb18fe91 100644
--- a/nuttx/binfmt/elf.c
+++ b/nuttx/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 <gnutt@nuttx.org>
*
* 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/nuttx/binfmt/nxflat.c b/nuttx/binfmt/nxflat.c
index d225912e3..a839bbc07 100644
--- a/nuttx/binfmt/nxflat.c
+++ b/nuttx/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/nuttx/include/nuttx/addrenv.h b/nuttx/include/nuttx/addrenv.h
index 44c414f42..51bd79491 100644
--- a/nuttx/include/nuttx/addrenv.h
+++ b/nuttx/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/nuttx/include/nuttx/arch.h b/nuttx/include/nuttx/arch.h
index 34ec4730e..483ee8e94 100644
--- a/nuttx/include/nuttx/arch.h
+++ b/nuttx/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
/****************************************************************************