| <!-- |
| Documentation/_templates/layout.html |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. The |
| ASF licenses this file to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance with the |
| License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| License for the specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| |
| |
| <!DOCTYPE html> |
| <html class="writer-html5" lang="en" > |
| <head> |
| <meta charset="utf-8"> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| |
| <title>Address Environments — NuttX latest documentation</title> |
| |
| |
| |
| <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> |
| <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> |
| <link rel="stylesheet" href="../../_static/sphinx_tabs/semantic-ui-2.4.1/segment.min.css" type="text/css" /> |
| <link rel="stylesheet" href="../../_static/sphinx_tabs/semantic-ui-2.4.1/menu.min.css" type="text/css" /> |
| <link rel="stylesheet" href="../../_static/sphinx_tabs/semantic-ui-2.4.1/tab.min.css" type="text/css" /> |
| <link rel="stylesheet" href="../../_static/sphinx_tabs/tabs.css" type="text/css" /> |
| <link rel="stylesheet" href="../../_static/custom.css" type="text/css" /> |
| |
| |
| |
| <link rel="shortcut icon" href="../../_static/favicon.ico"/> |
| |
| |
| |
| |
| |
| <!--[if lt IE 9]> |
| <script src="../../_static/js/html5shiv.min.js"></script> |
| <![endif]--> |
| |
| |
| <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script> |
| <script src="../../_static/jquery.js"></script> |
| <script src="../../_static/underscore.js"></script> |
| <script src="../../_static/doctools.js"></script> |
| <script src="../../_static/language_data.js"></script> |
| |
| <script type="text/javascript" src="../../_static/js/theme.js"></script> |
| |
| |
| <link rel="index" title="Index" href="../../genindex.html" /> |
| <link rel="search" title="Search" href="../../search.html" /> |
| <link rel="next" title="APIs Exported by NuttX to Architecture-Specific Logic" href="nuttx.html" /> |
| <link rel="prev" title="Work Queues" href="wqueue.html" /> |
| </head> |
| |
| <body class="wy-body-for-nav"> |
| |
| |
| <div class="wy-grid-for-nav"> |
| |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| <div class="wy-side-scroll"> |
| <div class="wy-side-nav-search" > |
| |
| |
| <a href="../../index.html" class="icon icon-home"> NuttX |
| |
| |
| |
| |
| <img src="../../_static/NuttX.png" class="logo" alt="Logo"/> |
| |
| </a> |
| |
| <!-- this version selector is quite ugly, should be probably replaced by something |
| more modern --> |
| |
| <div class="version-selector"> |
| <select> |
| |
| <option value="latest" selected="selected">latest</option> |
| |
| </select> |
| </div> |
| |
| |
| <div role="search"> |
| <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get"> |
| <input type="text" name="q" placeholder="Search docs" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| |
| </div> |
| |
| |
| <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
| |
| |
| |
| |
| |
| |
| <p class="caption"><span class="caption-text">Table of Contents</span></p> |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="../../index.html">Home</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../introduction/index.html">Introduction</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../introduction/inviolables.html">The Inviolable Principles of NuttX</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../quickstart/index.html">Getting Started</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../components/index.html">OS Components</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../applications/index.html">Applications</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../boards/index.html">Supported Boards</a></li> |
| <li class="toctree-l1 current"><a class="reference internal" href="../index.html">API Reference</a><ul class="current"> |
| <li class="toctree-l2"><a class="reference internal" href="../user/index.html">Userspace API</a></li> |
| <li class="toctree-l2 current"><a class="reference internal" href="index.html">Architecture APIs</a><ul class="current"> |
| <li class="toctree-l3"><a class="reference internal" href="conventions.html">Naming and Header File Conventions</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="arch.html">APIs Exported by Architecture-Specific Logic to NuttX</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="board.html">APIs Exported by Board-Specific Logic to NuttX</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="time_clock.html">System Time and Clock</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="wqueue.html">Work Queues</a></li> |
| <li class="toctree-l3 current"><a class="current reference internal" href="#">Address Environments</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="nuttx.html">APIs Exported by NuttX to Architecture-Specific Logic</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="app_vs_os.html">Application OS vs. Internal OS Interfaces</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="boardctl.html"><code class="docutils literal notranslate"><span class="pre">boardctl()</span></code> Application Interface</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="smp.html">Symmetric Multiprocessing (SMP) Application</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="shm.html">Shared Memory</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="paging.html">On-Demand Paging</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="led.html">LED Support</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="iob.html">I/O Buffer Management</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference internal" href="../../guides/index.html">Guides</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../releases/index.html">Releases</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../contributing/index.html">Contributing</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li> |
| </ul> |
| |
| |
| |
| </div> |
| |
| </div> |
| </nav> |
| |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
| |
| |
| <nav class="wy-nav-top" aria-label="top navigation"> |
| |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| <a href="../../index.html">NuttX</a> |
| |
| </nav> |
| |
| |
| <div class="wy-nav-content"> |
| |
| <div class="rst-content"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <div role="navigation" aria-label="breadcrumbs navigation"> |
| |
| <ul class="wy-breadcrumbs"> |
| |
| <li><a href="../../index.html" class="icon icon-home"></a> »</li> |
| |
| <li><a href="../index.html">API Reference</a> »</li> |
| |
| <li><a href="index.html">Architecture APIs</a> »</li> |
| |
| <li>Address Environments</li> |
| |
| |
| <li class="wy-breadcrumbs-aside"> |
| |
| |
| <a href="../../_sources/reference/os/addrenv.rst.txt" rel="nofollow"> View page source</a> |
| |
| |
| </li> |
| |
| </ul> |
| |
| |
| <hr/> |
| </div> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <div class="section" id="address-environments"> |
| <h1>Address Environments<a class="headerlink" href="#address-environments" title="Permalink to this headline">¶</a></h1> |
| <p>CPUs that support memory management units (MMUs) may provide |
| <em>address environments</em> within which tasks and their child threads |
| execute. The configuration indicates the CPUs ability to support |
| address environments by setting the configuration variable |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_ARCH_HAVE_ADDRENV=y</span></code>. That will enable the selection of |
| the actual address environment support which is indicated by the |
| selection of the configuration variable <code class="docutils literal notranslate"><span class="pre">CONFIG_ARCH_ADDRENV=y</span></code>. |
| These address environments are created only when tasks are created |
| via <code class="docutils literal notranslate"><span class="pre">exec()</span></code> or <code class="docutils literal notranslate"><span class="pre">exec_module()</span></code> (see |
| <code class="docutils literal notranslate"><span class="pre">include/nuttx/binfmt/binfmt.h</span></code>).</p> |
| <p>When <code class="docutils literal notranslate"><span class="pre">CONFIG_ARCH_ADDRENV=y</span></code> is set in the board configuration, |
| the CPU-specific logic must provide a set of interfaces as defined |
| in the header file <code class="docutils literal notranslate"><span class="pre">include/nuttx/arch.h</span></code>. These interfaces are |
| listed below and described in detail in the following paragraphs.</p> |
| <p>The CPU-specific logic must provide two categories in interfaces:</p> |
| <ol class="arabic"> |
| <li><p><strong>Binary Loader Support</strong>. These are low-level interfaces used |
| in <code class="docutils literal notranslate"><span class="pre">binfmt/</span></code> to instantiate tasks with address environments. |
| These interfaces all operate on type <code class="docutils literal notranslate"><span class="pre">group_addrenv_t</span></code> which |
| is an abstract representation of a task group’s address |
| environment and the type must be defined in<code class="docutils literal notranslate"><span class="pre">arch/arch.h</span></code> if |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_ARCH_ADDRENV</span></code> is defined. These low-level interfaces |
| include:</p> |
| <ul class="simple"> |
| <li><p><a class="reference internal" href="#c.up_addrenv_create" title="up_addrenv_create"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_create()</span></code></a>: Create an address environment.</p></li> |
| <li><p><a class="reference internal" href="#c.up_addrenv_destroy" title="up_addrenv_destroy"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_destroy()</span></code></a>: Destroy an address environment.</p></li> |
| <li><p><a class="reference internal" href="#c.up_addrenv_vtext" title="up_addrenv_vtext"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_vtext()</span></code></a>: Returns the virtual base address of the <code class="docutils literal notranslate"><span class="pre">.text</span></code> address environment.</p></li> |
| <li><p><a class="reference internal" href="#c.up_addrenv_vdata" title="up_addrenv_vdata"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_vdata()</span></code></a>: Returns the virtual base address of the <code class="docutils literal notranslate"><span class="pre">.bss</span></code>/<code class="docutils literal notranslate"><span class="pre">.data</span></code> address environment.</p></li> |
| <li><p><a class="reference internal" href="#c.up_addrenv_heapsize" title="up_addrenv_heapsize"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_heapsize()</span></code></a>: Return the initial heap size.</p></li> |
| <li><p><a class="reference internal" href="#c.up_addrenv_select" title="up_addrenv_select"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_select()</span></code></a>: Instantiate an address environment.</p></li> |
| <li><p><a class="reference internal" href="#c.up_addrenv_restore" title="up_addrenv_restore"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_restore()</span></code></a>: Restore an address environment.</p></li> |
| <li><p><a class="reference internal" href="#c.up_addrenv_clone" title="up_addrenv_clone"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_clone()</span></code></a>: Copy an address environment from one location to another.</p></li> |
| </ul> |
| </li> |
| <li><p><strong>Tasking Support</strong>. 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 class="docutils literal notranslate"><span class="pre">sched/</span></code> |
| and all operate on the task group which as been assigned an |
| address environment by <code class="docutils literal notranslate"><span class="pre">up_addrenv_clone()</span></code>.</p> |
| <ul class="simple"> |
| <li><p><a class="reference internal" href="#c.up_addrenv_attach" title="up_addrenv_attach"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_attach()</span></code></a>: Clone the group address environment assigned to a new |
| thread. This operation is done when a pthread is created |
| that share’s the same address environment.</p></li> |
| <li><p><a class="reference internal" href="#c.up_addrenv_detach" title="up_addrenv_detach"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_detach()</span></code></a>: Release the thread’s reference to a group address |
| environment when a task/thread exits.</p></li> |
| </ul> |
| </li> |
| <li><p><strong>Dynamic Stack Support</strong>. <code class="docutils literal notranslate"><span class="pre">CONFIG_ARCH_STACK_DYNAMIC=y</span></code> |
| indicates that the user process stack resides in its own |
| address space. This option is also <em>required</em> if |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_BUILD_KERNEL</span></code> and <code class="docutils literal notranslate"><span class="pre">CONFIG_LIBC_EXECFUNCS</span></code> are |
| selected. Why? Because the caller’s stack must be preserved in |
| its own address space when we instantiate the environment of |
| the new process in order to initialize it.</p> |
| <p><strong>NOTE:</strong> The naming of the <code class="docutils literal notranslate"><span class="pre">CONFIG_ARCH_STACK_DYNAMIC</span></code> |
| selection implies that dynamic stack allocation is supported. |
| Certainly this option must be set if dynamic stack allocation |
| is supported by a platform. But the more general meaning of |
| this configuration environment is simply that the stack has its |
| own address space.</p> |
| <p>If <code class="docutils literal notranslate"><span class="pre">CONFIG_ARCH_STACK_DYNAMIC=y</span></code> is selected then the |
| platform specific code must export these additional interfaces:</p> |
| <ul class="simple"> |
| <li><p><a class="reference internal" href="#c.up_addrenv_ustackalloc" title="up_addrenv_ustackalloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_ustackalloc()</span></code></a>: Create a stack address environment</p></li> |
| <li><p><a class="reference internal" href="#c.up_addrenv_ustackfree" title="up_addrenv_ustackfree"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_ustackfree()</span></code></a>: Destroy a stack address environment.</p></li> |
| <li><p><a class="reference internal" href="#c.up_addrenv_vustack" title="up_addrenv_vustack"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_vustack()</span></code></a>: Returns the virtual base address of the stack</p></li> |
| <li><p><a class="reference internal" href="#c.up_addrenv_ustackselect" title="up_addrenv_ustackselect"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_ustackselect()</span></code></a>: Instantiate a stack address environment</p></li> |
| </ul> |
| </li> |
| <li><p>If <code class="docutils literal notranslate"><span class="pre">CONFIG_ARCH_KERNEL_STACK</span></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 <em>required</em> if both <code class="docutils literal notranslate"><span class="pre">CONFIG_BUILD_KERNEL</span></code> and |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_LIBC_EXECFUNCS</span></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 class="docutils literal notranslate"><span class="pre">CONFIG_ARCH_KERNEL_STACK=y</span></code> is selected then the platform |
| specific code must export these additional interfaces:</p> |
| <ul class="simple"> |
| <li><p><a class="reference internal" href="#c.up_addrenv_kstackalloc" title="up_addrenv_kstackalloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">up_addrenv_kstackalloc()</span></code></a>: Allocate the process kernel stack.</p></li> |
| </ul> |
| </li> |
| </ol> |
| <dl class="c function"> |
| <dt id="c.up_addrenv_create"> |
| int <code class="sig-name descname">up_addrenv_create</code><span class="sig-paren">(</span><a class="reference internal" href="../user/structures.html#c.size_t" title="size_t">size_t</a> <em>textsize</em>, <a class="reference internal" href="../user/structures.html#c.size_t" title="size_t">size_t</a> <em>datasize</em>, <a class="reference internal" href="../user/structures.html#c.size_t" title="size_t">size_t</a> <em>heapsize</em>, FAR group_addrenv_t *<em>addrenv</em><span class="sig-paren">)</span>;<a class="headerlink" href="#c.up_addrenv_create" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>This function is called when a new task is created in order to |
| instantiate an address environment for the new task group. |
| up_addrenv_create() is essentially the allocator of the physical memory for the new task.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>textsize</strong> – The size (in bytes) of the <code class="docutils literal notranslate"><span class="pre">.text</span></code> address |
| environment needed by the task. This region may be read/execute |
| only.</p></li> |
| <li><p><strong>datasize</strong> – The size (in bytes) of the <code class="docutils literal notranslate"><span class="pre">.bss/.data</span></code> address |
| environment needed by the task. This region may be read/write |
| only.</p></li> |
| <li><p><strong>heapsize</strong> – The initial size (in bytes) of the heap address |
| environment needed by the task. This region may be read/write |
| only.</p></li> |
| <li><p><strong>addrenv</strong> – The location to return the representation of the |
| task address environment.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_destroy"> |
| int <code class="sig-name descname">up_addrenv_destroy</code><span class="sig-paren">(</span>group_addrenv_t *<em>addrenv</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_destroy" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>This function is called when a final thread leaves the task |
| group and the task group is destroyed. This function then destroys |
| the defunct address environment, releasing the underlying physical |
| memory allocated by up_addrenv_create().</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>addrenv</strong> – The representation of the task address environment |
| previously returned by <code class="docutils literal notranslate"><span class="pre">up_addrenv_create()</span></code>.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_vtext"> |
| int <code class="sig-name descname">up_addrenv_vtext</code><span class="sig-paren">(</span>FAR group_addrenv_t <em>addrenv</em>, FAR void **<em>vtext</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_vtext" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Return the virtual .text address associated with the newly create |
| address environment. This function is used by the binary loaders |
| in order get an address that can be used to initialize the new task.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>addrenv</strong> – The representation of the task address environment |
| previously returned by <code class="docutils literal notranslate"><span class="pre">up_addrenv_create()</span></code>.</p></li> |
| <li><p><strong>vtext</strong> – The location to return the virtual address.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_vdata"> |
| int <code class="sig-name descname">up_addrenv_vdata</code><span class="sig-paren">(</span>FAR group_addrenv_t *<em>addrenv</em>, <a class="reference internal" href="../user/structures.html#c.size_t" title="size_t">size_t</a> <em>textsize</em>, FAR void **<em>vdata</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_vdata" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Return the virtual .text address associated with the newly create |
| address environment. This function is used by the binary loaders |
| in order get an address that can be used to initialize the new task.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>addrenv</strong> – The representation of the task address environment |
| previously returned by <code class="docutils literal notranslate"><span class="pre">up_addrenv_create()</span></code>.</p></li> |
| <li><p><strong>textsize</strong> – For some implementations, the text and data will |
| be saved in the same memory region (read/write/execute) and, in |
| this case, the virtual address of the data just lies at this |
| offset into the common region.</p></li> |
| <li><p><strong>vdata</strong> – The location to return the virtual address.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_heapsize"> |
| ssize_t <code class="sig-name descname">up_addrenv_heapsize</code><span class="sig-paren">(</span>FAR <em class="property">const</em> group_addrenv_t *<em>addrenv</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_heapsize" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Return the initial heap allocation size. That is the amount of |
| memory allocated by up_addrenv_create() when the heap memory |
| region was first created. This may or may not differ from the |
| heapsize parameter that was passed to up_addrenv_create().</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>addrenv</strong> – The representation of the task address environment |
| previously returned by <code class="docutils literal notranslate"><span class="pre">up_addrenv_create()</span></code>.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>The initial heap size allocated is returned on success; |
| a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_select"> |
| int <code class="sig-name descname">up_addrenv_select</code><span class="sig-paren">(</span>group_addrenv_t *<em>addrenv</em>, save_addrenv_t *<em>oldenv</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_select" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>After an address environment has been established for a task |
| (via up_addrenv_create()), this function may be called to instantiate |
| that address environment in the virtual address space. This might be |
| necessary, for example, to load the code for the task from a file or |
| to access address environment private data.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>addrenv</strong> – The representation of the task address environment |
| previously returned by <code class="docutils literal notranslate"><span class="pre">up_addrenv_create()</span></code>.</p></li> |
| <li><p><strong>oldenv</strong> – The address environment that was in place before |
| <code class="docutils literal notranslate"><span class="pre">up_addrenv_select()</span></code> was called. This may be used with |
| <code class="docutils literal notranslate"><span class="pre">up_addrenv_restore()</span></code> to restore the original address |
| environment that was in place before <code class="docutils literal notranslate"><span class="pre">up_addrenv_select()</span></code> |
| was called. Note that this may be a task agnostic, |
| platform-specific representation that may or may not be |
| different from <code class="docutils literal notranslate"><span class="pre">group_addrenv_t</span></code>.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_restore"> |
| int <code class="sig-name descname">up_addrenv_restore</code><span class="sig-paren">(</span>save_addrenv_t <em>oldenv</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_restore" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>After an address environment has been temporarily instantiated |
| by up_addrenv_select, this function may be called to restore |
| the original address environment.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>oldenv</strong> – The platform-specific representation of the address |
| environment previously returned by <code class="docutils literal notranslate"><span class="pre">up_addrenv_select()</span></code>.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_clone"> |
| int <code class="sig-name descname">up_addrenv_clone</code><span class="sig-paren">(</span>FAR <em class="property">const</em> task_group_s *<em>src</em>, FAR <em class="property">struct</em> task_group_s *<em>dest</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_clone" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>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.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>src</strong> – The address environment to be copied.</p></li> |
| <li><p><strong>dest</strong> – The location to receive the copied address |
| environment.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_attach"> |
| int <code class="sig-name descname">up_addrenv_attach</code><span class="sig-paren">(</span>FAR <em class="property">struct</em> task_group_s *<em>group</em>, FAR <em class="property">struct</em> <a class="reference internal" href="../user/structures.html#c.tcb_s" title="tcb_s">tcb_s</a> *<em>tcb</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_attach" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>This function is called from the core scheduler logic when a |
| thread is created that needs to share the address environment |
| of its task group. In this case, the group’s address environment |
| may need to be “cloned” for the child thread.</p> |
| <p>NOTE: In most platforms, nothing will need to be done in this case. |
| Simply being a member of the group that has the address environment |
| may be sufficient.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>group</strong> – The task group to which the new thread belongs.</p></li> |
| <li><p><strong>ctcb</strong> – The TCB of the thread needing the address |
| environment.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_detach"> |
| int <code class="sig-name descname">up_addrenv_detach</code><span class="sig-paren">(</span>FAR <em class="property">struct</em> task_group_s *<em>group</em>, FAR <em class="property">struct</em> task_group_s *<em>tcb</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_detach" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>This function is called when a task or thread exits in order |
| to release its reference to an address environment. The address |
| environment, however, should persist until up_addrenv_destroy() |
| is called when the task group is itself destroyed. Any resources |
| unique to this thread may be destroyed now.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>group</strong> – The group to which the thread belonged.</p></li> |
| <li><p><strong>tcb</strong> – The TCB of the task or thread whose the address |
| environment will be released.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_ustackalloc"> |
| int <code class="sig-name descname">up_addrenv_ustackalloc</code><span class="sig-paren">(</span>FAR <em class="property">struct</em> <a class="reference internal" href="../user/structures.html#c.tcb_s" title="tcb_s">tcb_s</a> *<em>tcb</em>, <a class="reference internal" href="../user/structures.html#c.size_t" title="size_t">size_t</a> <em>stacksize</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_ustackalloc" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>This function is called when a new thread is created in order |
| to instantiate an address environment for the new thread’s stack. |
| up_addrenv_ustackalloc() is essentially the allocator of the |
| physical memory for the new task’s stack.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>tcb</strong> – The TCB of the thread that requires the stack address |
| environment.</p></li> |
| <li><p><strong>stacksize</strong> – The size (in bytes) of the initial stack address |
| environment needed by the task. This region may be read/write |
| only.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_ustackfree"> |
| int <code class="sig-name descname">up_addrenv_ustackfree</code><span class="sig-paren">(</span>FAR <em class="property">struct</em> <a class="reference internal" href="../user/structures.html#c.tcb_s" title="tcb_s">tcb_s</a> *<em>tcb</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_ustackfree" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>This function is called when any thread exits. This function then |
| destroys the defunct address environment for the thread’s stack, |
| releasing the underlying physical memory.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>tcb</strong> – The TCB of the thread that no longer requires the |
| stack address environment.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_vustack"> |
| int <code class="sig-name descname">up_addrenv_vustack</code><span class="sig-paren">(</span>FAR <em class="property">const</em> <em class="property">struct</em> <a class="reference internal" href="../user/structures.html#c.tcb_s" title="tcb_s">tcb_s</a> *<em>tcb</em>, FAR void **<em>vstack</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_vustack" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>Return the virtual address associated with the newly create stack address environment.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>tcb</strong> – The TCB of the thread with the stack address environment of interest.</p></li> |
| <li><p><strong>vstack</strong> – The location to return the stack virtual base address.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_ustackselect"> |
| int <code class="sig-name descname">up_addrenv_ustackselect</code><span class="sig-paren">(</span>FAR <em class="property">const</em> <em class="property">struct</em> <a class="reference internal" href="../user/structures.html#c.tcb_s" title="tcb_s">tcb_s</a> *<em>tcb</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_ustackselect" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>After an address environment has been established for a task’s |
| stack (via up_addrenv_ustackalloc(). This function may be called to |
| instantiate that address environment in the virtual address space. |
| This is a necessary step before each context switch to the newly |
| created thread (including the initial thread startup).</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>tcb</strong> – The TCB of the thread with the stack address |
| environment to be instantiated.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_kstackalloc"> |
| int <code class="sig-name descname">up_addrenv_kstackalloc</code><span class="sig-paren">(</span>FAR <em class="property">struct</em> <a class="reference internal" href="../user/structures.html#c.tcb_s" title="tcb_s">tcb_s</a> *<em>tcb</em><span class="sig-paren">)</span><a class="headerlink" href="#c.up_addrenv_kstackalloc" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>This function is called when a new thread is created to allocate the |
| new thread’s kernel stack. This function may be called for certain |
| terminating threads which have no kernel stack. It must be |
| tolerant of that case.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>tcb</strong> – The TCB of the thread that requires the kernel stack.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="c function"> |
| <dt id="c.up_addrenv_kstackfree"> |
| int <code class="sig-name descname">up_addrenv_kstackfree</code><span class="sig-paren">(</span>FAR <em class="property">struct</em> <a class="reference internal" href="../user/structures.html#c.tcb_s" title="tcb_s">tcb_s</a> *<em>tcb</em><span class="sig-paren">)</span>;<a class="headerlink" href="#c.up_addrenv_kstackfree" title="Permalink to this definition">¶</a><br /></dt> |
| <dd><p>This function is called when any thread exits. This function frees the kernel stack.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>tcb</strong> – The TCB of the thread that no longer requires the |
| kernel stack.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Zero (OK) on success; a negated errno value on failure.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| </div> |
| |
| |
| </div> |
| |
| </div> |
| <footer> |
| |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p> |
| |
| © Copyright 2020, The Apache Software Foundation |
| |
| </p> |
| </div> |
| |
| </footer> |
| |
| </div> |
| </div> |
| |
| </section> |
| |
| </div> |
| |
| |
| <script type="text/javascript"> |
| jQuery(function () { |
| SphinxRtdTheme.Navigation.enable(true); |
| }); |
| </script> |
| |
| |
| |
| |
| |
| |
| </body> |
| </html> |