Page 1 of 2
Commands available to an OS?
Posted: Wed Jan 14, 2009 9:59 pm
by GeniusCobyWalker
I have extensively looked this up and can not find an answer.
When making an OS what C commands are available? I know you cant draw or do normal string commands, so I was wondering what commands can you use? Are they Bios commands, Processor specific commands, 32, 64 bit commands, or what?
Is there somewhere that tells you?
Or is it like a code library of functions?
Thanks
(First OS

)
Re: Commands available to an OS?
Posted: Wed Jan 14, 2009 10:05 pm
by Troy Martin
Pretty much all there is at your disposal are teh builtin parts of C, no functions. You have to write everything yourself.
Re: Commands available to an OS?
Posted: Wed Jan 14, 2009 10:14 pm
by JohnnyTheDon
Are they Bios commands, Processor specific commands, 32, 64 bit commands, or what?
The BIOS is out of the picture if you are in protected (32) or long (64) mode. And most compilers don't do 16-bit.
Processor "commands" are mostly done through MSRs and control registers. Look at the Intel manuals. These just change the state of the processor. For the most part, they won't do work for you.
Like Troy said, no functions except for built in ones. There are 1000 implementations of the string functions on the internet, and they aren't hard to implement yourself. Here is a hint: rep movsb, rep scasb. Look up those two instructions and string functions will be easy.
Re: Commands available to an OS?
Posted: Wed Jan 14, 2009 10:18 pm
by piranha
All the information that you asked for is already available on the wiki, and in the intel manuals.
Please, research before you post.
-JL
Re: Commands available to an OS?
Posted: Thu Jan 15, 2009 12:10 am
by System123
How about reading some tutorials. There are great ones like James M's OS dev tutorials that will explain this all to you or there is a tutorial here
http://www.brokenthorn.com/Resources/OSDevIndex.html that later ventures into MSVC++ coding.
I am also goin to inform you of a little trade secret in the OS dev underworld. Its called GOOGLE
http://www.google.com just in case you can't find it.
Happy Deving
Re: Commands available to an OS?
Posted: Thu Jan 15, 2009 1:53 pm
by GeniusCobyWalker
Did you all write games and lots of programs in C before starting a C Operating System?
If I look at more C Tutorials wouldn't that not help me at all because they teach to use an OS's C Commands and not just C Commands?
Re: Commands available to an OS?
Posted: Thu Jan 15, 2009 2:46 pm
by JohnnyTheDon
Did you all write games and lots of programs in C before starting a C Operating System?
If I look at more C Tutorials wouldn't that not help me at all because they teach to use an OS's C Commands and not just C Commands?
The "OS's C commands" are called Application Programming Interfaces. They define how your program interacts with the OS.
There are no "C Commands" in OS development. You MUST write everything yourself. There are no functions except the ones you write. Need to draw to the screen? Write a display driver. Need to access the disk? Write a disk driver.
You interface with these devices primarily through A) writing to certain memory locations and B) IO ports. You obvously are not reading or not understanding the tutorials, as they tell you this. Read the barebones tutorial. Build it and run it in an emulator. Mess around with it until you understand what every little bit does. Then you can worry about doing anything else.
Re: Commands available to an OS?
Posted: Thu Jan 15, 2009 3:54 pm
by GeniusCobyWalker
I saw this in bar-bones
kernel.c
This is not exactly your average int main() (which is one of the reasons why you should not call it like that). Most notably, you do not have any library stuff available. As soon as you write so much as #include <, you have probably made the first mistake. Welcome to kernel land.
Is there something that says what you can use?
Tutorials on making drivers? Available drivers, how to use them?
Re: Commands available to an OS?
Posted: Thu Jan 15, 2009 3:59 pm
by JohnnyTheDon
Most notably, you do not have any library stuff available. As soon as you write so much as #include <, you have probably made the first mistake. Welcome to kernel land.
That says it all. There is NOTHING. You have to make everything yourself. You can use stack variables, math/binary operators, your own functions, etc. but no external library functions, malloc, etc. Write your own functions to do the things you want to do. If that is too much, then OS dev isn't for you.
Re: Commands available to an OS?
Posted: Thu Jan 15, 2009 5:11 pm
by neon
If I look at more C Tutorials wouldn't that not help me at all because they teach to use an OS's C Commands and not just C Commands?
There is no such thing as a "C command". I have not a clue where you got that from.
If you mean a "C command" as in printf(), then you are referring to a CRT (C Runtime Library) which depends on the systems user mode System API. In other words, its OS dependent. If you are referring to something else, please elaborate.
Is there something that says what you can use?
In kernel land, you can only use the BIOS's API via interrupts, and only in real or v86 mode. Every single thing else you will need to do yourself.
Tutorials on making drivers? Available drivers, how to use them?
Dont look for these tutorials until you have a good foundation for your OS. When making these drivers, look for tutorials on the hardware device you are looking for as well as the data sheets for the device. Google can be helpful here. Oh, and looking for generic driver tutorials will not be very helpful.
Re: Commands available to an OS?
Posted: Thu Jan 15, 2009 5:46 pm
by Love4Boobies
Looking at driver interfaces however, is a different thing. But you need to have a good understanding of what's going on before looking into that. From your use of the word command, I'm ready to bet you don't know assembly, nor how the CPU handles code and data. If this is true, learn assembly first (where you have instructions, not commands).
Re: Commands available to an OS?
Posted: Thu Jan 15, 2009 5:59 pm
by GeniusCobyWalker
heres a print command:
unsigned int k_printf(char *message, unsigned int line) // the message and then the line #
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
i=(line*80*2);
while(*message!=0)
{
if(*message=='\n') // check for a new line
{
line++;
i=(line*80*2);
*message++;
} else {
vidmem=*message;
*message++;
i++;
vidmem=WHITE_TXT;
i++;
};
};
return(1);
};
1) How did they know that video was oxb8000 and 0x0F was White on black? where is this info?
Thats what I was trying to ask before.
2)Also should I write a command-prompt OS before a GUI OS, and can I later add a GUI on top of my command-prompt if I do it first?
Re: Commands available to an OS?
Posted: Thu Jan 15, 2009 6:10 pm
by neon
heres a print command
No its not. Its a
routine,
function, or a
method. Please use the proper terminology.
1) How did they know that video was oxb8000 and 0x0F was White on black? where is this info?
Thats what I was trying to ask before.
On most VGA hardware, text mode video memory begins at 0xB8000 or 0xB0000. Each character contains two bytes, the ascii character code and the characters attribute. Im sure there is something in the Wiki that describes it in more detail...
2)Also should I write a command-prompt OS before a GUI OS, and can I later add a GUI on top of my command-prompt if I do it first?
I highly recommend the first method (console based then graphical based.) You can add a GUI shell later if you want. Much much later.
Re: Commands available to an OS?
Posted: Thu Jan 15, 2009 6:19 pm
by piranha
1) How did they know that video was oxb8000 and 0x0F was White on black? where is this info?
Thats what I was trying to ask before.
2)Also should I write a command-prompt OS before a GUI OS, and can I later add a GUI on top of my command-prompt if I do it first?
I think I may cry.
It's at that location because thats where someone decided it should be. The information is readily available and you should know it.
Yes, that a much better method for you (and I like it better too). But realize that you have a LOT of work to do before that happens.
-JL
Re: Commands available to an OS?
Posted: Thu Jan 15, 2009 6:54 pm
by GeniusCobyWalker
. The information is readily available and you should know it.
Where is it at?
Where did you see it at?