OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:12 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Tue Oct 28, 2014 4:34 pm 
Offline
Member
Member

Joined: Thu May 28, 2009 2:41 pm
Posts: 70
Location: Germany
Hi,

I'm using GRUB4DOS (so technically GRUB legacy) and if I use the vbeprobe in qemu it reports available VBE modes but GRUB doesn't pass any VBE fields of the multiboot struct to my kernel (Bit 11 of "flags" is also 0).

What's the reason for this? How can I fix this?


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Wed Oct 29, 2014 4:32 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

Cjreek wrote:
I'm using GRUB4DOS (so technically GRUB legacy) and if I use the vbeprobe in qemu it reports available VBE modes but GRUB doesn't pass any VBE fields of the multiboot struct to my kernel (Bit 11 of "flags" is also 0).

What's the reason for this? How can I fix this?


Old versions of GRUB legacy didn't support the video related parts of the multi-boot specification. Then someone created an (unofficial) patch that added the missing video support, and for a while some people (and some Linux distributions) were using "patched GRUB legacy". Eventually the functionality got added to official GRUB legacy, but not long after that the GRUB developers deprecated GRUB legacy and moved on to GRUB2. For GRUB2 it's in an optional module.

The end result is that if you're using multi-boot with the end user's pre-existing GRUB you can't assume video will work at all (as it might be an older GRUB legacy without the patch, or a newer GRUB2 without the optional module).

There are 2 work-arounds. This first work-around is to provide an OS installer that forces the end user to re-install their existing boot loader, where the OS installer has a version of GRUB that does support the video related parts of the multi-boot specification. Of course most end users who are already have existing boot manager/s or boot loader/s for other OS/s will consider this nasty and risky.

The other work-around is to not use the video related parts of the multi-boot specification; and (after you're booted via. multi-boot) switch back to real mode and setup a video mode yourself. This has the added benefit that you're able to do it properly (rather than the dodgy multi-boot way that allows the boot loader to auto-select a video mode that the OS doesn't support). Sadly; this work-around can't work on UEFI.

Of course a "work-around" never solves the underlying problem (and only works around the underlying problem); and this may not be the last problem caused by multi-boot (e.g. sooner or later you may want the OS to use its own secure file system, rather than relying on a gaping security hole like FAT where anyone using any OS can mess with your OSs critical files). The correct solution (which solves all underlying problem/s) is to stop using multi-boot as a boot loader. However, implementing your own boot loaders can take a bit of work; and for a "quick and dirty" hobby OS this additional work may not be justified.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Sat Nov 01, 2014 3:50 am 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
Brendan wrote:
Sadly; this work-around can't work on UEFI.
You won't need any work-around when dealing with UEFI, as you can set video modes with the structures it provides. When thinking about this I wonder why nobody on the forums has written an UEFI OS yet.

_________________
managarm


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Sat Nov 01, 2014 3:57 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Quote:
When thinking about this I wonder why nobody on the forums has written an UEFI OS yet.

I already boot just fine from UEFI. I even had to add framebuffer graphics support to my kernel because the boot menu actually leaves the system in graphics mode when calling an EFI binary.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Sat Nov 01, 2014 4:12 pm 
Offline
Member
Member
User avatar

Joined: Tue Feb 08, 2011 1:58 pm
Posts: 496
no92 wrote:
I wonder why nobody on the forums has written an UEFI OS yet.

Because that's silly. UEFI is a firmware that boots an OS. There's no point in writing an OS as an EFI application.

I've actually a BIOS boot loader and an UEFI boot loader booting the same OS. Both loaders were written in assembly and I've even shared the info about how to get GOP video modes on wiki almost 2 years ago.
If it's not enough for you, take a look at grub source or refit source for working C examples.


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Sat Nov 01, 2014 4:28 pm 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
I never wrote that I'm looking for examples (the information about UEFI is pretty good). I was just wondering why nobody (I knew of) was using UEFI for setting the video mode.

Writing an OS for UEFI and using it to set the video mode is not pointless. It's maybe not exactly perfect, but still better than using clunky old BIOS with VBE, which requires using Virtual 8086 mode.

I don't think anybody is willing to write drivers for multiple graphic cards here, so I guess using UEFI will become the next big change to the hobbyist OSdev community.

_________________
managarm


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Sat Nov 01, 2014 11:19 pm 
Offline
Member
Member

Joined: Thu Jul 05, 2012 5:12 am
Posts: 923
Location: Finland
no92 wrote:
It's maybe not exactly perfect, but still better than using clunky old BIOS with VBE, which requires using Virtual 8086 mode.


There is an old truth: "you should not use Virtual 8086 mode". If you set up the video mode at boot stage, using VBE would not be more that clunky. Actually, it is almost the same as using GOP (UEFI) for setting the video mode.

UEFI does not change the fact that we still need native drivers. As far as I know, the GOP is only available as a boot service (before your OS takes control). It is not a runtime service.

Being able to use the framebuffer set by VBE or UEFI is a very important feature for hobby OSs.

_________________
Undefined behavior since 2012


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Mon Nov 03, 2014 3:50 am 
Offline
Member
Member

Joined: Tue May 13, 2014 3:02 am
Posts: 280
Location: Private, UK
Personally, I don't consider that an OS that requires a reboot to change screen resolution has decent graphics support. Using the resolution set up by (U)EFI or GRUB is nice for the OS splash screen, but that's about it.

Therefore, to use graphics in an OS, there are two main options; VBE and per-device "native" drivers.

If you use VBE, the options are V86 mode (a legacy hack that's not easily available to 64-bit OSs) or running the video BIOS in emulation. In case it's not obvious, I'd consider the latter to be a better solution as it gives you more control and doesn't require interfacing with CPU features designed on a severely limited transistor budget in the early 1980s. It's also a technique that's been widely used on non-x86 platforms to support PCI graphics cards. The only potential issue is that future "integrated" GPU/CPU combos may use special CPU features in the video BIOS that you can't emulate.

I'd consider per-device drivers to be the "ideal", but that can be quite a bit of work. Still, supporting the common devices (AMD, NVidia, Intel and BGA) with a VBE or standard VGA fallback option isn't too hard; the Linux kernel's framebuffer drivers aren't that hard to understand.

_________________
Image


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Mon Nov 03, 2014 5:07 am 
Offline
Member
Member

Joined: Thu Jul 05, 2012 5:12 am
Posts: 923
Location: Finland
mallard wrote:
I don't consider that an OS that requires a reboot to change screen resolution has decent graphics support.


If native video drivers are not available (graphics support is not decent), a reboot is the only elegant way. A boot loader is responsible for setting the framebuffer (BIOS/VBE or UEFI/GOP). It makes things simple if your OS does not care whether the framebuffer is set by VBE or GOP.

mallard wrote:
is nice for the OS splash screen, but that's about it


Unfortunately, it is likely to be the primary video mode.

_________________
Undefined behavior since 2012


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Mon Nov 03, 2014 10:57 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

mallard wrote:
Personally, I don't consider that an OS that requires a reboot to change screen resolution has decent graphics support. Using the resolution set up by (U)EFI or GRUB is nice for the OS splash screen, but that's about it.


There's only about 5 situations were the end user needs to change video modes:
  • They're playing 3D games and the video card's GPU is too slow to handle to monitor's native resolution, so they want to change video mode to improve frame rates. In this case a native driver is necessary for hardware accelerated 3D anyway.
  • The boot loader chose the wrong video mode (e.g. not the best video mode that the OS, video card and monitor support). In this case, fixing the boot loader is far more important than supporting video mode switches after boot.
  • The OS's video API is very bad and doesn't support resolution independence; which forces the user to change video modes just so that applications look right (even though they really don't want to). In this case, fixing the OS's video API is far more important than supporting video mode switches after boot.
  • The user changed from one video driver to another, where there is a native video driver anyway.
  • The user changed from one video card to another. Typically the computer has to be turned off when you replace video cards, so this is extremely unlikely (there are USB video adapters that can be "hot-plugged", but without a driver they aren't going to work at all).
  • The user changed the monitor and the new monitor has a different native resolution.

Basically; if you don't have a native video driver, then the user only cares about change video modes when they change monitors. Most users don't change monitors very often, so rebooting to change video modes is only a minor inconvenience.

mallard wrote:
I'd consider per-device drivers to be the "ideal", but that can be quite a bit of work. Still, supporting the common devices (AMD, NVidia, Intel and BGA) with a VBE or standard VGA fallback option isn't too hard; the Linux kernel's framebuffer drivers aren't that hard to understand.


For an OS that supports both UEFI (where VBE doesn't exist) and 64-bit (where virtual8086 mode isn't usable); it's probably easier to write native drivers (that are able to do video mode switches, but don't support 2D/3D acceleration or GPGPU) than it is to get VBE to work.

Also; a generic "standard VGA" driver isn't really worth bothering with (apart from learning) - the best VGA video modes have low resolution and low colour depth, and are "unacceptably bad". I don't think I've used anything lower than 1024*768 for the last 10 years.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Mon Nov 03, 2014 11:09 am 
Offline

Joined: Sun Jun 08, 2014 10:39 am
Posts: 15
It seems it is not possible to support solutions like 1024*768 or greater for hobby-Os on 64-bit UEFI systems. Yay!

_________________
https://github.com/MartinErhardt/Lizarx


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Mon Nov 03, 2014 11:23 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Quote:
The boot loader chose the wrong video mode (e.g. not the best video mode that the OS, video card and monitor support). In this case, fixing the boot loader is far more important than supporting video mode switches after boot.
I have tried with UEFI/GOP and it exclusively reports low resolutions on my UEFI machine as well, and the de-facto EFI firmware for QEMU is similarly limited. Compared to VBE, you get roughly 10% of the potential graphics options when you use UEFI.

Basically, as an UEFI user with the best portability-feature demands, you will want to manually interpret the embedded video BIOS for it's VBE support. Which is of course a horrible hack of it's own right.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Mon Nov 03, 2014 11:49 am 
Offline

Joined: Sun Jun 08, 2014 10:39 am
Posts: 15
Many of those UEFI systems have a BIOS emulation mode. When enabled can VBE still be used in that case?

_________________
https://github.com/MartinErhardt/Lizarx


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Mon Nov 03, 2014 12:33 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

martinFTW wrote:
Many of those UEFI systems have a BIOS emulation mode. When enabled can VBE still be used in that case?


When not booting with UEFI and booting with BIOS, you can use VBE.

When booting with UEFI (and not booting with BIOS), it might be possible (but not necessarily easy) to use VBE. For example, this might involve mapping the video card's ROM somewhere, reconfiguring the chipset where necessary, and emulating enough BIOS to initialise the video card's ROM and trick it into thinking everything is fine.

For systems that have no BIOS compatibility mode you can't expect VBE to exist in ROM (especially for on-board video).

Note that we're currently making the transition from "BIOS only" to "UEFI only"; and most systems are currently UEFI with BIOS compatibility mode (except things like tablets where a significant number are UEFI only already). By the time you've finished writing an OS it's likely we would've completed the transition to "UEFI only".


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: GRUB legacy (GRUB4DOS) - VBE info missing
PostPosted: Mon Nov 03, 2014 1:41 pm 
Offline
Member
Member

Joined: Tue May 13, 2014 3:02 am
Posts: 280
Location: Private, UK
Brendan wrote:
Basically; if you don't have a native video driver, then the user only cares about change video modes when they change monitors. Most users don't change monitors very often, so rebooting to change video modes is only a minor inconvenience.


You've clearly never seen laptops in a corporate environment. In many cases, users connect/disconnect to monitors (via docking stations), projectors, etc. several times a day. Having to reboot every time is far more than a "minor inconvenience".

Brendan wrote:
For an OS that supports both UEFI (where VBE doesn't exist) and 64-bit (where virtual8086 mode isn't usable); it's probably easier to write native drivers (that are able to do video mode switches, but don't support 2D/3D acceleration or GPGPU) than it is to get VBE to work.


I'm not sure about "easier", but I'd agree that native drivers are the ultimate goal. It is nice to have a fallback however and the even the big-name OSs have VBE support for that purpose.

Brendan wrote:
Also; a generic "standard VGA" driver isn't really worth bothering with (apart from learning) - the best VGA video modes have low resolution and low colour depth, and are "unacceptably bad". I don't think I've used anything lower than 1024*768 for the last 10 years.


Sure, VGA isn't exactly "usable" in today's world, but it's good to at least be able to display a UI that can be used to install/configure a proper driver (or at least inform the user that their graphics card isn't supported).

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot], Majestic-12 [Bot], thewrongchristian and 76 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