mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-30 17:26:31 +00:00
dbf8647d59
Added top & right borders to RawDr. Improved spacing in some debug and compiler reporting. Fixed RawPutChar and EdLite tab width. Fixed Ui missing '0x' prefix syntax highlighter bug. Added 32BitPaint demo.
437 lines
48 KiB
HTML
Executable file
437 lines
48 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.08">
|
|
<style type="text/css">
|
|
body {background-color:#000000;}
|
|
.cF0{color:#ffffff;background-color:#000000;}
|
|
.cF1{color:#3465a4;background-color:#000000;}
|
|
.cF2{color:#4e9a06;background-color:#000000;}
|
|
.cF3{color:#06989a;background-color:#000000;}
|
|
.cF4{color:#a24444;background-color:#000000;}
|
|
.cF5{color:#75507b;background-color:#000000;}
|
|
.cF6{color:#ce982f;background-color:#000000;}
|
|
.cF7{color:#bcc0b9;background-color:#000000;}
|
|
.cF8{color:#555753;background-color:#000000;}
|
|
.cF9{color:#729fcf;background-color:#000000;}
|
|
.cFA{color:#82bc49;background-color:#000000;}
|
|
.cFB{color:#34e2e2;background-color:#000000;}
|
|
.cFC{color:#ac3535;background-color:#000000;}
|
|
.cFD{color:#ad7fa8;background-color:#000000;}
|
|
.cFE{color:#fce94f;background-color:#000000;}
|
|
.cFF{color:#000000;background-color:#000000;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DriveLock</span><span class=cF0>(</span><span class=cF9>CDrive</span><span class=cF0> *drive)
|
|
<a name="l2"></a>{</span><span class=cF2>//Make this task have exclusive access to drv & BlkDev.</span><span class=cF0>
|
|
<a name="l3"></a> </span><span class=cF5>DriveCheck</span><span class=cF0>(drive);
|
|
<a name="l4"></a> </span><span class=cF5>BlkDevLock</span><span class=cF0>(drive->bd);
|
|
<a name="l5"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&drive->locked_flags, </span><span class=cF3>DVlf_LOCKED</span><span class=cF7>)</span><span class=cF0> || drive->owning_task != </span><span class=cF5>Fs</span><span class=cF0>)
|
|
<a name="l6"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l7"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&drive->locked_flags, </span><span class=cF3>DVlf_LOCKED</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l8"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l9"></a> drive->owning_task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l10"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l11"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l12"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l13"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l14"></a>}
|
|
<a name="l15"></a>
|
|
<a name="l16"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DriveUnlock</span><span class=cF0>(</span><span class=cF9>CDrive</span><span class=cF0> *drive, </span><span class=cF1>Bool</span><span class=cF0> reset=</span><span class=cF3>FALSE</span><span class=cF0>)
|
|
<a name="l17"></a>{</span><span class=cF2>//Release exclusive lock on access to drv & BlkDev.</span><span class=cF0>
|
|
<a name="l18"></a> </span><span class=cF5>DriveCheck</span><span class=cF0>(drive);
|
|
<a name="l19"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&drive->locked_flags, </span><span class=cF3>DVlf_LOCKED</span><span class=cF7>)</span><span class=cF0> && drive->owning_task == </span><span class=cF5>Fs</span><span class=cF0>)
|
|
<a name="l20"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l21"></a> </span><span class=cF5>BlkDevUnlock</span><span class=cF0>(drive->bd, reset);
|
|
<a name="l22"></a> drive->owning_task = </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l23"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&drive->locked_flags, </span><span class=cF3>DVlf_LOCKED</span><span class=cF0>);
|
|
<a name="l24"></a> </span><span class=cF5>Yield</span><span class=cF0>; </span><span class=cF2>//Prevent deadlock</span><span class=cF0>
|
|
<a name="l25"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l26"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l27"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l28"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l29"></a>}
|
|
<a name="l30"></a>
|
|
<a name="l31"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DrivesRelease</span><span class=cF0>()
|
|
<a name="l32"></a>{</span><span class=cF2>//When task dies, release all owned drvs.</span><span class=cF0>
|
|
<a name="l33"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l34"></a> </span><span class=cF9>CDrive</span><span class=cF0> *drive;
|
|
<a name="l35"></a>
|
|
<a name="l36"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < </span><span class=cF3>DRIVES_NUM</span><span class=cF0>; i++)
|
|
<a name="l37"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l38"></a> drive = &</span><span class=cFB>blkdev</span><span class=cF0>.drvs[i];
|
|
<a name="l39"></a> </span><span class=cF1>if</span><span class=cF0> (drive->owning_task == </span><span class=cF5>Fs</span><span class=cF0> && drive->drive_signature == </span><span class=cF3>DRIVE_SIGNATURE_VAL</span><span class=cF0>)
|
|
<a name="l40"></a> </span><span class=cF5>DriveUnlock</span><span class=cF0>(drive, </span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l41"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l42"></a>}
|
|
<a name="l43"></a>
|
|
<a name="l44"></a></span><span class=cF9>CDrive</span><span class=cF0> *</span><span class=cF5>DriveMakeFreeSlot</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> drv_let)
|
|
<a name="l45"></a>{</span><span class=cF2>//Make a slot free for a new drv, like during </span><a href="https://tomawezome.github.io/ZealOS/System/BlkDev/Mount.CC.html#l235"><span class=cF4>Mount</span></a><span class=cF2>().</span><span class=cF0>
|
|
<a name="l46"></a> </span><span class=cF9>I64</span><span class=cF0> i = </span><span class=cF5>Letter2Letter</span><span class=cF0>(drv_let) - </span><span class=cF6>'A'</span><span class=cF0>;
|
|
<a name="l47"></a> </span><span class=cF9>CDrive</span><span class=cF0> *res;
|
|
<a name="l48"></a>
|
|
<a name="l49"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cFE>0</span><span class=cF0> <= i < </span><span class=cF3>DRIVES_NUM</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l50"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drive'</span><span class=cF0>);
|
|
<a name="l51"></a> res = &</span><span class=cFB>blkdev</span><span class=cF0>.drvs[i];
|
|
<a name="l52"></a> </span><span class=cF5>MemSet</span><span class=cF0>(res, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDrive</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l53"></a> res->drv_let = </span><span class=cF6>'A'</span><span class=cF0> + i;
|
|
<a name="l54"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l55"></a>}
|
|
<a name="l56"></a>
|
|
<a name="l57"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cF5>DriveNextFreeLet</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> first_drive_let=</span><span class=cF6>'C'</span><span class=cF0>)
|
|
<a name="l58"></a>{</span><span class=cF2>//Locate free slot for new drv, like during </span><a href="https://tomawezome.github.io/ZealOS/System/BlkDev/Mount.CC.html#l235"><span class=cF4>Mount</span></a><span class=cF2>().</span><span class=cF0>
|
|
<a name="l59"></a> </span><span class=cF9>I64</span><span class=cF0> i = </span><span class=cF5>Letter2Letter</span><span class=cF0>(first_drive_let) - </span><span class=cF6>'A'</span><span class=cF0>, type = </span><span class=cF5>Letter2BlkDevType</span><span class=cF0>(first_drive_let);
|
|
<a name="l60"></a>
|
|
<a name="l61"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cFE>0</span><span class=cF0> <= i < </span><span class=cF3>DRIVES_NUM</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l62"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drive'</span><span class=cF0>);
|
|
<a name="l63"></a> </span><span class=cF1>do</span><span class=cF0>
|
|
<a name="l64"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>blkdev</span><span class=cF0>.drvs[i].drive_signature != </span><span class=cF3>DRIVE_SIGNATURE_VAL</span><span class=cF0>)
|
|
<a name="l65"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l66"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Letter2BlkDevType</span><span class=cF7>(</span><span class=cF0>i + </span><span class=cF6>'A'</span><span class=cF7>)</span><span class=cF0> != type)
|
|
<a name="l67"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drive'</span><span class=cF0>);
|
|
<a name="l68"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l69"></a> </span><span class=cF1>return</span><span class=cF0> i + </span><span class=cF6>'A'</span><span class=cF0>;
|
|
<a name="l70"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l71"></a> </span><span class=cF1>while</span><span class=cF0> (++i < </span><span class=cF3>DRIVES_NUM</span><span class=cF0>);
|
|
<a name="l72"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drive'</span><span class=cF0>);
|
|
<a name="l73"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>; </span><span class=cF2>//Never gets here.</span><span class=cF0>
|
|
<a name="l74"></a>}
|
|
<a name="l75"></a>
|
|
<a name="l76"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DriveDel</span><span class=cF0>(</span><span class=cF9>CDrive</span><span class=cF0> *drive)
|
|
<a name="l77"></a>{</span><span class=cF2>//Delete drv</span><span class=cF0>
|
|
<a name="l78"></a> </span><span class=cF1>if</span><span class=cF0> (drive->fs_type == </span><span class=cF3>FSt_REDSEA</span><span class=cF0> && drive->next_free)
|
|
<a name="l79"></a> </span><span class=cFD>RedSeaFreeFreeList</span><span class=cF0>(drive);
|
|
<a name="l80"></a> </span><span class=cF5>Free</span><span class=cF0>(drive->cur_fat_blk);
|
|
<a name="l81"></a> </span><span class=cF5>Free</span><span class=cF0>(drive->fis);
|
|
<a name="l82"></a> </span><span class=cF5>MemSet</span><span class=cF0>(drive, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDrive</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l83"></a>}
|
|
<a name="l84"></a>
|
|
<a name="l85"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>DriveBlkDevDel</span><span class=cF0>(</span><span class=cF9>CBlkDev</span><span class=cF0> *bd)
|
|
<a name="l86"></a>{</span><span class=cF2>//Delete drv's of BlkDev</span><span class=cF0>
|
|
<a name="l87"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l88"></a> </span><span class=cF9>CDrive</span><span class=cF0> *drive;
|
|
<a name="l89"></a>
|
|
<a name="l90"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < </span><span class=cF3>DRIVES_NUM</span><span class=cF0>; i++)
|
|
<a name="l91"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l92"></a> drive = &</span><span class=cFB>blkdev</span><span class=cF0>.drvs[i];
|
|
<a name="l93"></a> </span><span class=cF1>if</span><span class=cF0> (drive->bd == bd)
|
|
<a name="l94"></a> </span><span class=cF5>DriveDel</span><span class=cF0>(drive);
|
|
<a name="l95"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l96"></a>}
|
|
<a name="l97"></a>
|
|
<a name="l98"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>DriveFATBlkAlloc</span><span class=cF0>(</span><span class=cF9>CDrive</span><span class=cF0> *drive)
|
|
<a name="l99"></a>{
|
|
<a name="l100"></a> </span><span class=cF5>DriveCheck</span><span class=cF0>(drive);
|
|
<a name="l101"></a> </span><span class=cF5>Free</span><span class=cF0>(drive->cur_fat_blk);
|
|
<a name="l102"></a> drive->cur_fat_blk = </span><span class=cF5>SysMAlloc</span><span class=cF0>(</span><span class=cF3>BLK_SIZE</span><span class=cF0>);
|
|
<a name="l103"></a> drive->cur_fat_blk_num = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l104"></a> drive->fat_blk_dirty = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l105"></a> </span><span class=cF5>BlkRead</span><span class=cF0>(drive, drive->cur_fat_blk, drive->fat1, </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l106"></a>}
|
|
<a name="l107"></a>
|
|
<a name="l108"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>DriveFATBlkClean</span><span class=cF0>(</span><span class=cF9>CDrive</span><span class=cF0> *drive, </span><span class=cF9>I64</span><span class=cF0> fat_sel=</span><span class=cFE>3</span><span class=cF0>)
|
|
<a name="l109"></a>{
|
|
<a name="l110"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>drive->fs_type == </span><span class=cF3>FSt_FAT32</span><span class=cF0> || drive->fs_type == </span><span class=cF3>FSt_REDSEA</span><span class=cF7>)</span><span class=cF0> && </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&drive->fat_blk_dirty, </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l111"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l112"></a> </span><span class=cF1>if</span><span class=cF0> (drive->fat1 == drive->fat2)
|
|
<a name="l113"></a> {
|
|
<a name="l114"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(drive, drive->cur_fat_blk, drive->fat1 + drive->cur_fat_blk_num, </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l115"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&drive->fat_blk_dirty, </span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l116"></a> }
|
|
<a name="l117"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l118"></a> {
|
|
<a name="l119"></a> </span><span class=cF1>if</span><span class=cF0> (fat_sel == </span><span class=cFE>3</span><span class=cF0> || !fat_sel)
|
|
<a name="l120"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(drive, drive->cur_fat_blk, drive->fat1 + drive->cur_fat_blk_num, </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l121"></a> </span><span class=cF1>if</span><span class=cF0> (fat_sel == </span><span class=cFE>3</span><span class=cF0> || fat_sel == </span><span class=cFE>1</span><span class=cF0>)
|
|
<a name="l122"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l123"></a> </span><span class=cF5>BlkWrite</span><span class=cF0>(drive, drive->cur_fat_blk, drive->fat2 + drive->cur_fat_blk_num, </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l124"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&drive->fat_blk_dirty, </span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l125"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l126"></a> }
|
|
<a name="l127"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l128"></a>}
|
|
<a name="l129"></a>
|
|
<a name="l130"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>DriveFATBlkSet</span><span class=cF0>(</span><span class=cF9>CDrive</span><span class=cF0> *drive, </span><span class=cF9>I64</span><span class=cF0> c, </span><span class=cF9>I64</span><span class=cF0> fat_sel=</span><span class=cFE>3</span><span class=cF0>)
|
|
<a name="l131"></a>{
|
|
<a name="l132"></a> </span><span class=cF9>I64</span><span class=cF0> fat_blk_num;
|
|
<a name="l133"></a>
|
|
<a name="l134"></a> </span><span class=cF1>if</span><span class=cF0> (c == </span><span class=cF3>INVALID_CLUS</span><span class=cF0>)
|
|
<a name="l135"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drive'</span><span class=cF0>);
|
|
<a name="l136"></a> </span><span class=cF1>switch</span><span class=cF0> (drive->fs_type)
|
|
<a name="l137"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l138"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_FAT32</span><span class=cF0>:
|
|
<a name="l139"></a> fat_blk_num = c >> (</span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF0>);
|
|
<a name="l140"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l141"></a>
|
|
<a name="l142"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_REDSEA</span><span class=cF0>:
|
|
<a name="l143"></a> fat_blk_num = (c-drive->data_area) >> (</span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0>);
|
|
<a name="l144"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l145"></a>
|
|
<a name="l146"></a> </span><span class=cF1>default</span><span class=cF0>:
|
|
<a name="l147"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drive'</span><span class=cF0>);
|
|
<a name="l148"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l149"></a> </span><span class=cF1>if</span><span class=cF0> (fat_blk_num != drive->cur_fat_blk_num)
|
|
<a name="l150"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l151"></a> </span><span class=cFD>DriveFATBlkClean</span><span class=cF0>(drive, fat_sel);
|
|
<a name="l152"></a> drive->cur_fat_blk_num = fat_blk_num;
|
|
<a name="l153"></a> </span><span class=cF1>if</span><span class=cF0> (fat_sel == </span><span class=cFE>3</span><span class=cF0> || !fat_sel)
|
|
<a name="l154"></a> </span><span class=cF5>BlkRead</span><span class=cF0>(drive, drive->cur_fat_blk, drive->fat1 + drive->cur_fat_blk_num, </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l155"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l156"></a> </span><span class=cF5>BlkRead</span><span class=cF0>(drive, drive->cur_fat_blk, drive->fat2 + drive->cur_fat_blk_num, </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l157"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l158"></a>}
|
|
<a name="l159"></a>
|
|
<a name="l160"></a></span><span class=cF9>CDrive</span><span class=cF0> *</span><span class=cF5>DriveCheck</span><span class=cF0>(</span><span class=cF9>CDrive</span><span class=cF0> *drive, </span><span class=cF1>Bool</span><span class=cF0> except=</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l161"></a>{</span><span class=cF2>//Check for valid drv. Throw exception.</span><span class=cF0>
|
|
<a name="l162"></a> </span><span class=cF1>if</span><span class=cF0> (!drive || drive->drive_signature != </span><span class=cF3>DRIVE_SIGNATURE_VAL</span><span class=cF0>)
|
|
<a name="l163"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l164"></a> </span><span class=cF1>if</span><span class=cF0> (except)
|
|
<a name="l165"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drive'</span><span class=cF0>);
|
|
<a name="l166"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l167"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l168"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l169"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l170"></a> </span><span class=cF1>return</span><span class=cF0> drive;
|
|
<a name="l171"></a>}
|
|
<a name="l172"></a>
|
|
<a name="l173"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cF5>Drive2Letter</span><span class=cF0>(</span><span class=cF9>CDrive</span><span class=cF0> *drive=</span><span class=cF3>NULL</span><span class=cF0>)
|
|
<a name="l174"></a>{</span><span class=cF2>//Drive ptr to Drive letter.</span><span class=cF0>
|
|
<a name="l175"></a> </span><span class=cF1>if</span><span class=cF0> (!drive)
|
|
<a name="l176"></a> drive = </span><span class=cF5>Fs</span><span class=cF0>->cur_dv;
|
|
<a name="l177"></a> </span><span class=cF5>DriveCheck</span><span class=cF0>(drive);
|
|
<a name="l178"></a> </span><span class=cF1>return</span><span class=cF0> drive->drv_let;
|
|
<a name="l179"></a>}
|
|
<a name="l180"></a>
|
|
<a name="l181"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cF5>Letter2Letter</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="l182"></a>{</span><span class=cF2>//Drive letter to Drive letter.</span><span class=cF0>
|
|
<a name="l183"></a> </span><span class=cF1>if</span><span class=cF0> (!drv_let)
|
|
<a name="l184"></a> drv_let = </span><span class=cF5>Drive2Letter</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dv);
|
|
<a name="l185"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (drv_let == </span><span class=cF6>':'</span><span class=cF0>)
|
|
<a name="l186"></a> drv_let = </span><span class=cFB>blkdev</span><span class=cF0>.boot_drive_let;
|
|
<a name="l187"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (drv_let == </span><span class=cF6>'~'</span><span class=cF0>)
|
|
<a name="l188"></a> drv_let = *</span><span class=cFB>blkdev</span><span class=cF0>.home_dir;
|
|
<a name="l189"></a>
|
|
<a name="l190"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>ToUpper</span><span class=cF0>(drv_let);
|
|
<a name="l191"></a>}
|
|
<a name="l192"></a>
|
|
<a name="l193"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>Letter2BlkDevType</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> drv_let)
|
|
<a name="l194"></a>{</span><span class=cF2>//Drive letter to BlkDev Type. drv_let=0 not allowed. See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3241"><span class=cF4>BDT_NULL</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l195"></a> drv_let = </span><span class=cF5>Letter2Letter</span><span class=cF0>(drv_let);
|
|
<a name="l196"></a>
|
|
<a name="l197"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'A'</span><span class=cF0> <= drv_let <= </span><span class=cF6>'B'</span><span class=cF0>)
|
|
<a name="l198"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>BDT_RAM</span><span class=cF0>;
|
|
<a name="l199"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'C'</span><span class=cF0> <= drv_let <= </span><span class=cF6>'L'</span><span class=cF0>)
|
|
<a name="l200"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>BDT_ATA</span><span class=cF0>;
|
|
<a name="l201"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'M'</span><span class=cF0> <= drv_let <= </span><span class=cF6>'P'</span><span class=cF0>)
|
|
<a name="l202"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>BDT_ISO_FILE_READ</span><span class=cF0>;
|
|
<a name="l203"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'Q'</span><span class=cF0> <= drv_let <= </span><span class=cF6>'S'</span><span class=cF0>)
|
|
<a name="l204"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>BDT_ISO_FILE_WRITE</span><span class=cF0>;
|
|
<a name="l205"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'T'</span><span class=cF0> <= drv_let <= </span><span class=cF6>'Z'</span><span class=cF0>)
|
|
<a name="l206"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>BDT_ATAPI</span><span class=cF0>;
|
|
<a name="l207"></a>
|
|
<a name="l208"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>BDT_NULL</span><span class=cF0>;
|
|
<a name="l209"></a>}
|
|
<a name="l210"></a>
|
|
<a name="l211"></a></span><span class=cF9>CDrive</span><span class=cF0> *</span><span class=cF5>Letter2Drive</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> drv_let=</span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> except=</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l212"></a>{</span><span class=cF2>//Drive letter to Drive ptr.</span><span class=cF0>
|
|
<a name="l213"></a> </span><span class=cF9>CDrive</span><span class=cF0> *drive;
|
|
<a name="l214"></a>
|
|
<a name="l215"></a> </span><span class=cF1>if</span><span class=cF0> (!drv_let)
|
|
<a name="l216"></a> drive = </span><span class=cF5>Fs</span><span class=cF0>->cur_dv;
|
|
<a name="l217"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l218"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l219"></a> drv_let = </span><span class=cF5>Letter2Letter</span><span class=cF0>(drv_let);
|
|
<a name="l220"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF6>'A'</span><span class=cF0> <= drv_let <= </span><span class=cF6>'Z'</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l221"></a> {
|
|
<a name="l222"></a> </span><span class=cF1>if</span><span class=cF0> (except)
|
|
<a name="l223"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drive'</span><span class=cF0>);
|
|
<a name="l224"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l225"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l226"></a> }
|
|
<a name="l227"></a> drive = </span><span class=cFB>blkdev</span><span class=cF0>.let_to_drive[drv_let - </span><span class=cF6>'A'</span><span class=cF0>];
|
|
<a name="l228"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l229"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>DriveCheck</span><span class=cF0>(drive, except);
|
|
<a name="l230"></a>}
|
|
<a name="l231"></a>
|
|
<a name="l232"></a></span><span class=cF9>CBlkDev</span><span class=cF0> *</span><span class=cF5>DriveIsWritable</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> drv_let=</span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> except=</span><span class=cF3>FALSE</span><span class=cF0>)
|
|
<a name="l233"></a>{</span><span class=cF2>//Is drive writable?</span><span class=cF0>
|
|
<a name="l234"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *bd;
|
|
<a name="l235"></a>
|
|
<a name="l236"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>bd = </span><span class=cF5>Letter2BlkDev</span><span class=cF0>(drv_let, except)</span><span class=cF7>)</span><span class=cF0> || bd->flags & </span><span class=cF3>BDF_READ_ONLY</span><span class=cF0>)
|
|
<a name="l237"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l238"></a> </span><span class=cF1>if</span><span class=cF0> (except)
|
|
<a name="l239"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'Drive'</span><span class=cF0>);
|
|
<a name="l240"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l241"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l242"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l243"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l244"></a> </span><span class=cF1>return</span><span class=cF0> bd;
|
|
<a name="l245"></a>}
|
|
<a name="l246"></a>
|
|
<a name="l247"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DiskCacheInvalidate</span><span class=cF0>(</span><span class=cF9>CDrive</span><span class=cF0> *drive)
|
|
<a name="l248"></a>{</span><span class=cF2>//Needed for removable media. Called by </span><a href="https://tomawezome.github.io/ZealOS/Kernel/BlkDev/DiskDrive.CC.html#l269"><span class=cF4>DiskChange</span></a><span class=cF2>().</span><span class=cF0>
|
|
<a name="l249"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock;
|
|
<a name="l250"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *bd = drive->bd;
|
|
<a name="l251"></a>
|
|
<a name="l252"></a> </span><span class=cF5>DriveCheck</span><span class=cF0>(drive);
|
|
<a name="l253"></a> </span><span class=cF1>try</span><span class=cF0>
|
|
<a name="l254"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l255"></a> unlock = </span><span class=cF5>DriveLock</span><span class=cF0>(drive);
|
|
<a name="l256"></a> </span><span class=cFD>BlkDevInit</span><span class=cF0>(bd);
|
|
<a name="l257"></a> </span><span class=cF1>if</span><span class=cF0> (bd->flags & </span><span class=cF3>BDF_READ_CACHE</span><span class=cF0>)
|
|
<a name="l258"></a> </span><span class=cFD>DiskCacheInvalidate2</span><span class=cF0>(drive);
|
|
<a name="l259"></a> </span><span class=cF1>if</span><span class=cF0> (bd->type == </span><span class=cF3>BDT_ATAPI</span><span class=cF0> && !</span><span class=cF7>(</span><span class=cF0>bd->flags & </span><span class=cF3>BDF_READ_ONLY_OVERRIDE</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l260"></a> </span><span class=cFD>ISOInit</span><span class=cF0>(drive, </span><span class=cF7>(</span><span class=cFE>32767</span><span class=cF0> / bd->blk_size + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0> * bd->blk_size >> </span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>);
|
|
<a name="l261"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l262"></a> </span><span class=cF5>DriveUnlock</span><span class=cF0>(drive);
|
|
<a name="l263"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l264"></a> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l265"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l266"></a> </span><span class=cF5>DriveUnlock</span><span class=cF0>(drive);
|
|
<a name="l267"></a>}
|
|
<a name="l268"></a>
|
|
<a name="l269"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DiskChange</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="l270"></a>{</span><span class=cF2>//Change disk. (Needed for removable media.)</span><span class=cF0>
|
|
<a name="l271"></a> </span><span class=cF9>CDrive</span><span class=cF0> *drive = </span><span class=cF5>Letter2Drive</span><span class=cF0>(drv_let);
|
|
<a name="l272"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *bd = drive->bd;
|
|
<a name="l273"></a>
|
|
<a name="l274"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>bd->flags & </span><span class=cF3>BDF_INITIALIZED</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l275"></a> </span><span class=cFD>BlkDevInit</span><span class=cF0>(bd);
|
|
<a name="l276"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (bd->flags & </span><span class=cF3>BDF_REMOVABLE</span><span class=cF0>)
|
|
<a name="l277"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l278"></a> </span><span class=cF1>if</span><span class=cF0> (bd->type == </span><span class=cF3>BDT_ATAPI</span><span class=cF0>)
|
|
<a name="l279"></a> </span><span class=cFD>AHCIAtaInit</span><span class=cF0>(bd); </span><span class=cF2>//TODO: This is a kludge for QEMU?</span><span class=cF0>
|
|
<a name="l280"></a> </span><span class=cF5>DiskCacheInvalidate</span><span class=cF0>(drive);
|
|
<a name="l281"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l282"></a> </span><span class=cF5>Drive</span><span class=cF0>(drv_let);
|
|
<a name="l283"></a> </span><span class=cFD>RedSeaFreeFreeList</span><span class=cF0>(drive);
|
|
<a name="l284"></a>}
|
|
<a name="l285"></a>
|
|
<a name="l286"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Drive</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> drv_let)
|
|
<a name="l287"></a>{</span><span class=cF2>//Change drive.</span><span class=cF0> </span><span class=cF2>You can set drive with </span><a href="https://tomawezome.github.io/ZealOS/Kernel/BlkDev/DiskDirB.CC.html#l9"><span class=cF4>Cd</span></a><span class=cF2>() as well.</span><span class=cF0>
|
|
<a name="l288"></a> </span><span class=cF9>CDrive</span><span class=cF0> *drive = </span><span class=cF5>Letter2Drive</span><span class=cF0>(drv_let);
|
|
<a name="l289"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *bd;
|
|
<a name="l290"></a>
|
|
<a name="l291"></a> bd = </span><span class=cF5>BlkDevCheck</span><span class=cF0>(drive->bd);
|
|
<a name="l292"></a> </span><span class=cF1>if</span><span class=cF0> (drive != </span><span class=cF5>Fs</span><span class=cF0>->cur_dv)
|
|
<a name="l293"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l294"></a> </span><span class=cF1>if</span><span class=cF0> (bd->flags & </span><span class=cF3>BDF_REMOVABLE</span><span class=cF0> && !</span><span class=cF7>(</span><span class=cF0>bd->flags & </span><span class=cF3>BDF_INITIALIZED</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l295"></a> </span><span class=cF5>DiskChange</span><span class=cF0>(</span><span class=cF5>Drive2Letter</span><span class=cF7>(</span><span class=cF0>drive</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l296"></a> </span><span class=cF1>if</span><span class=cF0> (bd->type == </span><span class=cF3>BDT_RAM</span><span class=cF0> || bd->type == </span><span class=cF3>BDT_ISO_FILE_READ</span><span class=cF0> || bd->type == </span><span class=cF3>BDT_ISO_FILE_WRITE</span><span class=cF0>)
|
|
<a name="l297"></a> </span><span class=cFD>BlkDevInit</span><span class=cF0>(bd);
|
|
<a name="l298"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l299"></a> </span><span class=cF5>Fs</span><span class=cF0>->cur_dv = drive;
|
|
<a name="l300"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>->cur_dir);
|
|
<a name="l301"></a> </span><span class=cF5>Fs</span><span class=cF0>->cur_dir = </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>"/"</span><span class=cF0>);
|
|
<a name="l302"></a> </span><span class=cF1>switch</span><span class=cF0> (drive->fs_type)
|
|
<a name="l303"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l304"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_REDSEA</span><span class=cF0>:
|
|
<a name="l305"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>FSt_FAT32</span><span class=cF0>:
|
|
<a name="l306"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l307"></a>
|
|
<a name="l308"></a> </span><span class=cF1>default</span><span class=cF0>:
|
|
<a name="l309"></a> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF6>"File System Not Supported\n"</span><span class=cF0>);
|
|
<a name="l310"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l311"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l312"></a>}
|
|
<a name="l313"></a>
|
|
<a name="l314"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>DriveSerialNum</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="l315"></a>{</span><span class=cF2>//20 bytes max.</span><span class=cF0>
|
|
<a name="l316"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *bd = </span><span class=cF5>Letter2BlkDev</span><span class=cF0>(drv_let);
|
|
<a name="l317"></a> </span><span class=cF9>U16</span><span class=cF0> *st, *res = </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l318"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l319"></a>
|
|
<a name="l320"></a> </span><span class=cF1>if</span><span class=cF0> (bd->dev_id_record)
|
|
<a name="l321"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l322"></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="l323"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < </span><span class=cFE>10</span><span class=cF0>; i++)
|
|
<a name="l324"></a> st[i] = </span><span class=cF5>EndianU16</span><span class=cF0>(bd->dev_id_record[</span><span class=cFE>10</span><span class=cF0> + i]);
|
|
<a name="l325"></a> res = </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="l326"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
|
<a name="l327"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l328"></a>
|
|
<a name="l329"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l330"></a>}
|
|
<a name="l331"></a>
|
|
<a name="l332"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>DriveModelNum</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="l333"></a>{</span><span class=cF2>//40 bytes max.</span><span class=cF0>
|
|
<a name="l334"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *bd = </span><span class=cF5>Letter2BlkDev</span><span class=cF0>(drv_let);
|
|
<a name="l335"></a> </span><span class=cF9>U16</span><span class=cF0> *st, *res = </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l336"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l337"></a>
|
|
<a name="l338"></a> </span><span class=cF1>if</span><span class=cF0> (bd->dev_id_record)
|
|
<a name="l339"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l340"></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="l341"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < </span><span class=cFE>20</span><span class=cF0>; i++)
|
|
<a name="l342"></a> st[i] = </span><span class=cF5>EndianU16</span><span class=cF0>(bd->dev_id_record[</span><span class=cFE>27</span><span class=cF0> + i]);
|
|
<a name="l343"></a> res = </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="l344"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
|
<a name="l345"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l346"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l347"></a>}
|
|
<a name="l348"></a>
|
|
<a name="l349"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cFD>blkdev_text_attr</span><span class=cF0>[</span><span class=cF3>BDT_TYPES_NUM</span><span class=cF0>] = {</span><span class=cF3>BLACK</span><span class=cF0>, </span><span class=cF3>LTCYAN</span><span class=cF0>, </span><span class=cF3>WHITE</span><span class=cF0>, </span><span class=cF3>LTGREEN</span><span class=cF0>, </span><span class=cF3>LTRED</span><span class=cF0>, </span><span class=cF3>LTBLUE</span><span class=cF0>};
|
|
<a name="l350"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cFD>drv_text_attr</span><span class=cF0>[</span><span class=cFE>3</span><span class=cF0>] = {</span><span class=cF3>BLACK</span><span class=cF0>, </span><span class=cF3>BLUE</span><span class=cF0>, </span><span class=cF3>RED</span><span class=cF0>};
|
|
<a name="l351"></a>
|
|
<a name="l352"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cF5>DriveTextAttrGet</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="l353"></a>{</span><span class=cF2>//Get color of drive.</span><span class=cF0>
|
|
<a name="l354"></a> drv_let = </span><span class=cF5>Letter2Letter</span><span class=cF0>(drv_let);
|
|
<a name="l355"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'A'</span><span class=cF0> <= drv_let <= </span><span class=cF6>'Z'</span><span class=cF0>)
|
|
<a name="l356"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFD>blkdev_text_attr</span><span class=cF0>[</span><span class=cF5>Letter2BlkDevType</span><span class=cF0>(drv_let)] << </span><span class=cFE>4</span><span class=cF0> | </span><span class=cFD>drv_text_attr</span><span class=cF0>[drv_let % </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cFD>drv_text_attr</span><span class=cF0>)];
|
|
<a name="l357"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l358"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>BLACK</span><span class=cF0> << </span><span class=cFE>4</span><span class=cF0> | </span><span class=cF3>WHITE</span><span class=cF0>;
|
|
<a name="l359"></a>}
|
|
<a name="l360"></a>
|
|
<a name="l361"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DriveRep</span><span class=cF0>()
|
|
<a name="l362"></a>{</span><span class=cF2>//Drive report.</span><span class=cF0>
|
|
<a name="l363"></a> </span><span class=cF9>CDrive</span><span class=cF0> *drive;
|
|
<a name="l364"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *bd;
|
|
<a name="l365"></a> </span><span class=cF9>I64</span><span class=cF0> ch, i, drv_let, attr;
|
|
<a name="l366"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
|
|
<a name="l367"></a>
|
|
<a name="l368"></a> </span><span class=cF6>"\nDefined Drives:\n"</span><span class=cF0>;
|
|
<a name="l369"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>, drive = </span><span class=cFB>blkdev</span><span class=cF0>.drvs; i < </span><span class=cF3>DRIVES_NUM</span><span class=cF0>; i++, drive++)
|
|
<a name="l370"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l371"></a> </span><span class=cF1>if</span><span class=cF0> (drive->drive_signature == </span><span class=cF3>DRIVE_SIGNATURE_VAL</span><span class=cF0>)
|
|
<a name="l372"></a> {
|
|
<a name="l373"></a> bd = drive->bd;
|
|
<a name="l374"></a> drv_let = </span><span class=cF5>Drive2Letter</span><span class=cF0>(drive);
|
|
<a name="l375"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&drive->fs_type, </span><span class=cF3>FStf_DISABLE</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l376"></a> ch = </span><span class=cF6>'-'</span><span class=cF0>;
|
|
<a name="l377"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (drv_let == </span><span class=cFB>blkdev</span><span class=cF0>.boot_drive_let)
|
|
<a name="l378"></a> ch = </span><span class=cF6>':'</span><span class=cF0>;
|
|
<a name="l379"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l380"></a> ch = </span><span class=cF6>'+'</span><span class=cF0>;
|
|
<a name="l381"></a> attr = </span><span class=cF5>DriveTextAttrGet</span><span class=cF0>(drv_let);
|
|
<a name="l382"></a> </span><span class=cF6>"$FG,%d$$BG,%d$%C %-8Z %-10Z %04X %04X %02X\n"</span><span class=cF0>, attr & </span><span class=cFE>15</span><span class=cF0>,
|
|
<a name="l383"></a> attr >> </span><span class=cFE>4</span><span class=cF0>,
|
|
<a name="l384"></a> drv_let,
|
|
<a name="l385"></a> drive->fs_type & </span><span class=cF3>FSG_TYPE_MASK</span><span class=cF0>,
|
|
<a name="l386"></a> </span><span class=cF6>"ST_DRIVE_TYPES"</span><span class=cF0>,
|
|
<a name="l387"></a> bd->type,
|
|
<a name="l388"></a> </span><span class=cF6>"ST_BLKDEV_TYPES"</span><span class=cF0>,
|
|
<a name="l389"></a> bd->base0,
|
|
<a name="l390"></a> bd->base1,
|
|
<a name="l391"></a> bd->unit;
|
|
<a name="l392"></a> </span><span class=cF1>if</span><span class=cF0> (st = </span><span class=cF5>DriveModelNum</span><span class=cF7>(</span><span class=cF0>drv_let</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l393"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l394"></a> </span><span class=cF6>" Model# :%s\n"</span><span class=cF0>, st;
|
|
<a name="l395"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
|
<a name="l396"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l397"></a> </span><span class=cF1>if</span><span class=cF0> (st = </span><span class=cF5>DriveSerialNum</span><span class=cF7>(</span><span class=cF0>drv_let</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l398"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l399"></a> </span><span class=cF6>" Serial#:%s\n"</span><span class=cF0>, st;
|
|
<a name="l400"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
|
<a name="l401"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l402"></a> </span><span class=cF1>if</span><span class=cF0> (bd->type == </span><span class=cF3>BDT_ISO_FILE_READ</span><span class=cF0> || bd->type == </span><span class=cF3>BDT_ISO_FILE_WRITE</span><span class=cF0>)
|
|
<a name="l403"></a> </span><span class=cF6>" File=\"%s\"\n"</span><span class=cF0>, bd->file_disk_name;
|
|
<a name="l404"></a> </span><span class=cF6>" %016X-%016X\n$FG$$BG$"</span><span class=cF0>, drive->drv_offset, drive->drv_offset + drive->size - </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l405"></a> }
|
|
<a name="l406"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l407"></a> </span><span class=cF6>"Home Dir:\"%s\"\n"</span><span class=cF0>, </span><span class=cFB>blkdev</span><span class=cF0>.home_dir;
|
|
<a name="l408"></a>}
|
|
</span></pre></body>
|
|
</html>
|