Newer
Older
UbixOS / doc / html / kmod_8c-source.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>UbixOS V2: src/sys/kmods/kmod.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
  <ul>
    <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
    <li id="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="dirs.html"><span>Directories</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    <li><a href="globals.html"><span>Globals</span></a></li>
  </ul></div>
<div class="nav">
<a class="el" href="dir_897b6a2d7bab147dd1db58381aad3984.html">src</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_832905b1f7f5feaf61a306b40c0ac817.html">sys</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_a0cadbe588a0f0b62517333d702e3cca.html">kmods</a></div>
<h1>kmod.c</h1><a href="kmod_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*****************************************************************************************</span>
<a name="l00002"></a>00002 <span class="comment"> Copyright (c) 2002-2005 The UbixOS Project</span>
<a name="l00003"></a>00003 <span class="comment"> All rights reserved.</span>
<a name="l00004"></a>00004 <span class="comment"></span>
<a name="l00005"></a>00005 <span class="comment"> Redistribution and use in source and binary forms, with or without modification, are</span>
<a name="l00006"></a>00006 <span class="comment"> permitted provided that the following conditions are met:</span>
<a name="l00007"></a>00007 <span class="comment"></span>
<a name="l00008"></a>00008 <span class="comment"> Redistributions of source code must retain the above copyright notice, this list of</span>
<a name="l00009"></a>00009 <span class="comment"> conditions, the following disclaimer and the list of authors.  Redistributions in binary</span>
<a name="l00010"></a>00010 <span class="comment"> form must reproduce the above copyright notice, this list of conditions, the following</span>
<a name="l00011"></a>00011 <span class="comment"> disclaimer and the list of authors in the documentation and/or other materials provided</span>
<a name="l00012"></a>00012 <span class="comment"> with the distribution. Neither the name of the UbixOS Project nor the names of its</span>
<a name="l00013"></a>00013 <span class="comment"> contributors may be used to endorse or promote products derived from this software</span>
<a name="l00014"></a>00014 <span class="comment"> without specific prior written permission.</span>
<a name="l00015"></a>00015 <span class="comment"></span>
<a name="l00016"></a>00016 <span class="comment"> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY</span>
<a name="l00017"></a>00017 <span class="comment"> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF</span>
<a name="l00018"></a>00018 <span class="comment"> MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL</span>
<a name="l00019"></a>00019 <span class="comment"> THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
<a name="l00020"></a>00020 <span class="comment"> SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT</span>
<a name="l00021"></a>00021 <span class="comment"> OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</span>
<a name="l00022"></a>00022 <span class="comment"> HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR</span>
<a name="l00023"></a>00023 <span class="comment"> TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<a name="l00024"></a>00024 <span class="comment"> SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment"> $Id: kmod_8c-source.html 88 2016-01-12 00:11:29Z reddawg $</span>
<a name="l00027"></a>00027 <span class="comment"></span>
<a name="l00028"></a>00028 <span class="comment">*****************************************************************************************/</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;<a class="code" href="types_8h.html">ubixos/types.h</a>&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;<a class="code" href="kmod_8h.html">ubixos/kmod.h</a>&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;<a class="code" href="sched_8h.html">ubixos/sched.h</a>&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;<a class="code" href="elf_8h.html">ubixos/elf.h</a>&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;<a class="code" href="kpanic_8h.html">ubixos/kpanic.h</a>&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;<a class="code" href="lists_8h.html">ubixos/lists.h</a>&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;<a class="code" href="spinlock_8h.html">ubixos/spinlock.h</a>&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;<a class="code" href="kprintf_8h.html">lib/kprintf.h</a>&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;<a class="code" href="kmalloc_8h.html">lib/kmalloc.h</a>&gt;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;<a class="code" href="vfs_8h.html">vfs/vfs.h</a>&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;<a class="code" href="vmm_8h.html">vmm/vmm.h</a>&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;<a class="code" href="string_8h.html">string.h</a>&gt;</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include &lt;<a class="code" href="assert_8h.html">assert.h</a>&gt;</span>
<a name="l00043"></a>00043 
<a name="l00044"></a><a class="code" href="kmod_8c.html#ef05a41ecb31fc37647810e583f3d37b">00044</a> <a class="code" href="struct__list__t.html">List_t</a> *<a class="code" href="kmod_8c.html#ef05a41ecb31fc37647810e583f3d37b">List</a> = 0x0;
<a name="l00045"></a>00045 
<a name="l00046"></a><a class="code" href="kmod_8c.html#f2a085a786b2cf77d53da7f364948cd4">00046</a> <a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a> <a class="code" href="kmod_8h.html#06399dbabee4a7e746b17c66a343d38f">kmod_add</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *kmod_file, <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="pci_8c.html#8f8f80d37794cde9472343e4487ba3eb">name</a>)
<a name="l00047"></a>00047 {
<a name="l00048"></a>00048         <a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a> addr = 0x0;
<a name="l00049"></a>00049         <a class="code" href="struct__item__t.html">Item_t</a> *tmp;
<a name="l00050"></a>00050         <a class="code" href="structkmod__struct.html">kmod_t</a> *kmods;
<a name="l00051"></a>00051 
<a name="l00052"></a>00052         
<a name="l00053"></a>00053         addr = <a class="code" href="kmod_8h.html#c9997cda5e69bc2c1fce8c8c343b3d4f">kmod_load</a>(kmod_file);
<a name="l00054"></a>00054         <span class="keywordflow">if</span> (addr == 0x0)
<a name="l00055"></a>00055                 <span class="keywordflow">return</span> 0x0;
<a name="l00056"></a>00056 
<a name="l00057"></a>00057         <span class="keywordflow">if</span>(<a class="code" href="kmod_8c.html#ef05a41ecb31fc37647810e583f3d37b">List</a> == 0x0)
<a name="l00058"></a>00058         {
<a name="l00059"></a>00059                 <a class="code" href="kmod_8c.html#ef05a41ecb31fc37647810e583f3d37b">List</a> = <a class="code" href="lists_8h.html#5f388b13396e1961b2a85720edf33712">InitializeList</a>();
<a name="l00060"></a>00060         }
<a name="l00061"></a>00061 
<a name="l00062"></a>00062         tmp = <a class="code" href="lists_8h.html#ddb302e5cc32ff6fd65b02523e648764">CreateItem</a>();
<a name="l00063"></a>00063         <a class="code" href="lists_8h.html#f4e720b926108dabb1a08d09798e76d0">InsertItemAtFront</a>(<a class="code" href="kmod_8c.html#ef05a41ecb31fc37647810e583f3d37b">List</a>, tmp);
<a name="l00064"></a>00064         kmods = <a class="code" href="kmalloc_8h.html#150eab2ac4ce4553e21ca10e7f441762">kmalloc</a>(<span class="keyword">sizeof</span> *kmods);
<a name="l00065"></a>00065         tmp-&gt;<a class="code" href="struct__item__t.html#76139a34f13eb90a9bf203579870dbd2">data</a> = kmods;
<a name="l00066"></a>00066         <span class="keywordflow">if</span>(kmods == <a class="code" href="types_8h.html#070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00067"></a>00067         {
<a name="l00068"></a>00068                 <a class="code" href="kprint_8h.html#b2761bdf0cca73ad0fb5880895210cd8">kprintf</a>(<span class="stringliteral">"kmod_add: unable to allocate memory!\n"</span>);
<a name="l00069"></a>00069                 <span class="keywordflow">return</span> 0x0;
<a name="l00070"></a>00070         }
<a name="l00071"></a>00071                 
<a name="l00072"></a>00072         <span class="keywordflow">return</span> 0x0;
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074 
<a name="l00075"></a><a class="code" href="kmod_8c.html#92b68dbf95bf5d651555a4c02ee1a74b">00075</a> <a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a> <a class="code" href="kmod_8h.html#c9997cda5e69bc2c1fce8c8c343b3d4f">kmod_load</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *kmod_file) {
<a name="l00076"></a>00076   <span class="keywordtype">int</span>               i             = 0x0;
<a name="l00077"></a>00077   <span class="keywordtype">int</span>               x             = 0x0;
<a name="l00078"></a>00078   <span class="keywordtype">int</span>               rel           = 0x0;
<a name="l00079"></a>00079   <span class="keywordtype">int</span>               sym           = 0x0;
<a name="l00080"></a>00080   <span class="keywordtype">char</span>             *newLoc        = 0x0; 
<a name="l00081"></a>00081   <span class="keywordtype">char</span>             *shStr         = 0x0;
<a name="l00082"></a>00082   <span class="keywordtype">char</span>             *dynStr        = 0x0;
<a name="l00083"></a>00083   <a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a>           *reMap         = 0x0;
<a name="l00084"></a>00084   <a class="code" href="structfileDescriptorStruct.html">fileDescriptor</a>   *kmod_fd       = 0x0;
<a name="l00085"></a>00085   <a class="code" href="structelfHeader.html">elfHeader</a>        *binaryHeader  = 0x0;
<a name="l00086"></a>00086   <a class="code" href="structelfProgramHeader.html">elfProgramHeader</a> *programHeader = 0x0;
<a name="l00087"></a>00087   <a class="code" href="structelfSectionHeader.html">elfSectionHeader</a> *sectionHeader = 0x0;
<a name="l00088"></a>00088   <a class="code" href="structelfDynSym.html">elfDynSym</a>        *relSymTab     = 0x0;
<a name="l00089"></a>00089   <a class="code" href="structelfPltInfo.html">elfPltInfo</a>       *elfRel        = 0x0;
<a name="l00090"></a>00090 
<a name="l00091"></a>00091   <span class="comment">/* Open kernel module */</span>
<a name="l00092"></a>00092   kmod_fd = <a class="code" href="file_8h.html#d6a41ac88a7d46d574e8a675fdde136c">fopen</a>(kmod_file,<span class="stringliteral">"rb"</span>);
<a name="l00093"></a>00093   <span class="keywordflow">if</span> (kmod_fd == 0x0) {
<a name="l00094"></a>00094     <a class="code" href="kprint_8h.html#b2761bdf0cca73ad0fb5880895210cd8">kprintf</a>(<span class="stringliteral">"Can not open %s\n"</span>,kmod_file);
<a name="l00095"></a>00095       <span class="keywordflow">return</span> 0x0;
<a name="l00096"></a>00096     }
<a name="l00097"></a>00097  
<a name="l00098"></a>00098   <span class="comment">/* load module header */</span>
<a name="l00099"></a>00099   <a class="code" href="file_8h.html#80528d8335cd52755f5d6a92e4f08391">fseek</a>(kmod_fd,0x0,0x0);
<a name="l00100"></a>00100   binaryHeader = (<a class="code" href="structelfHeader.html">elfHeader</a> *)<a class="code" href="kmalloc_8h.html#150eab2ac4ce4553e21ca10e7f441762">kmalloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="structelfHeader.html">elfHeader</a>));
<a name="l00101"></a>00101   <span class="keywordflow">if</span>(binaryHeader == 0x0)
<a name="l00102"></a>00102   {
<a name="l00103"></a>00103         <a class="code" href="kprint_8h.html#b2761bdf0cca73ad0fb5880895210cd8">kprintf</a>(<span class="stringliteral">"kmod: out of memory\n"</span>);
<a name="l00104"></a>00104         <span class="keywordflow">return</span> 0x0;
<a name="l00105"></a>00105   }
<a name="l00106"></a>00106         
<a name="l00107"></a>00107   <a class="code" href="assert_8h.html#d6d5aaa966ca7424f7cb9bd01f2c838b">assert</a>(binaryHeader);
<a name="l00108"></a>00108   <a class="code" href="file_8h.html#3b06878a03209e88c008c77234b89359">fread</a>(binaryHeader,<span class="keyword">sizeof</span>(elfHeader),1,kmod_fd);
<a name="l00109"></a>00109 
<a name="l00110"></a>00110   programHeader = (<a class="code" href="structelfProgramHeader.html">elfProgramHeader</a> *)<a class="code" href="kmalloc_8h.html#150eab2ac4ce4553e21ca10e7f441762">kmalloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="structelfProgramHeader.html">elfProgramHeader</a>)*binaryHeader-&gt;<a class="code" href="structelfHeader.html#4635401868104caa04fcb5bb60840df6">ePhnum</a>);
<a name="l00111"></a>00111   <a class="code" href="assert_8h.html#d6d5aaa966ca7424f7cb9bd01f2c838b">assert</a>(programHeader);
<a name="l00112"></a>00112   <a class="code" href="file_8h.html#80528d8335cd52755f5d6a92e4f08391">fseek</a>(kmod_fd,binaryHeader-&gt;<a class="code" href="structelfHeader.html#aff1ff2cb64932f1e1a1f6cf3b881787">ePhoff</a>,0);
<a name="l00113"></a>00113   <a class="code" href="file_8h.html#3b06878a03209e88c008c77234b89359">fread</a>(programHeader,<span class="keyword">sizeof</span>(<a class="code" href="structelfSectionHeader.html">elfSectionHeader</a>),binaryHeader-&gt;<a class="code" href="structelfHeader.html#4635401868104caa04fcb5bb60840df6">ePhnum</a>,kmod_fd);
<a name="l00114"></a>00114 
<a name="l00115"></a>00115   sectionHeader = (elfSectionHeader *)<a class="code" href="kmalloc_8h.html#150eab2ac4ce4553e21ca10e7f441762">kmalloc</a>(<span class="keyword">sizeof</span>(elfSectionHeader)*binaryHeader-&gt;<a class="code" href="structelfHeader.html#a5b9594ecad96ed7448dbcf95da7895f">eShnum</a>);
<a name="l00116"></a>00116   <a class="code" href="assert_8h.html#d6d5aaa966ca7424f7cb9bd01f2c838b">assert</a>(sectionHeader);
<a name="l00117"></a>00117   <a class="code" href="file_8h.html#80528d8335cd52755f5d6a92e4f08391">fseek</a>(kmod_fd,binaryHeader-&gt;<a class="code" href="structelfHeader.html#3d8c518903e5e4db018a336edb6ef204">eShoff</a>,0);
<a name="l00118"></a>00118   <a class="code" href="file_8h.html#3b06878a03209e88c008c77234b89359">fread</a>(sectionHeader,<span class="keyword">sizeof</span>(elfSectionHeader),binaryHeader-&gt;<a class="code" href="structelfHeader.html#a5b9594ecad96ed7448dbcf95da7895f">eShnum</a>,kmod_fd);
<a name="l00119"></a>00119 
<a name="l00120"></a>00120   shStr = (<span class="keywordtype">char</span> *)<a class="code" href="kmalloc_8h.html#150eab2ac4ce4553e21ca10e7f441762">kmalloc</a>(sectionHeader[binaryHeader-&gt;<a class="code" href="structelfHeader.html#8842d2d5aed087cd50914a46461d3f40">eShstrndx</a>].shSize);
<a name="l00121"></a>00121   <a class="code" href="file_8h.html#80528d8335cd52755f5d6a92e4f08391">fseek</a>(kmod_fd,sectionHeader[binaryHeader-&gt;<a class="code" href="structelfHeader.html#8842d2d5aed087cd50914a46461d3f40">eShstrndx</a>].shOffset,0);
<a name="l00122"></a>00122   <a class="code" href="file_8h.html#3b06878a03209e88c008c77234b89359">fread</a>(shStr,sectionHeader[binaryHeader-&gt;<a class="code" href="structelfHeader.html#8842d2d5aed087cd50914a46461d3f40">eShstrndx</a>].shSize,1,kmod_fd);
<a name="l00123"></a>00123 
<a name="l00124"></a>00124   <span class="keywordflow">for</span> (i=0;i&lt;binaryHeader-&gt;<a class="code" href="structelfHeader.html#4635401868104caa04fcb5bb60840df6">ePhnum</a>;i++) {
<a name="l00125"></a>00125     <span class="keywordflow">switch</span> (programHeader[i].phType) {
<a name="l00126"></a>00126       <span class="keywordflow">case</span> <a class="code" href="elf_8h.html#84d7768fd6c6ece599d297090900cf92">PT_LOAD</a>:
<a name="l00127"></a>00127       <span class="keywordflow">case</span> <a class="code" href="elf_8h.html#2121a2f01c51e8462bfd4d47725649d8">PT_DYNAMIC</a>:
<a name="l00128"></a>00128         newLoc = (<span class="keywordtype">char</span> *)programHeader[i].phVaddr + <a class="code" href="kmod_8h.html#f4d6f389174a00e0de80e1ea0e23e956">LD_START</a>;
<a name="l00129"></a>00129         <span class="comment">/*</span>
<a name="l00130"></a>00130 <span class="comment">        Allocate Memory Im Going To Have To Make This Load Memory With Correct</span>
<a name="l00131"></a>00131 <span class="comment">        Settings so it helps us in the future</span>
<a name="l00132"></a>00132 <span class="comment">        */</span>
<a name="l00133"></a>00133         <span class="keywordflow">for</span> (x=0;x &lt; ((programHeader[i].<a class="code" href="structelfProgramHeader.html#b5a140ab0f0225a8459f88d905995dd0">phMemsz</a>)+4095);x += 0x1000) {
<a name="l00134"></a>00134           <span class="comment">/* make r/w or ro */</span>
<a name="l00135"></a>00135           <span class="keywordflow">if</span> ((<a class="code" href="paging_8h.html#a05f8d8947fb5bcec87fc6661f83243e">vmm_remapPage</a>(<a class="code" href="vmm_8h.html#976cf3919bf7c77c868021ec9374593b">vmmFindFreePage</a>(<a class="code" href="sched_8h.html#54397bfe18d5da4d50ff03b15f540858">_current</a>-&gt;<a class="code" href="structtaskStruct.html#30966587a60db6b40c8be6c387e11d81">id</a>),((programHeader[i].<a class="code" href="structelfProgramHeader.html#14f11176e999131fb9be875aeb500447">phVaddr</a> &amp; 0xFFFFF000) + x + <a class="code" href="kmod_8h.html#f4d6f389174a00e0de80e1ea0e23e956">LD_START</a>),<a class="code" href="paging_8h.html#f0fff7a38cd2c7a32d580787423b94ea">PAGE_DEFAULT</a>)) == 0x0) 
<a name="l00136"></a>00136             <a class="code" href="kpanic_8h.html#db9a182aa071791a306163d50d653deb">kpanic</a>(<span class="stringliteral">"vmmRemapPage: ld\n"</span>);
<a name="l00137"></a>00137           <a class="code" href="lib_2string_8h.html#ce4b911463887af5e748326323e99a23">memset</a>((<span class="keywordtype">void</span> *)((programHeader[i].phVaddr &amp; 0xFFFFF000) + x + <a class="code" href="kmod_8h.html#f4d6f389174a00e0de80e1ea0e23e956">LD_START</a>),0x0,0<a class="code" href="ap-boot_8S.html#f78b91f02427adef14bb8b28aa93baa5">x1000</a>);
<a name="l00138"></a>00138           }
<a name="l00139"></a>00139         <span class="comment">/* Now Load Section To Memory */</span>
<a name="l00140"></a>00140         <a class="code" href="file_8h.html#80528d8335cd52755f5d6a92e4f08391">fseek</a>(kmod_fd,programHeader[i].phOffset,0x0);
<a name="l00141"></a>00141         <a class="code" href="file_8h.html#3b06878a03209e88c008c77234b89359">fread</a>(newLoc,programHeader[i].phFilesz,1,kmod_fd);
<a name="l00142"></a>00142         <span class="keywordflow">break</span>;
<a name="l00143"></a>00143       <span class="keywordflow">case</span> <a class="code" href="elf_8h.html#f9283bc32e6d3e87d2bab2f55bc1949b">PT_GNU_STACK</a>:
<a name="l00144"></a>00144         <span class="comment">/* Tells us if the stack should be executable.  Failsafe to executable</span>
<a name="l00145"></a>00145 <span class="comment">           until we add checking */</span>
<a name="l00146"></a>00146         <span class="keywordflow">break</span>;
<a name="l00147"></a>00147       <span class="keywordflow">case</span> <a class="code" href="elf_8h.html#7294b5e14e1cf5becf35236381698f48">PT_PAX_FLAGS</a>:
<a name="l00148"></a>00148         <span class="comment">/* Not sure... */</span>
<a name="l00149"></a>00149         <span class="keywordflow">break</span>;
<a name="l00150"></a>00150       <span class="keywordflow">default</span>:
<a name="l00151"></a>00151         <a class="code" href="kprint_8h.html#b2761bdf0cca73ad0fb5880895210cd8">kprintf</a>(<span class="stringliteral">"Unhandled Header : %08x\n"</span>, programHeader[i].phType);
<a name="l00152"></a>00152         <span class="keywordflow">break</span>;
<a name="l00153"></a>00153       }
<a name="l00154"></a>00154     }
<a name="l00155"></a>00155 
<a name="l00156"></a>00156   <span class="keywordflow">for</span> (i=0x0;i&lt;binaryHeader-&gt;<a class="code" href="structelfHeader.html#a5b9594ecad96ed7448dbcf95da7895f">eShnum</a>;i++) {
<a name="l00157"></a>00157     <span class="keywordflow">switch</span> (sectionHeader[i].shType) {
<a name="l00158"></a>00158      <span class="keywordflow">case</span> 3:
<a name="l00159"></a>00159         <span class="keywordflow">if</span> (!<a class="code" href="lib_2string_8h.html#6f3dcb20ff11ff9db5904c3cfb61a38c">strcmp</a>((shStr + sectionHeader[i].shName),<span class="stringliteral">".dynstr"</span>)) {
<a name="l00160"></a>00160           dynStr = (<span class="keywordtype">char</span> *)<a class="code" href="kmalloc_8h.html#150eab2ac4ce4553e21ca10e7f441762">kmalloc</a>(sectionHeader[i].shSize);
<a name="l00161"></a>00161           <a class="code" href="file_8h.html#80528d8335cd52755f5d6a92e4f08391">fseek</a>(kmod_fd,sectionHeader[i].shOffset,0x0);
<a name="l00162"></a>00162           <a class="code" href="file_8h.html#3b06878a03209e88c008c77234b89359">fread</a>(dynStr,sectionHeader[i].shSize,1,kmod_fd);
<a name="l00163"></a>00163           }
<a name="l00164"></a>00164         <span class="keywordflow">break</span>;
<a name="l00165"></a>00165       <span class="keywordflow">case</span> 9:
<a name="l00166"></a>00166         elfRel = (<a class="code" href="structelfPltInfo.html">elfPltInfo</a> *)<a class="code" href="kmalloc_8h.html#150eab2ac4ce4553e21ca10e7f441762">kmalloc</a>(sectionHeader[i].shSize);
<a name="l00167"></a>00167         <a class="code" href="file_8h.html#80528d8335cd52755f5d6a92e4f08391">fseek</a>(kmod_fd,sectionHeader[i].shOffset,0x0);
<a name="l00168"></a>00168         <a class="code" href="file_8h.html#3b06878a03209e88c008c77234b89359">fread</a>(elfRel,sectionHeader[i].shSize,1,kmod_fd);
<a name="l00169"></a>00169 
<a name="l00170"></a>00170         <span class="keywordflow">for</span> (x=0x0;x&lt;sectionHeader[i].<a class="code" href="structelfSectionHeader.html#285d41cc0ad6e460792b9524c6db5345">shSize</a>/<span class="keyword">sizeof</span>(<a class="code" href="structelfPltInfo.html">elfPltInfo</a>);x++) {
<a name="l00171"></a>00171           rel = <a class="code" href="elf_8h.html#8d1ac0f35a8999a4a8a3350ca95ab54b">ELF32_R_SYM</a>(elfRel[x].pltInfo);
<a name="l00172"></a>00172           reMap = (<a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a> *)((<a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a>)<a class="code" href="kmod_8h.html#f4d6f389174a00e0de80e1ea0e23e956">LD_START</a> + elfRel[x].pltOffset);
<a name="l00173"></a>00173           <span class="keywordflow">switch</span> (<a class="code" href="elf_8h.html#a4ffd69f2c1c03229686bfa3a898db00">ELF32_R_TYPE</a>(elfRel[x].pltInfo)) {
<a name="l00174"></a>00174             <span class="keywordflow">case</span> <a class="code" href="elf_8h.html#f363b787459afd7e272677d7858572c0">R_386_32</a>:
<a name="l00175"></a>00175               *reMap += ((<a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a>)<a class="code" href="kmod_8h.html#f4d6f389174a00e0de80e1ea0e23e956">LD_START</a> + relSymTab[rel].dynValue);
<a name="l00176"></a>00176               <span class="keywordflow">break</span>;
<a name="l00177"></a>00177             <span class="keywordflow">case</span> <a class="code" href="elf_8h.html#d55eb4ccb6e52c4c03f99b34cc8c690b">R_386_PC32</a>:
<a name="l00178"></a>00178               *reMap += ((<a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a>)<a class="code" href="kmod_8h.html#f4d6f389174a00e0de80e1ea0e23e956">LD_START</a> + relSymTab[rel].dynValue) - (<a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a>)reMap;
<a name="l00179"></a>00179               <span class="keywordflow">break</span>;
<a name="l00180"></a>00180             <span class="keywordflow">case</span> <a class="code" href="elf_8h.html#ee5190154984e6176e1c6804ac13217d">R_386_RELATIVE</a>:
<a name="l00181"></a>00181               *reMap += (<a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a>)<a class="code" href="kmod_8h.html#f4d6f389174a00e0de80e1ea0e23e956">LD_START</a>;
<a name="l00182"></a>00182               <span class="keywordflow">break</span>;
<a name="l00183"></a>00183             <span class="keywordflow">default</span>:
<a name="l00184"></a>00184               <a class="code" href="kprint_8h.html#b2761bdf0cca73ad0fb5880895210cd8">kprintf</a>(<span class="stringliteral">"[0x%X][0x%X](%i)[%s]\n"</span>,elfRel[x].pltOffset,elfRel[x].pltInfo,rel,<a class="code" href="elf_8h.html#18371af6e681af62767a92ac64af1ebb">elfGetRelType</a>(<a class="code" href="elf_8h.html#a4ffd69f2c1c03229686bfa3a898db00">ELF32_R_TYPE</a>(elfRel[x].pltInfo)));
<a name="l00185"></a>00185               <a class="code" href="kprint_8h.html#b2761bdf0cca73ad0fb5880895210cd8">kprintf</a>(<span class="stringliteral">"relTab [%s][0x%X][0x%X]\n"</span>,dynStr + relSymTab[rel].dynName,relSymTab[rel].dynValue,relSymTab[rel].dynName);
<a name="l00186"></a>00186               <span class="keywordflow">break</span>;
<a name="l00187"></a>00187             }
<a name="l00188"></a>00188           }
<a name="l00189"></a>00189         <a class="code" href="kmalloc_8h.html#aa9ed6886459604cf73ccdbf6410e487">kfree</a>(elfRel);
<a name="l00190"></a>00190         <span class="keywordflow">break</span>;
<a name="l00191"></a>00191       <span class="keywordflow">case</span> 11:
<a name="l00192"></a>00192         relSymTab = (<a class="code" href="structelfDynSym.html">elfDynSym</a> *)<a class="code" href="kmalloc_8h.html#150eab2ac4ce4553e21ca10e7f441762">kmalloc</a>(sectionHeader[i].shSize);
<a name="l00193"></a>00193         <a class="code" href="file_8h.html#80528d8335cd52755f5d6a92e4f08391">fseek</a>(kmod_fd,sectionHeader[i].shOffset,0x0);
<a name="l00194"></a>00194         <a class="code" href="file_8h.html#3b06878a03209e88c008c77234b89359">fread</a>(relSymTab,sectionHeader[i].shSize,1,kmod_fd);
<a name="l00195"></a>00195         sym = i;
<a name="l00196"></a>00196         <span class="keywordflow">break</span>;
<a name="l00197"></a>00197       }
<a name="l00198"></a>00198     }
<a name="l00199"></a>00199 
<a name="l00200"></a>00200   i = binaryHeader-&gt;<a class="code" href="structelfHeader.html#8ff3dd1b27053bc5a2f01afe5403e53b">eEntry</a> + <a class="code" href="kmod_8h.html#f4d6f389174a00e0de80e1ea0e23e956">LD_START</a>;
<a name="l00201"></a>00201 
<a name="l00202"></a>00202   <a class="code" href="kmalloc_8h.html#aa9ed6886459604cf73ccdbf6410e487">kfree</a>(dynStr);
<a name="l00203"></a>00203   <a class="code" href="kmalloc_8h.html#aa9ed6886459604cf73ccdbf6410e487">kfree</a>(shStr);
<a name="l00204"></a>00204   <a class="code" href="kmalloc_8h.html#aa9ed6886459604cf73ccdbf6410e487">kfree</a>(relSymTab);
<a name="l00205"></a>00205   <a class="code" href="kmalloc_8h.html#aa9ed6886459604cf73ccdbf6410e487">kfree</a>(sectionHeader);
<a name="l00206"></a>00206   <a class="code" href="kmalloc_8h.html#aa9ed6886459604cf73ccdbf6410e487">kfree</a>(programHeader);
<a name="l00207"></a>00207   <a class="code" href="kmalloc_8h.html#aa9ed6886459604cf73ccdbf6410e487">kfree</a>(binaryHeader);
<a name="l00208"></a>00208   <a class="code" href="file_8h.html#872c22366b4c63f4bdb10cd3b7980b11">fclose</a>(kmod_fd);
<a name="l00209"></a>00209 
<a name="l00210"></a>00210   <span class="keywordflow">return</span>((<a class="code" href="types_8h.html#5847ea0262a5aa61eee48cbe95544a78">uInt32</a>)i);
<a name="l00211"></a>00211   }
<a name="l00212"></a>00212 
<a name="l00213"></a>00213 <span class="comment">/***</span>
<a name="l00214"></a>00214 <span class="comment"> END</span>
<a name="l00215"></a>00215 <span class="comment"> ***/</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Dec 15 11:18:55 2006 for UbixOS V2 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>