flat assembler
Message board for the users of flat assembler.

Index > OS Construction > VESA -> LFB

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 27 Jan 2005, 14:16
hello everybody!

i've got a problem with the LFB in VESA. i'd like to enable VESA with the LFB. in bochs it works fine, but not so in real! first i search the list of available modes for a most good mode for the OS to work and supported. after finding it, i write it into "vesa_mode". later while setting, i load bx with "vesa_mode", add 0x4000 and then enable it. i do it like this:

Code:
;set vesamode
mov bx,[vesa_mode]
add bx,0x4000
mov ax,0x4F02
int 0x10 
    


but it doesn't run well. it runs with bochs, but not in real, as i already said. it's because i take the PhysBasePtr and write to it later and with that i can only use a small part on the top and not more. so i think it's 0xA0000 and working with bankswitchmethod... but i shouldn't...

in hope about help,

J!N
Post 27 Jan 2005, 14:16
View user's profile Send private message Visit poster's website Reply with quote
ASHLEY4



Joined: 28 Apr 2004
Posts: 376
Location: UK
ASHLEY4 27 Jan 2005, 17:03
One thing you should try is to enable A20, as with out it it will not fill the screen at high res .

_________________
\\\\||////
(@@)
ASHLEY4.

Batteries not included, Some assembly required.
Post 27 Jan 2005, 17:03
View user's profile Send private message Reply with quote
Octavio



Joined: 21 Jun 2003
Posts: 366
Location: Spain
Octavio 27 Jan 2005, 17:07
try without ' add bx,4000h' ,real hardware is not very standard.
also you must use function 1 to get videomode info struct and read
the video memory ptr at offset 28h
Post 27 Jan 2005, 17:07
View user's profile Send private message Visit poster's website Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 27 Jan 2005, 19:07
@octavio: without "add bx,0x4000" it won't work, because that sets the bit which has to be set for LFB. and as i already said am i loading the VideoMemPtr (aka PhysBasePtr) but there's only the adress of the first window in 0xA0000.
@ashley4: thank you. i don't realy understand what you're writing but i understand that i should enable A20-Gate first. i'll try it.
Post 27 Jan 2005, 19:07
View user's profile Send private message Visit poster's website Reply with quote
ASHLEY4



Joined: 28 Apr 2004
Posts: 376
Location: UK
ASHLEY4 27 Jan 2005, 19:47

_________________
\\\\||////
(@@)
ASHLEY4.

Batteries not included, Some assembly required.
Post 27 Jan 2005, 19:47
View user's profile Send private message Reply with quote
Octavio



Joined: 21 Jun 2003
Posts: 366
Location: Spain
Octavio 27 Jan 2005, 20:05
joachim_neu wrote:
@octavio: without "add bx,0x4000" it won't work, because that sets the bit which has to be set for LFB. and as i already said am i loading the VideoMemPtr (aka PhysBasePtr) but there's only the adress of the first window in 0xA0000.
@ashley4: thank you. i don't realy understand what you're writing but i understand that i should enable A20-Gate first. i'll try it.

it works on my computers,and you are reading the videomemptr at the wrong place.
Post 27 Jan 2005, 20:05
View user's profile Send private message Visit poster's website Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 27 Jan 2005, 20:20
@octavio: realy? it sets the mode with LFB without adding 0x4000? i'll test it, too! but i read the pointer from the right place. it's not shown in the exaplecode, but i load it from offset 40d =0x28, and if this'd be wrong, it wouldn't run in bochs!
@ashley4: i'll have a look at it.
Post 27 Jan 2005, 20:20
View user's profile Send private message Visit poster's website Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 27 Jan 2005, 20:40
@ashley4: first: the link you gave me didn't help me... second: it still doesn't work, if i enable A20-gate earliear!
Post 27 Jan 2005, 20:40
View user's profile Send private message Visit poster's website Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 28 Jan 2005, 03:51
BTW IF you enable LFB it is NEVER going to be at 0xA0000h .
Practically is almost always above the 2Gigabyte limit. Older boards are above 1Giga byte .

IF the LFB address is ok and IF you can only fill the top area of the screen
THEN the video mode is banked (ie it has no LFB) so you must use a bank switching routine that is always video board dependent.

Are you sure that the video bard is VESA 2.0 and NOT VESA 1.2 compatible?
Post 28 Jan 2005, 03:51
View user's profile Send private message Visit poster's website Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 28 Jan 2005, 08:50
@bog.: i know! often it's set to 0xe0000000, but because it's set to 0xA0000 i noticed, that something went wrong! i'm sure that it supports LFB , because MenuetOS runs with the same mode (0x115) in linearframebuffer (so the mode is 0x4115).
Post 28 Jan 2005, 08:50
View user's profile Send private message Visit poster's website Reply with quote
ASHLEY4



Joined: 28 Apr 2004
Posts: 376
Location: UK
ASHLEY4 28 Jan 2005, 16:26
Your put pixel code, can you post it, as you maybe doing stosb instead of stosd.

And do you do a:
Code:
cmp ax,004Fhjne VesaError    

After doing a set vesa mode ?.

_________________
\\\\||////
(@@)
ASHLEY4.

Batteries not included, Some assembly required.
Post 28 Jan 2005, 16:26
View user's profile Send private message Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 28 Jan 2005, 20:03
@ashley4: i'm not always doing a "cmp ax,004Fh; jne VesaError", only after the check if VESA is availible. i test this things not with a function, but with this: "mov edi,[BasePhys];mov ecx,0x200000;mov al,0x88;rep stosb" in BasePhys i wrote the PhysicalBaseAdress. so then i set ecx to 0x200000 (for 2 MB) which must be 2/3 of the 0x118-mode oder all of the 0x115-mode.
Post 28 Jan 2005, 20:03
View user's profile Send private message Visit poster's website Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 28 Jan 2005, 22:48
well, now i'm checking for LinearFrameBuffer during the modecheck like this:

Code:
mov si,0x50 ;beginning of informationblock
mov ds,si
xor si,si
lodsw
and ax,0000000010000000b
cmp ax,0000000010000000b
jne near vesa_error     
    


and what i found out was that LinearFrameBuffer seems to be possible, because he didn't jump to the label. but it still doesn't work!

i hope for another help,

J!N
Post 28 Jan 2005, 22:48
View user's profile Send private message Visit poster's website Reply with quote
ASHLEY4



Joined: 28 Apr 2004
Posts: 376
Location: UK
ASHLEY4 29 Jan 2005, 03:18
Heres a demo i wrote to demo, how to use vesa when making a OS, try it and see the differance.

_________________
\\\\||////
(@@)
ASHLEY4.

Batteries not included, Some assembly required.
Post 29 Jan 2005, 03:18
View user's profile Send private message Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 29 Jan 2005, 13:40
well, i tried your code and it runs! it runs with LFB, so my card supports LFB, i'm sure. i'll exactly search the differents to find my misstake! thank you so far!
Post 29 Jan 2005, 13:40
View user's profile Send private message Visit poster's website Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 29 Jan 2005, 15:57
okay, i tried to set up your mode (640x480) with LFB. it doesn't work, too Crying or Very sad ... but ASLEY4's code works! this is my full code, i hope someone finds my misstake:

Code:
;enable vesa!
push ds
;set up signature at the block at 0x50:0x00
mov di,0x50
mov es,di
xor di,di
mov al,'V'
stosb
mov al,'B'
stosb
mov al,'E'
stosb
mov al,'2'
stosb
xor di,di
mov ax,0x4F00
int 0x10             ;get vesainformation
;check availability
cmp ax,0x004F
jne near vesa_error
mov si,0x50
mov ds,si
xor si,si
lodsb
lodsb
cmp al,'E'
jne near vesa_error
mov cx,0x06
rep lodsw
lodsw
;get table of modes
mov bx,ax
lodsw
mov ds,ax
mov si,bx
push ds
push si
;search mode (0x0118)
find_right_mode1:
lodsw
cmp ax,0xFFFF
je check_115_mode
cmp ax,0x0118
jne find_right_mode1
mov bx,0x0118
jmp before_set_vesa
check_115_mode:
pop si
pop ds
;search mode (0x0115)
find_right_mode2:
lodsw
cmp ax,0xFFFF
je near vesa_error
cmp ax,0x0115
jne find_right_mode2
mov bx,0x0115
jmp set_vesa_mode
before_set_vesa:
pop si
pop ds
;get modeinformation
set_vesa_mode:
mov cx,bx
pop ds
mov [vesa_mode],cx
push ds
add cx,0x4000
mov ax,0x4F01
mov di,0x50
mov es,di
xor di,di
int 0x10
;read modeinformation
mov si,0x50
mov ds,si
xor si,si
lodsw
and ax,0000000010000000b
cmp ax,0000000010000000b
jne near vesa_error
mov cx,0x0A
rep lodsw
lodsb
lodsb
pop ds
mov [vesa_bits_per_pixel],al
push ds
mov si,0x50
mov ds,si
xor si,si
mov cx,0x14
rep lodsw
lodsd
pop ds
mov [vesa_physical_base_adress],eax
;set vesamode
mov bx,[vesa_mode]
add bx,0x4000
mov ax,0x4F02
int 0x10            
    


yes, that's it.... it's not very well commented, but i think it explains itself Wink the modeblock is written to 0x50:0x00.

thank you!

J!N
Post 29 Jan 2005, 15:57
View user's profile Send private message Visit poster's website Reply with quote
Octavio



Joined: 21 Jun 2003
Posts: 366
Location: Spain
Octavio 29 Jan 2005, 19:39
I haven´t found any scandalous bug if direction flag =0
perhaps the bug is in another part of the code, but why you don´t use a debuger?
most off us have our own sources to debug and very rarely we want to spend time debuging sources from others.
and do you know that you can do de same using 1/3 of the instructions?
i mean that mosts C compilers would generate better code.
Post 29 Jan 2005, 19:39
View user's profile Send private message Visit poster's website Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 29 Jan 2005, 20:03
@octavio: i found no error, too! but that's the problem! i know that you haven't so much time to spend in my code. i use a debugger, called bochs! and in bochs it works! that's the problem! in bochs it runs, but not so in real! and that's my problem. so i hope that anyone can help me.
Post 29 Jan 2005, 20:03
View user's profile Send private message Visit poster's website Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 29 Jan 2005, 22:13
to joachimneu

Well this code from solar os works also:

So it might be your setting of DS at 0x50h
or the fact that you request VBE2.0 ?

Basically never assume that you can use what ever segments you want for BIOS ints Wink

My buffer is at 0x0000:0x1000h .

Take care as some VESA implementations do write a lot more that the 256 or 512bytes in the standards when getting info. So beware of possible overwrites on some video boards.
Code:
  ;---------------------------
        ; Detect VESA version
       ;---------------------------
        mov     ax,0
        mov     es,ax   

        ;------------------------------------------
 ; 4fh=VESA function
 ; 00=Return Super VGA Information
   ;------------------------------------------
 mov     di,1000h
    mov     ax,04f00h       
    int     10h             ;make VESA BIOS call

    cmp     ax,004fh        ;ok value is ah=00 al=4f
    jz      vesa_is_ok
    


And for mode setup:

Code:
       mov     ebx,[user_mode]
     or      ebx,0C000h      ;clear flag+use lfb flag
    mov     ax,04f02h       ;02-set vesa mode function
  int     10h             ;call VESA
  or      ah,ah
       jnz     @@fx_mode_error ;restart menu on error
    


Have you noticed the 0xC000h for requesting LFB and clear as opposed to your 0x4000h ... ?

But that should not be an issue.

I agree with Octavio here: the error is there in your code but we are unlikely to want to debug your code as we have our code to debug. So i suggest you start testing every little bit using small steep by steep and finnaly find out where the problem is.


Octavio:

About the C compiler generating better code, it is irelevant in this area. The guy is just making some tests and he is just a beginner ASM programmer. A C compile could never compete with me for example. Besides i like to have the inteligence to write small and fast code only when it matters.

I would like the compiler to generate easy to understand code when speed doese not matter and very well optimized code where speed does matter.

But a compiler has no ideea of the stage of my algorithm and the purpose for it. This is what makes HLL crippled and pathetic for ever and ever.

They are usefull at times for the capitalistic world we live in but we should never praise them much, at least not on an ASM forum. There are countless forums for C/C++/Java and other abominations. And i bet members here read those forums also since we all have jobs to do.

Some of the members here are C/C++ or other HLL language experts also Very Happy

Even more I have seen C compilers generating small "little devil" mistakes that only apperred in code at specifica IRQ and multi thread handling making you nuts and having to dissassemble the ASM for some exotic CPU to only find that the stupid compiler creator was unable to know a little ASM and put our job work for months at risk.

Even more put lifes at risch for things i was not aware (aka C compiler mistakes) a thing that would NEVER happe if i would have written the thing in ASM originally.

_________________
"Any intelligent fool can make things bigger,
more complex, and more violent.
It takes a touch of genius -- and a lot of courage --
to move in the opposite direction."
Post 29 Jan 2005, 22:13
View user's profile Send private message Visit poster's website Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 29 Jan 2005, 22:27
@bogdanontanu: do you think the problem is about setting DS to 0x50 or about requesting VBE2? what should i write into the signature for requesting other VESAs above? i only found VBE2 in the manuals... and i'll have a try with the segments...

EDIT: but why should it fail to write to the segments? the information are right...
Post 29 Jan 2005, 22:27
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.