How to use newlib
How to use newlib
Err, maybe this is a stupid question, but I'm a "pre-beginner"
After porting building newlib what do have to do ? And how to integrate newlib to my OS ?
After porting building newlib what do have to do ? And how to integrate newlib to my OS ?
"Programmers are tools for converting caffeine into code."
Re: How to use newlib
Have you already ported newlib? If you have, the question is "what do you want to do?". What is the aim of your OS?
From the second part of your question, I would assume the next thing would be to create a native build of GCC using your newly ported C library. I don't quite understand how a "pre-beginner" has already ported newlib, though?
Cheers,
Adam
From the second part of your question, I would assume the next thing would be to create a native build of GCC using your newly ported C library. I don't quite understand how a "pre-beginner" has already ported newlib, though?
Cheers,
Adam
Re: How to use newlib
Seems like I haven't rebuild the toolchain using the newlib yet
http://wiki.osdev.org/OS_Specific_Toolchain
Or, according to this page http://wiki.osdev.org/GCC_Cross-Compiler , I've done step 2 so far.
"pre-beginner" == beginner + stupid + lazy
http://wiki.osdev.org/OS_Specific_Toolchain
Or, according to this page http://wiki.osdev.org/GCC_Cross-Compiler , I've done step 2 so far.
"pre-beginner" == beginner + stupid + lazy
"Programmers are tools for converting caffeine into code."
Re: How to use newlib
Ok, so now I'm working on my OS ( the first one). I'm going to use Newlib. And it says, for eaxample, printf needs
How do I implement these, and where should I put them?Supporting OS subroutines required: close, fstat, isatty, lseek, read, sbrk, write.
"Programmers are tools for converting caffeine into code."
Re: How to use newlib
How I started was by placing the text of files I wanted to compile inside my turbo asm's output kernel binary image. I then made an interpreter. For the command-line you need an interpreter and you probably want to parse batch-file scripts of some sort. The scripts I wanted done, i placed into the binary image before I had a file system.
For parser you make a lexical analyser which filters-out comments, gets the next tolken, a string, an indentifier, a number, etc. The parser must handle expressions. You can do a LR parse if you look it up, but it's not efficient. Anyway, you'll probably want to build an expression tree and a function to evaluate an expression.
Eventually, i converted from an interpreter to a compiler -- pretty easy. I made a file system. I have low level routines to read and write blocks, a routine to allocate a block (or cluster), routines to make a directory entry, delete a directory entry or find directory entries, read and write files by allocating clusters and storing data.
It's a lot of work. Are you doing it to have fun? You might want to use more stuff from other people, i don't know.
For parser you make a lexical analyser which filters-out comments, gets the next tolken, a string, an indentifier, a number, etc. The parser must handle expressions. You can do a LR parse if you look it up, but it's not efficient. Anyway, you'll probably want to build an expression tree and a function to evaluate an expression.
Eventually, i converted from an interpreter to a compiler -- pretty easy. I made a file system. I have low level routines to read and write blocks, a routine to allocate a block (or cluster), routines to make a directory entry, delete a directory entry or find directory entries, read and write files by allocating clusters and storing data.
It's a lot of work. Are you doing it to have fun? You might want to use more stuff from other people, i don't know.
Re: How to use newlib
What do you mean? "close, fstat, isatty, lseek, read, sbrk, write" is syscalls, not shell commands !LoseThos wrote:How I started was by placing the text of files I wanted to compile inside my turbo asm's output kernel binary image. I then made an interpreter. For the command-line you need an interpreter and you probably want to parse batch-file scripts of some sort. The scripts I wanted done, i placed into the binary image before I had a file system.
For parser you make a lexical analyser which filters-out comments, gets the next tolken, a string, an indentifier, a number, etc. The parser must handle expressions. You can do a LR parse if you look it up, but it's not efficient. Anyway, you'll probably want to build an expression tree and a function to evaluate an expression.
Eventually, i converted from an interpreter to a compiler -- pretty easy. I made a file system. I have low level routines to read and write blocks, a routine to allocate a block (or cluster), routines to make a directory entry, delete a directory entry or find directory entries, read and write files by allocating clusters and storing data.
It's a lot of work. Are you doing it to have fun? You might want to use more stuff from other people, i don't know.
"Programmers are tools for converting caffeine into code."
Re: How to use newlib
Why bother doing an operating system if you start with a standard library? Explain what your goals are. I use nothing standard and use not a single line of code from elsewhere.
Suppose you speak spanish, make the key words spanish and non ASCII.
I laugh at all the people who are not patient and use other people's code. It give the appearance of getting stuff done fast, but in the end, you've accomplished nothing but plugged together a few modules. If you're playing around, set less ambitious goals.
Be patient and do it from scratch.
Suppose you speak spanish, make the key words spanish and non ASCII.
I laugh at all the people who are not patient and use other people's code. It give the appearance of getting stuff done fast, but in the end, you've accomplished nothing but plugged together a few modules. If you're playing around, set less ambitious goals.
Be patient and do it from scratch.
Re: How to use newlib
Because you don't use standard code from others so you may not know. I use Newlib because I don't want to have myself implementing all the libc - an must have part in any OS. And as I port it to suit my OS, I need to work around with my own syscalls ( it is supposed to be OS-dependent). Using standard lib will help me extend my OS easier later (as I can run lots of linux or posix compatible apps).LoseThos wrote:Why bother doing an operating system if you start with a standard library? Explain what your goals are. I use nothing standard and use not a single line of code from elsewhere.
If you want, you can roll your own code. Maybe I'm lazy ( I said before ). And does it really necessary for me to do everything if there are standard code ? Lots of people don't thing so.
"Programmers are tools for converting caffeine into code."
Re: How to use newlib
Hi,
The OP asked a question. He expects an answer, not a paragraph on how you made a LR(1) parser.
Others prefer not to write every component of their hobby OS project, and just write the stuff they are interested in, which may or may not include the grime of writing a C library (see Solar's PDCLib for how long a properly implemented and tested portable C library takes to implement).
Either way it is irrelevant to the OP's question.
Realistically using others' code in certain places in your own solution can be a good thing. It helps you learn to interface with prewritten code, and to read and understand specifications and documentation, which are essential life skills in the world of software engineering.
@quanganht:
Those functions are POSIX-standard. Look them up in the POSIX specification to see how they should behave and what their proper signature is.
Normally you implement these functions yourself and "glue" them into newlib, using one of several methods. See Porting Newlib for full documentation.
Cheers,
James
The rule of thumb on these forums is to answer the question given, not one you make up so that you can give a commentary as to how you implemented something.LoseThos wrote:How I started was by placing the text of files I wanted to compile inside my turbo asm's output kernel binary image. I then made an interpreter. For the command-line you need an interpreter and you probably want to parse batch-file scripts of some sort. The scripts I wanted done, i placed into the binary image before I had a file system.
For parser you make a lexical analyser which filters-out comments, gets the next tolken, a string, an indentifier, a number, etc. The parser must handle expressions. You can do a LR parse if you look it up, but it's not efficient. Anyway, you'll probably want to build an expression tree and a function to evaluate an expression.
Eventually, i converted from an interpreter to a compiler -- pretty easy. I made a file system. I have low level routines to read and write blocks, a routine to allocate a block (or cluster), routines to make a directory entry, delete a directory entry or find directory entries, read and write files by allocating clusters and storing data.
It's a lot of work. Are you doing it to have fun? You might want to use more stuff from other people, i don't know.
The OP asked a question. He expects an answer, not a paragraph on how you made a LR(1) parser.
Some people prefer to implement parts at a time, and use pluggable components written by others that definitely work until they know the code that they wrote themselves works. It's a type of unit-design methodology.LoseThos wrote:Why bother doing an operating system if you start with a standard library?
Others prefer not to write every component of their hobby OS project, and just write the stuff they are interested in, which may or may not include the grime of writing a C library (see Solar's PDCLib for how long a properly implemented and tested portable C library takes to implement).
Either way it is irrelevant to the OP's question.
I believe he explained his goal - to use newlib as the C library in his OS.Explain what your goals are.
That's very clever of you. I'm sure many people will pat you on the back for reinventing the wheel. I'm not one of them.I use nothing standard and use not a single line of code from elsewhere.
On what evidence do you base this supposition?Suppose you speak spanish, make the key words spanish and non ASCII.
I laugh at people who feel the only way to accomplish anything is to write every line of code yourself. Actually, that's a lie. I don't laugh at anyone because of their design methodologies and personal inclinations. You seem to, however.I laugh at all the people who are not patient and use other people's code. It give the appearance of getting stuff done fast, but in the end, you've accomplished nothing but plugged together a few modules. If you're playing around, set less ambitious goals. Be patient and do it from scratch.
Realistically using others' code in certain places in your own solution can be a good thing. It helps you learn to interface with prewritten code, and to read and understand specifications and documentation, which are essential life skills in the world of software engineering.
@quanganht:
Those functions are POSIX-standard. Look them up in the POSIX specification to see how they should behave and what their proper signature is.
Normally you implement these functions yourself and "glue" them into newlib, using one of several methods. See Porting Newlib for full documentation.
Cheers,
James
Re: How to use newlib
Well, thanks very much. I've seen wiki page, but I thought the syscalls in there were " Minimal implementation" ???JamesM wrote: Those functions are POSIX-standard. Look them up in the POSIX specification to see how they should behave and what their proper signature is.
Normally you implement these functions yourself and "glue" them into newlib, using one of several methods. See Porting Newlib for full documentation.
Cheers,
James
Thanks again.
Actually, I speak VietnameseLoseThos wrote:Suppose you speak spanish, make the key words spanish and non ASCII.
Another thing that you might not know yet, I'm just 16 years old, so I'm not clever enough to go all by myselfLoseThos wrote:I use nothing standard and use not a single line of code from elsewhere.
"Programmers are tools for converting caffeine into code."
Re: How to use newlib
Hi,
Cheers,
James
They are minimally implemented. You need to add your own code to make the function operate in the way described in the POSIX specification which I linked to (I actually linked to the documentation for the open() function). The wiki page however will tell you how to get that code "glued" into newlib.quanganht wrote:Well, thanks very much. I've seen wiki page, but I thought the syscalls in there were " Minimal implementation" ???JamesM wrote: Those functions are POSIX-standard. Look them up in the POSIX specification to see how they should behave and what their proper signature is.
Normally you implement these functions yourself and "glue" them into newlib, using one of several methods. See Porting Newlib for full documentation.
Cheers,
James
Thanks again.
Cheers,
James
Re: How to use newlib
Oh I see now
Agian, thanks.
Agian, thanks.
"Programmers are tools for converting caffeine into code."
Re: How to use newlib
It's easier to make a standard than implement one. If you use GCC, you will be locking yourself into an object file format and a language syntax. You have to do a parser for the command line anyway, just make your own languages. I'm sure the elf object file is crusty. I've seen formats like that. You will be starting a 64-bit OS encumbered with cruft.
Edit: OT content removed - AJ
Edit: OT content removed - AJ
Re: How to use newlib
Reinventing something because you're too lazy or arrogant about your own programming prowess to investigate currently existing solutions is a retarded idea. End of story.LoseThos wrote:It's easier to make a standard than implement one. If you use GCC, you will be locking yourself into an object file format and a language syntax. You have to do a parser for the command line anyway, just make your own languages. I'm sure the elf object file is crusty. I've seen formats like that. You will be starting a 64-bit OS encumbered with cruft.