2005-10-06 21:56:22 +04:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;; BOOTCODE.INC ;;
|
|
|
|
|
;; ;;
|
2005-12-14 11:09:29 +03:00
|
|
|
|
;; KolibriOS 16-bit loader, ;;
|
|
|
|
|
;; based on bootcode for MenuetOS ;;
|
2005-10-06 21:56:22 +04:00
|
|
|
|
;; ;;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;==========================================================================
|
|
|
|
|
;
|
|
|
|
|
; 16 BIT FUNCTIONS
|
|
|
|
|
;
|
|
|
|
|
;==========================================================================
|
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
putchar:
|
|
|
|
|
; in: al=character
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov ah, 0Eh
|
|
|
|
|
mov bh, 0
|
|
|
|
|
int 10h
|
|
|
|
|
ret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
print:
|
|
|
|
|
; in: si->string
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov al, 186
|
|
|
|
|
call putchar
|
|
|
|
|
mov al, ' '
|
|
|
|
|
call putchar
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
printplain:
|
|
|
|
|
; in: si->string
|
2006-05-06 18:34:30 +04:00
|
|
|
|
pusha
|
|
|
|
|
lodsb
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
call putchar
|
|
|
|
|
lodsb
|
|
|
|
|
cmp al, 0
|
|
|
|
|
jnz @b
|
|
|
|
|
popa
|
|
|
|
|
ret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
; Now int 16 is used for keyboard support.
|
|
|
|
|
; This is shorter, simpler and more reliable.
|
|
|
|
|
if 0
|
2005-10-06 21:56:22 +04:00
|
|
|
|
getkey: push ecx
|
|
|
|
|
push edx
|
|
|
|
|
add ebx,0x0101
|
|
|
|
|
xor eax,eax
|
|
|
|
|
|
|
|
|
|
gk1:
|
|
|
|
|
in al,0x60
|
|
|
|
|
mov cl,al
|
|
|
|
|
gk0:
|
|
|
|
|
in al,0x60
|
|
|
|
|
cmp al,cl
|
|
|
|
|
je gk0
|
|
|
|
|
cmp ax,11
|
|
|
|
|
jg gk0
|
|
|
|
|
gk0_1:
|
|
|
|
|
mov cl,al
|
|
|
|
|
|
|
|
|
|
; add al,47
|
|
|
|
|
; mov [ds:keyinbs-0x10000],al
|
|
|
|
|
; mov si,keyinbs-0x10000
|
|
|
|
|
; call printplain
|
|
|
|
|
|
|
|
|
|
gk12:
|
|
|
|
|
in al,0x60
|
|
|
|
|
cmp al,cl
|
|
|
|
|
je gk12
|
|
|
|
|
cmp ax,240
|
|
|
|
|
jne gk13
|
|
|
|
|
mov al,cl
|
|
|
|
|
jmp gk14
|
|
|
|
|
gk13:
|
|
|
|
|
add cl,128
|
|
|
|
|
cmp al,cl
|
|
|
|
|
jne gk1
|
|
|
|
|
sub al,128
|
|
|
|
|
gk14:
|
|
|
|
|
|
|
|
|
|
movzx edx,bl
|
|
|
|
|
cmp eax,edx
|
|
|
|
|
jb gk1
|
|
|
|
|
movzx edx,bh
|
|
|
|
|
cmp eax,edx
|
|
|
|
|
jg gk1
|
|
|
|
|
test ebx,0x010000
|
|
|
|
|
jnz gk3
|
|
|
|
|
mov cx,0x1000
|
|
|
|
|
mov dx,cx
|
|
|
|
|
add eax,47
|
|
|
|
|
mov cx,ax
|
|
|
|
|
cmp cx,58
|
|
|
|
|
jb gk_nozero
|
|
|
|
|
sub cx,10
|
|
|
|
|
gk_nozero:
|
|
|
|
|
mov [ds:keyin-0x10000],cl
|
|
|
|
|
mov si,keyin-0x10000
|
|
|
|
|
call printplain
|
|
|
|
|
gk3:
|
|
|
|
|
sub eax,48
|
|
|
|
|
pop edx
|
|
|
|
|
pop ecx
|
|
|
|
|
ret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
getkey:
|
|
|
|
|
; get number in range [bl,bh] (bl,bh in ['0'..'9'])
|
|
|
|
|
; in: bx=range
|
|
|
|
|
; out: ax=digit (1..9, 10 for 0)
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov ah, 0
|
|
|
|
|
int 16h
|
|
|
|
|
cmp al, bl
|
|
|
|
|
jb getkey
|
|
|
|
|
cmp al, bh
|
|
|
|
|
ja getkey
|
|
|
|
|
push ax
|
|
|
|
|
call putchar
|
|
|
|
|
pop ax
|
|
|
|
|
and ax, 0Fh
|
|
|
|
|
jnz @f
|
|
|
|
|
mov al, 10
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
ret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
setcursor:
|
|
|
|
|
; in: dl=column, dh=row
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov ah, 2
|
|
|
|
|
mov bh, 0
|
|
|
|
|
int 10h
|
|
|
|
|
ret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
macro _setcursor row,column
|
|
|
|
|
{
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov dx, row*256 + column
|
|
|
|
|
call setcursor
|
2005-12-14 11:09:29 +03:00
|
|
|
|
}
|
|
|
|
|
|
2006-01-25 16:19:21 +03:00
|
|
|
|
pagetable_set:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
or al, 7
|
2006-01-25 16:19:21 +03:00
|
|
|
|
@@:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
stosd
|
|
|
|
|
add eax, 1000h
|
|
|
|
|
loop @b
|
|
|
|
|
ret
|
2006-01-25 16:19:21 +03:00
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; 16-bit data
|
|
|
|
|
; videomodes table
|
|
|
|
|
gr_table:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
dw 0x112+0100000000000000b , 640 , 480 ; 1
|
|
|
|
|
dw 0x115+0100000000000000b , 800 , 600 ; 2
|
|
|
|
|
dw 0x118+0100000000000000b , 1024 , 768 ; 3
|
|
|
|
|
dw 0x11B+0100000000000000b , 1280 , 1024 ; 4
|
|
|
|
|
dw 0x112 , 640 , 480 ; 5
|
|
|
|
|
dw 0x115 , 800 , 600 ; 6
|
|
|
|
|
dw 0x118 , 1024 , 768 ; 7
|
|
|
|
|
dw 0x11B , 1280 ,1024 ; 8
|
|
|
|
|
dw 0x13, 320, 200 ; 9
|
|
|
|
|
dw 0x12, 640, 480 ; 0
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
; table for move to extended memory (int 15h, ah=87h)
|
|
|
|
|
movedesc:
|
|
|
|
|
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
|
|
|
|
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
|
|
|
|
|
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
|
|
|
|
|
|
|
|
|
|
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
|
|
|
|
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
|
|
|
|
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
|
|
|
|
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
;=========================================================================
|
|
|
|
|
;
|
|
|
|
|
; 16 BIT CODE
|
|
|
|
|
;
|
|
|
|
|
;=========================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
start_of_code:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
cld
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; \begin{diamond}[02.12.2005]
|
2006-05-06 18:34:30 +04:00
|
|
|
|
cmp ax, 'KL'
|
|
|
|
|
jnz @f
|
|
|
|
|
mov word [cs:cfgmanager.loader_block-0x10000], si
|
|
|
|
|
mov word [cs:cfgmanager.loader_block+2-0x10000], ds
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
|
|
|
|
; \end{diamond}[02.12.2005]
|
|
|
|
|
|
|
|
|
|
; set up stack
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov ax, 3000h
|
|
|
|
|
mov ss, ax
|
|
|
|
|
mov sp, 0EC00h
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; set up segment registers
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push cs
|
|
|
|
|
pop ds
|
|
|
|
|
push cs
|
|
|
|
|
pop es
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
; set videomode
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov ax, 3
|
2005-10-06 21:56:22 +04:00
|
|
|
|
int 0x10
|
|
|
|
|
|
|
|
|
|
; Load & set russian VGA font (RU.INC)
|
|
|
|
|
mov bp,RU_FNT1-10000h ; RU_FNT1 - First part
|
|
|
|
|
mov bx,1000h ; 768 bytes
|
|
|
|
|
mov cx,30h ; 48 symbols
|
|
|
|
|
mov dx,80h ; 128 - position of first symbol
|
|
|
|
|
mov ax,1100h
|
|
|
|
|
int 10h
|
|
|
|
|
|
|
|
|
|
mov bp,RU_FNT2-10000h ; RU_FNT2 -Second part
|
|
|
|
|
mov bx,1000h ; 512 bytes
|
|
|
|
|
mov cx,20h ; 32 symbols
|
|
|
|
|
mov dx,0E0h ; 224 - position of first symbol
|
|
|
|
|
mov ax,1100h
|
|
|
|
|
int 10h
|
|
|
|
|
; End set VGA russian font
|
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; draw frames
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push 0xb800
|
|
|
|
|
pop es
|
|
|
|
|
xor di, di
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; mov si,d80x25-0x10000
|
|
|
|
|
; mov cx,80*25
|
|
|
|
|
; mov ah,1*16+15
|
|
|
|
|
; dfl1:
|
|
|
|
|
; lodsb
|
|
|
|
|
; stosw
|
|
|
|
|
; loop dfl1
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov ah, 1*16+15
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; draw top
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov si, d80x25_top - 0x10000
|
|
|
|
|
mov cx, d80x25_top_num * 80
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
lodsb
|
|
|
|
|
stosw
|
|
|
|
|
loop @b
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; draw spaces
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov si, space_msg - 0x10000
|
|
|
|
|
mov cx, 25 - d80x25_top_num - d80x25_bottom_num
|
2005-12-14 11:09:29 +03:00
|
|
|
|
dfl1:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push cx
|
|
|
|
|
push si
|
|
|
|
|
mov cx, 80
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
lodsb
|
|
|
|
|
stosw
|
|
|
|
|
loop @b
|
|
|
|
|
pop si
|
|
|
|
|
pop cx
|
|
|
|
|
loop dfl1
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; draw bottom
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov si, d80x25_bottom - 0x10000
|
|
|
|
|
mov cx, d80x25_bottom_num * 80
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
lodsb
|
|
|
|
|
stosw
|
|
|
|
|
loop @b
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov byte [space_msg-0x10000+80], 0 ; now space_msg is null terminated
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
_setcursor d80x25_top_num,0
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; TEST FOR 386+
|
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov bx, 0x4000
|
2005-10-06 21:56:22 +04:00
|
|
|
|
pushf
|
|
|
|
|
pop ax
|
|
|
|
|
mov dx,ax
|
2005-12-14 11:09:29 +03:00
|
|
|
|
xor ax,bx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
push ax
|
|
|
|
|
popf
|
|
|
|
|
pushf
|
|
|
|
|
pop ax
|
2005-12-14 11:09:29 +03:00
|
|
|
|
and ax,bx
|
|
|
|
|
and dx,bx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
cmp ax,dx
|
|
|
|
|
jnz cpugood
|
|
|
|
|
mov si,not386-0x10000
|
2006-01-25 16:19:21 +03:00
|
|
|
|
sayerr:
|
2005-10-06 21:56:22 +04:00
|
|
|
|
call print
|
|
|
|
|
jmp $
|
|
|
|
|
cpugood:
|
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; set up esp
|
2006-05-06 18:34:30 +04:00
|
|
|
|
movzx esp, sp
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
; FLUSH 8042 KEYBOARD CONTROLLER
|
|
|
|
|
|
|
|
|
|
;// mike.dld [
|
|
|
|
|
; mov al,0xED
|
|
|
|
|
; out 0x60,al
|
|
|
|
|
; or cx,-1
|
|
|
|
|
; @@:
|
|
|
|
|
; in al,0x64
|
|
|
|
|
; test al,2
|
|
|
|
|
; jz @f
|
|
|
|
|
; loop @b
|
|
|
|
|
; @@:
|
|
|
|
|
; mov al,0
|
|
|
|
|
; out 0x60,al
|
|
|
|
|
; or cx,-1
|
|
|
|
|
; @@:
|
|
|
|
|
; in al,0x64
|
|
|
|
|
; test al,2
|
|
|
|
|
; jz @f
|
|
|
|
|
; loop @b
|
|
|
|
|
; @@:
|
|
|
|
|
;// mike.dld ]
|
|
|
|
|
|
|
|
|
|
; mov ecx,10000
|
|
|
|
|
; fl1:
|
|
|
|
|
; in al,0x64
|
|
|
|
|
; loop fl1
|
|
|
|
|
; test al,1
|
|
|
|
|
; jz fl2
|
|
|
|
|
; in al,0x60
|
|
|
|
|
; jmp fl1
|
|
|
|
|
; fl2:
|
|
|
|
|
|
|
|
|
|
;****************************************************************
|
|
|
|
|
; The function is modified Mario79
|
|
|
|
|
;*****************************************************************
|
|
|
|
|
; wait_kbd: ; variant 1
|
|
|
|
|
; mov cx,2500h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 10 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
; test_kbd:
|
|
|
|
|
; in al,64h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
; test al,2 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
; loopnz test_kbd
|
|
|
|
|
|
|
|
|
|
mov al,0xf6 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
out 0x60,al
|
2005-12-14 11:09:29 +03:00
|
|
|
|
xor cx,cx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
wait_loop: ; variant 2
|
|
|
|
|
; reading state of port of 8042 controller
|
|
|
|
|
in al,64h
|
|
|
|
|
and al,00000010b ; ready flag
|
|
|
|
|
; wait until 8042 controller is ready
|
|
|
|
|
loopnz wait_loop
|
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
; --------------- APM ---------------------
|
|
|
|
|
push 0
|
|
|
|
|
pop es
|
|
|
|
|
mov word [es : 0x9044], 0 ; ver = 0.0 (APM not found)
|
|
|
|
|
mov ax, 0x5300
|
|
|
|
|
xor bx, bx
|
|
|
|
|
int 0x15
|
|
|
|
|
jc apm_end ; APM not found
|
|
|
|
|
test cx, 2
|
|
|
|
|
jz apm_end ; APM 32-bit protected-mode interface not supported
|
|
|
|
|
mov [es : 0x9044], ax ; Save APM Version
|
|
|
|
|
mov [es : 0x9046], cx ; Save APM flags
|
|
|
|
|
|
|
|
|
|
; Write APM ver ----
|
|
|
|
|
jmp @f
|
|
|
|
|
msg_apm:db ' APM x.x ', 0
|
|
|
|
|
@@: and ax, 0xf0f
|
|
|
|
|
add ax, '00'
|
|
|
|
|
mov [msg_apm - 0x10000 + 5], ah
|
|
|
|
|
mov [msg_apm - 0x10000 + 7], al
|
|
|
|
|
_setcursor 0, 3
|
|
|
|
|
mov si, msg_apm - 0x10000
|
|
|
|
|
call printplain
|
|
|
|
|
_setcursor d80x25_top_num,0
|
|
|
|
|
; ------------------
|
|
|
|
|
|
|
|
|
|
mov ax, 0x5304 ; Disconnect interface
|
|
|
|
|
xor bx, bx
|
|
|
|
|
int 0x15
|
|
|
|
|
mov ax, 0x5303 ; Connect 32 bit mode interface
|
|
|
|
|
xor bx, bx
|
|
|
|
|
int 0x15
|
|
|
|
|
; init selectors
|
|
|
|
|
movzx eax, ax ; real-mode segment base address of protected-mode 32-bit code segment
|
|
|
|
|
shl eax, 4
|
|
|
|
|
mov [apm_code_32 - 0x10000 + 2], ax
|
|
|
|
|
shr eax, 16
|
|
|
|
|
mov [apm_code_32 - 0x10000 + 4], al
|
|
|
|
|
movzx ecx, cx ; real-mode segment base address of protected-mode 16-bit code segment
|
|
|
|
|
shl ecx, 4
|
|
|
|
|
mov [apm_code_16 - 0x10000 + 2], cx
|
|
|
|
|
shr ecx, 16
|
|
|
|
|
mov [apm_code_16 - 0x10000 + 4], cl
|
|
|
|
|
movzx edx, dx ; real-mode segment base address of protected-mode 16-bit data segment
|
|
|
|
|
shl edx, 4
|
|
|
|
|
mov [apm_data_16 - 0x10000 + 2], dx
|
|
|
|
|
shr edx, 16
|
|
|
|
|
mov [apm_data_16 - 0x10000 + 4], dl
|
|
|
|
|
mov [es : 0x9040], ebx ; offset of APM entry point
|
|
|
|
|
apm_end:
|
|
|
|
|
; -----------------------------------------
|
|
|
|
|
|
2005-10-06 21:56:22 +04:00
|
|
|
|
; DISPLAY VESA INFORMATION
|
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push 0
|
|
|
|
|
pop es
|
2005-10-06 21:56:22 +04:00
|
|
|
|
mov ax,0x4f00
|
|
|
|
|
mov di,0xa000
|
|
|
|
|
int 0x10
|
|
|
|
|
cmp ax,0x004f
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov si, novesa-0x10000
|
|
|
|
|
jnz @f
|
2005-10-06 21:56:22 +04:00
|
|
|
|
mov ax,[es:di+4]
|
|
|
|
|
add ax,'0'*256+'0'
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov si,vervesa-0x10000
|
2006-01-25 16:19:21 +03:00
|
|
|
|
mov [si+vervesa_off], ah
|
|
|
|
|
mov [si+vervesa_off+2], al
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@: call print
|
|
|
|
|
|
|
|
|
|
; \begin{diamond}[30.11.2005]
|
|
|
|
|
cfgmanager:
|
|
|
|
|
; settings:
|
|
|
|
|
; a) preboot_graph = graphical mode
|
|
|
|
|
; preboot_gprobe = probe this mode?
|
|
|
|
|
; b) preboot_mtrr = use hardware acceleration?
|
|
|
|
|
; c) preboot_vrrm = use VRR?
|
|
|
|
|
; d) preboot_device = from what boot?
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov di, preboot_graph-0x10000
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; check bootloader block
|
2006-05-06 18:34:30 +04:00
|
|
|
|
cmp [.loader_block-0x10000], 0
|
|
|
|
|
jz .noloaderblock
|
|
|
|
|
les bx, [.loader_block-0x10000]
|
|
|
|
|
cmp byte [es:bx], 1
|
|
|
|
|
mov si, loader_block_error-0x10000
|
|
|
|
|
jnz sayerr
|
|
|
|
|
test byte [es:bx+1], 1
|
|
|
|
|
jz @f
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; image in memory present
|
2006-05-06 18:34:30 +04:00
|
|
|
|
cmp [di+preboot_device-preboot_graph], 0
|
|
|
|
|
jnz @f
|
|
|
|
|
mov [di+preboot_device-preboot_graph], 3
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
|
|
|
|
.noloaderblock:
|
|
|
|
|
; determine default settings
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov [.bSettingsChanged-0x10000], 0
|
|
|
|
|
cmp byte [di], 0
|
|
|
|
|
jnz .preboot_gr_end
|
|
|
|
|
mov [di+preboot_gprobe-preboot_graph], 0
|
|
|
|
|
mov al, [vervesa+vervesa_off-0x10000]
|
|
|
|
|
cmp al, 'x'
|
|
|
|
|
jz .novesa
|
|
|
|
|
cmp al, '1'
|
|
|
|
|
jz .vesa12
|
|
|
|
|
mov [di+preboot_gprobe-preboot_graph], 2
|
|
|
|
|
mov al, 3
|
|
|
|
|
jmp @f
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.vesa12:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov al, 7
|
|
|
|
|
jmp @f
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.novesa:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov al, 10
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov [di], al
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.preboot_gr_end:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
cmp [di+preboot_mtrr-preboot_graph], 1
|
|
|
|
|
adc [di+preboot_mtrr-preboot_graph], 0
|
|
|
|
|
cmp [di+preboot_vrrm-preboot_graph], 1
|
|
|
|
|
adc [di+preboot_vrrm-preboot_graph], 0
|
|
|
|
|
cmp [di+preboot_device-preboot_graph], 1
|
|
|
|
|
adc [di+preboot_device-preboot_graph], 0
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; notify user
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov si, linef-0x10000
|
|
|
|
|
call print
|
|
|
|
|
mov si, start_msg-0x10000
|
|
|
|
|
call print
|
|
|
|
|
mov si, time_msg-0x10000
|
|
|
|
|
call print
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; get start time
|
2006-05-06 18:34:30 +04:00
|
|
|
|
call .gettime
|
|
|
|
|
mov [.starttime-0x10000], eax
|
|
|
|
|
mov word [.timer-0x10000], .newtimer-0x10000
|
|
|
|
|
mov word [.timer-0x10000+2], cs
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.printcfg:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
_setcursor 9,0
|
|
|
|
|
mov si, current_cfg_msg-0x10000
|
|
|
|
|
call print
|
|
|
|
|
mov si, curvideo_msg-0x10000
|
|
|
|
|
call print
|
|
|
|
|
mov al, [preboot_graph-0x10000]
|
|
|
|
|
cmp al, 8
|
|
|
|
|
ja .pnovesa
|
|
|
|
|
mov dl, al
|
|
|
|
|
and eax, 3
|
|
|
|
|
mov si, [modes_msg-0x10000+eax*2]
|
|
|
|
|
call printplain
|
|
|
|
|
mov si, modevesa20-0x10000
|
|
|
|
|
cmp dl, 4
|
|
|
|
|
jbe @f
|
|
|
|
|
mov si, modevesa12-0x10000
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
call printplain
|
|
|
|
|
cmp dl, 4
|
|
|
|
|
ja .x
|
|
|
|
|
mov si, probeno_msg-0x10000
|
|
|
|
|
cmp [preboot_gprobe-0x10000], 2
|
|
|
|
|
jnz @f
|
|
|
|
|
mov si, probeok_msg-0x10000
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
call printplain
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.x:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
jmp .c
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.pnovesa:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
cmp al, 9
|
|
|
|
|
mov si, mode9-0x10000
|
|
|
|
|
jz @b
|
|
|
|
|
mov si, mode10-0x10000
|
|
|
|
|
jmp @b
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.c:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov si, linef-0x10000
|
|
|
|
|
call printplain
|
|
|
|
|
mov si, mtrr_msg-0x10000
|
|
|
|
|
cmp [preboot_mtrr-0x10000], 1
|
|
|
|
|
call .say_on_off
|
|
|
|
|
mov si, vrrm_msg-0x10000
|
|
|
|
|
cmp [preboot_vrrm-0x10000], 1
|
|
|
|
|
call .say_on_off
|
|
|
|
|
mov si, preboot_device_msg-0x10000
|
|
|
|
|
call print
|
|
|
|
|
mov al, [preboot_device-0x10000]
|
|
|
|
|
and eax, 3
|
|
|
|
|
mov si, [preboot_device_msgs-0x10000+eax*2]
|
|
|
|
|
call printplain
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.wait:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
_setcursor 25,0 ; out of screen
|
2006-01-11 12:46:06 +03:00
|
|
|
|
; set timer interrupt handler
|
2006-05-06 18:34:30 +04:00
|
|
|
|
cli
|
|
|
|
|
push 0
|
|
|
|
|
pop es
|
|
|
|
|
mov eax, [es:8*4]
|
|
|
|
|
mov [.oldtimer-0x10000], eax
|
|
|
|
|
mov eax, [.timer-0x10000]
|
|
|
|
|
mov [es:8*4], eax
|
|
|
|
|
sti
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; wait for keypressed
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov ah, 0
|
|
|
|
|
int 16h
|
|
|
|
|
push ax
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; restore timer interrupt
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push 0
|
|
|
|
|
pop es
|
|
|
|
|
mov eax, [.oldtimer-0x10000]
|
|
|
|
|
mov [es:8*4], eax
|
|
|
|
|
mov [.timer-0x10000], eax
|
|
|
|
|
_setcursor 7,0
|
|
|
|
|
mov si, space_msg-0x10000
|
|
|
|
|
call printplain
|
|
|
|
|
pop ax
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; switch on key
|
2006-05-06 18:34:30 +04:00
|
|
|
|
cmp al, 13
|
|
|
|
|
jz .continue
|
|
|
|
|
or al, 20h
|
|
|
|
|
cmp al, 'a'
|
|
|
|
|
jz .change_a
|
|
|
|
|
cmp al, 'b'
|
|
|
|
|
jz .change_b
|
|
|
|
|
cmp al, 'c'
|
|
|
|
|
jz .change_c
|
|
|
|
|
cmp al, 'd'
|
|
|
|
|
jnz .wait
|
|
|
|
|
_setcursor 15,0
|
|
|
|
|
mov si,bdev-0x10000
|
|
|
|
|
call print
|
|
|
|
|
mov bx,'13'
|
|
|
|
|
call getkey
|
|
|
|
|
mov [preboot_device-0x10000], al
|
|
|
|
|
_setcursor 13,0
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.d:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov [.bSettingsChanged-0x10000], 1
|
|
|
|
|
mov si, space_msg-0x10000
|
|
|
|
|
call printplain
|
|
|
|
|
_setcursor 15,0
|
|
|
|
|
mov cx, 6
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
call printplain
|
|
|
|
|
loop @b
|
|
|
|
|
jmp .printcfg
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.change_a:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
_setcursor 15,0
|
|
|
|
|
mov si, gr_mode-0x10000
|
|
|
|
|
call printplain
|
|
|
|
|
mov bx, '09'
|
|
|
|
|
call getkey
|
|
|
|
|
mov [preboot_graph-0x10000], al
|
|
|
|
|
cmp al, 4
|
|
|
|
|
ja @f
|
|
|
|
|
mov si, probetext-0x10000
|
|
|
|
|
call printplain
|
|
|
|
|
mov bx, '12'
|
|
|
|
|
call getkey
|
|
|
|
|
mov [preboot_gprobe-0x10000], al
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
_setcursor 10,0
|
|
|
|
|
jmp .d
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.change_b:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
_setcursor 15,0
|
|
|
|
|
mov si, gr_acc-0x10000
|
|
|
|
|
call print
|
|
|
|
|
mov bx, '12'
|
|
|
|
|
call getkey
|
|
|
|
|
mov [preboot_mtrr-0x10000], al
|
|
|
|
|
_setcursor 11,0
|
|
|
|
|
jmp .d
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.change_c:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
_setcursor 15,0
|
|
|
|
|
mov si, vrrmprint-0x10000
|
|
|
|
|
call print
|
|
|
|
|
mov bx, '12'
|
|
|
|
|
call getkey
|
|
|
|
|
mov [preboot_vrrm-0x10000], al
|
|
|
|
|
_setcursor 12,0
|
|
|
|
|
jmp .d
|
2006-01-25 16:19:21 +03:00
|
|
|
|
.say_on_off:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
pushf
|
|
|
|
|
call print
|
|
|
|
|
mov si, on_msg-0x10000
|
|
|
|
|
popf
|
|
|
|
|
jz @f
|
|
|
|
|
mov si, off_msg-0x10000
|
|
|
|
|
@@: call printplain
|
|
|
|
|
ret
|
2006-01-25 16:19:21 +03:00
|
|
|
|
; novesa and vervesa strings are not used at the moment of executing this code
|
|
|
|
|
virtual at novesa
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.oldtimer dd ?
|
|
|
|
|
.starttime dd ?
|
|
|
|
|
.bSettingsChanged db ?
|
2006-01-11 12:46:06 +03:00
|
|
|
|
.timer dd ?
|
2006-01-25 16:19:21 +03:00
|
|
|
|
end virtual
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.loader_block dd 0
|
|
|
|
|
.gettime:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov ah, 0
|
|
|
|
|
int 1Ah
|
|
|
|
|
xchg ax, cx
|
|
|
|
|
shl eax, 10h
|
|
|
|
|
xchg ax, dx
|
|
|
|
|
ret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.newtimer:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push ds
|
|
|
|
|
push cs
|
|
|
|
|
pop ds
|
|
|
|
|
pushf
|
|
|
|
|
call [.oldtimer-0x10000]
|
|
|
|
|
pushad
|
|
|
|
|
call .gettime
|
|
|
|
|
sub eax, [.starttime-0x10000]
|
|
|
|
|
sub ax, 18*5
|
|
|
|
|
jae .timergo
|
|
|
|
|
neg ax
|
|
|
|
|
add ax, 18-1
|
|
|
|
|
mov bx, 18
|
|
|
|
|
xor dx, dx
|
|
|
|
|
div bx
|
2005-12-14 11:09:29 +03:00
|
|
|
|
if lang eq ru
|
|
|
|
|
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 5 ᥪ㭤, 4/3/2 ᥪ㭤<EFBFBD>, 1 ᥪ㭤<EFBFBD>
|
2006-05-06 18:34:30 +04:00
|
|
|
|
cmp al, 5
|
|
|
|
|
mov cl, ' '
|
|
|
|
|
jae @f
|
|
|
|
|
cmp al, 1
|
|
|
|
|
mov cl, '<27>'
|
|
|
|
|
jz @f
|
|
|
|
|
mov cl, '<27>'
|
|
|
|
|
@@: mov [time_str+9-0x10000], cl
|
2005-12-14 11:09:29 +03:00
|
|
|
|
else
|
|
|
|
|
; wait 5/4/3/2 seconds, 1 second
|
2006-05-06 18:34:30 +04:00
|
|
|
|
cmp al, 1
|
|
|
|
|
mov cl, 's'
|
|
|
|
|
ja @f
|
|
|
|
|
mov cl, ' '
|
|
|
|
|
@@: mov [time_str+9-0x10000], cl
|
2005-12-14 11:09:29 +03:00
|
|
|
|
end if
|
2006-05-06 18:34:30 +04:00
|
|
|
|
add al, '0'
|
|
|
|
|
mov [time_str+1-0x10000], al
|
|
|
|
|
mov si, time_msg-0x10000
|
|
|
|
|
_setcursor 7,0
|
|
|
|
|
call print
|
|
|
|
|
_setcursor 25,0
|
|
|
|
|
popad
|
|
|
|
|
pop ds
|
|
|
|
|
iret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.timergo:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push 0
|
|
|
|
|
pop es
|
|
|
|
|
mov eax, [.oldtimer-0x10000]
|
|
|
|
|
mov [es:8*4], eax
|
|
|
|
|
mov sp, 0EC00h
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.continue:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
sti
|
|
|
|
|
_setcursor 6,0
|
|
|
|
|
mov si, space_msg-0x10000
|
|
|
|
|
call printplain
|
|
|
|
|
call printplain
|
|
|
|
|
_setcursor 6,0
|
|
|
|
|
mov si, loading_msg-0x10000
|
|
|
|
|
call print
|
|
|
|
|
_setcursor 15,0
|
|
|
|
|
cmp [.bSettingsChanged-0x10000], 0
|
|
|
|
|
jz .load
|
|
|
|
|
cmp [.loader_block-0x10000], 0
|
|
|
|
|
jz .load
|
|
|
|
|
les bx, [.loader_block-0x10000]
|
|
|
|
|
mov eax, [es:bx+3]
|
|
|
|
|
push ds
|
|
|
|
|
pop es
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz .load
|
|
|
|
|
push eax
|
|
|
|
|
mov si, save_quest-0x10000
|
|
|
|
|
call print
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.waityn:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov ah, 0
|
|
|
|
|
int 16h
|
|
|
|
|
or al, 20h
|
|
|
|
|
cmp al, 'n'
|
|
|
|
|
jz .loadc
|
|
|
|
|
cmp al, 'y'
|
|
|
|
|
jnz .waityn
|
|
|
|
|
call putchar
|
|
|
|
|
mov byte [space_msg-0x10000+80], 186
|
|
|
|
|
pop eax
|
|
|
|
|
push cs
|
|
|
|
|
push .cont-0x10000
|
|
|
|
|
push eax
|
|
|
|
|
retf
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.loadc:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
pop eax
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.cont:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push cs
|
|
|
|
|
pop ds
|
|
|
|
|
mov si, space_msg-0x10000
|
|
|
|
|
mov byte [si+80], 0
|
|
|
|
|
_setcursor 15,0
|
|
|
|
|
call printplain
|
|
|
|
|
_setcursor 15,0
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.load:
|
|
|
|
|
; \end{diamond}[02.12.2005]
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
; ASK GRAPHICS MODE
|
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
movzx ax, [preboot_graph-0x10000]
|
|
|
|
|
push 0
|
|
|
|
|
pop es
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; address is gr_table+6*(ax-1)-0x10000
|
2006-05-06 18:34:30 +04:00
|
|
|
|
add ax, ax
|
|
|
|
|
lea si, [gr_table-0x10000 + eax + eax*2 - 6]
|
2005-12-14 11:09:29 +03:00
|
|
|
|
mov bx,[si+0]
|
|
|
|
|
mov cx,[si+2]
|
|
|
|
|
mov dx,[si+4]
|
2006-05-06 18:34:30 +04:00
|
|
|
|
cmp al, 9*2
|
|
|
|
|
mov al, 32 ; BPP
|
|
|
|
|
jb @f
|
|
|
|
|
mov [es:0x9000], al
|
|
|
|
|
mov dword [es:0x9018], 0x800000
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2005-10-06 21:56:22 +04:00
|
|
|
|
mov [es:0x9008],bx
|
|
|
|
|
mov [es:0x900A],cx
|
|
|
|
|
mov [es:0x900C],dx
|
2006-05-06 18:34:30 +04:00
|
|
|
|
test bh, bh
|
|
|
|
|
jz nov
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
; USE DEFAULTS OR PROBE
|
|
|
|
|
|
|
|
|
|
; bx - mode : cx - x size : dx - y size
|
2006-05-06 18:34:30 +04:00
|
|
|
|
cmp [preboot_gprobe-0x10000], 1
|
|
|
|
|
jz noprobe
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
mov bx,0x100
|
|
|
|
|
newprobe:
|
|
|
|
|
inc bx
|
|
|
|
|
cmp bx,0x17f
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov si,prnotfnd-0x10000
|
|
|
|
|
jz sayerr
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
probemore:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push cx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
mov ax,0x4f01
|
|
|
|
|
mov cx,bx
|
|
|
|
|
and cx,0xfff
|
|
|
|
|
mov di,0xa000
|
|
|
|
|
int 0x10
|
2006-05-06 18:34:30 +04:00
|
|
|
|
pop cx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
test byte [es:di], 80h ; lfb?
|
|
|
|
|
jz newprobe
|
|
|
|
|
cmp [es:di+0x12], cx ; x size?
|
|
|
|
|
jnz newprobe
|
|
|
|
|
cmp [es:di+0x14], dx ; y size?
|
|
|
|
|
jnz newprobe
|
|
|
|
|
cmp byte [es:di+0x19], 32 ;24
|
|
|
|
|
jb newprobe
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
2006-01-25 16:19:21 +03:00
|
|
|
|
; add bx,0100000000000000b
|
2006-05-06 18:34:30 +04:00
|
|
|
|
or bh, 40h
|
2005-10-06 21:56:22 +04:00
|
|
|
|
mov [es:0x9008],bx
|
|
|
|
|
|
|
|
|
|
noprobe:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; FIND VESA 2.0 LFB & BPP
|
|
|
|
|
|
|
|
|
|
mov ax,0x4f01
|
|
|
|
|
mov cx,bx
|
|
|
|
|
and cx,0xfff
|
|
|
|
|
mov di,0xa000
|
|
|
|
|
int 0x10
|
|
|
|
|
; LFB
|
2006-01-25 16:19:21 +03:00
|
|
|
|
mov eax,[es:di+0x28]
|
|
|
|
|
mov [es:0x9018],eax
|
2005-10-06 21:56:22 +04:00
|
|
|
|
; ---- vbe voodoo
|
|
|
|
|
BytesPerScanLine equ 0x10
|
|
|
|
|
mov ax, [es:di+BytesPerScanLine]
|
|
|
|
|
mov [es:0x9001],ax
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; BPP
|
2006-01-25 16:19:21 +03:00
|
|
|
|
mov al,byte [es:di+0x19]
|
2005-12-14 11:09:29 +03:00
|
|
|
|
mov [es:0x9000],al
|
2005-10-06 21:56:22 +04:00
|
|
|
|
nov:
|
2006-01-25 16:19:21 +03:00
|
|
|
|
cmp al,24
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov si,bt24-0x10000
|
|
|
|
|
jz bppl
|
2006-01-25 16:19:21 +03:00
|
|
|
|
cmp al,32
|
2005-10-06 21:56:22 +04:00
|
|
|
|
mov si,bt32-0x10000
|
2005-12-14 11:09:29 +03:00
|
|
|
|
jz bppl
|
2005-10-06 21:56:22 +04:00
|
|
|
|
mov si,btns-0x10000
|
2006-05-06 18:34:30 +04:00
|
|
|
|
jmp sayerr
|
2005-10-06 21:56:22 +04:00
|
|
|
|
bppl:
|
2006-01-25 16:19:21 +03:00
|
|
|
|
call print
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; FIND VESA 1.2 PM BANK SWITCH ADDRESS
|
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push es
|
2005-10-06 21:56:22 +04:00
|
|
|
|
mov ax,0x4f0A
|
2006-05-06 18:34:30 +04:00
|
|
|
|
xor bx, bx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
int 0x10
|
|
|
|
|
xor eax,eax
|
|
|
|
|
mov ax,es
|
|
|
|
|
shl eax,4
|
2005-12-14 11:09:29 +03:00
|
|
|
|
movzx ebx,di
|
2005-10-06 21:56:22 +04:00
|
|
|
|
add eax,ebx
|
|
|
|
|
mov bx,[es:di]
|
|
|
|
|
add eax,ebx
|
|
|
|
|
pop es
|
|
|
|
|
mov [es:0x9014],eax
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; GRAPHICS ACCELERATION
|
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
mov al, [preboot_mtrr-0x10000]
|
2005-10-06 21:56:22 +04:00
|
|
|
|
mov [es:0x901C],al
|
|
|
|
|
|
|
|
|
|
; VRR_M USE
|
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
mov al,[preboot_vrrm-0x10000]
|
2005-10-06 21:56:22 +04:00
|
|
|
|
mov [es:0x9030],al
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; MEMORY MODEL
|
|
|
|
|
|
|
|
|
|
; movzx eax,byte [es:preboot_memory-0x10000]
|
|
|
|
|
; cmp eax,0
|
|
|
|
|
; jne pre_mem
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; mario79 - memory size ;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; mov ax,0E801h
|
|
|
|
|
;;; xor bx,bx ; thanks to Alexei for bugfix [18.07.2004]
|
|
|
|
|
; xor cx, cx
|
|
|
|
|
; xor dx, dx
|
|
|
|
|
; int 0x15
|
|
|
|
|
; movzx ebx, dx ;bx
|
|
|
|
|
; movzx eax, cx ;ax
|
|
|
|
|
; shl ebx,6 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (x64)
|
|
|
|
|
; add eax,ebx
|
|
|
|
|
; add eax, 1000h ;440h
|
|
|
|
|
; cmp eax,40000h ; 256?
|
|
|
|
|
; jge mem_256_z
|
|
|
|
|
; cmp eax,20000h ; 128?
|
|
|
|
|
; jge mem_128_z
|
|
|
|
|
; cmp eax,10000h ; 64?
|
|
|
|
|
; jge mem_64_z
|
|
|
|
|
; cmp eax,8000h ; 32?
|
|
|
|
|
; jge mem_32_z
|
|
|
|
|
; jmp mem_16_z
|
|
|
|
|
;
|
|
|
|
|
;mem_256_z: mov si,memokz256-0x10000
|
|
|
|
|
; call printplain
|
|
|
|
|
; mov eax,5
|
|
|
|
|
; jmp pre_mem
|
|
|
|
|
;mem_128_z: mov si,memokz128-0x10000
|
|
|
|
|
; call printplain
|
|
|
|
|
; mov eax,4
|
|
|
|
|
; jmp pre_mem
|
|
|
|
|
;mem_64_z: mov si,memokz64-0x10000
|
|
|
|
|
; call printplain
|
|
|
|
|
; mov eax,3
|
|
|
|
|
; jmp pre_mem
|
|
|
|
|
;mem_32_z: mov si,memokz32-0x10000
|
|
|
|
|
; call printplain
|
|
|
|
|
; mov eax,2
|
|
|
|
|
; jmp pre_mem
|
|
|
|
|
;mem_16_z: mov si,memokz16-0x10000
|
|
|
|
|
; call printplain
|
|
|
|
|
; mov eax,1
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; pre_mem:
|
|
|
|
|
; push word 0x0000
|
|
|
|
|
; pop es
|
|
|
|
|
; mov [es:0x9030],al
|
|
|
|
|
; push word 0x1000
|
|
|
|
|
; pop es
|
|
|
|
|
; mov si,linef-0x10000
|
|
|
|
|
; call printplain
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; DIRECT WRITE TO LFB, PAGING DISABLED
|
|
|
|
|
|
|
|
|
|
; movzx eax,byte [es:preboot_lfb-0x10000]
|
|
|
|
|
; mov eax,1 ; paging disabled
|
|
|
|
|
; cmp eax,0
|
|
|
|
|
; jne pre_lfb
|
|
|
|
|
; mov si,gr_direct-0x10000
|
|
|
|
|
; call printplain
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; mov ebx,'12'
|
2005-10-06 21:56:22 +04:00
|
|
|
|
; call getkey
|
|
|
|
|
; pre_lfb:
|
|
|
|
|
; push word 0x0000
|
|
|
|
|
; pop es
|
|
|
|
|
; mov [es:0x901E],al
|
|
|
|
|
; mov ax,0x1000
|
|
|
|
|
; mov es,ax
|
|
|
|
|
; mov si,linef-0x10000
|
|
|
|
|
; call printplain
|
|
|
|
|
mov [es:0x901E],byte 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; BOOT DEVICE
|
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov al, [preboot_device-0x10000]
|
2006-01-25 16:19:21 +03:00
|
|
|
|
dec al
|
2005-12-14 11:09:29 +03:00
|
|
|
|
mov [boot_dev-0x10000],al
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
; READ DISKETTE TO MEMORY
|
|
|
|
|
|
2006-01-25 16:19:21 +03:00
|
|
|
|
; cmp [boot_dev-0x10000],0
|
2005-10-06 21:56:22 +04:00
|
|
|
|
jne no_sys_on_floppy
|
|
|
|
|
mov si,diskload-0x10000
|
|
|
|
|
call print
|
2006-05-06 18:34:30 +04:00
|
|
|
|
xor ax, ax ; reset drive
|
|
|
|
|
xor dx, dx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
int 0x13
|
|
|
|
|
mov cx,0x0001 ; startcyl,startsector
|
2006-05-06 18:34:30 +04:00
|
|
|
|
xor dx, dx ; starthead,drive
|
2005-10-06 21:56:22 +04:00
|
|
|
|
push word 80*2 ; read no of sect
|
|
|
|
|
reads:
|
|
|
|
|
pusha
|
|
|
|
|
xor si,si
|
|
|
|
|
newread:
|
|
|
|
|
mov bx,0xa000 ; es:bx -> data area
|
|
|
|
|
mov ax,0x0200+18 ; read, no of sectors to read
|
|
|
|
|
int 0x13
|
2006-05-06 18:34:30 +04:00
|
|
|
|
test ah, ah
|
2005-10-06 21:56:22 +04:00
|
|
|
|
jz goodread
|
2006-05-06 18:34:30 +04:00
|
|
|
|
inc si
|
2005-10-06 21:56:22 +04:00
|
|
|
|
cmp si,10
|
|
|
|
|
jnz newread
|
|
|
|
|
mov si,badsect-0x10000
|
2006-01-25 16:19:21 +03:00
|
|
|
|
sayerr_plain:
|
2005-10-06 21:56:22 +04:00
|
|
|
|
call printplain
|
|
|
|
|
jmp $
|
|
|
|
|
goodread:
|
|
|
|
|
; move -> 1mb
|
|
|
|
|
mov si,movedesc-0x10000
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push es
|
|
|
|
|
push ds
|
2005-10-06 21:56:22 +04:00
|
|
|
|
pop es
|
|
|
|
|
mov cx,256*18
|
|
|
|
|
mov ah,0x87
|
|
|
|
|
int 0x15
|
2006-05-06 18:34:30 +04:00
|
|
|
|
pop es
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
test ah,ah ; was the move successfull ?
|
2005-10-06 21:56:22 +04:00
|
|
|
|
je goodmove
|
|
|
|
|
mov dx,0x3f2 ; floppy motor off
|
|
|
|
|
mov al,0
|
|
|
|
|
out dx,al
|
|
|
|
|
mov si,memmovefailed-0x10000
|
2006-05-06 18:34:30 +04:00
|
|
|
|
jmp sayerr_plain
|
2005-10-06 21:56:22 +04:00
|
|
|
|
goodmove:
|
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
add dword [movedesc-0x10000+0x18+2], 512*18
|
2005-10-06 21:56:22 +04:00
|
|
|
|
popa
|
|
|
|
|
inc dh
|
|
|
|
|
cmp dh,2
|
|
|
|
|
jnz bb2
|
|
|
|
|
mov dh,0
|
|
|
|
|
inc ch
|
|
|
|
|
pusha ; print prosentage
|
|
|
|
|
mov si,pros-0x10000
|
2006-05-06 18:34:30 +04:00
|
|
|
|
shr ch, 2
|
|
|
|
|
mov al, '5'
|
|
|
|
|
test ch, 1
|
|
|
|
|
jnz @f
|
|
|
|
|
mov al, '0'
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
mov [si+1], al
|
|
|
|
|
shr ch, 1
|
|
|
|
|
add ch, '0'
|
|
|
|
|
mov [si], ch
|
2005-10-06 21:56:22 +04:00
|
|
|
|
call printplain
|
|
|
|
|
popa
|
|
|
|
|
bb2:
|
|
|
|
|
pop ax
|
|
|
|
|
dec ax
|
|
|
|
|
push ax
|
2005-12-14 11:09:29 +03:00
|
|
|
|
jnz reads
|
2005-10-06 21:56:22 +04:00
|
|
|
|
readdone:
|
|
|
|
|
pop ax
|
2006-01-25 16:19:21 +03:00
|
|
|
|
mov si,backspace2-0x10000
|
2005-10-06 21:56:22 +04:00
|
|
|
|
call printplain
|
|
|
|
|
mov si,okt-0x10000
|
|
|
|
|
call printplain
|
|
|
|
|
no_sys_on_floppy:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
xor ax, ax ; reset drive
|
|
|
|
|
xor dx, dx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
int 0x13
|
|
|
|
|
mov dx,0x3f2 ; floppy motor off
|
|
|
|
|
mov al,0
|
2005-12-14 11:09:29 +03:00
|
|
|
|
out dx,al
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push es
|
2005-10-06 21:56:22 +04:00
|
|
|
|
; PAGE TABLE
|
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push dword [es:0x9018]
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
map_mem equ 64 ; amount of memory to map
|
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push 0x6000
|
|
|
|
|
pop es ; es:di = 6000:0
|
2005-12-14 11:09:29 +03:00
|
|
|
|
xor di,di
|
|
|
|
|
mov cx,256*map_mem ; Map (mapmem) M
|
2006-01-25 16:19:21 +03:00
|
|
|
|
; mov eax,7
|
|
|
|
|
; pt2:
|
|
|
|
|
; cmp cx,256*(map_mem-8) ; 8 M map to LFB
|
|
|
|
|
; jnz pt3
|
|
|
|
|
; pop eax
|
|
|
|
|
; add eax,7
|
|
|
|
|
; pt3:
|
|
|
|
|
; cmp cx,256*(map_mem-12) ; 12 M back to linear = physical
|
|
|
|
|
; jnz pt4
|
|
|
|
|
; mov eax,12*0x100000 + 7
|
|
|
|
|
; pt4:
|
|
|
|
|
; stosd
|
|
|
|
|
; add eax,4096
|
|
|
|
|
; loop pt2
|
|
|
|
|
; initialize as identity mapping
|
2006-05-06 18:34:30 +04:00
|
|
|
|
xor eax, eax
|
|
|
|
|
call pagetable_set
|
2006-01-25 16:19:21 +03:00
|
|
|
|
; 8M..12M map to LFB
|
2006-05-06 18:34:30 +04:00
|
|
|
|
pop eax
|
|
|
|
|
; mov cx, 256*4
|
|
|
|
|
mov ch, 4
|
|
|
|
|
mov di, 2000h
|
|
|
|
|
call pagetable_set
|
|
|
|
|
|
|
|
|
|
push 0x7100
|
|
|
|
|
pop es
|
2005-12-14 11:09:29 +03:00
|
|
|
|
xor di,di
|
2006-01-25 16:19:21 +03:00
|
|
|
|
mov eax,8*0x100000
|
2005-12-14 11:09:29 +03:00
|
|
|
|
mov cx,256*4
|
2006-05-06 18:34:30 +04:00
|
|
|
|
call pagetable_set
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
; 4 KB PAGE DIRECTORY
|
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push 0x7F00
|
|
|
|
|
pop es ; es:di = 7F00:0
|
2005-12-14 11:09:29 +03:00
|
|
|
|
xor di, di
|
|
|
|
|
mov cx, 64 / 4
|
2005-10-06 21:56:22 +04:00
|
|
|
|
mov eax, 0x60007 ; for 0 M
|
2006-05-06 18:34:30 +04:00
|
|
|
|
call pagetable_set
|
2005-10-06 21:56:22 +04:00
|
|
|
|
mov dword [es:0x800],0x71007 ;map region 0x80000000-0x803FFFFF to 0x800000-0xCFFFFF
|
2005-12-14 11:09:29 +03:00
|
|
|
|
xor si,si
|
|
|
|
|
mov di,second_base_address shr 20
|
2006-01-25 16:19:21 +03:00
|
|
|
|
mov cx,64/2
|
|
|
|
|
rep movs word [es:di], [es:si]
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
mov eax, 0x7F000 +8+16 ; Page directory and enable caches
|
|
|
|
|
mov cr3, eax
|
|
|
|
|
|
|
|
|
|
; SET GRAPHICS
|
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
pop es
|
|
|
|
|
mov ax,[es:0x9008] ; vga & 320x200
|
|
|
|
|
mov bx, ax
|
2005-10-06 21:56:22 +04:00
|
|
|
|
cmp ax,0x13
|
|
|
|
|
je setgr
|
|
|
|
|
cmp ax,0x12
|
|
|
|
|
je setgr
|
|
|
|
|
mov ax,0x4f02 ; Vesa
|
|
|
|
|
setgr:
|
|
|
|
|
int 0x10
|
2006-05-06 18:34:30 +04:00
|
|
|
|
test ah,ah
|
|
|
|
|
mov si, fatalsel-0x10000
|
|
|
|
|
jnz sayerr
|
2005-10-06 21:56:22 +04:00
|
|
|
|
; set mode 0x12 graphics registers:
|
|
|
|
|
cmp bx,0x12
|
|
|
|
|
jne gmok2
|
|
|
|
|
|
|
|
|
|
mov al,0x05
|
|
|
|
|
mov dx,0x03ce
|
2006-01-25 16:19:21 +03:00
|
|
|
|
push dx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
out dx,al ; select GDC mode register
|
|
|
|
|
mov al,0x02
|
2006-05-06 18:34:30 +04:00
|
|
|
|
inc dx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
out dx,al ; set write mode 2
|
|
|
|
|
|
|
|
|
|
mov al,0x02
|
|
|
|
|
mov dx,0x03c4
|
|
|
|
|
out dx,al ; select VGA sequencer map mask register
|
|
|
|
|
mov al,0x0f
|
2006-05-06 18:34:30 +04:00
|
|
|
|
inc dx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
out dx,al ; set mask for all planes 0-3
|
|
|
|
|
|
|
|
|
|
mov al,0x08
|
2006-05-06 18:34:30 +04:00
|
|
|
|
pop dx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
out dx,al ; select GDC bit mask register
|
|
|
|
|
; for writes to 0x03cf
|
|
|
|
|
|
|
|
|
|
gmok2:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push ds
|
|
|
|
|
pop es
|