在弄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;
这句又是什么意思,请斑竹出来解决下,实在不懂 |