VESA graphic 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.
Post Reply
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

VESA graphic mode

Post by Klakap »

Good day! Please, how do I switch to vesa the card into graphics mode 1024x768 without bios? Klakap
MrLolthe1st
Member
Member
Posts: 90
Joined: Sat Sep 24, 2016 12:06 am

Re: VESA graphic mode

Post by MrLolthe1st »

Hi, VESA - is a part of VBE, u can try to use int 10h in PM(may be w.o. switching v86), but w.o. BIOS u will write video driver for each video card.
Cheers,
Aleksandr
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: VESA graphic mode

Post by Klakap »

I can't go from protected mode to real and back and therefore I would rather like to write a driver but I don't know where to get information. Therefore, I am asking if anyone knows how to write a driver for VESA cards.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: VESA graphic mode

Post by Brendan »

Hi,
Klakap wrote:I can't go from protected mode to real and back and therefore I would rather like to write a driver but I don't know where to get information. Therefore, I am asking if anyone knows how to write a driver for VESA cards.
There are no "VESA cards"; there's just many video cards from many manufacturers that all use different (non-standard, proprietary) registers and memory mapped IO that happen to provide VESA's VBE interface as an "option ROM" that extends the BIOS.

If you don't/can't use VBE ("VESA BIOS Extensions') and don't/can't use UEFI's equivalent (GOP or UGA); then you have to write about 100 different video drivers (one for each different video card). In that case I'd probably be tempted to start with something ancient like "Cirrus Logic 5446" or "3dfx Voodoo Graphics" (both from about 20 years ago), partly because they're a lot simpler than anything modern, partly because you can obtain programming information for them (unlike NVidia cards, etc), and partly because they're emulated by various emulators.


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.
StudlyCaps
Member
Member
Posts: 232
Joined: Mon Jul 25, 2016 6:54 pm
Location: Adelaide, Australia

Re: VESA graphic mode

Post by StudlyCaps »

Brendan wrote: If you don't/can't use VBE ("VESA BIOS Extensions') and don't/can't use UEFI's equivalent (GOP or UGA); then you have to write about 100 different video drivers (one for each different video card). In that case I'd probably be tempted to start with something ancient like "Cirrus Logic 5446" or "3dfx Voodoo Graphics" (both from about 20 years ago), partly because they're a lot simpler than anything modern, partly because you can obtain programming information for them (unlike NVidia cards, etc), and partly because they're emulated by various emulators.
Apologies for off topic, but what do you think of starting with something like Intel HD instead of Cirrus of 3dfx? It seems that the standards are quite open, and honestly, I don't think I could find a real Cirrus or Voodoo card in 2018 if my life depended on it!
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: VESA graphic mode

Post by Brendan »

Hi,
StudlyCaps wrote:Apologies for off topic, but what do you think of starting with something like Intel HD instead of Cirrus of 3dfx? It seems that the standards are quite open, and honestly, I don't think I could find a real Cirrus or Voodoo card in 2018 if my life depended on it!
The standards are relatively open; but without prior experience it's very hard to understand any of it, and trying to debug a video driver when there's no video (because the video driver needs debugging) adds an extra layer of difficulty on top of that. Writing a video driver for an emulator (where you can use a debugger) gets you the prior experience that makes it "less hard" to understand (parts of) Intel's documentation.

Mostly; I'd start with Cirrus Logic (it's supported by both Bochs and Qemu) and then maybe consider "VMware SVGA-II" (supported by both Qemu and VMware). After that I'd try to find a real computer that has Intel's integrated video plus something else, where something else is/can be configured as "primary display adapter". That way I'd be able to use a working "raw framebuffer setup by boot loader" video driver for the primary display adapter (to see debugging messages, etc) while writing a proper driver for Intel's integrated video.

For writing a video driver; I'd want to start by trying to figure out which (VGA, HDMI, DVI, ..) ports there are and which ones have a monitor plugged in; then getting information/EDID from the monitor/s; then basic video mode switching (including using EDID to get the timing right); then monitor power management (sending the display into standby, etc) and backlight control (if its a laptop); then hot-plug events (for when a monitor is plugged in or unplugged). Next I'd probably add support for "unused video RAM as swap space"; then try to get vertical sync and page flipping to work. At this point I'd stop and move on to the next video card.

After "initial support" is finished for all video cards (and after I've died from old age in several of my lives - I'm hoping that's how it works) I'd revisit each video card driver. For "round two"; I'd start by adding support for any fixed function hardware (hardware mouse cursor, hardware bitblits, 2D and 3D graphics accelerators in old video cards, movie/MPEG/H.265 decoders). Then (for newer video cards) I'd do GPGPU (not for graphics), followed by GPU (for graphics - shaders or whatever); and GPU power management.


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.
StudlyCaps
Member
Member
Posts: 232
Joined: Mon Jul 25, 2016 6:54 pm
Location: Adelaide, Australia

Re: VESA graphic mode

Post by StudlyCaps »

Thanks Brendan, makes a lot of sense.
I hadn't really considered the difficulty of debugging with no emulator, very tricky. Personally I'd really like to be able to support at least one actual GPU so I can have nice stuff like resolution options and multiple displays. Intel would seem to be the way to go on actual hardware, because some 70-80% of consumer grade systems from the last 10 years should support it. In practice though it would probably be lots of staring at a blank screen wondering which one of hundreds of register pokes went wrong!

If one was really dedicated to that task, maybe setting up serial for debugging. Then working, as you described, but only for a single chip. Maybe it would be possible in only one or two lifetimes!
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: VESA graphic mode

Post by Korona »

Yes. Use serial ports for debugging. I wrote a driver for some Intel cards (see the Wiki) and did not find debugging to be very challenging - even if you can output to the screen, debugging via serial I/O is still superior (better scrolling).

You can start with Cirrus; that choice would not be too bad but OTOH you can only use that on emulators (unless you buy ancient graphics cards). You can also consider Bochs' BGA first, although its register interface has little in common with real interfaces. I jumped straight to Intel after implementing BGA but did a lot of reading in between.

Regardless of which route you choose, make sure to understand the VGA page on the Wiki - especially the section on the CRTC. While the register interfaces are somewhat different, the general terms are still in use. Reading Linux drivers also helps a lot, get used to that.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: VESA graphic mode

Post by Klakap »

I tried to write a driver for the VGA but nowhere I found how to switch VGA into graphics mode. Please what commands do I have to switch the VGA into graphics mode?
StudlyCaps
Member
Member
Posts: 232
Joined: Mon Jul 25, 2016 6:54 pm
Location: Adelaide, Australia

Re: VESA graphic mode

Post by StudlyCaps »

Klakap wrote:I tried to write a driver for the VGA but nowhere I found how to switch VGA into graphics mode. Please what commands do I have to switch the VGA into graphics mode?
I havn't done my own VGA driver yet, but there is code here which shows how you can switch between the different text and graphics modes. If you reference that against the register information here you should be able to figure out how to fit it into your driver design.
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: VESA graphic mode

Post by Klakap »

Thank you!
Post Reply