Undefined reference in asm-code

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.
david-h
Posts: 17
Joined: Sun Apr 08, 2007 5:48 am
Location: Frankfurt/Main, Germany
Contact:

Post by david-h »

I do the following things before I try to load the ISRs:

First, I set a GDT. One Null descriptor, a code and a Data segment.

Then, I set up the IDT:

Code: Select all

//Installs the IDT, called by main()
void IDT::install()
{
	 /* Sets the special IDT pointer up */
    idtp.limit = (sizeof (idt_entry) * 256) - 1;
    idtp.base = (unsigned int) &idt;

	//Load IDT´s into the processor
	idt_load();
}
idt_load() looks like this:

Code: Select all

global idt_load	  ; we want to call this in C++
extern idtp
idt_load:
	lidt [idtp]
	ret
And then I set up the ISR´s like this:

Code: Select all

void ISRs::install()
{
	IDT::set_gate(0, (unsigned)isr0, 0x08, 0x8E);
    IDT::set_gate(1, (unsigned)isr1, 0x08, 0x8E);
    IDT::set_gate(2, (unsigned)isr2, 0x08, 0x8E);
    IDT::set_gate(3, (unsigned)isr3, 0x08, 0x8E);
    IDT::set_gate(4, (unsigned)isr4, 0x08, 0x8E);
    IDT::set_gate(5, (unsigned)isr5, 0x08, 0x8E);
    IDT::set_gate(6, (unsigned)isr6, 0x08, 0x8E);
    IDT::set_gate(7, (unsigned)isr7, 0x08, 0x8E);

    IDT::set_gate(8, (unsigned)isr8, 0x08, 0x8E);
    IDT::set_gate(9, (unsigned)isr9, 0x08, 0x8E);
    IDT::set_gate(10, (unsigned)isr10, 0x08, 0x8E);
    IDT::set_gate(11, (unsigned)isr11, 0x08, 0x8E);
    IDT::set_gate(12, (unsigned)isr12, 0x08, 0x8E);
    IDT::set_gate(13, (unsigned)isr13, 0x08, 0x8E);
    IDT::set_gate(14, (unsigned)isr14, 0x08, 0x8E);
    IDT::set_gate(15, (unsigned)isr15, 0x08, 0x8E);

    IDT::set_gate(16, (unsigned)isr16, 0x08, 0x8E);
    IDT::set_gate(17, (unsigned)isr17, 0x08, 0x8E);
    IDT::set_gate(18, (unsigned)isr18, 0x08, 0x8E);
    IDT::set_gate(19, (unsigned)isr19, 0x08, 0x8E);
    IDT::set_gate(20, (unsigned)isr20, 0x08, 0x8E);
    IDT::set_gate(21, (unsigned)isr21, 0x08, 0x8E);
    IDT::set_gate(22, (unsigned)isr22, 0x08, 0x8E);
    IDT::set_gate(23, (unsigned)isr23, 0x08, 0x8E);

    IDT::set_gate(24, (unsigned)isr24, 0x08, 0x8E);
    IDT::set_gate(25, (unsigned)isr25, 0x08, 0x8E);
    IDT::set_gate(26, (unsigned)isr26, 0x08, 0x8E);
    IDT::set_gate(27, (unsigned)isr27, 0x08, 0x8E);
    IDT::set_gate(28, (unsigned)isr28, 0x08, 0x8E);
    IDT::set_gate(29, (unsigned)isr29, 0x08, 0x8E);
    IDT::set_gate(30, (unsigned)isr30, 0x08, 0x8E);
    IDT::set_gate(31, (unsigned)isr31, 0x08, 0x8E);
}
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

That's it then. Before STI, you need to set up your IRQ handlers.
david-h
Posts: 17
Joined: Sun Apr 08, 2007 5:48 am
Location: Frankfurt/Main, Germany
Contact:

Post by david-h »

Well, thank you very much. But I have another strange problem now.
The mein-Function of kernel should call GDT::install(), IDT::install() and ISRs::install().

The namespaces and functions are defined like this:

Code: Select all

#ifndef _GDT_HEADER_
#define _GDT_HEADER_

//function is defined in Loader.asm
extern "C" void gdt_flush();

namespace GDT
{
	//registers a GDT
	void set_gate(int num, unsigned long base, unsigned long limit, unsigned char access, unsigned char gran);
	//installs default GDTs
	void install();
}

#endif
In the .cpp file they´re defined like this:

Code: Select all

void GDT::set_gate(...)
{
...
}

void GDT::install();
{
...
}
But this code doesn´t get called! I had a std::cout << "Test"; in it, but I never saw this output! And my Output-System works.

What for a problem do I have now again?
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:

Post by Combuster »

have you checked that you aren't using any features mentioned on the C++ wiki page, because it looks like you are using global classes.
[edit]I meant "global objects". my mistake[/edit]
Last edited by Combuster on Tue May 15, 2007 10:23 am, edited 1 time in total.
"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 ]
david-h
Posts: 17
Joined: Sun Apr 08, 2007 5:48 am
Location: Frankfurt/Main, Germany
Contact:

Post by david-h »

:?: I couldn´t find anything about global classes in the wiki entry.

If you mean global objects, I already have implemented support for them.
david-h
Posts: 17
Joined: Sun Apr 08, 2007 5:48 am
Location: Frankfurt/Main, Germany
Contact:

Post by david-h »

OK, I solved the problem. Like AJ said I had to set up my IRQ handlers. Everythings working fine now.
Post Reply