www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/04/04/16:40:20

Date: Tue, 4 Apr 1995 20:20:24 +0200
From: sarda_jea AT lsi DOT supelec DOT fr
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re : Interrupt programming (keyboard)

Hello everybody,

Carsten Benecke wrote :

>I programmed an interrupt service function for a hardware interrupt (IRQ 9). I 
>used the source code from David Baggett`s Sound Blaster Sample (9-Nov-93) and 
>did some small changes for the IRQ 9:
>+ use slave PIC at base 0xa0 to enable and acknowledge the IRQ
>+ install a new real mode interrupt vector for interrupt 0x71 (IRQ 9)
>+ chain a new protected mode interrupt vector for interrupt 0x71

>The service function is called only for the first two hardware interrupts!
>No more hardware interrupts can be served by my function!

I had EXACTLY the same problem as you and I think I have nearly solved it but 
there is still some problems(by the way thanks to Tim Hesketh, Long Doan, Carl 
Burke for their helpful answers).

I have included my keyboard handler code in this article. It works (at least for 
more than the first two hardware interrupts) but the problem is that at random 
times (4,5 or 20 minutes after the execution begining) ,it makes a segmentation 
fault, or a unknow instruction code or even a SYSTEM RESET !!
I need your comments and help.

this the code :

/*
 * Interrupt handler
 *
 * This is called in both protected mode and in real mode -- this means
 * we don't have to switch modes when we service the interrupt.
 */
static unsigned char scan1,scan2;

void intr(_go32_dpmi_registers *reg)
{



  scan1=inportb(0x60);
  scan2=scan1;
/*********************** scan2 contain the useful scan code **************/

/********************** this is what i added to the soundblaster exemple
*********************** but in fact ,I dont know why it works with it
*********************** since I have taken this from another keyboard handler
******************************************************************************/
  scan1=inportb(0x61);
  scan1=scan1 | 0x82;
  outportb(0x61,scan1);
  outportb(outportb(0x61,scan1 & 0x7f);

/******************* _pressed is just a flag to know if a key was pressed or 
*******************   realesed **********************************************/

  _pressed=1;


  outportb (0x20, 0x20);
  outportb (0xa0, 0x20);



}


(I install this handler like it is done in the soundblaster demonstration 
programm.)



Jean-Philippe.


- Raw text -


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