VESA problem, help

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.
Mattx
Posts: 20
Joined: Fri Jul 11, 2008 5:10 am

VESA problem, help

Post by Mattx »

I'am beginner in OS Development so sorry if question was already asked here. I'm trying to write a kernel that using VESA driver and i have problem with bank switching, because in future propably i will have to swap to potected mode a dont want to use bank switching through INT10. I find that from VESA 2.0 + here is function that gives ability to switch banks without interupts. i get pointer to this function and count of bytes to copy to my adress space - hmm what virtual adress space i have - i dont know. I have kernel in pure asm ( nasm) right now i initialize graphics mode and putPixel with INT bank switching...I would be a very appriciate if someone would help me about it, anather this is linear freme buffer i would like to use it but i dont now how of course in asm...

And the last question what is general diffrence between VESA driver and normal driver from Win32...
Thanks for any response...
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Re: VESA problem, help

Post by lukem95 »

Windows drivers are usually chipset specific, so they can use the hardware functions that will greatly increase speed.

a VESA driver is a driver for a standard that cards conform too, but the CPU will have to do all the legwork, meaning it is slower, but will work on most cards (like NEARLY all).

and btw, GUI != OS... you'll have a fairly long way to go before you should think about getting graphics work started.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
ChazZeromus
Member
Member
Posts: 61
Joined: Sun Jun 22, 2008 4:09 pm

Re: VESA problem, help

Post by ChazZeromus »

Mattx wrote:I'am beginner in OS Development so sorry if question was already asked here. I'm trying to write a kernel that using VESA driver and i have problem with bank switching, because in future propably i will have to swap to potected mode a dont want to use bank switching through INT10. I find that from VESA 2.0 + here is function that gives ability to switch banks without interupts. i get pointer to this function and count of bytes to copy to my adress space - hmm what virtual adress space i have - i dont know. I have kernel in pure asm ( nasm) right now i initialize graphics mode and putPixel with INT bank switching...I would be a very appriciate if someone would help me about it, anather this is linear freme buffer i would like to use it but i dont now how of course in asm...

And the last question what is general diffrence between VESA driver and normal driver from Win32...
Thanks for any response...
Just figure out where the banks are stored in 32-bit address space? I've only read that bank switching is required because the video memory is store very high in address space and in real mode it's impossible to reach the addresses without hardware to help, by using a vesa driver you can switch which banks you're writing to. Thats what I think, I've haven't read the full specification yet, but yeah, figure where the memory is located in protected mode and I think that should do it.
Image
User avatar
cr2
Member
Member
Posts: 162
Joined: Fri Jun 27, 2008 8:05 pm
Location: ND, USA

Re: VESA problem, help

Post by cr2 »

Mattx wrote:I'am beginner in OS Development so sorry if question was already asked here. I'm trying to write a kernel that using VESA driver
Just a suggestion, you might want to start with a text-based kernel, and add the GUI later once you are finished with the kernel and a few other applications(e.g. a command prompt).
OS-LUX V0.0
Working on...
Memory management: the Pool
Mattx
Posts: 20
Joined: Fri Jul 11, 2008 5:10 am

Thanks for response

Post by Mattx »

You guys are right i should do it in proper order but GUI is the thing i was very very curious long time ago. I'm just trying to find answers to my questions and also create some simple OS. For total beginner it is very hard and very body have its own point of view one likes file systems other network i wanted ( now ) to concentrate on general working kernel (that's boots, gives me total control on machine) and a GUI. I just don't know how (and where) in my kernel copy VESA switch bank procedure to be able to switch banks in protected mode... I put my kernel on address 0800h:0000h and there is 512b stack before. I found some tutorial about it but they are using DJGPP or something like that and they have malloc function and getdosmem function and i don't have it i don't even know I can use 32bit code in real mode ??? I have real mode, address of function , number of bytes to copy.. It's all about this :

----------104F0A-----------------------------
INT 10 - VESA SuperVGA BIOS v2.0+ - GET PROTECTED-MODE CODE
AX = 4F0Ah
BX = function to be copied
0001h set bank
0002h set display start
0003h set palette
Return: AL = 4Fh if function supported
AH = status
00h successful
CX = number of bytes to copy
ES:DI -> code for requested function
01h failed

Still please help or response
Mattx
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Thanks for response

Post by jal »

Mattx wrote:I just don't know how (and where) in my kernel copy VESA switch bank procedure to be able to switch banks in protected mode...
That's because you don't want to switch banks in protected mode. Bank switching was invented solely for real mode, to cram the full video memory address space in the 1MB limit. In protected mode, you access the full video memory in one contiguous buffer.


JAL
Mattx
Posts: 20
Joined: Fri Jul 11, 2008 5:10 am

Re: VESA problem, help

Post by Mattx »

Yes you are right about pmode but there is also bank switching approch that gives you possibility to change banks without interupts. This is a solution VESA for protected mode and slow bank switching. Another approch is as you said linear frame buffer that I would be very delightful if some one would be able to tell me how to use linear freame buffer in pmode in nasm for example or other asm. I only know that i need to turn it on 14 bit in 0x4f02 VESA func. but Before we even think about using the Linear Frame Buffer, we have to map it into our addressable space i read it somewhere... but how to do it ???
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: VESA problem, help

Post by jal »

Mattx wrote:but Before we even think about using the Linear Frame Buffer, we have to map it into our addressable space i read it somewhere... but how to do it ???
It's not quite clear to me whether you are in real mode or protected mode, and whether you want to develop code for real mode or protected mode. In real mode, you can use BIOS interrupts and banked mode, in protected mode no BIOS interrupts but linear frame buffers. Usually, you'd set the video mode you want in real mode, then switch to protected mode. You do not have to 'map' anything in your address space (unless you are (planning on) using paging) if you set op pmode the right way. The actual address the video memory is mapped to depends on the video card, and can be retrieved by using the right VESA BIOS call (mode information, iirc).


JAL
Mattx
Posts: 20
Joined: Fri Jul 11, 2008 5:10 am

Re: VESA problem, help

Post by Mattx »

Yes, yes yes that's what i just dreamt about :D ... As you said JAL now i'm in real mode i choose ( switched to ) resolution i want with VESA INT10h and than switch to protected mode and then i don't know how to put pixel using LinearFrameBuffer method to be able to draw some simple things ... How to retrive actual adress of video memory as you said If you know some sources or some simple solution i was gooogling hundred times to find something in asm and i haven't found nothing intresting. Thanks for response i'm more closer to answers to my questions thanks to you.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: VESA problem, help

Post by Dex »

The asm file at the bottom of this post will help with your pmode bank switching (nasm code).
Also i have code a vesa demo for LFB from pmode.
http://www.dex4u.com/demos/VesaDemo.zip
Its coded with fasm (close to nasm), it come with code and a self extracting exe to put the demo on a floppy, it goes to and from pmode for vesa mode switching.
Attachments
pmodeVesaBankSwitching.ASM
(26.19 KiB) Downloaded 231 times
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: VESA problem, help

Post by jal »

Mattx wrote:i don't know how to put pixel using LinearFrameBuffer method to be able to draw some simple things
A linear frame buffer is just that: linear access to the video memory. How to fill that memory depends on the memory architecture of the video card for the mode you set.
How to retrive actual adress of video memory as you said If you know some sources or some simple solution i was gooogling hundred times to find something in asm and i haven't found nothing intresting.
Then Google harder. Just Googling for "vesa linear frame buffer" yields enough results to get your answers. The second hit is Wikipedia, with useful links to the specs themselves, the fourth link gives you many examples with source code.


JAL
Mattx
Posts: 20
Joined: Fri Jul 11, 2008 5:10 am

Re: VESA problem, help

Post by Mattx »

Thanks DEX and JAL you guys helped me a lot a specially DEX source code, thank you very much again =D>
Mattx
Posts: 20
Joined: Fri Jul 11, 2008 5:10 am

Re: VESA problem, help

Post by Mattx »

Yes its me again i have another problem but with the same thing... :(
I was trying to find something on net but there is only in DJGPP , examples... Here is my little kernel I work on and I dont know what do next do have my own first putPixel procedure... What i should do with framebuffer adress and do i have to switch to pmode to be able to use it or not ?
Please help one more time...

org 0000h

initStack:
mov ax,07C0h
mov ss,ax
mov sp,03FEh

start:
call initTextMode
call welcomeText
call endl
call getChar
call check_VESA
call initGFXMode
main:

call putPixel
jmp main
reset:
mov bx,40h
mov ds,bx
mov word[ds:72h],1234h
jmp 0FFFFh:0000h

check_VESA:
mov ax,4F00h ; Is Vesa installed ?
mov di,VESA_Info ; This is the address of how info block.
int 10h

mov ax,4f01h ; Get Vesa Mode information.
mov cx,112h ; 4112h = 32/24bit ; 0x4101 = 256bit ;4111h = 65535bit (640*480)
int 10h

mov eax,dword[es:di + 40]
mov dword[offset],eax

;mode attr = mov ax,word[es:di]
;xres = mov ax,word[es:di + 18]
;yres = mov ax,word[es:di + 20]
;bits per pixel = mov al,byte[es:di + 25]
;LinearFrameBuffer addr = mov eax,dword[es:di + 40]
;OffScreenMemOffset = mov eax,dword[es:di + 44]
;OffScreenMemSize = mov ax,word[es:di + 48]

ret

initGFXMode:
mov ax,4F02h
mov bx,112h ;101h = 640x480x8 112h = 640x480x32 118h = 1024x768x32bit
or bx, 4000h ;enable frame buffer bit 14
int 10h

cmp ax,4Fh
je done

mov ax,info2
mov bl,2
call writeString

mov ax,info3
mov bl,2
call writeString

call getChar
jmp reset
done:
ret

putPixel:
;mov ebp,dword[offset]
;mov ecx,12500
;draw:
;mov dword[ebp],0FFFFFFFFh
;mov eax,0A000h
;mov es,eax
;mov ebx,dword[ds:offset]
;mov dword[es:ebx],0FFFFFFFFh
; inc ebp
; loop draw

;mov eax,0A000h
;mov es,eax
;mov bx,word[ds:offset]
;mov dword[es:bx],0FFFFFFFFh

mov ax,0A000h
mov es,ax
xor edi,edi ; We make shore edi 0.
mov edi,dword[offset] ; we can just as easy as writing to this address,as normal VGA mode 13h.
mov ecx,640*480 ; Size of screen
mov eax,0FFFFFFFFh ; This is for the color of one pixel(note: this could be 24bit or 32bit)

rep stosd

ret

;Gloabal varables

info0: db "FX Operating System Loaded",0
info1: db "Press any key to continue...",0
info2: db "VESA init failed...",0
info3: db "Press ESC to restart.",0
x dd 0,0
y dd 0,0
color dw 0,0,0,0
offset: dd 0,0,0,0
bank: dw 0,0,0,0
liczba: dw 0,0,0,0
_pisz_bufor: dw 0,0,0,0
wndPointer: dw 0,0
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: VESA problem, help

Post by jal »

Mattx wrote:What i should do with framebuffer adress and do i have to switch to pmode to be able to use it or not ?
The framebuffer address is usually well above the 1MB mark, so yes, you must be in pmode to access it, unless you are in unreal mode, in which case you can access the buffer from real mode as well.


JAL
Mattx
Posts: 20
Joined: Fri Jul 11, 2008 5:10 am

Re: VESA problem, help

Post by Mattx »

So proper order is like this ? : (in my case of course)
1. Set stack
2. Say hello :)
3. Check VESA and obtain framwork buffer address
4. Switch to proper video mode with framebuffer enable
5. Switch to protected mode
6. and what now ???
Okey so let say that I switch to pmode by setting cr register and so on and what next ? There is a lot tutorials on net about pmode so maybe i will gunderstand something but what should i do when i in pmode and have LFB adress (i get it when i was in real mode) ...
Post Reply