gnuk/ChibiOS_2.0.2/docs/html/group__memcore.html
2010-08-10 12:11:02 +09:00

306 lines
16 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>ChibiOS/RT: Core Memory Manager</title>
<link href="custom.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<table style="text-align: center; width: 100%;" border="0"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="width: 80px;"><img alt="ChibiOS/RT Logo" src="logo_small.png"></td>
<td><big><big>ChibiOS/RT</big></big><br><br>Architecture - Reference Manual - Guides</td>
<td style="width: 80px;"></td>
</tr>
</tbody>
</table>
<hr size="1">
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>Core Memory Manager<br/>
<small>
[<a class="el" href="group__memory.html">Memory Management</a>]</small>
</h1>
<p><div class="dynheader">
Collaboration diagram for Core Memory Manager:</div>
<div class="dynsection">
<center><table><tr><td><img src="group__memcore.png" border="0" alt="" usemap="#group____memcore_map"/>
<map name="group____memcore_map" id="group____memcore">
<area shape="rect" href="group__memory.html" title="Memory Management" alt="" coords="7,5,129,29"/>
</map></td></tr></table></center>
</div>
</p>
<hr/><a name="_details"></a><h2>Description</h2>
<p>Core Memory Manager related APIs and services. </p>
<h2>Operation mode</h2>
<p>The core memory manager is a simplified allocator that only allows to allocate memory blocks without the possibility to free them.<br/>
This allocator is meant as a memory blocks provider for the other allocators such as:</p>
<ul>
<li>C-Runtime allocator (through a compiler specific adapter module).</li>
<li>Heap allocator (see <a class="el" href="group__heaps.html">Heaps</a>).</li>
<li>Memory pools allocator (see <a class="el" href="group__pools.html">Memory Pools</a>).</li>
</ul>
<p>By having a centralized memory provider the various allocators can coexist and share the main memory.<br/>
This allocator, alone, is also useful for very simple applications that just require a simple way to get memory blocks.<br/>
In order to use the core memory manager APIs the <code>CH_USE_MEMCORE</code> option must be enabled in <code><a class="el" href="chconf_8h.html" title="Configuration file template.">chconf.h</a></code>. </p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memcore.html#ga5d1c1010f72813c8fd39973ae1568d55">MEM_ALIGN_MASK</a>&nbsp;&nbsp;&nbsp;(sizeof(<a class="el" href="structstkalign__t.html">stkalign_t</a>) - 1)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Alignment mask constant. <a href="#ga5d1c1010f72813c8fd39973ae1568d55"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memcore.html#ga216a7738be23e0caa9d18e510eb795eb">MEM_ALIGN_SIZE</a>(p)&nbsp;&nbsp;&nbsp;(((size_t)(p) + MEM_ALIGN_MASK) &amp; ~MEM_ALIGN_MASK)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Alignment helper macro. <a href="#ga216a7738be23e0caa9d18e510eb795eb"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memcore.html#gac38a64d9001b24d62f1c9ab79fbc328b">MEM_IS_ALIGNED</a>(p)&nbsp;&nbsp;&nbsp;(((size_t)(p) &amp; MEM_ALIGN_MASK) == 0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns whatever a pointer or memory size is aligned to the type <code>align_t</code>. <a href="#gac38a64d9001b24d62f1c9ab79fbc328b"></a><br/></td></tr>
<tr><td colspan="2"><h2>Typedefs</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef void *(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memcore.html#ga4fb77ad6b1053341257948231799b4ad">memgetfunc_t</a> )(size_t size)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Memory get function. <a href="#ga4fb77ad6b1053341257948231799b4ad"></a><br/></td></tr>
<tr><td colspan="2"><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memcore.html#ga4dc59d68e345710573420dca5daa241c">core_init</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Low level memory manager initialization. <a href="#ga4dc59d68e345710573420dca5daa241c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memcore.html#ga5394bda5b809ecf6b80b041b6b9ebaf4">chCoreAlloc</a> (size_t size)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Allocates a memory block. <a href="#ga5394bda5b809ecf6b80b041b6b9ebaf4"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memcore.html#ga30a45ff539c9ed5f2f4b1e87e72eb767">chCoreAllocI</a> (size_t size)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Allocates a memory block. <a href="#ga30a45ff539c9ed5f2f4b1e87e72eb767"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">size_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memcore.html#ga1404de855a685500cb66e6c8560d4b25">chCoreStatus</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Core memory status. <a href="#ga1404de855a685500cb66e6c8560d4b25"></a><br/></td></tr>
</table>
<hr/><h2>Define Documentation</h2>
<a class="anchor" id="ga5d1c1010f72813c8fd39973ae1568d55"></a><!-- doxytag: member="chmemcore.h::MEM_ALIGN_MASK" ref="ga5d1c1010f72813c8fd39973ae1568d55" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define MEM_ALIGN_MASK&nbsp;&nbsp;&nbsp;(sizeof(<a class="el" href="structstkalign__t.html">stkalign_t</a>) - 1)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Alignment mask constant. </p>
<p>Definition at line <a class="el" href="chmemcore_8h_source.html#l00048">48</a> of file <a class="el" href="chmemcore_8h_source.html">chmemcore.h</a>.</p>
</div>
</div>
<a class="anchor" id="ga216a7738be23e0caa9d18e510eb795eb"></a><!-- doxytag: member="chmemcore.h::MEM_ALIGN_SIZE" ref="ga216a7738be23e0caa9d18e510eb795eb" args="(p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define MEM_ALIGN_SIZE</td>
<td>(</td>
<td class="paramtype">p&nbsp;</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;(((size_t)(p) + MEM_ALIGN_MASK) &amp; ~MEM_ALIGN_MASK)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Alignment helper macro. </p>
<p>Definition at line <a class="el" href="chmemcore_8h_source.html#l00053">53</a> of file <a class="el" href="chmemcore_8h_source.html">chmemcore.h</a>.</p>
<p>Referenced by <a class="el" href="group__memcore.html#ga30a45ff539c9ed5f2f4b1e87e72eb767">chCoreAllocI()</a>, <a class="el" href="group__heaps.html#ga3d364eec0bef8b1986f63b3288ebbd5f">chHeapAlloc()</a>, <a class="el" href="group__pools.html#ga9c53c25a5ae60930534cde8620775781">chPoolInit()</a>, and <a class="el" href="group__memcore.html#ga4dc59d68e345710573420dca5daa241c">core_init()</a>.</p>
</div>
</div>
<a class="anchor" id="gac38a64d9001b24d62f1c9ab79fbc328b"></a><!-- doxytag: member="chmemcore.h::MEM_IS_ALIGNED" ref="gac38a64d9001b24d62f1c9ab79fbc328b" args="(p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define MEM_IS_ALIGNED</td>
<td>(</td>
<td class="paramtype">p&nbsp;</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;(((size_t)(p) &amp; MEM_ALIGN_MASK) == 0)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns whatever a pointer or memory size is aligned to the type <code>align_t</code>. </p>
<p>Definition at line <a class="el" href="chmemcore_8h_source.html#l00059">59</a> of file <a class="el" href="chmemcore_8h_source.html">chmemcore.h</a>.</p>
<p>Referenced by <a class="el" href="group__heaps.html#ga7135c9ddbd1402a4a36ce44df948f4e4">chHeapInit()</a>, and <a class="el" href="group__pools.html#gab5c6c04fd14fbeee2183ca955371c515">chPoolFreeI()</a>.</p>
</div>
</div>
<hr/><h2>Typedef Documentation</h2>
<a class="anchor" id="ga4fb77ad6b1053341257948231799b4ad"></a><!-- doxytag: member="chmemcore.h::memgetfunc_t" ref="ga4fb77ad6b1053341257948231799b4ad" args=")(size_t size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef void*(* <a class="el" href="group__memcore.html#ga4fb77ad6b1053341257948231799b4ad">memgetfunc_t</a>)(size_t size)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Memory get function. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>This type must be assignment compatible with the <code>chMemAlloc()</code> function. </dd></dl>
<p>Definition at line <a class="el" href="chmemcore_8h_source.html#l00043">43</a> of file <a class="el" href="chmemcore_8h_source.html">chmemcore.h</a>.</p>
</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="ga4dc59d68e345710573420dca5daa241c"></a><!-- doxytag: member="chmemcore.h::core_init" ref="ga4dc59d68e345710573420dca5daa241c" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void core_init </td>
<td>(</td>
<td class="paramtype">void&nbsp;</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Low level memory manager initialization. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>Internal use only. </dd></dl>
<p>Definition at line <a class="el" href="chmemcore_8c_source.html#l00062">62</a> of file <a class="el" href="chmemcore_8c_source.html">chmemcore.c</a>.</p>
<p>References <a class="el" href="group__config.html#gac73902e3c40b375483f9dde71e83253d">CH_MEMCORE_SIZE</a>, and <a class="el" href="group__memcore.html#ga216a7738be23e0caa9d18e510eb795eb">MEM_ALIGN_SIZE</a>.</p>
<p>Referenced by <a class="el" href="group__system.html#gafe2c7de6567e98e487e009e81e3be10b">chSysInit()</a>.</p>
</div>
</div>
<a class="anchor" id="ga5394bda5b809ecf6b80b041b6b9ebaf4"></a><!-- doxytag: member="chmemcore.h::chCoreAlloc" ref="ga5394bda5b809ecf6b80b041b6b9ebaf4" args="(size_t size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void * chCoreAlloc </td>
<td>(</td>
<td class="paramtype">size_t&nbsp;</td>
<td class="paramname"> <em>size</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Allocates a memory block. </p>
<p>The size of the returned block is aligned to the alignment type <code><a class="el" href="structstkalign__t.html" title="Base type for stack and memory alignment.">stkalign_t</a></code> so it is not possible to allocate less than <code>sizeof(stkalign_t)</code>.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>size</em>&nbsp;</td><td>the size of the block to be allocated </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A pointer to the allocated memory block. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>NULL</em>&nbsp;</td><td>allocation failed, core memory exhausted. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chmemcore_8c_source.html#l00088">88</a> of file <a class="el" href="chmemcore_8c_source.html">chmemcore.c</a>.</p>
<p>References <a class="el" href="group__memcore.html#ga30a45ff539c9ed5f2f4b1e87e72eb767">chCoreAllocI()</a>, <a class="el" href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, and <a class="el" href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>.</p>
<p>Referenced by <a class="el" href="group__heaps.html#ga7e7a6625a49b6a560a47ae7575575264">heap_init()</a>.</p>
<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
<div class="center"><img src="group__memcore_ga5394bda5b809ecf6b80b041b6b9ebaf4_cgraph.png" border="0" usemap="#group__memcore_ga5394bda5b809ecf6b80b041b6b9ebaf4_cgraph_map" alt=""></div>
<map name="group__memcore_ga5394bda5b809ecf6b80b041b6b9ebaf4_cgraph_map" id="group__memcore_ga5394bda5b809ecf6b80b041b6b9ebaf4_cgraph">
<area shape="rect" href="group__memcore.html#ga30a45ff539c9ed5f2f4b1e87e72eb767" title="Allocates a memory block." alt="" coords="133,5,216,29"/>
</map>
</div>
</p>
</div>
</div>
<a class="anchor" id="ga30a45ff539c9ed5f2f4b1e87e72eb767"></a><!-- doxytag: member="chmemcore.h::chCoreAllocI" ref="ga30a45ff539c9ed5f2f4b1e87e72eb767" args="(size_t size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void * chCoreAllocI </td>
<td>(</td>
<td class="paramtype">size_t&nbsp;</td>
<td class="paramname"> <em>size</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Allocates a memory block. </p>
<p>The size of the returned block is aligned to the alignment type <code>align_t</code> so it is not possible to allocate less than <code>sizeof(align_t)</code>.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><tt>[in]</tt>&nbsp;</td><td valign="top"><em>size</em>&nbsp;</td><td>the size of the block to be allocated. </td></tr>
</table>
</dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>A pointer to the allocated memory block. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>NULL</em>&nbsp;</td><td>allocation failed, core memory exhausted. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="chmemcore_8c_source.html#l00107">107</a> of file <a class="el" href="chmemcore_8c_source.html">chmemcore.c</a>.</p>
<p>References <a class="el" href="group__memcore.html#ga216a7738be23e0caa9d18e510eb795eb">MEM_ALIGN_SIZE</a>.</p>
<p>Referenced by <a class="el" href="group__memcore.html#ga5394bda5b809ecf6b80b041b6b9ebaf4">chCoreAlloc()</a>.</p>
</div>
</div>
<a class="anchor" id="ga1404de855a685500cb66e6c8560d4b25"></a><!-- doxytag: member="chmemcore.h::chCoreStatus" ref="ga1404de855a685500cb66e6c8560d4b25" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">size_t chCoreStatus </td>
<td>(</td>
<td class="paramtype">void&nbsp;</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Core memory status. </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>The size, in bytes, of the free core memory. </dd></dl>
<p>Definition at line <a class="el" href="chmemcore_8c_source.html#l00123">123</a> of file <a class="el" href="chmemcore_8c_source.html">chmemcore.c</a>.</p>
</div>
</div>
</div>
<hr size="1"><address style="text-align: right;"><small>
Generated on Sun Jul 11 13:13:15 2010 for ChibiOS/RT by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.6.3</small></address>
</body>
</html>