Add the initial implementation of the process kernel stack logic. Not yet integrated into the main OS logic nor tested.
This commit is contained in:
parent
6fd14f0e21
commit
3d0f6aca5d
@ -12,7 +12,7 @@
|
||||
<h1><big><font color="#3c34ec">
|
||||
<i>NuttX RTOS Porting Guide</i>
|
||||
</font></big></h1>
|
||||
<p>Last Updated: September 13, 2014</p>
|
||||
<p>Last Updated: September 14, 2014</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -119,7 +119,9 @@
|
||||
<a href="#up_addrenv_ustackalloc">4.4.11 <code>up_addrenv_ustackalloc()</code></a></br>
|
||||
<a href="#up_addrenv_ustackfree">4.4.12 <code>up_addrenv_ustackfree()</code></a></br>
|
||||
<a href="#up_addrenv_vustack">4.4.13 <code>up_addrenv_vustack()</code></a></br>
|
||||
<a href="#up_addrenv_ustackselect">4.4.14 <code>up_addrenv_ustackselect()</code></a>
|
||||
<a href="#up_addrenv_ustackselect">4.4.14 <code>up_addrenv_ustackselect()</code></a></br>
|
||||
<a href="#up_addrenv_kstackalloc">4.4.15 <code>up_addrenv_kstackalloc()</code></a></br>
|
||||
<a href="#up_addrenv_kstackfree">4.4.16 <code>up_addrenv_kstackfree()</code></a>
|
||||
</ul>
|
||||
<a href="#exports">4.5 APIs Exported by NuttX to Architecture-Specific Logic</a>
|
||||
<ul>
|
||||
@ -2987,15 +2989,36 @@ VxWorks provides the following comparable interface:
|
||||
<li>
|
||||
<a href="#up_addrenv_ustackalloc">4.4.11 <code>up_addrenv_ustackalloc()</code></a>:
|
||||
Create a stack address environment
|
||||
</li>
|
||||
<li>
|
||||
<a href="#up_addrenv_ustackfree">4.4.12 <code>up_addrenv_ustackfree()</code></a>:
|
||||
Destroy a stack address environment.
|
||||
</li>
|
||||
<li>
|
||||
<a href="#up_addrenv_vustack">4.4.13 <code>up_addrenv_vustack()</code></a>:
|
||||
Returns the virtual base address of the stack
|
||||
</li>
|
||||
<li>
|
||||
<a href="#up_addrenv_ustackselect">4.4.14 <code>up_addrenv_ustackselect()</code></a>:
|
||||
Instantiate a stack address environment
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
If <code>CONFIG_ARCH_KERNEL_STACK</code> is selected, then each user process will have two stacks: (1) a large (and possibly dynamic) user stack and (2) a smaller kernel stack. However, this option is <i>required</i> if both <code>CONFIG_BUILD_KERNEL</code> and <code>CONFIG_LIBC_EXECFUNCS</code> are selected. Why? Because when we instantiate and initialize the address environment of the new user process, we will temporarily lose the address environment of the old user process, including its stack contents. The kernel C logic will crash immediately with no valid stack in place.
|
||||
</p>
|
||||
<p>
|
||||
If <code>CONFIG_ARCH_KERNEL_STACK=y</code> is selected then the platform specific code must export these additional interfaces:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#up_addrenv_kstackalloc">4.4.15 <code>up_addrenv_kstackalloc()</code></a>:
|
||||
Allocate the process kernel stack.
|
||||
</li>
|
||||
<a href="#up_addrenv_kstackfree">4.4.16 <code>up_addrenv_kstackfree()</code></a>:
|
||||
Free the process kernel stack.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ol>
|
||||
@ -3294,6 +3317,47 @@ 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_kstackalloc">4.4.15 <code>up_addrenv_kstackalloc()</code></a></h3>
|
||||
<p><b>Function Prototype</b>:<p>
|
||||
<ul>
|
||||
<code>int up_addrenv_kstackalloc(FAR struct tcb_s *tcb, size_t stacksize);</code>
|
||||
</ul>
|
||||
<p><b>Description</b>:</p>
|
||||
<ul>
|
||||
<p>
|
||||
This function is called when a new thread is created to allocate the new thread's kernel stack.
|
||||
</p>
|
||||
</ul>
|
||||
<p><b>Input Parameters</b>:</p>
|
||||
<ul>
|
||||
<li><code>tcb</code>: The TCB of the thread that requires the kernel stack.</li>
|
||||
<li><code>stacksize</code>: The size (in bytes) of the kernel stack needed by the thread.</li>
|
||||
</ul>
|
||||
<p><b>Returned Value</b>:</p>
|
||||
<ul>
|
||||
Zero (<code>OK</code>) on success; a negated <code>errno</code> value on failure.
|
||||
</ul>
|
||||
|
||||
<h3><a name="up_addrenv_kstackfree">4.4.16 <code>up_addrenv_kstackfree()</code></a></h3>
|
||||
<p><b>Function Prototype</b>:<p>
|
||||
<ul>
|
||||
<code>int up_addrenv_kstackfree(FAR struct tcb_s *tcb);</code>
|
||||
</ul>
|
||||
<p><b>Description</b>:</p>
|
||||
<ul>
|
||||
<p>
|
||||
This function is called when any thread exits. This function frees the kernel stack.
|
||||
</p>
|
||||
</ul>
|
||||
<p><b>Input Parameters</b>:</p>
|
||||
<ul>
|
||||
<li><code>tcb</code>: The TCB of the thread that no longer requires the kernel stack.</li>
|
||||
</ul>
|
||||
<p><b>Returned Value</b>:</p>
|
||||
<ul>
|
||||
Zero (<code>OK</code>) on success; a negated <code>errno</code> value on failure.
|
||||
</ul>
|
||||
|
||||
<h2><a name="exports">4.5 APIs Exported by NuttX to Architecture-Specific Logic</a></h2>
|
||||
<p>
|
||||
These are standard interfaces that are exported by the OS
|
||||
|
Loading…
Reference in New Issue
Block a user