[SOLVED] Getting framebuffer's size

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
User avatar
narke
Member
Member
Posts: 119
Joined: Wed Dec 26, 2007 3:37 am
Location: France

[SOLVED] Getting framebuffer's size

Post 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.
Last edited by narke on Sun Sep 03, 2017 3:11 pm, edited 1 time in total.
OS for PowerPC Macs: https://github.com/narke/Einherjar
Operating system: colorForth computing environment for x86.: https://github.com/narke/Roentgenium
User avatar
sleephacker
Member
Member
Posts: 97
Joined: Thu Aug 06, 2015 6:41 am
Location: Netherlands

Re: Getting framebuffer's size

Post 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.
User avatar
narke
Member
Member
Posts: 119
Joined: Wed Dec 26, 2007 3:37 am
Location: France

Re: Getting framebuffer's size

Post by narke »

LinBytesPerScanLine is same as pitch? Am I right? I saw http://wiki.osdev.org/VESA_Video_Modes
OS for PowerPC Macs: https://github.com/narke/Einherjar
Operating system: colorForth computing environment for x86.: https://github.com/narke/Roentgenium
User avatar
sleephacker
Member
Member
Posts: 97
Joined: Thu Aug 06, 2015 6:41 am
Location: Netherlands

Re: Getting framebuffer's size

Post by sleephacker »

narke wrote:LinBytesPerScanLine is same as pitch? Am I right? I saw http://wiki.osdev.org/VESA_Video_Modes
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.
User avatar
narke
Member
Member
Posts: 119
Joined: Wed Dec 26, 2007 3:37 am
Location: France

Re: Getting framebuffer's size

Post by narke »

Thank you very much! It seems to work.
OS for PowerPC Macs: https://github.com/narke/Einherjar
Operating system: colorForth computing environment for x86.: https://github.com/narke/Roentgenium
Post Reply