OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 6:52 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: VESA LFB in long mode x86
PostPosted: Mon Apr 25, 2022 9:19 am 
Offline
User avatar

Joined: Sun Dec 12, 2021 3:50 am
Posts: 5
I have never been able to get long mode and VESA LFB working together, when I try, qemu just dies, but in protected mode works fine, is it even possible for a VESA LFB to work in long mode? If so, How?

_________________
I can't wait until x86-s exists.


Top
 Profile  
 
 Post subject: Re: VESA LFB in long mode x86
PostPosted: Mon Apr 25, 2022 12:59 pm 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 618
Location: North Dakota, United States
I'm pretty sure this isn't possible. I might be wrong but isn't VESA/VBE a real-mode/32-bit technology only?


Top
 Profile  
 
 Post subject: Re: VESA LFB in long mode x86
PostPosted: Mon Apr 25, 2022 2:24 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
You can't call VBE in 64-bit mode, but you can use the linear framebuffer provided by VBE in 64-bit mode. In fact, the linear framebuffer works exactly the same in all CPU modes, and regardless of how you set it up (VBE, GOP, or native driver).

It sounds like you don't have an appropriate mapping in your page tables, causing a page fault, and you don't have working exception handlers, turning the page fault into a triple fault. You can add "-d int" (and maybe "-no-reboot") to your QEMU command line to see exactly what's causing the reboot.


Top
 Profile  
 
 Post subject: Re: VESA LFB in long mode x86
PostPosted: Tue Apr 26, 2022 4:03 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3191
Octocontrabass wrote:
You can't call VBE in 64-bit mode, but you can use the linear framebuffer provided by VBE in 64-bit mode. In fact, the linear framebuffer works exactly the same in all CPU modes, and regardless of how you set it up (VBE, GOP, or native driver).


Right, except that EFI have a few more organizational modes that VBE lacks.


Top
 Profile  
 
 Post subject: Re: VESA LFB in long mode x86
PostPosted: Tue Apr 26, 2022 8:06 am 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
I like to get the bootloader (GRUB) to enter the graphics mode for me, then read the location of the framebuffer, bit depth, and resolution from the multiboot info.

_________________
My OS is Perception.


Top
 Profile  
 
 Post subject: Re: VESA LFB in long mode x86
PostPosted: Wed Apr 27, 2022 2:40 pm 
Offline
User avatar

Joined: Sun Dec 12, 2021 3:50 am
Posts: 5
Octocontrabass wrote:
You can't call VBE in 64-bit mode, but you can use the linear framebuffer provided by VBE in 64-bit mode. In fact, the linear framebuffer works exactly the same in all CPU modes, and regardless of how you set it up (VBE, GOP, or native driver).

It sounds like you don't have an appropriate mapping in your page tables, causing a page fault, and you don't have working exception handlers, turning the page fault into a triple fault. You can add "-d int" (and maybe "-no-reboot") to your QEMU command line to see exactly what's causing the reboot.


So, It's a problem with my page table mapping? If so, then could that be related to the way I enter long mode? (Shown bellow, using osdev tutorial 'Setting Up Long Mode'). I've done some research but still don't understand page tables and that lot very well, so it would be great if someone could help.

Code:
bits 32
   mov dword [lfb0], ebx
   mov edi, 0x1000
   mov cr3, edi
   xor eax, eax
   mov ecx, 4096
   rep stosd
   mov edi, cr3
   mov dword [edi], 0x2003
   add edi, 0x1000
   mov dword [edi], 0x3003
   add edi, 0x1000
   mov dword [edi], 0x4003
   add edi, 0x1000
   mov dword ebx, 0x00000003
   mov ecx, 512
   .setEntry:
      mov dword [edi], ebx
      add ebx, 0x1000
      add edi, 8
      loop .setEntry
   mov eax, cr4
   or eax, 1 << 5
   mov cr4, eax
   mov ecx, 0xc0000080
   rdmsr
   or eax, 1 << 8
   wrmsr
   mov eax, cr0
   or eax, 1 << 31
   mov cr0, eax
   lgdt [GDT.Pointer]
   jmp GDT.Code:LongMode
   [bits 64]
   LongMode:
   mov ebx, dword [lfb0]
   mov edi, dword [ebx+22]


Thanks in advance (if advance exists).

_________________
I can't wait until x86-s exists.


Top
 Profile  
 
 Post subject: Re: VESA LFB in long mode x86
PostPosted: Wed Apr 27, 2022 7:39 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
ZufaligeDaten wrote:
If so, then could that be related to the way I enter long mode? (Shown bellow, using osdev tutorial 'Setting Up Long Mode').

The tutorial's page tables only include identity mappings for the first two megabytes. Your framebuffer is almost certainly at a higher address, so you'll need to set up mappings for it in order to access it. (You don't have to identity-map your framebuffer.)


Top
 Profile  
 
 Post subject: Re: VESA LFB in long mode x86
PostPosted: Wed Apr 27, 2022 11:56 pm 
Offline
User avatar

Joined: Sun Dec 12, 2021 3:50 am
Posts: 5
Octocontrabass wrote:
ZufaligeDaten wrote:
If so, then could that be related to the way I enter long mode? (Shown bellow, using osdev tutorial 'Setting Up Long Mode').

The tutorial's page tables only include identity mappings for the first two megabytes. Your framebuffer is almost certainly at a higher address, so you'll need to set up mappings for it in order to access it. (You don't have to identity-map your framebuffer.)


Thank you, that probably explains it.

_________________
I can't wait until x86-s exists.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 62 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group