// return the next input character from the console, or 0 if none waitingint
cons_getc(void)
{
int c;
// poll for any pending input characters,
// so that this function works even when interrupts are disabled
// (e.g., when called from the kernel monitor).
serial_intr(); // 输入又可能来自串口或者键盘, xxx_intr设置终端响应函数
kbd_intr(); // 调用cons_intr(int (*proc)(void)),proc为各自的接口处理函数
// 将输入保存到cons.buf内
// grab the next character from the input buffer.
if (cons.rpos != cons.wpos) { // buffer内有输入;使用数组作为循环buffer
c = cons.buf[cons.rpos++];
if (cons.rpos == CONSBUFSIZE) // 循环buffer
cons.rpos = 0;
return c;
}
return 0;
}
// output a character to the console
void
cons_putc(int c)
{
lpt_putc(c); // 输出到parallel printer port,打印机
cga_putc(c); // 输出到Color Graphics Adapter,显示器
}
阅读(1534) | 评论(0) | 转发(0) |