Import backup from 2003-08-17
This commit is contained in:
parent
149541fbf1
commit
43f3ea24f8
@ -15,7 +15,8 @@
|
||||
%define BOOT_VESA 0x0002 ;2 - 0 for console, otherwise VESA mode
|
||||
%define BOOT_VESA_OEM 0x0004 ;258 - null-terminated OEM identification string
|
||||
%define BOOT_VESA_VBE 0x0106 ;512 - copy of VESA VBEInfoBlock
|
||||
;%define BOOT_ 0x0306
|
||||
%define BOOT_VESA_INFO 0x0306 ;256 - copy of VESA ModeInfoBlock for selected mode
|
||||
%define BOOT_VESA_LFB 0x0406 ;1 - boolean: are we using LFB or not
|
||||
|
||||
|
||||
|
||||
|
300
stage2.asm
300
stage2.asm
@ -290,7 +290,7 @@ vesa_copyvbe:
|
||||
mov si, dx
|
||||
shr edx, 16
|
||||
mov ds, dx ;ds:si points to video mode list
|
||||
mov ax, GOOD_MODELIST_SEG
|
||||
mov ax, VESA_MODELIST_SEG
|
||||
mov es, ax
|
||||
xor di, di
|
||||
vesa_copymodes:
|
||||
@ -311,21 +311,181 @@ clear_good_mode_list_loop:
|
||||
mov ax, VESA_MODELIST_SEG
|
||||
mov ds, ax
|
||||
xor si, si ;ds:si points to video mode list where we can edit it :)
|
||||
mov ax, GOOD_MODELIST_SEG
|
||||
mov es, ax
|
||||
xor di, di
|
||||
xor dx, dx ;dx=what good mode # we are on
|
||||
vesa_readmodeinfo_loop:
|
||||
lodsw
|
||||
cmp ax, 0xffff
|
||||
jz vesa_endofmodes
|
||||
push ax ;save mode#
|
||||
call checkmode
|
||||
cmp ax, 0
|
||||
jz vesa_readmodeinfo_good
|
||||
pop ax
|
||||
jmp vesa_readmodeinfo_loop
|
||||
vesa_readmodeinfo_good:
|
||||
pop ax ;restore mode#
|
||||
stosw
|
||||
call vesa_showmodeinfo
|
||||
inc dx
|
||||
jmp vesa_readmodeinfo_loop
|
||||
|
||||
vesa_endofmodes: ;here we have a list of good modes at GOOD_MODELIST_SEG:0
|
||||
xor ax, ax
|
||||
mov ds, ax
|
||||
mov si, txt_consolemode
|
||||
mov ax, 0xb800
|
||||
mov es, ax
|
||||
mov di, 160*2
|
||||
mov ah, 7
|
||||
call puts
|
||||
mov di, 160*3
|
||||
mov cx, dx
|
||||
mov al, 'b'
|
||||
vesa_displaylabels:
|
||||
stosb
|
||||
push ax
|
||||
mov al, 7
|
||||
stosb
|
||||
mov al, '.'
|
||||
stosb
|
||||
mov al, 7
|
||||
stosb
|
||||
pop ax
|
||||
inc al
|
||||
add di, 160-4
|
||||
loop vesa_displaylabels ;done drawing screen of VESA choices, now ask for one
|
||||
;valid options are 'a' through (al-1)
|
||||
mov bl, al
|
||||
xor ax, ax
|
||||
mov ds, ax
|
||||
mov di, 160*24
|
||||
mov si, txt_input
|
||||
mov ah, 14
|
||||
call puts
|
||||
vesa_getchoice:
|
||||
xor ax, ax
|
||||
int 0x16
|
||||
cmp al, 'a'
|
||||
jl vesa_getchoice
|
||||
cmp al, bl
|
||||
jge vesa_getchoice
|
||||
stosb
|
||||
push ax
|
||||
mov al, 14
|
||||
stosb
|
||||
pop ax
|
||||
xor ah, ah
|
||||
sub ax, 'a'
|
||||
cmp ax, 0
|
||||
jz vesa_consolemode_only
|
||||
mov cx, ax ;cx holds good mode# (1=first good vesa mode)
|
||||
dec cx
|
||||
mov ax, GOOD_MODELIST_SEG
|
||||
mov ds, ax
|
||||
shl cx, 1
|
||||
mov si, cx ;ds:si points to word containing selected mode#
|
||||
lodsw
|
||||
mov cx, ax
|
||||
|
||||
mov ax, VESA_MODEINFO_SEG
|
||||
mov es, ax
|
||||
xor di, di
|
||||
lodsw
|
||||
cmp ax, 0xffff
|
||||
jnz vesa_notendofmodes
|
||||
jmp vesa_endofmodes
|
||||
vesa_notendofmodes:
|
||||
mov cx, ax
|
||||
mov ax, 0x4F01
|
||||
int 0x10
|
||||
call checkvesa
|
||||
xor di, di ;es:di -> ModeInfoBlock struc, ds:si -> video mode list
|
||||
|
||||
mov dx, 20
|
||||
call vesa_showmodeinfo
|
||||
|
||||
|
||||
vesa_consolemode_only:
|
||||
|
||||
jmp vesa_done
|
||||
|
||||
;------------------------------------------------------
|
||||
vesa_showmodeinfo:
|
||||
pusha
|
||||
push es
|
||||
push ds
|
||||
mov ax, VESA_MODEINFO_SEG
|
||||
mov ds, ax
|
||||
xor si, si
|
||||
mov ax, 0xb800
|
||||
mov es, ax
|
||||
|
||||
mov cx, dx
|
||||
|
||||
mov ax, 160
|
||||
mul dx ;ax=160*mod#
|
||||
add ax, 160*3+6 ;offset first line of modes and room on left for label
|
||||
mov di, ax
|
||||
|
||||
mov ax, [ds:18]
|
||||
call console_putDec
|
||||
add di, 10
|
||||
mov al, 'x'
|
||||
call console_putChar
|
||||
inc di
|
||||
inc di
|
||||
mov ax, [ds:20]
|
||||
call console_putDec
|
||||
add di, 10
|
||||
mov al, 'x'
|
||||
call console_putChar
|
||||
inc di
|
||||
inc di
|
||||
xor ah, ah
|
||||
mov al, [ds:25]
|
||||
call console_putDec
|
||||
add di, 8
|
||||
mov al, [ds:0]
|
||||
test al, 0x80
|
||||
jz vesa_showmodeinfo_done
|
||||
mov al, 'L'
|
||||
call console_putChar
|
||||
mov al, 'F'
|
||||
call console_putChar
|
||||
mov al, 'B'
|
||||
call console_putChar
|
||||
inc di
|
||||
inc di
|
||||
mov ebx, [ds:40]
|
||||
mov eax, ebx
|
||||
shr eax, 24
|
||||
call puthex2
|
||||
mov eax, ebx
|
||||
shr eax, 16
|
||||
call puthex2
|
||||
mov al, bh
|
||||
call puthex2
|
||||
mov al, bl
|
||||
call puthex2
|
||||
vesa_showmodeinfo_done:
|
||||
pop ds
|
||||
pop es
|
||||
popa
|
||||
ret
|
||||
|
||||
;------------------------------------------------------
|
||||
checkmode:
|
||||
push bx
|
||||
push cx
|
||||
push dx
|
||||
push es
|
||||
push ds
|
||||
push di
|
||||
push si
|
||||
mov cx, ax ;cx=modenumber
|
||||
mov ax, VESA_MODEINFO_SEG
|
||||
mov es, ax
|
||||
xor di, di
|
||||
mov ax, 0x4F01
|
||||
int 0x10
|
||||
call checkvesa
|
||||
xor di, di ;es:di -> ModeInfoBlock struc
|
||||
mov ax, [es:di] ;ModeAttributes
|
||||
test al, 1 ;mode supported
|
||||
jz vesa_modenogood
|
||||
@ -333,6 +493,14 @@ vesa_notendofmodes:
|
||||
jz vesa_modenogood
|
||||
test al, 0x10 ;graphics mode
|
||||
jz vesa_modenogood
|
||||
mov al, [es:di+25] ;BitsPerPixel
|
||||
cmp al, 16
|
||||
jz vesa_bppok
|
||||
cmp al, 24
|
||||
jz vesa_bppok
|
||||
cmp al, 32
|
||||
jnz vesa_modenogood
|
||||
vesa_bppok:
|
||||
mov ax, [es:di+18] ;XResolution
|
||||
mov bx, [es:di+20] ;YResolution
|
||||
cmp ax, 640 ;640x480
|
||||
@ -366,24 +534,25 @@ res_goon4:
|
||||
cmp bx, 1200
|
||||
jnz vesa_modenogood
|
||||
vesa_modegood:
|
||||
mov ax, 0xb800
|
||||
mov es, ax
|
||||
mov ax, 160
|
||||
push dx
|
||||
mul dx ;ax=160*#ofgoodmode
|
||||
pop si
|
||||
pop di
|
||||
pop ds
|
||||
pop es
|
||||
pop dx
|
||||
add ax, 160*2
|
||||
|
||||
|
||||
|
||||
jmp vesa_readmodeinfo_loop
|
||||
pop cx
|
||||
pop bx
|
||||
xor ax, ax
|
||||
ret
|
||||
vesa_modenogood:
|
||||
mov word [ds:si], 0
|
||||
jmp vesa_readmodeinfo_loop
|
||||
|
||||
vesa_endofmodes:
|
||||
|
||||
|
||||
pop si
|
||||
pop di
|
||||
pop ds
|
||||
pop es
|
||||
pop dx
|
||||
pop cx
|
||||
pop bx
|
||||
mov ax, 0xffff
|
||||
ret
|
||||
|
||||
;------------------------------------------------------
|
||||
vesa_done:
|
||||
@ -393,6 +562,7 @@ vesa_done:
|
||||
|
||||
jmp go_pm
|
||||
|
||||
;------------------------------------------------------
|
||||
puts:
|
||||
lodsb
|
||||
or al, al
|
||||
@ -404,6 +574,7 @@ puts:
|
||||
puts_done:
|
||||
ret
|
||||
|
||||
;------------------------------------------------------
|
||||
checkvesa:
|
||||
cmp ax, 0x004F
|
||||
jnz vesaerror
|
||||
@ -420,6 +591,85 @@ vesaerror:
|
||||
cli
|
||||
hlt
|
||||
|
||||
;-------Function console_putDec
|
||||
;input:
|
||||
; AX = number to display
|
||||
;output:
|
||||
; number written in decimal to es:di
|
||||
console_putDec:
|
||||
pusha
|
||||
xor dx, dx
|
||||
xor bh, bh ;no characters written yet
|
||||
mov cx, 10000
|
||||
div cx ;ax=quotiont, dx=remainder
|
||||
add ax, '0'
|
||||
cmp ax, '0'
|
||||
je .goon1
|
||||
call console_putChar
|
||||
mov bh, 1
|
||||
|
||||
.goon1:
|
||||
mov ax, dx ;load remainder to ax
|
||||
xor dx, dx
|
||||
mov cx, 1000
|
||||
div cx ;ax=quotiont, dx=remainder
|
||||
add ax, '0'
|
||||
cmp ax, '0'
|
||||
je .goon11
|
||||
call console_putChar
|
||||
mov bh, 1
|
||||
jmp .goon2
|
||||
.goon11:
|
||||
cmp bh, 0
|
||||
je .goon2
|
||||
call console_putChar
|
||||
|
||||
.goon2:
|
||||
mov ax, dx ;load remainder to ax
|
||||
xor dx, dx
|
||||
mov cx, 100
|
||||
div cx ;ax=quotiont, dx=remainder
|
||||
add ax, '0'
|
||||
cmp ax, '0'
|
||||
je .goon21
|
||||
call console_putChar
|
||||
mov bh, 1
|
||||
jmp .goon3
|
||||
.goon21:
|
||||
cmp bh, 0
|
||||
je .goon3
|
||||
call console_putChar
|
||||
|
||||
.goon3:
|
||||
mov ax, dx ;load remainder to ax
|
||||
xor dx, dx
|
||||
mov cx, 10
|
||||
div cx ;ax=quotiont, dx=remainder
|
||||
add ax, '0'
|
||||
cmp ax, '0'
|
||||
je .goon31
|
||||
call console_putChar
|
||||
mov bh, 1
|
||||
jmp .goon4
|
||||
.goon31:
|
||||
cmp bh, 0
|
||||
je .goon4
|
||||
call console_putChar
|
||||
.goon4: ;here dx contains last remainder
|
||||
mov ax, dx
|
||||
add ax, '0'
|
||||
call console_putChar
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
;------------------------------------------------------
|
||||
console_putChar:
|
||||
stosb
|
||||
mov al, 7
|
||||
stosb
|
||||
ret
|
||||
|
||||
;------------------------------------------------------
|
||||
puthex:
|
||||
;es:di points to video memory
|
||||
@ -494,6 +744,7 @@ txt_vesa: db "VESA version: ", 0
|
||||
txt_vesaerror: db "VESA function call error! Halting system!", 0
|
||||
txt_novesa: db "VESA not found. Starting in console mode...", 0
|
||||
txt_vesaold: db "VESA version 2.0 required. Starting in console mode...", 0
|
||||
txt_consolemode: db "a. Console mode only.", 0
|
||||
|
||||
;------------------------------------------------------
|
||||
getCHSfromCluster:
|
||||
@ -542,6 +793,7 @@ KERNEL_DATA equ $-gdt
|
||||
|
||||
gdt_end:
|
||||
|
||||
;------------------------------------------------------
|
||||
go_pm:
|
||||
xor ax, ax
|
||||
mov ds, ax
|
||||
|
Loading…
x
Reference in New Issue
Block a user