mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2025-01-03 19:26:30 +00:00
72e706962a
Begin skeleton of E1000 networking driver.
131 lines
8.9 KiB
HTML
Executable file
131 lines
8.9 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.06">
|
|
<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=cF2>/*</span><span class=cF0> </span><span class=cF2>Intel(R) E1000 Driver</span><span class=cF0>
|
|
<a name="l2"></a> </span><span class=cF2>Author: TomAwezome</span><span class=cF0>
|
|
<a name="l3"></a>
|
|
<a name="l4"></a> </span><span class=cF2>Driver is based on:</span><span class=cF0>
|
|
<a name="l5"></a> </span><span class=cF2>-</span><span class=cF0> </span><span class=cF2>Linux E1000 implementation</span><span class=cF0>
|
|
<a name="l6"></a> </span><span class=cF2>-</span><span class=cF0> </span><span class=cF2>01000101's example E1000 driver</span><span class=cF0>
|
|
<a name="l7"></a> </span><span class=cF2>-</span><span class=cF0> </span><span class=cF2>OSDev Intel(R) E1000 documentation</span><span class=cF0>
|
|
<a name="l8"></a> </span><span class=cF2>-</span><span class=cF0> </span><span class=cF2>Intel(R) 8254x family datasheet</span><span class=cF0>
|
|
<a name="l9"></a> </span><span class=cF2>-</span><span class=cF0> </span><span class=cF2>any other useful sources.</span><span class=cF0>
|
|
<a name="l10"></a>
|
|
<a name="l11"></a> </span><span class=cF2>Guidelines:</span><span class=cF0>
|
|
<a name="l12"></a> </span><span class=cF2>-</span><span class=cF0> </span><span class=cF2>Magic numbers are bad. #defines are good.</span><span class=cF0>
|
|
<a name="l13"></a> </span><span class=cF2>-</span><span class=cF0> </span><span class=cF2>Understandability over LOC.</span><span class=cF0>
|
|
<a name="l14"></a> </span><span class=cF2>-</span><span class=cF0> </span><span class=cF2>Clear documentation.</span><span class=cF0>
|
|
<a name="l15"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l16"></a>
|
|
<a name="l17"></a></span><span class=cF2>// TODO: WIP</span><span class=cF0>
|
|
<a name="l18"></a>
|
|
<a name="l19"></a></span><span class=cF1>class</span><span class=cF0> CE1000
|
|
<a name="l20"></a>{
|
|
<a name="l21"></a> </span><span class=cF9>CPCIDev</span><span class=cF0> *pci;
|
|
<a name="l22"></a>
|
|
<a name="l23"></a> </span><span class=cF1>U8</span><span class=cF0> mac_address[</span><span class=cFE>6</span><span class=cF0>];
|
|
<a name="l24"></a>
|
|
<a name="l25"></a>} e1000; </span><span class=cF2>// e1000 is the global variable we store all of this into.</span><span class=cF0>
|
|
<a name="l26"></a>
|
|
<a name="l27"></a></span><span class=cF9>CPCIDev</span><span class=cF0> *E1000PCIDevFind()
|
|
<a name="l28"></a>{</span><span class=cF2>// Find and return E1000 card as a CPCIDev pointer.</span><span class=cF0>
|
|
<a name="l29"></a>
|
|
<a name="l30"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>PCIDevFind</span><span class=cF0>(,, PCIV_E1000, PCID_82545EM);
|
|
<a name="l31"></a>}
|
|
<a name="l32"></a>
|
|
<a name="l33"></a></span><span class=cF1>U0</span><span class=cF0> EthernetFrameFinish(</span><span class=cF9>I64</span><span class=cF0> de_index)
|
|
<a name="l34"></a>{</span><span class=cF2>//Alias for driver Finish TX function.</span><span class=cF0>
|
|
<a name="l35"></a> </span><span class=cF2>//E1000TransmitPacketFinish(de_index);</span><span class=cF0>
|
|
<a name="l36"></a> </span><span class=cF1>no_warn</span><span class=cF0> de_index;
|
|
<a name="l37"></a> NetErr(</span><span class=cF6>"TODO E1000"</span><span class=cF0>);
|
|
<a name="l38"></a>}
|
|
<a name="l39"></a>
|
|
<a name="l40"></a></span><span class=cF2>/*</span><span class=cF0>
|
|
<a name="l41"></a></span><span class=cF2>U0 PCIInterruptsReroute(I64 base)</span><span class=cF0>
|
|
<a name="l42"></a></span><span class=cF2>{ // todo: comments explaining process, maybe better var names</span><span class=cF0>
|
|
<a name="l43"></a> </span><span class=cF2>I64</span><span class=cF0> </span><span class=cF2> i;</span><span class=cF0>
|
|
<a name="l44"></a> </span><span class=cF2>U8</span><span class=cF0> </span><span class=cF2>*da = dev.uncached_alias + IOAPIC_REG;</span><span class=cF0>
|
|
<a name="l45"></a> </span><span class=cF2>U32 *_d = dev.uncached_alias + IOAPIC_DATA;</span><span class=cF0>
|
|
<a name="l46"></a>
|
|
<a name="l47"></a> </span><span class=cF2>for (i = 0; i < 4; i++)</span><span class=cF0>
|
|
<a name="l48"></a> </span><span class=cF2>{</span><span class=cF0>
|
|
<a name="l49"></a> </span><span class=cF2>*da = IOREDTAB + i * 2 + 1;</span><span class=cF0>
|
|
<a name="l50"></a> </span><span class=cF2>*_d = dev.mp_apic_ids[INT_DEST_CPU] << 24;</span><span class=cF0>
|
|
<a name="l51"></a> </span><span class=cF2>*da = IOREDTAB + i * 2;</span><span class=cF0>
|
|
<a name="l52"></a> </span><span class=cF2>*_d = 0x4000 + base + i;</span><span class=cF0>
|
|
<a name="l53"></a> </span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l54"></a></span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l55"></a>
|
|
<a name="l56"></a>
|
|
<a name="l57"></a></span><span class=cF2>U0 E1000InterruptsSetup()</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> </span><span class=cF2>PCIInterruptsReroute(I_E10000);</span><span class=cF0>
|
|
<a name="l60"></a> </span><span class=cF2>NetErr("TODO E1000");</span><span class=cF0>
|
|
<a name="l61"></a></span><span class=cF2>}</span><span class=cF0>
|
|
<a name="l62"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l63"></a>
|
|
<a name="l64"></a></span><span class=cF1>U0</span><span class=cF0> E1000Init()
|
|
<a name="l65"></a>{
|
|
<a name="l66"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&e1000, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>CE1000</span><span class=cF7>)</span><span class=cF0>); </span><span class=cF2>// e1000 global var will hold member data the driver uses often.</span><span class=cF0>
|
|
<a name="l67"></a>
|
|
<a name="l68"></a> e1000.pci = E1000PCIDevFind;
|
|
<a name="l69"></a> </span><span class=cF1>if</span><span class=cF0> (!e1000.pci)
|
|
<a name="l70"></a> </span><span class=cF1>return</span><span class=cF0>; </span><span class=cF2>// if we don't find the card, quit.</span><span class=cF0>
|
|
<a name="l71"></a>
|
|
<a name="l72"></a> </span><span class=cF6>"\nE1000 driver WIP\n\n"</span><span class=cF0>;
|
|
<a name="l73"></a> NetErr(</span><span class=cF6>"TODO E1000"</span><span class=cF0>);
|
|
<a name="l74"></a>}
|
|
<a name="l75"></a>
|
|
<a name="l76"></a></span><span class=cF9>I64</span><span class=cF0> EthernetFrameAllocate(</span><span class=cF1>U8</span><span class=cF0> **packet_buffer_out,
|
|
<a name="l77"></a> </span><span class=cF1>U8</span><span class=cF0> *source_address,
|
|
<a name="l78"></a> </span><span class=cF1>U8</span><span class=cF0> *destination_address,
|
|
<a name="l79"></a> </span><span class=cF9>U16</span><span class=cF0> ethertype,
|
|
<a name="l80"></a> </span><span class=cF9>I64</span><span class=cF0> packet_length)
|
|
<a name="l81"></a>{
|
|
<a name="l82"></a> </span><span class=cF1>no_warn</span><span class=cF0> packet_buffer_out, source_address, destination_address, ethertype, packet_length;
|
|
<a name="l83"></a> NetErr(</span><span class=cF6>"TODO E1000"</span><span class=cF0>);
|
|
<a name="l84"></a> </span><span class=cF1>return</span><span class=cF0> -</span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l85"></a>}
|
|
<a name="l86"></a>
|
|
<a name="l87"></a></span><span class=cF1>U8</span><span class=cF0> *EthernetMACGet()
|
|
<a name="l88"></a>{
|
|
<a name="l89"></a> NetErr(</span><span class=cF6>"TODO E1000"</span><span class=cF0>);
|
|
<a name="l90"></a> </span><span class=cF1>return</span><span class=cF0> e1000.mac_address;
|
|
<a name="l91"></a>}
|
|
<a name="l92"></a>
|
|
<a name="l93"></a></span><span class=cF1>U0</span><span class=cF0> NetStop()
|
|
<a name="l94"></a>{
|
|
<a name="l95"></a>
|
|
<a name="l96"></a>}
|
|
<a name="l97"></a>
|
|
<a name="l98"></a></span><span class=cF1>U0</span><span class=cF0> NetStart()
|
|
<a name="l99"></a>{
|
|
<a name="l100"></a>
|
|
<a name="l101"></a>}
|
|
<a name="l102"></a>
|
|
<a name="l103"></a>E1000Init;</span></pre></body>
|
|
</html>
|