?? filesys_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>VLSI Solution Oy Evaluation MP3 Player Source Code Documentation</title><link href="doxygen.css" rel="stylesheet" type="text/css"><img src="vlsi_small.gif" hspace="20" bordercolor="#ffffff" alt="VLSI Solution Oy"><b>VLSI Solution Oy Evaluation MP3 Player Source Code Documentation</b><p></p></head><body><!-- Generated by Doxygen 1.3.7 --><div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div><h1>filesys.c</h1><a href="filesys_8c.html">Go to the documentation of this file.</a><pre class="fragment"><div>00001 00005 <span class="preprocessor">#include "<a class="code" href="board_8h.html">board.h</a>"</span>00006 <span class="preprocessor">#include "<a class="code" href="filesys_8h.html">filesys.h</a>"</span>00007 <span class="preprocessor">#include "<a class="code" href="storage_8h.html">storage.h</a>"</span>00008 <span class="preprocessor">#include "console.h"</span>00009 <span class="preprocessor">#include "<a class="code" href="mmc_8h.html">mmc.h</a>"</span>00010 00011 00012 <span class="comment">/* This needs display to put file name directly to display buffer */</span>00013 <span class="comment">/* It's not pretty but it saves a lot of memory! */</span>00014 <span class="preprocessor">#include "<a class="code" href="display_8h.html">display.h</a>"</span>00015 00016 00017 <a name="l00021"></a><a class="code" href="filesys_8c.html#a2">00021</a> data <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="filesys_8c.html#a2">fatStart</a>;00022 <a name="l00024"></a><a class="code" href="filesys_8c.html#a3">00024</a> data <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="filesys_8c.html#a3">rootStart</a>;00025 <a name="l00029"></a><a class="code" href="filesys_8c.html#a4">00029</a> data <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="filesys_8c.html#a4">dataStart</a>;00030 <a name="l00032"></a><a class="code" href="filesys_8c.html#a5">00032</a> data <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="filesys_8c.html#a5">fatSectorsPerCluster</a>;00033 00034 00035 <a name="l00037"></a><a class="code" href="filesys_8c.html#a0">00037</a> <span class="preprocessor">#define MAX_NUMBER_FRAGMENTS 10</span>00038 <span class="preprocessor"></span>00039 <a name="l00041"></a><a class="code" href="structfragmentEntry.html">00041</a> xdata <span class="keyword">struct </span><a class="code" href="structfragmentEntry.html">fragmentEntry</a> {00042 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="structfragmentEntry.html#o0">start</a>; 00043 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="structfragmentEntry.html#o1">length</a>; 00044 } <a class="code" href="filesys_8c.html#a6">fragment</a>[<a class="code" href="filesys_8c.html#a0">MAX_NUMBER_FRAGMENTS</a>];00045 <a name="l00047"></a><a class="code" href="filesys_8c.html#a7">00047</a> xdata <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="filesys_8c.html#a7">fileSize</a>;00048 <a name="l00050"></a><a class="code" href="filesys_8c.html#a1">00050</a> <span class="preprocessor">#define MAX_NUMBER_SUBDIRECTORIES 5</span>00051 <span class="preprocessor"></span><a name="l00053"></a><a class="code" href="structdirectoryStack.html">00053</a> xdata <span class="keyword">struct </span><a class="code" href="structdirectoryStack.html">directoryStack</a> {<a name="l00054"></a><a class="code" href="structdirectoryStack.html#o0">00054</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="structdirectoryStack.html#o0">sector</a>; <a name="l00055"></a><a class="code" href="structdirectoryStack.html#o1">00055</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="structdirectoryStack.html#o1">entry</a>; 00056 } <a class="code" href="filesys_8c.html#a8">dirStack</a>[<a class="code" href="filesys_8c.html#a1">MAX_NUMBER_SUBDIRECTORIES</a>];00057 <a name="l00059"></a><a class="code" href="filesys_8c.html#a9">00059</a> xdata <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="filesys_8c.html#a9">dirLevel</a> = 0;00060 <a name="l00062"></a><a class="code" href="filesys_8c.html#a10">00062</a> xdata <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="filesys_8c.html#a10">freeSector</a> = 0;00063 <a name="l00065"></a><a class="code" href="filesys_8c.html#a11">00065</a> xdata <span class="keywordtype">char</span> <a class="code" href="filesys_8c.html#a11">currentFileName</a>[12];00066 <a name="l00068"></a><a class="code" href="filesys_8c.html#a12">00068</a> bit <a class="code" href="filesys_8c.html#a12">IS_FAT_12</a> = 0;00069 00070 <a name="l00072"></a><a class="code" href="filesys_8c.html#a13">00072</a> <span class="keywordtype">void</span> <a class="code" href="filesys_8c.html#a13">PConvertSectorToCluster</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *sector){00073 *sector-=<a class="code" href="filesys_8c.html#a4">dataStart</a>;00074 *sector/=<a class="code" href="filesys_8c.html#a5">fatSectorsPerCluster</a>;00075 }00076 <a name="l00078"></a><a class="code" href="filesys_8c.html#a14">00078</a> <span class="keywordtype">void</span> <a class="code" href="filesys_8c.html#a14">PConvertClusterToSector</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *cluster){00079 *cluster*=<a class="code" href="filesys_8c.html#a5">fatSectorsPerCluster</a>;00080 *cluster+=<a class="code" href="filesys_8c.html#a4">dataStart</a>;00081 }00082 00083 <a name="l00085"></a><a class="code" href="filesys_8c.html#a15">00085</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="filesys_8c.html#a15">GetFatEntry</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> clusterNumber){00086 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> entryNumber; <span class="comment">/* entry number inside page */</span>00087 00088 <span class="keywordflow">if</span> (!<a class="code" href="filesys_8h.html#a0">IS_FAT_32</a>){ <span class="comment">//FAT16</span>00089 entryNumber = clusterNumber & 0xff; 00090 clusterNumber >>= 8; 00091 }<span class="keywordflow">else</span>{ <span class="comment">//FAT32</span>00092 entryNumber = clusterNumber & 0x7f;00093 clusterNumber >>= 7; 00094 }00095 clusterNumber += <a class="code" href="filesys_8c.html#a2">fatStart</a>;00096 <span class="keywordflow">if</span> (<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> != clusterNumber){00097 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> = clusterNumber;00098 <a class="code" href="storage_8h.html#a2">ReadDiskSector</a>(<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a>);00099 }00100 <span class="keywordflow">if</span> (<a class="code" href="filesys_8h.html#a0">IS_FAT_32</a>){00101 clusterNumber=<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o4">Fat32Table</a>[entryNumber];00102 <span class="keywordflow">return</span> clusterNumber;00103 }00104 <span class="keywordflow">if</span> ((clusterNumber=<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o3">Fat16Table</a>[entryNumber])==0xffff) <span class="keywordflow">return</span> 0xffffffff;00105 <span class="keywordflow">return</span> clusterNumber;00106 }00107 00108 00109 00110 <a name="l00129"></a><a class="code" href="filesys_8h.html#a12">00129</a> <span class="keywordtype">void</span> <a class="code" href="filesys_8c.html#a16">WriteClusterChain</a>(){00130 00131 xdata <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> currentCluster; <span class="comment">//is now fragment[0].start</span>00132 xdata <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> fragSize; <span class="comment">//is now fragment[0].length</span>00133 xdata <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> fatPageSector;00134 xdata <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> entryNumber; 00135 00136 00137 <span class="comment">// PREPARE</span>00138 00139 <span class="comment">// Calculate starting cluster number...</span>00140 currentCluster = <a class="code" href="filesys_8c.html#a6">fragment</a>[0].<a class="code" href="structfragmentEntry.html#o0">start</a>;00141 <a class="code" href="filesys_8c.html#a13">PConvertSectorToCluster</a>(&currentCluster);00142 00143 fragSize = <a class="code" href="filesys_8c.html#a6">fragment</a>[0].<a class="code" href="structfragmentEntry.html#o1">length</a>; <span class="comment">//size in sectors</span>00144 00145 <span class="comment">// Write cluster number and size in bytes to fragment[0]</span>00146 <span class="comment">// for the function that registers directory entries</span>00147 <a class="code" href="filesys_8c.html#a6">fragment</a>[0].<a class="code" href="structfragmentEntry.html#o0">start</a> = currentCluster;00148 <a class="code" href="filesys_8c.html#a6">fragment</a>[0].<a class="code" href="structfragmentEntry.html#o1">length</a> *= 512;00149 00150 <span class="comment">// Locate the relevant page in FAT clusterchain records</span>00151 fatPageSector = currentCluster;00152 <span class="keywordflow">if</span> (!<a class="code" href="filesys_8h.html#a0">IS_FAT_32</a>){ <span class="comment">//FAT16</span>00153 entryNumber = fatPageSector & 0xff; 00154 fatPageSector >>= 8; 00155 }<span class="keywordflow">else</span>{ <span class="comment">//FAT32</span>00156 entryNumber = fatPageSector & 0x7f;00157 fatPageSector >>= 7; 00158 }00159 fatPageSector += <a class="code" href="filesys_8c.html#a2">fatStart</a>;00160
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -