📄 filesys_8h.html
字号:
<p>Start the filing system and initialize all necessary subsystems. <p>Init storage and file system. FAT16 and FAT32 are supported <p>Definition at line <a class="el" href="filesys_8c-source.html#l00923">923</a> of file <a class="el" href="filesys_8c-source.html">filesys.c</a>.<p>References <a class="el" href="unionAddress.html#o1">Address::b</a>, <a class="el" href="buffer_8h-source.html#l00131">Address::B::b0</a>, <a class="el" href="buffer_8h-source.html#l00132">Address::B::b1</a>, <a class="el" href="buffer_8h-source.html#l00133">Address::B::b2</a>, <a class="el" href="buffer_8h-source.html#l00134">Address::B::b3</a>, <a class="el" href="buffer_8h-source.html#l00107">DiskBlock::Raw::buf</a>, <a class="el" href="filesys_8c-source.html#l00029">dataStart</a>, <a class="el" href="buffer_8c-source.html#l00010">diskSect</a>, <a class="el" href="filesys_8c-source.html#l00806">FatInitGlobals()</a>, <a class="el" href="filesys_8c-source.html#l00021">fatStart</a>, <a class="el" href="filesys_8c-source.html#l00062">freeSector</a>, <a class="el" href="storage_8c-source.html#l00043">InitStorage()</a>, <a class="el" href="buffer_8h-source.html#l00129">Address::l</a>, <a class="el" href="board_8h-source.html#l00280">Public</a>, <a class="el" href="unionDiskBlock.html#o1">DiskBlock::raw</a>, <a class="el" href="storage_8c-source.html#l00110">ReadDiskSector()</a>, <a class="el" href="filesys_8c-source.html#l00024">rootStart</a>, and <a class="el" href="buffer_8c-source.html#l00015">sectorAddress</a>.<p>Referenced by <a class="el" href="player_8c-source.html#l00765">main()</a>.<p><pre class="fragment"><div>00923 {00924 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> c;00925 00926 <span class="comment">/* Initialize variables to sane values in case of error exit. */</span>00927 <a class="code" href="filesys_8c.html#a2">fatStart</a> = 0;00928 <a class="code" href="filesys_8c.html#a3">rootStart</a> = 0;00929 <a class="code" href="filesys_8c.html#a4">dataStart</a> = 0;00930 <a class="code" href="filesys_8c.html#a10">freeSector</a> = 0;00931 00932 ConsoleWrite(<span class="stringliteral">"Init: Filesystem; supports: MBR, FAT16, FAT32\r"</span>);00933 00934 ConsoleWrite(<span class="stringliteral">"Trying to bring up storage...\r"</span>);00935 <span class="comment">/* Initialize the storage system */</span>00936 <span class="keywordflow">if</span> ((c=<a class="code" href="storage_8c.html#a1">InitStorage</a>())){00937 ConsoleWrite(<span class="stringliteral">"Storage init returns error "</span>);00938 ConsolePutUInt(c);00939 ConsolePutChar(13);00940 <span class="keywordflow">return</span> c; <span class="comment">/* Error in InitStorage */</span>00941 }00942 00943 ConsoleWrite(<span class="stringliteral">"Storage ok.\rSector 0 read..."</span>);00944 00945 <span class="comment">/* Load MBR */</span>00946 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> = 0; <span class="comment">/* the first sector on disk */</span>00947 <a class="code" href="storage_8h.html#a2">ReadDiskSector</a>(0);00948 00949 00950 00951 00952 ConsoleWrite(<span class="stringliteral">"ok.\rSector signature..."</span>);00953 00954 <span class="comment">/* Ok, it should be a MBR sector. Let's verify */</span>00955 <span class="keywordflow">if</span> (<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[510] != 0x55)00956 <span class="keywordflow">return</span> 8; <span class="comment">/* sector 0 is not MBR. */</span>00957 <span class="keywordflow">if</span> (<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[511] != 0xaa)00958 <span class="keywordflow">return</span> 8; <span class="comment">/* sector 0 is not MBR. */</span>00959 00960 ConsoleWrite(<span class="stringliteral">"ok.\rPartition 1..."</span>);00961 00962 00963 <span class="keywordflow">if</span> (!((<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0x036]==<span class="charliteral">'F'</span>)00964 &&(<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0x037]==<span class="charliteral">'A'</span>)00965 &&(<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0x038]==<span class="charliteral">'T'</span>))){00966 00967 00968 00969 00970 <span class="comment">/* This checks that partition 1 is active. Alter code to allow</span>00971 <span class="comment"> * other partition configurations. */</span>00972 <span class="keywordflow">if</span> (<a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0x1be] == 0x80){00973 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o0">b0</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0x1c6];00974 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o1">b1</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0x1c7];00975 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o2">b2</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0x1c8];00976 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o3">b3</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0x1c9];00977 ConsoleWrite (<span class="stringliteral">" active"</span>);00978 }<span class="keywordflow">else</span>{00979 <span class="comment">//-------- DEBUG: Uncomment if you want to explore the sector</span>00980 <span class="comment">//DumpDiskSector();</span>00981 <span class="comment">//while (!KEY_BUTTON);</span>00982 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o0">b0</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0x1c6];00983 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o1">b1</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0x1c7];00984 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o2">b2</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0x1c8];00985 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o3">b3</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[0x1c9];00986 00987 }00988 00989 <span class="comment">// return 9; /* No active partition*/</span>00990 00991 }00992 00993 ConsoleWrite(<span class="stringliteral">" at sector "</span>);00994 ConsolePutHex8(<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o3">b3</a>);00995 ConsolePutHex8(<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o2">b2</a>);00996 ConsolePutHex8(<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o1">b1</a>);00997 ConsolePutHex8(<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o0">b0</a>);00998 ConsolePutChar(<span class="charliteral">'\r'</span>);00999 01000 01001 <span class="comment">/* Now leave MBR and load sector 0 of partition */</span>01002 <span class="comment">//SeekDiskSectorToRead();</span>01003 <span class="comment">//ReadDiskSector(); /* to global buffer */</span>01004 01005 <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>);01006 01007 <span class="keywordflow">if</span> (<a class="code" href="filesys_8c.html#a23">FatInitGlobals</a>()){01008 <span class="keywordflow">return</span> 0x0a; <span class="comment">/* FAT init failed */</span>01009 }01010 01011 <span class="keywordflow">return</span> 0; <span class="comment">/* All ok return */</span>01012 01013 }</div></pre><p>Here is the call graph for this function:<p><center><img src="filesys_8h_a7_cgraph.png" border="0" usemap="#filesys_8h_a7_cgraph_map" alt=""></center><map name="filesys_8h_a7_cgraph_map"><area href="filesys_8c.html#a23" shape="rect" coords="156,6,244,30" alt=""><area href="storage_8c.html#a1" shape="rect" coords="165,54,235,78" alt=""><area href="storage_8h.html#a2" shape="rect" coords="293,103,394,127" alt=""><area href="mmc_8c.html#a5" shape="rect" coords="316,56,372,79" alt=""><area href="mmc_8c.html#a9" shape="rect" coords="445,56,570,79" alt=""><area href="mmc_8h.html#a2" shape="rect" coords="469,103,546,127" alt=""></map> </td> </tr></table><a class="anchor" name="a8" doxytag="filesys.h::OpenFile" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> unsigned char OpenFile </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">unsigned int </td> <td class="mdname1" valign="top" nowrap> <em>fileNumber</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -