tty: i386: rs232 fix

. ignore interrupt (stop interrupt check loop) if
	  interrupt bit not set; limit loop too
	. mask off other bits when testing bits in the status register
	. this fixes rs232 output that would otherwise never get re-triggered
	  as too many bits were set in the status byte to match the
	  possibilities.

Change-Id: I311c93377fa8fb477ee9a756455fdeda780e6ba1
This commit is contained in:
Ben Gras 2013-06-11 14:11:57 +00:00
parent 9178749e13
commit 93d9caa2d6

View file

@ -22,9 +22,11 @@
/* Interrupt status bits. */ /* Interrupt status bits. */
#define IS_MODEM_STATUS_CHANGE 0 #define IS_MODEM_STATUS_CHANGE 0
#define IS_NOTPENDING 1
#define IS_TRANSMITTER_READY 2 #define IS_TRANSMITTER_READY 2
#define IS_RECEIVER_READY 4 #define IS_RECEIVER_READY 4
#define IS_LINE_STATUS_CHANGE 6 #define IS_LINE_STATUS_CHANGE 6
#define IS_IDBITS 6
/* Line control bits. */ /* Line control bits. */
#define LC_2STOP_BITS 0x04 #define LC_2STOP_BITS 0x04
@ -659,8 +661,9 @@ static void rs232_handler(struct rs232 *rs)
{ {
/* Interrupt hander for RS232. */ /* Interrupt hander for RS232. */
int s; int s;
int trying = 1000;
while (TRUE) { while (trying--) {
u32_t v; u32_t v;
/* Loop to pick up ALL pending interrupts for device. /* Loop to pick up ALL pending interrupts for device.
* This usually just wastes time unless the hardware has a buffer * This usually just wastes time unless the hardware has a buffer
@ -668,8 +671,13 @@ static void rs232_handler(struct rs232 *rs)
* Unfortunately, some serial cards lock up without this. * Unfortunately, some serial cards lock up without this.
*/ */
if ((s = sys_inb(rs->int_id_port, &v)) != OK) if ((s = sys_inb(rs->int_id_port, &v)) != OK)
printf("TTY: sys_inb() failed: %d", s); panic("TTY: sys_inb() failed: %d", s);
switch (v) {
/* do we have interrupt info? */
if(v & IS_NOTPENDING) return;
/* what kind of interrupt? */
switch (v & IS_IDBITS) {
case IS_RECEIVER_READY: case IS_RECEIVER_READY:
in_int(rs); in_int(rs);
continue; continue;
@ -685,6 +693,8 @@ static void rs232_handler(struct rs232 *rs)
} }
return; return;
} }
printf("tty rs232: enough!\n");
} }
/*===========================================================================* /*===========================================================================*