Beispiel #1
0
Datei: tty.c Projekt: zf369/Tinix
/*======================================================================*
                            task_tty
 *----------------------------------------------------------------------*
 * 作用:键盘中断处理函数
 *======================================================================*/
PUBLIC void task_tty()
{
	TTY *p_tty;

	// 初始化键盘中断放到这里,进程开始执行的时候执行一次
	init_keyboard();

	// 遍历初始化所有TTY
	for (p_tty = TTY_FIRST; p_tty < TTY_END; p_tty++)
	{
		init_tty(p_tty);
	}

	nr_current_console = 0;    // 最开始生效的是第一个TTY

	while (1)
	{
		// 轮询所有TTY,如果当前TTY在前台,读取键盘缓冲区,显示到显存中
		for (p_tty = TTY_FIRST; p_tty < TTY_END; p_tty++)
		{
			tty_do_read(p_tty);
			tty_do_write(p_tty);
		}
	}
}
Beispiel #2
0
void task_tty(void)
{
  Tty *tty;

  init_console();

  for (tty = tty_table ; tty < tty_table + TTY_NUM ; ++tty)
  {
    init_tty(tty);
  }
  select_tty(0);

  static int i=0;
  while(1)
  {
    //assert(0);
    //panic("in tty");
    s32_print_int(i, (u8*)(0xb8000+160*23), 10);
    ++i;
    for (tty = tty_table ; tty < tty_table + TTY_NUM ; ++tty)
    {
      if (tty->ready == 1)
      {
        tty_do_read(tty);
        tty_do_write(tty);
      }
    }
  }
}
Beispiel #3
0
/**
 * <Ring 1> Main loop of task TTY.
 *****************************************************************************/
PUBLIC void task_tty()
{
	TTY *	tty;
	MESSAGE msg;

	init_keyboard();

	for (tty = TTY_FIRST; tty < TTY_END; tty++)
		init_tty(tty);

	select_console(0);

	while (1) {
		for (tty = TTY_FIRST; tty < TTY_END; tty++) {
			do {
				tty_dev_read(tty);
				tty_dev_write(tty);
			} while (tty->ibuf_cnt);
		}

		send_recv(RECEIVE, ANY, &msg);

		int src = msg.source;
		assert(src != TASK_TTY);

		TTY* ptty = &tty_table[msg.DEVICE];

		switch (msg.type) {
		case DEV_OPEN:
			reset_msg(&msg);
			msg.type = SYSCALL_RET;
			send_recv(SEND, src, &msg);
			break;
		case DEV_READ:
			tty_do_read(ptty, &msg);
			break;
		case DEV_WRITE:
			tty_do_write(ptty, &msg);
			break;
		case HARD_INT:
			/**
			 * waked up by clock_handler -- a key was just pressed
			 * @see clock_handler() inform_int()
			 */
			key_pressed = 0;
			continue;
		default:
			dump_msg("TTY::unknown msg", &msg);
			break;
		}
	}
}
Beispiel #4
0
/*-----tty_platform-----*/
void tty_platform(void)
{
	struct	ttybuf	*pTtab = ttyTab;

	tty_init();

	while(1) {
		for(pTtab = ttyTab; pTtab < ttyTab + NR_TTY; pTtab++) {
			tty_do_read(pTtab);
			tty_do_write(pTtab);
		}
	}
}
Beispiel #5
0
void task_tty()
{
        struct Tty *p_tty;
        init_keyboard();
        for (p_tty = tty_table; p_tty < tty_table + NR_CONSOLES; p_tty++)
                init_tty(p_tty);
        select_console(0);
        while(1) {
                for (p_tty = tty_table; p_tty < tty_table + NR_CONSOLES; p_tty++) {
                        tty_do_read(p_tty);
                        tty_do_write(p_tty);
                }
        }
}
Beispiel #6
0
/*======================================================================*
                           task_tty
 *======================================================================*/
PUBLIC void task_tty()
{
	TTY*	p_tty;

	init_keyboard();

	for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) {
		init_tty(p_tty);
	}
	select_console(0);
	while (1) {
		for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) {
			tty_do_read(p_tty);
			tty_do_write(p_tty);
		}
	}
}
Beispiel #7
0
PUBLIC void task_tty()
{
	TTY*	tty;

	init_keyboard();

	for (tty=TTY_FIRST;tty<TTY_END;tty++) {
		init_tty(tty);
	}
	printinfo("\ninit clock\n");
printinfo("init keyboard\n");
	select_SCREEN(0);
	while (1) {
		for (tty=TTY_FIRST;tty<TTY_END;tty++) {
			tty_do_read(tty);
			tty_do_write(tty);
		}
	}
}
Beispiel #8
0
Datei: tty.c Projekt: MKStudy/MK
/*======================================================================*
                           task_tty
 *======================================================================*/
PUBLIC void task_tty()
{
	MESSAGE msg;
	TTY*	p_tty;
	int src;
	int f_WaitSend = 0;
	int i = 0;

	//while(1);
	/* panic("in TTY"); */
	/* assert(0); */

	//init_keyboard();

	for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) {
		init_tty(p_tty);
	}
	select_console(0);

	//printf("tty ok!\n");
	while (1) {

		for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) {
			tty_do_read(p_tty);
			if (p_tty->inbuf_count)
			{
					if(*(p_tty->p_inbuf_tail) == '\n')
					{
						tty_do_write(p_tty);
						szTTYBuffer[nTTYBufferIndex] = 0;
						nTTYBufferIndex = 0;

						if(f_WaitSend)
						{
							msg.type = TTY_ENTER;
							msg.u.m2.m2p1 = szTTYBuffer;
							send_recv(SEND, src, &msg);
							f_WaitSend = 0;
							//printf(szTTYBuffer);
							//printf("\n");
							}
					}
					else
					{
						char ch = *(p_tty->p_inbuf_tail);
						tty_do_write(p_tty);
						szTTYBuffer[nTTYBufferIndex++] = ch;
					}
				}

		}

		if(f_WaitSend == 0)
		{
			send_recv(RECEIVE, ANY, &msg);
			src = msg.source;
			f_WaitSend = 1;
		}



	}
}