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.
[SOLVED] Getting framebuffer's size
[SOLVED] Getting framebuffer's size
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
Operating system: colorForth computing environment for x86.: https://github.com/narke/Roentgenium
- sleephacker
- Member
- Posts: 97
- Joined: Thu Aug 06, 2015 6:41 am
- Location: Netherlands
Re: Getting framebuffer's size
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.
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
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
Operating system: colorForth computing environment for x86.: https://github.com/narke/Roentgenium
- sleephacker
- Member
- Posts: 97
- Joined: Thu Aug 06, 2015 6:41 am
- Location: Netherlands
Re: Getting framebuffer's size
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'.narke wrote:LinBytesPerScanLine is same as pitch? Am I right? I saw http://wiki.osdev.org/VESA_Video_Modes
Note that the value defined as 'pitch' in that wiki article is actually BytesPerScanLine, not LinBytesPerScanLine. To quote the document (page 38):
So BytesPerScanLine might work for some linear modes, LinBytesPerScanLine works for all linear modes.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.
Re: Getting framebuffer's size
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
Operating system: colorForth computing environment for x86.: https://github.com/narke/Roentgenium