Rename up_addrenv_assign() to up_addrenv_clone() and generalize its arguments so that can be used for other purposes
This commit is contained in:
parent
a14cb94b45
commit
b13d9b4161
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user