Beispiel #1
0
/* SMP racecondition */
void printk_switch_tty(int ctty)
{
    struct tty *tty = get_tty(ctty);

    tty_set_output(tty, &console_dev);
    tty_set_input(tty, &keyboard_dev);
    //tty_set_input(tty, &serial_dev);
    tty_set_buffered(tty, 0);

    printk_tty = tty;

    __printk_emitter = __printk_emit_tty;
}
Beispiel #2
0
static int tty_readline(fs_node_t * dev, char * linebuf, int max) {
	int read = 0;
	tty_set_unbuffered(dev);
	while (read < max) {
		uint8_t buf[1];
		int r = read_fs(dev, 0, 1, (unsigned char *)buf);
		if (!r) {
			debug_print(WARNING, "Read nothing?");
			continue;
		}
		spin_lock(irc_tty_lock);
		linebuf[read] = buf[0];
		if (buf[0] == '\n') {
			linebuf[read] = 0;
			spin_unlock(irc_tty_lock);
			break;
		} else if (buf[0] == 0x08) {
			if (read > 0) {
				fprintf(dev, "\010 \010");
				read--;
				linebuf[read] = 0;
			}
		} else if (buf[0] < ' ') {
			switch (buf[0]) {
				case 0x0C: /* ^L */
					/* Should reset display here */
					spin_unlock(irc_tty_lock);
					break;
				default:
					/* do nothing */
					spin_unlock(irc_tty_lock);
					break;
			}
		} else {
			fprintf(dev, "%c", buf[0]);
			read += r;
		}
		spin_unlock(irc_tty_lock);
	}
	tty_set_buffered(dev);
	return read;
}