Problems with Interrupts

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
zecarlos
Posts: 11
Joined: Tue Feb 18, 2020 8:20 am

Problems with Interrupts

Post by zecarlos »

Good morning my dear friends.
I am trying to compile and run one of the many excellent toturials I have found out there about developing operating systems. However, I always face the same problem.
(the code can be found at <https://github.com/zecarlos1957/LearnOS>)

When an interruption occurs, the processor resets and the process restarts.
To confirm my prediction, I will unmask timer interrupt 0 in the idt.cpp file with the instruction
io :: outb (PIC_MASTER_DATA, 0x1). So it only restarts when I press a key.
This appears to be because the call to the interruption entry point does not jump to the correct address, but I cannot find the reason for this. Can you help me to solve this difficulty?
Thank you for your attention.

Along with the result of BochsDBG that executes all the code and when it is in the infinite loop after leaving kmain, there is an interruption that resets the processor.



========================================================================
Bochs x86 Emulator 2.6.9
Built from SVN snapshot on April 9, 2017
Compiled on Apr 9 2017 at 09:49:25
========================================================================
00000000000i[ ] reading configuration from bochsrc.txt
00000000000e[ ] bochsrc.txt:736: ataX-master/slave CHS set to 0/0/0 - autodetection enabled
00000000000i[ ] installing win32 module as the Bochs GUI
00000000000i[ ] using log file bochsout.txt
Next at t=0
(0) [0x0000fffffff0] f000:fff0 (unk. ctxt): jmpf 0xf000:e05b ; ea5be000f0
<bochs:1> lb 0x100027
<bochs:2> c
(0) Breakpoint 1, 0x0000000000100027 in ?? ()
Next at t=63796793
(0) [0x000000100027] 0008:0000000000100027 (unk. ctxt): jmp .-2 (0x00100027) ; ebfe
<bochs:3> s
Next at t=63796794
(0) [0x000000100027] 0008:0000000000100027 (unk. ctxt): jmp .-2 (0x00100027) ; ebfe
<bochs:4> c
(0) Breakpoint 1, 0x0000000000100027 in ?? ()
Next at t=63796795
(0) [0x000000100027] 0008:0000000000100027 (unk. ctxt): jmp .-2 (0x00100027) ; ebfe
<bochs:5> del 1
<bochs:6> c
(0).[65915658] [0x000000100027] 0008:0000000000100027 (unk. ctxt): jmp .-2 (0x00100027) ; ebfe
Next at t=65915659
(0) [0x0000fffffff0] f000:fff0 (unk. ctxt): jmpf 0xf000:e05b ; ea5be000f0
<bochs:7>
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Problems with Interrupts

Post by iansjack »

Perhaps an email to the author of this "tutorial" (although it just seems to be code, not a tutorial)? They are best placed to test the code with the information that you give.
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: Problems with Interrupts

Post by Klakap »

Your problem is in file https://github.com/zecarlos1957/LearnOS ... Stage2.asm on line:

Code: Select all

  cli
  hlt
HLT command halt CPU only to next interrupt, so if interrupt is call, CPU try to execute commands after HLT what in your code make reboot. Solution is very easy:

Code: Select all

  ;we don't want disable interrupts! cli command should be erased
  halt:
    hlt ;halt CPU to next interrupt
  jmp halt
Now your handlers should call right. I use same way in my OS.
zecarlos
Posts: 11
Joined: Tue Feb 18, 2020 8:20 am

Re: Problems with Interrupts

Post by zecarlos »

Thank you for your observation KLAKAP :lol:
Your analysis makes perfect sense, that will be one of the problems I have already addressed, but it continues to do the same. I'm going back to BochsDBG.
Post Reply