mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-30 17:26:31 +00:00
67479705de
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.
187 lines
15 KiB
HTML
Executable file
187 lines
15 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=cF2>/* // TODO: implement this in AHCI ATAPI</span><span class=cF0>
|
|
<a name="l2"></a></span><span class=cF2>Bool IDEATAPISetMaxSpeed(CBlkDev *bd)</span><span class=cF0>
|
|
<a name="l3"></a></span><span class=cF2>{</span><span class=cF0>
|
|
<a name="l4"></a> </span><span class=cF2>if (bd->flags & BDF_EXT_SIZE)</span><span class=cF0>
|
|
<a name="l5"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_SEL, 0xEF | bd->unit << 4);</span><span class=cF0>
|
|
<a name="l6"></a> </span><span class=cF2>else</span><span class=cF0>
|
|
<a name="l7"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_SEL, 0xE0 | bd->unit << 4);</span><span class=cF0>
|
|
<a name="l8"></a>
|
|
<a name="l9"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_LCYL, 0);</span><span class=cF0>
|
|
<a name="l10"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_HCYL, 0);</span><span class=cF0>
|
|
<a name="l11"></a> </span><span class=cF2>IDEATACmd(bd, ATA_PACKET);</span><span class=cF0>
|
|
<a name="l12"></a> </span><span class=cF2>IDEATAPIWritePacketWord(bd, 0, ATAPI_SET_CD_SPEED, 0xFFFF, 0xFFFF, 0, 0, 0);</span><span class=cF0>
|
|
<a name="l13"></a>
|
|
<a name="l14"></a> </span><span class=cF2>return IDEATAWaitNotBUSY(bd, 0);</span><span class=cF0>
|
|
<a name="l15"></a></span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l16"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l17"></a>
|
|
<a name="l18"></a></span><span class=cF2>/* // TODO: implement this in AHCI ATAPI</span><span class=cF0>
|
|
<a name="l19"></a></span><span class=cF2>CATAPITrack *IDEATAPIReadTrackInfo(CBlkDev *bd, I64 blk)</span><span class=cF0>
|
|
<a name="l20"></a></span><span class=cF2>{</span><span class=cF0>
|
|
<a name="l21"></a> </span><span class=cF2>CATAPITrack</span><span class=cF0> </span><span class=cF2>*res</span><span class=cF0> </span><span class=cF2>= CAlloc(sizeof(CATAPITrack));</span><span class=cF0>
|
|
<a name="l22"></a> </span><span class=cF2>Bool</span><span class=cF0> </span><span class=cF2> unlock</span><span class=cF0> </span><span class=cF2>= BlkDevLock(bd);</span><span class=cF0>
|
|
<a name="l23"></a>
|
|
<a name="l24"></a> </span><span class=cF2>if (IDEATAWaitNotBUSY(bd, 0))</span><span class=cF0>
|
|
<a name="l25"></a> </span><span class=cF2>{</span><span class=cF0>
|
|
<a name="l26"></a> </span><span class=cF2>if (bd->flags & BDF_EXT_SIZE)</span><span class=cF0>
|
|
<a name="l27"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_SEL, 0xEF | bd->unit << 4);</span><span class=cF0>
|
|
<a name="l28"></a> </span><span class=cF2>else</span><span class=cF0>
|
|
<a name="l29"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_SEL, 0xE0 | bd->unit << 4);</span><span class=cF0>
|
|
<a name="l30"></a>
|
|
<a name="l31"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_LCYL, sizeof(CATAPITrack) & 0xFF);</span><span class=cF0>
|
|
<a name="l32"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_HCYL, sizeof(CATAPITrack) >> 8);</span><span class=cF0>
|
|
<a name="l33"></a>
|
|
<a name="l34"></a> </span><span class=cF2>IDEATACmd(bd, ATA_PACKET);</span><span class=cF0>
|
|
<a name="l35"></a> </span><span class=cF2>IDEATAPIWritePacketWord(bd,</span><span class=cF0>
|
|
<a name="l36"></a> </span><span class=cF2> 0,</span><span class=cF0>
|
|
<a name="l37"></a> </span><span class=cF2> ATAPI_READ_TRACK_INFO,</span><span class=cF0>
|
|
<a name="l38"></a> </span><span class=cF2> blk.u16[1],</span><span class=cF0>
|
|
<a name="l39"></a> </span><span class=cF2> blk.u16[0],</span><span class=cF0>
|
|
<a name="l40"></a> </span><span class=cF2> (sizeof(CATAPITrack) & 0xFF00) >> 8,</span><span class=cF0>
|
|
<a name="l41"></a> </span><span class=cF2> (sizeof(CATAPITrack) & 0x00FF) << 8,</span><span class=cF0>
|
|
<a name="l42"></a> </span><span class=cF2> 0);</span><span class=cF0>
|
|
<a name="l43"></a>
|
|
<a name="l44"></a> </span><span class=cF2>if (!IDEATAGetRes(bd, 0, res, sizeof(CATAPITrack), 0, TRUE))</span><span class=cF0>
|
|
<a name="l45"></a> </span><span class=cF2>{</span><span class=cF0>
|
|
<a name="l46"></a> </span><span class=cF2>Free(res);</span><span class=cF0>
|
|
<a name="l47"></a> </span><span class=cF2>res = NULL;</span><span class=cF0>
|
|
<a name="l48"></a> </span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l49"></a> </span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l50"></a> </span><span class=cF2>else</span><span class=cF0>
|
|
<a name="l51"></a> </span><span class=cF2>{</span><span class=cF0>
|
|
<a name="l52"></a> </span><span class=cF2>Free(res);</span><span class=cF0>
|
|
<a name="l53"></a> </span><span class=cF2>res = NULL;</span><span class=cF0>
|
|
<a name="l54"></a> </span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l55"></a> </span><span class=cF2>if (unlock)</span><span class=cF0>
|
|
<a name="l56"></a> </span><span class=cF2>BlkDevUnlock(bd);</span><span class=cF0>
|
|
<a name="l57"></a> </span><span class=cF2>return res;</span><span class=cF0>
|
|
<a name="l58"></a></span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l59"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l60"></a>
|
|
<a name="l61"></a></span><span class=cF2>/* // TODO: get AHCI ATAPI Sync to work, keep this here until it does</span><span class=cF0>
|
|
<a name="l62"></a></span><span class=cF2>Bool IDEATAPISync(CBlkDev *bd)</span><span class=cF0>
|
|
<a name="l63"></a></span><span class=cF2>{</span><span class=cF0>
|
|
<a name="l64"></a> </span><span class=cF2>Bool okay = TRUE;</span><span class=cF0>
|
|
<a name="l65"></a>
|
|
<a name="l66"></a> </span><span class=cF2>if (!IDEATAWaitNotBUSY(bd, 0))</span><span class=cF0>
|
|
<a name="l67"></a> </span><span class=cF2>okay = FALSE;</span><span class=cF0>
|
|
<a name="l68"></a> </span><span class=cF2>else</span><span class=cF0>
|
|
<a name="l69"></a> </span><span class=cF2>{</span><span class=cF0>
|
|
<a name="l70"></a> </span><span class=cF2>if (bd->flags & BDF_EXT_SIZE)</span><span class=cF0>
|
|
<a name="l71"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_SEL, 0xEF | bd->unit << 4);</span><span class=cF0>
|
|
<a name="l72"></a> </span><span class=cF2>else</span><span class=cF0>
|
|
<a name="l73"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_SEL, 0xE0 | bd->unit << 4);</span><span class=cF0>
|
|
<a name="l74"></a>
|
|
<a name="l75"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_LCYL, 0);</span><span class=cF0>
|
|
<a name="l76"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_HCYL, 0);</span><span class=cF0>
|
|
<a name="l77"></a> </span><span class=cF2>IDEATACmd(bd, ATA_PACKET);</span><span class=cF0>
|
|
<a name="l78"></a> </span><span class=cF2>IDEATAPIWritePacketWord(bd, 0, ATAPI_SYNC_CACHE, 0, 0, 0, 0, 0);</span><span class=cF0>
|
|
<a name="l79"></a>
|
|
<a name="l80"></a> </span><span class=cF2>if (!IDEATAWaitNotBUSY(bd, 0))</span><span class=cF0>
|
|
<a name="l81"></a> </span><span class=cF2>okay = FALSE;</span><span class=cF0>
|
|
<a name="l82"></a> </span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l83"></a>
|
|
<a name="l84"></a> </span><span class=cF2>return okay;</span><span class=cF0>
|
|
<a name="l85"></a></span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l86"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l87"></a>
|
|
<a name="l88"></a></span><span class=cF2>/* // TODO: get AHCI ATAPI Close to work, keep this here until it does</span><span class=cF0>
|
|
<a name="l89"></a></span><span class=cF2>U0 IDEATAPIClose(CBlkDev *bd, I64 close_field=0x200, I64 track=0)</span><span class=cF0>
|
|
<a name="l90"></a></span><span class=cF2>{//0x200 CD/DVD part 1</span><span class=cF0>
|
|
<a name="l91"></a></span><span class=cF2>// 0x300</span><span class=cF0> </span><span class=cF2>DVD part 2</span><span class=cF0>
|
|
<a name="l92"></a> </span><span class=cF2>if (bd->flags & BDF_EXT_SIZE)</span><span class=cF0>
|
|
<a name="l93"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_SEL, 0xEF | bd->unit << 4);</span><span class=cF0>
|
|
<a name="l94"></a> </span><span class=cF2>else</span><span class=cF0>
|
|
<a name="l95"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_SEL, 0xE0 | bd->unit << 4);</span><span class=cF0>
|
|
<a name="l96"></a>
|
|
<a name="l97"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_LCYL, 0);</span><span class=cF0>
|
|
<a name="l98"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_HCYL, 0);</span><span class=cF0>
|
|
<a name="l99"></a> </span><span class=cF2>IDEATACmd(bd, ATA_PACKET);</span><span class=cF0>
|
|
<a name="l100"></a> </span><span class=cF2>IDEATAPIWritePacketWord(bd, 0, ATAPI_CLOSE_TRACK_SESSION, close_field, track, 0, 0, 0);</span><span class=cF0>
|
|
<a name="l101"></a>
|
|
<a name="l102"></a> </span><span class=cF2>IDEATAWaitNotBUSY(bd, 0);</span><span class=cF0>
|
|
<a name="l103"></a></span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l104"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l105"></a>
|
|
<a name="l106"></a></span><span class=cF2>/* // TODO: get AHCI ATAPI WriteBlks to work, keep this here until it does</span><span class=cF0>
|
|
<a name="l107"></a></span><span class=cF2>U0 IDEATAPIWriteBlks(CBlkDev *bd, U8 *buf, I64 native_blk, I64 count)</span><span class=cF0>
|
|
<a name="l108"></a></span><span class=cF2>{</span><span class=cF0>
|
|
<a name="l109"></a> </span><span class=cF2>I64 U32s_avail;</span><span class=cF0>
|
|
<a name="l110"></a> </span><span class=cF2>U8 *buf2;</span><span class=cF0>
|
|
<a name="l111"></a>
|
|
<a name="l112"></a> </span><span class=cF2>IDEATAWaitNotBUSY(bd, 0);</span><span class=cF0>
|
|
<a name="l113"></a> </span><span class=cF2>IDEATAPISeek(bd, native_blk);</span><span class=cF0>
|
|
<a name="l114"></a>
|
|
<a name="l115"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_FEAT, 0);</span><span class=cF0>
|
|
<a name="l116"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_LCYL, bd->blk_size);</span><span class=cF0>
|
|
<a name="l117"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_HCYL, bd->blk_size.u8[1]);</span><span class=cF0>
|
|
<a name="l118"></a>
|
|
<a name="l119"></a> </span><span class=cF2>if (bd->flags & BDF_EXT_SIZE)</span><span class=cF0>
|
|
<a name="l120"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_SEL, 0xEF | bd->unit << 4);</span><span class=cF0>
|
|
<a name="l121"></a> </span><span class=cF2>else</span><span class=cF0>
|
|
<a name="l122"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_SEL, 0xE0 | bd->unit << 4);</span><span class=cF0>
|
|
<a name="l123"></a>
|
|
<a name="l124"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_CMD, ATA_PACKET);</span><span class=cF0>
|
|
<a name="l125"></a> </span><span class=cF2>IDEATAPIWritePacketWord(bd, 0, ATAPI_FORMAT_UNIT, native_blk.u16[1], native_blk, count.u16[1], count, 0);</span><span class=cF0>
|
|
<a name="l126"></a>
|
|
<a name="l127"></a> </span><span class=cF2>bd->flags |= BDF_LAST_WAS_WRITE;</span><span class=cF0>
|
|
<a name="l128"></a>
|
|
<a name="l129"></a> </span><span class=cF2>IDEATAWaitNotBUSY(bd, 0);</span><span class=cF0>
|
|
<a name="l130"></a> </span><span class=cF2>IDEATAPISeek(bd, native_blk);</span><span class=cF0>
|
|
<a name="l131"></a>
|
|
<a name="l132"></a> </span><span class=cF2>if (bd->flags & BDF_EXT_SIZE)</span><span class=cF0>
|
|
<a name="l133"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_SEL, 0xEF | bd->unit << 4);</span><span class=cF0>
|
|
<a name="l134"></a> </span><span class=cF2>else</span><span class=cF0>
|
|
<a name="l135"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_SEL, 0xE0 | bd->unit << 4);</span><span class=cF0>
|
|
<a name="l136"></a>
|
|
<a name="l137"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_LCYL, bd->blk_size);</span><span class=cF0>
|
|
<a name="l138"></a> </span><span class=cF2>OutU8(bd->base0 + ATAR0_HCYL, bd->blk_size.u8[1]);</span><span class=cF0>
|
|
<a name="l139"></a> </span><span class=cF2>IDEATACmd(bd, ATA_PACKET);</span><span class=cF0>
|
|
<a name="l140"></a> </span><span class=cF2>IDEATAPIWritePacketWord(bd, 0, ATAPI_WRITE, native_blk.u16[1], native_blk, count.u16[1], count, 0);</span><span class=cF0>
|
|
<a name="l141"></a>
|
|
<a name="l142"></a> </span><span class=cF2>buf2 = buf + bd->blk_size * count;</span><span class=cF0>
|
|
<a name="l143"></a> </span><span class=cF2>while (buf < buf2)</span><span class=cF0>
|
|
<a name="l144"></a> </span><span class=cF2>{</span><span class=cF0>
|
|
<a name="l145"></a> </span><span class=cF2>IDEATAWaitDRQ(bd, 0);</span><span class=cF0>
|
|
<a name="l146"></a> </span><span class=cF2>U32s_avail = (InU8(bd->base0 + ATAR0_HCYL) << 8 + InU8(bd->base0 + ATAR0_LCYL)) >> 2;</span><span class=cF0>
|
|
<a name="l147"></a> </span><span class=cF2>if (buf + U32s_avail << 2 > buf2)</span><span class=cF0>
|
|
<a name="l148"></a> </span><span class=cF2>U32s_avail = (buf2-buf) >> 2;</span><span class=cF0>
|
|
<a name="l149"></a> </span><span class=cF2>if (U32s_avail)</span><span class=cF0>
|
|
<a name="l150"></a> </span><span class=cF2>{</span><span class=cF0>
|
|
<a name="l151"></a> </span><span class=cF2>RepOutU32(buf, U32s_avail, bd->base0 + ATAR0_DATA);</span><span class=cF0>
|
|
<a name="l152"></a> </span><span class=cF2>buf += U32s_avail << 2;</span><span class=cF0>
|
|
<a name="l153"></a> </span><span class=cF2>blkdev.write_count += U32s_avail >> (BLK_SIZE_BITS - 2);</span><span class=cF0>
|
|
<a name="l154"></a> </span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l155"></a> </span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l156"></a> </span><span class=cF2>IDEATAWaitNotBUSY(bd, 0);</span><span class=cF0>
|
|
<a name="l157"></a></span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l158"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
</span></pre></body>
|
|
</html>
|