Any C++ basic kernel example?
Any C++ basic kernel example?
Hey, before writting my kernel, I want to test something. So, I wish somebody would give me a kernel example (written in C++). I only need that this kernel has a basic input/output library, so I could add some commands.
Here, there are a lot of OSdevelopers, there might be a simple open-sourced kernel like the one that I am looking for.
Thanks.
Here, there are a lot of OSdevelopers, there might be a simple open-sourced kernel like the one that I am looking for.
Thanks.
Re: Any C++ basic kernel example?
You won't believe but read http://wiki.osdev.org/C%2B%2B_Bare_Bones
Re: Any C++ basic kernel example?
I have read that before, but know I don't want to create a kernel. I only want to test something. When I will have tested that, I will start to create the kernel.Nable wrote:You won't believe but read http://wiki.osdev.org/C%2B%2B_Bare_Bones
Re: Any C++ basic kernel example?
Erm.. As for me, the article contains enough code for building some small testing environment.
Re: Any C++ basic kernel example?
I need a little bit more and it has to be faster, because if the test fails, I am going to change my idea of how the kernel should be.Nable wrote:Erm.. As for me, the article contains enough code for building some small testing environment.
-
- Member
- Posts: 255
- Joined: Tue Jun 15, 2010 9:27 am
- Location: Flyover State, United States
- Contact:
Re: Any C++ basic kernel example?
This isn't a place to ask for code.
Either code it yourself, or find some existing implementation and port it.
Writing to screen is exceedingly easy if you stick to the basics.
Remember, if you can do it in C, you can do it in C++ with little to no change to the code.
Either code it yourself, or find some existing implementation and port it.
Writing to screen is exceedingly easy if you stick to the basics.
Remember, if you can do it in C, you can do it in C++ with little to no change to the code.
Re: Any C++ basic kernel example?
Ok, I am going to port my C kernel to C++. Thanks.Tosi wrote:This isn't a place to ask for code.
Either code it yourself, or find some existing implementation and port it.
Writing to screen is exceedingly easy if you stick to the basics.
Remember, if you can do it in C, you can do it in C++ with little to no change to the code.
Re: Any C++ basic kernel example?
No, you don't have to implement it to test your idea, you're not writing linux huh?platform wrote:I need a little bit more and it has to be faster, because if the test fails, I am going to change my idea of how the kernel should be.
For complex problem like kernel design, you test your idea by running thru the design documents and diagrams.
Re: Any C++ basic kernel example?
It's not the idea what needs to be tested, I only want to test how a c++ program that I have runs in a minimal kernel.bluemoon wrote:No, you don't have to implement it to test your idea, you're not writing linux huh?platform wrote:I need a little bit more and it has to be faster, because if the test fails, I am going to change my idea of how the kernel should be.
For complex problem like kernel design, you test your idea by running thru the design documents and diagrams.
Re: Any C++ basic kernel example?
By the way, I have tested many times the C++ Bare bones and:
loader.s:18: Error: junk at end of line, first unrecognized character is `,'
Can anybody tell me what is the mistake that I have commited?
loader.s:18: Error: junk at end of line, first unrecognized character is `,'
Can anybody tell me what is the mistake that I have commited?
Re: Any C++ basic kernel example?
The C++ barebone tutorial is about writing kernel in C++, not about running C++ program with your kernel.
In order to run user-space application (in particular with C++ runtime, and a reasonable set of syscall), the kernel itself already require lots of features.
I consider my kernel a very minimum just to run a C program:
This requires over 5000 lines of code, which is comparable to the scale of a 3D engine with scene management and particle dynamics.
If you are having trouble building the barebone, I very doubt looking into codebase of such amount would provide any reasonable insight.
A more productive way is that you go thru the tutorials and ask questions.
Try type it by hand, you are not suggested to copy&paste anyway.
(Hint: check loader.s line 18 to see any hidden character, then delete the whole line and type it by hand)
In order to run user-space application (in particular with C++ runtime, and a reasonable set of syscall), the kernel itself already require lots of features.
I consider my kernel a very minimum just to run a C program:
Code: Select all
$ cat testapp/main.c
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main ( int argc, char *argv[] ) {
int pid = (int)getpid();
for (int i=0;i<pid+3;i++) {
printf (" PID[%d]: Hello again! counter=%d\n", pid, i);
usleep((useconds_t) (1000000));
}
return (int)0xBADC0DE0+ (int)pid;
}
SLOC Directory SLOC-by-Language (Sorted)
4958 kernel ansic=2205,asm=1354,cpp=1253,sh=146
679 boot asm=679
430 drivers ansic=288,sh=142
338 libgloss asm=226,sh=112
143 mkinitrd cpp=143
124 testapp sh=112,ansic=12
92 mkdiskimage cpp=92
If you are having trouble building the barebone, I very doubt looking into codebase of such amount would provide any reasonable insight.
A more productive way is that you go thru the tutorials and ask questions.
I copy&paste the code and it assemble without error, have you verify that your browser do not insert junk when copy&paste?platform wrote:By the way, I have tested many times the C++ Bare bones and:
loader.s:18: Error: junk at end of line, first unrecognized character is `,'
Try type it by hand, you are not suggested to copy&paste anyway.
(Hint: check loader.s line 18 to see any hidden character, then delete the whole line and type it by hand)
Re: Any C++ basic kernel example?
First of all, thanks, but I think that the error is not a typing error. I have typed the loader.s code three times, I have copied and pasted to (two times), I have looked for hidden characters and not, that can't be the problem, as far as I'am concerned.bluemoon wrote:The C++ barebone tutorial is about writing kernel in C++, not about running C++ program with your kernel.
In order to run user-space application (in particular with C++ runtime, and a reasonable set of syscall), the kernel itself already require lots of features.
I consider my kernel a very minimum just to run a C program:This requires over 5000 lines of code, which is comparable to the scale of a 3D engine with scene management and particle dynamics.Code: Select all
$ cat testapp/main.c #include <stdint.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> int main ( int argc, char *argv[] ) { int pid = (int)getpid(); for (int i=0;i<pid+3;i++) { printf (" PID[%d]: Hello again! counter=%d\n", pid, i); usleep((useconds_t) (1000000)); } return (int)0xBADC0DE0+ (int)pid; } SLOC Directory SLOC-by-Language (Sorted) 4958 kernel ansic=2205,asm=1354,cpp=1253,sh=146 679 boot asm=679 430 drivers ansic=288,sh=142 338 libgloss asm=226,sh=112 143 mkinitrd cpp=143 124 testapp sh=112,ansic=12 92 mkdiskimage cpp=92
If you are having trouble building the barebone, I very doubt looking into codebase of such amount would provide any reasonable insight.
A more productive way is that you go thru the tutorials and ask questions.
I copy&paste the code and it assemble without error, have you verify that your browser do not insert junk when copy&paste?platform wrote:By the way, I have tested many times the C++ Bare bones and:
loader.s:18: Error: junk at end of line, first unrecognized character is `,'
Try type it by hand, you are not suggested to copy&paste anyway.
(Hint: check loader.s line 18 to see any hidden character, then delete the whole line and type it by hand)
I have read the loader.s code of the C Bare Bones (not C++), and I get the same error. In that article the author said:
"I get Error: junk at end of line, first unrecognized character is ',' ...
Chances are the GNU as you use is not targeted at ELF - it chokes on the .comm stack, STACKSIZE, 32 line, as three arguments to .comm are only supported for ELF targets. Try setting up a GCC Cross-Compiler."
So, have I to set up a GCC Cross-Compiler? I thought that I have installed a lot of packages which let me compile in "32 bit mode" on a 64 system... But well, I have read the article and it says that there is a Debian package to set up that, but when I type "apt-get update" my system can't find that package... (yes, I have added it to the sources list...).
I sincerely don't understand anything... I have a 32 bit Ubuntu in a virtual machine... And when I try to assembly the loader.s on it, the error is the same! Then the error hasn't relation with the architecture, has it?
So, what I am supposed to do? That means that you, user "bluemoon", has reason and I have typed badly the code?
Thanks.
Re: Any C++ basic kernel example?
There is an article on wiki that guide you build a gcc cross compiler from source. IMO cross compiler, while not strictly required, put you on the same environment with many genius on this forum, and easier to get helped.
Note that I can only point to possible suspect of the cause. If you verified there was no typo then the issue should be elsewhere. Troubleshooting is a trial&error task.platform wrote:So, what I am supposed to do? That means that you, user "bluemoon", has reason and I have typed badly the code?
-
- Member
- Posts: 255
- Joined: Tue Jun 15, 2010 9:27 am
- Location: Flyover State, United States
- Contact:
Re: Any C++ basic kernel example?
If I recall correctly I had problems with the GCC that came with Ubuntu (both the x86 and x86_64 versions).
In this case, you really should build a cross compiler.
In this case, you really should build a cross compiler.
Re: Any C++ basic kernel example?
You can use the C++ classlibrary of RDOS. If you are going to write a Java script implementation on top of some OS you cannot use the tutorial as it doesn't have the support you require. An alternative is to use Linux and write the Javascript code as a replacement for command-line, and then bundle them much like Android does.