IDT multiple call bug
Posted: Sun Sep 17, 2023 7:15 am
hello, i am quite a beginner of OSDev, i am tring to build my first os, and i have implemented my IDT just regular basic stuff that every OS have. Nothing special. And then i try to trigger an zero division interrupt the i see my kernel calls the idt_zero exception in a endless loop. here is my implemetation.
idt.c:
idt.asm:
then I am crating a problem in my kernel.asm:
the kernel actually works and prints the division by zero error on screen but i expected to print it once. My kernel is calling the idt_zerro for ever. I'm tried to debug but cant find any error prone code. It would be nice to guadience. Also i am sharing a screen shot too on attachments.
idt.c:
Code: Select all
#include "../include/idt.h"
idt_t idt[ARTILLERYOS_MAX_INTERRUPT_SIZE];
idt_ptr_t idt_ptr;
extern void idt_load(idt_ptr_t *ptr);
static int handled = 0;
void idt_zero()
{
if (handled == 0) {
terminal_print("\n div error");
handled = 1;
}
}
void idt_set(int interrupt_no, void *address)
{
idt_t *desc = &idt[interrupt_no];
uint32_t addr = (uint32_t)address;
desc->offset_1 = addr & 0xFFFF;
desc->selector = KERNEL_CODE_SELECTOR;
desc->zero = 0x00;
desc->type_attr = 0xEE;
desc->offset_2 = (addr >> 16) & 0xFFFF;
}
void idt_init()
{
memset(idt, 0, sizeof(idt));
idt_ptr.limit = sizeof(idt) - 1;
idt_ptr.base = (uint32_t)idt;
idt_set(0, idt_zero);
idt_load(&idt_ptr);
}
idt.asm:
Code: Select all
section .asm
global idt_load
idt_load:
push ebp
mov ebp, esp
mov ebx, [ebp+8]
lidt [ebx]
pop ebp
ret
then I am crating a problem in my kernel.asm:
Code: Select all
problem:
mov eax, 0
div eax