Page 1 of 1

10 Stuffs (GUI,more)???

Posted: Tue Feb 14, 2012 10:02 am
by Yashas
GUI:

1)What do I need to develop a basic GUI?
Something like DOS or Windows 3.0 Shell ,Squarish Windows.

2)How to get a higher resolution in protected mode in C?
3)How to print a Character at the centre of the screen?(C only)
4)How to make a cursor move according to x and y of the mouse?(I have the x and y but I just 5)need a cursor on the screen)


Someother stuff:
6)How to check weather a mouse is connected or not?
7)How to identify a Keyboard Layout?
8)How to dump the registers on the screen?(C Code)
9)How does an USB mouse work?
10)Important:

I enable A_20 through the keyboard.On few PC's they wont work so I want to combine all the methods ofenabling a_20 and try each of them until it is enabled.How to make such a code in C.

Thank You in advance. :D [-o<

Re: 10 Stuffs (GUI,more)???

Posted: Tue Feb 14, 2012 10:42 am
by bluemoon
Yashas wrote:1)What do I need to develop a basic GUI?
Something like DOS or Windows 3.0 Shell ,Squarish Windows.
It can be split into widget management, signalling and rendering, each require some knowledge.
PS. DOS has no built-in Graphical User Interface.
Yashas wrote:2)How to get a higher resolution in protected mode in C?
Check the wiki, however it involve low level operations when are outside the scope of C, which require inline assembly or external modules.
By the way, the easier way is probably do it in real mode, or let it handle by grub.
Yashas wrote:3)How to print a Character at the centre of the screen?(C only)
Depends on video mode. Some graphic mode support text buffer which you simply write text in the memory; other mode may require you draw the text by pixel.
Yashas wrote:4)How to make a cursor move according to x and y of the mouse?(I have the x and y but I just 5)need a cursor on the screen
Check the wiki on how to access the mouse events. and you draw the cursor on screen (I'm not sure on acceleration displays).
Yashas wrote:6)How to check weather a mouse is connected or not?
There is a thread talk about this recently. IMO for hobby/early stage OS you may just assume some standard equipments exists.
Yashas wrote:7)How to identify a Keyboard Layout?
Linux, FreeBSD and Mac OS X do ask the user.
Yashas wrote:8)How to dump the registers on the screen?(C Code)
C has no concept of registers. Think again.
Yashas wrote:9)How does an USB mouse work?
I think it's too complicated. It may require a few books for such topic.
Yashas wrote: 10)Important:
I enable A_20 through the keyboard.On few PC's they wont work so I want to combine all the methods of enabling a_20 and try each of them until it is enabled.How to make such a code in C.
I presume you have assembly part to do the dirty work of A20 thingy.
To test if A20 is enabled with C, you write test pattern on odd MiB address and check the even address. However some precaution to make sure the address you try to write is legal; such legal address space can be obtained from BIOS memory map.

Re: 10 Stuffs (GUI,more)???

Posted: Tue Feb 14, 2012 10:59 am
by bubach
Hi,
wow, you need to slow down and tackle one problem at a time.. :shock:
1)What do I need to develop a basic GUI?
Something like DOS or Windows 3.0 Shell ,Squarish Windows.
An Operating System to do it on would be preferable. Are you going to write it for an existing OS you'd need to figure out how to set a graphics mode and, well.. how to put this nicely.. how to google. For your own OS you would need a basic kernel with at least keyboard, mouse, memory management and VESA support.
2)How to get a higher resolution in protected mode in C?
Like any other programming language. You could use standard VGA 640*480px with 16 colors to get an easy start, and make some window/button code. For a more serious resolution and more colors you'd need to set up VESA, easiest to to before entering protected mode. See the wiki.
3)How to print a Character at the centre of the screen?(C only)
In what, text mode? Depends on the mode and resolution.
4)How to make a cursor move according to x and y of the mouse?(I have the x and y but I just 5)need a cursor on the screen)
Again, depends on the text mode or graphics mode you are in. If it's normal 80*25 text mode 0x03, check the wiki on VGA/text basics.
6)How to check weather a mouse is connected or not?
PS/2 mouse is fairly easy, with the keyboard controller. See the wiki for info/links.
7)How to identify a Keyboard Layout?
For language? Not sure you can... even win7 asks the user at install.. Hmm, check the wiki to be sure, and once again, try google.
8 ) How to dump the registers on the screen?(C Code)
You need a function to print hex, and then call it. Do you even have a function to print to screen? Finding out how to convert hex to ASCII is also just one google away. So asking for ready to use code is insulting to most people here - mostly since it's so easy to find examples and code by just searching and reading the wiki.
9)How does an USB mouse work?
Well basically it works over the USB protocol. *suprise* So you'd need USB support first, which isn't something you start out with. PS/2 emulation will have to do until you get a grasp on the basics.
10)Important: I enable A_20 through the keyboard.On few PC's they wont work so I want to combine all the methods ofenabling a_20 and try each of them until it is enabled.How to make such a code in C.
So, you have code to enable the A20? And you want to add more ways to do it, is that correct? Start by checking the wiki and google for ways to set the A20 gate, and then add those methods to your existing code. I don't see the problem.

Hope that helps, and be sure to read the wiki!

Re: 10 Stuffs (GUI,more)???

Posted: Tue Feb 14, 2012 11:14 am
by Yashas
I have print hex, decimal and also binary(Not perfect).
Can I just do it like this

tempregval is defined as a signed int

mov tmpregval,eax

then call in at C as printhex(tempregval);
Or something else

Re: 10 Stuffs (GUI,more)???

Posted: Tue Feb 14, 2012 11:20 am
by bubach
Yes something like that, see this thread on how to get register value in GCC:
http://forum.osdev.org/viewtopic.php?f=1&t=24803

Re: 10 Stuffs (GUI,more)???

Posted: Tue Feb 14, 2012 11:45 am
by bluemoon
dump_register() is one of the useless function if you have a proper debugging environment like bochs or qemu+gdb...
but it's a nice topic for learning.

Re: 10 Stuffs (GUI,more)???

Posted: Tue Feb 14, 2012 11:48 am
by Yashas
I just wanted to attach my own debugging tool to my os.It has few stuff for debuggin for example it shows current process,tasks, and a detailed report of the error when it takes place.

Now i have the function to dump the registers.

Got my A_20 also.I just the test function of the http://wiki.osdev.org/A20_Line
Alsoo i hope this is correct to call a assembly function in C

void haltsys ()
{
__asm__ ("hlt");

}

Re: 10 Stuffs (GUI,more)???

Posted: Tue Feb 14, 2012 12:50 pm
by Brendan
Hi,
Yashas wrote:1)What do I need to develop a basic GUI?
First, make sure you've got all the basic stuff working (boot code, physical memory management, virtual memory management, SMP, scheduler, IPC). This all needs to work reliably.

Next start work on generic device management. Things like support for IRQs, PCI configuration space, etc. It should also include device detection and enumeration, and resource assignment (setting BARs, etc).

Once all that is working, stop programming. It's time to write formal specifications that describe the interface/s between device drivers and the OS. You'd need one for storage device drivers, one for "user input" devices (keyboard, mouse, etc) and one huge one for video. While you're at it you should also do something similar for file systems, and the VFS. You could do more at this point if you want - e.g. something for sound, font engine, etc.

Once that is out of the way, I'd probably start with an ATA or SATA/AHCI driver (that complies with the "storage device interface specification" you wrote). After that would be a very simple file system (FAT32?) and the VFS (mount/unmount, caching, etc). Once you can load files via. the VFS it's time to add support for executing files to your kernel; and after that you can modify your device detection/enumeration code so that it tries to load/start device drivers (from the VFS) for any detected hardware.

Next would be a few more device drivers - PS/2 keyboard and mouse, generic "VBE only" video driver, USB if you have to.

After all of this, you're almost ready to start working on the GUI. You need a secure login thing first though (e.g. username and password prompt). When a user logs in you check their configuration file to determine which executable to use for their GUI.

Next, you want write another formal specification that describes the interface between applications and the GUI.

Finally, after several years of hard work, start writing the GUI. This should be very easy to do, because you should already have everything you need written down in formal specifications and implemented (and tested) in drivers, etc. Mostly it's just gluing stuff that you've already done together.
Yashas wrote:2)How to get a higher resolution in protected mode in C?
You'd need to write a native video driver for your specific video card. An alternative would be using VBE in real mode in a mixture of C and assembly.
Yashas wrote:3)How to print a Character at the centre of the screen?(C only)
I'd create a little "comand list" that says "clear the canvas and draw the unicode string in the middle" and send it to my video driver. The video driver would execute the list of commands I sent (except it'd ask the font engine to convert the unicode string into bitmap data).
Yashas wrote:4)How to make a cursor move according to x and y of the mouse?(I have the x and y but I just 5)need a cursor on the screen)
Just upload a "cursor" texture into your video driver; then tell the video driver where to draw this texture whenever the mouse moves. Hopefully the video driver will support hardware cursors (but if it doesn't it'd need to do it in software).
Yashas wrote:6)How to check weather a mouse is connected or not?
USB device enumeration (for USB), or from its response to the "identify" command (for PS/2).
Yashas wrote:7)How to identify a Keyboard Layout?
This is one of the things that annoys me. The USB specs for keyboards (HID) include fields that should be used to describe keyboard layout, but keyboard manufacturers are assholes that ignore these fields and pretend everything is "US QWERTY" layout even when it's not. In some (rare) cases it might actually work correctly, but if the keyboard says it's "US QWERTY" you don't know if it is or not. For PS/2 it can't be done either (legacy stuff that never supported it); however, for some laptops you can cheat (e.g. use SMBIOS to determine which specific laptop, and use that to infer the type of the built-in keyboard).

Basically (except for rare cases) you have to ask the user. Of course the user won't know the difference between "US QWERTY" and "UK QWERTY" or whatever else (and then they'll complain that it doesn't work when they've set it wrong); so it's best to have a set of pictures and get them to select the picture that best represents their keyboard layout.

Also don't forget virtual keyboards (e.g. touchscreen where the user presses a picture of a keyboard) and things like input method editors. I'd want to be fairly careful with security too (try to make keyloggers impossible).
Yashas wrote:8)How to dump the registers on the screen?(C Code)
Write an assembly language stub that stores the registers in a structure and passes the structure to C code.
Yashas wrote:9)How does an USB mouse work?
USB mouse works fairly well (almost as good as a PS/2 mouse, just a bit slower). My USB mouse is starting to get old though - the left mouse button has to be pressed "just right". :)
Yashas wrote:10)Important:

I enable A_20 through the keyboard.On few PC's they wont work so I want to combine all the methods ofenabling a_20 and try each of them until it is enabled.How to make such a code in C.
First, detect if A20 is already enabled and do nothing if you can. If A20 is disabled, start by trying the BIOS function and test again. If that didn't work try the keyboard controller.


Cheers,

Brendan

Re: 10 Stuffs (GUI,more)???

Posted: Tue Feb 14, 2012 3:22 pm
by VolTeK
Yashas wrote: GUI:

1)What do I need to develop a basic GUI?
Something like DOS or Windows 3.0 Shell ,Squarish Windows.

2)How to get a higher resolution in protected mode in C?
3)How to print a Character at the centre of the screen?(C only)
4)How to make a cursor move according to x and y of the mouse?(I have the x and y but I just 5)need a cursor on the screen)


Someother stuff:
6)How to check weather a mouse is connected or not?
7)How to identify a Keyboard Layout?
How to dump the registers on the screen?(C Code)
9)How does an USB mouse work?
10)Important:

I enable A_20 through the keyboard.On few PC's they wont work so I want to combine all the methods ofenabling a_20 and try each of them until it is enabled.How to make such a code in C.

Thank You in advance.

These questions are for Google and a search on the wiki. Or observing what others have done. However,


These are NOT questions to ask when your not even remotely near the point of even working on a GUI. If your in this for looks, making two box's from two different processes or at least two child windows from a process, just overlap, will be a journey for you. Not just to get it to work, but writing the manager so other windows from other processes can do the same, and over other windows as well. Like i said, if your in this for looks, find another hobby. There are more battles over the hill ahead.

Not being rude, but hope you will understand. It looks cool, but it probably took months to code, and a year to research and design.

Re: 10 Stuffs (GUI,more)???

Posted: Wed Feb 15, 2012 3:08 pm
by Combuster
berkus wrote:
Brendan wrote:First, detect if A20 is already enabled and do nothing if you can. If A20 is disabled, start by trying the BIOS function and test again. If that didn't work try the keyboard controller.
Also, detect if A20 gate is ever present before trying to do anything with is (ACPI tables should help with that afaict). Otherwise you will hard-lock the machine.
Checking it's state before any attempts at changing the A20 line is safe - if there's no gate A20 any attempts to observe it will tell you it's enabled and any of the destructive code for that platform can consequently be skipped.