📄 filesys_8h.html
字号:
</td> <td><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#l00262">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#l00733">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 ConsoleWrite(<span class="stringliteral">"ok.\rSector signature..."</span>);00950 00951 <span class="comment">/* Ok, it should be a MBR sector. Let's verify */</span>00952 <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)00953 <span class="keywordflow">return</span> 8; <span class="comment">/* sector 0 is not MBR. */</span>00954 <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)00955 <span class="keywordflow">return</span> 8; <span class="comment">/* sector 0 is not MBR. */</span>00956 00957 ConsoleWrite(<span class="stringliteral">"ok.\rPartition 1..."</span>);00958 00959 <span class="comment">/* This checks that partition 1 is active. Alter code to allow</span>00960 <span class="comment"> * other partition configurations. */</span>00961 <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){00962 <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];00963 <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];00964 <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];00965 <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];00966 ConsoleWrite (<span class="stringliteral">" active"</span>);00967 }<span class="keywordflow">else</span>{00968 <span class="comment">//-------- DEBUG: Uncomment if you want to explore the sector</span>00969 <span class="comment">//DumpDiskSector();</span>00970 <span class="comment">//while (!KEY_BUTTON);</span>00971 <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];00972 <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];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#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];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#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];00975 00976 00977 }00978 00979 <span class="comment">// return 9; /* No active partition*/</span>00980 00981 00982 ConsoleWrite(<span class="stringliteral">" at sector "</span>);00983 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>);00984 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>);00985 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>);00986 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>);00987 ConsolePutChar(<span class="charliteral">'\r'</span>);00988 00989 00990 <span class="comment">/* Now leave MBR and load sector 0 of partition */</span>00991 <span class="comment">//SeekDiskSectorToRead();</span>00992 <span class="comment">//ReadDiskSector(); /* to global buffer */</span>00993 00994 <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>);00995 00996 <span class="keywordflow">if</span> (<a class="code" href="filesys_8c.html#a23">FatInitGlobals</a>()){00997 <span class="keywordflow">return</span> 0x0a; <span class="comment">/* FAT init failed */</span>00998 }00999 01000 <span class="keywordflow">return</span> 0; <span class="comment">/* All ok return */</span>01001 01002 }</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><p>Open a file for reading. <p>Prepares the Filing System to read a data file from the storage. Files are referred to by their numbers, not file names. This makes the system generic, not necessarily needing a complex file system such as FAT. The way to assign numbers to files is implementation dependent. Returns 0 when ok, error code otherwise. <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>fileNumber</em> </td><td>number of file, starting from beginning of storage, to open.</td></tr> </table>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -