Vesa Help
-
- Posts: 6
- Joined: Sat Dec 11, 2010 3:52 pm
- Location: Sydney, Australia
Re: Vesa Help
Can you please expand on what you mean by VESA? AFAIK, VESA is a standards body, do you maybe mean VGA?
This contains a nice example of VGA text mode:
http://www.few.vu.nl/~herbertb/misc/basickernel.pdf
Once, you've got started with VGA text mode, you can read this, to get graphics going.
http://wiki.osdev.org/VGA_Hardware
On the other hand, if all you are doing is dumping text (which is more than enough for a LONG time on a personal kernel project) then I can show you how to get a serial port working and configure qemu to show this.
This contains a nice example of VGA text mode:
http://www.few.vu.nl/~herbertb/misc/basickernel.pdf
Once, you've got started with VGA text mode, you can read this, to get graphics going.
http://wiki.osdev.org/VGA_Hardware
On the other hand, if all you are doing is dumping text (which is more than enough for a LONG time on a personal kernel project) then I can show you how to get a serial port working and configure qemu to show this.
Re: Vesa Help
Sorry. I'm used to refering to SVGA as Vesa.
~Osmium USA
~Osmium USA
Re: Vesa Help
Hi,
The last 2 choices won't support 2D/3D acceleration or anything more than a "framebuffer" interface; won't work for dual-monitors; and won't support all video modes that the video card is capable of (e.g. typically you get 4:3 modes and don't get any 16:9 or 16:10 modes).
Of course if your OS is for protected mode and/or long mode you can't use the real mode interface directly. In this case your options are:
For a good quality OS your long-term goal must be native video drivers, as that's the only way to support the features that users expect. In this case you'd also need to support some sort fall-back option (for when there is no native video driver). For the fall-back option the user won't be satisfied regardless of what you do; so there isn't much point wasting too much time on it, and I'd use the "set a video mode during boot" option (as it's the least amount of work). This isn't as simple as it seems at first - to support native drivers your video driver interface has to expect the video driver to do all the drawing (so it can be accelerated), which means that your "framebuffer" fall-back driver (which needs to use the same video driver interface) also needs to do all the drawing. Basically you end up implementing a software renderer for the "framebuffer" driver (that imitates the features of hardware accelerated 2D/3D); and parts of this software renderer might also be used by native video drivers for low-end video cards that don't support some features.
Cheers,
Brendan
Your choices are:osmiumusa wrote:Sorry. I'm used to refering to SVGA as Vesa.
- Write native drivers for each different type of video card (some of which are undocumented)
- Use the VESA/VBE protected mode interface that was introduced in VBE 3.0, that isn't supported by any older video cards video cards and isn't supported by most VBE 3.0 video cards either
- Use the VESA/VBE real mode interface
The last 2 choices won't support 2D/3D acceleration or anything more than a "framebuffer" interface; won't work for dual-monitors; and won't support all video modes that the video card is capable of (e.g. typically you get 4:3 modes and don't get any 16:9 or 16:10 modes).
Of course if your OS is for protected mode and/or long mode you can't use the real mode interface directly. In this case your options are:
- Setup a video mode during boot (e.g. before you switch to protected mode or long mode). If the user wants to switch video modes after boot then they either need a native video driver or they need to reboot.
- Use Virtual8086 mode (can be messy, and doesn't work for long mode)
- Implement (or port) some sort of "real mode emulator" (even more messy than Virtual8086 mode, but works in long mode)
- Use hardware virtualisation - very messy (different code for AMD/SVM and Intel/VMX, where I think VMX needs to use Virtual8086 inside the virtual machine to run real mode code). This doesn't work on CPUs that don't support SVM or VMX.
- Temporarily switch back to real mode, which is difficult to do reliably without causing major problems for IRQ handling (for all possible IRQs you need to install real mode stubs which switch back to protected/long mode and run the real IRQ handlers)
For a good quality OS your long-term goal must be native video drivers, as that's the only way to support the features that users expect. In this case you'd also need to support some sort fall-back option (for when there is no native video driver). For the fall-back option the user won't be satisfied regardless of what you do; so there isn't much point wasting too much time on it, and I'd use the "set a video mode during boot" option (as it's the least amount of work). This isn't as simple as it seems at first - to support native drivers your video driver interface has to expect the video driver to do all the drawing (so it can be accelerated), which means that your "framebuffer" fall-back driver (which needs to use the same video driver interface) also needs to do all the drawing. Basically you end up implementing a software renderer for the "framebuffer" driver (that imitates the features of hardware accelerated 2D/3D); and parts of this software renderer might also be used by native video drivers for low-end video cards that don't support some features.
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.
- Combuster
- 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: Vesa Help
You can not use VESA VBE from C. It's a real mode assembly interface. I see Brendan gave a fully rephrased version of the FAQ page on the subject, but most likely you want to either use GRUB to do the dirty work of setting a video mode, or not use VBE and write a VGA driver: they are the fastest way to get into a working graphics mode.osmiumusa wrote:I'd like to know how to use VESA in C.
V8086 (hardware) and software emulation are by general consensus the best way into a VESA mode, but they are also more elaborate and therefore much more demanding on the rest of your system, and my crystal ball suggests you're not quite there yet. And at the far end, writing a plethora of graphics drivers is pretty much reserved for the nutcases like yours truly
Re: Vesa Help
OK. So then from C, in simplest terms, how do I set a SVGA mode and print a pixel - using GCC inline assembly or otherwise. I've gotten basic IN/OUT functions on my OS to work. But I'd like to move into graphics.
~Osmium USA
~Osmium USA
Re: Vesa Help
Hello,
The only alternatives is to set the VBE mode before going into protected mode or scrapping supporting SVGA modes, and just use standard VGA.
If you want to stick with using C, either add support for v86 tasks and use VBE, or find the specification for your video card and build an implementation to support it. Sorry, but it doesnt get much simpler, and both solutions require a bit of support code.osmiumusa wrote:OK. So then from C, in simplest terms, how do I set a SVGA mode and print a pixel - using GCC inline assembly or otherwise. I've gotten basic IN/OUT functions on my OS to work. But I'd like to move into graphics.
The only alternatives is to set the VBE mode before going into protected mode or scrapping supporting SVGA modes, and just use standard VGA.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: Vesa Help
This is NOT entirely true Combuster, the VBE setup is required to be in RM assembly yes, but, once you have it initialized, and have a pointer the the video memory, C is not unrealistic to use.Combuster wrote:You can not use VESA VBE from C. It's a real mode assembly interface. I see Brendan gave a fully rephrased version of the FAQ page on the subject, but most likely you want to either use GRUB to do the dirty work of setting a video mode, or not use VBE and write a VGA driver: they are the fastest way to get into a working graphics mode.osmiumusa wrote:I'd like to know how to use VESA in C.
V8086 (hardware) and software emulation are by general consensus the best way into a VESA mode, but they are also more elaborate and therefore much more demanding on the rest of your system, and my crystal ball suggests you're not quite there yet. And at the far end, writing a plethora of graphics drivers is pretty much reserved for the nutcases like yours truly
< This is how i do it aswell, my bootloader handles the RM VBE interface. But since i run in longmode... switching to PM then to V86 is a real pain. So the reboot option works well.Setup a video mode during boot (e.g. before you switch to protected mode or long mode). If the user wants to switch video modes after boot then they either need a native video driver or they need to reboot.
I think what your actually asking, osmiumusa, is how to change res then access the screen...?
-
- Member
- Posts: 127
- Joined: Sat Sep 29, 2007 5:43 pm
- Location: Amsterdam, The Netherlands
Re: Vesa Help
You are implying that modifying the video memory using C is equal to using the VESA VBE interface.iLewis wrote:This is NOT entirely true Combuster, the VBE setup is required to be in RM assembly yes, but, once you have it initialized, and have a pointer the the video memory, C is not unrealistic to use.Combuster wrote:You can not use VESA VBE from C. It's a real mode assembly interface. I see Brendan gave a fully rephrased version of the FAQ page on the subject, but most likely you want to either use GRUB to do the dirty work of setting a video mode, or not use VBE and write a VGA driver: they are the fastest way to get into a working graphics mode.osmiumusa wrote:I'd like to know how to use VESA in C.
V8086 (hardware) and software emulation are by general consensus the best way into a VESA mode, but they are also more elaborate and therefore much more demanding on the rest of your system, and my crystal ball suggests you're not quite there yet. And at the far end, writing a plethora of graphics drivers is pretty much reserved for the nutcases like yours truly
Regards,
Stephan J.R. van Schaik.
Re: Vesa Help
Not to mention that the above is only true for modes that support a LFB. If not you would still need to use the VBE interface from within your C code.StephanVanSchaik wrote:You are implying that modifying the video memory using C is equal to using the VESA VBE interface.iLewis wrote:This is NOT entirely true Combuster, the VBE setup is required to be in RM assembly yes, but, once you have it initialized, and have a pointer the the video memory, C is not unrealistic to use.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: Vesa Help
Yes you are correct, that is my mistake. I need to remember not everyone lives in the future...neon wrote:Not to mention that the above is only true for modes that support a LFB. If not you would still need to use the VBE interface from within your C code.StephanVanSchaik wrote:You are implying that modifying the video memory using C is equal to using the VESA VBE interface.iLewis wrote:This is NOT entirely true Combuster, the VBE setup is required to be in RM assembly yes, but, once you have it initialized, and have a pointer the the video memory, C is not unrealistic to use.
Re: Vesa Help
I guess what you are looking for, at this stage, is switch to high resolution true color mode and then plot pixel on it . Plotting pixel is quite simple once you initialize the mode you want. And this can be done entirely in C once you are set to use the linear frame buffer. The wiki has a good explanation about this . Unfortunately, setting up the appropriate mode has to be done while in real mode. If you are using GRUB you can configure it to do this job for you but if you are using custom bootloader, you need to manually do this. There are alot of VESA tutorial available in the web so get one and get going. And of course, for simplicity here's what you need to do:
1 Check to see if VESA 2.0 interface exist.
2 Search the mode you want. Check to see if this mode supports LFB. If it doesnt, find the mode which does.
3 Save the address of LFB. You need to pass this address to the kernel.
4 Set the mode you find appropriate. Set bit 14 to use the LFB.
All done. You can now throw pixel at the address of LFB from within the C code.
And of course, at this stage, if you are thinking about the alternative such as Specific video card driver or Virtual8086 mode, get ready to struck your head in the wall.
Best regards,
Chandra
1 Check to see if VESA 2.0 interface exist.
2 Search the mode you want. Check to see if this mode supports LFB. If it doesnt, find the mode which does.
3 Save the address of LFB. You need to pass this address to the kernel.
4 Set the mode you find appropriate. Set bit 14 to use the LFB.
All done. You can now throw pixel at the address of LFB from within the C code.
And of course, at this stage, if you are thinking about the alternative such as Specific video card driver or Virtual8086 mode, get ready to struck your head in the wall.
Best regards,
Chandra
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Re: Vesa Help
How do you configure grub to do this?
~osmiumusa
~osmiumusa
Re: Vesa Help
GRUB legacy doesn't support the video mode aspects of multiboot without a patch, IIRC.