C OS sample
C OS sample
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?
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?
Last edited by pichalsi on Mon Oct 31, 2005 12:00 am, edited 1 time in total.
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Re: C OS sample
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
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
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
but thx anyway for bothering
EDIT:that site looks really good even the other articles, thx again
Last edited by pichalsi on Tue Nov 01, 2005 12:00 am, edited 1 time in total.
Re: C OS sample
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)
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:
Code: Select all
cli
hlt
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)
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Re: C OS sample
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
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
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
JAAman thx for info i didnt know that
-
- Member
- Posts: 144
- Joined: Tue Oct 26, 2004 11:00 pm
- Location: Australia
Re: C OS sample
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)
I prefer to use this code:
Code: Select all
@loop:
hlt
jmp @loop
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
--- Albert Einstein
Re: C OS sample
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
so if the OS is in RMode then
Code: Select all
.loop
hlt
jmp loop
Re: C OS sample
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:
Code: Select all
int 19h
Code: Select all
mov ah, 0
int 16h
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Re: C OS sample
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
--Jeff
-
- Member
- Posts: 134
- Joined: Sun Oct 24, 2004 11:00 pm
- Location: North Dakota, where the buffalo roam
Re: C OS sample
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.
Don't know what you would need to do to get it working with DJGPP though.
Re: C OS sample
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.carbonBased wrote:I asked before, but no one responded -- if there's any tutorial topics that people would find useful, please post them here.
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.
-
- Member
- Posts: 144
- Joined: Tue Oct 26, 2004 11:00 pm
- Location: Australia
Re: C OS sample
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.
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.
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
--- Albert Einstein
Re: C OS sample
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.
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
im interested in devloping voice interactive os
simply every command will be executed as in the case of nlp
simply every command will be executed as in the case of nlp