Understanding Bare Bones

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.
gsingh2011
Member
Member
Posts: 83
Joined: Tue Feb 03, 2009 11:37 am

Re: Understanding Bare Bones

Post by gsingh2011 »

Ok so I finally got the following code to compile with errors. Basically, I want to clear the screen.

Code: Select all

#include "kernel.h"
#include <string.h>

// Screen dimensions (for default 80x25 console)
#define LINE_PITCH 160       // line width in bytes
#define LINE_COUNT 25

default_console::default_console()
{
    videoram = (volatile unsigned char *) 0xb8000;
    cursor = (volatile unsigned int *) 0xb903c;
    clear();
}

void default_console::clear()
{
    memset((void*)videoram, 0, LINE_PITCH*LINE_COUNT);
    locate(0,0);
    attr = 0x07;
}

void kmain( void* mbd, unsigned int magic )
{
	default_console();
	clear();
}
I get the errors when linking it:

Code: Select all

Object Files/loader.o: In function `loader':
Source Files/loader.s:(.text+0x14): undefined reference to `kmain'
Object Files/kernel.o: In function `default_console::clear()':
kernel.cpp:(.text+0x25): undefined reference to `memset'
kernel.cpp:(.text+0x40): undefined reference to `default_console::locate(int, int)'
Object Files/kernel.o: In function `default_console::self()':
kernel.cpp:(.text+0xb4): undefined reference to `__cxa_guard_acquire'
kernel.cpp:(.text+0xdd): undefined reference to `__cxa_guard_release'
kernel.cpp:(.text+0x108): undefined reference to `__cxa_guard_abort'
kernel.cpp:(.text+0x11f): undefined reference to `_Unwind_Resume'
Object Files/kernel.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
My loader.s and linker script are the exact same as in the barebones tutorial. Sorry if these are all noob questions, but I simply don't have enough experience with OS programming to solve the errors on my own...

BTW, will this code work when it runs? Is it the correct code to clear the screen?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Understanding Bare Bones

Post by Combuster »

Classic mistakes:
- Using header files you did not write yourself
- Mixing C headers with C++ code
- Using a language of which you know too little for OS development.
- Not building a GCC Cross-Compiler, not telling g++ to strip all platform dependencies.
- Not listening to what others said already

based on #2 and #3 (and partially #5), I'd say that OS development is too high a goal for now.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply