Page 1 of 1
Getting the size of video memory (VBE)
Posted: Sat May 28, 2016 7:27 am
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
Re: Getting the size of video memory (VBE)
Posted: Sat May 28, 2016 7:41 am
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.
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.
Re: Getting the size of video memory (VBE)
Posted: Sat May 28, 2016 7:56 am
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.
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
Re: Getting the size of video memory (VBE)
Posted: Sat May 28, 2016 9:17 am
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.
Re: Getting the size of video memory (VBE)
Posted: Sat May 28, 2016 9:43 am
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
Re: Getting the size of video memory (VBE)
Posted: Tue May 31, 2016 2:49 am
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.
Re: Getting the size of video memory (VBE)
Posted: Thu Jun 02, 2016 3:47 am
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.
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?