Cant add global function
Posted: Wed Apr 01, 2009 2:38 am
Hello every one !
I am creating my kernel in c++.
I have made an ostream implementation for printing variables.
Now i am creating and IDTEntry class to help me with the creation of the IDT.
Header:
Implementation:
the problem is that if i run the kernel like that and print a string i have declared:
prints garbage
whereas if i run the cstream& operator<<(cstream& cs,const IDTEntry& var) i get a gpf.
I guess it has somethink to do with the linker,perhaps i need a linker script?
Can anyone point me in the right direction?
Thanks in advance.
I am creating my kernel in c++.
I have made an ostream implementation for printing variables.
Now i am creating and IDTEntry class to help me with the creation of the IDT.
Header:
Code: Select all
class IDTEntry
{
friend cstream& operator<<(cstream& cs,const IDTEntry& var);
public:
IDTEntry(void (*isr)(void),PrivilegeType privilege = Kernel,bool present = true);
private:
unsigned short offset_high;
unsigned short seg_selector;
unsigned char unused;
unsigned char atributes;
unsigned short offset_low;
}__attribute__((__packed__));
cstream& operator<<(cstream& cs,const IDTEntry& var);
Code: Select all
#include "IDTEntry.h"
IDTEntry::IDTEntry(void (*isr)(void),PrivilegeType privilege,bool present)
{
offset_low = ((unsigned int)isr)&0xFFFF;
offset_high = (((unsigned int)isr)>>16)&0xFFFF;
atributes = present<<7 + (privilege&3)<<5 + Int32;
seg_selector = 0x8; //Deafault CS
}
cstream& operator<<(cstream& cs,const IDTEntry& var)
{
cs << (void*)var.seg_selector << cstream::endl;
return cs;
}
Code: Select all
char str[] = "Hello C++!";
whereas if i run the cstream& operator<<(cstream& cs,const IDTEntry& var) i get a gpf.
I guess it has somethink to do with the linker,perhaps i need a linker script?
Can anyone point me in the right direction?
Thanks in advance.