IRQs and how they work?

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
Thunder

IRQs and how they work?

Post by Thunder »

Hello!
I have read about ISRs IRQs and software interrupts, but one thing worries "How works IRQs and how setup them"?
Bye
Unexpected

Re:IRQs and how they work?

Post by Unexpected »

If you are in PMode, first you must create Interrupt Description Table(IDT). In this table is writed where interrupts handlers is. Then you need initialize the PIC to enable interrupts.
It works like:
When comes a hardware call (for ex. you press a keyboard button), then CPU "jumps" to IRQ1 handler(hanler address located in IDT).

P.S. - sorry for my poor English :'(
Thunder

Re:IRQs and how they work?

Post by Thunder »

then I must to create ISR for keyboard? I'm wrong?
If keyboard is IRQ2 then the ISR2 should handle with keyboard? How about exeptions?
Unexpected

Re:IRQs and how they work?

Post by Unexpected »

IRQ - interrupt, ISR - exeption
And keyboard uses IRQ1 not 2(see http://osdev.neopages.net/tutorials/irqs.php).
So you must create in IDT table 32 entrys for exeptions plus interrupts. Keyboard interrupt is 34(33 - Timer).
Full IDT size is 255 entries.
:)
Thunder

Re:IRQs and how they work?

Post by Thunder »

Aciu tau dar karta :) :D
Thunder

Re:IRQs and how they work?

Post by Thunder »

So here is a part of my GDT:
codesel equ $-gdt
dw 0FFFFh
dw 0
db 0
db 9Ah
db 0CFh
db 0

DW ISR0
DW 0x08 ;code selector ???????????
DB 0x00
DB 0x8E
DW 0x00


what should be in dw 0x08?
Thanks
Unexpected

Re:IRQs and how they work?

Post by Unexpected »

I dont understand your question but..
Here is example GDT:

Code: Select all

GDT
   DD 0
   DD 0
; CodeSel
   DW 0FFFFh
   DW 0
   DB 0
   DB 10011010b
   DB 0CFh
   DB 0
; DataSel
   DW 0FFFFh
   DW 0
   DB 0
   DB 10010010b
   DB 0CFh
   DB 0
GDT_End
Here is example of IDT entry:

Code: Select all

IDT_0:
   DW EXN_0
   DW CodeSel
   DB 0x00
   DB 0x8e
   DW 0x0000
CodeSel must be 0x08, because NULL entry is 8bytes long(two DD). DataSel must be 0x10 because NULL entry + CodeSel = 8 + 8 = 0x10(in hex)

Ner uz ka ;)
Thunder

Re:IRQs and how they work?

Post by Thunder »

OK Thanks
Thunder

Re:IRQs and how they work?

Post by Thunder »

Hey, but when I'm trying to create IDT:
DW ISR0
DW 0x08 ;code selector but should it be 0x0800
DB 0x00
DB 0x8E
DW 0x0000

The NASM says that: (.text+0x5a):" relocation truncated to fit: 16 text" this is DW ISR0, but when I write "DD ISR0" I get no errors, and when I put command "sti" computer just restarts.Whats wrong?
;Here is my part of ISR0:
ISR0:
pusha
push gs
push fs
push es
push ds

[extern _isr_0]
call _isr_0
pop ds
pop es
pop fs
pop gs
popa
iret
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:IRQs and how they work?

Post by Pype.Clicker »

what is wrong is that the linker will have to make a 32-bit address fit a 16-bits location. This has been replied about 10 times on this forum... check out archives if it doesn't speak by itself...
Post Reply