Page 1 of 1

IDT in asm

Posted: Sun Sep 11, 2005 4:48 am
by OSMAN
Hello.

Here is part of my boiler-plate:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:Text section
lidt [idt_pointer]
call main
jmp $

;My only ISR for now
isr:
pusha
push gs
push fs
push es
push ds

extern interrupt_service_routine
call interrupt_service_routine

pop ds
pop es
pop fs
pop gs
popa
iret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Data section
start_of_idt:

dw 0x0000
dw 0x10
dw 0x8E00
dw 0x20

dw 0x0000
dw 0x10
dw 0x8E00
dw 0x20

dw 0x0000
dw 0x10
dw 0xE00
dw 0x20

%rep 0xC
dw 0x0000
dw 0x10
dw 0x8E00
dw 0x20
%endrep

dw 0x0000
dw 0x10
dw 0xE00
dw 0x20

dw 0x0000
dw 0x10
dw 0x8E00
dw 0x20
end_of_idt:

idt_pointer:
dw end_of_idt - start_of_idt - 1
dd start_of_idt
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

I want to keep this as simple as I can.
The question is:
what do I have to change from IDT
dw 0x0000
dw 0x10
dw 0x8E00
dw 0x20
if I want it to jump to "isr" when the interrupt comes?

Re:IDT in asm

Posted: Sun Sep 11, 2005 5:16 am
by JoeKayzA
This should be all in the intel manuals.

Code: Select all

 dw 0x0000       << these are the lower 16 bits of 'isr'
dw 0x10
dw 0x8E00
dw 0x20                      << these are the higher 16 bits of 'isr'

The best is IMO to write a setup function that shifts the address of the isr in the right way, and then inserts it in the idt-entries. Note that you most likely need a seperate ISR for every idt-entry since there is no other way to determine which interrupt actually fired the ISR.

cheers Joe

Re:IDT in asm

Posted: Sun Sep 11, 2005 5:55 am
by OSMAN
Thanks.

But how can I find the IDT made in asm from C code later?

Re:IDT in asm

Posted: Sun Sep 11, 2005 6:53 am
by Pype.Clicker
Just like any other symbol ... tell the linker it's a global symbol, make sure your assembler code and C compiler follow the same mangling rules (e.g. that they both do/don't prepend a "_" character in front of global names) and you're done.

If you created the table dynamically in asm, just set its address to a global variable. That will work too :)