Page 1 of 2
C OS sample
Posted: Mon Oct 31, 2005 12:00 am
by pichalsi
Ive been searching for some simple C kernel, i found some tutorials on osdever.net but most of them somehow didnt work... i use win XP and DJGPP, NASM, and i want to load it with GRUB... all i want is to see "hello world", plz dont send me to some tutorial with 25 pages and 10 files i want only simple sample
thx if its possible
P.S. ive tried this
http://www.invalidsoftware.net/os/?the_id=11, but it didnt work with grub... what loader do i need to load that c++ kernel?
Re: C OS sample
Posted: Mon Oct 31, 2005 12:00 am
by carbonBased
An OS isn't simple. You should probably try to get those other OSs working on your system... it's the best way to learn, for most.
Despite your plea, here's another tutorial that speaks of grub specifically, and gives an example;
http://www.neuraldk.org/document.php?grubKernel
This code may seem similar. That's because its' based on the example that comes with the grub documentation.... in other words, you may already have this 'simple kernel' on your HD as we speak.
As per the OS that didn't work with grub... you should actually read the grub docs (where this sample kernel resides). An OS must comply to certain requirements to be bootable by GRUB. Not every OS will do this.
Cheers,
Jeff
Re: C OS sample
Posted: Tue Nov 01, 2005 12:00 am
by pichalsi
aaaaah I was so fool i tried that OS in Bochs but it always crashed with error like HTL instruction with if=0!, so i become mad and copied it to floppy rebboted pc and it worked... i even got it fixed just by erasing cli and hlt from assembler loader file...
but thx anyway for bothering
EDIT:that site looks really good even the other articles, thx again
Re: C OS sample
Posted: Tue Nov 01, 2005 12:00 am
by JAAman
no, in bochs it worked just fine:
that "error" you found is just a common way of stopping the computer -- removing it will probably
cause it to crash
basically if you clear interupts then hlt, the computer will freaze and never resume, therefore bochs tells you when this happens to let you know that the computer has halted and cannot continue
this is a very common way of ending sample OSs because while a normal OS will never end, you must have much built before this is possible so most "sample" kernels end with:
to halt the system
this really isn't an error and if bochs reports it, that means that it ran successfully (if it failed, bochs would never see the cli hlt and wouldn't report that)
Re: C OS sample
Posted: Tue Nov 01, 2005 12:00 am
by carbonBased
Thanks Pichalsi... neuraldk.org is actually my site
It's in desparate need of an update (and will soon acquire one including a new (vastly superior) release of my OS) but hopefully is found to be useful.
I asked before, but no one responded -- if there's any tutorial topics that people would find useful, please post them here. I'll soon be sitting down to write-up more documentation/tuts on what I've completed during my OSDev experiments and would like to know what people are most interested in.
Cheers,
Jeff
Re: C OS sample
Posted: Tue Nov 01, 2005 12:00 am
by pichalsi
that site is nice but i still have not read whole the tutorial cause i dont have much time now... i just didnt think OS development was so hard
but im not giving up...
JAAman thx for info i didnt know that
Re: C OS sample
Posted: Wed Nov 02, 2005 12:00 am
by Da_Maestro
One thing I hate about sample kernels that use the cli; hlt method of stopping the system is that you can't restart it with ctrl+alt+delete! You must do a physical restart if you halt the system using this method...
I prefer to use this code:
This way, your system can catch the interrupts that are sent when you press ctrl+alt+del (or whatever key combination you use to restart)
Re: C OS sample
Posted: Wed Nov 02, 2005 12:00 am
by JAAman
no, that will only work in RMode: once you enter PMode the 3-finger-salute must be handled by the OS, and bios will not see it
so if the OS is in RMode then
will work but it wont if in PMode
Re: C OS sample
Posted: Sun Dec 04, 2005 12:00 am
by luke
It is not that hard to reboot, just use this code:
Maybe it would be nice to wait for a key too so you can see the result:
Re: C OS sample
Posted: Mon Dec 05, 2005 12:00 am
by carbonBased
The interrupts you reference (0x16 and 0x19) are used in rmode. They will not function as such in pmode unless you've wrong them like this.
--Jeff
Re: C OS sample
Posted: Mon Dec 05, 2005 12:00 am
by rexlunae
If you're just looking for a basic hello world to boot from GRUB, click <a href="http://www.osdev.org/index.html?module=bb&op=viewtopic&p=802">here</a> and scroll down a little.
Don't know what you would need to do to get it working with DJGPP though.
Re: C OS sample
Posted: Fri Dec 16, 2005 12:00 am
by mrd
carbonBased wrote:I asked before, but no one responded -- if there's any tutorial topics that people would find useful, please post them here.
If you make the assumption that most beginners will be starting on x86/wintel systems, then I think it'd be useful to have a 'Getting Started' section which can briefly cover the basics of x86 pc hardware. That is, cpu modes, booting, interrupts, keyboard, mouse, vga, ata, floppy.
This will help seriously interested people get their feet wet instead of getting discouraged after many failed attempts and giving up. The more hobbyists involved, the greater manpower we have to develop community resources.
From here you can cover design topics that aren't tightly tied to wintel hardware. Scheduling, memory management, file management, kernel/driver/process/thread security and communications, networking, video, etc.. and not just how YOU did it, but a discussion of popular algorithms, techniques and implementations.
Links to discussion forums and chats would also be helpful.
Re: C OS sample
Posted: Sun Dec 18, 2005 12:00 am
by Da_Maestro
My OS handles ctrl+alt+del properly. Of course ctrl+alt+del doesn't work if you're in protected mode! What I was saying is that if you use that code to stop your sample kernel, the code you've just written to handle the ctrl+alt+del becomes useless, and not worth the time writing it.
Sample OSes should lead by example and stop a whole heap of newbie OSdevers from ripping their hair out when their ctrl+alt+del code doesn't work!
int 19 won't reboot in protected mode. I use the keyboard controller to assert the #RESET pin on the cpu.
Re: C OS sample
Posted: Tue Dec 20, 2005 12:00 am
by deadmutex
For anyone who wants more info on OSdev, the FAQ and forums at
http://www.mega-tokyo.com/osfaq2/index.php are awesome.
Also I recommend reading some of the books that are listed on
http://www.osdever.net/books.php
(especially Modern Operating Systems by Tanenbaum). If you can't afford to buy them, then you should at least get them from your library.
Re: C OS sample
Posted: Wed Dec 21, 2005 12:00 am
by kerberos
im interested in devloping voice interactive os
simply every command will be executed as in the case of nlp