Exemple #1
0
int
uart_getchar(int offset)
{
	/* If interrupts are enabled, use wtint assuming that either the
	   device itself will wake us, or that a clock interrupt will.  */
	if ((rdps() & 7) == 0) {
	    while (!uart_charav(offset)) {
		wtint(0);
	    }
	} else {
	    while (!uart_charav(offset))
	        continue;
	}

	return inb(com2Rbr + offset);
}
/* ( addr len -- actual ) */
static void
pc_serial_read(unsigned long *address)
{
    char *addr;
    int len;

    len = POP();
    addr = (char *)POP();

    if (len != 1)
        printk("pc_serial_read: bad len, addr %lx len %x\n", (unsigned long)addr, len);

    if (uart_charav(*address)) {
        *addr = (char)uart_getchar(*address);
        PUSH(1);
    } else {
        PUSH(0);
    }
}
char uart_getchar(int port)
{
	while (!uart_charav(port));
	return ((char) inb(RBR(port)) & 0177);
}