How in the world do you set up a GUI??

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
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

How in the world do you set up a GUI??

Post by zhiayang »

Hi, again. So I've fixed all the problems in my kernel. So now I'm wondering, how on earth do you change the vbe mode or something?

I've googled so much, but nothing. I know there is a patch that makes grub actually use the vbe flag, but I can't find the 0.97 source anywhere. I know I should switch to real mode to change modes, but how would I do that?

Also, don't ask me to use GRUB 2; It is over-complicated. Unless of course, someone would be kind enough to provide me with a set of commands that actually make a bootable ISO file. (Qemu complains about no bootable media).
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: How in the world do you set up a GUI??

Post by gerryg400 »

I couldn't get Grub 0.97 to do VBE. I tried patching it and rebuilding it and even tried to debug it a little but in the end I gave up.

I wrote a small asm function that drops back to real mode and does an int10 then returns to protected mode and copies the data to a C buffer. I only use it in my loader before the OS is actually loaded to set a graphics mode.

There is a wiki article on how to switch to real mode but I didn't try that. It looks correct though http://wiki.osdev.org/Real_mode#Switchi ... _Real_Mode
If a trainstation is where trains stop, what is a workstation ?
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: How in the world do you set up a GUI??

Post by turdus »

requimrar wrote:I know I should switch to real mode to change modes, but how would I do that?
For example long->real (bios int)->long: http://forum.osdev.org/viewtopic.php?f=1&t=23125
Learn to search. There are many examples for protmode too, also for creating iso files on the wiki.

Actualy I wonder how on earth could you write an OS, if creating an iso image is too complicated for you.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: How in the world do you set up a GUI??

Post by zhiayang »

turdus wrote:
Actualy I wonder how on earth could you write an OS, if creating an iso image is too complicated for you.
I can make an iso image. I know how to read tutorials. BUT: All those grub2 isos I made refuse to boot anywhere.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: How in the world do you set up a GUI??

Post by Solar »

requimrar wrote:I can make an iso image. [...] All those grub2 isos I made refuse to boot anywhere.
alias making="making successfully"
Every good solution is obvious once you've found it.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: How in the world do you set up a GUI??

Post by zhiayang »

Solar wrote:
requimrar wrote:I can make an iso image. [...] All those grub2 isos I made refuse to boot anywhere.
alias making="making successfully"
... Okay then. Either way, I was just curious. Maybe when I get to that stage grub 2.0 will remove this lame crap.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: How in the world do you set up a GUI??

Post by Solar »

I wouldn't hold my breath for the GRUB maintainers putting much of an effort into "fixing" VBE handling. GRUB is mainly a bootloader for mainstream operating systems, and those come with their own GFX driver architecture...
Every good solution is obvious once you've found it.
rdos
Member
Member
Posts: 3308
Joined: Wed Oct 01, 2008 1:55 pm

Re: How in the world do you set up a GUI??

Post by rdos »

You wouldn't want to use GRUB to change video-mode, simply because you want to be able run your OS without GRUB. GRUB is a bootloader, not a video-BIOS.

The easiest way to change video mode is while you are still in real-mode. Then you can just issue the appropriate calls and it would work unless the BIOS is broken. The best way is to be able to do it at any time, but that requires a pretty good V86 environment. That is not the first thing you want to do.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: How in the world do you set up a GUI??

Post by neon »

Not sure why GrUB doesn't support it... being able to tell the bootloader what video mode you want is defined by the multiboot standard. Does GrUB not implement proper support for it anymore?

In any case, I do agree with rdos - having the bootloader switch video modes creates a dependency between your OS and a specific boot loader and effectively makes it impossible to switch video modes later on. Options include real/v86 modes with VBE or Video BIOS, writing your own SVGA+ drivers, or writing a VGA-compliant driver.

Also, GUI != video driver or graphics API. You need both (of sorts) before being able to set up a GUI.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

Re: How in the world do you set up a GUI??

Post by VolTeK »

requimrar wrote:I know I should switch to real mode to change modes, but how would I do that?

How in the hell did you get into protected mode then.
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: How in the world do you set up a GUI??

Post by quok »

GhostXoPCorp wrote:
requimrar wrote:I know I should switch to real mode to change modes, but how would I do that?
How in the hell did you get into protected mode then.
The OP didn't. Grub did it for him.
rdos
Member
Member
Posts: 3308
Joined: Wed Oct 01, 2008 1:55 pm

Re: How in the world do you set up a GUI??

Post by rdos »

quok wrote:
GhostXoPCorp wrote:
requimrar wrote:I know I should switch to real mode to change modes, but how would I do that?
How in the hell did you get into protected mode then.
The OP didn't. Grub did it for him.
Yeah, the downside of too powerful tools. You don't know how you ended up in protected mode, and you don't know how to exit protected mode, and may not even know what protected mode actually is since GRUB allows you to write your code in C.
:roll:
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: How in the world do you set up a GUI??

Post by piranha »

rdos wrote: Yeah, the downside of too powerful tools. You don't know how you ended up in protected mode, and you don't know how to exit protected mode, and may not even know what protected mode actually is since GRUB allows you to write your code in C.
:roll:
Read: I hate C. Everyone should code in assembly. *cough*theOPsignoranceastowhatprotectedmodeishasnothingtodowithhisusingC,butmoretodowithhislackofresearchandknowledge*cough*

Patching grub to switch modes for you isn't that difficult, I got it working pretty quickly. Other than that, if you're using bochs or Qemu you can write a really simple driver that allows you to switch modes...

All that said, if you don't know how to switch to and from protected mode you should focus on the basics before switching to graphics mode...

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
Mano
Posts: 8
Joined: Mon Jan 09, 2012 4:52 am
Location: Brazil

Re: How in the world do you set up a GUI??

Post by Mano »

Well, I was looking for an easy way to change the video mode. On wiki there's a list of possible ways of doing it, and it's in order of dificulty. Because I'm using GRUB, interrupts won't do. So I decided to search how to patch Grub, and I've found a pre-built patched GRUB on this topic.

I downloaded the stage2_eltorito, replaced it, and changed my menu.lst file. All I did was actually to add a line after the kernel command:

Code: Select all

vbeset XXX
Where XXX is the hex value related to the mode you want. To find out which value to put, I just pressed C to enter grub's command line, and typed the command:

Code: Select all

vbeprobe
It worked for me at least. Anyway, I don't think this is really useful. I still think it's better to study and try to code my own vga driver.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: How in the world do you set up a GUI??

Post by neon »

Yeah, the downside of too powerful tools. You don't know how you ended up in protected mode, and you don't know how to exit protected mode, and may not even know what protected mode actually is since GRUB allows you to write your code in C.
That's not the fault of the software, its the programmer(s). Processor modes are very well documented in the specifications. By not understanding the architecture, the programmer is limited in understanding of the software.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Post Reply