wut/group__coreinit__codegen.html
2020-03-26 16:49:18 +11:00

338 lines
19 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>wut: Codegen</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">wut
&#160;<span id="projectnumber">1.0.0-beta9</span>
</div>
<div id="projectbrief">Wii U Toolchain</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">Codegen<div class="ingroups"><a class="el" href="group__coreinit.html">coreinit</a></div></div> </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ga44ea1e92974661e06fccbf783a2b5453"><td class="memItemLeft" align="right" valign="top">typedef enum <a class="el" href="group__coreinit__codegen.html#ga71a49a79e47963f81655cc0381c9658f">OSCodegenSecMode</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__coreinit__codegen.html#ga44ea1e92974661e06fccbf783a2b5453">OSCodegenSecMode</a></td></tr>
<tr class="memdesc:ga44ea1e92974661e06fccbf783a2b5453"><td class="mdescLeft">&#160;</td><td class="mdescRight">The memory permissions for the codegen area. <a href="group__coreinit__codegen.html#ga44ea1e92974661e06fccbf783a2b5453">More...</a><br /></td></tr>
<tr class="separator:ga44ea1e92974661e06fccbf783a2b5453"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:ga71a49a79e47963f81655cc0381c9658f"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__coreinit__codegen.html#ga71a49a79e47963f81655cc0381c9658f">OSCodegenSecMode</a> { <br />
&#160;&#160;<a class="el" href="group__coreinit__codegen.html#gga71a49a79e47963f81655cc0381c9658fa283eddc240c8b49af5568b91c5f35c73">CODEGEN_RW_</a> = 0,
<br />
&#160;&#160;<a class="el" href="group__coreinit__codegen.html#gga71a49a79e47963f81655cc0381c9658facafba395111808a76182dd9c74d5545e">CODEGEN_R_X</a> = 1
<br />
}</td></tr>
<tr class="memdesc:ga71a49a79e47963f81655cc0381c9658f"><td class="mdescLeft">&#160;</td><td class="mdescRight">The memory permissions for the codegen area. <a href="group__coreinit__codegen.html#ga71a49a79e47963f81655cc0381c9658f">More...</a><br /></td></tr>
<tr class="separator:ga71a49a79e47963f81655cc0381c9658f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gaafd7747ab31cb4671397c486c9d78043"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__coreinit__codegen.html#gaafd7747ab31cb4671397c486c9d78043">OSCodegenGetVirtAddrRange</a> (uint32_t *outVirtualAddress, uint32_t *outSize)</td></tr>
<tr class="memdesc:gaafd7747ab31cb4671397c486c9d78043"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets the location and size of codegen memory, if available. <a href="group__coreinit__codegen.html#gaafd7747ab31cb4671397c486c9d78043">More...</a><br /></td></tr>
<tr class="separator:gaafd7747ab31cb4671397c486c9d78043"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad621a18bf8f5173658f8cc8717d2495a"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__coreinit__codegen.html#gad621a18bf8f5173658f8cc8717d2495a">OSGetCodegenCore</a> ()</td></tr>
<tr class="memdesc:gad621a18bf8f5173658f8cc8717d2495a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets the CPU core that's allowed to use codegen. <a href="group__coreinit__codegen.html#gad621a18bf8f5173658f8cc8717d2495a">More...</a><br /></td></tr>
<tr class="separator:gad621a18bf8f5173658f8cc8717d2495a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf23cfcb6c33a574b7c88946e1fd3d942"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__coreinit__codegen.html#gaf23cfcb6c33a574b7c88946e1fd3d942">OSGetCodegenMode</a> ()</td></tr>
<tr class="separator:gaf23cfcb6c33a574b7c88946e1fd3d942"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3d4d83b25c330418afe3293147b5ff58"><td class="memItemLeft" align="right" valign="top"><a class="el" href="wut__types_8h.html#a975dbe9e4396bf9e0064ce01827fa372">BOOL</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__coreinit__codegen.html#ga3d4d83b25c330418afe3293147b5ff58">OSSwitchSecCodeGenMode</a> (<a class="el" href="group__coreinit__codegen.html#ga71a49a79e47963f81655cc0381c9658f">OSCodegenSecMode</a> mode)</td></tr>
<tr class="memdesc:ga3d4d83b25c330418afe3293147b5ff58"><td class="mdescLeft">&#160;</td><td class="mdescRight">Switches the permissions on the codegen memory area. <a href="group__coreinit__codegen.html#ga3d4d83b25c330418afe3293147b5ff58">More...</a><br /></td></tr>
<tr class="separator:ga3d4d83b25c330418afe3293147b5ff58"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3a951fec2cd23ca91ca56fc646f34b6b"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__coreinit__codegen.html#ga3a951fec2cd23ca91ca56fc646f34b6b">OSGetSecCodeGenMode</a> ()</td></tr>
<tr class="separator:ga3a951fec2cd23ca91ca56fc646f34b6b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga348ef2b95998b4ad0b171db8f13884e5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="wut__types_8h.html#a975dbe9e4396bf9e0064ce01827fa372">BOOL</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__coreinit__codegen.html#ga348ef2b95998b4ad0b171db8f13884e5">OSCodegenCopy</a> (void *dst, void *src, size_t size)</td></tr>
<tr class="memdesc:ga348ef2b95998b4ad0b171db8f13884e5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copies data from normal memory into the codegen area, leaving the area in <a class="el" href="group__coreinit__codegen.html#gga71a49a79e47963f81655cc0381c9658facafba395111808a76182dd9c74d5545e">CODEGEN_R_X</a> mode. <a href="group__coreinit__codegen.html#ga348ef2b95998b4ad0b171db8f13884e5">More...</a><br /></td></tr>
<tr class="separator:ga348ef2b95998b4ad0b171db8f13884e5"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Controls a memory area that can switch between writable and executable states, allowing dynamic code generation. For some applications, a codegen area is avilable for things like JIT or otherwise generating CPU instructions on the fly. Enabled apps can use <a class="el" href="group__coreinit__codegen.html#gaafd7747ab31cb4671397c486c9d78043">OSCodegenGetVirtAddrRange</a> to discover this area, then use <a class="el" href="group__coreinit__codegen.html#ga3d4d83b25c330418afe3293147b5ff58">OSSwitchSecCodeGenMode</a> or <a class="el" href="group__coreinit__codegen.html#ga348ef2b95998b4ad0b171db8f13884e5">OSCodegenCopy</a> to move instructions in and out before executing them. Codegen can only be used from a specific, predetermined CPU core - see <a class="el" href="group__coreinit__codegen.html#gad621a18bf8f5173658f8cc8717d2495a">OSGetCodegenCore</a>. Codegen can only be used when enabled in an app's cos.xml. </p>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="ga44ea1e92974661e06fccbf783a2b5453"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga44ea1e92974661e06fccbf783a2b5453">&#9670;&nbsp;</a></span>OSCodegenSecMode</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">typedef enum <a class="el" href="group__coreinit__codegen.html#ga71a49a79e47963f81655cc0381c9658f">OSCodegenSecMode</a> <a class="el" href="group__coreinit__codegen.html#ga71a49a79e47963f81655cc0381c9658f">OSCodegenSecMode</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>The memory permissions for the codegen area. </p>
</div>
</div>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a id="ga71a49a79e47963f81655cc0381c9658f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga71a49a79e47963f81655cc0381c9658f">&#9670;&nbsp;</a></span>OSCodegenSecMode</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">enum <a class="el" href="group__coreinit__codegen.html#ga71a49a79e47963f81655cc0381c9658f">OSCodegenSecMode</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>The memory permissions for the codegen area. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="gga71a49a79e47963f81655cc0381c9658fa283eddc240c8b49af5568b91c5f35c73"></a>CODEGEN_RW_&#160;</td><td class="fielddoc"><p>The area can be read or written to, but not executed. </p>
</td></tr>
<tr><td class="fieldname"><a id="gga71a49a79e47963f81655cc0381c9658facafba395111808a76182dd9c74d5545e"></a>CODEGEN_R_X&#160;</td><td class="fielddoc"><p>The area can be read or executed, but not written to. </p>
</td></tr>
</table>
<p class="definition">Definition at line <a class="el" href="codegen_8h_source.html#l00033">33</a> of file <a class="el" href="codegen_8h_source.html">codegen.h</a>.</p>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="gaafd7747ab31cb4671397c486c9d78043"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaafd7747ab31cb4671397c486c9d78043">&#9670;&nbsp;</a></span>OSCodegenGetVirtAddrRange()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void OSCodegenGetVirtAddrRange </td>
<td>(</td>
<td class="paramtype">uint32_t *&#160;</td>
<td class="paramname"><em>outVirtualAddress</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t *&#160;</td>
<td class="paramname"><em>outSize</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Gets the location and size of codegen memory, if available. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">outVirtualAddress</td><td>Pointer to write the virtual address of the codegen area to. Will write 0 if codegen isn't available.</td></tr>
<tr><td class="paramname">outSize</td><td>Pointer to write the size of the codegen area to. Will write 0 if codegen isn't available.</td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__coreinit__codegen.html#ga3a951fec2cd23ca91ca56fc646f34b6b">OSGetSecCodeGenMode</a> </li>
</ul>
</dd></dl>
</div>
</div>
<a id="gad621a18bf8f5173658f8cc8717d2495a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad621a18bf8f5173658f8cc8717d2495a">&#9670;&nbsp;</a></span>OSGetCodegenCore()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t OSGetCodegenCore </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Gets the CPU core that's allowed to use codegen. </p>
<dl class="section return"><dt>Returns</dt><dd>The core id of the core that can use codegen.</dd></dl>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__coreinit__core.html#gae46ae66c00e018f914ba43df11035651">OSGetCoreId</a> </li>
</ul>
</dd></dl>
</div>
</div>
<a id="gaf23cfcb6c33a574b7c88946e1fd3d942"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf23cfcb6c33a574b7c88946e1fd3d942">&#9670;&nbsp;</a></span>OSGetCodegenMode()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t OSGetCodegenMode </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="ga3d4d83b25c330418afe3293147b5ff58"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3d4d83b25c330418afe3293147b5ff58">&#9670;&nbsp;</a></span>OSSwitchSecCodeGenMode()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="wut__types_8h.html#a975dbe9e4396bf9e0064ce01827fa372">BOOL</a> OSSwitchSecCodeGenMode </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__coreinit__codegen.html#ga71a49a79e47963f81655cc0381c9658f">OSCodegenSecMode</a>&#160;</td>
<td class="paramname"><em>mode</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Switches the permissions on the codegen memory area. </p>
<p>Use this function to move between writing code and executing it.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">mode</td><td>The memory permission mode to use - one of <a class="el" href="group__coreinit__codegen.html#ga44ea1e92974661e06fccbf783a2b5453">OSCodegenSecMode</a>.</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> on success, or <code>false</code> on a failure, such as codegen not being available for this app or CPU core. </dd></dl>
</div>
</div>
<a id="ga3a951fec2cd23ca91ca56fc646f34b6b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3a951fec2cd23ca91ca56fc646f34b6b">&#9670;&nbsp;</a></span>OSGetSecCodeGenMode()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t OSGetSecCodeGenMode </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="ga348ef2b95998b4ad0b171db8f13884e5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga348ef2b95998b4ad0b171db8f13884e5">&#9670;&nbsp;</a></span>OSCodegenCopy()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="wut__types_8h.html#a975dbe9e4396bf9e0064ce01827fa372">BOOL</a> OSCodegenCopy </td>
<td>(</td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>dst</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>src</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>size</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Copies data from normal memory into the codegen area, leaving the area in <a class="el" href="group__coreinit__codegen.html#gga71a49a79e47963f81655cc0381c9658facafba395111808a76182dd9c74d5545e">CODEGEN_R_X</a> mode. </p>
<p>This function copies into the codegen area regardless of the current permission status by switching modes as required for the copy.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">dst</td><td>The starting virtual address of the area in codegen memory to copy to. Must be a valid pointer</td></tr>
<tr><td class="paramname">src</td><td>The starting virtual address of the source to copy from. Must be a valid pointer.</td></tr>
<tr><td class="paramname">size</td><td>The size of the data to copy. Must not be 0, and must be small enough such that <code>dst + size</code> does not pass the end of the codegen area (see <a class="el" href="group__coreinit__codegen.html#gaafd7747ab31cb4671397c486c9d78043">OSCodegenGetVirtAddrRange</a>).</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>TRUE</code> on success, indicating the codegen area is now in <a class="el" href="group__coreinit__codegen.html#gga71a49a79e47963f81655cc0381c9658facafba395111808a76182dd9c74d5545e">CODEGEN_R_X</a>, or <code>FALSE</code> on an error, such as invalid pointers or codegen not being available. </dd></dl>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>