64 |
inb (unsigned short port) |
inb (unsigned short port) |
65 |
{ |
{ |
66 |
unsigned char value; |
unsigned char value; |
67 |
|
|
68 |
asm volatile ("inb %w1, %0" : "=a" (value) : "Nd" (port)); |
asm volatile ("inb %w1, %0" : "=a" (value) : "Nd" (port)); |
69 |
|
asm volatile ("outb %%al, $0x80" : : ); |
70 |
|
|
71 |
return value; |
return value; |
72 |
} |
} |
73 |
|
|
76 |
outb (unsigned short port, unsigned char value) |
outb (unsigned short port, unsigned char value) |
77 |
{ |
{ |
78 |
asm volatile ("outb %b0, %w1" : : "a" (value), "Nd" (port)); |
asm volatile ("outb %b0, %w1" : : "a" (value), "Nd" (port)); |
79 |
|
asm volatile ("outb %%al, $0x80" : : ); |
80 |
} |
} |
81 |
|
|
82 |
/* Fetch a key. */ |
/* Fetch a key. */ |
93 |
void |
void |
94 |
serial_hw_put (int c) |
serial_hw_put (int c) |
95 |
{ |
{ |
96 |
int timeout = 10000; |
int timeout = 100000; |
97 |
|
|
98 |
/* Wait until the transmitter holding register is empty. */ |
/* Wait until the transmitter holding register is empty. */ |
99 |
while ((inb (serial_hw_port + UART_LSR) & UART_EMPTY_TRANSMITTER) == 0) |
while ((inb (serial_hw_port + UART_LSR) & UART_EMPTY_TRANSMITTER) == 0) |
101 |
if (--timeout == 0) |
if (--timeout == 0) |
102 |
/* There is something wrong. But what can I do? */ |
/* There is something wrong. But what can I do? */ |
103 |
return; |
return; |
|
|
|
|
/* Insert a delay. */ |
|
|
serial_hw_delay (); |
|
104 |
} |
} |
105 |
|
|
106 |
outb (serial_hw_port + UART_TX, c); |
outb (serial_hw_port + UART_TX, c); |
107 |
} |
} |
108 |
|
|
263 |
int fill_input_buf (void) |
int fill_input_buf (void) |
264 |
{ |
{ |
265 |
int i; |
int i; |
266 |
|
|
267 |
for (i = 0; i < 1000 && npending < sizeof (input_buf); i++) |
for (i = 0; i < 10000 && npending < sizeof (input_buf); i++) |
268 |
{ |
{ |
269 |
int c; |
int c; |
270 |
|
|
271 |
c = serial_hw_fetch (); |
c = serial_hw_fetch (); |
272 |
if (c >= 0) |
if (c >= 0) |
273 |
input_buf[npending++] = c; |
{ |
274 |
|
input_buf[npending++] = c; |
275 |
|
|
276 |
/* Insert a delay. */ |
/* Reset the counter to zero, to wait for the same interval. */ |
277 |
serial_hw_delay (); |
i = 0; |
278 |
|
} |
279 |
} |
} |
280 |
|
|
281 |
/* Translate some key sequences. */ |
/* Translate some key sequences. */ |