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

325 lines
33 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=cF1>Bool</span><span class=cF0> </span><span class=cFD>BootDVDProbe</span><span class=cF0>(</span><span class=cF9>CBlkDev</span><span class=cF0> *bd)
<a name="l2"></a>{
<a name="l3"></a> </span><span class=cF1>U8</span><span class=cF0> *img=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF3>DVD_BLK_SIZE</span><span class=cF0>);
<a name="l4"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l5"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l6"></a> </span><span class=cF6>&quot;Port: %04X,%04X Unit: %02X &quot;</span><span class=cF0>,bd-&gt;base0,bd-&gt;base1,bd-&gt;unit;
<a name="l7"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>ATAProbe</span><span class=cF7>(</span><span class=cF0>bd-&gt;base0,bd-&gt;base1,bd-&gt;unit</span><span class=cF7>)</span><span class=cF0>==</span><span class=cF3>BDT_ATAPI</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l8"></a> </span><span class=cF6>&quot; ATAPI&quot;</span><span class=cF0>;
<a name="l9"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>ATAPIStartStop</span><span class=cF7>(</span><span class=cF0>bd,</span><span class=cF5>tS</span><span class=cF0>+5.0,</span><span class=cF3>TRUE</span><span class=cF7>)</span><span class=cF0>) {
<a name="l10"></a> </span><span class=cF6>&quot; Started&quot;</span><span class=cF0>;
<a name="l11"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;2;i++) </span><span class=cF7>{</span><span class=cF2>//Retry</span><span class=cF0>
<a name="l12"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>ATAPIReadBlks2</span><span class=cF7>(</span><span class=cF0>bd,</span><span class=cF5>tS</span><span class=cF0>+7.0,img,</span><span class=cFB>sys_boot_blk</span><span class=cF0>,1,</span><span class=cF3>FALSE</span><span class=cF7>)</span><span class=cF0>) {
<a name="l13"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>img+</span><span class=cFB>sys_boot_src</span><span class=cF0>.u16[1]&lt;&lt;</span><span class=cF3>BLK_SIZE_BITS</span><span class=cF7>)(</span><span class=cF9>CKernel</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>
<a name="l14"></a> -&gt;compile_time==</span><span class=cFB>sys_compile_time</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l15"></a> </span><span class=cF6>&quot; Found\n&quot;</span><span class=cF0>;
<a name="l16"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l17"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
<a name="l18"></a> </span><span class=cF6>&quot; Read&quot;</span><span class=cF0>;
<a name="l19"></a> } </span><span class=cF1>else</span><span class=cF0>
<a name="l20"></a> </span><span class=cF6>&quot; NoRead&quot;</span><span class=cF0>;
<a name="l21"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l22"></a> }
<a name="l23"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l24"></a> </span><span class=cF6>&quot; Nope\n&quot;</span><span class=cF0>;
<a name="l25"></a> </span><span class=cF5>Free</span><span class=cF0>(img);
<a name="l26"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l27"></a>}
<a name="l28"></a>
<a name="l29"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>BootDVDProbeAll</span><span class=cF0>(</span><span class=cF9>CBlkDev</span><span class=cF0> *bd)
<a name="l30"></a>{
<a name="l31"></a> </span><span class=cF9>I64</span><span class=cF0> d1,d2,i,j,k;
<a name="l32"></a>
<a name="l33"></a> bd-&gt;base1=0;
<a name="l34"></a> </span><span class=cF1>for</span><span class=cF0> (k=0;k&lt;256;k++) </span><span class=cF7>{</span><span class=cF0>
<a name="l35"></a> i=-1;
<a name="l36"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
<a name="l37"></a> j=</span><span class=cF5>PCIClassFind</span><span class=cF0>(0x010100+k,++i);
<a name="l38"></a> </span><span class=cF1>if</span><span class=cF0> (j&lt;0)
<a name="l39"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l40"></a> </span><span class=cF6>&quot;Subcode:0x%X Bus:0x%X Dev:0x%X Fun:0x%X\n&quot;</span><span class=cF0>,k,j.u8[2],j.u8[1],j.u8[0];
<a name="l41"></a> d1=</span><span class=cF5>PCIReadU32</span><span class=cF0>(j.u8[2],j.u8[1],j.u8[0],0x10);
<a name="l42"></a> d2=</span><span class=cF5>PCIReadU32</span><span class=cF0>(j.u8[2],j.u8[1],j.u8[0],0x14);
<a name="l43"></a> </span><span class=cF1>if</span><span class=cF0> (d1&amp;1 &amp;&amp; d2&amp;1) </span><span class=cF7>{</span><span class=cF0>
<a name="l44"></a> </span><span class=cF1>if</span><span class=cF0> (bd-&gt;base0=d1&amp;~7) {
<a name="l45"></a> bd-&gt;unit=0;
<a name="l46"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>BootDVDProbe</span><span class=cF7>(</span><span class=cF0>bd</span><span class=cF7>)</span><span class=cF0>)
<a name="l47"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l48"></a> bd-&gt;unit=1;
<a name="l49"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>BootDVDProbe</span><span class=cF7>(</span><span class=cF0>bd</span><span class=cF7>)</span><span class=cF0>)
<a name="l50"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l51"></a> }
<a name="l52"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l53"></a> d1=</span><span class=cF5>PCIReadU32</span><span class=cF0>(j.u8[2],j.u8[1],j.u8[0],0x18);
<a name="l54"></a> d2=</span><span class=cF5>PCIReadU32</span><span class=cF0>(j.u8[2],j.u8[1],j.u8[0],0x1C);
<a name="l55"></a> </span><span class=cF1>if</span><span class=cF0> (d1&amp;1 &amp;&amp; d2&amp;1) </span><span class=cF7>{</span><span class=cF0>
<a name="l56"></a> </span><span class=cF1>if</span><span class=cF0> (bd-&gt;base0=d1&amp;~7) {
<a name="l57"></a> bd-&gt;unit=0;
<a name="l58"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>BootDVDProbe</span><span class=cF7>(</span><span class=cF0>bd</span><span class=cF7>)</span><span class=cF0>)
<a name="l59"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l60"></a> bd-&gt;unit=1;
<a name="l61"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>BootDVDProbe</span><span class=cF7>(</span><span class=cF0>bd</span><span class=cF7>)</span><span class=cF0>)
<a name="l62"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l63"></a> }
<a name="l64"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l65"></a> }
<a name="l66"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l67"></a>
<a name="l68"></a> d1=0x1F0;
<a name="l69"></a> d2=0x3F6;
<a name="l70"></a> </span><span class=cF1>if</span><span class=cF0> (bd-&gt;base0=d1&amp;~7) </span><span class=cF7>{</span><span class=cF0>
<a name="l71"></a> bd-&gt;unit=0;
<a name="l72"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>BootDVDProbe</span><span class=cF7>(</span><span class=cF0>bd</span><span class=cF7>)</span><span class=cF0>)
<a name="l73"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l74"></a> bd-&gt;unit=1;
<a name="l75"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>BootDVDProbe</span><span class=cF7>(</span><span class=cF0>bd</span><span class=cF7>)</span><span class=cF0>)
<a name="l76"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l77"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l78"></a>
<a name="l79"></a> d1=0x170;
<a name="l80"></a> d2=0x376;
<a name="l81"></a> </span><span class=cF1>if</span><span class=cF0> (bd-&gt;base0=d1&amp;~7) </span><span class=cF7>{</span><span class=cF0>
<a name="l82"></a> bd-&gt;unit=0;
<a name="l83"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>BootDVDProbe</span><span class=cF7>(</span><span class=cF0>bd</span><span class=cF7>)</span><span class=cF0>)
<a name="l84"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l85"></a> bd-&gt;unit=1;
<a name="l86"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFD>BootDVDProbe</span><span class=cF7>(</span><span class=cF0>bd</span><span class=cF7>)</span><span class=cF0>)
<a name="l87"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l88"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l89"></a>}
<a name="l90"></a>
<a name="l91"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>ATARepEntry</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> base0,</span><span class=cF9>I64</span><span class=cF0> base1,</span><span class=cF9>I64</span><span class=cF0> unit,</span><span class=cF1>U8</span><span class=cF0> *msg,
<a name="l92"></a> </span><span class=cF9>CATARep</span><span class=cF0> **_head,</span><span class=cF9>I64</span><span class=cF0> *num_hints)
<a name="l93"></a>{
<a name="l94"></a> </span><span class=cF9>I64</span><span class=cF0> type;
<a name="l95"></a> base0&amp;=-8;
<a name="l96"></a> base1&amp;=-4;
<a name="l97"></a> </span><span class=cF9>CATARep</span><span class=cF0> *tmpha;
<a name="l98"></a> </span><span class=cF1>if</span><span class=cF0> (type=</span><span class=cF5>ATAProbe</span><span class=cF7>(</span><span class=cF0>base0,base1,unit</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l99"></a> *num_hints+=1;
<a name="l100"></a> </span><span class=cF6>&quot;\n$PURPLE$ $BT+X,\&quot;%d\&quot;,LM=\&quot;%d\\n\&quot;$$FG$$LM,4$&quot;</span><span class=cF0>,*num_hints,*num_hints;
<a name="l101"></a> </span><span class=cF1>if</span><span class=cF0> (type==</span><span class=cF3>BDT_ATA</span><span class=cF0>)
<a name="l102"></a> </span><span class=cF6>&quot;$RED$Hard Drive $LTBLUE$ATA &quot;</span><span class=cF0>;
<a name="l103"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l104"></a> </span><span class=cF6>&quot;$RED$CD/DVD Drive $LTBLUE$ATAPI &quot;</span><span class=cF0>;
<a name="l105"></a> </span><span class=cF6>&quot;%s$FG$\n&quot;</span><span class=cF0>,msg;
<a name="l106"></a> </span><span class=cF1>if</span><span class=cF0> (base0==</span><span class=cFB>blkdev</span><span class=cF0>.ins_base0 &amp;&amp; unit==</span><span class=cFB>blkdev</span><span class=cF0>.ins_unit)
<a name="l107"></a> </span><span class=cF6>&quot;$PURPLE$(Drive originally installed from.)$FG$\n&quot;</span><span class=cF0>;
<a name="l108"></a> </span><span class=cF6>&quot;Base0:0x%04X Base1:0x%04X Unit:%d$LM,0$\n&quot;</span><span class=cF0>,
<a name="l109"></a> base0,base1,unit;
<a name="l110"></a> </span><span class=cF1>if</span><span class=cF0> (_head) {
<a name="l111"></a> tmpha=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CATARep</span><span class=cF7>)</span><span class=cF0>);
<a name="l112"></a> tmpha-&gt;next=*_head;
<a name="l113"></a> *_head=tmpha;
<a name="l114"></a> tmpha-&gt;num=*num_hints;
<a name="l115"></a> tmpha-&gt;type=type;
<a name="l116"></a> tmpha-&gt;base0=base0;
<a name="l117"></a> tmpha-&gt;base1=base1;
<a name="l118"></a> tmpha-&gt;unit=unit;
<a name="l119"></a> }
<a name="l120"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l121"></a>}
<a name="l122"></a>
<a name="l123"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cFD>ATARepExitAllApplications</span><span class=cF0>()
<a name="l124"></a>{
<a name="l125"></a> </span><span class=cF6>&quot;\nWe're going to probe hardware.\n&quot;</span><span class=cF0>
<a name="l126"></a> </span><span class=cF6>&quot;$RED$Exit all other applications.$FG$\n&quot;</span><span class=cF0>
<a name="l127"></a> </span><span class=cF6>&quot;Press '$PURPLE$p$FG$' to probe or '$PURPLE$s$FG$' to skip.\n&quot;</span><span class=cF0>;
<a name="l128"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>ToUpper</span><span class=cF7>(</span><span class=cF5>GetChar</span><span class=cF0>(,</span><span class=cF3>FALSE</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>==</span><span class=cF6>'S'</span><span class=cF0>)
<a name="l129"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l130"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l131"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l132"></a>}
<a name="l133"></a>
<a name="l134"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>ATARep</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> pmt=</span><span class=cF3>TRUE</span><span class=cF0>,</span><span class=cF1>Bool</span><span class=cF0> just_ide=</span><span class=cF3>FALSE</span><span class=cF0>,</span><span class=cF9>CATARep</span><span class=cF0> **_head=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l135"></a>{</span><span class=cF2>//Report possible ATA devices by probing. Hard disks and CD/DVDs.</span><span class=cF0>
<a name="l136"></a> </span><span class=cF9>I64</span><span class=cF0> d1,d2,i,j,k,cnt=0,unlock_flags=0,num_hints=0;
<a name="l137"></a>#</span><span class=cF1>assert</span><span class=cF0> </span><span class=cF3>BLKDEVS_NUM</span><span class=cF0>&lt;=64
<a name="l138"></a> </span><span class=cF1>if</span><span class=cF0> (_head) *_head=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l139"></a>
<a name="l140"></a> </span><span class=cF1>if</span><span class=cF0> (pmt &amp;&amp; </span><span class=cFD>ATARepExitAllApplications</span><span class=cF0>)
<a name="l141"></a> </span><span class=cF1>return</span><span class=cF0> 0;
<a name="l142"></a>
<a name="l143"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>BLKDEVS_NUM</span><span class=cF0>;i++)
<a name="l144"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>blkdev</span><span class=cF0>.blkdevs[i].bd_signature==</span><span class=cF3>BD_SIGNATURE_VAL</span><span class=cF0>)
<a name="l145"></a> </span><span class=cF5>BEqu</span><span class=cF0>(&amp;unlock_flags,i,
<a name="l146"></a> </span><span class=cF5>BlkDevLock</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>blkdev</span><span class=cF0>.blkdevs[i]</span><span class=cF7>)</span><span class=cF0>);
<a name="l147"></a>
<a name="l148"></a> </span><span class=cF1>if</span><span class=cF0> (!just_ide)
<a name="l149"></a> </span><span class=cF1>for</span><span class=cF0> (k=0;k&lt;256;k++) </span><span class=cF7>{</span><span class=cF0>
<a name="l150"></a> i=-1;
<a name="l151"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
<a name="l152"></a> j=</span><span class=cF5>PCIClassFind</span><span class=cF0>(0x010100+k,++i);
<a name="l153"></a> </span><span class=cF1>if</span><span class=cF0> (j&lt;0)
<a name="l154"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l155"></a>
<a name="l156"></a> </span><span class=cF6>&quot;\nSubcode:0x%X Bus:0x%X Dev:0x%X Fun:0x%X\n&quot;</span><span class=cF0>,k,j.u8[2],j.u8[1],j.u8[0];
<a name="l157"></a> cnt++;
<a name="l158"></a>
<a name="l159"></a> d1=</span><span class=cF5>PCIReadU32</span><span class=cF0>(j.u8[2],j.u8[1],j.u8[0],0x10);
<a name="l160"></a> d2=</span><span class=cF5>PCIReadU32</span><span class=cF0>(j.u8[2],j.u8[1],j.u8[0],0x14);
<a name="l161"></a> </span><span class=cF1>if</span><span class=cF0> (d1&amp;1 &amp;&amp; d2&amp;1) </span><span class=cF7>{</span><span class=cF0>
<a name="l162"></a> </span><span class=cFD>ATARepEntry</span><span class=cF0>(d1,d2,0,</span><span class=cF6>&quot;Primary IDE&quot;</span><span class=cF0>,_head,&amp;num_hints);
<a name="l163"></a> </span><span class=cFD>ATARepEntry</span><span class=cF0>(d1,d2,1,</span><span class=cF6>&quot;Primary IDE&quot;</span><span class=cF0>,_head,&amp;num_hints);
<a name="l164"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l165"></a> d1=0x1F0; d2=0x3F6;
<a name="l166"></a> </span><span class=cFD>ATARepEntry</span><span class=cF0>(d1,d2,0,</span><span class=cF6>&quot;Primary IDE&quot;</span><span class=cF0>,_head,&amp;num_hints);
<a name="l167"></a> </span><span class=cFD>ATARepEntry</span><span class=cF0>(d1,d2,1,</span><span class=cF6>&quot;Primary IDE&quot;</span><span class=cF0>,_head,&amp;num_hints);
<a name="l168"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l169"></a> d1=</span><span class=cF5>PCIReadU32</span><span class=cF0>(j.u8[2],j.u8[1],j.u8[0],0x18);
<a name="l170"></a> d2=</span><span class=cF5>PCIReadU32</span><span class=cF0>(j.u8[2],j.u8[1],j.u8[0],0x1C);
<a name="l171"></a> </span><span class=cF1>if</span><span class=cF0> (d1&amp;1 &amp;&amp; d2&amp;1) </span><span class=cF7>{</span><span class=cF0>
<a name="l172"></a> </span><span class=cFD>ATARepEntry</span><span class=cF0>(d1,d2,0,</span><span class=cF6>&quot;Secondary IDE&quot;</span><span class=cF0>,_head,&amp;num_hints);
<a name="l173"></a> </span><span class=cFD>ATARepEntry</span><span class=cF0>(d1,d2,1,</span><span class=cF6>&quot;Secondary IDE&quot;</span><span class=cF0>,_head,&amp;num_hints);
<a name="l174"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l175"></a> d1=0x170; d2=0x376;
<a name="l176"></a> </span><span class=cFD>ATARepEntry</span><span class=cF0>(d1,d2,0,</span><span class=cF6>&quot;Secondary IDE&quot;</span><span class=cF0>,_head,&amp;num_hints);
<a name="l177"></a> </span><span class=cFD>ATARepEntry</span><span class=cF0>(d1,d2,1,</span><span class=cF6>&quot;Secondary IDE&quot;</span><span class=cF0>,_head,&amp;num_hints);
<a name="l178"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l179"></a> }
<a name="l180"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l181"></a> </span><span class=cF1>if</span><span class=cF0> (!cnt) </span><span class=cF7>{</span><span class=cF0>
<a name="l182"></a> d1=0x1F0; d2=0x3F6;
<a name="l183"></a> </span><span class=cFD>ATARepEntry</span><span class=cF0>(d1,d2,0,</span><span class=cF6>&quot;Primary IDE&quot;</span><span class=cF0>,_head,&amp;num_hints);
<a name="l184"></a> </span><span class=cFD>ATARepEntry</span><span class=cF0>(d1,d2,1,</span><span class=cF6>&quot;Primary IDE&quot;</span><span class=cF0>,_head,&amp;num_hints);
<a name="l185"></a>
<a name="l186"></a> d1=0x170; d2=0x376;
<a name="l187"></a> </span><span class=cFD>ATARepEntry</span><span class=cF0>(d1,d2,0,</span><span class=cF6>&quot;Secondary IDE&quot;</span><span class=cF0>,_head,&amp;num_hints);
<a name="l188"></a> </span><span class=cFD>ATARepEntry</span><span class=cF0>(d1,d2,1,</span><span class=cF6>&quot;Secondary IDE&quot;</span><span class=cF0>,_head,&amp;num_hints);
<a name="l189"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l190"></a> </span><span class=cF6>'\n\n'</span><span class=cF0>;
<a name="l191"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>BLKDEVS_NUM</span><span class=cF0>;i++)
<a name="l192"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;unlock_flags,i</span><span class=cF7>)</span><span class=cF0>)
<a name="l193"></a> </span><span class=cF5>BlkDevUnlock</span><span class=cF0>(&amp;</span><span class=cFB>blkdev</span><span class=cF0>.blkdevs[i]);
<a name="l194"></a> </span><span class=cF1>return</span><span class=cF0> num_hints;
<a name="l195"></a>}
<a name="l196"></a>
<a name="l197"></a></span><span class=cF9>CATARep</span><span class=cF0> *</span><span class=cF5>ATARepFind</span><span class=cF0>(</span><span class=cF9>CATARep</span><span class=cF0> *haystack_head,</span><span class=cF9>I64</span><span class=cF0> needle_num)
<a name="l198"></a>{
<a name="l199"></a> </span><span class=cF1>while</span><span class=cF0> (haystack_head) </span><span class=cF7>{</span><span class=cF0>
<a name="l200"></a> </span><span class=cF1>if</span><span class=cF0> (haystack_head-&gt;num==needle_num)
<a name="l201"></a> </span><span class=cF1>return</span><span class=cF0> haystack_head;
<a name="l202"></a> haystack_head=haystack_head-&gt;next;
<a name="l203"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l204"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l205"></a>}
<a name="l206"></a>
<a name="l207"></a></span><span class=cF9>CATARep</span><span class=cF0> *</span><span class=cF5>ATAIDDrvs</span><span class=cF0>(</span><span class=cF9>CATARep</span><span class=cF0> *head,</span><span class=cF9>CATARep</span><span class=cF0> **_ata_drv,</span><span class=cF9>CATARep</span><span class=cF0> **_atapi_drv)
<a name="l208"></a>{</span><span class=cF2>//This is for when trying to sort-out main hard drives and CD/DVD drives.</span><span class=cF0>
<a name="l209"></a> </span><span class=cF9>CATARep</span><span class=cF0> *res=</span><span class=cF3>NULL</span><span class=cF0>,*tmpha=head,*ata_drv=</span><span class=cF3>NULL</span><span class=cF0>,*atapi_drv=</span><span class=cF3>NULL</span><span class=cF0>;
<a name="l210"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *bd;
<a name="l211"></a> </span><span class=cF1>Bool</span><span class=cF0> was_silent=</span><span class=cF5>Silent</span><span class=cF0>,ins_found=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l212"></a> bd=</span><span class=cF5>Let2BlkDev</span><span class=cF0>(</span><span class=cF6>':'</span><span class=cF0>,</span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l213"></a> </span><span class=cF5>Silent</span><span class=cF0>(was_silent);
<a name="l214"></a> </span><span class=cF1>while</span><span class=cF0> (tmpha) </span><span class=cF7>{</span><span class=cF0>
<a name="l215"></a> </span><span class=cF1>if</span><span class=cF0> (!res &amp;&amp; bd &amp;&amp; bd-&gt;type==tmpha-&gt;type) {
<a name="l216"></a> </span><span class=cF1>if</span><span class=cF0> (bd-&gt;type==</span><span class=cF3>BDT_ATAPI</span><span class=cF0> &amp;&amp;
<a name="l217"></a> bd-&gt;base0==tmpha-&gt;base0 &amp;&amp; bd-&gt;unit==tmpha-&gt;unit)
<a name="l218"></a> res=atapi_drv=tmpha;
<a name="l219"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (bd-&gt;type==</span><span class=cF3>BDT_ATA</span><span class=cF0> &amp;&amp; bd-&gt;base0==tmpha-&gt;base0 &amp;&amp;
<a name="l220"></a> bd-&gt;base1==tmpha-&gt;base1 &amp;&amp; bd-&gt;unit==tmpha-&gt;unit)
<a name="l221"></a> res=ata_drv=tmpha;
<a name="l222"></a> }
<a name="l223"></a> </span><span class=cF1>if</span><span class=cF0> (!res || res-&gt;type!=tmpha-&gt;type) {
<a name="l224"></a> </span><span class=cF1>if</span><span class=cF0> (tmpha-&gt;type==</span><span class=cF3>BDT_ATA</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l225"></a> </span><span class=cF1>if</span><span class=cF0> (!ata_drv || tmpha-&gt;unit&lt;ata_drv-&gt;unit ||
<a name="l226"></a> tmpha-&gt;unit==ata_drv-&gt;unit &amp;&amp; tmpha-&gt;num&lt;ata_drv-&gt;num)
<a name="l227"></a> ata_drv=tmpha;
<a name="l228"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpha-&gt;type==</span><span class=cF3>BDT_ATAPI</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l229"></a> </span><span class=cF1>if</span><span class=cF0> (!atapi_drv || !ins_found &amp;&amp; </span><span class=cF7>(</span><span class=cF0>tmpha-&gt;unit&lt;atapi_drv-&gt;unit ||
<a name="l230"></a> tmpha-&gt;unit==atapi_drv-&gt;unit &amp;&amp; tmpha-&gt;num&lt;atapi_drv-&gt;num</span><span class=cF7>)</span><span class=cF0>)
<a name="l231"></a> atapi_drv=tmpha;
<a name="l232"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l233"></a> }
<a name="l234"></a> </span><span class=cF1>if</span><span class=cF0> (tmpha-&gt;type==</span><span class=cF3>BDT_ATAPI</span><span class=cF0> &amp;&amp; bd &amp;&amp; bd-&gt;type==</span><span class=cF3>BDT_ATA</span><span class=cF0> &amp;&amp;
<a name="l235"></a> tmpha-&gt;base0==</span><span class=cFB>blkdev</span><span class=cF0>.ins_base0 &amp;&amp; tmpha-&gt;unit==</span><span class=cFB>blkdev</span><span class=cF0>.ins_unit) {
<a name="l236"></a> </span><span class=cF1>if</span><span class=cF0> (!ins_found) </span><span class=cF7>{</span><span class=cF0>
<a name="l237"></a> atapi_drv=tmpha;
<a name="l238"></a> ins_found=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l239"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l240"></a> }
<a name="l241"></a> tmpha=tmpha-&gt;next;
<a name="l242"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l243"></a> </span><span class=cF1>if</span><span class=cF0> (_ata_drv) *_ata_drv =ata_drv;
<a name="l244"></a> </span><span class=cF1>if</span><span class=cF0> (_atapi_drv) *_atapi_drv=atapi_drv;
<a name="l245"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l246"></a>}
<a name="l247"></a>
<a name="l248"></a></span><span class=cF9>CBlkDev</span><span class=cF0> *</span><span class=cF5>ATAMount</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> first_drv_let,</span><span class=cF9>I64</span><span class=cF0> type,</span><span class=cF9>I64</span><span class=cF0> base0,</span><span class=cF9>I64</span><span class=cF0> base1,</span><span class=cF9>I64</span><span class=cF0> unit)
<a name="l249"></a>{
<a name="l250"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *res;
<a name="l251"></a> </span><span class=cF1>if</span><span class=cF0> (0&lt;=first_drv_let-</span><span class=cF6>'A'</span><span class=cF0>&lt;</span><span class=cF3>DRVS_NUM</span><span class=cF0> &amp;&amp; </span><span class=cF7>(</span><span class=cF0>type==</span><span class=cF3>BDT_ATA</span><span class=cF0> || type==</span><span class=cF3>BDT_ATAPI</span><span class=cF7>)</span><span class=cF0> &amp;&amp;
<a name="l252"></a> 0&lt;=unit&lt;=1) </span><span class=cF7>{</span><span class=cF0>
<a name="l253"></a> res=</span><span class=cF5>BlkDevNextFreeSlot</span><span class=cF0>(first_drv_let,type);
<a name="l254"></a> res-&gt;unit=unit;
<a name="l255"></a> res-&gt;base0=base0;
<a name="l256"></a> res-&gt;base1=base1;
<a name="l257"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>BlkDevAdd</span><span class=cF7>(</span><span class=cF0>res,,</span><span class=cF3>FALSE</span><span class=cF0>,</span><span class=cF3>FALSE</span><span class=cF7>)</span><span class=cF0>)
<a name="l258"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l259"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l260"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l261"></a>}
<a name="l262"></a>
<a name="l263"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>MountIDEAuto</span><span class=cF0>()
<a name="l264"></a>{</span><span class=cF2>//Try to mount hard drive and CD/DVD, automatically. (Kernel.Cfg option).</span><span class=cF0>
<a name="l265"></a></span><span class=cF2>//It uses 'C' and 'T' as first drive letters or whatever you set</span><span class=cF0>
<a name="l266"></a> </span><span class=cF2>//in config when compiling Kernel.BIN.</span><span class=cF0>
<a name="l267"></a> </span><span class=cF9>I64</span><span class=cF0> res=0;
<a name="l268"></a> </span><span class=cF9>CATARep</span><span class=cF0> *head=</span><span class=cF3>NULL</span><span class=cF0>,*ata_drv=</span><span class=cF3>NULL</span><span class=cF0>,*atapi_drv=</span><span class=cF3>NULL</span><span class=cF0>,*tmpha;
<a name="l269"></a> </span><span class=cF5>ATARep</span><span class=cF0>(</span><span class=cF3>FALSE</span><span class=cF0>,</span><span class=cF3>TRUE</span><span class=cF0>,&amp;head);
<a name="l270"></a> </span><span class=cF5>ATAIDDrvs</span><span class=cF0>(head,&amp;ata_drv,&amp;atapi_drv);
<a name="l271"></a> </span><span class=cF1>if</span><span class=cF0> (ata_drv &amp;&amp; </span><span class=cF5>ATAMount</span><span class=cF7>(</span><span class=cFB>blkdev</span><span class=cF0>.first_hd_drv_let,</span><span class=cF3>BDT_ATA</span><span class=cF0>,
<a name="l272"></a> ata_drv-&gt;base0,ata_drv-&gt;base1,ata_drv-&gt;unit</span><span class=cF7>)</span><span class=cF0>)
<a name="l273"></a> res++;
<a name="l274"></a> </span><span class=cF1>if</span><span class=cF0> (atapi_drv &amp;&amp; </span><span class=cF5>ATAMount</span><span class=cF7>(</span><span class=cFB>blkdev</span><span class=cF0>.first_dvd_drv_let,</span><span class=cF3>BDT_ATAPI</span><span class=cF0>,
<a name="l275"></a> atapi_drv-&gt;base0,atapi_drv-&gt;base1,atapi_drv-&gt;unit</span><span class=cF7>)</span><span class=cF0>)
<a name="l276"></a> res++;
<a name="l277"></a> tmpha=head;
<a name="l278"></a> </span><span class=cF1>while</span><span class=cF0> (tmpha) </span><span class=cF7>{</span><span class=cF0>
<a name="l279"></a> </span><span class=cF1>if</span><span class=cF0> (tmpha!=ata_drv &amp;&amp; tmpha!=atapi_drv) {
<a name="l280"></a> </span><span class=cF1>if</span><span class=cF0> (tmpha-&gt;type==</span><span class=cF3>BDT_ATA</span><span class=cF0> &amp;&amp; </span><span class=cF5>ATAMount</span><span class=cF7>(</span><span class=cFB>blkdev</span><span class=cF0>.first_hd_drv_let,</span><span class=cF3>BDT_ATA</span><span class=cF0>,
<a name="l281"></a> tmpha-&gt;base0,tmpha-&gt;base1,tmpha-&gt;unit</span><span class=cF7>)</span><span class=cF0>)
<a name="l282"></a> res++;
<a name="l283"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpha-&gt;type==</span><span class=cF3>BDT_ATAPI</span><span class=cF0> &amp;&amp;
<a name="l284"></a> </span><span class=cF5>ATAMount</span><span class=cF7>(</span><span class=cFB>blkdev</span><span class=cF0>.first_dvd_drv_let,</span><span class=cF3>BDT_ATAPI</span><span class=cF0>,
<a name="l285"></a> tmpha-&gt;base0,tmpha-&gt;base1,tmpha-&gt;unit</span><span class=cF7>)</span><span class=cF0>)
<a name="l286"></a> res++;
<a name="l287"></a> }
<a name="l288"></a> tmpha=tmpha-&gt;next;
<a name="l289"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l290"></a> </span><span class=cF5>LinkedLstDel</span><span class=cF0>(head);
<a name="l291"></a> </span><span class=cFB>blkdev</span><span class=cF0>.mount_ide_auto_cnt=res;
<a name="l292"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l293"></a>}
</span></pre></body>
</html>