Page 1 of 1

random interrupt related questions

Posted: Mon Jun 23, 2003 8:15 pm
by libber
ok, i setup interrupts, with all 256 entries in the IDT to point to this filler interrupt (note: it is an interrupt not a call or trap gate)

Code: Select all

filler_int:
   cli   
   cld   
   
   pusha
   push ds
   push es
   mov eax, 0x10   ;data descriptor 
   mov ds, eax
   mov esi, interrupt_msg

   call simple_print
   ;note we are useing eax and the stack, that is because it is safe
   ; to assume we are in protected mode, because we dont setup the
   ; IDT until we are in protected mode.
   pop es
   pop ds
   popa
   iret   
but when i test to see if the handler is called correctly bochs gives me the '[CPU ] exception(): 3rd (13) exception with no resolution' error. the way i am testing to see if this interrupt works is by doing 'int 9' and trying interrupts lke that, with different numbers, so far nothing has produced anything but the error above.

i mapped the pic, copying the code from this tutorial http://osdev.neopages.net/tutorials/pic.php

and this is how i load the idt (lifted from the linux setup code mainly)

Code: Select all

;Setup IDT with filler interrupt handler.
; eax: offset 16-31 (16b)     | flags (16b)
; ebx: segment selector (16b) | offset 0-15

;eax = 0010 for offset. and 0x8e00 for flags. 0x00108e00
;ebx = 0008, 003c for offset

lea eax, [filler_int]           ; 0x0010003c in eax for example, ax here is 003c
mov ax, 0x8e00              ;mov flags into low word. flags are: interrupt
                                       ;gate, dpl = 0, present.
mov ebx, 0x00080000    ;mov in offset of CS segment selector, and clear
                                       ; low word (bx) for coming offset
lea ecx, [filler_int]           ;get address so we can put bottom half in ebx
mov bx, cx                       ;move low word of interrupt handler into ebx
lea edi, [IDT]
mov ecx, 0x100               ;loop 256 times to fill all of idt

load_idt_with_filler_interrupt:

mov [edi], eax                 ;load first half of handler into address of IDT
add edi, 4
mov [edi], ebx                 ;load second half into address of IDT (assuming edi is
                                        ; the base of the IDT, IDT now points to top of IDT)
add edi, 4
dec ecx
jne load_idt_with_filler_interrupt
  
so, the questions are
did i setup everything correctly?
and am i testing this the correct way?

also i am wondering if i loaded the interrupt gate in the correct order, i loaded, the flags (dpl, present-flag, signature to say it is an interrupt gate etc) first ( i load 16bits at a time), then i load the last half of the offset, then the first part of the offset, then the segment selector.

i have searched the forum and the only relavent post i could find was a fellow who had the same problem as me but was loading without any exception gates (just like i am doing) so i tried to replace some and all of the IDT entries with exception gates but i still had the same problem.

any help would be most appreciated.

thanks for your time,
libber

Re:random interrupt related questions

Posted: Tue Jun 24, 2003 2:32 am
by Pype.Clicker
from what you're doing, you assume the following structure of the IDT entries:

Code: Select all

db 00, type 
dw <offset-hi> 
dw selector
dw <offset-lo>
which is actually the perfect opposite of what is expected by the CPU:

word <offset-lo>@edi
word selector@edi+2
byte zero@edi+4
byte type@edi+5
word <offset-hi>@edi+6

Re:random interrupt related questions

Posted: Wed Jul 02, 2003 8:16 pm
by libber
ok i have been struggeleing with interrupts for 3 days now, i have no idea where i have gone wrong, and, as much as i dislike these sorts of posts, i am going to post a will-you-please-debug-my-program-for-me message.

i think this is what i get for thinking the IDT would be easy and trying to get through it quickly, heh.

i compile part1 and part2 then just concatinate part2 onto the end of part1. so far i have a small bootloader (part1) and part2 is the second stage bootloader. i am putting my IDT at 0x7c00 because i figure that space should be free since i am done booting with it but i have tried other places below 1mb for the IDT also. i think that my handler is setup correctly and i am just filling the idt with a filler handler.
good luck to any brave souls who might look through my poorly setup and incredibly over-commented code :)

part 1: openbs.org/~libber/part1.html
part 2: openbs.org/~libber/part2.html

note: part2 is where i do all the IDT stuff.

also even if you havent looked over my code but have reccomendations for places to setup the IDT or what has worked for you while setting up the IDT, the methods you may have used to setup the IDT ( part of .data then just loaded or built "on the fly") please let me know.

thanks for your time,
Libber