templeos-info/public/Wb/Kernel/BlkDev/DskFmt.HC.HTML

124 lines
11 KiB
Plaintext
Raw Normal View History

2024-03-24 21:24:44 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>DrvTypeSet</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> drv_let,</span><span class=cF9>I64</span><span class=cF0> type=</span><span class=cF3>FSt_REDSEA</span><span class=cF0>)
<a name="l2"></a>{</span><span class=cF2>//Very dangerous</span><span class=cF0>
<a name="l3"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,ext_base,drv_num,</span><span class=cF1>offset</span><span class=cF0>,cur_type;
<a name="l4"></a> </span><span class=cF9>CMasterBoot</span><span class=cF0> mbr;
<a name="l5"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *bd;
<a name="l6"></a> drv_let=</span><span class=cF5>Let2Let</span><span class=cF0>(drv_let);
<a name="l7"></a> bd=</span><span class=cF5>Let2BlkDev</span><span class=cF0>(drv_let);
<a name="l8"></a> drv_num=bd-&gt;first_drv_let-</span><span class=cF6>'A'</span><span class=cF0>;
<a name="l9"></a> </span><span class=cF1>switch</span><span class=cF0> (bd-&gt;type) </span><span class=cF7>{</span><span class=cF0>
<a name="l10"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ATA</span><span class=cF0>:
<a name="l11"></a> </span><span class=cF1>offset</span><span class=cF0>=0;
<a name="l12"></a> ext_base=</span><span class=cF3>INVALID_CLUS</span><span class=cF0>;
<a name="l13"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
<a name="l14"></a> </span><span class=cF5>ATAReadBlks</span><span class=cF0>(bd,&amp;mbr,</span><span class=cF1>offset</span><span class=cF0>,1);
<a name="l15"></a> j=-1;
<a name="l16"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;4;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l17"></a> cur_type=mbr.p[i].type;
<a name="l18"></a> </span><span class=cF1>if</span><span class=cF0> (cur_type) {
<a name="l19"></a> </span><span class=cF1>if</span><span class=cF0> (cur_type==5 || cur_type==15)
<a name="l20"></a> j=i;
<a name="l21"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l22"></a> </span><span class=cF1>if</span><span class=cF0> (drv_num+</span><span class=cF6>'A'</span><span class=cF0>==drv_let) {
<a name="l23"></a> </span><span class=cF1>switch</span><span class=cF0> (type) </span><span class=cF7>{</span><span class=cF0>
<a name="l24"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_REDSEA</span><span class=cF0>:
<a name="l25"></a> mbr.p[i].type=</span><span class=cF3>MBR_PT_REDSEA</span><span class=cF0>;
<a name="l26"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l27"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_FAT32</span><span class=cF0>:
<a name="l28"></a> mbr.p[i].type=</span><span class=cF3>MBR_PT_FAT32a</span><span class=cF0>;
<a name="l29"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l30"></a> </span><span class=cF1>default</span><span class=cF0>:
<a name="l31"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drv'</span><span class=cF0>);
<a name="l32"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l33"></a> mbr.p[i].active=0x80;
<a name="l34"></a> </span><span class=cF5>ATAWriteBlks</span><span class=cF0>(bd,&amp;mbr,</span><span class=cF1>offset</span><span class=cF0>,1);
<a name="l35"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l36"></a> }
<a name="l37"></a> drv_num++;
<a name="l38"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l39"></a> }
<a name="l40"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l41"></a> </span><span class=cF1>if</span><span class=cF0> (j&lt;0)
<a name="l42"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l43"></a> </span><span class=cF1>if</span><span class=cF0> (!mbr.p[j].</span><span class=cF1>offset</span><span class=cF0>)
<a name="l44"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l45"></a> </span><span class=cF1>if</span><span class=cF0> (ext_base==</span><span class=cF3>INVALID_CLUS</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l46"></a> </span><span class=cF1>offset</span><span class=cF0>=mbr.p[j].</span><span class=cF1>offset</span><span class=cF0>;
<a name="l47"></a> ext_base=</span><span class=cF1>offset</span><span class=cF0>;
<a name="l48"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
<a name="l49"></a> </span><span class=cF1>offset</span><span class=cF0>=mbr.p[j].</span><span class=cF1>offset</span><span class=cF0>+ext_base;
<a name="l50"></a> }
<a name="l51"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l52"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l53"></a>}
<a name="l54"></a>
<a name="l55"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Fmt</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> drv_let,</span><span class=cF1>Bool</span><span class=cF0> quick=</span><span class=cF3>TRUE</span><span class=cF0>,</span><span class=cF1>Bool</span><span class=cF0> confirm=</span><span class=cF3>TRUE</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> type=</span><span class=cF3>FSt_FAT32</span><span class=cF0>)
<a name="l56"></a>{</span><span class=cF2>//Format hard drive or RAM drive.</span><span class=cF0>
<a name="l57"></a></span><span class=cF2>//Warning: Destroys all prev info.</span><span class=cF0>
<a name="l58"></a> </span><span class=cF2>//quick=FALSE means fill entire drive with zeros.</span><span class=cF0>
<a name="l59"></a> </span><span class=cF2>//Choose </span><a href="/Wb/Kernel/KernelA.HH.HTML#l2660"><span class=cF4>FSt_FAT32</span></a><span class=cF2> or </span><a href="/Wb/Kernel/KernelA.HH.HTML#l2659"><span class=cF4>FSt_REDSEA</span></a><span class=cF2>.</span><span class=cF0>
<a name="l60"></a> </span><span class=cF2>//You don't format a CD/DVD with this.</span><span class=cF0>
<a name="l61"></a> </span><span class=cF9>CDrv</span><span class=cF0> *dv=</span><span class=cF5>Let2Drv</span><span class=cF0>(drv_let);
<a name="l62"></a> </span><span class=cF1>Bool</span><span class=cF0> old_silent=</span><span class=cF5>IsSilent</span><span class=cF0>;
<a name="l63"></a> </span><span class=cF1>if</span><span class=cF0> (confirm &amp;&amp; !</span><span class=cF5>AreYouSure</span><span class=cF0>)
<a name="l64"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l65"></a> </span><span class=cF1>if</span><span class=cF0> (!dv) </span><span class=cF7>{</span><span class=cF0>
<a name="l66"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>&quot;Invalid Drive\n&quot;</span><span class=cF0>);
<a name="l67"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l68"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l69"></a> </span><span class=cF1>switch</span><span class=cF0> (type) </span><span class=cF7>{</span><span class=cF0>
<a name="l70"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_FAT32</span><span class=cF0>:
<a name="l71"></a> </span><span class=cF1>if</span><span class=cF0> (dv-&gt;bd-&gt;type==</span><span class=cF3>BDT_ATA</span><span class=cF0>) {
<a name="l72"></a> </span><span class=cF5>Silent</span><span class=cF0>;
<a name="l73"></a> </span><span class=cF5>Drv</span><span class=cF0>(drv_let);
<a name="l74"></a> </span><span class=cF5>Silent</span><span class=cF0>(old_silent);
<a name="l75"></a> </span><span class=cFD>FAT32Fmt</span><span class=cF0>(drv_let,quick);
<a name="l76"></a> </span><span class=cF5>DskCacheInvalidate</span><span class=cF0>(</span><span class=cF5>Let2Drv</span><span class=cF7>(</span><span class=cF0>drv_let</span><span class=cF7>)</span><span class=cF0>);
<a name="l77"></a> </span><span class=cF5>Drv</span><span class=cF0>(drv_let);
<a name="l78"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l79"></a> }
<a name="l80"></a> </span><span class=cF6>&quot;Using RedSea File System.\n&quot;</span><span class=cF0>;
<a name="l81"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_REDSEA</span><span class=cF0>:
<a name="l82"></a> </span><span class=cF5>Silent</span><span class=cF0>;
<a name="l83"></a> </span><span class=cF5>Drv</span><span class=cF0>(drv_let);
<a name="l84"></a> </span><span class=cF5>Silent</span><span class=cF0>(old_silent);
<a name="l85"></a> </span><span class=cFD>RedSeaFmt</span><span class=cF0>(drv_let,quick);
<a name="l86"></a> </span><span class=cF5>DskCacheInvalidate</span><span class=cF0>(</span><span class=cF5>Let2Drv</span><span class=cF7>(</span><span class=cF0>drv_let</span><span class=cF7>)</span><span class=cF0>);
<a name="l87"></a> </span><span class=cF5>Drv</span><span class=cF0>(drv_let);
<a name="l88"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l89"></a> </span><span class=cF1>default</span><span class=cF0>:
<a name="l90"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>&quot;File System Not Supported\n&quot;</span><span class=cF0>);
<a name="l91"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l92"></a>}
</span></pre></body>
</html>