Chinaunix首页 | 论坛 | 博客
  • 博客访问: 522255
  • 博文数量: 118
  • 博客积分: 3995
  • 博客等级: 中校
  • 技术积分: 1276
  • 用 户 组: 普通用户
  • 注册时间: 2005-11-15 12:15
文章分类

全部博文(118)

文章存档

2014年(1)

2013年(1)

2010年(6)

2009年(27)

2008年(10)

2007年(33)

2006年(38)

2005年(2)

我的朋友

分类: LINUX

2009-02-27 23:23:54

// 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,显示器
}




阅读(1480) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~