Ejemplo n.º 1
0
bool PDC_check_key(void)
{
#ifdef CONFIG_USB_HID
    usb_poll();
    if ((curses_flags & F_ENABLE_CONSOLE) &&
        usbhid_havechar()) {
        return TRUE;
    }
#endif

#ifdef CONFIG_PC_KEYBOARD
    if ((curses_flags & F_ENABLE_CONSOLE) &&
        keyboard_havechar()) {
        return TRUE;
    }
#endif

#ifdef CONFIG_SERIAL_CONSOLE
    if ((curses_flags & F_ENABLE_SERIAL) &&
        serial_havechar()) {
        return TRUE;
    }
#endif

    return FALSE;
}
Ejemplo n.º 2
0
int serial_getchar(void)
{
	if (!serial_hardware_is_present)
		return -1;
	while (!serial_havechar()) ;
	return serial_read_reg(0x00);
}
Ejemplo n.º 3
0
/**
 * ipq806x_serial_getc - reads a character
 *
 * Returns the character read from serial port.
 */
int serial_getchar(void)
{
	uint8_t byte;

	while (!serial_havechar()) {
		/* wait for incoming data */
	}

	byte = (uint8_t)(uart_rx_fifo_word & 0xff);
	uart_rx_fifo_word = uart_rx_fifo_word >> 8;
	uart_ready_data_count--;

	return byte;
}
Ejemplo n.º 4
0
static int curses_getchar(int _delay)
{
#if CONFIG(LP_USB_HID) || CONFIG(LP_PC_KEYBOARD) || \
	CONFIG(LP_SERIAL_CONSOLE)
	unsigned short c;
#endif

	do {
#if CONFIG(LP_USB_HID)
		usb_poll();
		if ((curses_flags & F_ENABLE_CONSOLE) &&
		    usbhid_havechar()) {
			c = usbhid_getchar();
			if (c != 0) return c;
		}
#endif
#if CONFIG(LP_PC_KEYBOARD)
		if ((curses_flags & F_ENABLE_CONSOLE) &&
		    keyboard_havechar()) {
			c = keyboard_getchar();
			if (c != 0) return c;
		}
#endif

#if CONFIG(LP_SERIAL_CONSOLE)
		if ((curses_flags & F_ENABLE_SERIAL) &&
		    serial_havechar()) {
			c = serial_getchar();
			return cook_serial(c);
		}
#endif

		if (_delay == 0) {
			break;
		} else if (_delay >= 10) {
			mdelay(10);
			_delay -= 10;
		} else if (_delay > 0) {
			mdelay(_delay);
			_delay = 0;
		}
	} while (1);

	return ERR;
}
Ejemplo n.º 5
0
static int curses_getchar(int _delay)
{
#if defined(CONFIG_USB_HID) || defined(CONFIG_PC_KEYBOARD) || defined(CONFIG_SERIAL_CONSOLE)
	unsigned short c;
#endif

	do {
#ifdef CONFIG_USB_HID
		usb_poll();
		if ((curses_flags & F_ENABLE_CONSOLE) &&
		    usbhid_havechar()) {
			c = usbhid_getchar();
			if (c != 0) return c;
		}
#endif
#ifdef CONFIG_PC_KEYBOARD
		if ((curses_flags & F_ENABLE_CONSOLE) &&
		    keyboard_havechar()) {
			c = keyboard_getchar();
			if (c != 0) return c;
		}
#endif

#ifdef CONFIG_SERIAL_CONSOLE
		if ((curses_flags & F_ENABLE_SERIAL) &&
		    serial_havechar()) {
			c = serial_getchar();
			return cook_serial(c);
		}
#endif

		if (_delay == 0)
			break;

		if (_delay > 0) {
			mdelay(1);
			_delay--;
		}


	} while (1);

	return ERR;
}
Ejemplo n.º 6
0
static int getkeyseq(char *buffer, int len, int max)
{
	int i;

	while (1) {
		for(i = 0; i < 75; i++) {
			if (serial_havechar())
				break;
			mdelay(1);
		}

		if (i == 75)
			return len;

		buffer[len++] = serial_getchar();
		if (len == max)
			return len;
	}
}
Ejemplo n.º 7
0
static bool event(void* data) {
	int ch;
	if(serial_enabled) {
		while(serial_havechar()) {
			ch = serial_getchar();
			// TODO: process other special keys
			if(ch == '\r') {
				// Serial mode of QEMU is cooked mode. 
				// Line feed('\r') expected for new line('\n') 
				stdio_putchar((const char)'\n');
			} else {
				stdio_putchar((const char)ch);
			}

		}
	}

	if(callback)
		callback();

	return true;
}
Ejemplo n.º 8
0
int PDC_get_key(void)
{
    int c = 0;

#ifdef CONFIG_USB_HID
    usb_poll();
    if ((curses_flags & F_ENABLE_CONSOLE) &&
        usbhid_havechar()) {
        c = usbhid_getchar();
    }
#endif

#ifdef CONFIG_PC_KEYBOARD
    if ((curses_flags & F_ENABLE_CONSOLE) &&
        keyboard_havechar() && (c==0)) {
        c = keyboard_getchar();
    }
#endif

#ifdef CONFIG_SERIAL_CONSOLE
    if ((curses_flags & F_ENABLE_SERIAL) &&
        serial_havechar() && (c==0)) {
        c = cook_serial(serial_getchar());
    }
#endif

    SP->key_code = FALSE;

    if (c == 0) {
        c = ERR;
    }
    if (c >= KEY_MIN) {
        SP->key_code = TRUE;
    }

    return c;
}
Ejemplo n.º 9
0
int serial_getchar(void)
{
	while (!serial_havechar());
	return readl(&uart_regs->uart_rbr)&0xff;
}