From 4fcd549f568b87d06c875b5e305627aad6577260 Mon Sep 17 00:00:00 2001 From: okuji Date: Tue, 2 Jul 2002 23:39:14 +0000 Subject: [PATCH] 2002-07-03 Yoshinori K. Okuji * stage2/serial.c [!GRUB_UTIL] (inb): Added a delay into this function itself. [!GRUB_UTIL] (outb): Likewise. [!GRUB_UTIL] (serial_hw_put): Increase the timeout value, and don't call serial_hw_delay explicitly any longer. (fill_input_buf): Increase the maximum number of retries, reset the counter to zero after getting a valid character, and don't call serial_hw_delay explicitly any longer. --- ChangeLog | 11 +++++++++++ stage2/serial.c | 24 +++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32d5345f6..75a2170df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-07-03 Yoshinori K. Okuji + + * stage2/serial.c [!GRUB_UTIL] (inb): Added a delay into this + function itself. + [!GRUB_UTIL] (outb): Likewise. + [!GRUB_UTIL] (serial_hw_put): Increase the timeout value, and + don't call serial_hw_delay explicitly any longer. + (fill_input_buf): Increase the maximum number of retries, reset + the counter to zero after getting a valid character, and don't + call serial_hw_delay explicitly any longer. + 2002-07-03 Yoshinori K. Okuji * stage2/serial.c [!GRUB_UTIL] (serial_hw_fetch): Fixed a typo. diff --git a/stage2/serial.c b/stage2/serial.c index 5b7d9a3aa..4637231e6 100644 --- a/stage2/serial.c +++ b/stage2/serial.c @@ -64,8 +64,10 @@ static inline unsigned char inb (unsigned short port) { unsigned char value; - + asm volatile ("inb %w1, %0" : "=a" (value) : "Nd" (port)); + asm volatile ("outb %%al, $0x80" : : ); + return value; } @@ -74,6 +76,7 @@ static inline void outb (unsigned short port, unsigned char value) { asm volatile ("outb %b0, %w1" : : "a" (value), "Nd" (port)); + asm volatile ("outb %%al, $0x80" : : ); } /* Fetch a key. */ @@ -90,7 +93,7 @@ serial_hw_fetch (void) void serial_hw_put (int c) { - int timeout = 10000; + int timeout = 100000; /* Wait until the transmitter holding register is empty. */ while ((inb (serial_hw_port + UART_LSR) & UART_EMPTY_TRANSMITTER) == 0) @@ -98,11 +101,8 @@ serial_hw_put (int c) if (--timeout == 0) /* There is something wrong. But what can I do? */ return; - - /* Insert a delay. */ - serial_hw_delay (); } - + outb (serial_hw_port + UART_TX, c); } @@ -263,17 +263,19 @@ static int fill_input_buf (void) { int i; - - for (i = 0; i < 1000 && npending < sizeof (input_buf); i++) + + for (i = 0; i < 10000 && npending < sizeof (input_buf); i++) { int c; c = serial_hw_fetch (); if (c >= 0) - input_buf[npending++] = c; + { + input_buf[npending++] = c; - /* Insert a delay. */ - serial_hw_delay (); + /* Reset the counter to zero, to wait for the same interval. */ + i = 0; + } } /* Translate some key sequences. */