ZealOS/docs/System/Boot/DiskISORedSea.CC.html
TomAwezome 1b75d91002 Fix Mount AHCI Port selection.
Add arg to SATARep to specify drive types to show.
Add checks in AHCIPortInit to verify port signatures, add helper method to get signatures from port.
2021-08-02 16:40:05 -04:00

242 lines
27 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;File/CD DVD&quot;</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>FillU16Palindrome</span><span class=cF0>(</span><span class=cF9>CPalindromeU16</span><span class=cF0> *dst, </span><span class=cF9>U16</span><span class=cF0> w)
<a name="l4"></a>{
<a name="l5"></a> dst-&gt;big = </span><span class=cF5>EndianU16</span><span class=cF0>(w);
<a name="l6"></a> dst-&gt;little = w;
<a name="l7"></a>}
<a name="l8"></a>
<a name="l9"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>FillU32Palindrome</span><span class=cF0>(</span><span class=cF9>CPalindromeU32</span><span class=cF0> *dst, </span><span class=cF9>I64</span><span class=cF0> d)
<a name="l10"></a>{
<a name="l11"></a> dst-&gt;big = </span><span class=cF5>EndianU32</span><span class=cF0>(d);
<a name="l12"></a> dst-&gt;little = d;
<a name="l13"></a>}
<a name="l14"></a>
<a name="l15"></a></span><span class=cF1>class</span><span class=cF0> </span><span class=cF9>CElTorito</span><span class=cF0>
<a name="l16"></a>{
<a name="l17"></a> </span><span class=cF9>U16</span><span class=cF0> w[</span><span class=cFE>16</span><span class=cF0>];
<a name="l18"></a> </span><span class=cF1>U8</span><span class=cF0> bootable; </span><span class=cF2>// 88=bootable 00=not bootable</span><span class=cF0>
<a name="l19"></a> </span><span class=cF1>U8</span><span class=cF0> media_type; </span><span class=cF2>// 0=no emulation 4=hard disk</span><span class=cF0>
<a name="l20"></a> </span><span class=cF9>U16</span><span class=cF0> load_seg; </span><span class=cF2>// 0000-&gt;07C0</span><span class=cF0>
<a name="l21"></a> </span><span class=cF1>U8</span><span class=cF0> sys_type;
<a name="l22"></a> </span><span class=cF1>U8</span><span class=cF0> zero;
<a name="l23"></a> </span><span class=cF9>U16</span><span class=cF0> sect_count;
<a name="l24"></a> </span><span class=cF9>U32</span><span class=cF0> load_rba; </span><span class=cF2>// start addr of virtual disk</span><span class=cF0>
<a name="l25"></a> </span><span class=cF1>U8</span><span class=cF0> zero2[</span><span class=cFE>20</span><span class=cF0>];
<a name="l26"></a>};
<a name="l27"></a>
<a name="l28"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>RedSeaISO9660Stage1</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *iso_filename, </span><span class=cF1>U8</span><span class=cF0> *stage2_filename)
<a name="l29"></a>{
<a name="l30"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> de;
<a name="l31"></a> </span><span class=cF9>CFile</span><span class=cF0> *out_file = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l32"></a> </span><span class=cF1>U8</span><span class=cF0> *stage1_buf = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF3>DVD_BOOT_LOADER_SIZE</span><span class=cF0>);
<a name="l33"></a>
<a name="l34"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>FileFind</span><span class=cF7>(</span><span class=cF0>stage2_filename, &amp;de</span><span class=cF7>)</span><span class=cF0> &amp;&amp; </span><span class=cF7>(</span><span class=cF0>out_file = </span><span class=cF5>FOpen</span><span class=cF0>(iso_filename, </span><span class=cF6>&quot;wc+&quot;</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
<a name="l35"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l36"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(stage1_buf, </span><span class=cFD>BDVD_START</span><span class=cF0>, </span><span class=cFD>BDVD_END</span><span class=cF0> - </span><span class=cFD>BDVD_START</span><span class=cF0>);
<a name="l37"></a> *(</span><span class=cFD>BDVD_BLK_LO</span><span class=cF0> - </span><span class=cFD>BDVD_START</span><span class=cF0> + stage1_buf)(</span><span class=cF9>U32</span><span class=cF0> *) = de.clus &gt;&gt; </span><span class=cFE>2</span><span class=cF0>;
<a name="l38"></a> *(</span><span class=cFD>BDVD_BLK_COUNT</span><span class=cF0> - </span><span class=cFD>BDVD_START</span><span class=cF0> + stage1_buf)(</span><span class=cF9>U16</span><span class=cF0> *) = (de.size + </span><span class=cF3>DVD_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> + </span><span class=cFE>2</span><span class=cF0>);
<a name="l39"></a> *(</span><span class=cFD>BDVD_SHIFT_BLKS</span><span class=cF0> - </span><span class=cFD>BDVD_START</span><span class=cF0> + stage1_buf)(</span><span class=cF9>U16</span><span class=cF0> *) = de.clus &amp; </span><span class=cFE>3</span><span class=cF0>;
<a name="l40"></a>
<a name="l41"></a> </span><span class=cF1>if</span><span class=cF0> (de.clus &amp; </span><span class=cFE>3</span><span class=cF0>)
<a name="l42"></a> *(</span><span class=cFD>BDVD_BLK_COUNT</span><span class=cF0> - </span><span class=cFD>BDVD_START</span><span class=cF0> + stage1_buf)(</span><span class=cF9>U16</span><span class=cF0> *) += </span><span class=cFE>1</span><span class=cF0>;
<a name="l43"></a>
<a name="l44"></a> </span><span class=cF5>FBlkWrite</span><span class=cF0>(out_file, stage1_buf, </span><span class=cFE>20</span><span class=cF0> &lt;&lt; </span><span class=cFE>2</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </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="l45"></a> </span><span class=cF5>FClose</span><span class=cF0>(out_file);
<a name="l46"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l47"></a> </span><span class=cF5>Free</span><span class=cF0>(stage1_buf);
<a name="l48"></a>}
<a name="l49"></a>
<a name="l50"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>RedSeaISO9660</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *iso_filename, </span><span class=cF1>U8</span><span class=cF0> drv_let)
<a name="l51"></a>{
<a name="l52"></a> </span><span class=cF9>CDrive</span><span class=cF0> *drive = </span><span class=cF5>Letter2Drive</span><span class=cF0>(drv_let);
<a name="l53"></a> </span><span class=cF9>CISOPriDesc</span><span class=cF0> *iso_pri = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF3>DVD_BLK_SIZE</span><span class=cF0>),
<a name="l54"></a> *iso_boot = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF3>DVD_BLK_SIZE</span><span class=cF0>),
<a name="l55"></a> *iso_sup = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF3>DVD_BLK_SIZE</span><span class=cF0>),
<a name="l56"></a> *iso_term = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF3>DVD_BLK_SIZE</span><span class=cF0>);
<a name="l57"></a> </span><span class=cF9>I64</span><span class=cF0> iso_size = </span><span class=cFE>0</span><span class=cF0>, i, j;
<a name="l58"></a> </span><span class=cF9>U32</span><span class=cF0> *d;
<a name="l59"></a> </span><span class=cF9>CElTorito</span><span class=cF0> *et = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF3>DVD_BLK_SIZE</span><span class=cF0>);
<a name="l60"></a> </span><span class=cF1>U8</span><span class=cF0> *zero_buf = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF3>DVD_BLK_SIZE</span><span class=cF0>);
<a name="l61"></a> </span><span class=cF9>CFile</span><span class=cF0> *out_file = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l62"></a>
<a name="l63"></a> </span><span class=cF1>if</span><span class=cF0> (out_file = </span><span class=cF5>FOpen</span><span class=cF7>(</span><span class=cF0>iso_filename, </span><span class=cF6>&quot;wc+&quot;</span><span class=cF7>)</span><span class=cF0>)
<a name="l64"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l65"></a> iso_size = </span><span class=cF5>FSize</span><span class=cF0>(out_file) / </span><span class=cF3>DVD_BLK_SIZE</span><span class=cF0>;
<a name="l66"></a>
<a name="l67"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; drive-&gt;bd-&gt;drv_offset; i += </span><span class=cFE>4</span><span class=cF0>)
<a name="l68"></a> </span><span class=cF5>FBlkWrite</span><span class=cF0>(out_file, zero_buf, i, </span><span class=cFE>4</span><span class=cF0>);
<a name="l69"></a>
<a name="l70"></a> iso_pri-&gt;type = </span><span class=cF3>ISOT_PRI_VOL_DESC</span><span class=cF0>;
<a name="l71"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(iso_pri-&gt;id, </span><span class=cF6>&quot;CD001&quot;</span><span class=cF0>);
<a name="l72"></a> iso_pri-&gt;version = </span><span class=cFE>1</span><span class=cF0>;
<a name="l73"></a> </span><span class=cF5>FillU16Palindrome</span><span class=cF0>(&amp;iso_pri-&gt;vol_set_size, </span><span class=cFE>1</span><span class=cF0>);
<a name="l74"></a> </span><span class=cF5>FillU16Palindrome</span><span class=cF0>(&amp;iso_pri-&gt;vol_seq_num, </span><span class=cFE>1</span><span class=cF0>);
<a name="l75"></a> </span><span class=cF5>FillU16Palindrome</span><span class=cF0>(&amp;iso_pri-&gt;log_block_size, </span><span class=cF3>DVD_BLK_SIZE</span><span class=cF0>);
<a name="l76"></a> </span><span class=cF5>FillU32Palindrome</span><span class=cF0>(&amp;iso_pri-&gt;vol_space_size, iso_size);
<a name="l77"></a> </span><span class=cF5>FillU32Palindrome</span><span class=cF0>(&amp;iso_pri-&gt;root_dir_record, drive-&gt;root_clus);
<a name="l78"></a> iso_pri-&gt;file_structure_version = </span><span class=cFE>1</span><span class=cF0>;
<a name="l79"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(iso_pri-&gt;publisher_id, </span><span class=cF6>&quot;ZealOS RedSea&quot;</span><span class=cF0>);
<a name="l80"></a>
<a name="l81"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(iso_sup, iso_pri, </span><span class=cF3>DVD_BLK_SIZE</span><span class=cF0>);
<a name="l82"></a> iso_sup-&gt;type = </span><span class=cF3>ISOT_SUPPLEMENTARY_DESC</span><span class=cF0>;
<a name="l83"></a>
<a name="l84"></a> iso_boot-&gt;type = </span><span class=cF3>ISOT_BOOT_RECORD</span><span class=cF0>;
<a name="l85"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(iso_boot-&gt;id, </span><span class=cF6>&quot;CD001&quot;</span><span class=cF0>);
<a name="l86"></a> iso_boot-&gt;version = </span><span class=cFE>1</span><span class=cF0>;
<a name="l87"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(iso_boot</span><span class=cF7>(</span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>7</span><span class=cF0>, </span><span class=cF6>&quot;EL TORITO SPECIFICATION&quot;</span><span class=cF0>);
<a name="l88"></a>
<a name="l89"></a> </span><span class=cF5>FBlkWrite</span><span class=cF0>(out_file, iso_pri, </span><span class=cFE>16</span><span class=cF0> &lt;&lt; </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>);
<a name="l90"></a> iso_term-&gt;type = </span><span class=cF3>ISOT_TERMINATOR</span><span class=cF0>;
<a name="l91"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(iso_term-&gt;id, </span><span class=cF6>&quot;CD001&quot;</span><span class=cF0>);
<a name="l92"></a> iso_term-&gt;version = </span><span class=cFE>1</span><span class=cF0>;
<a name="l93"></a>
<a name="l94"></a> d = iso_boot(</span><span class=cF1>U8</span><span class=cF0> *) + </span><span class=cFE>0x47</span><span class=cF0>;
<a name="l95"></a> *d = </span><span class=cFE>20</span><span class=cF0> &lt;&lt; </span><span class=cFE>2</span><span class=cF0> &gt;&gt; </span><span class=cFE>2</span><span class=cF0>;
<a name="l96"></a> </span><span class=cF5>FBlkWrite</span><span class=cF0>(out_file, iso_boot, </span><span class=cFE>17</span><span class=cF0> &lt;&lt; </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>);
<a name="l97"></a>
<a name="l98"></a> </span><span class=cF5>FBlkWrite</span><span class=cF0>(out_file, iso_sup, </span><span class=cFE>18</span><span class=cF0> &lt;&lt; </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>);
<a name="l99"></a> </span><span class=cF5>FBlkWrite</span><span class=cF0>(out_file, iso_term, </span><span class=cFE>19</span><span class=cF0> &lt;&lt; </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>);
<a name="l100"></a>
<a name="l101"></a> et-&gt;w[</span><span class=cFE>0</span><span class=cF0>] = </span><span class=cFE>1</span><span class=cF0>;
<a name="l102"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(&amp;et-&gt;w[</span><span class=cFE>2</span><span class=cF0>], </span><span class=cF6>&quot;ZealOS&quot;</span><span class=cF0>);
<a name="l103"></a> et-&gt;w[</span><span class=cFE>15</span><span class=cF0>] = </span><span class=cFE>0xAA55</span><span class=cF0>;
<a name="l104"></a>
<a name="l105"></a> j = </span><span class=cFE>0</span><span class=cF0>;
<a name="l106"></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=cFE>16</span><span class=cF0>; i++) </span><span class=cF2>//Checksum</span><span class=cF0>
<a name="l107"></a> j += et-&gt;w[i];
<a name="l108"></a>
<a name="l109"></a> et-&gt;w[</span><span class=cFE>14</span><span class=cF0>] = -j;
<a name="l110"></a> et-&gt;bootable = </span><span class=cFE>0x88</span><span class=cF0>;
<a name="l111"></a> et-&gt;media_type = </span><span class=cFE>0</span><span class=cF0>;</span><span class=cF2>//0=no emu 2=1.44meg 4=hard drive</span><span class=cF0>
<a name="l112"></a> et-&gt;sect_count = </span><span class=cFE>4</span><span class=cF0>; </span><span class=cF2>//5 seems like the limit, 4 is safer</span><span class=cF0>
<a name="l113"></a> et-&gt;load_rba = </span><span class=cFE>20</span><span class=cF0> &lt;&lt; </span><span class=cFE>2</span><span class=cF0> &gt;&gt; </span><span class=cFE>2</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>;
<a name="l114"></a> </span><span class=cF5>FBlkWrite</span><span class=cF0>(out_file, et, </span><span class=cFE>20</span><span class=cF0> &lt;&lt; </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>);
<a name="l115"></a> </span><span class=cF5>FClose</span><span class=cF0>(out_file);
<a name="l116"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l117"></a> </span><span class=cF5>Free</span><span class=cF0>(zero_buf);
<a name="l118"></a> </span><span class=cF5>Free</span><span class=cF0>(et);
<a name="l119"></a> </span><span class=cF5>Free</span><span class=cF0>(iso_pri);
<a name="l120"></a> </span><span class=cF5>Free</span><span class=cF0>(iso_boot);
<a name="l121"></a> </span><span class=cF5>Free</span><span class=cF0>(iso_sup);
<a name="l122"></a> </span><span class=cF5>Free</span><span class=cF0>(iso_term);
<a name="l123"></a>}
<a name="l124"></a>
<a name="l125"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>RedSeaISOPass1</span><span class=cF0>(</span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde)
<a name="l126"></a>{
<a name="l127"></a> </span><span class=cF9>I64</span><span class=cF0> dir_entry_count = </span><span class=cFE>3</span><span class=cF0> + </span><span class=cF5>LinkedListCount</span><span class=cF0>(tmpde), res = </span><span class=cFE>0</span><span class=cF0>;
<a name="l128"></a>
<a name="l129"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde)
<a name="l130"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l131"></a> </span><span class=cF1>if</span><span class=cF0> (tmpde-&gt;attr &amp; </span><span class=cF3>RS_ATTR_DIR</span><span class=cF0>)
<a name="l132"></a> {
<a name="l133"></a> </span><span class=cF1>if</span><span class=cF0> (tmpde-&gt;sub)
<a name="l134"></a> res += </span><span class=cF5>RedSeaISOPass1</span><span class=cF0>(tmpde-&gt;sub);
<a name="l135"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l136"></a> res += </span><span class=cF3>BLK_SIZE</span><span class=cF0>; </span><span class=cF2>//Empty dir</span><span class=cF0>
<a name="l137"></a> }
<a name="l138"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l139"></a> res += </span><span class=cF5>CeilU64</span><span class=cF0>(tmpde-&gt;size, </span><span class=cF3>BLK_SIZE</span><span class=cF0>);
<a name="l140"></a>
<a name="l141"></a> tmpde = tmpde-&gt;next;
<a name="l142"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l143"></a> res += </span><span class=cF5>CeilU64</span><span class=cF0>(dir_entry_count &lt;&lt; </span><span class=cFE>6</span><span class=cF0>, </span><span class=cF3>BLK_SIZE</span><span class=cF0>); </span><span class=cF2>//Size in bytes</span><span class=cF0>
<a name="l144"></a>
<a name="l145"></a>#</span><span class=cF1>assert</span><span class=cF0> </span><span class=cF3>CDIR_SIZE</span><span class=cF0> == </span><span class=cFE>64</span><span class=cF0>
<a name="l146"></a>
<a name="l147"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l148"></a>}
<a name="l149"></a>
<a name="l150"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>RedSeaISO</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *_iso_filename=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *_src_dir, </span><span class=cF1>U8</span><span class=cF0> *_stage2_filename=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l151"></a>{</span><span class=cF2>//See </span><a href="https://zeal-operating-system.github.io/ZealOS/Misc/DoDistro.CC.html#l1"><span class=cF4>::/Misc/DoDistro.CC</span></a><span class=cF2>. Must be ISO.C</span><span class=cF0>
<a name="l152"></a> </span><span class=cF9>I64</span><span class=cF0> i, res, root_count, root_dir_blks, bitmap_blks, bitmap_blks1;
<a name="l153"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde;
<a name="l154"></a> </span><span class=cF1>U8</span><span class=cF0> buf[</span><span class=cF3>STR_LEN</span><span class=cF0>], *iso_filename, *src_dir, *stage2_filename;
<a name="l155"></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>'Q'</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#l3286"><span class=cF4>BDT_ISO_FILE_WRITE</span></a><span class=cF0>
<a name="l156"></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_WRITE</span><span class=cF0>);
<a name="l157"></a>
<a name="l158"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsDir</span><span class=cF7>(</span><span class=cF0>_src_dir</span><span class=cF7>)</span><span class=cF0>)
<a name="l159"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>&quot;'%s' is not a dir.\n&quot;</span><span class=cF0>, _src_dir);
<a name="l160"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l161"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l162"></a> </span><span class=cF1>if</span><span class=cF0> (!_iso_filename)
<a name="l163"></a> _iso_filename = </span><span class=cFB>blkdev</span><span class=cF0>.default_iso_c_filename;
<a name="l164"></a>
<a name="l165"></a> iso_filename = </span><span class=cF5>ExtChange</span><span class=cF0>(_iso_filename, </span><span class=cF6>&quot;ISO.C&quot;</span><span class=cF0>);
<a name="l166"></a> src_dir = </span><span class=cF5>DirNameAbs</span><span class=cF0>(_src_dir);
<a name="l167"></a>
<a name="l168"></a> </span><span class=cF1>if</span><span class=cF0> (_stage2_filename)
<a name="l169"></a> {
<a name="l170"></a> stage2_filename = </span><span class=cF5>FileNameAbs</span><span class=cF0>(_stage2_filename);
<a name="l171"></a> *stage2_filename = drive-&gt;drv_let;
<a name="l172"></a>
<a name="l173"></a> i = </span><span class=cF5>StrLen</span><span class=cF0>(src_dir);
<a name="l174"></a> </span><span class=cF1>if</span><span class=cF0> (i != </span><span class=cFE>3</span><span class=cF0>) </span><span class=cF2>//If not root</span><span class=cF0>
<a name="l175"></a> i++; </span><span class=cF2>//Skip slash</span><span class=cF0>
<a name="l176"></a>
<a name="l177"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(stage2_filename + </span><span class=cFE>3</span><span class=cF0>, stage2_filename + i);
<a name="l178"></a> }
<a name="l179"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l180"></a> stage2_filename = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l181"></a>
<a name="l182"></a> tmpde = </span><span class=cF5>FilesFind</span><span class=cF0>(src_dir, </span><span class=cF3>FUF_RECURSE</span><span class=cF0>);
<a name="l183"></a> root_count = </span><span class=cF5>LinkedListCount</span><span class=cF0>(tmpde) + </span><span class=cFE>3</span><span class=cF0>;
<a name="l184"></a> root_dir_blks = </span><span class=cF5>CeilU64</span><span class=cF0>(root_count &lt;&lt; </span><span class=cFE>6</span><span class=cF0>, </span><span class=cF3>BLK_SIZE</span><span class=cF0>) &gt;&gt; </span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>;
<a name="l185"></a>
<a name="l186"></a> </span><span class=cF1>if</span><span class=cF0> (res = </span><span class=cF5>RedSeaISOPass1</span><span class=cF7>(</span><span class=cF0>tmpde</span><span class=cF7>)</span><span class=cF0> &gt;&gt; </span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>)
<a name="l187"></a> {
<a name="l188"></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="l189"></a> bitmap_blks = </span><span class=cFE>1</span><span class=cF0>;
<a name="l190"></a> </span><span class=cF1>do</span><span class=cF0>
<a name="l191"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l192"></a> bitmap_blks1 = bitmap_blks;
<a name="l193"></a> bitmap_blks = (res + bitmap_blks + </span><span class=cF3>BLK_SIZE</span><span class=cF0> &lt;&lt; </span><span class=cFE>3</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>) / </span><span class=cF3>BLK_SIZE</span><span class=cF0> &lt;&lt; </span><span class=cFE>3</span><span class=cF0>;
<a name="l194"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l195"></a> </span><span class=cF1>while</span><span class=cF0> (bitmap_blks != bitmap_blks1);
<a name="l196"></a>
<a name="l197"></a> bd-&gt;max_blk = </span><span class=cF5>CeilI64</span><span class=cF0>(bd-&gt;drv_offset + </span><span class=cFE>1</span><span class=cF0> + bitmap_blks + res, </span><span class=cFE>4</span><span class=cF0>);
<a name="l198"></a> bd-&gt;max_blk--; </span><span class=cF2>//Inclusive.</span><span class=cF0>
<a name="l199"></a> bd-&gt;file_disk_name = </span><span class=cF5>SysStrNew</span><span class=cF0>(iso_filename);
<a name="l200"></a> bd-&gt;init_root_dir_blks = root_dir_blks;
<a name="l201"></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="l202"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf, </span><span class=cF6>&quot;%C:/&quot;</span><span class=cF0>, drive-&gt;drv_let);
<a name="l203"></a> </span><span class=cF5>CopyTree</span><span class=cF0>(src_dir, buf, </span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l204"></a> </span><span class=cF5>RedSeaISO9660Stage1</span><span class=cF0>(iso_filename, stage2_filename);
<a name="l205"></a> </span><span class=cF5>DriveDel</span><span class=cF0>(drive);
<a name="l206"></a> </span><span class=cF5>BlkDevDel</span><span class=cF0>(bd);
<a name="l207"></a> }
<a name="l208"></a> </span><span class=cF5>Free</span><span class=cF0>(stage2_filename);
<a name="l209"></a> </span><span class=cF5>Free</span><span class=cF0>(src_dir);
<a name="l210"></a> </span><span class=cF5>Free</span><span class=cF0>(iso_filename);
<a name="l211"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l212"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l213"></a>}
</span></pre></body>
</html>