8259 interrupts for Serial Com

Hi,
I have been working on some basic low level communication through the number 1 port of a UART through C and now we have been asked to include interrupts instead of polling. With polling i had no problems using either in/outportb or int86. But now that we have to use the 8259 PIC something goes wrong. I use the go32 and dpmi functions in order to replace the ISR in the vector that is associated with the 0Ch interrupt (which corresponds to the serial port 1 interrupt) but it seems that even though i have unmasked and enabled all the required bits, when i send a character the UART does not send an interrupt or the PIC does not recognize it. Some help would be appreciated!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <pc.h>
#include <dos.h>
#include <dpmi.h>
#include <go32.h>
#include "com.h"


#define PORTINT 0x0C


   _go32_dpmi_seginfo OldISR, NewISR; //Structs
   char ch;
void Port_Routine(void)
{
  ch=inportb(0x3F8);
  printf("Received: %c\n",ch);
}

void chip_init(void){
     com_init(COM1,0xEF); //Initializes the UART baud rate parity etc.
     outportb(COM1+1,0x0F); //Initializes the UART interrupt registers

     outportb(0x21,inportb(0x21)&0xEF); //We and out the bit of IRQ4 in order
                                        //to enable the interrupt mask register
}

void handler_set(void){
   
//point NewISR to the proper selector:offset for handler
//function
   NewISR.pm_offset = (int)Port_Routine;
   NewISR.pm_selector = _go32_my_cs();
   
//load the address of the old timer ISR into the OldISR structure
   _go32_dpmi_get_protected_mode_interrupt_vector(PORTINT, &OldISR);
   _go32_dpmi_allocate_iret_wrapper(&NewISR);
   _go32_dpmi_set_protected_mode_interrupt_vector(PORTINT, &NewISR);
   
   puts("New ISR set");
}

void handler_reset(void)
{
     _go32_dpmi_free_iret_wrapper(&NewISR);
     _go32_dpmi_set_protected_mode_interrupt_vector(PORTINT, &OldISR);
     
}
int main(void)
{

//Initializing COM port
   chip_init();

   printf("About to set the new ISR onto the old timer ISR..\n");
   getkey();
   
   handler_set();
   
   while(!kbhit());

   handler_reset();

   
   printf("Removing new ISR from the timer ISR chain\n");

   return 0;
}
Topic archived. No new replies allowed.