C++ ';' expected error before error?
Posted: Wed May 04, 2022 7:52 am
Merhaba, C++ ';' expected error before error? Hello, I'm getting what is the solution? I'm Posting Screenshot and Source Code.
interrupts.cpp:
interrupts.h:
interrupts.cpp:
Code: Select all
#include "interrupts.h"
void printf(char* str);
InterruptManager::GateDescriptor InterruptManager::interruptDescriptorTable[256];
void InterruptManager::SetInterruptDescriptorTableEntry(
uint8_t interruptNumber,
uint16_t codeSegmentSelectorOffset,
void (*handler)(),
uint8_t DescriptorPrivlegeLevel,
uint8_t DescriptorType)
{
const uint8_t IDT_DESC_PRESENT = 0x80;
interruptDescriptorTable[interruptNumber].handlerAdressLowBits = ((uint32_t)handler) & 0xFFFF;
interruptDescriptorTable[interruptNumber].handlerAdressLowBits = (((uint32_t)handler) >> 16) & 0xFFF;
interruptDescriptorTable[interruptNumber].gdt_codeSegmentSelector = codeSegmentSelectorOffset
interruptDescriptorTable[interrupt].access = IDT_DESC_PRESENT | ((DescriptorPrivilegeLevel & 3) << 5);
interruptDescriptorTable[interruptNumber].reserved = 0;
}
InterruptManager::InterruptManager(GlobalDescriptorTable* gdt)
{
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);
InterruptDescriptorTablePointer idt;
idt.size = 256 * sizeof(GateDescriptor) -1;
idt.base = (uint32_t)interruptDescriptorTable;
asm volatile("lidt %0" : : "m" (idt));
}
InterruptManager::~InterruptManager()
{
}
void InterruptManager::Activate()
{
asm("sti");
}
uint32_t InterruptManager::handleInterrupt(uint8_t interruptNumber, uint32_t esp)
{
printf(" INTERRUPT");
return esp;
}
interrupts.h:
Code: Select all
#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;
uint8_t reserved;
uint8_t acess;
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 codeSegmentSelectorOfset,
void (*handler)(),
uint8_t DescriptorPrivlegeLevel,
uint8_t DescriptorType
);
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