Mail Archives: djgpp/1998/09/16/05:15:16
From: | default <@res.raytheon.com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | More Q's about IRQs
|
Date: | Wed, 09 Sep 1998 18:40:40 -0400
|
Organization: | Raytheon Electronic Systems
|
Lines: | 73
|
Message-ID: | <35F703E7.AE7F8896@res.raytheon.com>
|
NNTP-Posting-Host: | neomar1.res.ray.com
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Okay, here's the story.
I have written an ISR to service an HW interrupt generated by Com Port 1
on a Pentium PC.
I have set up the port in the conventional manner, ie:
(Note that this configuration has been proven to work fine in RM.)
-9600-8-1-n,
-system interrupts enabled through OUT2 based on DataReady.
-HW setup: I've simply tied pins 2&3 together to route outbound data
inbound.
Now I want to do it in PM.
The interesting part comes when I actually hook the protected mode
interrupt and try to get the port to respond.
<CODE_FRAGMENT>
_go32_dpmi_lock_code(ComISR, (dword) ComISR_End - (dword) ComISR);
new_handler.pm_offset = (int) ComISR;
new_handler.pm_selector = _go32_my_cs();
_go32_dpmi_allocate_iret_wrapper(&new_handler);
_go32_dpmi_set_protected_mode_interrupt_vector(COM1_INT, &new_handler);
<\CODE_FRAGMENT>
Note that my handler simply increments a global count variable for now,
reads the port to clear data, and issues an EOI (since it is not
specified whether or not the _go32 wrappers handle that sort of thing in
my documentation)
When I write data to the port in order to get it to generate an int,
nothing happens.
_However_, when I read the port directly from my main program, the
interrupts suddenly start working, my variable is incremented, and the
"write - head" of my serial-in data ring buffer accelerates compared to
the "read - head" of the same buffer, indicating that the interrupts are
being generated properly. Here is the code fragment from main():
<MAIN()_CODE_FRAGMENT>
int i = 0x00;
while(kbhit() == 0) {
if(bufrdptr != bufwrtptr) { /* i.e. if data has been written to
buffer since last read*/
gotoxy(5,5);
cprintf("com_buffer:%s\n\r", com_buffer[bufrdptr]);
bufrdptr = (bufrdptr < 0x400) ? (bufrdptr + 1) : 0;
}
gotoxy(10,10);
cprintf("Read: % 3d Write: % 3d", bufrdptr, bufwrtptr);
delay(100);
gotoxy(10,11);
cprintf("Writing % 2d to port\n\r",i);
outportb(BASE, i);
gotoxy(10,12);
/*************************************************************/
/* here is the magic mystery: */
cprintf("Reading Port % 2d \n\r", inportb(BASE)); /* note BASE =
0x3F8*/
/*************************************************************/
i += (i < 0xFFF) ? 1 : 0;
}
<\MAIN()_CODE_FRAGMENT>
Remember, the code worked fine in real mode, all I have done was to add
the adaptions for PM as defined by DJGPP.
Thanks for reading through all this drivel, if you can help, I will be
much indebted.
- Raw text -