Which is the variable, which gets the read data in CMD53 in byte mode ?

E

esha

Hi,

I have the SDIO client driver up and runningoon XP. I can do the CMD 52
read and write properly. Now, i'm trying the CMD53 (read extended). In
this, first i'm trying the byte mode (SDTT_CMD_ONLY) and not the block
mode. But I dont know where do i get the response data. The DDK does
not document it properly ? Will the Mdl be used in case of byte mode
also ? Or is it similar to CMD52 where the read value will be in
sdrp->ResponseData.AsUCHAR[0] ?? What will be there in sdrp.Information
??? (The SDIO status ?)

I tried both SDRT_1 and SDRT_5 but got the same result...
I'm trying to read the 0x07 offset of CCCR register which indicates the
bus width which should be 0x2 in my case. I'm able to read this proplery
using CMD52 but then when i use the CMD53 in byte mode i'm getting 0 in
AsUCHAR[0]... what could be wrong ?

I have attached my function here
----------------------------------------------------------
NTSTATUS SdioReadWriteBuffer(PDEVICE_OBJECT fdo, IN ULONG Function, IN
PUCHAR PBuffer,IN ULONG Address,IN UCHAR BlockMode,IN ULONG Length,IN
BOOLEAN WriteToDevice,OUT PULONG BytesRead )
/*++
This takes care of reading or writing to SDIO device using CMD53
--*/
{
PFDO_DATA fdoData;
SDBUS_REQUEST_PACKET sdrp;
SD_RW_EXTENDED_ARGUMENT extendedArgument;
NTSTATUS status;
PMDL Mdl=NULL;

const SDCMD_DESCRIPTOR ReadIoExtendedDesc =
{SDCMD_IO_RW_EXTENDED, SDCC_STANDARD, SDTD_READ,
SDTT_CMD_ONLY, SDRT_1};
const SDCMD_DESCRIPTOR WriteIoExtendedDesc =
{SDCMD_IO_RW_EXTENDED, SDCC_STANDARD, SDTD_WRITE,
SDTT_CMD_ONLY, SDRT_1};

//PAGED_CODE();
fdoData = (PFDO_DATA)fdo->DeviceExtension;
RtlZeroMemory(&sdrp, sizeof(SDBUS_REQUEST_PACKET));
// first, get an MDL to map the data. Call IoAllocateMdl to
// allocate an MDL and pass in a pointer to a buffer
// allocated from the non-paged pool.

Mdl = IoAllocateMdl(PBuffer, Length, FALSE, FALSE, NULL);
if (Mdl == NULL) {
return STATUS_INSUFFICIENT_RESOURCES;
}
MmBuildMdlForNonPagedPool (Mdl);
sdrp.RequestFunction = SDRF_DEVICE_COMMAND;
sdrp.Parameters.DeviceCommand.Mdl = Mdl;
extendedArgument.u.AsULONG = 0;
extendedArgument.u.bits.Function = Function;
extendedArgument.u.bits.OpCode = 0;
extendedArgument.u.bits.BlockMode = 0;
extendedArgument.u.bits.Address = Address;

if((fdoData->SdioGlobals.ioctlData.requestMode == BLOCK_MODE) &&
(fdoData->BlockMode == 0))
{
SdioDbgPrint(TRACE,"\nSdioReadWriteBuffer: Block Mode
not supported by the device\n");
//Device does not support the block mode - return error
//since this is the dianostics driver all to send any block
mode.
//return STATUS_INVALID_DEVICE_REQUEST;
}
if (WriteToDevice) {
extendedArgument.u.bits.WriteToDevice = 1;
sdrp.Parameters.DeviceCommand.CmdDesc =
WriteIoExtendedDesc;
} else {
sdrp.Parameters.DeviceCommand.CmdDesc =
ReadIoExtendedDesc;
}

sdrp.Parameters.DeviceCommand.Argument =
extendedArgument.u.AsULONG;
sdrp.Parameters.DeviceCommand.Length = Length;

//
// Send the IO request down to the bus driver
//

status =
SdBusSubmitRequest(fdoData->SDBusInterface.Context, &sdrp);
*BytesRead = (ULONG)sdrp.Information;

if (NT_SUCCESS(status) && !WriteToDevice) {
DbgPrint("\nReadExtended: Uchar0 0x%X\n",
sdrp.ResponseData.AsUCHAR[0]);
//*Data = sdrp.ResponseData.AsUCHAR[0];
SdioDbgPrint(TRACE,"\nReadEx: Byte in the buff
0x%X\n",*PBuffer);

}
SdioDbgPrint(TRACE,"\nSdioReadWriteBuffer: BytesRead
%d\n",*BytesRead);
IoFreeMdl(mdl);
return status;

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top