flat assembler
Message board for the users of flat assembler.

Index > OS Construction > IRQs in Pmode

Author
Thread Post new topic Reply to topic
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER
Hi everyone!
I've made interrupts and they do work, now I need to know how to handle IRQs in protected mode. I read on bonafide that I will have to map them somehow, how???

_________________
_______________________________
NSOS
Post 13 Jun 2011, 11:26
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17665
Location: In your JS exploiting you and your system
revolution
BOTOKILLER wrote:
... I will have to map them somehow, how???
Use the IDTR luke.

Intel Manual 3A, Chapter 6, Section 10 "INTERRUPT DESCRIPTOR TABLE (IDT)"
Post 13 Jun 2011, 11:37
View user's profile Send private message Visit poster's website Reply with quote
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER
I know that I have to use IDT, but what interrupt numbers IRQs occupy???
Post 13 Jun 2011, 14:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17665
Location: In your JS exploiting you and your system
revolution
I assume then that you are asking about the hardware interrupt numbers? If so then you need to program the PIC chips to set the base value.
Post 13 Jun 2011, 15:11
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Yes you need to remap them, something like this:
Code:
remap_pic:
       cli
 mov  al,0x11                                      ; put both 8259s in init mode
     out  0x20,al
        out  0xA0,al
        mov  al,0x20                                      ; remap pic irq0-irq7 -> int 0x20-27
   out  0x21,al
        mov  al,0x28
        out  0xA1,al                                      ; remap pic irq8-irq15 -> int 0x28-30
  mov  al,4                                         ; icw3 pic1(master)
       out  0x21,al                                      ; bit 2=1: irq2 is the slave
  mov  al,2                                         ; icw3 pic2
       out  0xA1,al                                      ; bit 1=1: slave id is 2
      mov  al,1                                         ; icw4 to both controllers
        out  0x21,al                                      ; bit 0=1: 8086 mode
  out  0xA1,al
mask_irqs:    
  cli
 mov  al,255                                       ; mask all irqs
   out  0xa1,al
        out  0x21,al
        ret


    
Post 13 Jun 2011, 15:17
View user's profile Send private message Reply with quote
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER
Dex4u wrote:
Yes you need to remap them, something like this:
Code:
remap_pic:
     cli
 mov  al,0x11                                      ; put both 8259s in init mode
     out  0x20,al
        out  0xA0,al
        mov  al,0x20                                      ; remap pic irq0-irq7 -> int 0x20-27
   out  0x21,al
        mov  al,0x28
        out  0xA1,al                                      ; remap pic irq8-irq15 -> int 0x28-30
  mov  al,4                                         ; icw3 pic1(master)
       out  0x21,al                                      ; bit 2=1: irq2 is the slave
  mov  al,2                                         ; icw3 pic2
       out  0xA1,al                                      ; bit 1=1: slave id is 2
      mov  al,1                                         ; icw4 to both controllers
        out  0x21,al                                      ; bit 0=1: 8086 mode
  out  0xA1,al
mask_irqs:    
  cli
 mov  al,255                                       ; mask all irqs
   out  0xa1,al
        out  0x21,al
        ret


    

thanks works fine, but mask must be 0, so that interrupts work

_________________
_______________________________
NSOS
Post 15 Jun 2011, 12:08
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
BOTOKILLER wrote:

thanks works fine, but mask must be 0, so that interrupts work
Yes, but first you should mask all interrupts first, than un-mask the ones you have implemented.
Which in most cases it all of them.
Code:
unmask_irqs:
  mov  al,0                                         ; unmask irq's 
  out  0xA1,al
        out  0x21,al
        sti
 ret
    

But not always Wink .
Post 15 Jun 2011, 15:40
View user's profile Send private message Reply with quote
christiandy



Joined: 03 Mar 2011
Posts: 25
Location: 101
christiandy
My IRQs can call in software interrupt but not working in hardware interrupt I used exactly same with this code. do you know why?
Post 14 Jul 2011, 18:08
View user's profile Send private message AIM Address Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
ISRs require a valid GDT and IDT as well as interrupts being enabled. IRQs have an additional enable by writing 0 to their mask bit in their respective registers (Intel 8259 ports 0x20,0xA0) [writing 1 disables them].

Note the above code simply remaps the IRQs and disables (masks) them.
Post 22 Jul 2011, 19:15
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
You also need to send a end of IRQ
Eg:
Code:
       mov  al,0x20
        out   0xa0,al
       out   0x20,al
    

At the end of every IRQ handler, or you will only get one firing, once.
Post 22 Jul 2011, 19:50
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.