OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:09 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: C++ ';' expected error before error?
PostPosted: Wed May 04, 2022 7:52 am 
Offline

Joined: Fri Apr 01, 2022 10:06 am
Posts: 23
Location: Türkiye, Uşak/Merkez
Merhaba, C++ ';' expected error before error? Hello, I'm getting what is the solution? I'm Posting Screenshot and Source Code.

interrupts.cpp:
Code:
#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:
#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


Attachments:
Ekran görüntüsü 2022-05-04 165018.png
Ekran görüntüsü 2022-05-04 165018.png [ 15.86 KiB | Viewed 2479 times ]

_________________
M. Alp
Top
 Profile  
 
 Post subject: Re: C++ ';' expected error before error?
PostPosted: Wed May 04, 2022 8:50 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
The error message is telling you exactly what the error is, and exactly where it is. To tell you more would be to spoon-feed you, and you are never going to learn the language if you have to ask for help every time you make a simple error. This is not the first time you have asked very elementary questions about errors when the message tells you exactly what the error is.

I don't wish to be rude, but I would suggest that you forget about OS development for the time being (are you just copy-pasting code from elsewhere?) and learn how to program in C++ using simple examples in a user environment. There are a number of books and courses on C++ programming that you might profitably study. Once you can confidently program in C++, and debug for yourself any errors that you make, you will be in a better position to look again at OS development.

I don't believe it is the place of this forum to teach beginners a programming language.


Top
 Profile  
 
 Post subject: Re: C++ ';' expected error before error?
PostPosted: Wed May 04, 2022 2:05 pm 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 618
Location: North Dakota, United States
I concur. You are asking elementary questions you should be able to solve on your own. We are not going to spoon-feed you all the answers to all your C++ questions. I'm not sure how long you've been programming in C++, but it doesn't seem like a long time considering the questions your asking. Get to a level where your comfortable in user environments, and then try your hand at OSDev again. I would strongly encourage you to ask your questions in a subreddit like cpp_questions, but do note that no C++ forum is going to spoon-feed you your code, nor are they going to be problem solvers for you. Part of programming is learning to solve problems on your own. We'll provide you with lots of advice, but we won't write your OS for you, nor will we help you find every little compiler error that you get.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot] and 40 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group