Page 1 of 1
[SOLVED] Getting framebuffer's size
Posted: Sun Sep 03, 2017 8:34 am
by narke
Hi, I Implemented VBE and paging support to have a framebuffer and would like to know how to get the framebuffer's size in order to map framebuffer's address into virtual memory with the right size.
I can display characters because for the moment its mapped with an arbitrary value: framebuffer's address to framebuffer's address + 128 page size.
Thank you in advance.
Re: Getting framebuffer's size
Posted: Sun Sep 03, 2017 10:30 am
by sleephacker
Multiplying LinBytesPerScanLine with YResolution (as found in the ModeInfoBlock structure) gives you the size of the screen in bytes for linear framebuffer modes. LinNumberOfImagePages gives you the number of times the entire screen (LinBytesPerScanLine * YResolution) fits in the framebuffer, minus one. So the framebuffer is at least LinBytesPerScanLine * YResolution * (LinNumberOfImagePages + 1) bytes in size.
I'm not sure if there's also a way to find out the exact size of the framebuffer memory, but if you're only interested in the part of the framebuffer that allows you to draw to the screen then LinBytesPerScanLine * YResolution is the size of the area you want to map.
Re: Getting framebuffer's size
Posted: Sun Sep 03, 2017 1:28 pm
by narke
LinBytesPerScanLine is same as pitch? Am I right? I saw
http://wiki.osdev.org/VESA_Video_Modes
Re: Getting framebuffer's size
Posted: Sun Sep 03, 2017 2:14 pm
by sleephacker
Yes, it is generally referred to as pitch, I used the names as they appear in
this document (see page 30 for the ModeInfoBlock struct) because there are multiple fields that could be called 'pitch'.
Note that the value defined as 'pitch' in that wiki article is actually BytesPerScanLine, not LinBytesPerScanLine. To quote the document (page 38):
The LinBytesPerScanLine field specifies how many full bytes are in each logical scanline for linear framebuffer modes if the linear framebuffer modes are different to the banked modes. (...) VBE 3.0 applications should look at this value for linear modes, as it is possible for the linear modes to have a different logical scanline width than the banked modes.
So BytesPerScanLine might work for some linear modes, LinBytesPerScanLine works for all linear modes.
Re: Getting framebuffer's size
Posted: Sun Sep 03, 2017 3:07 pm
by narke
Thank you very much! It seems to work.