ZealOS/docs/System/BlkDev/Mount.CC.html
TomAwezome 67479705de Add SATA port number reporting to DriveRep.
Improve Lex assert failure warning to give exact line number.
Remove some deprecated IDE functions.
Add default arg to Drive.
Fix raw-mode printing in StackRep, DriveRep, SATARep, Mount2, and CharGet.
Change LongLines cols default arg from 80 to 128.
2021-08-04 15:25:55 -04:00

349 lines
41 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.13">
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF0>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;PCI;Info;File/System;Devices&quot;</span><span class=cF0>
<a name="l2"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>SATARep</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> bd_type=</span><span class=cF3>BDT_NULL</span><span class=cF0>)
<a name="l3"></a>{ </span><span class=cF2>// Report ATA and ATAPI drives implemented by SATA controller.</span><span class=cF0>
<a name="l4"></a> </span><span class=cF9>I64</span><span class=cF0> bdf, i, j, num = </span><span class=cFE>0</span><span class=cF0>;
<a name="l5"></a> </span><span class=cF9>CAHCIPort</span><span class=cF0> *port;
<a name="l6"></a> </span><span class=cF9>CPCIDev</span><span class=cF0> *pci;
<a name="l7"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *temp_blkdev;
<a name="l8"></a> </span><span class=cF9>U16</span><span class=cF0> *st, *model, *serial;
<a name="l9"></a> </span><span class=cF1>Bool</span><span class=cF0> show_atapi = </span><span class=cF3>FALSE</span><span class=cF0>, show_ata = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l10"></a>
<a name="l11"></a>
<a name="l12"></a> </span><span class=cF1>switch</span><span class=cF0> (bd_type)
<a name="l13"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l14"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_NULL</span><span class=cF0>:
<a name="l15"></a> show_atapi = show_ata = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l16"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l17"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ATAPI</span><span class=cF0>:
<a name="l18"></a> show_atapi = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l19"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l20"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ATA</span><span class=cF0>:
<a name="l21"></a> show_ata = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l22"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l23"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l24"></a>
<a name="l25"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsRaw</span><span class=cF0>)
<a name="l26"></a> </span><span class=cF6>&quot;\n$LTBLUE$AHCI version %X.%1X%1X$FG$\n\n&quot;</span><span class=cF0>,
<a name="l27"></a> </span><span class=cFB>blkdev</span><span class=cF0>.ahci_hba-&gt;version &gt;&gt; </span><span class=cFE>16</span><span class=cF0>, (</span><span class=cFB>blkdev</span><span class=cF0>.ahci_hba-&gt;version &amp; </span><span class=cFE>0xFF00</span><span class=cF0>) &gt;&gt; </span><span class=cFE>8</span><span class=cF0>, </span><span class=cFB>blkdev</span><span class=cF0>.ahci_hba-&gt;version &amp; </span><span class=cFE>0xFF</span><span class=cF0>;
<a name="l28"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l29"></a> </span><span class=cF6>&quot;\nAHCI version %X.%1X%1X\n\n&quot;</span><span class=cF0>,
<a name="l30"></a> </span><span class=cFB>blkdev</span><span class=cF0>.ahci_hba-&gt;version &gt;&gt; </span><span class=cFE>16</span><span class=cF0>, (</span><span class=cFB>blkdev</span><span class=cF0>.ahci_hba-&gt;version &amp; </span><span class=cFE>0xFF00</span><span class=cF0>) &gt;&gt; </span><span class=cFE>8</span><span class=cF0>, </span><span class=cFB>blkdev</span><span class=cF0>.ahci_hba-&gt;version &amp; </span><span class=cFE>0xFF</span><span class=cF0>;
<a name="l31"></a>
<a name="l32"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>dev</span><span class=cF0>.pci_head)
<a name="l33"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l34"></a> pci = </span><span class=cF5>PCIDevFind</span><span class=cF0>(</span><span class=cF3>PCIC_STORAGE</span><span class=cF0>, </span><span class=cF3>PCISC_AHCI</span><span class=cF0>);
<a name="l35"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsRaw</span><span class=cF0>)
<a name="l36"></a> {
<a name="l37"></a> </span><span class=cF6>&quot;$RED$$HL,1$Bus: 0x%02X, Dev: 0x%02X, Fun: 0x%02X$HL,0$$FG$\n\n&quot;</span><span class=cF0>, pci-&gt;bus, pci-&gt;</span><span class=cFB>dev</span><span class=cF0>, pci-&gt;fun;
<a name="l38"></a> </span><span class=cF6>&quot;$RED$Vendor$FG$: $LTBLUE$%s$FG$\n&quot;</span><span class=cF0>, pci-&gt;vendor_str;
<a name="l39"></a> </span><span class=cF6>&quot;$RED$Device$FG$: $LTBLUE$%s$FG$\n&quot;</span><span class=cF0>, pci-&gt;dev_id_str;
<a name="l40"></a> }
<a name="l41"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l42"></a> {
<a name="l43"></a> </span><span class=cF6>&quot;Bus: 0x%02X, Dev: 0x%02X, Fun: 0x%02X\n\n&quot;</span><span class=cF0>, pci-&gt;bus, pci-&gt;</span><span class=cFB>dev</span><span class=cF0>, pci-&gt;fun;
<a name="l44"></a> </span><span class=cF6>&quot;Vendor: %s\n&quot;</span><span class=cF0>, pci-&gt;vendor_str;
<a name="l45"></a> </span><span class=cF6>&quot;Device: %s\n&quot;</span><span class=cF0>, pci-&gt;dev_id_str;
<a name="l46"></a> }
<a name="l47"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l48"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l49"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l50"></a> bdf = </span><span class=cF5>PCIClassFind</span><span class=cF0>(</span><span class=cF3>PCIC_STORAGE</span><span class=cF0> &lt;&lt; </span><span class=cFE>16</span><span class=cF0> | </span><span class=cF3>PCISC_AHCI</span><span class=cF0> &lt;&lt; </span><span class=cFE>8</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>);
<a name="l51"></a> </span><span class=cF6>&quot;Bus:%02X, Dev:%02X, Fun:%02X\n&quot;</span><span class=cF0>, bdf.u8[</span><span class=cFE>2</span><span class=cF0>], bdf.u8[</span><span class=cFE>1</span><span class=cF0>], bdf.u8[</span><span class=cFE>0</span><span class=cF0>];
<a name="l52"></a> </span><span class=cF6>&quot;HBA Base Address: 0x%X&quot;</span><span class=cF0>, </span><span class=cF5>PCIReadU32</span><span class=cF0>(bdf.u8[</span><span class=cFE>2</span><span class=cF0>], bdf.u8[</span><span class=cFE>1</span><span class=cF0>], bdf.u8[</span><span class=cFE>0</span><span class=cF0>], </span><span class=cF3>PCIR_BASE5</span><span class=cF0>) &amp; ~</span><span class=cFE>0x1F</span><span class=cF0>;
<a name="l53"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l54"></a>
<a name="l55"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>blkdev</span><span class=cF0>.ahci_hba)
<a name="l56"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l57"></a> </span><span class=cF6>&quot;\nImplemented Ports:\n&quot;</span><span class=cF0>;
<a name="l58"></a> </span><span class=cF6>&quot;(Show ATA: %Z)\n&quot;</span><span class=cF0>, show_ata, </span><span class=cF6>&quot;ST_FALSE_TRUE&quot;</span><span class=cF0>;
<a name="l59"></a> </span><span class=cF6>&quot;(Show ATAPI: %Z)\n\n&quot;</span><span class=cF0>, show_atapi, </span><span class=cF6>&quot;ST_FALSE_TRUE&quot;</span><span class=cF0>;
<a name="l60"></a>
<a name="l61"></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=cF3>AHCI_MAX_PORTS</span><span class=cF0>; i++)
<a name="l62"></a> {
<a name="l63"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>blkdev</span><span class=cF0>.ahci_hba-&gt;ports_implemented, i</span><span class=cF7>)</span><span class=cF0>)
<a name="l64"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l65"></a> port = &amp;</span><span class=cFB>blkdev</span><span class=cF0>.ahci_hba-&gt;ports[i];
<a name="l66"></a>
<a name="l67"></a> </span><span class=cF1>if</span><span class=cF0> (port-&gt;signature == </span><span class=cF3>AHCI_PxSIG_ATAPI</span><span class=cF0> &amp;&amp; show_atapi ||
<a name="l68"></a> port-&gt;signature == </span><span class=cF3>AHCI_PxSIG_ATA</span><span class=cF0> &amp;&amp; show_ata)
<a name="l69"></a> {
<a name="l70"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsRaw</span><span class=cF0>)
<a name="l71"></a> </span><span class=cF6>&quot;$PURPLE$ $BT,\&quot;%d\&quot;,LM=\&quot;%d\n\&quot;$$FG$&quot;</span><span class=cF0>, i, i;
<a name="l72"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l73"></a> </span><span class=cF6>&quot;[%d]&quot;</span><span class=cF0>, i;
<a name="l74"></a>
<a name="l75"></a> </span><span class=cF1>if</span><span class=cF0> (port-&gt;signature == </span><span class=cF3>AHCI_PxSIG_ATA</span><span class=cF0>)
<a name="l76"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l77"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsRaw</span><span class=cF0>)
<a name="l78"></a> </span><span class=cF6>&quot;$LM,4$$RED$Hard Drive $LTBLUE$ATA$FG$\n&quot;</span><span class=cF0>;
<a name="l79"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l80"></a> </span><span class=cF6>&quot;\tHard Drive ATA\n&quot;</span><span class=cF0>;
<a name="l81"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l82"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (port-&gt;signature == </span><span class=cF3>AHCI_PxSIG_ATAPI</span><span class=cF0>)
<a name="l83"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l84"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsRaw</span><span class=cF0>)
<a name="l85"></a> </span><span class=cF6>&quot;$LM,4$$RED$CD/DVD Drive $LTBLUE$ATAPI$FG$\n&quot;</span><span class=cF0>;
<a name="l86"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l87"></a> </span><span class=cF6>&quot;\tCD/DVD Drive ATAPI\n&quot;</span><span class=cF0>;
<a name="l88"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l89"></a>
<a name="l90"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsRaw</span><span class=cF0>)
<a name="l91"></a> </span><span class=cF6>&quot;$LM,0$&quot;</span><span class=cF0>;
<a name="l92"></a> </span><span class=cF6>'\n\t'</span><span class=cF0>;
<a name="l93"></a>
<a name="l94"></a> temp_blkdev = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CBlkDev</span><span class=cF7>)</span><span class=cF0>);
<a name="l95"></a> </span><span class=cF1>if</span><span class=cF0> (port-&gt;signature == </span><span class=cF3>AHCI_PxSIG_ATAPI</span><span class=cF0>)
<a name="l96"></a> temp_blkdev-&gt;first_drive_let = </span><span class=cF6>'T'</span><span class=cF0>;
<a name="l97"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF2>// ATA</span><span class=cF0>
<a name="l98"></a> temp_blkdev-&gt;first_drive_let = </span><span class=cF6>'C'</span><span class=cF0>;
<a name="l99"></a>
<a name="l100"></a> </span><span class=cF5>AHCIPortInit</span><span class=cF0>(temp_blkdev, port, i);
<a name="l101"></a> </span><span class=cF6>&quot;\n\t&quot;</span><span class=cF0>;
<a name="l102"></a>
<a name="l103"></a> </span><span class=cF1>if</span><span class=cF0> (temp_blkdev-&gt;dev_id_record)
<a name="l104"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l105"></a> st = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cFE>40</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>);
<a name="l106"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt; </span><span class=cFE>20</span><span class=cF0>; j++)
<a name="l107"></a> st[j] = </span><span class=cF5>EndianU16</span><span class=cF0>(temp_blkdev-&gt;dev_id_record[</span><span class=cFE>27</span><span class=cF0> + j]);
<a name="l108"></a> model = </span><span class=cF5>MStrUtil</span><span class=cF0>(st, </span><span class=cF3>SUF_REM_LEADING</span><span class=cF0> | </span><span class=cF3>SUF_REM_TRAILING</span><span class=cF0>);
<a name="l109"></a> </span><span class=cF6>&quot;Model: %s\n\t&quot;</span><span class=cF0>, model;
<a name="l110"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l111"></a> </span><span class=cF5>Free</span><span class=cF0>(model);
<a name="l112"></a>
<a name="l113"></a> st = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cFE>20</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>);
<a name="l114"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt; </span><span class=cFE>10</span><span class=cF0>; j++)
<a name="l115"></a> st[j] = </span><span class=cF5>EndianU16</span><span class=cF0>(temp_blkdev-&gt;dev_id_record[</span><span class=cFE>10</span><span class=cF0> + j]);
<a name="l116"></a> serial = </span><span class=cF5>MStrUtil</span><span class=cF0>(st, </span><span class=cF3>SUF_REM_LEADING</span><span class=cF0> | </span><span class=cF3>SUF_REM_TRAILING</span><span class=cF0>);
<a name="l117"></a> </span><span class=cF6>&quot;Serial: %s\n&quot;</span><span class=cF0>, serial;
<a name="l118"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l119"></a> </span><span class=cF5>Free</span><span class=cF0>(serial);
<a name="l120"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l121"></a>
<a name="l122"></a> </span><span class=cF6>&quot;\n&quot;</span><span class=cF0>;
<a name="l123"></a>
<a name="l124"></a> </span><span class=cF5>BlkDevDel</span><span class=cF0>(temp_blkdev);
<a name="l125"></a> </span><span class=cF5>Free</span><span class=cF0>(temp_blkdev);
<a name="l126"></a> }
<a name="l127"></a> num++;
<a name="l128"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l129"></a> }
<a name="l130"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l131"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l132"></a> </span><span class=cF6>&quot;blkdev.ahci_hba is NULL !\n\n&quot;</span><span class=cF0>;
<a name="l133"></a>
<a name="l134"></a> </span><span class=cF1>return</span><span class=cF0> num;
<a name="l135"></a>}
<a name="l136"></a>
<a name="l137"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;Install;File/Cmd Line (Typically);Cmd Line (Typically);&quot;</span><span class=cF0>
<a name="l138"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cF5>Mount2</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> boot_drive_let, </span><span class=cF9>CDoc</span><span class=cF0> *_doc, </span><span class=cF1>Bool</span><span class=cF0> _caller_is_prtdisk)
<a name="l139"></a>{</span><span class=cF2>//If _doc, called by </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KConfig.CC.html#l1"><span class=cF4>::/Kernel/KConfig.CC</span></a><span class=cF2> else called by </span><a href="https://zeal-operating-system.github.io/ZealOS/System/BlkDev/Mount.CC.html#l297"><span class=cF4>Mount</span></a><span class=cF2>().</span><span class=cF0>
<a name="l140"></a> </span><span class=cF9>I64</span><span class=cF0> count, total = </span><span class=cFE>0</span><span class=cF0>, num_hints, drv_let, type, prt_num, port = -</span><span class=cFE>1</span><span class=cF0>;
<a name="l141"></a> </span><span class=cF1>U8</span><span class=cF0> blks_buf[</span><span class=cF3>STR_LEN</span><span class=cF0>], addr_buf[</span><span class=cF3>STR_LEN</span><span class=cF0>], port_str[</span><span class=cF3>STR_LEN</span><span class=cF0>],
<a name="l142"></a> *filename = </span><span class=cF3>NULL</span><span class=cF0>, *filename2 = </span><span class=cF3>NULL</span><span class=cF0>, res = </span><span class=cFE>0</span><span class=cF0>;
<a name="l143"></a> </span><span class=cF1>Bool</span><span class=cF0> whole_drive, make_free;
<a name="l144"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc;
<a name="l145"></a>
<a name="l146"></a> </span><span class=cF1>if</span><span class=cF0> (boot_drive_let)
<a name="l147"></a> boot_drive_let = </span><span class=cF5>Letter2Letter</span><span class=cF0>(boot_drive_let);
<a name="l148"></a> </span><span class=cF1>do</span><span class=cF0>
<a name="l149"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l150"></a> count = </span><span class=cFE>0</span><span class=cF0>;
<a name="l151"></a> </span><span class=cF1>if</span><span class=cF0> (!_doc)
<a name="l152"></a> </span><span class=cF5>DriveRep</span><span class=cF0>;
<a name="l153"></a>
<a name="l154"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsRaw</span><span class=cF0>)
<a name="l155"></a> </span><span class=cF6>&quot;\n****** Mount Drives ******\n&quot;</span><span class=cF0>
<a name="l156"></a> </span><span class=cF6>&quot;$GREEN$A$FG$-$GREEN$B$FG$ are RAM drives.\n&quot;</span><span class=cF0>
<a name="l157"></a> </span><span class=cF6>&quot;$GREEN$C$FG$-$GREEN$L$FG$ are ATA hard drives.\n&quot;</span><span class=cF0>
<a name="l158"></a> </span><span class=cF6>&quot;$GREEN$M$FG$-$GREEN$P$FG$ are ISO file read drives.\n&quot;</span><span class=cF0>
<a name="l159"></a> </span><span class=cF6>&quot;$GREEN$Q$FG$-$GREEN$S$FG$ are ISO file write drives.\n&quot;</span><span class=cF0>
<a name="l160"></a> </span><span class=cF6>&quot;$GREEN$T$FG$-$GREEN$Z$FG$ are ATAPI CD/DVD drives.\n&quot;</span><span class=cF0>
<a name="l161"></a> </span><span class=cF6>&quot;\nDrive Letter ($PURPLE$&lt;ENTER&gt;$FG$ to exit):&quot;</span><span class=cF0>;
<a name="l162"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l163"></a> </span><span class=cF6>&quot;\n****** Mount Drives ******\n&quot;</span><span class=cF0>
<a name="l164"></a> </span><span class=cF6>&quot;A-B are RAM drives.\n&quot;</span><span class=cF0>
<a name="l165"></a> </span><span class=cF6>&quot;C-L are ATA hard drives.\n&quot;</span><span class=cF0>
<a name="l166"></a> </span><span class=cF6>&quot;M-P are ISO file read drives.\n&quot;</span><span class=cF0>
<a name="l167"></a> </span><span class=cF6>&quot;Q-S are ISO file write drives.\n&quot;</span><span class=cF0>
<a name="l168"></a> </span><span class=cF6>&quot;T-Z are ATAPI CD/DVD drives.\n&quot;</span><span class=cF0>
<a name="l169"></a> </span><span class=cF6>&quot;\nDrive Letter (&lt;ENTER&gt; to exit):&quot;</span><span class=cF0>;
<a name="l170"></a>
<a name="l171"></a> drv_let = </span><span class=cF5>Letter2Letter</span><span class=cF0>(</span><span class=cF5>CharGet</span><span class=cF0>);
<a name="l172"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l173"></a> </span><span class=cF1>if</span><span class=cF0> (type = </span><span class=cF5>Letter2BlkDevType</span><span class=cF7>(</span><span class=cF0>drv_let</span><span class=cF7>)</span><span class=cF0>)
<a name="l174"></a> {
<a name="l175"></a> whole_drive = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l176"></a> </span><span class=cF1>if</span><span class=cF0> (_doc)
<a name="l177"></a> </span><span class=cF7>{</span><span class=cF0> </span><span class=cF2>//Called by </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KConfig.CC.html#l1"><span class=cF4>::/Kernel/KConfig.CC</span></a><span class=cF0>
<a name="l178"></a> doc = _doc;
<a name="l179"></a> make_free = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l180"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l181"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l182"></a> </span><span class=cF7>{</span><span class=cF0> </span><span class=cF2>//Called by </span><a href="https://zeal-operating-system.github.io/ZealOS/System/BlkDev/Mount.CC.html#l297"><span class=cF4>Mount</span></a><span class=cF2>()</span><span class=cF0>
<a name="l183"></a> doc = </span><span class=cF5>DocNew</span><span class=cF0>;
<a name="l184"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;CBlkDev *bd;\n&quot;</span><span class=cF0>);
<a name="l185"></a> make_free = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l186"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l187"></a> prt_num = </span><span class=cF3>I64_MIN</span><span class=cF0>;
<a name="l188"></a> </span><span class=cF1>switch</span><span class=cF0> (type)
<a name="l189"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l190"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_RAM</span><span class=cF0>:
<a name="l191"></a> </span><span class=cF6>&quot;Addr of RAM disk ($PURPLE$&lt;ENTER&gt;$FG$ to MAlloc):&quot;</span><span class=cF0>;
<a name="l192"></a> </span><span class=cF5>StrNGet</span><span class=cF0>(addr_buf, </span><span class=cF3>STR_LEN</span><span class=cF0>);
<a name="l193"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ISO_FILE_WRITE</span><span class=cF0>:
<a name="l194"></a> </span><span class=cF6>&quot;Blks of 512 bytes:&quot;</span><span class=cF0>;
<a name="l195"></a> </span><span class=cF5>StrNGet</span><span class=cF0>(blks_buf, </span><span class=cF3>STR_LEN</span><span class=cF0>);
<a name="l196"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l197"></a>
<a name="l198"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ISO_FILE_READ</span><span class=cF0>:
<a name="l199"></a> filename = </span><span class=cF5>StrGet</span><span class=cF0>(</span><span class=cF6>&quot;File Name:&quot;</span><span class=cF0>);
<a name="l200"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l201"></a>
<a name="l202"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ATA</span><span class=cF0>:
<a name="l203"></a> prt_num = </span><span class=cF5>I64Get</span><span class=cF0>(</span><span class=cF6>&quot;Partition Num (Default=All):&quot;</span><span class=cF0>, prt_num);
<a name="l204"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ATAPI</span><span class=cF0>:
<a name="l205"></a> num_hints = </span><span class=cF5>SATARep</span><span class=cF0>(type);
<a name="l206"></a> </span><span class=cF1>if</span><span class=cF0> (type == </span><span class=cF3>BDT_ATAPI</span><span class=cF0> &amp;&amp; boot_drive_let)
<a name="l207"></a> </span><span class=cF6>&quot;&lt;ENTER&gt; to use booted CD/DVD\n&quot;</span><span class=cF0>; </span><span class=cF2>//Only </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KConfig.CC.html#l1"><span class=cF4>::/Kernel/KConfig.CC</span></a><span class=cF0>
<a name="l208"></a> </span><span class=cF1>do</span><span class=cF0>
<a name="l209"></a> {
<a name="l210"></a> </span><span class=cF1>if</span><span class=cF0> (num_hints)
<a name="l211"></a> </span><span class=cF6>&quot;Enter port number: \n&quot;</span><span class=cF0>;
<a name="l212"></a> </span><span class=cF5>StrNGet</span><span class=cF0>(port_str, </span><span class=cF3>STR_LEN</span><span class=cF0>);
<a name="l213"></a> }
<a name="l214"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0> type == </span><span class=cF3>BDT_ATAPI</span><span class=cF0> &amp;&amp; </span><span class=cF5>AHCIPortSignatureGet</span><span class=cF0>(</span><span class=cF5>Str2I64</span><span class=cF7>(</span><span class=cF0>port_str</span><span class=cF7>)</span><span class=cF0>) != </span><span class=cF3>AHCI_PxSIG_ATAPI</span><span class=cF0> ||
<a name="l215"></a> type == </span><span class=cF3>BDT_ATA</span><span class=cF0> &amp;&amp; </span><span class=cF5>AHCIPortSignatureGet</span><span class=cF0>(</span><span class=cF5>Str2I64</span><span class=cF7>(</span><span class=cF0>port_str</span><span class=cF7>)</span><span class=cF0>) != </span><span class=cF3>AHCI_PxSIG_ATA</span><span class=cF0> ||
<a name="l216"></a> </span><span class=cFE>0</span><span class=cF0> &gt; </span><span class=cF5>Str2I64</span><span class=cF0>(port_str) || </span><span class=cF5>Str2I64</span><span class=cF0>(port_str) &gt; num_hints - </span><span class=cFE>1</span><span class=cF0>
<a name="l217"></a> </span><span class=cF7>)</span><span class=cF0> &amp;&amp;
<a name="l218"></a> </span><span class=cF7>(</span><span class=cF0>type != </span><span class=cF3>BDT_ATAPI</span><span class=cF0> || !boot_drive_let</span><span class=cF7>)</span><span class=cF0>);
<a name="l219"></a>
<a name="l220"></a> port = </span><span class=cF5>Str2I64</span><span class=cF0>(port_str);
<a name="l221"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l222"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l223"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;\&quot;bd = BlkDevNextFreeSlot('%C', %d);\n\&quot;;\n&quot;</span><span class=cF0>, drv_let, type);
<a name="l224"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;bd = BlkDevNextFreeSlot(\'%C\', %d);\n&quot;</span><span class=cF0>, drv_let, type);
<a name="l225"></a> </span><span class=cF1>if</span><span class=cF0> (port != -</span><span class=cFE>1</span><span class=cF0> &amp;&amp; *port_str)
<a name="l226"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l227"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;\&quot;AHCIPortInit(bd, &amp;blkdev.ahci_hba-&gt;ports[%d], %d);\n\&quot;;\n&quot;</span><span class=cF0>, port, port);
<a name="l228"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;AHCIPortInit(bd, &amp;blkdev.ahci_hba-&gt;ports[%d], %d);\n&quot;</span><span class=cF0>, port, port);
<a name="l229"></a>
<a name="l230"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l231"></a>
<a name="l232"></a> </span><span class=cF1>switch</span><span class=cF0> (type)
<a name="l233"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l234"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_RAM</span><span class=cF0>:
<a name="l235"></a> </span><span class=cF1>if</span><span class=cF0> (!*addr_buf) </span><span class=cF5>StrCopy</span><span class=cF0>(addr_buf, </span><span class=cF6>&quot;0&quot;</span><span class=cF0>);
<a name="l236"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;bd-&gt;RAM_disk = %s;\n&quot;</span><span class=cF0>, addr_buf);
<a name="l237"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ISO_FILE_WRITE</span><span class=cF0>:
<a name="l238"></a> </span><span class=cF1>if</span><span class=cF0> (!*blks_buf) </span><span class=cF5>StrCopy</span><span class=cF0>(blks_buf, </span><span class=cF6>&quot;0&quot;</span><span class=cF0>);
<a name="l239"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;bd-&gt;max_blk = (%s) - 1;\n&quot;</span><span class=cF0>, blks_buf);
<a name="l240"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;bd-&gt;drv_offset = 19 &lt;&lt; 2 + (DVD_BLK_SIZE * 2 + DVD_BOOT_LOADER_SIZE) / BLK_SIZE;\n&quot;</span><span class=cF0>);
<a name="l241"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l242"></a>
<a name="l243"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ISO_FILE_READ</span><span class=cF0>:
<a name="l244"></a> filename2 = </span><span class=cF5>FileNameAbs</span><span class=cF0>(filename);
<a name="l245"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;bd-&gt;file_disk_name = SysStrNew(\&quot;%s\&quot;);\n&quot;</span><span class=cF0>, filename2);
<a name="l246"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;bd-&gt;drv_offset = 19 &lt;&lt; 2 + (DVD_BLK_SIZE * 2 + DVD_BOOT_LOADER_SIZE) / BLK_SIZE;\n&quot;</span><span class=cF0>);
<a name="l247"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l248"></a>
<a name="l249"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ATAPI</span><span class=cF0>:
<a name="l250"></a> </span><span class=cF1>if</span><span class=cF0> (!*port_str &amp;&amp; _doc)
<a name="l251"></a> {
<a name="l252"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;\&quot;AHCIBootDVDProbeAll(bd);\n\&quot;;\n&quot;</span><span class=cF0>);
<a name="l253"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;AHCIBootDVDProbeAll(bd);\n&quot;</span><span class=cF0>); </span><span class=cF2>//Only </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KConfig.CC.html#l1"><span class=cF4>::/Kernel/KConfig.CC</span></a><span class=cF0>
<a name="l254"></a>
<a name="l255"></a> </span><span class=cF1>if</span><span class=cF0> (drv_let == boot_drive_let)
<a name="l256"></a> make_free = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l257"></a> }
<a name="l258"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l259"></a>
<a name="l260"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>BDT_ATA</span><span class=cF0>:
<a name="l261"></a> </span><span class=cF1>if</span><span class=cF0> (_caller_is_prtdisk)
<a name="l262"></a> {
<a name="l263"></a> </span><span class=cF6>&quot;\nReformat WHOLE drive!&quot;</span><span class=cF0>;
<a name="l264"></a> whole_drive = </span><span class=cF5>YorN</span><span class=cF0>;
<a name="l265"></a> }
<a name="l266"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l267"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l268"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;\&quot;BlkDevAdd(bd, 0x%0X, %Z, %Z);\n\&quot;;\n&quot;</span><span class=cF0>, prt_num, whole_drive, </span><span class=cF6>&quot;ST_FALSE_TRUE&quot;</span><span class=cF0>, make_free, </span><span class=cF6>&quot;ST_FALSE_TRUE&quot;</span><span class=cF0>);
<a name="l269"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc, </span><span class=cF6>&quot;BlkDevAdd(bd, 0x%0X, %d, %d);\n&quot;</span><span class=cF0>, prt_num, whole_drive, make_free);
<a name="l270"></a> </span><span class=cF1>if</span><span class=cF0> (_doc) </span><span class=cF2>//Called by </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KConfig.CC.html#l1"><span class=cF4>::/Kernel/KConfig.CC</span></a><span class=cF0>
<a name="l271"></a> count++;
<a name="l272"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l273"></a> </span><span class=cF7>{</span><span class=cF0> </span><span class=cF2>//Called by </span><a href="https://zeal-operating-system.github.io/ZealOS/System/BlkDev/Mount.CC.html#l297"><span class=cF4>Mount</span></a><span class=cF2>()</span><span class=cF0>
<a name="l274"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>count = </span><span class=cF5>ExeDoc</span><span class=cF0>(doc)</span><span class=cF7>)</span><span class=cF0> &amp;&amp; whole_drive)
<a name="l275"></a> {
<a name="l276"></a> </span><span class=cF1>if</span><span class=cF0> (_caller_is_prtdisk)
<a name="l277"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l278"></a> res = drv_let;
<a name="l279"></a> </span><span class=cF5>DiskPart</span><span class=cF0>(drv_let, </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>); </span><span class=cF2>//First mount whole drive.</span><span class=cF0>
<a name="l280"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l281"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l282"></a> </span><span class=cF5>DiskPart</span><span class=cF0>(drv_let);
<a name="l283"></a> }
<a name="l284"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l285"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l286"></a> }
<a name="l287"></a> total += count;
<a name="l288"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l289"></a> </span><span class=cF1>while</span><span class=cF0> (count &amp;&amp; !_caller_is_prtdisk || !total &amp;&amp; _doc); </span><span class=cF2>//At least 1 if Called by </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KConfig.CC.html#l1"><span class=cF4>::/Kernel/KConfig.CC</span></a><span class=cF0>
<a name="l290"></a>
<a name="l291"></a> </span><span class=cF5>Free</span><span class=cF0>(filename);
<a name="l292"></a> </span><span class=cF5>Free</span><span class=cF0>(filename2);
<a name="l293"></a>
<a name="l294"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l295"></a>}
<a name="l296"></a>
<a name="l297"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> </span><span class=cF5>Mount</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> caller_is_prtdisk=</span><span class=cF3>FALSE</span><span class=cF0>)
<a name="l298"></a>{</span><span class=cF2>//Mount drives. Called from </span><a href="https://zeal-operating-system.github.io/ZealOS/System/BlkDev/DiskPart.CC.html#l43"><span class=cF4>DiskPart(Mount)</span></a><span class=cF2>.</span><span class=cF0>
<a name="l299"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Mount2</span><span class=cF0>(</span><span class=cFE>0</span><span class=cF0>, </span><span class=cF3>NULL</span><span class=cF0>, caller_is_prtdisk);
<a name="l300"></a>}
<a name="l301"></a>
<a name="l302"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Unmount</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="l303"></a>{</span><span class=cF2>//Unmount drive(s).</span><span class=cF0>
<a name="l304"></a> </span><span class=cF5>BlkDevDel</span><span class=cF0>(</span><span class=cF5>Letter2BlkDev</span><span class=cF7>(</span><span class=cF0>drv_let</span><span class=cF7>)</span><span class=cF0>);
<a name="l305"></a>}
<a name="l306"></a>
<a name="l307"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> </span><span class=cF5>MountFile</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename)
<a name="l308"></a>{</span><span class=cF2>//Mount ISO.C file.</span><span class=cF0>
<a name="l309"></a> </span><span class=cF1>U8</span><span class=cF0> *filename2 = </span><span class=cF5>ExtDefault</span><span class=cF0>(filename, </span><span class=cF6>&quot;ISO.C&quot;</span><span class=cF0>), *filename3 = </span><span class=cF5>FileNameAbs</span><span class=cF0>(filename2);
<a name="l310"></a> </span><span class=cF9>CDrive</span><span class=cF0> *drive = </span><span class=cF5>DriveMakeFreeSlot</span><span class=cF0>(</span><span class=cF5>DriveNextFreeLet</span><span class=cF7>(</span><span class=cF6>'M'</span><span class=cF7>)</span><span class=cF0>); </span><span class=cF2>//First </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l3273"><span class=cF4>BDT_ISO_FILE_READ</span></a><span class=cF0>
<a name="l311"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *bd = </span><span class=cF5>BlkDevNextFreeSlot</span><span class=cF0>(drive-&gt;drv_let, </span><span class=cF3>BDT_ISO_FILE_READ</span><span class=cF0>);
<a name="l312"></a>
<a name="l313"></a> bd-&gt;drv_offset = </span><span class=cFE>19</span><span class=cF0> &lt;&lt; </span><span class=cFE>2</span><span class=cF0> + (</span><span class=cF3>DVD_BLK_SIZE</span><span class=cF0> * </span><span class=cFE>2</span><span class=cF0> + </span><span class=cF3>DVD_BOOT_LOADER_SIZE</span><span class=cF0>) / </span><span class=cF3>BLK_SIZE</span><span class=cF0>;
<a name="l314"></a> bd-&gt;file_disk_name = </span><span class=cF5>SysStrNew</span><span class=cF0>(filename3);
<a name="l315"></a> </span><span class=cF5>BlkDevAdd</span><span class=cF0>(bd,, </span><span class=cF3>TRUE</span><span class=cF0>, </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l316"></a> </span><span class=cF5>Free</span><span class=cF0>(filename3);
<a name="l317"></a> </span><span class=cF5>Free</span><span class=cF0>(filename2);
<a name="l318"></a>
<a name="l319"></a> </span><span class=cF1>return</span><span class=cF0> drive-&gt;drv_let;
<a name="l320"></a>}
</span></pre></body>
</html>