Getting the size of video memory (VBE)

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
glauxosdever
Member
Member
Posts: 501
Joined: Wed Jun 17, 2015 9:40 am
Libera.chat IRC: glauxosdever
Location: Athens, Greece

Getting the size of video memory (VBE)

Post by glauxosdever »

Hi,


I need to get the size of the VBE framebuffer, so I know how much space I need for its mapping. I have examined both the VBE 2.0 and 3.0 specifications. VBE 2.0 contains a field in "VBE Mode Info" to determine the start of the offscreen memory, plus the size of the offscreen memory.

However, in VBE 3.0 they are set to 0. To get the number of pages I can use the "LinNumberOfImagePages" field, but what is the size of a page? Is it equivalent to "BankSize", since I don't see any fields similar to "ImageSize"?

At last, should I only map to virtual memory the framebuffer, or should I map the whole video memory?

Your help would be much respected.


Regards,
glauxosdever
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Getting the size of video memory (VBE)

Post by Octocontrabass »

glauxosdever wrote:I need to get the size of the VBE framebuffer, so I know how much space I need for its mapping.
How many bytes in each scanline? How many scanlines?

I think you can figure it out once you have those two numbers. :wink:
glauxosdever wrote:At last, should I only map to virtual memory the framebuffer, or should I map the whole video memory?
You only need to map the parts you're using.
glauxosdever
Member
Member
Posts: 501
Joined: Wed Jun 17, 2015 9:40 am
Libera.chat IRC: glauxosdever
Location: Athens, Greece

Re: Getting the size of video memory (VBE)

Post by glauxosdever »

Hi,

Octocontrabass wrote:How many bytes in each scanline? How many scanlines?

I think you can figure it out once you have those two numbers. :wink:
This is what I am currently doing. But I wasn't sure if it is the best solution. In fact, I think I'll wait for another reply to AND the suggested statements together.

By the way, I'm not saying you are wrong (since you are far more experienced than me), but I always prefer having two of more opinions, so I have a broader perspective.


Regards,
glauxosdever
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Getting the size of video memory (VBE)

Post by BrightLight »

Well, height * bytes per line is probably how to calculate on-screen memory. If you want the entire VGA memory of the controller, the VESA Controller Information block has a field for that which contains the size of memory in 64 KB blocks.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
glauxosdever
Member
Member
Posts: 501
Joined: Wed Jun 17, 2015 9:40 am
Libera.chat IRC: glauxosdever
Location: Athens, Greece

Re: Getting the size of video memory (VBE)

Post by glauxosdever »

Hi,

omarrx024 wrote:Well, height * bytes per line is probably how to calculate on-screen memory. If you want the entire VGA memory of the controller, the VESA Controller Information block has a field for that which contains the size of memory in 64 KB blocks.
Ok, it seems I'm doing it well, then. But a third opinion wouldn't hurt, still. :)

Edit: People in #osdev told me this is the correct way too. So it seems it indeed is.


Regards,
glauxosdever
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Getting the size of video memory (VBE)

Post by Combuster »

glauxosdever wrote:But a third opinion wouldn't hurt, still. :)
Since you asked, look up the BARs in the device's PCI space, find the one matching the framebuffer, then map it in its entirety.*


* Fun exercise, but a bad idea in production code.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
ggwpez
Posts: 2
Joined: Wed Sep 16, 2015 3:23 am
Libera.chat IRC: ggwpez
Location: (0, 0, 0)

Re: Getting the size of video memory (VBE)

Post by ggwpez »

glauxosdever wrote:
Octocontrabass wrote:How many bytes in each scanline? How many scanlines?

I think you can figure it out once you have those two numbers. :wink:
This is what I am currently doing. But I wasn't sure if it is the best solution.
That is the usual way, Im also doing it, just try it out.
You identity map from the framebuffer up to framebuffer+(heigth *pitch) and if you can still see all changes going on the screen, it works.
Are you somehow afraid of it not working everywhere?
My Bootloader Does Not Work?!
Post Reply