if( ByteCount > MaxBytesToRead )
{
ByteCount = MaxBytesToRead;
}
// we are touching the block buffer, we must set the process permissions
SD_SET_PROC_PERMISSIONS_FROM_REQUEST(pRequest)
{
// empty the FIFO RETAILMSG(1, (TEXT("SDControl.c_EmptyReceiveFifo:start empty the FIFO!\r\n")));
while (ByteCount)
{ RETAILMSG(1, (TEXT("SDControl.c_EmptyReceiveFifo:go into while (ByteCount) !\r\n")));
// fill up the receive buffer
if (receiveBufferIndex < MMC_RXFIFO_SIZE)
{ RETAILMSG(1, (TEXT("SDControl.c_EmptyReceiveFifo:if (receiveBufferIndex < MMC_RXFIFO_SIZE) !\r\n")));
if( ByteCount >= 4 )
{
// read in the dword from the FIFO RETAILMSG(1, (TEXT("SDControl.c_EmptyReceiveFifo:ByteCount >= 4!\r\n")));
*(DWORD*)(&pController->RcvBuffer[receiveBufferIndex]) = *pMMC_RX_FifoDW;
receiveBufferIndex+=4;
ByteCount-=4;
}
else
{
// read in the byte from the FIFO
RETAILMSG(1, (TEXT("SDControl.c_EmptyReceiveFifo:ByteCount < 4!\r\n")));
pController->RcvBuffer[receiveBufferIndex] = *pMMC_RX_Fifo;
receiveBufferIndex++;
ByteCount--;
}
// check to see if we've read enough
if ((pRequest->HCParam + receiveBufferIndex) >= MaxBytes)
{
RETAILMSG(1, (TEXT("SDControl.c_EmptyReceiveFifo:HCParam + receiveBufferIndex>= MaxBytes,Break!\r\n")));
break;
}
}
else
{
RETAILMSG(1, (TEXT("SDControl.c_EmptyReceiveFifo:if (receiveBufferIndex >= MMC_RXFIFO_SIZE) !\r\n")));
// receive buffer is full, now transfer the data safely
PREFAST_SUPPRESS( 12008, "False positive: the buffer access index 'pRequest->HCParam + receiveBufferIndex' is guaranteed to be valid prior to this call" );
SDPerformSafeCopy(&pRequest->pBlockBuffer[pRequest->HCParam],
pController->RcvBuffer,
receiveBufferIndex);
// bump the running count
pRequest->HCParam += receiveBufferIndex;
// reset receive buffer index
receiveBufferIndex = 0;
}
} // while
RETAILMSG(1, (TEXT("SDControl.c_EmptyReceiveFifo:break while (ByteCount) !\r\n")));
// check for any left over data
if (receiveBufferIndex)
{
RETAILMSG(1, (TEXT("SDControl.c_EmptyReceiveFifo:go into if (receiveBufferIndex)!\r\n")));
// safely copy the data
SDPerformSafeCopy(&pRequest->pBlockBuffer[pRequest->HCParam],
pController->RcvBuffer,
receiveBufferIndex);
// bump the running count
pRequest->HCParam += receiveBufferIndex;
}
} SD_RESTORE_PROC_PERMISSIONS();
RETAILMSG(1, (TEXT("SDControl.c_EmptyReceiveFifo:break SD_RESTORE_PROC_PERMISSIONS !\r\n")));
}
插入卡之后主要运行这个函数,主要打印我标识的“黑粗体”的信息