Page 1 of 1

Problem with LFB

Posted: Thu Apr 06, 2006 2:55 pm
by Lazarus
Hi,

i tried to enable VESA mode 4118h (LFB!) and it doesn't work well :(

I use this code to fill the screen with a certain color:

Code: Select all

   mov edi, [VbeModePhysBasePtr]       
   mov ecx, 1024*768
   mov eax, 0xff408080
   rep stosd
The problem is that the first 1/3 of the screen is colored, the 2/3 is just black and the 3/3 is colored, too. ???

This is the whole code:

Code: Select all

start:
   mov ax, cs
   mov ds, ax
   mov es, ax

   call enable_a20

   ;VESA vorhanden?
   mov ax, 4f00h
   mov di, VbeInfoBlock
   int 10h

   cmp ax, 004Fh
   jne short novesa

   ;VESA initialisieren
   mov ax, 4F01h
   mov di, VbeModeInfoBlock
   mov cx, 0x4118
   int 10h

   cmp dword [VbeSignature], 'VESA'
   jne short novesa

   cmp byte [VbeVersion+1], 2
   jb short novesa

   ;Setze Aufl?sung (1024x768x24 LFB)
   mov ax, 0x4F02
   mov bx, 0x4118
   int 10h  

   jmp short kernel16

novesa:
   jmp $

kernel16:
   xor ebx, ebx
   mov bx, ds                       ; Bx ist das Segment
   shl ebx, 4                       ; Bx ist die lineare Addresse des Segments
   mov eax, ebx

   mov [gdt2 + 2], ax               ; Setze Addresse des 32-bit Segments
   mov [gdt3 + 2], ax
   mov [gdt4 + 2], ax               ; Setze Addresse des 32-bit Segments
   mov [gdt5 + 2], ax

   shr eax, 16

   mov [gdt2 + 4], al
   mov [gdt3 + 4], al
   mov [gdt4 + 4], al
   mov [gdt5 + 4], al

   mov [gdt2 + 7], ah
   mov [gdt3 + 7], ah
   mov [gdt4 + 7], ah
   mov [gdt5 + 7], ah

        lea eax,[gdt + ebx]             ; Eax ist die physikalische Adresse der GDT
        mov [gdtr + 2],eax

   cli

   lgdt [gdtr]         ; Die GDTR mit der Adresse laden und dem Limit der GDT

   mov eax, cr0         ; Setze das PE Bit im Register CR0 ...
   or al, 1
   mov cr0, eax         ; ... und wechsel dadurch in den Protected Mode

   jmp SYS_CODE_SEL:kernel32   ; Springe zum 32-bit Kernel


[BITS 32]

kernel32:
        xor edi,edi
        xor esi,esi

   mov ax,SYS_DATA_SEL
   mov ds,ax
   mov ss,ax

   mov ax,LINEAR_SEL
   mov es,ax

   mov edi, [VbeModePhysBasePtr]       
   mov ecx, 1024*768
   mov eax, 0xff408080
   rep stosd

   jmp $
I don't know whats wrong... LFB is enabled, but why is only the 2/3 of screen black?!

MfG, Prometheus

Re:Problem with LFB

Posted: Thu Apr 06, 2006 3:46 pm
by Lazarus
OMG, i just used another A20 routine and it worked 8)

@Mods: Please close ;)

Re:Problem with LFB

Posted: Sat Apr 08, 2006 11:20 am
by Dex4u
Not so fast ;), a little warning some vesa use 24bit and some use 32bit, you need to check BPP for 24 or 32 and jump to the right code, if not some code will have black line down the screen.
32bits = XRGBXRGB
24bits = RGBRGB
X = 00
R = red
G = green
B = blue
You have been warned :).