mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-30 17:26:31 +00:00
dbf8647d59
Added top & right borders to RawDr. Improved spacing in some debug and compiler reporting. Fixed RawPutChar and EdLite tab width. Fixed Ui missing '0x' prefix syntax highlighter bug. Added 32BitPaint demo.
381 lines
57 KiB
HTML
Executable file
381 lines
57 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.08">
|
|
<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=cF1>asm</span><span class=cF0> {</span><span class=cF2>/* See </span><a href="https://tomawezome.github.io/ZealOS/Doc/Boot.DD.html#l1"><span class=cF4>::/Doc/Boot.DD</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l2"></a></span><span class=cF2>ZealOS starts in real, calls some BIOS routines, switches to 32 bit, and 64 bit mode and continues in </span><a href="https://tomawezome.github.io/ZealOS/Doc/CosmiC.DD.html#l1"><span class=cF4>CosmiC</span></a><span class=cF2> at </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KMain.CC.html#l143"><span class=cF4>KMain</span></a><span class=cF2>().</span><span class=cF0>
|
|
<a name="l3"></a>
|
|
<a name="l4"></a></span><span class=cF2>The boot loader jumps here in real-mode (16-bit).</span><span class=cF0>
|
|
<a name="l5"></a></span><span class=cF2>It actually jumps to the </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l452"><span class=cF4>CBinFile</span></a><span class=cF2> header which is placed just before this by </span><a href="https://tomawezome.github.io/ZealOS/Compiler/CMain.CC.html#l628"><span class=cF4>the compiler</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l6"></a></span><span class=cF2>The header begins with a short jmp to the start of this file's code which begins with the following small jump past some data.</span><span class=cF0>
|
|
<a name="l7"></a>
|
|
<a name="l8"></a></span><span class=cF2>This file is first in the Kernel image because it is #included first. </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Kernel.PRJ.html#l14"><span class=cF4>Kernel.PRJ</span></a><span class=cF0>
|
|
<a name="l9"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l10"></a></span><span class=cF1>USE16</span><span class=cF0>
|
|
<a name="l11"></a></span><span class=cFD>SYS_KERNEL</span><span class=cF0>:: </span><span class=cF2>//This must match </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l548"><span class=cF4>CKernel</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l12"></a> </span><span class=cF1>JMP</span><span class=cF0> </span><span class=cF9>I16</span><span class=cF0> </span><span class=cFD>CORE0_16BIT_INIT</span><span class=cF0>
|
|
<a name="l13"></a>
|
|
<a name="l14"></a></span><span class=cF2>//************************************</span><span class=cF0>
|
|
<a name="l15"></a></span><span class=cF2>//</span><span class=cF0> </span><span class=cF2>ASM Global vars required for 16-bit start-up</span><span class=cF0>
|
|
<a name="l16"></a> </span><span class=cF1>ALIGN</span><span class=cF0> </span><span class=cFE>4</span><span class=cF0>, </span><span class=cF3>OC_NOP</span><span class=cF0>
|
|
<a name="l17"></a>
|
|
<a name="l18"></a></span><span class=cFD>SYS_BOOT_SRC</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cF3>BOOT_SRC_NULL</span><span class=cF0>;
|
|
<a name="l19"></a></span><span class=cFD>SYS_BOOT_BLK</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l20"></a></span><span class=cFD>SYS_BOOT_PATCH_TABLE_BASE</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l21"></a></span><span class=cFD>SYS_RUN_LEVEL</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l22"></a>
|
|
<a name="l23"></a>#</span><span class=cF1>exe</span><span class=cF0>
|
|
<a name="l24"></a></span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l25"></a> </span><span class=cF5>StreamPrint</span><span class=cF0>(</span><span class=cF6>"SYS_COMPILE_TIME:: DU64 0x%X;"</span><span class=cF0>, </span><span class=cF5>Now</span><span class=cF0>); </span><span class=cF2>//See </span><span class=cF4><u>IDEBootDVDProbe</span><span class=cF0>
|
|
<a name="l26"></a></u></span><span class=cF7>}</span><span class=cF0>;
|
|
<a name="l27"></a>
|
|
<a name="l28"></a>#</span><span class=cF1>assert</span><span class=cF0> </span><span class=cFD>SYS_COMPILE_TIME</span><span class=cF0> + </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CDate</span><span class=cF0>) + </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CBinFile</span><span class=cF0>) < </span><span class=cF3>DVD_BLK_SIZE</span><span class=cF0>
|
|
<a name="l29"></a>
|
|
<a name="l30"></a></span><span class=cFD>MEM_BOOT_BASE</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>; </span><span class=cF2>//Offset from start used by reboot</span><span class=cF0>
|
|
<a name="l31"></a></span><span class=cFD>MEM_E801</span><span class=cF0>:: </span><span class=cF1>DU16</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l32"></a></span><span class=cFD>MEM_E820</span><span class=cF0>:: </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF3>MEM_E820_ENTRIES_NUM</span><span class=cF0> * </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CMemE820</span><span class=cF0>) </span><span class=cF1>DUP</span><span class=cF0> (</span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l33"></a></span><span class=cFD>MEM_PHYSICAL_SPACE</span><span class=cF0>:: </span><span class=cF1>DU64</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l34"></a></span><span class=cFD>SYS_GDT_PTR</span><span class=cF0>:: </span><span class=cF1>DU16</span><span class=cF0> </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CGDT</span><span class=cF0>) - </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l35"></a> </span><span class=cF1>DU64</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l36"></a></span><span class=cFD>SYS_PCI_BUSES</span><span class=cF0>:: </span><span class=cF1>DU16</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l37"></a>
|
|
<a name="l38"></a> </span><span class=cF1>ALIGN</span><span class=cF0> </span><span class=cFE>16</span><span class=cF0>, </span><span class=cF3>OC_NOP</span><span class=cF0>
|
|
<a name="l39"></a>
|
|
<a name="l40"></a></span><span class=cFD>SYS_GDT</span><span class=cF0>:: </span><span class=cF2>//See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l396"><span class=cF4>CGDT</span></a><span class=cF0>
|
|
<a name="l41"></a>GDT_NULL: </span><span class=cF1>DU64</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>,</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l42"></a>GDT_BOOT_DS: </span><span class=cF1>DU64</span><span class=cF0> </span><span class=cFE>0x00CF92000000FFFF</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>; </span><span class=cF2>//Gets patched.</span><span class=cF0>
|
|
<a name="l43"></a>GDT_BOOT_CS: </span><span class=cF1>DU64</span><span class=cF0> </span><span class=cFE>0x00CF9A000000FFFF</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>; </span><span class=cF2>//Gets patched.</span><span class=cF0>
|
|
<a name="l44"></a>GDT_CS32: </span><span class=cF1>DU64</span><span class=cF0> </span><span class=cFE>0x00CF9A000000FFFF</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l45"></a>GDT_CS64: </span><span class=cF1>DU64</span><span class=cF0> </span><span class=cFE>0x00209A0000000000</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>; </span><span class=cF2>//The </span><a href="https://tomawezome.github.io/ZealOS/Doc/Charter.DD.html#l1"><span class=cF4>Charter</span></a><span class=cF2> says just ring0.</span><span class=cF0>
|
|
<a name="l46"></a>GDT_CS64_RING3: </span><span class=cF1>DU64</span><span class=cF0> </span><span class=cFE>0x0020FA0000000000</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>; </span><span class=cF2>//</span><a href="https://tomawezome.github.io/ZealOS/Demo/Lectures/Ring3.CC.html#l1"><span class=cF4>Ring3</span></a><span class=cF2>, so you can play with.</span><span class=cF0>
|
|
<a name="l47"></a>GDT_DS: </span><span class=cF1>DU64</span><span class=cF0> </span><span class=cFE>0x00CF92000000FFFF</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l48"></a>GDT_DS_RING3: </span><span class=cF1>DU64</span><span class=cF0> </span><span class=cFE>0x00CFF2000000FFFF</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l49"></a>GDT_TR: </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF3>MP_PROCESSORS_NUM</span><span class=cF0> * </span><span class=cFE>16</span><span class=cF0> </span><span class=cF1>DUP</span><span class=cF0>(</span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l50"></a>GDT_TR_RING3: </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF3>MP_PROCESSORS_NUM</span><span class=cF0> * </span><span class=cFE>16</span><span class=cF0> </span><span class=cF1>DUP</span><span class=cF0>(</span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l51"></a>#</span><span class=cF1>assert</span><span class=cF0> $ - </span><span class=cFD>SYS_GDT</span><span class=cF0> == </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CGDT</span><span class=cF0>)
|
|
<a name="l52"></a>
|
|
<a name="l53"></a></span><span class=cFD>SYS_FONT_PTR</span><span class=cF0>:: </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l54"></a>
|
|
<a name="l55"></a></span><span class=cFD>SYS_VBE_INFO</span><span class=cF0>:: </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CVBEInfo</span><span class=cF0>) </span><span class=cF1>DUP</span><span class=cF0>(</span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l56"></a></span><span class=cFD>SYS_VBE_MODES</span><span class=cF0>:: </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CVBEModeShort</span><span class=cF0>) * </span><span class=cF3>VBE_MODES_NUM</span><span class=cF0> </span><span class=cF1>DUP</span><span class=cF0>(</span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l57"></a></span><span class=cFD>SYS_VBE_FINAL_MODE</span><span class=cF0>:: </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CVBEMode</span><span class=cF0>) </span><span class=cF1>DUP</span><span class=cF0>(</span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l58"></a></span><span class=cFD>SYS_VBE_FINAL_MODE_NUM</span><span class=cF0>::</span><span class=cF1>DU16</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>; </span><span class=cF2>//mode number of final mode set</span><span class=cF0>
|
|
<a name="l59"></a>#</span><span class=cF1>assert</span><span class=cF0> $ - </span><span class=cFD>SYS_KERNEL</span><span class=cF0> == </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CKernel</span><span class=cF0>) - </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CBinFile</span><span class=cF0>)
|
|
<a name="l60"></a>
|
|
<a name="l61"></a>TEMP_VBE_MODE: </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CVBEMode</span><span class=cF0>) </span><span class=cF1>DUP</span><span class=cF0>(</span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l62"></a>MAX_VBE_MODE: </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CVBEModeShort</span><span class=cF0>) </span><span class=cF1>DUP</span><span class=cF0>(</span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l63"></a>MAX_SCREEN_HEIGHT: </span><span class=cF1>DU16</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l64"></a>
|
|
<a name="l65"></a>#</span><span class=cF1>exe</span><span class=cF0>
|
|
<a name="l66"></a></span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l67"></a> </span><span class=cF5>StreamPrint</span><span class=cF0>(</span><span class=cF6>"SCREEN_WIDTH:</span><span class=cF0> </span><span class=cF6>DU16</span><span class=cF0> </span><span class=cF6>%d;"</span><span class=cF0>
|
|
<a name="l68"></a> </span><span class=cF6>"SCREEN_HEIGHT: DU16</span><span class=cF0> </span><span class=cF6>%d;"</span><span class=cF0>, kernel_config->screen_width, kernel_config->screen_height);
|
|
<a name="l69"></a></span><span class=cF7>}</span><span class=cF0>;
|
|
<a name="l70"></a>
|
|
<a name="l71"></a></span><span class=cF2>//************************************</span><span class=cF0>
|
|
<a name="l72"></a></span><span class=cFD>CORE0_16BIT_INIT</span><span class=cF0>::
|
|
<a name="l73"></a></span><span class=cF2>//EAX is </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KStart16.CC.html#l311"><span class=cF4>SYS_BOOT_SRC</span></a><span class=cF2>. (Val passed from boot blk, </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootHD.CC.html#l84"><span class=cF4>BootHD</span></a><span class=cF2>, </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootDVD.CC.html#l175"><span class=cF4>BootDVD</span></a><span class=cF2>, & </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootRAM.CC.html#l46"><span class=cF4>BootRAM</span></a><span class=cF2>.)</span><span class=cF0>
|
|
<a name="l74"></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="l75"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, (</span><span class=cF3>BOOT_RAM_LIMIT</span><span class=cF0> - </span><span class=cF3>BOOT_STACK_SIZE</span><span class=cF0>) / </span><span class=cFE>16</span><span class=cF0>
|
|
<a name="l76"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>SS</span><span class=cF0>, </span><span class=cFC>AX</span><span class=cF0>
|
|
<a name="l77"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>SP</span><span class=cF0>, </span><span class=cF3>BOOT_STACK_SIZE</span><span class=cF0>
|
|
<a name="l78"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0> </span><span class=cF2>//Will be </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KStart16.CC.html#l311"><span class=cF4>SYS_BOOT_SRC</span></a><span class=cF2>. See </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootHD.CC.html#l84"><span class=cF4>BootHD</span></a><span class=cF2>, </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootDVD.CC.html#l175"><span class=cF4>BootDVD</span></a><span class=cF2> & </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootRAM.CC.html#l46"><span class=cF4>BootRAM</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l79"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>EBX</span><span class=cF0>
|
|
<a name="l80"></a> </span><span class=cF1>CALL</span><span class=cF0> </span><span class=cF9>U16</span><span class=cF0> GET_IP
|
|
<a name="l81"></a>GET_IP: </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>BX</span><span class=cF0>
|
|
<a name="l82"></a> </span><span class=cF1>SUB</span><span class=cF0> </span><span class=cFC>BX</span><span class=cF0>, GET_IP
|
|
<a name="l83"></a> </span><span class=cF1>SHR</span><span class=cF0> </span><span class=cFC>BX</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>
|
|
<a name="l84"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFC>CS</span><span class=cF0>
|
|
<a name="l85"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFC>BX</span><span class=cF0>
|
|
<a name="l86"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>
|
|
<a name="l87"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cF9>U16</span><span class=cF0> @@04
|
|
<a name="l88"></a> </span><span class=cF1>RETF</span><span class=cF0>
|
|
<a name="l89"></a>
|
|
<a name="l90"></a>@@04: </span><span class=cF1>STI</span><span class=cF0>
|
|
<a name="l91"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFC>CS</span><span class=cF0>
|
|
<a name="l92"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>DS</span><span class=cF0>, </span><span class=cFC>AX</span><span class=cF0>
|
|
<a name="l93"></a> </span><span class=cF1>MOV</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_16BIT</span><span class=cF0>
|
|
<a name="l94"></a>
|
|
<a name="l95"></a></span><span class=cF2>//Our variables are on the data segment, but VBE functions require ES.</span><span class=cF0>
|
|
<a name="l96"></a></span><span class=cF2>//moving DS into ES, while preserving ES</span><span class=cF0>
|
|
<a name="l97"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>ES</span><span class=cF0>
|
|
<a name="l98"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>DS</span><span class=cF0>
|
|
<a name="l99"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>ES</span><span class=cF0>
|
|
<a name="l100"></a>
|
|
<a name="l101"></a></span><span class=cF2>//Get VBE implementation information</span><span class=cF0>
|
|
<a name="l102"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0x4F00</span><span class=cF0>
|
|
<a name="l103"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>DI</span><span class=cF0>, </span><span class=cFD>SYS_VBE_INFO</span><span class=cF0>
|
|
<a name="l104"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>CVBEInfo</span><span class=cF0>.signature[</span><span class=cFC>DI</span><span class=cF0>], </span><span class=cF6>'VBE2'</span><span class=cF0> </span><span class=cF2>//set to 'VBE2' to use VBE 2.0 functionality</span><span class=cF0>
|
|
<a name="l105"></a> </span><span class=cF1>INT</span><span class=cF0> </span><span class=cFE>0x10</span><span class=cF0>
|
|
<a name="l106"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>ES</span><span class=cF0>
|
|
<a name="l107"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0x004F</span><span class=cF0>
|
|
<a name="l108"></a> </span><span class=cF1>JE</span><span class=cF0> @@05
|
|
<a name="l109"></a> </span><span class=cF1>JMP</span><span class=cF0> $ </span><span class=cF2>//Freeze system if VBE not supported</span><span class=cF0>
|
|
<a name="l110"></a>
|
|
<a name="l111"></a>@@05:
|
|
<a name="l112"></a>
|
|
<a name="l113"></a></span><span class=cF2>/*Loop variables:</span><span class=cF0>
|
|
<a name="l114"></a></span><span class=cF2> DI <- Temporary storage for mode information</span><span class=cF0>
|
|
<a name="l115"></a></span><span class=cF2> CX <- Mode number</span><span class=cF0>
|
|
<a name="l116"></a></span><span class=cF2> DX <- mode array</span><span class=cF0>
|
|
<a name="l117"></a></span><span class=cF2> GS <- Segment for video modes list</span><span class=cF0>
|
|
<a name="l118"></a></span><span class=cF2> SI <- Offset for video modes list</span><span class=cF0>
|
|
<a name="l119"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l120"></a></span><span class=cF2>//Obtain segment:offset of list of potential video modes</span><span class=cF0>
|
|
<a name="l121"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFD>SYS_VBE_INFO</span><span class=cF0>
|
|
<a name="l122"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>SI</span><span class=cF0>, </span><span class=cF9>CVBEInfo</span><span class=cF0>.video_modes[</span><span class=cFC>AX</span><span class=cF0>]
|
|
<a name="l123"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>GS</span><span class=cF0>, </span><span class=cF9>CVBEInfo</span><span class=cF0>.video_modes+</span><span class=cFE>2</span><span class=cF0>[</span><span class=cFC>AX</span><span class=cF0>]
|
|
<a name="l124"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>DI</span><span class=cF0>, TEMP_VBE_MODE
|
|
<a name="l125"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>DX</span><span class=cF0>, </span><span class=cFD>SYS_VBE_MODES</span><span class=cF0>
|
|
<a name="l126"></a>
|
|
<a name="l127"></a>@@06: </span><span class=cF2>//Loop through all the mode numbers</span><span class=cF0>
|
|
<a name="l128"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFC>GS</span><span class=cF0>:[</span><span class=cFC>SI</span><span class=cF0>]
|
|
<a name="l129"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0xFFFF</span><span class=cF0> </span><span class=cF2>//FFFF signifies the end of the list</span><span class=cF0>
|
|
<a name="l130"></a> </span><span class=cF1>JE</span><span class=cF0> @@08
|
|
<a name="l131"></a>
|
|
<a name="l132"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>SI</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> </span><span class=cF2>//Increment pointer to read next U16 mode</span><span class=cF0>
|
|
<a name="l133"></a>
|
|
<a name="l134"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>CX</span><span class=cF0>, </span><span class=cFC>AX</span><span class=cF0>
|
|
<a name="l135"></a> </span><span class=cF1>BTS</span><span class=cF0> </span><span class=cFC>CX</span><span class=cF0>, </span><span class=cFE>14</span><span class=cF0> </span><span class=cF2>//Set linear framebuffer bit in the mode number we are about to pass to the BIOS below</span><span class=cF0>
|
|
<a name="l136"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>ES</span><span class=cF0>
|
|
<a name="l137"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>DS</span><span class=cF0>
|
|
<a name="l138"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>ES</span><span class=cF0>
|
|
<a name="l139"></a></span><span class=cF2>//Get mode information for mode number</span><span class=cF0>
|
|
<a name="l140"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0x4F01</span><span class=cF0>
|
|
<a name="l141"></a> </span><span class=cF1>INT</span><span class=cF0> </span><span class=cFE>0x10</span><span class=cF0>
|
|
<a name="l142"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>ES</span><span class=cF0>
|
|
<a name="l143"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0x004F</span><span class=cF0>
|
|
<a name="l144"></a> </span><span class=cF1>JNE</span><span class=cF0> @@06 </span><span class=cF2>//if call to get mode information failed</span><span class=cF0>
|
|
<a name="l145"></a>
|
|
<a name="l146"></a></span><span class=cF2>//filter everything but 32-bit color</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=cF9>CVBEMode</span><span class=cF0>.bpp[</span><span class=cFC>DI</span><span class=cF0>]
|
|
<a name="l148"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>AL</span><span class=cF0>, </span><span class=cFE>32</span><span class=cF0>
|
|
<a name="l149"></a> </span><span class=cF1>JNE</span><span class=cF0> @@06
|
|
<a name="l150"></a>
|
|
<a name="l151"></a></span><span class=cF2>//Check if the mode is actually supported</span><span class=cF0>
|
|
<a name="l152"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cF9>CVBEMode</span><span class=cF0>.attributes[</span><span class=cFC>DI</span><span class=cF0>]
|
|
<a name="l153"></a> </span><span class=cF1>AND</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0x91</span><span class=cF0> </span><span class=cF2>//bit 0 = supported, bit 4 = graphics mode, bit 7 = linear framebuffer</span><span class=cF0>
|
|
<a name="l154"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0x91</span><span class=cF0>
|
|
<a name="l155"></a> </span><span class=cF1>JNE</span><span class=cF0> @@06
|
|
<a name="l156"></a>
|
|
<a name="l157"></a></span><span class=cF2>//Only want memory model of packed pixel or direct color (RGB)</span><span class=cF0>
|
|
<a name="l158"></a></span><span class=cF2>//</span><span class=cF0> </span><span class=cF2>MOV </span><span class=cF0> </span><span class=cF2>AX, CVBEMode.memory_model[DI]</span><span class=cF0>
|
|
<a name="l159"></a></span><span class=cF2>//</span><span class=cF0> </span><span class=cF2>CMP </span><span class=cF0> </span><span class=cF2>AX, 4</span><span class=cF0>
|
|
<a name="l160"></a></span><span class=cF2>//</span><span class=cF0> </span><span class=cF2>JNE </span><span class=cF0> </span><span class=cF2>@@06</span><span class=cF0>
|
|
<a name="l161"></a></span><span class=cF2>//</span><span class=cF0> </span><span class=cF2>CMP </span><span class=cF0> </span><span class=cF2>AX, 6</span><span class=cF0>
|
|
<a name="l162"></a></span><span class=cF2>//</span><span class=cF0> </span><span class=cF2>JNE </span><span class=cF0> </span><span class=cF2>@@06</span><span class=cF0>
|
|
<a name="l163"></a></span><span class=cF2>//Copy information about this mode into an element of the mode array</span><span class=cF0>
|
|
<a name="l164"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>BX</span><span class=cF0>, </span><span class=cF9>CVBEMode</span><span class=cF0>.height[</span><span class=cFC>DI</span><span class=cF0>]
|
|
<a name="l165"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>CVBEModeShort</span><span class=cF0>.height[</span><span class=cFC>DX</span><span class=cF0>], </span><span class=cFC>BX</span><span class=cF0>
|
|
<a name="l166"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>BX</span><span class=cF0>, [MAX_SCREEN_HEIGHT]
|
|
<a name="l167"></a> </span><span class=cF1>JL</span><span class=cF0> @@07
|
|
<a name="l168"></a>
|
|
<a name="l169"></a> </span><span class=cF1>MOV</span><span class=cF0> [MAX_SCREEN_HEIGHT], </span><span class=cFC>BX</span><span class=cF0>
|
|
<a name="l170"></a> </span><span class=cF1>MOV</span><span class=cF0> [MAX_VBE_MODE], </span><span class=cFC>CX</span><span class=cF0>
|
|
<a name="l171"></a>
|
|
<a name="l172"></a>@@07: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cF9>CVBEMode</span><span class=cF0>.width[</span><span class=cFC>DI</span><span class=cF0>]
|
|
<a name="l173"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>CVBEModeShort</span><span class=cF0>.width[</span><span class=cFC>DX</span><span class=cF0>], </span><span class=cFC>AX</span><span class=cF0>
|
|
<a name="l174"></a></span><span class=cF2>//</span><span class=cF0> </span><span class=cF2>MOV</span><span class=cF0> </span><span class=cF2>EAX, CVBEMode.max_pixel_clock[DI]</span><span class=cF0>
|
|
<a name="l175"></a></span><span class=cF2>//</span><span class=cF0> </span><span class=cF2>MOV</span><span class=cF0> </span><span class=cF2>CVBEModeShort.max_pixel_clock[DX], EAX</span><span class=cF0>
|
|
<a name="l176"></a>
|
|
<a name="l177"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>CVBEModeShort</span><span class=cF0>.mode_num[</span><span class=cFC>DX</span><span class=cF0>], </span><span class=cFC>CX</span><span class=cF0>
|
|
<a name="l178"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>DX</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CVBEModeShort</span><span class=cF0>) </span><span class=cF2>//next array element</span><span class=cF0>
|
|
<a name="l179"></a>
|
|
<a name="l180"></a></span><span class=cF2>//Check if width and height match</span><span class=cF0>
|
|
<a name="l181"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, [SCREEN_WIDTH]
|
|
<a name="l182"></a> </span><span class=cF1>JNE</span><span class=cF0> @@06
|
|
<a name="l183"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>BX</span><span class=cF0>, [SCREEN_HEIGHT]
|
|
<a name="l184"></a> </span><span class=cF1>JNE</span><span class=cF0> @@06
|
|
<a name="l185"></a>
|
|
<a name="l186"></a></span><span class=cF2>//If we've made it here we have our mode</span><span class=cF0>
|
|
<a name="l187"></a> </span><span class=cF1>MOV</span><span class=cF0> [</span><span class=cFD>SYS_VBE_FINAL_MODE_NUM</span><span class=cF0>], </span><span class=cFC>CX</span><span class=cF0>
|
|
<a name="l188"></a> </span><span class=cF1>JMP</span><span class=cF0> @@06
|
|
<a name="l189"></a>
|
|
<a name="l190"></a>@@08: </span><span class=cF2>//End of loop</span><span class=cF0>
|
|
<a name="l191"></a></span><span class=cF2>//If there isn't a valid mode set by user through kernel config, set the mode with the biggest height.</span><span class=cF0>
|
|
<a name="l192"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, [</span><span class=cFD>SYS_VBE_FINAL_MODE_NUM</span><span class=cF0>]
|
|
<a name="l193"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>
|
|
<a name="l194"></a> </span><span class=cF1>JNE</span><span class=cF0> @@09
|
|
<a name="l195"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>CX</span><span class=cF0>, [MAX_VBE_MODE]
|
|
<a name="l196"></a> </span><span class=cF1>MOV</span><span class=cF0> [</span><span class=cFD>SYS_VBE_FINAL_MODE_NUM</span><span class=cF0>], </span><span class=cFC>CX</span><span class=cF0>
|
|
<a name="l197"></a>
|
|
<a name="l198"></a>@@09: </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>ES</span><span class=cF0>
|
|
<a name="l199"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>DS</span><span class=cF0>
|
|
<a name="l200"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>ES</span><span class=cF0>
|
|
<a name="l201"></a></span><span class=cF2>//Get mode infomration for the mode we want</span><span class=cF0>
|
|
<a name="l202"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>DI</span><span class=cF0>, </span><span class=cFD>SYS_VBE_FINAL_MODE</span><span class=cF0>
|
|
<a name="l203"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>CX</span><span class=cF0>, [</span><span class=cFD>SYS_VBE_FINAL_MODE_NUM</span><span class=cF0>]
|
|
<a name="l204"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0x4F01</span><span class=cF0>
|
|
<a name="l205"></a> </span><span class=cF1>INT</span><span class=cF0> </span><span class=cFE>0x10</span><span class=cF0>
|
|
<a name="l206"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>ES</span><span class=cF0>
|
|
<a name="l207"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0x004F</span><span class=cF0>
|
|
<a name="l208"></a> </span><span class=cF1>JNE</span><span class=cF0> @@10 </span><span class=cF2>//if called failed</span><span class=cF0>
|
|
<a name="l209"></a>
|
|
<a name="l210"></a></span><span class=cF2>//Set the mode; call takes mode number in BX</span><span class=cF0>
|
|
<a name="l211"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0x4F02</span><span class=cF0>
|
|
<a name="l212"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>BX</span><span class=cF0>, </span><span class=cFC>CX</span><span class=cF0>
|
|
<a name="l213"></a> </span><span class=cF1>INT</span><span class=cF0> </span><span class=cFE>0x10</span><span class=cF0>
|
|
<a name="l214"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0x004F</span><span class=cF0>
|
|
<a name="l215"></a> </span><span class=cF1>JNE</span><span class=cF0> @@10
|
|
<a name="l216"></a>
|
|
<a name="l217"></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_VESA</span><span class=cF0>
|
|
<a name="l218"></a>@@10:
|
|
<a name="l219"></a>
|
|
<a name="l220"></a></span><span class=cF2>//Get pointer to 8x8 VGA ROM font.</span><span class=cF0>
|
|
<a name="l221"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0x1130</span><span class=cF0>
|
|
<a name="l222"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>BH</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0>
|
|
<a name="l223"></a> </span><span class=cF1>INT</span><span class=cF0> </span><span class=cFE>0x10</span><span class=cF0>
|
|
<a name="l224"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFC>ES</span><span class=cF0>
|
|
<a name="l225"></a> </span><span class=cF1>SHL</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>16</span><span class=cF0>
|
|
<a name="l226"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFC>BP</span><span class=cF0>
|
|
<a name="l227"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_FONT_PTR</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
|
|
<a name="l228"></a>
|
|
<a name="l229"></a></span><span class=cF2>//Get E801 memory map.</span><span class=cF0>
|
|
<a name="l230"></a></span><span class=cF2>//Output: AX = Memory between 1MiB and 16MiB in KiB (max 0x3C00 == 15 MiB)</span><span class=cF0>
|
|
<a name="l231"></a></span><span class=cF2>//</span><span class=cF0> </span><span class=cF2> BX = Memory after 16MiB until first memory hole in 64KiB blocks.</span><span class=cF0>
|
|
<a name="l232"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>CX</span><span class=cF0>, </span><span class=cFC>CX</span><span class=cF0>
|
|
<a name="l233"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>DX</span><span class=cF0>, </span><span class=cFC>DX</span><span class=cF0>
|
|
<a name="l234"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0xE801</span><span class=cF0>
|
|
<a name="l235"></a> </span><span class=cF1>INT</span><span class=cF0> </span><span class=cFE>0x15</span><span class=cF0>
|
|
<a name="l236"></a> </span><span class=cF1>JCXZ</span><span class=cF0> @@12 </span><span class=cF2>//if CX and DX are zero, use AX and BX instead.</span><span class=cF0>
|
|
<a name="l237"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFC>CX</span><span class=cF0>
|
|
<a name="l238"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>BX</span><span class=cF0>, </span><span class=cFC>DX</span><span class=cF0>
|
|
<a name="l239"></a>@@12: </span><span class=cF1>MOV</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=cFC>AX</span><span class=cF0>
|
|
<a name="l240"></a> </span><span class=cF1>MOV</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=cFE>2</span><span class=cF0>], </span><span class=cFC>BX</span><span class=cF0>
|
|
<a name="l241"></a>
|
|
<a name="l242"></a></span><span class=cF2>//Get E820 memory map.</span><span class=cF0>
|
|
<a name="l243"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>CX</span><span class=cF0>, </span><span class=cF3>MEM_E820_ENTRIES_NUM</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0> </span><span class=cF2>//Leave one to terminate</span><span class=cF0>
|
|
<a name="l244"></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="l245"></a> </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>DS</span><span class=cF0>
|
|
<a name="l246"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>ES</span><span class=cF0>
|
|
<a name="l247"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>DI</span><span class=cF0>, </span><span class=cFD>MEM_E820</span><span class=cF0>
|
|
<a name="l248"></a>@@15: </span><span class=cF1>PUSH</span><span class=cF0> </span><span class=cFC>CX</span><span class=cF0>
|
|
<a name="l249"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>0xE820</span><span class=cF0>
|
|
<a name="l250"></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>CMemE820</span><span class=cF0>)
|
|
<a name="l251"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cF6>'PAMS'</span><span class=cF0>
|
|
<a name="l252"></a> </span><span class=cF1>INT</span><span class=cF0> </span><span class=cFE>0x15</span><span class=cF0>
|
|
<a name="l253"></a> </span><span class=cF1>JC</span><span class=cF0> @@20
|
|
<a name="l254"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cF6>'PAMS'</span><span class=cF0>
|
|
<a name="l255"></a> </span><span class=cF1>JNE</span><span class=cF0> @@20
|
|
<a name="l256"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cFC>EBX</span><span class=cF0>, </span><span class=cFC>EBX</span><span class=cF0>
|
|
<a name="l257"></a> </span><span class=cF1>JZ</span><span class=cF0> @@20
|
|
<a name="l258"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>DI</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CMemE820</span><span class=cF0>)
|
|
<a name="l259"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cFC>CX</span><span class=cF0>
|
|
<a name="l260"></a> </span><span class=cF1>LOOP</span><span class=cF0> @@15
|
|
<a name="l261"></a> </span><span class=cF1>SUB</span><span class=cF0> </span><span class=cFC>SP</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0>
|
|
<a name="l262"></a>@@20: </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>SP</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0> </span><span class=cF2>//if called failed we want to nullify the PUSHed CX value.</span><span class=cF0>
|
|
<a name="l263"></a>
|
|
<a name="l264"></a></span><span class=cF2>//Find how much space to map, start with E801 limit.</span><span class=cF0>
|
|
<a name="l265"></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="l266"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, [</span><span class=cFD>MEM_E801</span><span class=cF0>+</span><span class=cFE>2</span><span class=cF0>]
|
|
<a name="l267"></a> </span><span class=cF1>SHL</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>16</span><span class=cF0>
|
|
<a name="l268"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cF3>SYS_16MEG_AREA_LIMIT</span><span class=cF0>
|
|
<a name="l269"></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="l270"></a>
|
|
<a name="l271"></a></span><span class=cF2>//Find max of E820 to set mapped space.</span><span class=cF0>
|
|
<a name="l272"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>SI</span><span class=cF0>, </span><span class=cFD>MEM_E820</span><span class=cF0>
|
|
<a name="l273"></a>@@25: </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>CL</span><span class=cF0>, </span><span class=cF9>CMemE820</span><span class=cF0>.type[</span><span class=cFC>SI</span><span class=cF0>]
|
|
<a name="l274"></a> </span><span class=cF1>TEST</span><span class=cF0> </span><span class=cFC>CL</span><span class=cF0>, </span><span class=cFC>CL</span><span class=cF0>
|
|
<a name="l275"></a> </span><span class=cF1>JZ</span><span class=cF0> @@35
|
|
<a name="l276"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EBX</span><span class=cF0>, </span><span class=cF9>CMemE820</span><span class=cF0>.base [</span><span class=cFC>SI</span><span class=cF0>]
|
|
<a name="l277"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, </span><span class=cF9>CMemE820</span><span class=cF0>.base+</span><span class=cFE>4</span><span class=cF0>[</span><span class=cFC>SI</span><span class=cF0>]
|
|
<a name="l278"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EBX</span><span class=cF0>, </span><span class=cF9>CMemE820</span><span class=cF0>.len [</span><span class=cFC>SI</span><span class=cF0>]
|
|
<a name="l279"></a> </span><span class=cF1>ADC</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, </span><span class=cF9>CMemE820</span><span class=cF0>.len+</span><span class=cFE>4</span><span class=cF0> [</span><span class=cFC>SI</span><span class=cF0>]
|
|
<a name="l280"></a> </span><span class=cF1>SUB</span><span class=cF0> </span><span class=cFC>EBX</span><span class=cF0>, </span><span class=cFC>EAX</span><span class=cF0>
|
|
<a name="l281"></a> </span><span class=cF1>SBB</span><span class=cF0> </span><span class=cFC>ECX</span><span class=cF0>, </span><span class=cFC>EDX</span><span class=cF0>
|
|
<a name="l282"></a> </span><span class=cF1>JC</span><span class=cF0> @@30
|
|
<a name="l283"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cF9>CMemE820</span><span class=cF0>.base [</span><span class=cFC>SI</span><span class=cF0>]
|
|
<a name="l284"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cF9>CMemE820</span><span class=cF0>.base+</span><span class=cFE>4</span><span class=cF0>[</span><span class=cFC>SI</span><span class=cF0>]
|
|
<a name="l285"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cF9>CMemE820</span><span class=cF0>.len [</span><span class=cFC>SI</span><span class=cF0>]
|
|
<a name="l286"></a> </span><span class=cF1>ADC</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cF9>CMemE820</span><span class=cF0>.len+</span><span class=cFE>4</span><span class=cF0> [</span><span class=cFC>SI</span><span class=cF0>]
|
|
<a name="l287"></a>@@30: </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>SI</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CMemE820</span><span class=cF0>)
|
|
<a name="l288"></a> </span><span class=cF1>JMP</span><span class=cF0> @@25
|
|
<a name="l289"></a>
|
|
<a name="l290"></a>@@35: </span><span class=cF1>MOV</span><span class=cF0> [</span><span class=cFD>MEM_PHYSICAL_SPACE</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
|
|
<a name="l291"></a> </span><span class=cF1>MOV</span><span class=cF0> [</span><span class=cFD>MEM_PHYSICAL_SPACE</span><span class=cF0>+</span><span class=cFE>4</span><span class=cF0>], </span><span class=cFC>EDX</span><span class=cF0>
|
|
<a name="l292"></a>
|
|
<a name="l293"></a></span><span class=cF2>//Get PCI Bus Info</span><span class=cF0>
|
|
<a name="l294"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U16</span><span class=cF0> [</span><span class=cFD>SYS_PCI_BUSES</span><span class=cF0>], </span><span class=cFE>256</span><span class=cF0>
|
|
<a name="l295"></a> </span><span class=cF1>XOR</span><span class=cF0> </span><span class=cFC>DX</span><span class=cF0>, </span><span class=cFC>DX</span><span class=cF0>
|
|
<a name="l296"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFE>0xB101</span><span class=cF0>
|
|
<a name="l297"></a> </span><span class=cF1>INT</span><span class=cF0> </span><span class=cFE>0x1A</span><span class=cF0>
|
|
<a name="l298"></a> </span><span class=cF1>CMP</span><span class=cF0> </span><span class=cFC>DX</span><span class=cF0>, </span><span class=cF6>'PC'</span><span class=cF0>
|
|
<a name="l299"></a> </span><span class=cF1>JNE</span><span class=cF0> @@40
|
|
<a name="l300"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>CH</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>
|
|
<a name="l301"></a> </span><span class=cF1>INC</span><span class=cF0> </span><span class=cFC>CX</span><span class=cF0>
|
|
<a name="l302"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U16</span><span class=cF0> [</span><span class=cFD>SYS_PCI_BUSES</span><span class=cF0>], </span><span class=cFC>CX</span><span class=cF0>
|
|
<a name="l303"></a>@@40:
|
|
<a name="l304"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l305"></a></span><span class=cF2>//Enable A20</span><span class=cF0>
|
|
<a name="l306"></a> </span><span class=cF1>IN</span><span class=cF0> </span><span class=cFC>AL</span><span class=cF0>, </span><span class=cFE>0x92</span><span class=cF0>
|
|
<a name="l307"></a> </span><span class=cF1>OR</span><span class=cF0> </span><span class=cFC>AL</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0>
|
|
<a name="l308"></a> </span><span class=cF1>OUT</span><span class=cF0> </span><span class=cFE>0x92</span><span class=cF0>, </span><span class=cFC>AL</span><span class=cF0>
|
|
<a name="l309"></a>
|
|
<a name="l310"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_BOOT_BLK</span><span class=cF0>]
|
|
<a name="l311"></a> </span><span class=cF1>POP</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_BOOT_SRC</span><span class=cF0>] </span><span class=cF2>//See </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootHD.CC.html#l84"><span class=cF4>BootHD</span></a><span class=cF2>, </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootDVD.CC.html#l175"><span class=cF4>BootDVD</span></a><span class=cF2>, & </span><a href="https://tomawezome.github.io/ZealOS/System/Boot/BootRAM.CC.html#l46"><span class=cF4>BootRAM</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l312"></a>
|
|
<a name="l313"></a> </span><span class=cF1>CLD</span><span class=cF0>
|
|
<a name="l314"></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="l315"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>AX</span><span class=cF0>, </span><span class=cFC>CS</span><span class=cF0>
|
|
<a name="l316"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>DS</span><span class=cF0>, </span><span class=cFC>AX</span><span class=cF0>
|
|
<a name="l317"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>ES</span><span class=cF0>, </span><span class=cFC>AX</span><span class=cF0>
|
|
<a name="l318"></a> </span><span class=cF1>SHL</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cFE>4</span><span class=cF0>
|
|
<a name="l319"></a>
|
|
<a name="l320"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>MEM_BOOT_BASE</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
|
|
<a name="l321"></a>
|
|
<a name="l322"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>DX</span><span class=cF0>, </span><span class=cFC>CS</span><span class=cF0>
|
|
<a name="l323"></a> </span><span class=cF1>SUB</span><span class=cF0> </span><span class=cFC>DX</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CBinFile</span><span class=cF0>) / </span><span class=cFE>16</span><span class=cF0>
|
|
<a name="l324"></a>#</span><span class=cF1>assert</span><span class=cF0> !(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CBinFile</span><span class=cF7>)</span><span class=cF0> & </span><span class=cFE>0xF</span><span class=cF0>)
|
|
<a name="l325"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>GS</span><span class=cF0>, </span><span class=cFC>DX</span><span class=cF0>
|
|
<a name="l326"></a>
|
|
<a name="l327"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cFC>EAX</span><span class=cF0>
|
|
<a name="l328"></a> </span><span class=cF1>ADD</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=cFC>GS</span><span class=cF0>:[</span><span class=cF9>CBinFile</span><span class=cF0>.patch_table_offset]
|
|
<a name="l329"></a> </span><span class=cF1>SUB</span><span class=cF0> </span><span class=cFC>EDX</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CBinFile</span><span class=cF0>)
|
|
<a name="l330"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_BOOT_PATCH_TABLE_BASE</span><span class=cF0>], </span><span class=cFC>EDX</span><span class=cF0>
|
|
<a name="l331"></a>
|
|
<a name="l332"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [GDT_BOOT_DS+</span><span class=cFE>2</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
|
|
<a name="l333"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [GDT_BOOT_CS+</span><span class=cFE>2</span><span class=cF0>], </span><span class=cFC>EAX</span><span class=cF0>
|
|
<a name="l334"></a> </span><span class=cF1>ADD</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cF9>I32</span><span class=cF0> </span><span class=cFD>SYS_GDT</span><span class=cF0>
|
|
<a name="l335"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_GDT_PTR</span><span class=cF0> + </span><span class=cF9>CSysLimitBase</span><span class=cF0>.base], </span><span class=cFC>EAX</span><span class=cF0>
|
|
<a name="l336"></a> </span><span class=cF1>LGDT</span><span class=cF0> </span><span class=cF9>U32</span><span class=cF0> [</span><span class=cFD>SYS_GDT_PTR</span><span class=cF0>]
|
|
<a name="l337"></a>
|
|
<a name="l338"></a> </span><span class=cF1>MOV</span><span class=cF0> </span><span class=cFC>EAX</span><span class=cF0>, </span><span class=cF3>SYS_START_CR0</span><span class=cF0>
|
|
<a name="l339"></a> </span><span class=cF1>MOV_CR0_EAX</span><span class=cF0>
|
|
<a name="l340"></a>
|
|
<a name="l341"></a></span><span class=cF2>/* The assembler doesn't support far jumps so</span><span class=cF0>
|
|
<a name="l342"></a></span><span class=cF2>we hand code it.</span><span class=cF0> </span><span class=cF2>16-bit code is not important</span><span class=cF0>
|
|
<a name="l343"></a></span><span class=cF2>enough to fully implement in the assembler.</span><span class=cF0>
|
|
<a name="l344"></a>
|
|
<a name="l345"></a></span><span class=cF2>To complete the switch to 32-bit mode, we have to load</span><span class=cF0>
|
|
<a name="l346"></a></span><span class=cF2>the code segment with a far jump.</span><span class=cF0>
|
|
<a name="l347"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l348"></a> </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cFE>0x66</span><span class=cF0>, </span><span class=cFE>0xEA</span><span class=cF0>; </span><span class=cF2>//JMP CGDT.boot_cs:CORE0_32BIT_INIT</span><span class=cF0>
|
|
<a name="l349"></a> </span><span class=cF1>DU32</span><span class=cF0> </span><span class=cFD>CORE0_32BIT_INIT</span><span class=cF0>;
|
|
<a name="l350"></a> </span><span class=cF1>DU16</span><span class=cF0> </span><span class=cF9>CGDT</span><span class=cF0>.boot_cs;
|
|
<a name="l351"></a>#</span><span class=cF1>assert</span><span class=cF0> $ + </span><span class=cFE>16</span><span class=cF0> <= </span><span class=cFE>0xFFFF</span><span class=cF0>
|
|
<a name="l352"></a>}
|
|
</span></pre></body>
|
|
</html>
|