How to enter graphics mode?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: How to enter graphics mode?

Post by Combuster »

If you insist on not using the firmware, your pilgrimage starts here. Expect nobody to be able answer your questions past this point if you do.
"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 ]
reload
Posts: 9
Joined: Sun Jul 12, 2015 10:15 am

Re: How to enter graphics mode?

Post by reload »

Ok, I see I can do this well only with BIOS, right?
....
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: How to enter graphics mode?

Post by Roman »

reload wrote:Ok, I see I can do this well only with BIOS, right?
Define "well". VESA BIOS extensions are old and obsolete interfaces to the graphics card. It is the fastest and easiest way to get to the graphics, but fastest != best. You should use VBE as a fallback and then try to write some card-specific drivers. I suggest you to begin with an older and simpler GPU or try to understand Linux code, if you really want Nvidia (because Nvidia doesn't provide any documentation, unfortunately).
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: How to enter graphics mode?

Post by Roman »

Combuster wrote:If you insist on not using the firmware, your pilgrimage starts here. Expect nobody to be able answer your questions past this point if you do.
Shouldn't he also consider looking at drivers/gpu/drm/nouveau? Or it's not necessary?
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: How to enter graphics mode?

Post by Combuster »

If you read the exact wording, you'll notice that question is already answered.
"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 ]
Unsigned
Posts: 24
Joined: Thu Sep 20, 2012 6:46 pm

Re: How to enter graphics mode?

Post by Unsigned »

reload wrote:Ok, I see I can do this well only with BIOS, right?
It is possible to write directly to the VGA registers, but there are some things to consider:
  • The graphics adapter must be VGA-compatible.
  • The graphics adapter must be in a VGA-compatible mode, that's to say, card-specific registers must not be currently taken into account and VGA registers must be taken into account by the adapter so that you can actually change the video mode by modifying them.
  • The maximum resolution will be 720*480 pixels, with only 16 colors.
  • There will be only 256KB of video memory, so you can get 2 video pages with a resolution of 640*400, but you'll get only 1 video page with higher resolutions.
  • Memory addressing will be bit-planar, but this shouldn't be a big problem once you write routines to update parts of the screen from your software framebuffer.
If you still want to use this lower resolution graphics mode, see this post. You can set a VGA graphics mode with this code.

Anyway, you should use v86 mode, not only for VESA, but also in case you want to add DOS compatibility to your OS, or for supporting more BIOS interrupts.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: How to enter graphics mode?

Post by Combuster »

Unsigned wrote:Anyway, you should use v86 mode, not only for VESA, but also in case you want to add DOS compatibility to your OS, or for supporting more BIOS interrupts.
Now there's a really bad idea.

Video BIOS interrupts already assume control over the entire video card and on several occasions more than that. Other BIOS interrupts assume control over the entire computer. Going along with the former is doable, but you already interfered with the latter if you've got any decent protected mode setup, and you're just begging for the system to halt and catch fire if you try any interrupt other than int 0x10.
"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 ]
Unsigned
Posts: 24
Joined: Thu Sep 20, 2012 6:46 pm

Re: How to enter graphics mode?

Post by Unsigned »

Yes, that's true.
I just said that as a suggestion, but in reality there's no need to use the other BIOS interrupts like, say, Plug and Play. It's better to write drivers for that.
As far as I can remember, the VESA specification says VBE functions should be given access to the PCI configuration registers. And since they don't provide information about the ports the card needs, the v86 task should be given access to any port belonging to detected graphics adapters, as well as ports belonging to non-detected (non-Plug and Play) graphics adapters too. So basically, to be sure it will work, the v86 task would be given access to all the ports, except those ones which belong to detected, non-graphics devices.
Post Reply