?? sdbusreq.cpp
字號(hào):
DEBUGMSG(SDBUS_ZONE_REQUEST, (TEXT("--- SDBusDriver: Response Dump: \n")));
if (ResponseR2 == CommandResponse.ResponseType) {
SDOutputBuffer(CommandResponse.ResponseBuffer, 17);
} else {
SDOutputBuffer(CommandResponse.ResponseBuffer, 6);
}
}
if (NULL != pBlockBuffer) {
if (SD_READ == TransferClass) {
DEBUGMSG(SDBUS_ZONE_REQUEST, (TEXT("--- SDBusDriver: Read Data Transfered : NumBlocks:%d BytesPerBlock:%d \n"),
NumBlocks, BlockSize));
if (SDBUS_ZONE_BUFFER) {
DEBUGMSG(SDBUS_ZONE_BUFFER, (TEXT("--- SDBusDriver: Read Data Dump: \n")));
SDOutputBuffer(pBlockBuffer, NumBlocks * BlockSize);
}
} else {
DEBUGMSG(SDBUS_ZONE_REQUEST, (TEXT("--- SDBusDriver: Write Transfer Complete: NumBlocks:%d BytesPerBlock:%d\n"),
NumBlocks, BlockSize));
}
}
}
}
#endif
PSD_BUS_REQUEST_CALLBACK pCallbackPtr = (PSD_BUS_REQUEST_CALLBACK)InterlockedExchange( (LPLONG)&pCallback, NULL); // Make sure only call once.
if (pCallbackPtr) {
__try {
if (m_hCallback) {
IO_BUS_SD_REQUEST_CALLBACK busSdRequestCallback = {
pCallbackPtr, m_sdDevice.GetDeviceHandle().hValue,m_ExternalHandle,
m_sdDevice.GetDeviceContext(), RequestParam };
CeDriverPerformCallback(
m_hCallback, IOCTL_BUS_SD_REQUEST_CALLBACK,&busSdRequestCallback,sizeof(busSdRequestCallback),
NULL,0,NULL,NULL);
}
else {
pCallbackPtr(m_sdDevice.GetDeviceHandle().hValue, // device handle
(PSD_BUS_REQUEST)m_ExternalHandle, // the request
m_sdDevice.GetDeviceContext(), // device context
RequestParam); // request argument
}
} __except (SDProcessException(GetExceptionInformation())) {
DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("--- SDBusDriver: Exception caught in CompleteRequest when calling callback in device %s \n"),
m_sdDevice.GetClientName()));
}
}
}
return TRUE;
}
BOOL CSDBusRequest::IsRequestNeedRetry()
{
if ((m_sdDevice.GetClientFlags() & SD_CLIENT_HANDLES_RETRY)==0) { // we need retry.
if (((SD_API_STATUS_RESPONSE_TIMEOUT == Status) || (SD_API_STATUS_DATA_TIMEOUT == Status) || (SD_API_STATUS_CRC_ERROR == Status))
&& GetRetryCount()!=0) {
return TRUE;
}
}
return FALSE;
}
BOOL CSDBusRequest::BuildSoftBlock()
{
ASSERT(m_pParentBus == NULL);
ASSERT(NumBlocks>1);
ASSERT(pBlockBuffer!=NULL);
BOOL fRetun = TRUE;
UCHAR SoftBlockCommand = CommandCode;
DWORD SoftBlockArgument ;
DWORD SoftwareBlockByteCount = NumBlocks * BlockSize;
DWORD SoftBlockLengthInBytes = min (BlockSize, 1 + SD_CMD53_BLOCK_COUNT);
PBYTE pSoftBlockBuffer = pBlockBuffer;
BOOL fIncreasAddr ;
// Setup Current Transfer
DWORD dwCurOffset = 0 ;
if ( SD_CMD_IO_RW_EXTENDED == SoftBlockCommand ) {
SoftBlockArgument = (CommandArgument & ~( SD_CMD53_BLOCK_MODE | SD_CMD53_BLOCK_COUNT )) ;
SoftBlockArgument |= SoftBlockLengthInBytes ;
fIncreasAddr = ((CommandArgument & SD_CMD53_OPCODE) != 0);
CommandCode = SoftBlockCommand ;
}
else {
// Set the appropriate command.
SoftBlockArgument = CommandArgument;
fIncreasAddr = TRUE;
CommandCode -= 1;
}
// Turn this request into a byte mode request.
NumBlocks = 1;
BlockSize = SoftBlockLengthInBytes;
CommandArgument = SoftBlockArgument ;
pBlockBuffer = pSoftBlockBuffer;
// Update.
if (SoftwareBlockByteCount > SoftBlockLengthInBytes)
SoftwareBlockByteCount -= SoftBlockLengthInBytes;
else
SoftwareBlockByteCount = 0;
pSoftBlockBuffer += SoftBlockLengthInBytes;
if (fIncreasAddr) {
// Increasing address being used.
if ( SD_CMD_IO_RW_EXTENDED == SoftBlockCommand ) {
SoftBlockArgument = ( SoftBlockArgument & ( ~ SD_CMD53_REGISTER_ADDRESS ))
| ((SoftBlockArgument + (SoftBlockLengthInBytes << SD_CMD53_REGISTER_ADDRESS_POS )) & SD_CMD53_REGISTER_ADDRESS );
}
else {
SoftBlockArgument += SoftBlockLengthInBytes;
}
}
while (SoftwareBlockByteCount && fRetun ) {
SD_BUS_REQUEST sdRequest = {
{NULL},m_sdDevice.GetDeviceHandle().hValue,0,
TransferClass,SoftBlockCommand, SoftBlockArgument,
{CommandResponse.ResponseType,{0}},
NULL,
SD_API_STATUS_UNSUCCESSFUL,
1,SoftBlockLengthInBytes,0,
pBlockBuffer,NULL,
0,
Flags
};
CSDBusRequest * pNewRequest = new CSDBusRequest(m_sdDevice, sdRequest, NULL, this );
if (pNewRequest && pNewRequest->Init() ) {
// Added to Child List.
pNewRequest->AddRef();
SetChildListNext(pNewRequest);
// Update.
if (SoftwareBlockByteCount > SoftBlockLengthInBytes)
SoftwareBlockByteCount -= SoftBlockLengthInBytes;
else
SoftwareBlockByteCount = 0;
pSoftBlockBuffer += SoftBlockLengthInBytes;
if (fIncreasAddr) {
// Increasing address being used.
if ( SD_CMD_IO_RW_EXTENDED == SoftBlockCommand ) {
SoftBlockArgument = ( SoftBlockArgument & ( ~ SD_CMD53_REGISTER_ADDRESS ))
| ((SoftBlockArgument + (SoftBlockLengthInBytes << SD_CMD53_REGISTER_ADDRESS_POS )) & SD_CMD53_REGISTER_ADDRESS );
}
else {
SoftBlockArgument += SoftBlockLengthInBytes;
}
}
}
else {
fRetun = FALSE;
if (pNewRequest!=NULL)
delete pNewRequest;
}
}
return fRetun;
}
BOOL CSDBusRequest::BuildOptionalRequest( UCHAR ucSDIOFlags )
{
BOOL fReturn = TRUE;
if (Flags & (SD_AUTO_ISSUE_CMD12 | SD_SDIO_AUTO_IO_ABORT)) {
SD_BUS_REQUEST sdRequest = { // for SD_AUTO_ISSUE_CMD12
{NULL},m_sdDevice.GetDeviceHandle().hValue,0,
SD_COMMAND,
SD_CMD_STOP_TRANSMISSION, 0 ,{ResponseR1b,{0}},
NULL,
SD_API_STATUS_UNSUCCESSFUL,
0,0,0,
NULL,NULL,
0,
0
};
if (Flags & SD_SDIO_AUTO_IO_ABORT) {
DEBUGCHK( m_sdDevice.GetCardInfo().SDIOInformation.Function != 0);
// CMD52
sdRequest.CommandCode = SD_IO_RW_DIRECT;
// set up argument to write the function number to the I/O abort register
sdRequest.CommandArgument = BUILD_IO_RW_DIRECT_ARG(SD_IO_OP_WRITE,
SD_IO_RW_NORMAL,
0, // must be function 0 for access to common regs
SD_IO_REG_IO_ABORT,
m_sdDevice.GetCardInfo().SDIOInformation.Function);
sdRequest.CommandResponse.ResponseType = ResponseR5;
}
CSDBusRequest * pNewRequest = new CSDBusRequest(m_sdDevice, sdRequest, NULL, this );
if (pNewRequest && pNewRequest->Init() ) {
// Added to Child List.
pNewRequest->AddRef();
SetChildListNext(pNewRequest);
}
else {
fReturn = FALSE;
if (pNewRequest)
delete pNewRequest;
}
}
return fReturn;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -