主题 : 关于SD卡驱动中的一个问题! 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 35891
精华: 0
发帖: 29
金钱: 150 两
威望: 30 点
综合积分: 58 分
注册时间: 2011-01-08
最后登录: 2012-03-19
楼主  发表于: 2011-09-25 16:00

 关于SD卡驱动中的一个问题!

在弄SD卡驱动程序时,看到有这么一段代码,
while ((fifo = fifo_free(host)) > 3) {
                   if (!host->pio_bytes) {
                            res = get_data_buffer(host, &host->pio_bytes,
                   /* If we have reached the end of the block, we have to
                    * write exactly the remaining number of bytes.  If we
                    * in the middle of the block, we have to write full
                    * words, so round down to an even multiple of 4. */
                   if (fifo >= host->pio_bytes)//fifo的空间比pio_bytes大,表明这是读这个块的最后一次
                            fifo = host->pio_bytes;
                   /* because the volume of FIFO can contain the remaning block*/
                   else
                            fifo -= fifo & 3;/*round down to an even multiple of 4*/

                   host->pio_bytes -= fifo;//更新还剩余的没有写完的字
                   host->pio_count += fifo;/*chang the value of pio_bytes*/

                   fifo = (fifo + 3) >> 2;//将字节数转化为字数
                   /*how many words fifo contain,every time we just writ one word*/
                   ptr = host->pio_ptr;
                   while (fifo--)
                            writel(*ptr++, to_ptr);//写往FIFO.
                   host->pio_ptr = ptr;
         }


这代码是说往fifo里读写数据的,我想问下host->pio_bytes -= fifo;//更新还剩余的没有写完的字
                   host->pio_count += fifo;/*chang the value of pio_bytes*/      这句什么意思啊,为什么要更新没写完的字,
fifo = (fifo + 3) >> 2;//将字节数转化为字数,还有这个,它是如何将字节数转换为字数的,

while (fifo--)
                            writel(*ptr++, to_ptr);//写往FIFO.
                   host->pio_ptr = ptr;
这句又是什么意思,请斑竹出来解决下,实在不懂


级别: 新手上路
UID: 35891
精华: 0
发帖: 29
金钱: 150 两
威望: 30 点
综合积分: 58 分
注册时间: 2011-01-08
最后登录: 2012-03-19
1楼  发表于: 2011-09-25 21:57
求版主啊!!