diff --git a/bootdef.inc b/bootdef.inc index 6a6b962..bb5c3f9 100644 --- a/bootdef.inc +++ b/bootdef.inc @@ -15,7 +15,7 @@ %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_ 0x0306 diff --git a/idt.inc b/idt.inc index c2163fa..511211c 100644 --- a/idt.inc +++ b/idt.inc @@ -1,6 +1,6 @@ idtr: - dw 49*8-1 ;size of idt + dw 50*8-1 ;size of idt dd IDT ;address of idt diff --git a/kernel.asm b/kernel.asm index 7f32c79..14475bd 100644 --- a/kernel.asm +++ b/kernel.asm @@ -23,7 +23,7 @@ copy_gdt: mov edi, IDT ;destination mov esi, isr_0 ;address of isr0 mov edx, isr_1-isr_0 ;distance between isr labels - mov ecx, 49 ;number of isrlabels + mov ecx, 50 ;number of isrlabels fill_idt: mov ebx, esi mov ax, si diff --git a/kernel.c b/kernel.c index ba4795f..c7b1ba5 100644 --- a/kernel.c +++ b/kernel.c @@ -27,7 +27,7 @@ void isr(int num) { (*(char*)0xB8000)++; *(char*)0xB8001 = 7; + eoi(); } - eoi(); } diff --git a/stage2.asm b/stage2.asm index 892f940..b928d87 100644 --- a/stage2.asm +++ b/stage2.asm @@ -1,6 +1,10 @@ %include "bootdef.inc" +%define VESA_MODEINFO_SEG 0x0120 +%define VESA_MODELIST_SEG 0x0140 +%define GOOD_MODELIST_SEG 0x0160 + [bits 16] org BOOT_STAGE2_ADD @@ -286,6 +290,98 @@ vesa_copyvbe: mov si, dx shr edx, 16 mov ds, dx ;ds:si points to video mode list + mov ax, GOOD_MODELIST_SEG + mov es, ax + xor di, di +vesa_copymodes: + lodsw + stosw + cmp ax, 0xffff + jnz vesa_copymodes + + mov ax, GOOD_MODELIST_SEG + mov es, ax + xor di, di + mov cx, 256 + mov ax, 0xffff +clear_good_mode_list_loop: + stosw + loop 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 :) + xor dx, dx ;dx=what good mode # we are on +vesa_readmodeinfo_loop: + 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 ax, [es:di] ;ModeAttributes + test al, 1 ;mode supported + jz vesa_modenogood + test al, 8 ;color mode + jz vesa_modenogood + test al, 0x10 ;graphics mode + jz vesa_modenogood + mov ax, [es:di+18] ;XResolution + mov bx, [es:di+20] ;YResolution + cmp ax, 640 ;640x480 + jnz res_goon1 + cmp bx, 480 + jnz vesa_modenogood + jmp vesa_modegood +res_goon1: + cmp ax, 800 + jnz res_goon2 + cmp bx, 600 + jnz vesa_modenogood + jmp vesa_modegood +res_goon2: + cmp ax, 1024 + jnz res_goon3 + cmp bx, 768 + jnz vesa_modenogood + jmp vesa_modegood +res_goon3: + cmp ax, 1280 + jnz res_goon4 + cmp bx, 1024 + jz vesa_modegood + cmp bx, 960 + jz vesa_modegood + jmp vesa_modenogood +res_goon4: + cmp ax, 1600 + jnz vesa_modenogood + 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 dx + add ax, 160*2 + + + + jmp vesa_readmodeinfo_loop +vesa_modenogood: + mov word [ds:si], 0 + jmp vesa_readmodeinfo_loop + +vesa_endofmodes: @@ -358,6 +454,7 @@ puthex_goon2: pop ax ret +;------------------------------------------------------ puthex2: ;es:di points to video memory, always displays 2 characters! ;al holds hex value