?? sdhcslot.h
字號:
inline DWORD ReadDword (DWORD dwOffset) {
return ReadReg<DWORD>(dwOffset);
}
inline VOID WriteDword(DWORD dwOffset, DWORD dwValue) {
WriteReg(dwOffset, dwValue);
}
// Interrupt handling methods
virtual VOID HandleRemoval(BOOL fCancelRequest);
virtual VOID HandleInsertion();
virtual BOOL HandleCommandComplete();
virtual VOID HandleErrors();
virtual VOID HandleTransferDone();
virtual VOID HandleReadReady();
virtual VOID HandleWriteReady();
virtual PVOID SlotAllocDMABuffer(ULONG Length,PPHYSICAL_ADDRESS LogicalAddress,BOOLEAN CacheEnabled );
virtual BOOL SlotFreeDMABuffer( ULONG Length,PHYSICAL_ADDRESS LogicalAddress,PVOID VirtualAddr,BOOLEAN CacheEnabled );
// Allocates a physical buffer for DMA.
virtual PVOID AllocPhysBuffer(size_t cb, PDWORD pdwPhysAddr);
// Frees the physical buffer.
virtual VOID FreePhysBuffer(PVOID pv);
// Place the slot into the desired power state.
virtual VOID SetHardwarePowerState(CEDEVICE_POWER_STATE cpsNew);
// Performs the actual enabling/disabling of SDIO card interrupts.
virtual VOID DoEnableSDIOInterrupts(BOOL fEnable);
// Perform the desired reset and wait for completion. Returns FALSE
// if there is a timeout.
virtual BOOL SoftwareReset(BYTE bResetBits);
// Keep reading the register using (*pfnReadReg)(dwRegOffset) until
// value & tMask == tWaitForEqual.
template<class T>
BOOL WaitForReg(
T (CSDHCSlotBase::*pfnReadReg)(DWORD),
DWORD dwRegOffset,
T tMask,
T tWaitForEqual,
DWORD dwTimeout = 1000
);
// Turn the LED on or off.
virtual VOID EnableLED(BOOL fEnable);
// Calls SDHCDIndicateSlotStateChange.
virtual VOID IndicateSlotStateChange(SD_SLOT_EVENT sdEvent);
// Calls SDHCDGetAndLockCurrentRequest.
virtual PSD_BUS_REQUEST GetAndLockCurrentRequest();
// Calls SDHCDPowerUpDown.
virtual VOID PowerUpDown(BOOL fPowerUp, BOOL fKeepPower);
// Calls SDHCDIndicateBusRequestComplete.
virtual VOID IndicateBusRequestComplete(PSD_BUS_REQUEST pRequest, SD_API_STATUS status);
// Finds the closest rate that is *pdwRate or lower. Stores the
// actual rate in *pdwRate.
virtual VOID SetClockRate(PDWORD pdwRate);
// Turn on the SD clock according to the clock divisor found
// in SetClockRate().
virtual VOID SDClockOn();
// Turn off the SD clock.
virtual VOID SDClockOff();
// Determine the Vdd windows from the capabilities register.
virtual DWORD DetermineVddWindows();
// Set an interrupt event.
virtual VOID SetInterruptEvent() { ::SetInterruptEvent(m_dwSysIntr); }
virtual BOOL DetermineCommandPolling();
virtual BOOL PollingForCommandComplete();
#ifdef DEBUG
// Print out the standard host register set.
virtual VOID DumpRegisters();
// Validate the member data.
virtual VOID Validate();
// Verify that the desired register accesses are properly aligned.
VOID CheckRegOffset(DWORD dwOffset, DWORD dwRegSize) {
DEBUGCHK( (dwOffset % dwRegSize) == 0);
DEBUGCHK(dwOffset < sizeof(SSDHC_REGISTERS));
DEBUGCHK( (dwOffset + dwRegSize) <= sizeof(SSDHC_REGISTERS));
}
#else
// These routines do nothing in non-debug builds.
inline VOID DumpRegisters() {}
inline VOID Validate() {}
inline VOID CheckRegOffset(DWORD dwOffset, DWORD dwRegSize) {}
#endif
#ifdef _SMDK6410_CH0_EXTCD_
// Prototype for a new function can detect whether card is presented of HSMMC ch0 on SMRP6400.
virtual BOOL IsCardPresent();
#endif
CReg *m_pregDevice; // pointer to device registry key
CSDHCSlotBaseDMA *m_SlotDma; // DMA object
DWORD m_dwSlot; // physical slot number
volatile BYTE *m_pbRegisters; // memory-mapped registers
PSDCARD_HC_CONTEXT m_pHCDContext; // host context
DWORD m_dwSysIntr; // system interrupt
HANDLE m_hBusAccess; // bus parent
INTERFACE_TYPE m_interfaceType; // interface of the controller
DWORD m_dwBusNumber; // bus number of the controller
DWORD m_dwVddWindows; // supported VDD windows
DWORD m_dwMaxClockRate; // maximum clock rate
DWORD m_dwTimeoutControl; // timeout control value
DWORD m_dwMaxBlockLen; // maximum block length
WORD m_wRegClockControl; // register value of Clock Control
WORD m_wIntSignals; // saved int signals for powerup
CEDEVICE_POWER_STATE m_cpsCurrent; // current power state
CEDEVICE_POWER_STATE m_cpsAtPowerDown; // power state at PowerDown()
BOOL m_isSDIOInterrupt;
DWORD m_dwDefaultWakeupControl; // wakeup source list
BYTE m_bWakeupControl; // current wakeup interrupts
#ifdef DEBUG
DWORD m_dwReadyInts; // number of Read/WriteReady interrupts that have occurred
#endif DEBUG
BOOL m_fCommandCompleteOccurred; // has the Command Complete occurred for the current transfer?
PSD_BUS_REQUEST m_pCurrentRequest; // Current Processing Request.
BOOL m_fCurrentRequestFastPath;
SD_API_STATUS m_FastPathStatus;
DWORD m_dwFastPathTimeoutTicks;
DWORD m_dwPollingModeSize;
BOOL m_fSleepsWithPower : 1; // keep power in PowerDown()?
BOOL m_fPowerUpDisabledInts : 1; // did PowerUp disable SDIO card interrupts?
BOOL m_fIsPowerManaged : 1; // is the power manager handling us?
BOOL m_fSDIOInterruptsEnabled : 1; // are SDIO card interrupts enabled?
BOOL m_fCardPresent : 1; // is a card present
BOOL m_fAutoCMD12Success : 1; // AutoCMD12 success
BOOL m_fCheckSlot : 1; // does HandleInterrupt() need to be run?
BOOL m_fCanWakeOnSDIOInterrupts : 1; // can wake on SDIO interrupts
BOOL m_f4BitMode : 1; // 4 bit bus mode?
BOOL m_fFakeCardRemoval : 1; // should we simulate card removal?
BOOL m_fCommandPolling: 1;
BOOL m_fDisableDMA:1; // Disable The DMA
} *PCSDHCSlotBase;
#define CB_DMA_BUFFER 0x20000 // 128KB buffer
#define CB_DMA_PAGE 0x1000 // we program DMA for 4KB pages
#define TRANSFER_IS_WRITE(pRequest) (SD_WRITE == (pRequest)->TransferClass)
#define TRANSFER_IS_READ(pRequest) (SD_READ == (pRequest)->TransferClass)
#define TRANSFER_IS_COMMAND_ONLY(pRequest) (SD_COMMAND == (pRequest)->TransferClass)
#define TRANSFER_SIZE(pRequest) ((pRequest)->BlockSize * (pRequest)->NumBlocks)
#define SDHC_DEFAULT_TIMEOUT 2000 // 2 seconds
// Is this request an SDIO abort (CMD52, Function 0, I/O Abort Reg)?
inline
BOOL
TransferIsSDIOAbort(
PSD_BUS_REQUEST pRequest
)
{
PREFAST_DEBUGCHK(pRequest);
BOOL fRet = FALSE;
if (pRequest->CommandCode == SD_CMD_IO_RW_DIRECT) {
if (IO_RW_DIRECT_ARG_FUNC(pRequest->CommandArgument) == 0) {
if (IO_RW_DIRECT_ARG_ADDR(pRequest->CommandArgument) == SD_IO_REG_IO_ABORT) {
fRet = TRUE;
}
}
}
return fRet;
}
#endif // _SDHCSLOT_DEFINED
// DO NOT REMOVE --- END EXTERNALLY DEVELOPED SOURCE CODE ID --- DO NOT REMOVE
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -