Page 1 of 1

Porting Newlib/Handling System Calls

Posted: Thu Feb 21, 2013 4:14 pm
by twixthehero
Hello -

I'm at the part of building my own OS where I need to port Newlib. On the Porting Newlib page, it says I have to support a set of 17 system calls. Where/How exactly do I do this? The basic kernel from the C++ tutorial doesn't handle interupts.

Thanks

Re: Porting Newlib/Handling System Calls

Posted: Thu Feb 21, 2013 5:22 pm
by Griwes
There are few nonsensical things in your post.
I need to make a cross compiler
You don't *need*, you are just encouraged to do so.
On the Porting Newlib page
Whoa, that was quick jump from one topic to another...
Where/How exactly do I do this?
Wrong hobby, if you have to ask this question this way...

And the best for the end. Look at these two quotes:
The basic kernel from the C++ tutorial doesn't handle interupts.
building my own OS
and try to guess what is the most utterly stupid thing you wrote in that post.

You have very huge misconception of how things work in this field.

Re: Porting Newlib/Handling System Calls

Posted: Thu Feb 21, 2013 5:41 pm
by feare56
I can understand the porting newlib question but if you don't know how to do a system call I wish you all the luck with making your "own" os

Re: Porting Newlib/Handling System Calls

Posted: Thu Feb 21, 2013 6:36 pm
by twixthehero
You don't *need*, you are just encouraged to do so.
Then why is it in 90% of the posts, people with compiling problems are told they need cross compilers. I assumed that this is the "better" option because everyone does this. I even remember reading a thread here where a poster said something like: "I remember the days when we didn't tell everyone they needed a cross compiler."
Whoa, that was quick jump from one topic to another...
What is the title of the thread? "Porting Newlib/Handling System Calls"
Wrong hobby, if you have to ask this question this way...
Well excuse me for trying to learn how OS's work by making my own.
And the best for the end. Look at these two quotes:
The basic kernel from the C++ tutorial doesn't handle interupts.
building my own OS
I know it doesn't handle interrupts. I even said that in my post! The point is to learn HOW it can be done.
and try to guess what is the most utterly stupid thing you wrote in that post.
What might that be? Even posting?...
You have very huge misconception of how things work in this field.
Well then correct me! I'm here to learn, not get told off.

Maybe I should refine my original question even more to get a good answer: What exactly is an interrupt? And why (if I even do) would I need it to handle the system calls that newlib requires?
feare56 wrote:I can understand the porting newlib question but if you don't know how to do a system call I wish you all the luck with making your "own" os
How would I know how to do a system call immediately off the bat? The tutorial doesn't. cover. it. I don't want people to write code for me, because then it's not my work, and I still wouldn't understand what they did.

Re: Porting Newlib/Handling System Calls

Posted: Thu Feb 21, 2013 6:52 pm
by feare56
Well the tutorials think that you have a lot of knowledge in programming and the language you are using they are just there to help you get a bootable kernel that you can take and make it close to your own then later you can decide to redo it and truly make it your own.

Re: Porting Newlib/Handling System Calls

Posted: Thu Feb 21, 2013 8:47 pm
by FallenAvatar
I think the problem most people have with your post is the following:

1) There is a rather large link at the top of every page of this forum with the text "The OSDev.org Wiki - Got a question? Search this first!"
2) The link takes you to a wiki (the collected knowledge of many many many programmers before you)
3) Less than 1 page down is a link titled Interrupts that has a rather succinct definition of interrupts and how/why/when to use them.

- Monk

Re: Porting Newlib/Handling System Calls

Posted: Thu Feb 21, 2013 10:22 pm
by twixthehero
tjmonk15 wrote:I think the problem most people have with your post is the following:

1) There is a rather large link at the top of every page of this forum with the text "The OSDev.org Wiki - Got a question? Search this first!"
2) The link takes you to a wiki (the collected knowledge of many many many programmers before you)
3) Less than 1 page down is a link titled Interrupts that has a rather succinct definition of interrupts and how/why/when to use them.

- Monk
My apologies, but I did not think to search "Interrupts"! Derp :P Thank you very much!

Re: Porting Newlib/Handling System Calls

Posted: Fri Feb 22, 2013 1:54 am
by iansjack
Interrupts are a red herring; they are not equivalent to system calls (although one way to implement system calls is with software interrupts). All a system call is is a means for a user program to request a particular service from the Operating System kernel. For example, one of those system calls concerns opening a file. You need to write a routine to open a file and then provide a means for a program to "call" this routine. You can do this via a software interrupt, via the SYSCALL instruction, or any other means that you see fit. As far as the user program is concerned this is implemented as a function with specified parameters. (But, to be fair, you will probably need to learn about interrupts to best talk to the hardware.)

I'd have to say that if you don't understand this, and don't already have routines in your kernel to provide such operations as opening, reading, writing, and closing files, allocating blocks of memory, loading and executing programs, etc., then it is a little premature to be looking at porting a standard library. None of the standard tutorials that I am aware of go into this sort of detail, but by implementing these system calls and eventually porting the library (and then, ideally, an assembler, linker, and even C compiler) you will learn a lot. This is the difficult - and fun - part of writing your own OS (as opposed to typing in a tutorial), but don't expect to complete it in a week or two. In many senses your system calls are what defines your operating system.

I would recommend that rather than just following tutorials you read a few books on OS design and PC hardware (and, of course, read the articles on this Wiki and other online sources) so that you can produce your own design rather than just following someone else's.