📄 sdcardio.cpp
字号:
case SD_IS_FAST_PATH_AVAILABLE:
status = SD_API_STATUS_SUCCESS;
break;
case SD_FAST_PATH_DISABLE:
// Disable the use of Fast-Path for testing.
pDevice->SDCardInfo.SDIOInformation.Flags |= FSTPTH_DISABLE;
status = SD_API_STATUS_SUCCESS;
break;
case SD_FAST_PATH_ENABLE:
// Always use Fast-Path operations.
pDevice->SDCardInfo.SDIOInformation.Flags &= ~ FSTPTH_DISABLE;
status = SD_API_STATUS_SUCCESS;
break;
case SD_IS_SOFT_BLOCK_AVAILABLE:
status = SD_API_STATUS_SUCCESS;
break;
case SD_SOFT_BLOCK_FORCE_UTILIZATION:
// Always use Soft-Block operations.
pDevice->SDCardInfo.SDIOInformation.Flags |= SFTBLK_USE_ALWAYS;
status = SD_API_STATUS_SUCCESS;
break;
case SD_SOFT_BLOCK_DEFAULT_UTILIZATON:
// Use hardware multi-block operations if supported by the card,
// otherwise use Soft-Block.
pDevice->SDCardInfo.SDIOInformation.Flags &= ~ SFTBLK_USE_ALWAYS;
status = SD_API_STATUS_SUCCESS;
break;
case SD_SET_CARD_INTERFACE: {
if ((sizeof(SD_CARD_INTERFACE) != StructureSize) ||
(NULL == pCardInfo)) {
DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDSetCardFeature: SD_SET_CARD_INTERFACE - Invalid params \n")));
return SD_API_STATUS_INVALID_PARAMETER;
}
PSD_CARD_INTERFACE pCardInterface = (PSD_CARD_INTERFACE) pCardInfo;
// Check if the slot can accept this interface request
// For multifunction card or combo card, the requested interface may not be fitted
// for other functions.
{
PSDCARD_DEVICE_CONTEXT pCurrentDevice;
BOOL bAllFunctionsAcceptThisInterface;
bAllFunctionsAcceptThisInterface = TRUE;
// Start from parent device
pCurrentDevice = SDDCGetClientDeviceFromHandle(pDevice->pSlot->hDevice);
while (pCurrentDevice != NULL) {
// Check if current device supports 4 bit mode request
if ((pCardInterface->InterfaceMode == SD_INTERFACE_SD_4BIT) &&
(pCurrentDevice->CardInterface.InterfaceMode == SD_INTERFACE_SD_MMC_1BIT)) {
bAllFunctionsAcceptThisInterface = FALSE;
break;
}
// Check if request clock rate is too high for this device
if (pCardInterface->ClockRate > pCurrentDevice->CardInterface.ClockRate) {
bAllFunctionsAcceptThisInterface = FALSE;
break;
}
// Get the next device from the list.
pCurrentDevice = pCurrentDevice->pNext;
}
if (bAllFunctionsAcceptThisInterface == FALSE) {
DbgPrintZo(SDCARD_ZONE_ERROR,
(TEXT("SDSetCardFeature: SD_SET_CARD_INTERFACE - invalod interface request\n")));
return SD_API_STATUS_INVALID_DEVICE_REQUEST;
}
}
// Changing the bus width is tricky when SDIO interrupts are
// enabled. In 1-bit mode, DAT[1] is used as the interrupt line.
// In 4-bit mode, DAT[1] is used for data and interrupts. If
// we change from 1-bit mode to 4-bit mode while interrupts are
// occurring (like when a BTH mouse is being moved franticly), we
// need to disable SDIO interrupts while we are changing the mode
// on both the host controller and the card. Otherwise an interrupt in
// the middle could confuse the host controller.
// Acquire lock so that we are not interrupted.
SDAcquireDeviceLock(pDevice->pParentDevice);
PSD_INTERRUPT_CALLBACK pInterruptCallBack = NULL;
if ( (Device_SD_IO == pDevice->DeviceType) &&
IS_SLOT_SDIO_INTERRUPT_ON(pDevice->pSlot) &&
(pDevice->CardInterface.InterfaceMode != pCardInterface->InterfaceMode) ) {
// Temporarily disable SDIO interrupts
pInterruptCallBack = pDevice->SDCardInfo.SDIOInformation.pInterruptCallBack;
DEBUGCHK(pInterruptCallBack);
SDIOConnectDisconnectInterrupt(hDevice, NULL, FALSE);
}
// set the card interface for device's slot
status = pDevice->pSlot->pHostController->pSlotOptionHandler(pDevice->pSlot->pHostController,
pDevice->pSlot->SlotIndex,
SDHCDSetSlotInterface,
pCardInterface,
sizeof(*pCardInterface));
// check for success
if (SD_API_SUCCESS(status)) {
PSDCARD_DEVICE_CONTEXT pCurrentDevice;
// now set the interface in the card, this issues bus commands
// start with the parent device
pCurrentDevice = SDDCGetClientDeviceFromHandle(pDevice->pSlot->hDevice);
// for each device set it's card interface
while (pCurrentDevice != NULL) {
// set the card interface as slot interface
status = SetCardInterface(pCurrentDevice, pCardInterface);
if (!SD_API_SUCCESS(status)) {
return status;
}
pCurrentDevice = pCurrentDevice->pNext;
}
// check status
if (SD_API_SUCCESS(status)) {
// update the slot interface information, keep write protect
// intact
pDevice->pSlot->SlotInterface.InterfaceMode = pCardInterface->InterfaceMode;
pDevice->pSlot->SlotInterface.ClockRate = pCardInterface->ClockRate;
}
}
if (pInterruptCallBack) {
// Re-enable SDIO interrupts
DEBUGCHK(!IS_SLOT_SDIO_INTERRUPT_ON(pDevice->pSlot));
DEBUGCHK(Device_SD_IO == pDevice->DeviceType);
SDIOConnectDisconnectInterrupt(hDevice, pInterruptCallBack, TRUE);
}
SDReleaseDeviceLock(pDevice->pParentDevice);
break;
}
case SD_SET_CLOCK_STATE_DURING_IDLE:
if ( (sizeof(BOOL) != StructureSize) || (NULL == pCardInfo) ) {
DEBUGMSG(SDCARD_ZONE_ERROR,
(TEXT("SDSetCardFeature: SD_SET_CLOCK_ON_DURING_IDLE - Invalid params \n")));
return SD_API_STATUS_INVALID_PARAMETER;
}
// prompt the host to turn on or off the clock during the idle state based on the client's
// request.
status = pDevice->pSlot->pHostController->pSlotOptionHandler(
pDevice->pSlot->pHostController,
pDevice->pSlot->SlotIndex,
SDHCDSetClockStateDuringIdle,
pCardInfo,
StructureSize);
DEBUGMSG(SDCARD_ZONE_INFO,
(TEXT("SDSetCardFeature: SDHCDSetClockStateDuringIdle finished with status: %x\n"),
status));
break;
#ifdef ENABLE_SDIO_V1_1_SUPPORT
case SD_CARD_FORCE_RESET:
{
CSDBusDriver *pBusDriver;
SD_SLOT_EVENT SlotEvent;
DbgPrintZo(SDCARD_ZONE_INIT,
(TEXT("SDSetCardFeature: call SD_CARD_FORCE_RESET \n")));
// Post Slot Event
pBusDriver = SDDCGetBusDriver(pDevice);
SlotEvent = SlotResetRequest;
pBusDriver->PostSlotEvent(SlotEvent, pDevice->pSlot, (CSDWorkItem *)pDevice->pSlot->pWorkItem);
}
break;
case SD_CARD_SELECT_REQUEST:
// request made by client driver to select the card. The request will not be honored
// until all client drivers in this slot make such request.
{
PSDCARD_DEVICE_CONTEXT pCurrentDevice;
BOOL bAllFunctionsRequestedCardSelect;
CSDBusDriver *pBusDriver;
SD_SLOT_EVENT SlotEvent;
DbgPrintZo(SDCARD_ZONE_INIT,
(TEXT("SDSetCardFeature: call SD_CARD_SELECT_REQUEST \n")));
bAllFunctionsRequestedCardSelect = TRUE;
// Set this device's bCardSelectRequest flag as true
pDevice->bCardSelectRequest = TRUE;
// Start from parent device
pCurrentDevice = SDDCGetClientDeviceFromHandle(pDevice->pSlot->hDevice);
while (pCurrentDevice != NULL) {
if (pCurrentDevice->bCardSelectRequest == FALSE) {
// Notify other clients driver
NotifyClient(pCurrentDevice, SDCardSelectRequest);
bAllFunctionsRequestedCardSelect = FALSE;
}
pCurrentDevice = pCurrentDevice->pNext;
}
if (bAllFunctionsRequestedCardSelect == FALSE) {
DbgPrintZo(SDCARD_ZONE_INFO,
(TEXT("SDSetCardFeature: SD_CARD_SELECT_REQUEST - request is pending\n")));
return SD_API_STATUS_PENDING;
}
DbgPrintZo(SDCARD_ZONE_INIT,
(TEXT("SDSetCardFeature: SD_CARD_SELECT_REQUEST - request is processing\n")));
// Post Slot Event
pBusDriver = SDDCGetBusDriver(pDevice);
SlotEvent = SlotSelectRequest;
pBusDriver->PostSlotEvent(SlotEvent, pDevice->pSlot, (CSDWorkItem *)pDevice->pSlot->pWorkItem);
}
break;
case SD_CARD_DESELECT_REQUEST:
{
PSDCARD_DEVICE_CONTEXT pCurrentDevice;
BOOL bAllFunctionsRequestedCardDeselect;
CSDBusDriver *pBusDriver;
SD_SLOT_EVENT SlotEvent;
DbgPrintZo(SDCARD_ZONE_INIT,
(TEXT("SDSetCardFeature: call SD_CARD_DESELECT_REQUEST \n")));
bAllFunctionsRequestedCardDeselect = TRUE;
// Set this device's bCardSelectRequest flag as true
pDevice->bCardDeselectRequest = TRUE;
// Start from parent device
pCurrentDevice = SDDCGetClientDeviceFromHandle(pDevice->pSlot->hDevice);
while (pCurrentDevice != NULL) {
if (pCurrentDevice->bCardDeselectRequest == FALSE) {
// Notify other clients driver
NotifyClient(pCurrentDevice, SDCardDeselectRequest);
bAllFunctionsRequestedCardDeselect = FALSE;
break;
}
pCurrentDevice = pCurrentDevice->pNext;
}
if (bAllFunctionsRequestedCardDeselect == FALSE) {
DbgPrintZo(SDCARD_ZONE_INFO,
(TEXT("SDSetCardFeature: SD_CARD_DESELECT_REQUEST - request is pending\n")));
return SD_API_STATUS_PENDING;
}
DbgPrintZo(SDCARD_ZONE_INIT,
(TEXT("SDSetCardFeature: SD_CARD_DESELECT_REQUEST - request is processing\n")));
// Post Slot Event
pBusDriver = SDDCGetBusDriver(pDevice);
SlotEvent = SlotDeselectRequest;
pBusDriver->PostSlotEvent(SlotEvent, pDevice->pSlot, (CSDWorkItem *)pDevice->pSlot->pWorkItem);
}
break;
#endif //ENABLE_SDIO_V1_1_SUPPORT
default:
status = SD_API_STATUS_INVALID_PARAMETER;
}
return status;
}
// DO NOT REMOVE --- END EXTERNALLY DEVELOPED SOURCE CODE ID --- DO NOT REMOVE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -