ZealOS/docs/System/Boot/BootHDIns.CC.html

112 lines
10 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=cF2>//See </span><a href="https://tomawezome.github.io/ZealOS/Doc/Install.html#l1"><span class=cF4>Install Documentation</span></a><span class=cF2>.</span><span class=cF0>
<a name="l2"></a></span><span class=cF2>//Study the account examples: </span><a href="https://tomawezome.github.io/ZealOS/Demo/AcctExample/TOS/TOSConfig.html#l1"><span class=cF4>Config Strs</span></a><span class=cF2>, </span><a href="https://tomawezome.github.io/ZealOS/Demo/AcctExample/TOS/TOSDistro.html#l1"><span class=cF4>Update Funs</span></a><span class=cF0>
<a name="l3"></a>
<a name="l4"></a>#</span><span class=cF1>include</span><span class=cF0> </span><span class=cF6>&quot;BootHD&quot;</span><span class=cF0>
<a name="l5"></a>
<a name="l6"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;Install&quot;</span><span class=cF0>
<a name="l7"></a>
<a name="l8"></a>#</span><span class=cF1>define</span><span class=cF0> </span><span class=cF3>KERNEL_BIN_C</span><span class=cF0> </span><span class=cF6>&quot;Kernel.BIN.C&quot;</span><span class=cF0>
<a name="l9"></a>
<a name="l10"></a>
<a name="l11"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>CompComp</span><span class=cF0>()
<a name="l12"></a>{
<a name="l13"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Comp</span><span class=cF7>(</span><span class=cF6>&quot;/Compiler/Compiler&quot;</span><span class=cF0>, </span><span class=cF6>&quot;Compiler&quot;</span><span class=cF0>,, </span><span class=cF6>':'</span><span class=cF7>)</span><span class=cF0>)
<a name="l14"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l15"></a>}
<a name="l16"></a>
<a name="l17"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>MakeAll</span><span class=cF0>()
<a name="l18"></a>{
<a name="l19"></a> </span><span class=cF5>CompComp</span><span class=cF0>;
<a name="l20"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Comp</span><span class=cF7>(</span><span class=cF6>&quot;/Kernel/Kernel&quot;</span><span class=cF0>, </span><span class=cF6>&quot;Kernel&quot;</span><span class=cF0>,, </span><span class=cF6>':'</span><span class=cF7>)</span><span class=cF0>)
<a name="l21"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l22"></a>}
<a name="l23"></a>
<a name="l24"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>BootHDIns</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> drv_let=</span><span class=cFE>0</span><span class=cF0>)
<a name="l25"></a>{</span><span class=cF2>//</span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootHDIns.html#l17"><span class=cF4>MakeAll</span></a><span class=cF2> and install new boot-loader.</span><span class=cF0>
<a name="l26"></a> </span><span class=cF9>CDrive</span><span class=cF0> *drive;
<a name="l27"></a> </span><span class=cF9>CFAT32Boot</span><span class=cF0> br;
<a name="l28"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
<a name="l29"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l30"></a>
<a name="l31"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l32"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l33"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Drive</span><span class=cF7>(</span><span class=cF0>drv_let</span><span class=cF7>)</span><span class=cF0>)
<a name="l34"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l35"></a>
<a name="l36"></a> drive = </span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_dv;
<a name="l37"></a> </span><span class=cF5>MakeAll</span><span class=cF0>;
<a name="l38"></a>
<a name="l39"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>Letter2BlkDevType</span><span class=cF7>(</span><span class=cF0>drive-&gt;drv_let</span><span class=cF7>)</span><span class=cF0>)
<a name="l40"></a> {
<a name="l41"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_RAM</span><span class=cF0>:
<a name="l42"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ATA</span><span class=cF0>:
<a name="l43"></a> </span><span class=cF5>Move</span><span class=cF0>(</span><span class=cF6>&quot;/Kernel/Kernel.BIN&quot;</span><span class=cF0>, </span><span class=cF6>&quot;/&quot;</span><span class=cF0> </span><span class=cF3>KERNEL_BIN_C</span><span class=cF0>);
<a name="l44"></a>
<a name="l45"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>FileFind</span><span class=cF7>(</span><span class=cF6>&quot;/&quot;</span><span class=cF0> </span><span class=cF3>KERNEL_BIN_C</span><span class=cF0>, &amp;de, </span><span class=cF3>FUF_JUST_FILES</span><span class=cF7>)</span><span class=cF0>)
<a name="l46"></a> </span><span class=cF6>&quot;No Kernel.BIN.C\n&quot;</span><span class=cF0>;
<a name="l47"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l48"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l49"></a> </span><span class=cF5>Free</span><span class=cF0>(de.full_name);
<a name="l50"></a> </span><span class=cF6>&quot;Modifying partition boot record.\n&quot;</span><span class=cF0>;
<a name="l51"></a> </span><span class=cF5>BlkRead</span><span class=cF0>(drive, &amp;br, drive-&gt;drv_offset, </span><span class=cFE>1</span><span class=cF0>);
<a name="l52"></a>
<a name="l53"></a> br.jump_and_nop[</span><span class=cFE>0</span><span class=cF0>] = </span><span class=cF3>OC_JMP_REL8</span><span class=cF0>;
<a name="l54"></a> br.jump_and_nop[</span><span class=cFE>1</span><span class=cF0>] = </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32Boot</span><span class=cF0>.code) - </span><span class=cFE>2</span><span class=cF0>;
<a name="l55"></a>
<a name="l56"></a>#</span><span class=cF1>assert</span><span class=cF0> </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32Boot</span><span class=cF0>.code) &gt;= </span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CRedSeaBoot</span><span class=cF0>.code)
<a name="l57"></a>
<a name="l58"></a> br.jump_and_nop[</span><span class=cFE>2</span><span class=cF0>] = </span><span class=cF3>OC_NOP</span><span class=cF0>;
<a name="l59"></a> *</span><span class=cFD>BHD_BLK_COUNT</span><span class=cF0>(</span><span class=cF9>U16</span><span class=cF0> *) = (de.size + </span><span class=cF3>BLK_SIZE</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>) &gt;&gt; </span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>;
<a name="l60"></a> *</span><span class=cFD>BHD_DAP_BLK</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *) = </span><span class=cF5>Clus2Blk</span><span class=cF0>(drive, de.clus);
<a name="l61"></a>
<a name="l62"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cFD>BHD_END</span><span class=cF0> - </span><span class=cFD>BHD_CODE</span><span class=cF0>; i++)
<a name="l63"></a> br.code[i] = </span><span class=cFD>BHD_CODE</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *)[i];
<a name="l64"></a>
<a name="l65"></a>#</span><span class=cF1>assert</span><span class=cF0> </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CFAT32Boot</span><span class=cF0>.code) &gt;= </span><span class=cFD>BHD_END</span><span class=cF0> - </span><span class=cFD>BHD_CODE</span><span class=cF0>
<a name="l66"></a>
<a name="l67"></a> </span><span class=cF1>for</span><span class=cF0> (; i &lt; </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CFAT32Boot</span><span class=cF0>.code</span><span class=cF7>)</span><span class=cF0>; i++)
<a name="l68"></a> br.code[i] = </span><span class=cFE>0</span><span class=cF0>;
<a name="l69"></a>
<a name="l70"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(drive, &amp;br, drive-&gt;drv_offset, </span><span class=cFE>1</span><span class=cF0>);
<a name="l71"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l72"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l73"></a>
<a name="l74"></a> </span><span class=cF1>default</span><span class=cF0>:
<a name="l75"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l76"></a> }
<a name="l77"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l78"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l79"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l80"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l81"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l82"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l83"></a>}
</span></pre></body>
</html>