ZealOS/docs/Kernel/PCIBIOS.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

327 lines
44 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=cF1>asm</span><span class=cF0> {
<a name="l2"></a></span><span class=cF1>USE32</span><span class=cF0>
<a name="l3"></a>
<a name="l4"></a></span><span class=cFD>SYS_PCIBIOS_SERVICE_DIR</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l5"></a></span><span class=cFD>SYS_PCI_SERVICES</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l6"></a>
<a name="l7"></a></span><span class=cFD>SYS_FIND_PCIBIOS_SERVICE_DIR</span><span class=cF0>::
<a name="l8"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ESI</span><span class=cF0>, </span><span class=cFE>0xE0000</span><span class=cF0>
<a name="l9"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, (</span><span class=cFE>0x100000</span><span class=cF0> - </span><span class=cFE>0xE0000</span><span class=cF0>) / </span><span class=cFE>4</span><span class=cF0>
<a name="l10"></a>@@05: </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>ESI</span><span class=cF0>], </span><span class=cF6>'_32_'</span><span class=cF0>
<a name="l11"></a> </span><span class=cF1>JNE</span><span class=cF0> @@20
<a name="l12"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>
<a name="l13"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, </span><span class=cFC>ECX</span><span class=cF0>
<a name="l14"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>CL</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> </span><span class=cFE>9</span><span class=cF0>[</span><span class=cFC>ESI</span><span class=cF0>]
<a name="l15"></a> </span><span class=cF1>SHL</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>
<a name="l16"></a>@@10: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cFC>ESI</span><span class=cF0>
<a name="l17"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFC>EAX</span><span class=cF0>
<a name="l18"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFC>EDX</span><span class=cF0>
<a name="l19"></a>@@15: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>DL</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> [</span><span class=cFC>EDI</span><span class=cF0>]
<a name="l20"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFC>EDX</span><span class=cF0>
<a name="l21"></a> </span><span class=cF1>INC</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>
<a name="l22"></a> </span><span class=cF1>DEC</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>
<a name="l23"></a> </span><span class=cF1>JNZ</span><span class=cF0> @@15
<a name="l24"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>
<a name="l25"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cFC>AL</span><span class=cF0>, </span><span class=cFC>AL</span><span class=cF0>
<a name="l26"></a> </span><span class=cF1>JNZ</span><span class=cF0> @@20
<a name="l27"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_PCIBIOS_SERVICE_DIR</span><span class=cF0>], </span><span class=cFC>ESI</span><span class=cF0>
<a name="l28"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ESI</span><span class=cF0>, </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFE>4</span><span class=cF0>[</span><span class=cFC>ESI</span><span class=cF0>]
<a name="l29"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_PCIBIOS_SERVICE_CALL</span><span class=cF0>], </span><span class=cFC>ESI</span><span class=cF0>
<a name="l30"></a> </span><span class=cF1>RET</span><span class=cF0>
<a name="l31"></a>
<a name="l32"></a>@@20: </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>ESI</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>
<a name="l33"></a> </span><span class=cF1>LOOP</span><span class=cF0> @@05
<a name="l34"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_PCIBIOS_SERVICE_DIR</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>
<a name="l35"></a> </span><span class=cF1>RET</span><span class=cF0>
<a name="l36"></a>
<a name="l37"></a></span><span class=cFD>SYS_FIND_PCI_SERVICES</span><span class=cF0>::
<a name="l38"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ESI</span><span class=cF0>, </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_PCIBIOS_SERVICE_DIR</span><span class=cF0>]
<a name="l39"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cFC>ESI</span><span class=cF0>, </span><span class=cFC>ESI</span><span class=cF0>
<a name="l40"></a> </span><span class=cF1>JNZ</span><span class=cF0> @@05
<a name="l41"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_PCI_SERVICES</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>
<a name="l42"></a> </span><span class=cF1>RET</span><span class=cF0>
<a name="l43"></a>@@05: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cF6>'$PCI'</span><span class=cF0>
<a name="l44"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>EBX</span><span class=cF0>, </span><span class=cFC>EBX</span><span class=cF0>
<a name="l45"></a> </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cFE>0x9A</span><span class=cF0>; </span><span class=cF2>//CALL CGDT.cs32:PCIBIOS_SERVICE</span><span class=cF0>
<a name="l46"></a></span><span class=cFD>SYS_PCIBIOS_SERVICE_CALL</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l47"></a> </span><span class=cF1>DU16</span><span class=cF0> </span><span class=cF9>CGDT</span><span class=cF0>.cs32;
<a name="l48"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cFC>AL</span><span class=cF0>, </span><span class=cFC>AL</span><span class=cF0>
<a name="l49"></a> </span><span class=cF1>JNZ</span><span class=cF0> @@05
<a name="l50"></a> </span><span class=cF1>LEA</span><span class=cF0> </span><span class=cFC>ESI</span><span class=cF0>, </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>EBX</span><span class=cF0> + </span><span class=cFC>EDX</span><span class=cF0>]
<a name="l51"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_PCI_SERVICES</span><span class=cF0>], </span><span class=cFC>ESI</span><span class=cF0>
<a name="l52"></a> </span><span class=cF1>RET</span><span class=cF0>
<a name="l53"></a>
<a name="l54"></a>@@05: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_PCI_SERVICES</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>
<a name="l55"></a> </span><span class=cF1>RET</span><span class=cF0>
<a name="l56"></a>
<a name="l57"></a></span><span class=cF1>USE64</span><span class=cF0>
<a name="l58"></a></span><span class=cFD>C32_EAX</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l59"></a></span><span class=cFD>C32_EBX</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l60"></a></span><span class=cFD>C32_ECX</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l61"></a></span><span class=cFD>C32_EDX</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l62"></a></span><span class=cFD>C32_ESI</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l63"></a></span><span class=cFD>C32_EDI</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l64"></a></span><span class=cFD>C32_EFLAGS</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l65"></a>
<a name="l66"></a></span><span class=cFD>C32_RSP</span><span class=cF0>:: </span><span class=cF1>DU64</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l67"></a>
<a name="l68"></a></span><span class=cFD>_FAR_CALL32</span><span class=cF0>::
<a name="l69"></a></span><span class=cF2>//This calls a 32-bit mode routine.</span><span class=cF0>
<a name="l70"></a></span><span class=cF2>//(We must switch from 64-bit mode to do it.)</span><span class=cF0>
<a name="l71"></a></span><span class=cF2>//</span><span class=cF0>
<a name="l72"></a></span><span class=cF2>//NON REENTRANT</span><span class=cF0>
<a name="l73"></a></span><span class=cF2>//</span><span class=cF0>
<a name="l74"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>RBP</span><span class=cF0>
<a name="l75"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RBP</span><span class=cF0>, </span><span class=cFC>RSP</span><span class=cF0>
<a name="l76"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> </span><span class=cF3>SF_ARG1</span><span class=cF0>[</span><span class=cFC>RBP</span><span class=cF0>]
<a name="l77"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RAX</span><span class=cF0>
<a name="l78"></a> </span><span class=cF1>JNZ</span><span class=cF0> @@05
<a name="l79"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RBP</span><span class=cF0>
<a name="l80"></a> </span><span class=cF1>RET1</span><span class=cF0> </span><span class=cFE>8</span><span class=cF0> </span><span class=cF2>//return FALSE</span><span class=cF0>
<a name="l81"></a>@@05: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_ADD</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
<a name="l82"></a> </span><span class=cF3>PUSH_REGS</span><span class=cF0>
<a name="l83"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l84"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RAX</span><span class=cF0>
<a name="l85"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cFC>FS</span><span class=cF0>:</span><span class=cF9>CTask</span><span class=cF0>.addr[</span><span class=cFC>RAX</span><span class=cF0>]
<a name="l86"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> </span><span class=cFC>GS</span><span class=cF0>:</span><span class=cF9>CCPU</span><span class=cF0>.addr[</span><span class=cFC>RAX</span><span class=cF0>]
<a name="l87"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U64</span><span class=cF0> [</span><span class=cFD>C32_RSP</span><span class=cF0>], </span><span class=cFC>RSP</span><span class=cF0>
<a name="l88"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cF9>CGDT</span><span class=cF0>.ds </span><span class=cF2>//STACKSEG</span><span class=cF0>
<a name="l89"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cF3>BOOT_RAM_LIMIT</span><span class=cF0> </span><span class=cF2>//STACK</span><span class=cF0>
<a name="l90"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0> </span><span class=cF2>//FLAGS--interrupts off</span><span class=cF0>
<a name="l91"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cF9>CGDT</span><span class=cF0>.cs32
<a name="l92"></a> </span><span class=cF1>LEA</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, [@@15]
<a name="l93"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>
<a name="l94"></a> </span><span class=cF1>IRET</span><span class=cF0>
<a name="l95"></a></span><span class=cF1>USE32</span><span class=cF0>
<a name="l96"></a>@@15:
<a name="l97"></a> </span><span class=cF1>WBINVD</span><span class=cF0>
<a name="l98"></a></span><span class=cF2>//disable paging</span><span class=cF0>
<a name="l99"></a> </span><span class=cF1>MOV_EAX_CR0</span><span class=cF0>
<a name="l100"></a> </span><span class=cF1>BTR</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cF3>CR0f_PG</span><span class=cF0>
<a name="l101"></a> </span><span class=cF1>MOV_CR0_EAX</span><span class=cF0>
<a name="l102"></a>
<a name="l103"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, </span><span class=cF3>IA32_EFER</span><span class=cF0>
<a name="l104"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFC>EDX</span><span class=cF0>
<a name="l105"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFC>EAX</span><span class=cF0>
<a name="l106"></a> </span><span class=cF1>WRMSR</span><span class=cF0>
<a name="l107"></a>
<a name="l108"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cF9>CGDT</span><span class=cF0>.ds
<a name="l109"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>FS</span><span class=cF0>, </span><span class=cFC>AX</span><span class=cF0>
<a name="l110"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>GS</span><span class=cF0>, </span><span class=cFC>AX</span><span class=cF0>
<a name="l111"></a></span><span class=cF2>//SS already set</span><span class=cF0>
<a name="l112"></a>
<a name="l113"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_EAX</span><span class=cF0>]
<a name="l114"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EBX</span><span class=cF0>, </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_EBX</span><span class=cF0>]
<a name="l115"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_ECX</span><span class=cF0>]
<a name="l116"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_EDX</span><span class=cF0>]
<a name="l117"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ESI</span><span class=cF0>, </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_ESI</span><span class=cF0>]
<a name="l118"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_EDI</span><span class=cF0>]
<a name="l119"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_EFLAGS</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>
<a name="l120"></a>
<a name="l121"></a> </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cFE>0x9A</span><span class=cF0>; </span><span class=cF2>//CALL CGDT.cs32:[C32_ADD]</span><span class=cF0>
<a name="l122"></a></span><span class=cFD>C32_ADD</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l123"></a> </span><span class=cF1>DU16</span><span class=cF0> </span><span class=cF9>CGDT</span><span class=cF0>.cs32;
<a name="l124"></a>
<a name="l125"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l126"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_EFLAGS</span><span class=cF0>]
<a name="l127"></a>
<a name="l128"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_EAX</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
<a name="l129"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_EBX</span><span class=cF0>], </span><span class=cFC>EBX</span><span class=cF0>
<a name="l130"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_ECX</span><span class=cF0>], </span><span class=cFC>ECX</span><span class=cF0>
<a name="l131"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_EDX</span><span class=cF0>], </span><span class=cFC>EDX</span><span class=cF0>
<a name="l132"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_ESI</span><span class=cF0>], </span><span class=cFC>ESI</span><span class=cF0>
<a name="l133"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>C32_EDI</span><span class=cF0>], </span><span class=cFC>EDI</span><span class=cF0>
<a name="l134"></a>
<a name="l135"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0> </span><span class=cF2>//Return from next call will be 64-bit</span><span class=cF0>
<a name="l136"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cFD>SYS_ENTER_LONG_MODE</span><span class=cF0>
<a name="l137"></a>
<a name="l138"></a></span><span class=cF1>USE64</span><span class=cF0> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>RSP</span><span class=cF0>, </span><span class=cF9>U64</span><span class=cF0> [</span><span class=cFD>C32_RSP</span><span class=cF0>]
<a name="l139"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>
<a name="l140"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cFD>SET_GS_BASE</span><span class=cF0>
<a name="l141"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>
<a name="l142"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cFD>SET_FS_BASE</span><span class=cF0>
<a name="l143"></a>
<a name="l144"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l145"></a> </span><span class=cF3>POP_REGS</span><span class=cF0>
<a name="l146"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>RAX</span><span class=cF0>, </span><span class=cFC>RAX</span><span class=cF0>
<a name="l147"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AL</span><span class=cF0>, </span><span class=cF3>TRUE</span><span class=cF0>
<a name="l148"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>RBP</span><span class=cF0>
<a name="l149"></a> </span><span class=cF1>RET1</span><span class=cF0> </span><span class=cFE>8</span><span class=cF0>
<a name="l150"></a>}
<a name="l151"></a>
<a name="l152"></a></span><span class=cF1>_extern</span><span class=cF0> </span><span class=cFD>C32_EAX</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFB>c32_eax</span><span class=cF0>;
<a name="l153"></a></span><span class=cF1>_extern</span><span class=cF0> </span><span class=cFD>C32_EBX</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFB>c32_ebx</span><span class=cF0>;
<a name="l154"></a></span><span class=cF1>_extern</span><span class=cF0> </span><span class=cFD>C32_ECX</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFB>c32_ecx</span><span class=cF0>;
<a name="l155"></a></span><span class=cF1>_extern</span><span class=cF0> </span><span class=cFD>C32_EDX</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFB>c32_edx</span><span class=cF0>;
<a name="l156"></a></span><span class=cF1>_extern</span><span class=cF0> </span><span class=cFD>C32_ESI</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFB>c32_esi</span><span class=cF0>;
<a name="l157"></a></span><span class=cF1>_extern</span><span class=cF0> </span><span class=cFD>C32_EDI</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFB>c32_edi</span><span class=cF0>;
<a name="l158"></a></span><span class=cF1>_extern</span><span class=cF0> </span><span class=cFD>C32_EFLAGS</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFB>c32_eflags</span><span class=cF0>;
<a name="l159"></a>
<a name="l160"></a></span><span class=cF1>_extern</span><span class=cF0> </span><span class=cFD>SYS_PCI_SERVICES</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cFB>sys_pci_services</span><span class=cF0>;
<a name="l161"></a>
<a name="l162"></a></span><span class=cF1>_extern</span><span class=cF0> </span><span class=cFD>_FAR_CALL32</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>FarCall32</span><span class=cF0>(</span><span class=cF1>U0</span><span class=cF0> </span><span class=cF7>(</span><span class=cF0>*fp_addr</span><span class=cF7>)()</span><span class=cF0>);</span><span class=cF2>//Not reentrant.For PCIBIOS.</span><span class=cF0>
<a name="l163"></a>
<a name="l164"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cFD>PCIBIOSReadU8</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="l165"></a>{</span><span class=cF2>//Read U8 in PCI configspace at bus, dev, fun, reg.</span><span class=cF0>
<a name="l166"></a> </span><span class=cF9>I64</span><span class=cF0> res;
<a name="l167"></a>
<a name="l168"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l169"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l170"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l171"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l172"></a> </span><span class=cFB>c32_eax</span><span class=cF0> = </span><span class=cFE>0xB108</span><span class=cF0>;
<a name="l173"></a> </span><span class=cFB>c32_ebx</span><span class=cF0> = bus &lt;&lt; </span><span class=cFE>8</span><span class=cF0> + </span><span class=cFB>dev</span><span class=cF0> &lt;&lt; </span><span class=cFE>3</span><span class=cF0> + fun;
<a name="l174"></a> </span><span class=cFB>c32_edi</span><span class=cF0> = rg;
<a name="l175"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>FarCall32</span><span class=cF7>(</span><span class=cFB>sys_pci_services</span><span class=cF7>)</span><span class=cF0>)
<a name="l176"></a> res = </span><span class=cFB>c32_ecx</span><span class=cF0>.u8[</span><span class=cFE>0</span><span class=cF0>];
<a name="l177"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l178"></a> res = </span><span class=cFE>0xFF</span><span class=cF0>;
<a name="l179"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l180"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l181"></a>
<a name="l182"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l183"></a>}
<a name="l184"></a>
<a name="l185"></a></span><span class=cF9>U16</span><span class=cF0> </span><span class=cFD>PCIBIOSReadU16</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="l186"></a>{</span><span class=cF2>//Read U16 in PCI configspace at bus, dev, fun, reg.</span><span class=cF0>
<a name="l187"></a> </span><span class=cF9>I64</span><span class=cF0> res;
<a name="l188"></a>
<a name="l189"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l190"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l191"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l192"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l193"></a> </span><span class=cFB>c32_eax</span><span class=cF0> = </span><span class=cFE>0xB109</span><span class=cF0>;
<a name="l194"></a> </span><span class=cFB>c32_ebx</span><span class=cF0> = bus &lt;&lt; </span><span class=cFE>8</span><span class=cF0> + </span><span class=cFB>dev</span><span class=cF0> &lt;&lt; </span><span class=cFE>3</span><span class=cF0> + fun;
<a name="l195"></a> </span><span class=cFB>c32_edi</span><span class=cF0> = rg;
<a name="l196"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>FarCall32</span><span class=cF7>(</span><span class=cFB>sys_pci_services</span><span class=cF7>)</span><span class=cF0>)
<a name="l197"></a> res = </span><span class=cFB>c32_ecx</span><span class=cF0>.u16[</span><span class=cFE>0</span><span class=cF0>];
<a name="l198"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l199"></a> res = </span><span class=cFE>0xFFFF</span><span class=cF0>;
<a name="l200"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l201"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l202"></a>
<a name="l203"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l204"></a>}
<a name="l205"></a>
<a name="l206"></a></span><span class=cF9>U32</span><span class=cF0> </span><span class=cFD>PCIBIOSReadU32</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="l207"></a>{</span><span class=cF2>//Read U32 in PCI configspace at bus, dev, fun, reg.</span><span class=cF0>
<a name="l208"></a> </span><span class=cF9>I64</span><span class=cF0> res;
<a name="l209"></a>
<a name="l210"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l211"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l212"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l213"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l214"></a> </span><span class=cFB>c32_eax</span><span class=cF0> = </span><span class=cFE>0xB10A</span><span class=cF0>;
<a name="l215"></a> </span><span class=cFB>c32_ebx</span><span class=cF0> = bus &lt;&lt; </span><span class=cFE>8</span><span class=cF0> + </span><span class=cFB>dev</span><span class=cF0> &lt;&lt; </span><span class=cFE>3</span><span class=cF0> + fun;
<a name="l216"></a> </span><span class=cFB>c32_edi</span><span class=cF0> = rg;
<a name="l217"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>FarCall32</span><span class=cF7>(</span><span class=cFB>sys_pci_services</span><span class=cF7>)</span><span class=cF0>)
<a name="l218"></a> res = </span><span class=cFB>c32_ecx</span><span class=cF0>;
<a name="l219"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l220"></a> res = </span><span class=cFE>0xFFFFFFFF</span><span class=cF0>;
<a name="l221"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l222"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l223"></a>
<a name="l224"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l225"></a>}
<a name="l226"></a>
<a name="l227"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>PCIBIOSWriteU8</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="l228"></a>{</span><span class=cF2>//Write U8 in PCI configspace at bus, dev, fun, reg.</span><span class=cF0>
<a name="l229"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l230"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l231"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l232"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l233"></a> </span><span class=cFB>c32_eax</span><span class=cF0> = </span><span class=cFE>0xB10B</span><span class=cF0>;
<a name="l234"></a> </span><span class=cFB>c32_ebx</span><span class=cF0> = bus &lt;&lt; </span><span class=cFE>8</span><span class=cF0> + </span><span class=cFB>dev</span><span class=cF0> &lt;&lt; </span><span class=cFE>3</span><span class=cF0> + fun;
<a name="l235"></a> </span><span class=cFB>c32_edi</span><span class=cF0> = rg;
<a name="l236"></a> </span><span class=cFB>c32_ecx</span><span class=cF0> = val;
<a name="l237"></a> </span><span class=cF5>FarCall32</span><span class=cF0>(</span><span class=cFB>sys_pci_services</span><span class=cF0>);
<a name="l238"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l239"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l240"></a>}
<a name="l241"></a>
<a name="l242"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>PCIBIOSWriteU16</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="l243"></a>{</span><span class=cF2>//Write U16 in PCI configspace at bus, dev, fun, reg.</span><span class=cF0>
<a name="l244"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l245"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l246"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l247"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l248"></a> </span><span class=cFB>c32_eax</span><span class=cF0> = </span><span class=cFE>0xB10C</span><span class=cF0>;
<a name="l249"></a> </span><span class=cFB>c32_ebx</span><span class=cF0> = bus &lt;&lt; </span><span class=cFE>8</span><span class=cF0> + </span><span class=cFB>dev</span><span class=cF0> &lt;&lt; </span><span class=cFE>3</span><span class=cF0> + fun;
<a name="l250"></a> </span><span class=cFB>c32_edi</span><span class=cF0> = rg;
<a name="l251"></a> </span><span class=cFB>c32_ecx</span><span class=cF0> = val;
<a name="l252"></a> </span><span class=cF5>FarCall32</span><span class=cF0>(</span><span class=cFB>sys_pci_services</span><span class=cF0>);
<a name="l253"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l254"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l255"></a>}
<a name="l256"></a>
<a name="l257"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>PCIBIOSWriteU32</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="l258"></a>{</span><span class=cF2>//Write U32 in PCI configspace at bus, dev, fun, reg.</span><span class=cF0>
<a name="l259"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l260"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l261"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l262"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l263"></a> </span><span class=cFB>c32_eax</span><span class=cF0> = </span><span class=cFE>0xB10D</span><span class=cF0>;
<a name="l264"></a> </span><span class=cFB>c32_ebx</span><span class=cF0> = bus &lt;&lt; </span><span class=cFE>8</span><span class=cF0> + </span><span class=cFB>dev</span><span class=cF0> &lt;&lt; </span><span class=cFE>3</span><span class=cF0> + fun;
<a name="l265"></a> </span><span class=cFB>c32_edi</span><span class=cF0> = rg;
<a name="l266"></a> </span><span class=cFB>c32_ecx</span><span class=cF0> = val;
<a name="l267"></a> </span><span class=cF5>FarCall32</span><span class=cF0>(</span><span class=cFB>sys_pci_services</span><span class=cF0>);
<a name="l268"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l269"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l270"></a>}
<a name="l271"></a>
<a name="l272"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>PCIBIOSClassFind</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="l273"></a>{</span><span class=cF2>/*Find bus, dev, fun of Nth class_code dev.</span><span class=cF0>
<a name="l274"></a>
<a name="l275"></a></span><span class=cF2>class_code is low three bytes</span><span class=cF0>
<a name="l276"></a></span><span class=cF2>n is index starting at zero</span><span class=cF0>
<a name="l277"></a></span><span class=cF2>Return: -1 not found</span><span class=cF0>
<a name="l278"></a></span><span class=cF2>else bus, dev, fun.</span><span class=cF0>
<a name="l279"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l280"></a> </span><span class=cF9>I64</span><span class=cF0> res;
<a name="l281"></a>
<a name="l282"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l283"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l284"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l285"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l286"></a> </span><span class=cFB>c32_eax</span><span class=cF0> = </span><span class=cFE>0xB103</span><span class=cF0>;
<a name="l287"></a> </span><span class=cFB>c32_esi</span><span class=cF0> = n;
<a name="l288"></a> </span><span class=cFB>c32_ecx</span><span class=cF0> = class_code;
<a name="l289"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>FarCall32</span><span class=cF7>(</span><span class=cFB>sys_pci_services</span><span class=cF7>)</span><span class=cF0> &amp;&amp; !</span><span class=cFB>c32_eax</span><span class=cF0>.u8[</span><span class=cFE>1</span><span class=cF0>])
<a name="l290"></a> res = </span><span class=cFB>c32_ebx</span><span class=cF0>.u8[</span><span class=cFE>1</span><span class=cF0>] &lt;&lt; </span><span class=cFE>16</span><span class=cF0> + (</span><span class=cFB>c32_ebx</span><span class=cF0> &amp; </span><span class=cFE>0xF8</span><span class=cF0>) &lt;&lt; </span><span class=cFE>5</span><span class=cF0> + </span><span class=cFB>c32_ebx</span><span class=cF0> &amp; </span><span class=cFE>7</span><span class=cF0>;
<a name="l291"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l292"></a> res = -</span><span class=cFE>1</span><span class=cF0>;
<a name="l293"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FAR_CALL32</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
<a name="l294"></a> </span><span class=cF1>POPFD</span><span class=cF0>
<a name="l295"></a>
<a name="l296"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l297"></a>}
<a name="l298"></a>
</span></pre></body>
</html>