ZealOS/docs/Kernel/Memory/PageTables.CC.html

235 lines
36 KiB
HTML
Raw Normal View History

2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V0.10">
2021-07-03 05:07:57 +01:00
<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">
2021-07-03 05:07:57 +01:00
<a name="l1"></a><span class=cF1>asm</span><span class=cF0> {
<a name="l2"></a></span><span class=cF2>// </span><a href="https://zeal-operating-system.github.io/ZealOS/Doc/MemoryOverview.DD.html#l1"><span class=cF4>::/Doc/MemoryOverview.DD</span></a><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l3"></a>
<a name="l4"></a></span><span class=cF1>USE32</span><span class=cF0>
<a name="l5"></a></span><span class=cFD>SYS_INIT_PAGE_TABLES</span><span class=cF0>::
<a name="l6"></a></span><span class=cF2>//Check 1Gig page capability and set page size.</span><span class=cF0>
<a name="l7"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x80000001</span><span class=cF0>
<a name="l8"></a> </span><span class=cF1>CPUID</span><span class=cF0>
<a name="l9"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cFE>21</span><span class=cF0>
<a name="l10"></a> </span><span class=cF1>BT</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFE>26</span><span class=cF0>
<a name="l11"></a> </span><span class=cF1>JNC</span><span class=cF0> @@05
<a name="l12"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cFE>30</span><span class=cF0>
<a name="l13"></a>@@05: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>MEM_PAGE_SIZE</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l14"></a>
<a name="l15"></a></span><span class=cF2>//Set mapped space limit</span><span class=cF0>
<a name="l16"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, [</span><span class=cFD>MEM_PHYSICAL_SPACE</span><span class=cF0>]
<a name="l17"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, [</span><span class=cFD>MEM_PHYSICAL_SPACE</span><span class=cF0> + </span><span class=cFE>4</span><span class=cF0>]
<a name="l18"></a> </span><span class=cF1>BT</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>MEM_PAGE_SIZE</span><span class=cF0>], </span><span class=cFE>30</span><span class=cF0> </span><span class=cF2>//Round-up to 1Gig boundary?</span><span class=cF0>
<a name="l19"></a> </span><span class=cF1>JNC</span><span class=cF0> @@10
<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=cFE>0x3FFFFFFF</span><span class=cF0>
<a name="l21"></a> </span><span class=cF1>ADC</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>
<a name="l22"></a> </span><span class=cF1>AND</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, ~</span><span class=cFE>0x3FFFFFFF</span><span class=cF0>
<a name="l23"></a>@@10: </span><span class=cF1>INC</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0> </span><span class=cF2>//Need 4Gig extra for uncached alias up at top of space.</span><span class=cF0>
<a name="l24"></a> </span><span class=cF1>MOV</span><span class=cF0> [</span><span class=cFD>MEM_MAPPED_SPACE</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
<a name="l25"></a> </span><span class=cF1>MOV</span><span class=cF0> [</span><span class=cFD>MEM_MAPPED_SPACE</span><span class=cF0> + </span><span class=cFE>4</span><span class=cF0>], </span><span class=cFC>EDX</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l26"></a>
<a name="l27"></a></span><span class=cF2>//How many 2Meg pages?</span><span class=cF0>
<a name="l28"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>CL</span><span class=cF0>, </span><span class=cFE>21</span><span class=cF0>
<a name="l29"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x1FFFFF</span><span class=cF0>
<a name="l30"></a> </span><span class=cF1>ADC</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>
<a name="l31"></a> </span><span class=cF1>SHRD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFC>EDX</span><span class=cF0>
<a name="l32"></a> </span><span class=cF1>SHR</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFC>CL</span><span class=cF0>
<a name="l33"></a> </span><span class=cF1>MOV</span><span class=cF0> [</span><span class=cFD>MEM_2MEG_NUM</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
<a name="l34"></a> </span><span class=cF1>MOV</span><span class=cF0> [</span><span class=cFD>MEM_2MEG_NUM</span><span class=cF0> + </span><span class=cFE>4</span><span class=cF0>], </span><span class=cFC>EDX</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l35"></a>
<a name="l36"></a></span><span class=cF2>//How many 1Gig pages?</span><span class=cF0>
<a name="l37"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>CL</span><span class=cF0>, </span><span class=cFE>9</span><span class=cF0>
<a name="l38"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x1FF</span><span class=cF0>
<a name="l39"></a> </span><span class=cF1>ADC</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>
<a name="l40"></a> </span><span class=cF1>SHRD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFC>EDX</span><span class=cF0>
<a name="l41"></a> </span><span class=cF1>SHR</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFC>CL</span><span class=cF0>
<a name="l42"></a> </span><span class=cF1>MOV</span><span class=cF0> [</span><span class=cFD>MEM_1GIG_NUM</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
<a name="l43"></a> </span><span class=cF1>MOV</span><span class=cF0> [</span><span class=cFD>MEM_1GIG_NUM</span><span class=cF0> + </span><span class=cFE>4</span><span class=cF0>], </span><span class=cFC>EDX</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l44"></a>
<a name="l45"></a></span><span class=cF2>//How many 512Gig pages?</span><span class=cF0>
<a name="l46"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>CL</span><span class=cF0>, </span><span class=cFE>9</span><span class=cF0>
<a name="l47"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x1FF</span><span class=cF0>
<a name="l48"></a> </span><span class=cF1>ADC</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>
<a name="l49"></a> </span><span class=cF1>SHRD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFC>EDX</span><span class=cF0>
<a name="l50"></a> </span><span class=cF1>SHR</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFC>CL</span><span class=cF0>
<a name="l51"></a> </span><span class=cF1>MOV</span><span class=cF0> [</span><span class=cFD>MEM_512GIG_NUM</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
<a name="l52"></a> </span><span class=cF1>MOV</span><span class=cF0> [</span><span class=cFD>MEM_512GIG_NUM</span><span class=cF0> + </span><span class=cFE>4</span><span class=cF0>], </span><span class=cFC>EDX</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l53"></a>
<a name="l54"></a></span><span class=cF2>//Set </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4107"><span class=cF4>CSysFixedArea</span></a><span class=cF2> to zero</span><span class=cF0>
<a name="l55"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cF3>SYS_FIXED_AREA</span><span class=cF0>
<a name="l56"></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="l57"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CSysFixedArea</span><span class=cF0>) / </span><span class=cFE>4</span><span class=cF0>
<a name="l58"></a> </span><span class=cF1>REP_STOSD</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l59"></a>
<a name="l60"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>MEM_PML2</span><span class=cF0>], </span><span class=cFC>EDI</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l61"></a></span><span class=cF2>//Check for 1Gig page capability.</span><span class=cF0>
<a name="l62"></a> </span><span class=cF1>BT</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>MEM_PAGE_SIZE</span><span class=cF0>], </span><span class=cFE>30</span><span class=cF0>
<a name="l63"></a> </span><span class=cF1>JC</span><span class=cF0> @@15
2021-07-03 05:07:57 +01:00
<a name="l64"></a></span><span class=cF2>//Find PML2 Size</span><span class=cF0>
<a name="l65"></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>MEM_2MEG_NUM</span><span class=cF0>]
<a name="l66"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x1FF</span><span class=cF0>
<a name="l67"></a> </span><span class=cF1>AND</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, ~</span><span class=cFE>0x1FF</span><span class=cF0>
<a name="l68"></a> </span><span class=cF1>SHL</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0>
<a name="l69"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cFC>EAX</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l70"></a>
<a name="l71"></a></span><span class=cF2>//Find PML3 Size</span><span class=cF0>
<a name="l72"></a>@@15: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>MEM_PML3</span><span class=cF0>], </span><span class=cFC>EDI</span><span class=cF0>
<a name="l73"></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>MEM_1GIG_NUM</span><span class=cF0>]
<a name="l74"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x1FF</span><span class=cF0>
<a name="l75"></a> </span><span class=cF1>AND</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, ~</span><span class=cFE>0x1FF</span><span class=cF0>
<a name="l76"></a> </span><span class=cF1>SHL</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0>
<a name="l77"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cFC>EAX</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l78"></a>
<a name="l79"></a></span><span class=cF2>//Find PML4 Size</span><span class=cF0>
<a name="l80"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>MEM_PML4</span><span class=cF0>], </span><span class=cFC>EDI</span><span class=cF0>
<a name="l81"></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>MEM_512GIG_NUM</span><span class=cF0>]
<a name="l82"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x1FF</span><span class=cF0>
<a name="l83"></a> </span><span class=cF1>AND</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, ~</span><span class=cFE>0x1FF</span><span class=cF0>
<a name="l84"></a> </span><span class=cF1>SHL</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0>
<a name="l85"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFC>EDI</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l86"></a>
<a name="l87"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>MEM_HEAP_BASE</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l88"></a>
<a name="l89"></a></span><span class=cF2>//Set page tables to zero</span><span class=cF0>
<a name="l90"></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>MEM_PML2</span><span class=cF0>]
<a name="l91"></a> </span><span class=cF1>SUB</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFC>EDI</span><span class=cF0>
<a name="l92"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, </span><span class=cFC>EAX</span><span class=cF0>
<a name="l93"></a> </span><span class=cF1>SHR</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0>
<a name="l94"></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="l95"></a> </span><span class=cF1>REP_STOSD</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l96"></a>
<a name="l97"></a></span><span class=cF2>//Check for 1Gig page capability.</span><span class=cF0>
<a name="l98"></a> </span><span class=cF1>BT</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>MEM_PAGE_SIZE</span><span class=cF0>], </span><span class=cFE>30</span><span class=cF0>
<a name="l99"></a> </span><span class=cF1>JC</span><span class=cF0> @@30
2021-07-03 05:07:57 +01:00
<a name="l100"></a>
<a name="l101"></a></span><span class=cF2>//PML2: Use 2Meg Pages</span><span class=cF0>
<a name="l102"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x87</span><span class=cF0> </span><span class=cF2>//bit 7 is page size (2Meg)</span><span class=cF0>
<a name="l103"></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="l104"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, [</span><span class=cFD>MEM_PML2</span><span class=cF0>]
<a name="l105"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, [</span><span class=cFD>MEM_2MEG_NUM</span><span class=cF0>]
<a name="l106"></a>@@20: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>EDI</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
<a name="l107"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>
<a name="l108"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>EDI</span><span class=cF0>], </span><span class=cFC>EDX</span><span class=cF0>
<a name="l109"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>
<a name="l110"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x200000</span><span class=cF0>
<a name="l111"></a> </span><span class=cF1>ADC</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>
<a name="l112"></a> </span><span class=cF1>LOOP</span><span class=cF0> @@20
2021-07-03 05:07:57 +01:00
<a name="l113"></a></span><span class=cF2>//PML3: Use 2Meg Pages</span><span class=cF0>
<a name="l114"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, [</span><span class=cFD>MEM_PML2</span><span class=cF0>]
<a name="l115"></a> </span><span class=cF1>OR</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>7</span><span class=cF0>
<a name="l116"></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="l117"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, [</span><span class=cFD>MEM_PML3</span><span class=cF0>]
<a name="l118"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, [</span><span class=cFD>MEM_1GIG_NUM</span><span class=cF0>]
<a name="l119"></a>@@25: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>EDI</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
<a name="l120"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>
<a name="l121"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>EDI</span><span class=cF0>], </span><span class=cFC>EDX</span><span class=cF0>
<a name="l122"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>
<a name="l123"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x1000</span><span class=cF0>
<a name="l124"></a> </span><span class=cF1>ADC</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>
<a name="l125"></a> </span><span class=cF1>LOOP</span><span class=cF0> @@25
<a name="l126"></a> </span><span class=cF1>JMP</span><span class=cF0> @@40
2021-07-03 05:07:57 +01:00
<a name="l127"></a>
<a name="l128"></a></span><span class=cF2>//PML3: Use 1Gig Pages</span><span class=cF0>
<a name="l129"></a>@@30: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x87</span><span class=cF0> </span><span class=cF2>//bit 7 is page size (1Gig)</span><span class=cF0>
<a name="l130"></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="l131"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, [</span><span class=cFD>MEM_PML3</span><span class=cF0>]
<a name="l132"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, [</span><span class=cFD>MEM_1GIG_NUM</span><span class=cF0>]
<a name="l133"></a>@@35: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>EDI</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
<a name="l134"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>
<a name="l135"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>EDI</span><span class=cF0>], </span><span class=cFC>EDX</span><span class=cF0>
<a name="l136"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>
<a name="l137"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x40000000</span><span class=cF0>
<a name="l138"></a> </span><span class=cF1>ADC</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>
<a name="l139"></a> </span><span class=cF1>LOOP</span><span class=cF0> @@35
2021-07-03 05:07:57 +01:00
<a name="l140"></a>
<a name="l141"></a></span><span class=cF2>//PML4</span><span class=cF0>
<a name="l142"></a>@@40: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, [</span><span class=cFD>MEM_PML3</span><span class=cF0>]
<a name="l143"></a> </span><span class=cF1>OR</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>7</span><span class=cF0>
<a name="l144"></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="l145"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, [</span><span class=cFD>MEM_PML4</span><span class=cF0>]
<a name="l146"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, [</span><span class=cFD>MEM_512GIG_NUM</span><span class=cF0>]
<a name="l147"></a>@@45: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>EDI</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
<a name="l148"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>
<a name="l149"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFC>EDI</span><span class=cF0>], </span><span class=cFC>EDX</span><span class=cF0>
<a name="l150"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>
<a name="l151"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x1000</span><span class=cF0>
<a name="l152"></a> </span><span class=cF1>ADC</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>
<a name="l153"></a> </span><span class=cF1>LOOP</span><span class=cF0> @@45
<a name="l154"></a> </span><span class=cF1>RET</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l155"></a>
<a name="l156"></a></span><span class=cFD>SYS_INIT_16MEG_SYS_CODE_BP</span><span class=cF0>::
<a name="l157"></a></span><span class=cF2>// Init sys_code_bp to BIOS E801 lowest 16Meg val.</span><span class=cF0>
<a name="l158"></a></span><span class=cF2>// </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/Memory/BlkPool.CC.html#l31"><span class=cF4>BlkPoolsInit</span></a><span class=cF2>() adds the rest.</span><span class=cF0>
<a name="l159"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_CODE_BP</span><span class=cF0>], </span><span class=cF3>SYS_FIXED_AREA</span><span class=cF0> + </span><span class=cF9>CSysFixedArea</span><span class=cF0>.</span><span class=cFB>sys_code_bp</span><span class=cF0>
<a name="l160"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_CODE_BP</span><span class=cF0> + </span><span class=cFE>4</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l161"></a>
<a name="l162"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_DATA_BP</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>
<a name="l163"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_DATA_BP</span><span class=cF0> + </span><span class=cFE>4</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l164"></a>
<a name="l165"></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="l166"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cF9>U16</span><span class=cF0> [</span><span class=cFD>MEM_E801</span><span class=cF0>] </span><span class=cF2>//1 Kb blks between 1M and 16M</span><span class=cF0>
<a name="l167"></a> </span><span class=cF1>SHL</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>10</span><span class=cF0>
<a name="l168"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0x100000</span><span class=cF0>
<a name="l169"></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>MEM_HEAP_BASE</span><span class=cF0>]
<a name="l170"></a> </span><span class=cF1>SUB</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFC>EDI</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l171"></a>
<a name="l172"></a></span><span class=cF2>//EDI=BASE EAX=SIZE</span><span class=cF0>
<a name="l173"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> [</span><span class=cFD>SYS_MEM_INIT_FLAG</span><span class=cF0>], </span><span class=cFE>1</span><span class=cF0>
<a name="l174"></a> </span><span class=cF1>JZ</span><span class=cF0> @@05
<a name="l175"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>
<a name="l176"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>
<a name="l177"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, </span><span class=cFC>EAX</span><span class=cF0>
<a name="l178"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AL</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> [</span><span class=cFD>SYS_MEM_INIT_VAL</span><span class=cF0>]
<a name="l179"></a> </span><span class=cF1>REP_STOSB</span><span class=cF0>
<a name="l180"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>EDI</span><span class=cF0>
<a name="l181"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l182"></a>
<a name="l183"></a>@@05: </span><span class=cF1>SHR</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cF3>MEM_PAG_BITS</span><span class=cF0>
<a name="l184"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ESI</span><span class=cF0>, </span><span class=cF3>SYS_FIXED_AREA</span><span class=cF0> + </span><span class=cF9>CSysFixedArea</span><span class=cF0>.</span><span class=cFB>sys_code_bp</span><span class=cF0>
<a name="l185"></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=cF9>CBlkPool</span><span class=cF0>.mem_free_list[</span><span class=cFC>ESI</span><span class=cF0>]
<a name="l186"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cF9>CMemBlk</span><span class=cF0>.next [</span><span class=cFC>EDI</span><span class=cF0>], </span><span class=cFC>EBX</span><span class=cF0>
<a name="l187"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cF9>CMemBlk</span><span class=cF0>.next + </span><span class=cFE>4</span><span class=cF0> [</span><span class=cFC>EDI</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>
<a name="l188"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cF9>CBlkPool</span><span class=cF0>.mem_free_list [</span><span class=cFC>ESI</span><span class=cF0>], </span><span class=cFC>EDI</span><span class=cF0>
<a name="l189"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cF9>CBlkPool</span><span class=cF0>.mem_free_list + </span><span class=cFE>4</span><span class=cF0> [</span><span class=cFC>ESI</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>
<a name="l190"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cF9>CMemBlk</span><span class=cF0>.mb_signature[</span><span class=cFC>EDI</span><span class=cF0>], </span><span class=cF3>MBS_UNUSED_SIGNATURE_VAL</span><span class=cF0>
<a name="l191"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cF9>CMemBlk</span><span class=cF0>.pags[</span><span class=cFC>EDI</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
<a name="l192"></a> </span><span class=cF1>SHL</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cF3>MEM_PAG_BITS</span><span class=cF0>
<a name="l193"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> </span><span class=cF9>CBlkPool</span><span class=cF0>.alloced_u8s[</span><span class=cFC>ESI</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l194"></a>
<a name="l195"></a> </span><span class=cF1>BTS</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_RUN_LEVEL</span><span class=cF0>], </span><span class=cF3>RLf_16MEG_SYS_CODE_BP</span><span class=cF0>
<a name="l196"></a> </span><span class=cF1>RET</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l197"></a>}
<a name="l198"></a>
<a name="l199"></a></span><span class=cF9>I64</span><span class=cF0> *</span><span class=cF5>MemPageTable</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *a)
<a name="l200"></a>{</span><span class=cF2>//Point to page table entry for addr.</span><span class=cF0>
<a name="l201"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>mem_page_size</span><span class=cF0>, </span><span class=cFE>30</span><span class=cF7>)</span><span class=cF0>)
<a name="l202"></a> </span><span class=cF1>return</span><span class=cF0> *</span><span class=cFD>MEM_PML3</span><span class=cF0>(</span><span class=cF9>U64</span><span class=cF0> *) + a &gt;&gt; </span><span class=cFE>30</span><span class=cF0> * </span><span class=cFE>8</span><span class=cF0>;
<a name="l203"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l204"></a> </span><span class=cF1>return</span><span class=cF0> *</span><span class=cFD>MEM_PML2</span><span class=cF0>(</span><span class=cF9>U64</span><span class=cF0> *) + a &gt;&gt; </span><span class=cFE>21</span><span class=cF0> * </span><span class=cFE>8</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l205"></a>}
</span></pre></body>
</html>