CORRECTION:
It's not true that my handler is not even called. I checked it in GDB again. I probably had the wrong symbol file loaded at the time.
SHORT DESCRIPTION HOW MY CODE WORKS:
My code is well written, but kernel.c, idt.c, intr.c are chaotic because I have been debugging IDT for a long time and have tried many things. idttest.s, idttest.asm and structs.c files are junk that I also used to test IDT and are now unnecessary.
My code works something like this:
kernel.h - file with many extern expressions. All functions that I want to use in other files are defined there. I attach this file to each file.
init.asm - loads GDT, enters 64-bit mode and calls the main function "kernel_start" in the kernel.c file. It has a multiboot header.
kernel.c - Contains only one function - "kernel_start". It's similar to main function.
make.sh - A script that builds the project. Used with the "-b" option builds only the symbol file for GDB. Used with the "-i" option builds an ISO image that can be run, for example with "qemu-system-x86_64 -hda kernel.iso" command. If no option is used, the default is "-i".
kernel.ld - Linker script.
Other files have some functions that you can use with kernel_start. You are only interested in a fragment from 24'th to 28'th line in kernel_start. It looks like this:
Code: Select all
idt_init();
//keyboard init
set_intr_gate(0x21, &irq1); //irq1
enable_irq(1);
Functions in this fragment:
idt_init - Reroutes hardware interrupts and loads IDT. And also executes "sti".
set_intr_gate - Sets entry in IDT
enable_irq - Enables interrupt
WHAT'S THE PROBLEM?
When I press any key, the irq1 function from irqs.asm file is called, irq1 function calls kbd_irq function from kbd.c file. Then the kbd_irq function returns, but irq1 does not. GDB writes something like this to me:
Code: Select all
(gdb) n
0x00000000001257b1 in irq1 ()
(gdb) n
Single stepping until exit from function irq1,
which has no line number information.
0x000000000000e05b in ?? ()
In this moment processor halts. You can find compressed archive with code here:
https://ufile.io/i0j1e2k7