IDT in asm

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
OSMAN

IDT in asm

Post 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?
JoeKayzA

Re:IDT in asm

Post 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
OSMAN

Re:IDT in asm

Post by OSMAN »

Thanks.

But how can I find the IDT made in asm from C code later?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:IDT in asm

Post 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 :)
Post Reply