⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fat_8c-source.html

📁 方便飞利浦arm7tdmi 处理器lpc2100开发的C函数库 Procyon ARMlib-LPC2100 C-Language Function Library for Philips LPC21
💻 HTML
📖 第 1 页 / 共 4 页
字号:
00159                 <span class="keywordflow">break</span>;00160     }00161 00162     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"First sector    : "</span>);   <a class="code" href="rprintf_8h.html#a15">rprintfu32</a>(PartInfo.prStartLBA);    <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00163     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"Size            : "</span>);   <a class="code" href="rprintf_8h.html#a15">rprintfu32</a>(PartInfo.prSize);        <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00164     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"bytes/sector    : "</span>);   <a class="code" href="rprintf_8h.html#a14">rprintfu16</a>(bpb-&gt;bpbBytesPerSec);    <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00165     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"sectors/cluster : "</span>);   <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(bpb-&gt;bpbSecPerClust);    <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00166     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"reserved sectors: "</span>);   <a class="code" href="rprintf_8h.html#a14">rprintfu16</a>(bpb-&gt;bpbResSectors);     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00167     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"FatSectors      : "</span>);   <a class="code" href="rprintf_8h.html#a14">rprintfu16</a>(bpb-&gt;bpbFATsecs);        <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00168     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"BigFatSectors   : "</span>);   <a class="code" href="rprintf_8h.html#a15">rprintfu32</a>(bpb-&gt;bpbBigFATsecs);     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00169     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"Number of Fats  : "</span>);   <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(bpb-&gt;bpbFATs);           <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00170     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"First Fat Sector: "</span>);   <a class="code" href="rprintf_8h.html#a15">rprintfu32</a>(FirstFATSector);         <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00171     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"First Data Sect : "</span>);   <a class="code" href="rprintf_8h.html#a15">rprintfu32</a>(FirstDataSector);        <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00172     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"RootDirStartClus: "</span>);   <a class="code" href="rprintf_8h.html#a15">rprintfu32</a>(RootDirStartCluster);    <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00173 <span class="preprocessor">#endif</span>00174 <span class="preprocessor"></span>00175     <span class="keywordflow">return</span> 0;   00176 }00177 00178 <span class="keywordtype">void</span> fatPrintPartition(<span class="keyword">struct</span> partrecord *partition)00179 {00180     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"----- Partition -----\r\n"</span>);00181     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"Active        : "</span>); <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(partition-&gt;prIsActive);      <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00182     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"StartHead     : "</span>); <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(partition-&gt;prStartHead);     <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00183     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"StartCylSect  : "</span>); <a class="code" href="rprintf_8h.html#a14">rprintfu16</a>(partition-&gt;prStartCylSect);  <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00184     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"Partition Type: "</span>);00185     <span class="keywordflow">switch</span>(partition-&gt;prPartType)00186     {00187         <span class="keywordflow">case</span> PART_TYPE_DOSFAT16:00188                 <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"Found: DOSFAT 16\r\n"</span>);00189                 <span class="keywordflow">break</span>;00190         <span class="keywordflow">case</span> PART_TYPE_FAT16:00191                 <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"Found: FAT16\r\n"</span>);00192                 <span class="keywordflow">break</span>;00193         <span class="keywordflow">case</span> PART_TYPE_FAT16LBA:00194                 <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"Found: FAT16 LBA\r\n"</span>);00195                 <span class="keywordflow">break</span>;00196         <span class="keywordflow">case</span> PART_TYPE_FAT32LBA:00197                 <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"Found: FAT32 LBA\r\n"</span>);00198                 <span class="keywordflow">break</span>;00199         <span class="keywordflow">case</span> PART_TYPE_FAT32:00200                 <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"Found: FAT32\r\n"</span>);00201                 <span class="keywordflow">break</span>;00202         <span class="keywordflow">case</span> PART_TYPE_UNKNOWN:00203                 <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"No Partition\r\n"</span>);00204                 <span class="keywordflow">break</span>;00205         <span class="keywordflow">default</span>:00206                 rprintf(<span class="stringliteral">"Type: 0x%x\r\n"</span>, partition-&gt;prPartType);00207                 <span class="keywordflow">break</span>;00208     }00209     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"EndHead       : "</span>); <a class="code" href="rprintf_8h.html#a13">rprintfu08</a>(partition-&gt;prEndHead);       <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00210     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"EndCylSect    : "</span>); <a class="code" href="rprintf_8h.html#a14">rprintfu16</a>(partition-&gt;prEndCylSect);    <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00211     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"StartLBA      : "</span>); <a class="code" href="rprintf_8h.html#a15">rprintfu32</a>(partition-&gt;prStartLBA);      <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00212     <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"Size          : "</span>); <a class="code" href="rprintf_8h.html#a15">rprintfu32</a>(partition-&gt;prSize);          <a class="code" href="rprintf_8c.html#a10">rprintfCRLF</a>();00213 }00214 00215 <span class="keywordtype">void</span> fatPrintPartitionTable(<span class="keyword">struct</span> partsector *buffer)00216 {00217     ataReadSectors(DRIVE0, 0, 1, SectorBuffer);00218     buffer = SectorBuffer;00219 00220     fatPrintPartition( (<span class="keyword">struct</span> partrecord*) &amp;(buffer-&gt;psPart[0x00]) );00221     fatPrintPartition( (<span class="keyword">struct</span> partrecord*) &amp;(buffer-&gt;psPart[0x10]) );00222     fatPrintPartition( (<span class="keyword">struct</span> partrecord*) &amp;(buffer-&gt;psPart[0x20]) );00223     fatPrintPartition( (<span class="keyword">struct</span> partrecord*) &amp;(buffer-&gt;psPart[0x30]) );00224     00225     <span class="keywordflow">if</span>( (buffer-&gt;psBootSectSig0 == BOOTSIG0) &amp;&amp;00226         (buffer-&gt;psBootSectSig1 == BOOTSIG1) )00227     {00228         <a class="code" href="rprintf_8h.html#a8">rprintfStr</a>(<span class="stringliteral">"Partition Sector Valid."</span>);00229     }00230 }00231 00232 <span class="comment"></span>00233 <span class="comment">//////////////////////////////////////////////////////////////</span>00234 <span class="comment"></span>00235 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> fatGetDirEntry(<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> entry)00236 {00237     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> sector;00238     <span class="keyword">struct </span>direntry *de = 0;    <span class="comment">// avoid compiler warning by initializing</span>00239     <span class="keyword">struct </span>winentry *we;00240     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> haveLongNameEntry;00241     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> gotEntry;00242     <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> b;00243     <span class="keywordtype">int</span> i,index;00244     <span class="keywordtype">char</span> *fnbPtr;00245     <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> entrycount = 0;00246 00247     <span class="comment">// read dir data</span>00248     sector = fatClustToSect(CurrentDirStartCluster);00249 00250     haveLongNameEntry = 0;00251     gotEntry = 0;00252 00253     index = 16; <span class="comment">// crank it up</span>00254     00255     <span class="comment">//while(entrycount &lt; entry) </span>00256     <span class="keywordflow">while</span>(1)00257     {00258         <span class="keywordflow">if</span>(index == 16) <span class="comment">// time for next sector ?</span>00259         {00260             ataReadSectors( DRIVE0, sector++, 1, SectorBuffer);00261             de = (<span class="keyword">struct </span>direntry *) SectorBuffer;00262             index = 0;00263         }00264         00265         <span class="comment">// check the status of this directory entry slot</span>00266         <span class="keywordflow">if</span>(de-&gt;deName[0] == 0x00)00267         {00268             <span class="comment">// slot is empty and this is the end of directory</span>00269             gotEntry = 0;00270             <span class="keywordflow">break</span>;00271         }00272         <span class="keywordflow">else</span> <span class="keywordflow">if</span>(de-&gt;deName[0] == 0xE5)00273         {00274             <span class="comment">// this is an empty slot</span>00275             <span class="comment">// do nothing and move to the next one</span>00276         }00277         <span class="keywordflow">else</span>00278         {00279             <span class="comment">// this is a valid and occupied entry</span>00280             <span class="comment">// is it a part of a long file/dir name?</span>00281             <span class="keywordflow">if</span>(de-&gt;deAttributes == ATTR_LONG_FILENAME)00282             {00283                 <span class="comment">// we have a long name entry</span>00284                 <span class="comment">// cast this directory entry as a "windows" (LFN: LongFileName) entry</span>00285                 we = (<span class="keyword">struct </span>winentry *) de;00286                 00287                 b = WIN_ENTRY_CHARS*( (we-&gt;weCnt-1) &amp; 0x0f);        <span class="comment">// index into string</span>00288                 fnbPtr = &amp;FileNameBuffer[b];00289                 <span class="keywordflow">for</span> (i=0;i&lt;5;i++)   *fnbPtr++ = we-&gt;wePart1[i*2];   <span class="comment">// copy first part</span>00290                 <span class="keywordflow">for</span> (i=0;i&lt;6;i++)   *fnbPtr++ = we-&gt;wePart2[i*2];   <span class="comment">// second part</span>00291                 <span class="keywordflow">for</span> (i=0;i&lt;2;i++)   *fnbPtr++ = we-&gt;wePart3[i*2];   <span class="comment">// and third part</span>00292                 <span class="keywordflow">if</span> (we-&gt;weCnt &amp; WIN_LAST) *fnbPtr = 0;              <span class="comment">// in case dirnamelength is multiple of 13, add termination</span>00293                 <span class="keywordflow">if</span> ((we-&gt;weCnt &amp; 0x0f) == 1) haveLongNameEntry = 1; <span class="comment">// flag that we have a complete long name entry set</span>00294             }00295             <span class="keywordflow">else</span>00296             {00297                 <span class="comment">// we have a short name entry</span>00298                 00299                 <span class="comment">// check if this is the short name entry corresponding</span>00300                 <span class="comment">// to the end of a multi-part long name entry</span>00301                 <span class="keywordflow">if</span>(haveLongNameEntry)00302                 {00303                     <span class="comment">// a long entry name has been collected</span>00304                     <span class="keywordflow">if</span>(entrycount == entry)     00305                     {00306                         <span class="comment">// desired entry has been found, break out</span>00307                         gotEntry = 1;00308                         <span class="keywordflow">break</span>;00309                     }00310                     <span class="comment">// otherwise</span>00311                     haveLongNameEntry = 0;  <span class="comment">// clear long name flag</span>00312                     entrycount++;           <span class="comment">// increment entry counter      </span>00313                 }00314                 <span class="keywordflow">else</span>00315                 {00316                     <span class="comment">// entry is a short name (8.3 format) without a</span>00317                     <span class="comment">// corresponding multi-part long name entry</span>00318                     fnbPtr = FileNameBuffer;00319                     <span class="keywordflow">for</span> (i=0;i&lt;8;i++)   *fnbPtr++ = de-&gt;deName[i];      <span class="comment">// copy name</span>00320                     *fnbPtr++ = <span class="charliteral">'.'</span>;                                    <span class="comment">// insert '.'</span>00321                     <span class="keywordflow">for</span> (i=0;i&lt;3;i++)   *fnbPtr++ = de-&gt;deExtension[i]; <span class="comment">// copy extension</span>00322                     *fnbPtr = 0;                                        <span class="comment">// null-terminate</span>00323 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -