"Undefined reference to" Hatası hangi kod dosyasından kaynaklanıyor?

mrht1234

Hectopat
Katılım
3 Aralık 2020
Mesajlar
1.397
Çözümler
4
Yer
Edirne/Merkez
Daha fazla  
Cinsiyet
Erkek
Merhaba, undefined reference to hatası hangi kod dosyasından veya dosyalarından kaynaklanıyor? Kod dosyalarındaki kodu ve ekran görüntüsünü atıyorum.
interrupts.cpp:

[CODE lang="cpp" title="interrupts.cpp"]
#include "interrupts.h"

void printf(char* str);

static void SetInterruptDescriptorTableEntry(
uint8_t interruptNumber,
uint16_t codeSegmentSelectorOffset,
void (*handler) (),
uint8_t DescriptorPrivlegeLevel,
uint8_t DescriptorType)

{
uint8_t const IDT_DESC_PRESENT = 0x80;

interruptDescriptorTable[interruptNumber].handlerAdressLowBits = ((uint32_t)handler) & 0xFFFF;
interruptDescriptorTable[interruptNumber].handlerAdressHighBits = (((uint32_t)handler) >> 16) & 0xFFFF;
interruptDescriptorTable[interruptNumber].gdt_codeSegmentSelector = codeSegmentSelectorOffset;
interruptDescriptorTable[interruptNumber].access = IDT_DESC_PRESENT | DescriptorType | ((DescriptorPrivlegeLevel&3) << 5);
interruptDescriptorTable[interruptNumber].reserved = 0;
}

InterruptManager::InterruptManager(GlobalDescriptorTable* gdt)
: picMasterCommand(0x20),
picMasterData(0x21),
picSlaveCommand(0xA0),
picSlaveData(0xA1)

{
uint16_t CodeSegment = gdt->CodeSegmentSelector();
const uint8_t IDT_INTERRUPT_GATE = 0xE;

for(uint16_t i = 0; i < 256; i++)
SetInterruptDescriptorTableEntry(i, CodeSegment, &IgnoreInterruptRequest, 0, IDT_INTERRUPT_GATE);

SetInterruptDescriptorTableEntry(0x20, CodeSegment, &HandleInterruptRequest0x00, 0, IDT_INTERRUPT_GATE);
SetInterruptDescriptorTableEntry(0x21, CodeSegment, &HandleInterruptRequest0x01, 0, IDT_INTERRUPT_GATE);

picMasterCommand.Write(0x11);
picSlaveCommand.Write(0x11);

picMasterData.Write(0x20);
picSlaveData.Write(0x28);

picMasterData.Write(0x04);
picSlaveData.Write(0x02);

picMasterData.Write(0x01);
picSlaveData.Write(0x01);

picMasterData.Write(0x00);
picSlaveData.Write(0x00);

InterruptDescriptorTablePointer idt;
idt.size = 256 * sizeof(GateDescriptor) - 1;
idt.base = (uint32_t)interruptDescriptorTable;
asm volatile("lidt %0" : : "m" (lidt));
}

InterruptManager::~InterruptManager()
{
}

void InterruptManager::Activate()
{
asm("sti");
}

uint32_t InterruptManager::handleInterrupt(uint8_t interruptNumber, uint32_t esp)
{

printf(" INTERRUPT");

return esp;
}[/CODE]

interrupts.h:

[CODE lang="cpp" title="interrupts.h"]
#ifndef __INTERRUPTS_H.
#define __INTERRUPTS_H.

#include "types.h"
#include "port.h"
#include "gdt.h"

class InterruptManager.
{

protected:

struct GateDescriptor.
{
uint16_t handlerAdressLowBits;
uint16_t gdt_codeSegmentSelector;
uint16_t reserved;
uint16_t access;
uint16_t handlerAdressHighBits;

} __attribute__((packed));

static GateDescriptor interruptDescriptorTable[256];

struct InterruptDescriptorTablePointer
{
uint16_t size;
uint32_t base;
} __attribute__((packed));

static void SetInterruptDescriptorTableEntry(
uint8_t interruptNumber,
uint16_t codeSegmentSelectorOffset,
void (*handler) (),
uint8_t DescriptorPrivlegeLevel,
uint8_t DescriptorType.
);

Port8BitSlow picMasterCommand;
Port8BitSlow picMasterData;
Port8BitSlow picSlaveCommand;
Port8BitSlow picSlaveData;

public:

InterruptManager(GlobalDescriptorTable* gdt);
~InterruptManager();

void Activate();

static uint32_t handleInterrupt(uint8_t interruptNumber, uint32_t esp);

static void IgnoreInterruptRequest();
static void HandleInterruptRequest0x00();
static void HandleInterruptRequest0x01();
};

#endif[/CODE]

kernel.cpp:

[CODE lang="cpp" title="kernel.cpp"]
#include "types.h"
#include "gdt.h"
#include "interrupts.h"

void printf(char* str)
{
static uint16_t* VideoMemory = (uint16_t*)0xb8000;

static uint8_t x =0 , y=0;

for(int i = 0; str != '\0'; i++)
{

switch(str)
{
case '\n':
y++;
x = 0;
break;
default:
VideoMemory[80*y+x] = (VideoMemory[80*y+x] & 0xFF00) | str;
x++;
break;
}

if(x >= 80)
{
y++;
x = 0;

}

if(y >= 25)
{
for(y = 0; y < 25; y++)
for(x = 0; x < 80; x++)
VideoMemory[80*y+x] = (VideoMemory[80*y+x] & 0xFF00) | ' ';

x = 0;
y=0;

}
}

}

extern "C" void kernelMain(const void* multiboot_structure, uint32_t /*multiboot_magic*/)
{
printf("Kapilar Onyukleyicisine Hosgeldiniz...");

GlobalDescriptorTable gdt;
InterruptManager interrupts(&gdt);

interrupts.Activate();

while(1);

}[/CODE]

[CODE title="interruptstubst.s"]
.set IRQ_BASE, 0X20.

.section .text

.extern _ZN16InterruptManager15handleInterruptEhj

.global _ZN16InterruptManager22IgnoreInterruptRequestEv

.macro HandleException num.
.global _ZN16InterruptManager16HandleException\num\()Ev
_ZN16InterruptManager16HandleException\num\()Ev:
movb $\num, (interruptnumber)
jmp int_bottom.
.endm

.macro HandleInterruptRequest num.
.global _ZN16InterruptManager26HandleInterruptRequest\num\()Ev
_ZN16InterruptManager26HandleInterruptRequest\num\()Ev:
movb $\num + IRQ_BASE, (interruptnumber)
jmp int_bottom.
.endm

HandleInterruptRequest 0x00.
HandleInterruptRequest 0x01.

int_bottom:
pusha.
pushl %ds
pushl %es
pushl %fs
pushl %gs

pushl% esp.
push (interruptnumber)
call _ZN16InterruptManager15handleInterruptEhj
# addl $5, %esp
movl %eax, %esp

popl %gs
popl %fs
popl %es
popl %ds
popa.

_ZN16InterruptManager22IgnoreInterruptRequestEv:

iret.

.data
interruptnumber: .byte 0[/CODE]

@Enes3078
@Dynamics
@TerabyteForever
@Vavien.
@Aspletan
 

Technopat Haberler

Geri
Yukarı