delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/13/07:21:09

From: "Mark Usher" <marku AT magnet DOT at>
Newsgroups: comp.os.msdos.djgpp
Subject: Can't get my IRQ 7 handler to trigger
Date: Sun, 13 Jun 1999 12:21:50 +0200
Organization: Telenor magnet GmbH
Lines: 125
Message-ID: <7k0143$prv$1@orudios.magnet.at>
NNTP-Posting-Host: n095p022.dipool.highway.telekom.at
X-Trace: orudios.magnet.at 929269699 26495 195.3.75.214 (13 Jun 1999 10:28:19 GMT)
X-Complaints-To: abuse AT magnet DOT at
NNTP-Posting-Date: 13 Jun 1999 10:28:19 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi

I have been trying for about a week now to get my IRQ handler to trigger on
a hardware IRQ 7 which is triggered by an ISA card. I've been using the
examples provided by A. Williams. My timer INT routine is working great but
I can't seem to get this 2nd handler working. I am 95% certain that the card
is firing the interrupt, and know it works with the original software so the
hardware is functioning as it should.

The code is as follows....If anyone could spare a few moments to try and
help me I'd really appreciate it.

Mark
marku AT magnet DOT at


#define MASTER_FIRST_VECTOR    0x08
#define CARD_INTERRUPT         0x07

///////////////////////////////////////////////////////////////////////
// Main program init and loop

int main()
{
    _go32_dpmi_seginfo old_card_handler, new_card_handler;

    /* get the current handler saving it in old_handler for later */
    _go32_dpmi_get_protected_mode_interrupt_vector( MASTER_FIRST_VECTOR +
CARD_INTERRUPT, &old_card_handler);

    /* lock function so it is not paged out */
    _go32_dpmi_lock_code(card_handler, (long)end_card_handler -
(long)card_handler);

    /* get the address of the function to execute when the card INT occurs
*/
    new_card_handler.pm_offset = (int)card_handler;
    new_card_handler.pm_selector = _go32_my_cs();

    /* add handler to the chain */
    _go32_dpmi_chain_protected_mode_interrupt_vector( MASTER_FIRST_VECTOR +
CARD_INTERRUPT, &new_card_handler);

   InstallInterrupt();
   enable();

   do {}
   while (0==0);

    /* Remove the IRQ event from the chain */
    _go32_dpmi_set_protected_mode_interrupt_vector(MASTER_FIRST_VECTOR +
CARD_INTERRUPT, &old_card_handler);

    /* Flag the interrupt in the PIC as no longer being used */
    handle =inportb(0x21);
    handle = handle & (0x1 << CARD_INTERRUPT);  /* Set the mask for the PIC
command */
    outportb(0x21, handle);

}

///////////////////////////////////////////////////////////////////////
// Handler routine

void card_handler()
{
   ScreenPutChar(65, (BLUE << 4) | WHITE, 78, 6);
}

void end_card_handler(){}

///////////////////////////////////////////////////////////////////////
// Set up the pic

byte InstallInterrupt(void)
{
    byte value;
    byte mask;
    byte i;

    mask = 0x01 << CARD_INTERRUPT;

    /* test to see if the interrupt is in use */
    asm ("cli");

    value = CARD_INTERRUPT | SPECIFIC_EOI;
    outportb(0x20, value);        /* OCW 2 */

    i=0;
    do
    {
        /* Select IRR Interrupt Request Register */
        outportb(0x20, 0x0A);        /* OCW 3 */
        i++;
        value = inportb(0x20) & mask;
    }
    while ((i<255) && (value ==0));

    if (i>=255)
    {
       printf("Interrupt already in use. 0x%X\n",value);
       return -1;
    }

    value = CARD_INTERRUPT | SPECIFIC_EOI;
    outportb(0x20, value);        /* OCW 2 */

    /* enable the cards interrupt */

    value = inportb(0x21);
    value = value & ~(0x1 << CARD_INTERRUPT);  /* Set the mask for the PIC
command */
    outportb(0x21, value);

    asm("sti");

    return 0;
}







- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019