OSDev.org
https://forum.osdev.org/

Getting VBE framebuffer location returns 0x0000
https://forum.osdev.org/viewtopic.php?f=1&t=56480
Page 1 of 1

Author:  Cyao [ Sun Sep 11, 2022 11:07 am ]
Post subject:  Getting VBE framebuffer location returns 0x0000

I've made a little piece of code to get me the location of the framebuffer of VBE 0x100 mode
Code:
[ORG 0x7C00]
[BITS 16]

Main:
    mov di, 0xF000 ; just put the info here
    mov ax, 0x4F01 ;mode
    mov cx, 0x0100 ; video mode number
    int 0x10 ;call

    cmp ax, 0x004F
    jne error ;checks for error

    mov ah, 0x0E ; print mode

    mov al, [0xF000 + 0x28] ; 1st byte of the adress

    and al, 0xF0 ; print 1st char
    shr al, 4
    add al, 0x30
    int 0x10

    mov al, [0xF000 + 0x28]

    and al, 0x0F
    add al, 0x30
    int 0x10

    mov al, [0xF000 + 0x2A]

    and al, 0xF0
    shr al, 4
    add al, 0x30
    int 0x10

    mov al, [0xF000 + 0x2A]

    and al, 0x0F
    add al, 0x30
    int 0x10

error:
    jmp $

times 510 - ($-$$) db 0
dw 0xAA55


I think i made it all good, but on the screen it only displays "0000", am I doing something wrong?

Author:  Minoto [ Sun Sep 11, 2022 1:59 pm ]
Post subject:  Re: Getting VBE framebuffer location returns 0x0000

The segment registers aren't initialized in your code, so there's no guarantee that the information is stored (relative to es) at the same address you're attempting to read it from (relative to ds).

Your code also only prints two bytes of a four byte address, which is probably not what you intended.

Author:  Cyao [ Mon Sep 12, 2022 8:57 am ]
Post subject:  Re: Getting VBE framebuffer location returns 0x0000

Oh so I initialized the registers and I got the frambuffer adress is 0xFD000000 which seems a bit odd, but it works in 16 bit mode. but after switching to 64 bit mode, it dosent work :( Is there some way to get to know why? and is there some documentation of the framebuffer adresses?

Author:  Octocontrabass [ Mon Sep 12, 2022 10:42 am ]
Post subject:  Re: Getting VBE framebuffer location returns 0x0000

cyao1234 wrote:
but after switching to 64 bit mode, it dosent work :( Is there some way to get to know why?

In 64-bit mode, paging is enabled. Do your page tables have an appropriate mapping for physical address 0xFD000000?

cyao1234 wrote:
and is there some documentation of the framebuffer adresses?

What do you mean? On modern PCs, the firmware assigns physical addresses to PCI BARs before your OS boots, and the linear framebuffer address is derived from one of those BARs. The address can change depending on the hardware and firmware configuration.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/