vesa bank switching

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pofuduk

vesa bank switching

Post by pofuduk »

Im implementing a simple qui and using vesa. I set my video mode in my second stage loader and I want to store WinFuncPtr pointer, which holds a pointer to switch bank in protected mode part. But I couldnt manage to do it. I have some problems with pointers I think. Here is what Im doing:

Code: Select all

...
lGetVesaInfo:
    mov ax, 0
    mov es, ax

    mov di, VesaInfo
    mov ax, 4F00h
    int 10h

    cmp AX, 004Fh
    jne $

okVESA:
    mov ax, 4F02h
    mov bx, 115h                                ; 800*600*24
    int 10h
    cmp AX, 004Fh
    jne $

    mov di, ModeInfo
    mov ax, 4F01h
    mov cx, 115h
    int 10h

    mov dword eax, [ModeInfo+12]
    mov dword [VESA_WINFUNCPTR], eax
   ...
and here is my bank switching code:

Code: Select all

void SetBank(unsigned int BankNo)
{
    void (*WinFuncPtr)(void) =  (void *)VESA_WINFUNCPTR;

    __asm__ __volatile__ ("movw %w0, %%bx" : : "rm" (0) );
    __asm__ __volatile__ ("movw %w0, %%dx" : : "rm" (BankNo) );
    WinFuncPtr();
}
But SetBank doesnt work. I think there is a problem in first line but not so sure. Ill be glad if someone check it and help me..
Slasher

Re:vesa bank switching

Post by Slasher »

Hi,
Are you in protected mode? If you are in protected mode, you can't call the bank switching function like that.
WinFuncPtr is a real mode pointer if you want to use it in pmode, then you will have to get the vbe protected mode entry point.If you want to start with simple stuff use the linear frame buffer instead by using (0x4000+mode_number) to set a mode. Then the address pointed to by PhysBasePtr is the 32bit physical address for the frame buffer. writing data into this address will cause pixels to be displayed. If you are using paging,then PhysBasePtr has to be mapped to a virtual address and the virtual address used instead.Get vbe3.pdf - http://www.vesa.org/vbe3.pdf , it will help you alot.
pofuduk

Re:vesa bank switching

Post by pofuduk »

I set video mode and get video mode info in real mode and then switch into protected mode.Cannt I call winfuncptr in protected mode?
Slasher

Re:vesa bank switching

Post by Slasher »

Like I said above,No! not the way you are doing it. get the pdf and read it carefully.
Cemre

Re:vesa bank switching

Post by Cemre »

A way to use a real mode far pointer in pmode DOES exist... You can use this ptr in a 16 bit segment selector with base 0xC0000... i tried this on three nvidia and one cirrus logic card and WinFuncPtr does work... I haven't seen ( or programmed ) any vesa card that use segments ( ds , es , cs , ss ... etc ) in WinFuncPtr direct implementation, of course I'm only talking about VESA here, for other things, this will not work...
...Engin...
Tim

Re:vesa bank switching

Post by Tim »

The problem is that the code at WinFuncPtr expects to be running in real mode, and there's nothing which says it can't attempt to load real-mode segment values into the segment registers and use them. Since it's running in 16-bit pmode at best, it's not allowed to do that.

However, 16-bit and 32-bit protected mode VESA entry points do exist. As always -- read the PDF!
Post Reply