免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1819 | 回复: 1
打印 上一主题 下一主题

IDE驱动中的一个疑问 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-08-20 12:51 |只看该作者 |倒序浏览
在ide-iops.c中有如下代码:
  1. static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long timeout, u8 *rstat)
  2. {
  3.         unsigned long flags;
  4.         int i;
  5.         u8 stat;

  6.         udelay(1);        /* spec allows drive 400ns to assert "BUSY" */
  7.         stat = ide_read_status(drive);

  8.         if (stat & BUSY_STAT) {
  9.                 local_irq_set(flags);
  10.                 timeout += jiffies;
  11.                 while ((stat = ide_read_status(drive)) & BUSY_STAT) {
  12.                         if (time_after(jiffies, timeout)) {
  13.                                 /*
  14.                                  * One last read after the timeout in case
  15.                                  * heavy interrupt load made us not make any
  16.                                  * progress during the timeout..
  17.                                  */
  18.                                 stat = ide_read_status(drive);
  19.                                 if (!(stat & BUSY_STAT))
  20.                                         break;

  21.                                 local_irq_restore(flags);
  22.                                 *rstat = stat;
  23.                                 return -EBUSY;
  24.                         }
  25.                 }
  26.                 local_irq_restore(flags);
  27.         }
  28.         /*
  29.          * Allow status to settle, then read it again.
  30.          * A few rare drives vastly violate the 400ns spec here,
  31.          * so we'll wait up to 10usec for a "good" status
  32.          * rather than expensively fail things immediately.
  33.          * This fix courtesy of Matthew Faupel & Niccolo Rigacci.
  34.          */
  35.         for (i = 0; i < 10; i++) {
  36.                 udelay(1);
  37.                 stat = ide_read_status(drive);

  38.                 if (OK_STAT(stat, good, bad)) {
  39.                         *rstat = stat;
  40.                         return 0;
  41.                 }
  42.         }
  43.         *rstat = stat;
  44.         return -EFAULT;
  45. }
复制代码
这时为什么判断BSY位是单独做的,等判断它被清除之后,然后再读取判断DRDY以及DRQ等?并且判断BSY和其它位之间至少会等待10us再读一次Status Register?

论坛徽章:
0
2 [报告]
发表于 2010-08-20 12:55 |只看该作者
刚才看资料不够细心,自己明白了,Standard中定义为BSY定清之后其它状态位在400ns内会有效,所以按说软件至少等400ns就OK了,只是有些Drivre没有遵从规范,所以代码中多试了几次。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP