code:ttread - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki
- 从 tty 读取字符
- 传入1个参数 atp
- atp : 指定tty
- 使用的隐式参数(传入字符的目标地址,字符个数,...),参看passc
8530 /* Called from device’s read routine after it has
8531 * calculated the tty-structure given as argument.
8532 * The pc is backed up for the duration of this call.
8533 * In case of a caught interrupt, an RTI will re-execute.
8534 */
8535 ttread(atp)
8536 struct tty *atp;
8537 {
8538 register struct tty *tp;
8539
8540 tp = atp;
8541 if ((tp->t_state&CARR_ON)==0)
8542 return;
8543 if (tp->t_canq.c_cc || canon(tp))
- tty 未打开,则直接返回
8544 while (tp->t_canq.c_cc && passc(getc(&tp->t_canq))>=0);或 有元素 能从 原始队列 传入 非原始队列 则 ...
- tty 非原始队列不为空
8545 }
- 完成 读取 工作
8546 /* ------------------------- */