www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/04/10/06:25:31

Date: Sat, 10 Apr 1993 17:37 CST
From: S352704 AT twncu865 DOT ncu DOT edu DOT tw
Subject: Re: Interrput handler.
To: djgpp AT sun DOT soe DOT clarkson DOT edu

   
        Days ago I have the same problem, I want get data from
   RS-232, and write a program which is similar to yours.
   But, it didn't work.

        There are two method to solve this problem.
   One is
          A file in the directory GO32 named EXPHDLR.C
      A section list as follow......
          We find that exception_handler not support
      int 0x60, so we can add a staments
         case 0x60:
      befor the line
      return generic_handler();
      then Rebuild it. (make)

........
exception_handler()
{
  int i;
  i = tss_ptr->tss_irqn;
  ....
  switch (i)
  {
    case 8:
      fprintf(stderr, "double fault!\n");
      exit(1);
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 15:
      return 1;
    case 0x75:
      return 1;
    case 7:
      fprintf(stderr, "Fatal!  Application attempted to use not-present 80387!\n");
      fprintf(stderr, "Floating point opcode at virtual address 0x%08lx\n", tss_ptr->tss_eip);
      return 1;
    case 14:
      return page_in();

    case 0x10:
      return i_10();
    case 0x11:
    case 0x12:
    case 0x14:
    case 0x16:
    case 0x17:
    case 0x1a:
    case 0x15:
/*  Add a line here */
    case 0x60:
      return generic_handler();
    case 0x21:
      return i_21();
    case 0x33:
      return i_33();
    default:
      return 1;
  }
}
......
    File EXPHDLER.C


    Another method is
        If you don't want to modify go32
        you can chain your interrupt handle to
        those inerrrupt that execption_handler support.

        For example

        I chain my interrupt handle to keyboard interrupt (int 0x16)
        we can call it with
              ........
              _AX=0x7000;
              geninterrupt(INTNO);
              ....
        The progrm list as follow:

#include <dos.h>
#include <stdio.h>
#include <stdlib.h>

void  (interrupt far *old_kbint)(void); /* save old int vector */
void  interrupt far REC_intr(void);     /* RS-232C hardware int */
void  interrupt far Interface();        /* Interface of get points */

void interrupt far REC_intr()
{
    .......
    Get data from RS-232 and put the data into a queue
    ......
    outp(0x20,0x20);      /* EOI of mainboard 8259A */
}

void interrupt Interface(bp,di,si,ds,es,dx,cx,bx,ax,ip,cs,flags)
{
    if (((unsigned)_AX & 0xf000u) != 0x7000u)
    {
        _AX=ax;
     	(*old_kbint)();
     	ax=_AX;  flags=_FLAGS;
     	return;
    }
    ....
    Get data from the data queue.
    .....
    ax=data;
}

int main(int argc, char *argv[])
{
    old_kbint=_dos_getvect(INTNO);  /* save old int vector */
    _dos_setvect(0x16,Interface);
    ......
    Initial RS-232 hardware interruprt ...
    _dos_setvect(0x0C,REC_intr);
    outp(Int_Enable,0x01);          /* enable data ready interrupt */
    .....
    printf("Driver successfully installed.\n");
    _dos_keep(0, (_SS + (_SP/16) - _psp));
    return(0);
};

                        Seven
                        s352704 AT ncu865 DOT ncu DOT edu DOT tw

- Raw text -


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