mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-26 15:26:43 +00:00
157 lines
15 KiB
HTML
Executable file
157 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 V1.07">
|
|
<style type="text/css">
|
|
body {background-color:#1f1f1f;}
|
|
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
|
|
.cF1{color:#4f84a6;background-color:#1f1f1f;}
|
|
.cF2{color:#73a255;background-color:#1f1f1f;}
|
|
.cF3{color:#297582;background-color:#1f1f1f;}
|
|
.cF4{color:#b34f4b;background-color:#1f1f1f;}
|
|
.cF5{color:#8a52c3;background-color:#1f1f1f;}
|
|
.cF6{color:#b7822f;background-color:#1f1f1f;}
|
|
.cF7{color:#444444;background-color:#1f1f1f;}
|
|
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
|
|
.cF9{color:#94bfde;background-color:#1f1f1f;}
|
|
.cFA{color:#a1ce97;background-color:#1f1f1f;}
|
|
.cFB{color:#6db4be;background-color:#1f1f1f;}
|
|
.cFC{color:#e88e88;background-color:#1f1f1f;}
|
|
.cFD{color:#ca94e8;background-color:#1f1f1f;}
|
|
.cFE{color:#d4b475;background-color:#1f1f1f;}
|
|
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF0>
|
|
<a name="l2"></a></span><span class=cF9>U32</span><span class=cF0> </span><span class=cF5>PCIReadU32</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> bus, </span><span class=cF9>I64</span><span class=cF0> </span><span class=cFB>dev</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> fun, </span><span class=cF9>I64</span><span class=cF0> rg)
|
|
<a name="l3"></a>{</span><span class=cF2>//Read U32 in PCI configspace at bus, dev, fun, reg.</span><span class=cF0>
|
|
<a name="l4"></a> </span><span class=cF9>I64</span><span class=cF0> res, addr, </span><span class=cF1>offset</span><span class=cF0>;
|
|
<a name="l5"></a>
|
|
<a name="l6"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>sys_pci_services</span><span class=cF0>)
|
|
<a name="l7"></a> res = </span><span class=cFD>PCIBIOSReadU32</span><span class=cF0>(bus, </span><span class=cFB>dev</span><span class=cF0>, fun, rg);
|
|
<a name="l8"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l9"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l10"></a> addr = bus << </span><span class=cFE>16</span><span class=cF0> |
|
|
<a name="l11"></a> </span><span class=cFB>dev</span><span class=cF0> << </span><span class=cFE>11</span><span class=cF0> |
|
|
<a name="l12"></a> fun << </span><span class=cFE>8</span><span class=cF0> |
|
|
<a name="l13"></a> rg & </span><span class=cFE>0xFC</span><span class=cF0> |
|
|
<a name="l14"></a> </span><span class=cFE>0x80000000</span><span class=cF0>;
|
|
<a name="l15"></a>
|
|
<a name="l16"></a> </span><span class=cF1>offset</span><span class=cF0> = rg - rg & </span><span class=cFE>0xFC</span><span class=cF0>;
|
|
<a name="l17"></a> </span><span class=cF5>OutU32</span><span class=cF0>(</span><span class=cF3>PCI_ADDR</span><span class=cF0>, addr);
|
|
<a name="l18"></a> res = </span><span class=cF5>InU32</span><span class=cF0>(</span><span class=cF3>PCI_DATA</span><span class=cF0>) >> (</span><span class=cF1>offset</span><span class=cF0> * </span><span class=cFE>8</span><span class=cF0>);
|
|
<a name="l19"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l20"></a>
|
|
<a name="l21"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l22"></a>}
|
|
<a name="l23"></a>
|
|
<a name="l24"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cF5>PCIReadU8</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> bus, </span><span class=cF9>I64</span><span class=cF0> </span><span class=cFB>dev</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> fun, </span><span class=cF9>I64</span><span class=cF0> rg)
|
|
<a name="l25"></a>{</span><span class=cF2>//Read U8 in PCI configspace at bus, dev, fun, reg.</span><span class=cF0>
|
|
<a name="l26"></a> </span><span class=cF9>I64</span><span class=cF0> res;
|
|
<a name="l27"></a>
|
|
<a name="l28"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>sys_pci_services</span><span class=cF0>)
|
|
<a name="l29"></a> res = </span><span class=cFD>PCIBIOSReadU8</span><span class=cF0>(bus, </span><span class=cFB>dev</span><span class=cF0>, fun, rg);
|
|
<a name="l30"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l31"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l32"></a> res = </span><span class=cF5>PCIReadU32</span><span class=cF0>(bus, </span><span class=cFB>dev</span><span class=cF0>, fun, rg) & </span><span class=cFE>0xFF</span><span class=cF0>;
|
|
<a name="l33"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l34"></a>
|
|
<a name="l35"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l36"></a>}
|
|
<a name="l37"></a>
|
|
<a name="l38"></a></span><span class=cF9>U16</span><span class=cF0> </span><span class=cF5>PCIReadU16</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> bus, </span><span class=cF9>I64</span><span class=cF0> </span><span class=cFB>dev</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> fun, </span><span class=cF9>I64</span><span class=cF0> rg)
|
|
<a name="l39"></a>{</span><span class=cF2>//Read U16 in PCI configspace at bus, dev, fun, reg.</span><span class=cF0>
|
|
<a name="l40"></a> </span><span class=cF9>I64</span><span class=cF0> res;
|
|
<a name="l41"></a>
|
|
<a name="l42"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>sys_pci_services</span><span class=cF0>)
|
|
<a name="l43"></a> res = </span><span class=cFD>PCIBIOSReadU16</span><span class=cF0>(bus, </span><span class=cFB>dev</span><span class=cF0>, fun, rg);
|
|
<a name="l44"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l45"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l46"></a> res = </span><span class=cF5>PCIReadU32</span><span class=cF0>(bus, </span><span class=cFB>dev</span><span class=cF0>, fun, rg) & </span><span class=cFE>0xFFFF</span><span class=cF0>;
|
|
<a name="l47"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l48"></a>
|
|
<a name="l49"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l50"></a>}
|
|
<a name="l51"></a>
|
|
<a name="l52"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>PCIWriteU32</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> bus, </span><span class=cF9>I64</span><span class=cF0> </span><span class=cFB>dev</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> fun, </span><span class=cF9>I64</span><span class=cF0> rg, </span><span class=cF9>I64</span><span class=cF0> val)
|
|
<a name="l53"></a>{</span><span class=cF2>//Write U32 in PCI configspace at bus, dev, fun, reg.</span><span class=cF0>
|
|
<a name="l54"></a> </span><span class=cF9>I64</span><span class=cF0> addr, </span><span class=cF1>offset</span><span class=cF0>;
|
|
<a name="l55"></a>
|
|
<a name="l56"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>sys_pci_services</span><span class=cF0>)
|
|
<a name="l57"></a> </span><span class=cFD>PCIBIOSWriteU32</span><span class=cF0>(bus, </span><span class=cFB>dev</span><span class=cF0>, fun, rg, val);
|
|
<a name="l58"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l59"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l60"></a> addr = bus << </span><span class=cFE>16</span><span class=cF0> |
|
|
<a name="l61"></a> </span><span class=cFB>dev</span><span class=cF0> << </span><span class=cFE>11</span><span class=cF0> |
|
|
<a name="l62"></a> fun << </span><span class=cFE>8</span><span class=cF0> |
|
|
<a name="l63"></a> rg & </span><span class=cFE>0xFC</span><span class=cF0> |
|
|
<a name="l64"></a> </span><span class=cFE>0x80000000</span><span class=cF0>;
|
|
<a name="l65"></a>
|
|
<a name="l66"></a> </span><span class=cF1>offset</span><span class=cF0> = rg - rg & </span><span class=cFE>0xFC</span><span class=cF0>;
|
|
<a name="l67"></a> </span><span class=cF5>OutU32</span><span class=cF0>(</span><span class=cF3>PCI_ADDR</span><span class=cF0>, addr);
|
|
<a name="l68"></a> </span><span class=cF5>OutU32</span><span class=cF0>(</span><span class=cF3>PCI_DATA</span><span class=cF0>, val << </span><span class=cF7>(</span><span class=cF1>offset</span><span class=cF0> * </span><span class=cFE>8</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l69"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l70"></a>}
|
|
<a name="l71"></a>
|
|
<a name="l72"></a>
|
|
<a name="l73"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>PCIWriteU8</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> bus, </span><span class=cF9>I64</span><span class=cF0> </span><span class=cFB>dev</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> fun, </span><span class=cF9>I64</span><span class=cF0> rg, </span><span class=cF9>I64</span><span class=cF0> val)
|
|
<a name="l74"></a>{</span><span class=cF2>//Write U8 in PCI configspace at bus, dev, fun, reg.</span><span class=cF0>
|
|
<a name="l75"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>sys_pci_services</span><span class=cF0>)
|
|
<a name="l76"></a> </span><span class=cFD>PCIBIOSWriteU8</span><span class=cF0>(bus, </span><span class=cFB>dev</span><span class=cF0>, fun, rg, val);
|
|
<a name="l77"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l78"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l79"></a> </span><span class=cF5>PCIWriteU32</span><span class=cF0>(bus, </span><span class=cFB>dev</span><span class=cF0>, fun, rg, val & </span><span class=cFE>0xFF</span><span class=cF0>);
|
|
<a name="l80"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l81"></a>}
|
|
<a name="l82"></a>
|
|
<a name="l83"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>PCIWriteU16</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> bus, </span><span class=cF9>I64</span><span class=cF0> </span><span class=cFB>dev</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> fun, </span><span class=cF9>I64</span><span class=cF0> rg, </span><span class=cF9>I64</span><span class=cF0> val)
|
|
<a name="l84"></a>{</span><span class=cF2>//Write U16 in PCI configspace at bus, dev, fun, reg.</span><span class=cF0>
|
|
<a name="l85"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>sys_pci_services</span><span class=cF0>)
|
|
<a name="l86"></a> </span><span class=cFD>PCIBIOSWriteU16</span><span class=cF0>(bus, </span><span class=cFB>dev</span><span class=cF0>, fun, rg, val);
|
|
<a name="l87"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l88"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l89"></a> </span><span class=cF5>PCIWriteU32</span><span class=cF0>(bus, </span><span class=cFB>dev</span><span class=cF0>, fun, rg, val & </span><span class=cFE>0xFFFF</span><span class=cF0>);
|
|
<a name="l90"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l91"></a>}
|
|
<a name="l92"></a>
|
|
<a name="l93"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>PCIClassFind</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> class_code, </span><span class=cF9>I64</span><span class=cF0> n)
|
|
<a name="l94"></a>{</span><span class=cF2>/*Find bus, dev, fun of Nth class_code dev.</span><span class=cF0>
|
|
<a name="l95"></a>
|
|
<a name="l96"></a></span><span class=cF2>class_code is low three bytes</span><span class=cF0>
|
|
<a name="l97"></a></span><span class=cF2>n is index starting at zero</span><span class=cF0>
|
|
<a name="l98"></a></span><span class=cF2>Return: -1 not found</span><span class=cF0>
|
|
<a name="l99"></a></span><span class=cF2>else bus, dev, fun.</span><span class=cF0>
|
|
<a name="l100"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l101"></a> </span><span class=cF9>I64</span><span class=cF0> res = -</span><span class=cFE>1</span><span class=cF0>, cur = </span><span class=cFE>0</span><span class=cF0>, b, d, f;
|
|
<a name="l102"></a>
|
|
<a name="l103"></a>
|
|
<a name="l104"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>sys_pci_services</span><span class=cF0>)
|
|
<a name="l105"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l106"></a> </span><span class=cF6>"(System has PCIBIOS)\n"</span><span class=cF0>;
|
|
<a name="l107"></a> res = </span><span class=cFD>PCIBIOSClassFind</span><span class=cF0>(class_code, n);
|
|
<a name="l108"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l109"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l110"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l111"></a> </span><span class=cF6>"(System does not have PCIBIOS)\n"</span><span class=cF0>;
|
|
<a name="l112"></a> </span><span class=cF1>for</span><span class=cF0> (b = </span><span class=cFE>0</span><span class=cF0>; b < </span><span class=cFB>sys_pci_buses</span><span class=cF0>; b++)
|
|
<a name="l113"></a> </span><span class=cF1>for</span><span class=cF0> (d = </span><span class=cFE>0</span><span class=cF0>; d < </span><span class=cFE>32</span><span class=cF0>; d++)
|
|
<a name="l114"></a> </span><span class=cF1>for</span><span class=cF0> (f = </span><span class=cFE>0</span><span class=cF0>; f < </span><span class=cFE>8</span><span class=cF0>; f++)
|
|
<a name="l115"></a> {
|
|
<a name="l116"></a> </span><span class=cF1>if</span><span class=cF0> (class_code == </span><span class=cF5>PCIReadU32</span><span class=cF7>(</span><span class=cF0>b, d, f, </span><span class=cF3>PCIR_PROG_IF</span><span class=cF7>)</span><span class=cF0> & </span><span class=cFE>0xFFFFFF</span><span class=cF0>)
|
|
<a name="l117"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l118"></a> </span><span class=cF1>if</span><span class=cF0> (n == cur++)
|
|
<a name="l119"></a> {
|
|
<a name="l120"></a> res = b << </span><span class=cFE>16</span><span class=cF0> | d << </span><span class=cFE>8</span><span class=cF0> | f;
|
|
<a name="l121"></a> </span><span class=cF1>goto</span><span class=cF0> pci_end;
|
|
<a name="l122"></a> }
|
|
<a name="l123"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l124"></a> }
|
|
<a name="l125"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l126"></a>pci_end:
|
|
<a name="l127"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l128"></a>}
|
|
</span></pre></body>
|
|
</html>
|