//EAX is $LK,"SYS_BOOT_SRC",A="FF:::/Kernel/KStart16.HC,[SYS_BOOT_SRC]"$. (Val passed from boot blk, $LK,"BootHD",A="FF:::/Adam/Opt/Boot/BootHD.HC,BOOT_SRC_HARDDRV"$, $LK,"BootDVD",A="FF:::/Adam/Opt/Boot/BootDVD.HC,BOOT_SRC_DVD"$, & $LK,"BootRAM",A="FF:::/Adam/Opt/Boot/BootRAM.HC,BOOT_SRC_RAM"$.)
MOVECX,EAX
MOVAX,(BOOT_RAM_LIMIT-BOOT_STK_SIZE)/16
MOVSS,AX
MOVSP,BOOT_STK_SIZE
PUSHECX//Will be $LK,"SYS_BOOT_SRC",A="FF:::/Kernel/KStart16.HC,[SYS_BOOT_SRC]"$. See $LK,"BootHD",A="FF:::/Adam/Opt/Boot/BootHD.HC,BOOT_SRC_HARDDRV"$, $LK,"BootDVD",A="FF:::/Adam/Opt/Boot/BootDVD.HC,BOOT_SRC_DVD"$ & $LK,"BootRAM",A="FF:::/Adam/Opt/Boot/BootRAM.HC,BOOT_SRC_RAM"$.
PUSHEBX
CALLU16GET_RIP
GET_RIP:POPBX
SUBBX,GET_RIP
SHRBX,4
MOVAX,CS
ADDAX,BX
PUSHAX
PUSHU16@@05
RETF
@@05:STI
MOVAX,CS
MOVDS,AX
MOVU32[SYS_RUN_LEVEL],RLF_16BIT
MOVAX,0x4F02
MOVBX,0x12//640x480 16 color
#exe {
if(!kernel_cfg->opts[CFG_TEXT_MODE])
StreamPrint("INT 0x10");//Enable VGA
};
CMPAX,0x004F
JNE@@10//Jmp if fail
BTSU32[SYS_RUN_LEVEL],RLf_VGA
@@10:
//Get mem maps.
MOVAX,0xE801
INT0x15
MOVU16[MEM_E801],CX
MOVU16[MEM_E801+2],DX
MOVCX,MEM_E820_ENTRIES_NUM-1//Leave one to terminate
XOREBX,EBX
MOVAX,DS
MOVES,AX
MOVDI,MEM_E820
@@15:PUSHCX
MOVEAX,0xE820
MOVECX,sizeof(CMemE820)
MOVEDX,'PAMS'
INT0x15
JC@@20
CMPEAX,'PAMS'
JNE@@20
TESTEBX,EBX
JZ@@20
ADDDI,sizeof(CMemE820)
POPCX
LOOP@@15
SUBSP,2
@@20:ADDSP,2
//Find how much space to map, start with E801 limit.