Kernel question:

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
nuno_silva_pt

Kernel question:

Post by nuno_silva_pt »

Is this source code for my kernel right?
Please Help me.

[attachment deleted by admin]
slacker

Re:Kernel question:

Post by slacker »

it looks like misc functions are there.


does anyone know when someone says they want to make their OS portable...what does that mean?
frank

Re:Kernel question:

Post by frank »

I think they mean letting their os run on more than 1 architecture.

for example netbsd supports a lot of different architectures.
(see the list at the right on www.netbsd.org)
Jamethiel

Re:Kernel question:

Post by Jamethiel »

I think they mean they want their OS to be buzzword-compliant.

For example, windows NT is 'portable'.

(Well, NT -used- to have Alpha and MIPS versions...)
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Kernel question:

Post by Pype.Clicker »

nuno_silva_pt wrote: Is this source code for my kernel right?
Please Help me.
one thing that trouble me with your source is that you have so much PCI scanning and memory probe code, while everything main does is issuing two calls to printf (which isn't declared here ...)
Tim

Re:Kernel question:

Post by Tim »

Windows NT is portable. It's just not being ported right now. (Windows NT 3.51 targetted x86, Alpha, PowerPC and MIPS. NT dropped to x86 only after Windows 2000 RC1. Windows CE, on the other hand, is everywhere.)
nuno_silva_pt

Re:Kernel question:

Post by nuno_silva_pt »

I forgot what are the #include files.
Will u ppl tell me, pls, if it isn't asking too much?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Kernel question:

Post by Pype.Clicker »

Is this source code for my kernel right?
hmm, you should be more clear on what you'd like to know, if you want to be helped. Did you ever try to compile your sources ??
nuno_silva_Main.c:3: error: parse error before "ULONG"
obviously, you need something like #include "types.h" that will declare your ULONG, UCHAR, etc. uppercase identifiers are usually macros, which means the language per se do not know them: they must be #define'd somewhere ...

Code: Select all

#define ULONG unsigned long
#define UCHAR unsigned char
#define USHORT unsigned short
#define NULL ((void*)0)
should do the trick.
nuno_silva_Main.c:7: error: parse error before "attribute"
this should be __attribute__ rather than attribute.

nuno_silva_Main.c:32: error: `X' undeclared (first use in this function)
nuno_silva_Main.c:32: error: `P' undeclared (first use in this function)
C identifiers are case-sensitive ... where you have "x", you may not have "X" instead. And this is true for keywords aswell: "IF" is not "if".

This is *not* basic, okay ?

moreover, unlike in basic, printf is not a built-in function of the language (as PRINT is), but rather a library function available in the standard library. However, your kernel usually do not have an implementation of the stdlib to help him, because the STDLIB is OS-dependent ... Therefore, if you want to create an OS, you may not rely on functions like printf, fopen, log(), sin(), etc. to be available. The only functions that will be available are those you'll put in the kernel's environment yourself.
Schol-R-LEA

Re:Kernel question:

Post by Schol-R-LEA »

nuno_silva_pt wrote: I forgot what are the #include files.
Will u ppl tell me, pls, if it isn't asking too much?
OK, no problem... but I should warn you that, if you're having trouble with something as fundemental as this, you really should learn more about C programming before jumping into OS design. Just a word of advice.

Anyway: include files, or header files, are files which are automatcally inserted into the text of a source file by the [tt]#include[/tt] preprocessor directive. They are primarily used to allow separate source files to share common type definitions, [tt]extern[/tt] variable declarations, and function prototypes. For example, in the classic "Hello, World!" program,

Code: Select all

#include <stdio.h>

int main()
{
  printf("Hello, World!");
}
The line [tt]#include <stdio.h>[/tt] causes the contents of the file "stdio.h" to be added to the source code before it is compiled. The reason for doing this is because, somewhere in the "stdio.h" file, is a function prototype like this:

Code: Select all

int printf (const char*, ...);
(example taken from the Dev-C++ version of stdio.h)

This function prototype tells the compiler that there is a function by this name and accepting these arguments, so that it can set up the necessary structures in the object code for the linker to add the function from the library later. Such function prototypes are used to make sure that the function calls in the programs match the actual functions in the libraries.

For some more detailed explanations of [tt]#include[/tt], and the preprocessor in general, see
reply #9 in this thread
Reply #3 in this thread
Reply #13 in this thread
nuno_silva_pt

Re:Kernel question:

Post by nuno_silva_pt »

I have a new kernel, from a tutorial, but when i compile it, gcc says: gcc - undefined reference to __gxx_personality_v0
Please help me...
nuno_silva_pt

Re:Kernel question:

Post by nuno_silva_pt »

It also gives me an information saying something about str, that is the first use of this function...
Here is the source:

[attachment deleted by admin]
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Kernel question:

Post by Pype.Clicker »

nuno_silva_pt wrote: I have a new kernel, from a tutorial, but when i compile it, gcc says: gcc - undefined reference to __gxx_personality_v0
Please help me...
Dear Nuno... please, read carefully:
  • you MAY NOT use something like #include <stdio.h> in a kernel, because your kernel has nothing like a standard lib.
  • you MUST use the --ffreestanding flag when compiling your kernel (which you probably did).
by #including <stdio.h>, you may be referencing some libc-specific stuff, and as you're not linking to libc, it cannot find what you tell it to do.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Kernel question:

Post by Pype.Clicker »

nuno_silva_pt wrote: It also gives me an information saying something about str, that is the first use of this function...
Here is the source:

Code: Select all

nuno-kernel2.c: In function `clear_screen':
nuno-kernel2.c:30: error: `str' undeclared (first use in this function)
nuno-kernel2.c:30: error: (Each undeclared identifier is reported only once
nuno-kernel2.c:30: error: for each function it appears in.)
unlike in Basic, C variables only exists in the block you declare them.
As a particular case, "str" which was declared in "main" does not exist in "clearscreen" even if "clearscreen" is called by main.

looks like you cut'n'pasted the "while" loop a bit too fast. just remove "str++" and it will compile fine.

you also seem to have problems with pointers:

Code: Select all

   *text_video++;
does increment the byte located at "text_video". If you want to advance text_video to the next position, you should do

Code: Select all

       text_video++;
and this needs to be repeated after

Code: Select all

   *text_video = attrib;
too.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Kernel question:

Post by Pype.Clicker »

Code: Select all

gcc nuno-kernel2.c -ffreestanding -nostdlib
did the trick (would compile without errors if you rename k_main() in _start.
Post Reply