Re:Compling errors
Posted: Thu Feb 06, 2003 9:00 am
Abless..Not if you want super-fast inlined functions.
I put them in header files, so long as they aren't large.
I put them in header files, so long as they aren't large.
That only applies to member functions in C++; standard C does not inline functions at all, nor will ordinary functions inline in C++ IIRC. Also, you want to limit inline functions to those where the function call overhead significantly impacts the performance, such as get/set operations(that is, functions who sole purpose is to read or change a protected instance variable). Inlining the majority of you functions is a Bad Thing, if only because you then have multiple copies of the same code bloating up your executable.Daryl Dudey wrote: Abless..Not if you want super-fast inlined functions.
I put them in header files, so long as they aren't large.
No, I checked my code and its included in there.On a guess, though, what is happening is that either you haven't put function prototypes for printk() and and clear_screen() in the matching header files, or else you aren't including the header files in your main.c file.
Kernel.bin is the binary file made when I link main.o and ks.o together, forming the kernel. Bootpm.bin is copied seperate first to the disk using partcopy and then kernel.bin using partcopy also.Also, what is 'kernel.bin'? Is this supposed to be bootpm.bin (I doubt it, but I don't know what your design plans are), or is it something else entirely?
I'll have to check into this as in my ks.asm file, I jump to the c kernel like this:Also, while you specify flat-binary object format for bootpm.asm, and a.out object format for ks.asm, you seem to be leaving the C code at the default object format, which is ELF. Aside from the problems of linking ELF to a.out, there are also differnces in how it handles extern function names; specifically, it does not automatically assume that extern functions are prefixed with an underscore. If the function manes are prefixed, but the prototypes are not (as would be the case with traditional C compilers and linkers), the link will break under ELF, IIUC.
Code: Select all
jmp _k_main
Code: Select all
#include <stdio.h>
Code: Select all
#include "stdio.h">
Oh, of course... it's just after the '-o' (output filename) option, isn't it? <kicks self>beyondsociety wrote:
Kernel.bin is the binary file made when I link main.o and ks.o together, forming the kernel. Bootpm.bin is copied seperate first to the disk using partcopy and then kernel.bin using partcopy also.
AFIAK, it determines the search path used to find the files by the preprocessor. Using angle brackets causes the preprocessor to search in the [tt]/include[/tt] directory for the compiler; using double-quotes makes it look in the local directory.Whats the difference between these two forms of including a file in my kernel?Code: Select all
#include <stdio.h>
Code: Select all
#include "stdio.h"
<file> is not limited to the compiler/include directory, but can be extended to every directory added to the include set (with -Idirectory in gcc) and compiler/include/* can be excluded (useful for OSdev) using -fno-std-include ...Schol-R-LEA wrote:
AFIAK, it determines the search path used to find the files by the preprocessor. Using angle brackets causes the preprocessor to search in the [tt]/include[/tt] directory for the compiler; using double-quotes makes it look in the local directory.
Code: Select all
#include "video.h"
void main()
{
k_print("IBOX Operating System");
for(;;);
}
Code: Select all
#include "video.h"
#define WHITE_TXT 0x07;
void k_print(char *str)
{
char *video = (char *) 0xb8000;
while(*str)
{
*video++ = *str++;
*video++ = WHITE_TXT;
}
return;
}
Code: Select all
/* Prototypes */
void k_print(char *str);
Code: Select all
@ECHO OFF
nasm -f bin bootpm.asm -o bootpm.bin ; Bootsector
nasm -f aout ks.asm -o ks.o
gcc -ffreestanding -c main.c -o main.o
gcc -c video.c -o video.o
ld -T link.ld -o kernel.bin main.o ks.o video.o
bootcopy bootpm.bin 0
bootcopy kernel.bin 1
makeboot test.img bootpm.bin kernel.bin
Code: Select all
[BITS 32]
[GLOBAL start]
[EXTERN _main] ; This in the C Kernel
start:
call _main
jmp $
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x100000 : {
*(.text)
}
.data : {
*(.data)
}
.bss :
{
*(.bss)
}
}