From: Ben Gras Date: Tue, 11 Jun 2013 14:11:57 +0000 (+0000) Subject: tty: i386: rs232 fix X-Git-Tag: v3.3.0~928 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=refs%2Fchanges%2F26%2F626%2F2;p=minix.git 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 --- diff --git a/drivers/tty/arch/i386/rs232.c b/drivers/tty/arch/i386/rs232.c index 142bd6967..d7b2472dd 100644 --- a/drivers/tty/arch/i386/rs232.c +++ b/drivers/tty/arch/i386/rs232.c @@ -22,9 +22,11 @@ /* Interrupt status bits. */ #define IS_MODEM_STATUS_CHANGE 0 +#define IS_NOTPENDING 1 #define IS_TRANSMITTER_READY 2 #define IS_RECEIVER_READY 4 #define IS_LINE_STATUS_CHANGE 6 +#define IS_IDBITS 6 /* Line control bits. */ #define LC_2STOP_BITS 0x04 @@ -659,8 +661,9 @@ static void rs232_handler(struct rs232 *rs) { /* Interrupt hander for RS232. */ int s; + int trying = 1000; - while (TRUE) { + while (trying--) { u32_t v; /* Loop to pick up ALL pending interrupts for device. * 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. */ if ((s = sys_inb(rs->int_id_port, &v)) != OK) - printf("TTY: sys_inb() failed: %d", s); - switch (v) { + panic("TTY: sys_inb() failed: %d", s); + + /* do we have interrupt info? */ + if(v & IS_NOTPENDING) return; + + /* what kind of interrupt? */ + switch (v & IS_IDBITS) { case IS_RECEIVER_READY: in_int(rs); continue; @@ -685,6 +693,8 @@ static void rs232_handler(struct rs232 *rs) } return; } + + printf("tty rs232: enough!\n"); } /*===========================================================================*