📄 sdcardddk.h
字号:
// SDFreeBusRequest
typedef VOID (*PSD_FREE_BUS_REQUEST) (PSD_BUS_REQUEST);
// SDCardRegistersQuery
typedef SD_API_STATUS (*PSD_CARD_INFO_QUERY) (SD_DEVICE_HANDLE,
SD_INFO_TYPE,
PVOID,
ULONG);
// SDReadWriteRegisterDirect
typedef SD_API_STATUS (*PSD_READ_WRITE_REGISTER_DIRECT)(SD_DEVICE_HANDLE,
SD_IO_TRANSFER_TYPE,
UCHAR,
DWORD,
BOOLEAN,
PUCHAR,
ULONG);
// SDGetTuple
typedef SD_API_STATUS (*PSD_GET_TUPLE)(SD_DEVICE_HANDLE,
UCHAR,
PUCHAR,
PULONG,
BOOL);
// SDIOConnectInterrupt
typedef SD_API_STATUS (*PSD_IO_CONNECT_INTERRUPT) (SD_DEVICE_HANDLE,
PSD_INTERRUPT_CALLBACK);
// SDIODisconnectInterrupt
typedef VOID (*PSD_IO_DISCONNECT_INTERRUPT) (SD_DEVICE_HANDLE);
// SDSetCardFeature
typedef SD_API_STATUS (*PSD_SET_CARD_FEATURE) (SD_DEVICE_HANDLE,
SD_SET_FEATURE_TYPE,
PVOID,
ULONG);
// SD Card Api function structure definition
typedef struct _SDCARD_API_FUNCTIONS {
DWORD dwSize;
PSD_REGISTER_CLIENT pSDRegisterClient;
PSD_SYNCHRONOUS_BUS_REQUEST pSDSynchronousBusRequest;
PSDBUS_REQUEST pSDBusRequest;
PSD_FREE_BUS_REQUEST pSDFreeBusRequest;
PSD_CARD_INFO_QUERY pSDCardInfoQuery;
PSD_READ_WRITE_REGISTER_DIRECT pSDReadWriteRegistersDirect;
PSD_CANCEL_BUS_REQUEST pSDCancelBusRequest;
PSD_GET_TUPLE pSDGetTuple;
PSD_IO_CONNECT_INTERRUPT pSDIOConnectInterrupt;
PSD_IO_DISCONNECT_INTERRUPT pSDIODisconnectInterrupt;
PSD_SET_CARD_FEATURE pSDSetCardFeature;
}SDCARD_API_FUNCTIONS, *PSDCARD_API_FUNCTIONS;
// global variable containing function pointers to SD Card api
extern SDCARD_API_FUNCTIONS g_SDClientApiFunctions;
// debug output function
VOID SDCardDebugOutput(TCHAR *pDebugText, ...);
#ifdef DEBUG
// SDRegisterDebugZones - register a client device
// Input: hDevice - device handle
// pRegPath - pointer to registry path
//
// Output:
// Return:
// Notes:
//
VOID SDRegisterDebugZones(SD_DEVICE_HANDLE hDevice, PTSTR);
#else
#define SDRegisterDebugZones(hDevice, reserved)
#endif // DEBUG
// Sending debug output to a file is no longer supported.
#define SDInitializeOutputToFile(pFileName, MaxFileLength)
#define SDDeinitializeOutputToFile()
#define SDSwitchDebugOutput(OutputToFile)
#define SD_CHECK_OUTPUT_TO_FILE(pPath)
// SDInitializeQueue - initialize a driver allocated request queue
// Input: pQueue - queue to initialize
// Output:
// Return:
// Notes:
//
VOID SDInitializeQueue(PSD_REQUEST_QUEUE pQueue);
// SDQueueBusRequest - queue a request (FIFO order)
// Input: pQueue - queue to use
// pRequest - request to add to queue
// Output:
// Return:
// Notes:
//
VOID SDQueueBusRequest(PSD_REQUEST_QUEUE pQueue, PSD_BUS_REQUEST pRequest);
// SDDequeueBusRequest - de-queue a request (FIFO order)
// Input: pQueue - the queue
// Output:
// Return: the first request queued , otherwise NULL if request queue is empty
// Notes:
//
PSD_BUS_REQUEST SDDequeueBusRequest(PSD_REQUEST_QUEUE pQueue);
// SDGetCurrentRequest - Get the current request at the front of the queue
// but do not remove it from the queue
// Input: pQueue - the queue
// Output:
// Return: the current request that is at the front of the queue (FIFO orer)
// NULL if the queue is empty
// Notes:
//
PSD_BUS_REQUEST SDGetCurrentRequest(PSD_REQUEST_QUEUE pQueue);
// SDRemoveEntryFromQueue - remove an entry from the queue
// Input: pQueue - queue to use
// pRequest - request to be removed
// Output:
// Return:
// Notes:
//
VOID SDRemoveEntryFromQueue(PSD_REQUEST_QUEUE pQueue, PSD_BUS_REQUEST pRequest);
// GetBitSlice - Get a bit slice from a byte buffer
// Input: pBuffer - buffer containing data
// BufferSize - size of buffer in bytes
// BitOffset - bit offset from start of buffer
// NumberOfBits - number of bits (less than or equal to 32)
// Output:
//
// Return: returns a DWORD contain the bit slice shifted to fill the least significant bits
// Notes:
//
DWORD GetBitSlice(PUCHAR pBuffer, ULONG BufferSize, DWORD BitOffset, UCHAR NumberOfBits);
// SDGetDeviceHandle - Get the device handle from the context passed in
// XXX_Init
// Input: InitContext - Context passed in XXX_Init
//
// Output: ppRegPath - registry path of device (optional)
// Return: SD_DEVICE_HANDLE
// Notes:
// returns SD Client Device Handle or NULL on failure
// Caller must free ppRegPath using SDFreeMemory()
//
SD_DEVICE_HANDLE SDGetDeviceHandle(DWORD InitContext, PWCHAR *ppRegPath);
// SDGetCardStatusFromResponse - get the card status from a response
// Input: pCardResponse - the card response
//
// Output:
// Return:
// Notes:
// the response must be of type R1 or R1b
//
#define SDGetCardStatusFromResponse(pCardResponse, pCardStatus) \
memcpy((pCardStatus), &(pCardResponse)->ResponseBuffer[1], sizeof(SD_CARD_STATUS))
// SDRegisterClient - register a client device
// Input: hDevice - device handle
// pDeviceContext - device specific context allocated by driver
// pInfo - registration information
//
// Output:
// Return: SD API Status
// Notes:
//
//
SD_API_STATUS SDRegisterClient(SD_DEVICE_HANDLE hDevice,
PVOID pDeviceContext,
PSDCARD_CLIENT_REGISTRATION_INFO pInfo);
// SDGetRegPathFromInitContext - Get the real device registry path from the context
// passed in XXX_Init
// Input: pActivePath - the active path
// Length - length in bytes of pRegPath
// Output: pRegPath - caller supplied storage for the registry path
//
// Return: SD API Status
// Notes:
// For streams drivers the InitContext passed in the XXX_Init entry point
// is the active registry path and not the real path of the device.
// This function can be used to retrieve the real path.
//
// returns WIN32 Error
//
DWORD SDGetRegPathFromInitContext(PWCHAR pActivePath, PWCHAR pRegPath, ULONG Length);
// SDGetClientFunctions - get the client function table
// Input: pClientFunctions - function table
// Return: SD API Status
//
SD_API_STATUS SDGetClientFunctions(PSDCARD_API_FUNCTIONS pClientFunctions);
// SDSynchronousBusRequest - send an SD Bus request synchronously
// Input: hDevice - device handle
// Command - command to send
// Argument - argument for command
// TransferClass - Command only, or associated with read/write data
// ResponseType - expected response
// NumBlocks - number of blocks
// BlockSize - block size
// pBuffer - block buffer
// Flags - request flags
//
// Output: pResponse - caller allocated storage for the return response
// Return: SD API Status
// Notes:
// This function provides a synchronous (blocking) call to perform a
// bus request. This function should not be called in a bus request callback
// which can be called in a dispatch context. Calling this function
// within a Bus Request callback will result in a deadlock.
//
#define SDSynchronousBusRequest(hDevice, \
Command, \
Argument, \
TransferClass, \
ResponseType, \
pResponse, \
NumBlocks, \
BlockSize, \
pBuffer, \
Flags) \
g_SDClientApiFunctions.pSDSynchronousBusRequest((hDevice),(Command),(Argument),(TransferClass), \
(ResponseType),(pResponse), \
(NumBlocks), (BlockSize), (pBuffer), (Flags))
// SDBusRequest - send command over SD bus
// Input: hDevice - SD device handle
// Command - SD command to send over bus
// Argument - 32 bit argument specific to the command
// TransferClass - Command only, or associated with read/write data
// ResponseType - the response type for the command
// NumBlocks - Number of data blocks in pBlockArray, can be zero
// if transfer class is not read or write
// BlockSize - Size of data blocks in pBlockArray. All blocks
// must be same size.
// pBuffer - Pointer to buffer containing BlockSize*NumBlocks bytes
// pCallback - completion callback
// RequestParam - optional driver specific parameter for this request
// Flags - bus request flags
// Output: pRequest - newly allocated request
// Return: SD API Status
// Notes:
// Must call free request in the completion callback
//
#define SDBusRequest(hDevice, \
Command, \
Argument, \
TransferClass, \
ResponseType, \
NumBlocks, \
BlockSize, \
pBuffer, \
pCallback, \
RequestParam,\
pRequest, \
Flags) \
g_SDClientApiFunctions.pSDBusRequest((hDevice),(Command),(Argument),(TransferClass), \
(ResponseType),(NumBlocks),(BlockSize), \
(pBuffer), (pCallback), (RequestParam), (pRequest), (Flags))
// SDCancelBusRequest - Cancel an outstanding bus request
// Input:
// pRequest - request to cancel,(returned from SDBusRequest)
// Output:
// Return: TRUE if request was cancelled , FALSE if the request is still pending
// Notes:
//
#define SDCancelBusRequest(pRequest) g_SDClientApiFunctions.pSDCancelBusRequest((pRequest))
// SDFreeBusRequest - free a bus request
// Input: pRequest
// Output:
// Return:
// Notes:
// this function should be called when the request has completed,
// typically in the completion callback
//
#define SDFreeBusRequest(pRequest) g_SDClientApiFunctions.pSDFreeBusRequest((pRequest))
// SDCardInfoQuery - Obtain Card information
// Input: hDevice - SD Device Handle
// InfoType - information to get
// StructureSize - size of info structure
// Output: pCardInfo - Information specific structure
// Return: SD_API_STATUS code
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -