OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 1:30 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: [Answered] GRUB2 "Hacking"
PostPosted: Wed Aug 10, 2016 12:23 pm 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
Hello peeps.
Is there a way to hack GRUB2 so it sets wanted video mode only when you type custom command inside your shell?

_________________
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader


Last edited by Octacone on Wed Aug 10, 2016 2:46 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: GRUB2 "Hacking"
PostPosted: Wed Aug 10, 2016 12:53 pm 
Offline
Member
Member
User avatar

Joined: Thu Mar 27, 2014 3:57 am
Posts: 568
Location: Moscow, Russia
I'm not a GRUB2 user, but AFAIK there is a command for that, "gfxmode" maybe. If you really want to extend GRUB's functionality you can a write a plugin.

_________________
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay


Top
 Profile  
 
 Post subject: Re: GRUB2 "Hacking"
PostPosted: Wed Aug 10, 2016 1:12 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
GRUB2 uses the firmware to change video modes. For the legacy BIOS case, you can mostly return the computer to the state it was in when the firmware loaded GRUB2 the first time. For the UEFI case, GRUB2 exits boot services when it loads your OS the first time, which means there's no firmware for it to use the second time around.

For the amount of effort that would take, you may as well reboot every time you want to change the video mode.

If you really want to change the video mode from within your OS, you should write a native driver. (Or, if you're truly masochistic, write a PCI option ROM interpreter and all of the necessary PCI-related driver infrastructure.)


Top
 Profile  
 
 Post subject: Re: GRUB2 "Hacking"
PostPosted: Wed Aug 10, 2016 1:31 pm 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
Octocontrabass wrote:
GRUB2 uses the firmware to change video modes. For the legacy BIOS case, you can mostly return the computer to the state it was in when the firmware loaded GRUB2 the first time. For the UEFI case, GRUB2 exits boot services when it loads your OS the first time, which means there's no firmware for it to use the second time around.

For the amount of effort that would take, you may as well reboot every time you want to change the video mode.

If you really want to change the video mode from within your OS, you should write a native driver. (Or, if you're truly masochistic, write a PCI option ROM interpreter and all of the necessary PCI-related driver infrastructure.)


I don't use UEFI. I just want to know if I can force GRUB to switch from default text mode to high resolution mode after my kernel has loaded, when I want it.

_________________
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader


Top
 Profile  
 
 Post subject: Re: GRUB2 "Hacking"
PostPosted: Wed Aug 10, 2016 1:45 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
All new PCs have UEFI.

Once your kernel is loaded, GRUB is gone. If you want GRUB, you have to load it again, and GRUB will restart your kernel from the beginning.


Top
 Profile  
 
 Post subject: Re: GRUB2 "Hacking"
PostPosted: Wed Aug 10, 2016 1:55 pm 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
Octocontrabass wrote:
All new PCs have UEFI.

Once your kernel is loaded, GRUB is gone. If you want GRUB, you have to load it again, and GRUB will restart your kernel from the beginning.


Okay, so I guess that writing native VBE driver is my best bet.

_________________
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader


Top
 Profile  
 
 Post subject: Re: [Answered] GRUB2 "Hacking"
PostPosted: Wed Aug 10, 2016 4:30 pm 
Offline
Member
Member
User avatar

Joined: Sun Sep 19, 2010 10:05 pm
Posts: 1074
octacone wrote:
Okay, so I guess that writing native VBE driver is my best bet.

VBE is really only going to be available in 16-bit real mode, so a VBE driver is kind of a bad idea as well.

Your VBE driver would have to switch back to 16-bit mode, call the VBE interrupts, and then switch back to 32-bit mode. Alternately, you could write a virtual machine that runs 16-bit code in 32-bit mode, but this is probably overkill if you only want to be able to switch graphics modes.

Until you write your own native 32-bit video driver(s), your best bet is to just pick a graphics mode, and let GRUB do the switch for you at boot time.

_________________
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 93 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