delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/14/18:30:46

From: kaplan AT hokie DOT larc DOT nasa DOT gov (Joseph Kaplan)
Newsgroups: comp.os.msdos.djgpp
Subject: hardware interrupts
Date: Thu, 14 May 1998 17:31:12 -0400
Organization: NASA Langley Research Center
Lines: 82
Message-ID: <kaplan-1405981731120001@hokie.larc.nasa.gov>
NNTP-Posting-Host: hokie.larc.nasa.gov
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I am programming an embedded 486 system that has a
Condor Engineering 400 Arinc board in it.  This board is
supposed to generate interrupts on IRQ 5.  I need to be able
to catch them.  Someone has already written the following
bit of code in real mode and compiled it with Borland and
had it work (i.e., it calls the function IntrHandler):

  vector = 0x08 + 0x05;
  irqMask = 0x01 << 5;
  IRQvalue = 5;
  oldHandler = getvect(vector);
  disable();
  setvect(vector, &IntrHandler);
  outportb(0x21, inportb(0x21) & ~irqMask);
  outportb(0x20, 0x0B);
  enable();

I am trying to do the same thing in DJGPP.  Here is what
I have:


  int interrupt_vector = 0x08 + 0x05;

  disable();

  _go32_dpmi_get_protected_mode_interrupt_vector(
    interrupt_vector,
    &protected_previous_handler);

  protected_receive_handler.pm_offset =
    (int) protectedInterruptHandler;
  
  protected_receive_handler.pm_selector = _go32_my_cs();

  _go32_dpmi_chain_protected_mode_interrupt_vector(
    interrupt_vector,
    &protected_receive_handler);

  _go32_dpmi_get_real_mode_interrupt_vector(
    interrupt_vector,
    &real_previous_handler);

  real_handler.pm_offset = (int) realInterruptHandler;

  _go32_dpmi_allocate_real_mode_callback_iret(
    &real_handler, &real_register1);
  
  _go32_dpmi_set_real_mode_interrupt_vector(
    interrupt_vector, &real_handler);

  int old_programmable_interrupt_mask = inportb(0x21);
  
  int new_programmable_interrupt_mask =
    old_programmable_interrupt_mask & 0xDF;

  outportb(0x21,new_programmable_interrupt_mask);
  outportb(0x0020,0x0B);  
  
  enable();

Here are some of the declarations:

  static _go32_dpmi_seginfo protected_receive_handler;
  static _go32_dpmi_seginfo protected_previous_handler;

  static void protectedInterruptHandler(...);
  static void realInterruptHandler(...);

  static _go32_dpmi_registers real_register1;
  static _go32_dpmi_registers real_register2;
  static _go32_dpmi_seginfo real_previous_handler;
  static _go32_dpmi_seginfo real_handler;


This is not working.  What am I missing here?  I have attempted to
comment out the setting of the programmable interrupt controller and
it still doesn't work.  Any help on getting this working would be
greatly appreciated.

Thanks

Joe

- Raw text -


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