templeos-info/public/Wb/Adam/Opt/Boot/BootHDIns.HC.HTML

92 lines
8.9 KiB
HTML
Executable File

<!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=cF2>//See </span><a href="/Wb/Doc/Install.DD.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 my account examples: </span><a href="/Wb/Demo/AcctExample/TOS/TOSCfg.HC.HTML#l1"><span class=cF4>Cfg Strs</span></a><span class=cF2>, </span><a href="/Wb/Demo/AcctExample/TOS/TOSDistro.HC.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></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>MakeAll</span><span class=cF0>()
<a name="l11"></a>{
<a name="l12"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Cmp</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="l13"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l14"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Cmp</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="l15"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l16"></a>}
<a name="l17"></a>
<a name="l18"></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=0)
<a name="l19"></a>{</span><span class=cF2>//</span><a href="/Wb/Adam/Opt/Boot/BootHDIns.HC.HTML#l10"><span class=cF4>MakeAll</span></a><span class=cF2> and install new boot-loader.</span><span class=cF0>
<a name="l20"></a> </span><span class=cF9>CDrv</span><span class=cF0> *dv;
<a name="l21"></a> </span><span class=cF9>CFAT32Boot</span><span class=cF0> br;
<a name="l22"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
<a name="l23"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l24"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l25"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Drv</span><span class=cF7>(</span><span class=cF0>drv_let</span><span class=cF7>)</span><span class=cF0>)
<a name="l26"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l27"></a> dv=</span><span class=cF5>Fs</span><span class=cF0>-&gt;cur_dv;
<a name="l28"></a> </span><span class=cF5>MakeAll</span><span class=cF0>;
<a name="l29"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>Let2BlkDevType</span><span class=cF7>(</span><span class=cF0>dv-&gt;drv_let</span><span class=cF7>)</span><span class=cF0>) {
<a name="l30"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_RAM</span><span class=cF0>:
<a name="l31"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ATA</span><span class=cF0>:
<a name="l32"></a> </span><span class=cF5>Move</span><span class=cF0>(</span><span class=cF6>&quot;/Kernel/Kernel.BIN.Z&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="l33"></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="l34"></a> </span><span class=cF6>&quot;No Kernel.BIN.C\n&quot;</span><span class=cF0>;
<a name="l35"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l36"></a> </span><span class=cF5>Free</span><span class=cF0>(de.full_name);
<a name="l37"></a> </span><span class=cF6>&quot;Modifying partition boot record.\n&quot;</span><span class=cF0>;
<a name="l38"></a> </span><span class=cF5>BlkRead</span><span class=cF0>(dv,&amp;br,dv-&gt;drv_offset,1);
<a name="l39"></a> br.jump_and_nop[0]=</span><span class=cF3>OC_JMP_REL8</span><span class=cF0>;
<a name="l40"></a> br.jump_and_nop[1]=</span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CFAT32Boot</span><span class=cF0>.code)-2;
<a name="l41"></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="l42"></a> br.jump_and_nop[2]=</span><span class=cF3>OC_NOP</span><span class=cF0>;
<a name="l43"></a> *</span><span class=cFD>BHD_BLK_CNT</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>-1)&gt;&gt;</span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>;
<a name="l44"></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>(dv,de.clus);
<a name="l45"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;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="l46"></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="l47"></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="l48"></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="l49"></a> br.code[i]=0;
<a name="l50"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(dv,&amp;br,dv-&gt;drv_offset,1);
<a name="l51"></a> </span><span class=cF7>}</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>default</span><span class=cF0>:
<a name="l54"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l55"></a> }
<a name="l56"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l57"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l58"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l59"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l60"></a>}
</span></pre></body>
</html>