mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-30 17:26:31 +00:00
138 lines
13 KiB
HTML
Executable file
138 lines
13 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V0.05">
|
|
<style type="text/css">
|
|
body {background-color:#000000;}
|
|
.cF0{color:#ffffff;background-color:#000000;}
|
|
.cF1{color:#3465a4;background-color:#000000;}
|
|
.cF2{color:#4e9a06;background-color:#000000;}
|
|
.cF3{color:#06989a;background-color:#000000;}
|
|
.cF4{color:#a24444;background-color:#000000;}
|
|
.cF5{color:#75507b;background-color:#000000;}
|
|
.cF6{color:#ce982f;background-color:#000000;}
|
|
.cF7{color:#bcc0b9;background-color:#000000;}
|
|
.cF8{color:#555753;background-color:#000000;}
|
|
.cF9{color:#729fcf;background-color:#000000;}
|
|
.cFA{color:#82bc49;background-color:#000000;}
|
|
.cFB{color:#34e2e2;background-color:#000000;}
|
|
.cFC{color:#ac3535;background-color:#000000;}
|
|
.cFD{color:#ad7fa8;background-color:#000000;}
|
|
.cFE{color:#fce94f;background-color:#000000;}
|
|
.cFF{color:#000000;background-color:#000000;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>DriveTypeSet</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>
|
|
<a name="l7"></a> drv_let = </span><span class=cF5>Letter2Letter</span><span class=cF0>(drv_let);
|
|
<a name="l8"></a> bd = </span><span class=cF5>Letter2BlkDev</span><span class=cF0>(drv_let);
|
|
<a name="l9"></a> drv_num = bd->first_drive_let - </span><span class=cF6>'A'</span><span class=cF0>;
|
|
<a name="l10"></a> </span><span class=cF1>switch</span><span class=cF0> (bd->type)
|
|
<a name="l11"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l12"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ATA</span><span class=cF0>:
|
|
<a name="l13"></a> </span><span class=cF1>offset</span><span class=cF0> = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l14"></a> ext_base = </span><span class=cF3>INVALID_CLUS</span><span class=cF0>;
|
|
<a name="l15"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l16"></a> {
|
|
<a name="l17"></a> </span><span class=cF5>AHCIAtaBlksRead</span><span class=cF0>(bd, &mbr, </span><span class=cF1>offset</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l18"></a> j =- </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l19"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < </span><span class=cFE>4</span><span class=cF0>; i++)
|
|
<a name="l20"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l21"></a> cur_type = mbr.p[i].type;
|
|
<a name="l22"></a> </span><span class=cF1>if</span><span class=cF0> (cur_type)
|
|
<a name="l23"></a> {
|
|
<a name="l24"></a> </span><span class=cF1>if</span><span class=cF0> (cur_type == </span><span class=cFE>5</span><span class=cF0> || cur_type == </span><span class=cFE>15</span><span class=cF0>)
|
|
<a name="l25"></a> j = i;
|
|
<a name="l26"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l27"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l28"></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="l29"></a> {
|
|
<a name="l30"></a> </span><span class=cF1>switch</span><span class=cF0> (type)
|
|
<a name="l31"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l32"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_REDSEA</span><span class=cF0>:
|
|
<a name="l33"></a> mbr.p[i].type = </span><span class=cF3>MBR_PT_REDSEA</span><span class=cF0>;
|
|
<a name="l34"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l35"></a>
|
|
<a name="l36"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_FAT32</span><span class=cF0>:
|
|
<a name="l37"></a> mbr.p[i].type = </span><span class=cF3>MBR_PT_FAT32a</span><span class=cF0>;
|
|
<a name="l38"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l39"></a>
|
|
<a name="l40"></a> </span><span class=cF1>default</span><span class=cF0>:
|
|
<a name="l41"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drive'</span><span class=cF0>);
|
|
<a name="l42"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l43"></a> mbr.p[i].active = </span><span class=cFE>0x80</span><span class=cF0>;
|
|
<a name="l44"></a> </span><span class=cF5>AHCIAtaBlksWrite</span><span class=cF0>(bd, &mbr, </span><span class=cF1>offset</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l45"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l46"></a> }
|
|
<a name="l47"></a> drv_num++;
|
|
<a name="l48"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l49"></a> }
|
|
<a name="l50"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l51"></a> </span><span class=cF1>if</span><span class=cF0> (j < </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l52"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l53"></a> </span><span class=cF1>if</span><span class=cF0> (!mbr.p[j].</span><span class=cF1>offset</span><span class=cF0>)
|
|
<a name="l54"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l55"></a> </span><span class=cF1>if</span><span class=cF0> (ext_base == </span><span class=cF3>INVALID_CLUS</span><span class=cF0>)
|
|
<a name="l56"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l57"></a> </span><span class=cF1>offset</span><span class=cF0> = mbr.p[j].</span><span class=cF1>offset</span><span class=cF0>;
|
|
<a name="l58"></a> ext_base = </span><span class=cF1>offset</span><span class=cF0>;
|
|
<a name="l59"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l60"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l61"></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="l62"></a> }
|
|
<a name="l63"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l64"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l65"></a>}
|
|
<a name="l66"></a>
|
|
<a name="l67"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Format</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="l68"></a>{</span><span class=cF2>//Format hard drive or RAM drive.</span><span class=cF0>
|
|
<a name="l69"></a></span><span class=cF2>//Warning: Destroys all prev info.</span><span class=cF0>
|
|
<a name="l70"></a> </span><span class=cF2>//quick=FALSE means fill entire drive with zeros.</span><span class=cF0>
|
|
<a name="l71"></a> </span><span class=cF2>//Choose </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.html#l3311"><span class=cF4>FSt_FAT32</span></a><span class=cF2> or </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.html#l3310"><span class=cF4>FSt_REDSEA</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l72"></a> </span><span class=cF2>//You don't format a CD/DVD with this.</span><span class=cF0>
|
|
<a name="l73"></a> </span><span class=cF9>CDrive</span><span class=cF0> *drive = </span><span class=cF5>Letter2Drive</span><span class=cF0>(drv_let);
|
|
<a name="l74"></a> </span><span class=cF1>Bool</span><span class=cF0> old_silent = </span><span class=cF5>IsSilent</span><span class=cF0>;
|
|
<a name="l75"></a>
|
|
<a name="l76"></a> </span><span class=cF1>if</span><span class=cF0> (confirm && !</span><span class=cF5>AreYouSure</span><span class=cF0>)
|
|
<a name="l77"></a> </span><span class=cF1>return</span><span class=cF0>;
|
|
<a name="l78"></a> </span><span class=cF1>if</span><span class=cF0> (!drive)
|
|
<a name="l79"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l80"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"Invalid Drive\n"</span><span class=cF0>);
|
|
<a name="l81"></a> </span><span class=cF1>return</span><span class=cF0>;
|
|
<a name="l82"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l83"></a> </span><span class=cF1>switch</span><span class=cF0> (type)
|
|
<a name="l84"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l85"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_FAT32</span><span class=cF0>:
|
|
<a name="l86"></a> </span><span class=cF1>if</span><span class=cF0> (drive->bd->type == </span><span class=cF3>BDT_ATA</span><span class=cF0>)
|
|
<a name="l87"></a> {
|
|
<a name="l88"></a> </span><span class=cF5>Silent</span><span class=cF0>;
|
|
<a name="l89"></a> </span><span class=cF5>Drive</span><span class=cF0>(drv_let);
|
|
<a name="l90"></a> </span><span class=cF5>Silent</span><span class=cF0>(old_silent);
|
|
<a name="l91"></a> </span><span class=cFD>FAT32Format</span><span class=cF0>(drv_let, quick);
|
|
<a name="l92"></a> </span><span class=cF5>DiskCacheInvalidate</span><span class=cF0>(</span><span class=cF5>Letter2Drive</span><span class=cF7>(</span><span class=cF0>drv_let</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l93"></a> </span><span class=cF5>Drive</span><span class=cF0>(drv_let);
|
|
<a name="l94"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l95"></a> }
|
|
<a name="l96"></a> </span><span class=cF6>"Using RedSea File System.\n"</span><span class=cF0>;
|
|
<a name="l97"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_REDSEA</span><span class=cF0>:
|
|
<a name="l98"></a> </span><span class=cF5>Silent</span><span class=cF0>;
|
|
<a name="l99"></a> </span><span class=cF5>Drive</span><span class=cF0>(drv_let);
|
|
<a name="l100"></a> </span><span class=cF5>Silent</span><span class=cF0>(old_silent);
|
|
<a name="l101"></a> </span><span class=cFD>RedSeaFormat</span><span class=cF0>(drv_let, quick);
|
|
<a name="l102"></a> </span><span class=cF5>DiskCacheInvalidate</span><span class=cF0>(</span><span class=cF5>Letter2Drive</span><span class=cF7>(</span><span class=cF0>drv_let</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l103"></a> </span><span class=cF5>Drive</span><span class=cF0>(drv_let);
|
|
<a name="l104"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l105"></a>
|
|
<a name="l106"></a> </span><span class=cF1>default</span><span class=cF0>:
|
|
<a name="l107"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"File System Not Supported\n"</span><span class=cF0>);
|
|
<a name="l108"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l109"></a>}
|
|
</span></pre></body>
|
|
</html>
|