From: iwub on
Thanks,I send CMD52 seems correct.
but the CMD53 may wrong although return OK.
because my Ready Register is not OK.(use it to specify my FW is download and
run ok now.)

What wrong will it be ?

THX


//Submit Request Device Command
{//1.3 start
PSDBUS_REQUEST_PACKET sdrp =NULL;
PMDL mdl = NULL;
SD_RW_EXTENDED_ARGUMENT sdIoArgument;
//SD_RW_DIRECT_ARGUMENT sdIoArgument;
int len_help;
const SDCMD_DESCRIPTOR IoExtendedDesc1 = {
SDCMD_IO_RW_EXTENDED,//SD_COMMAND_CODE Cmd
SDCC_STANDARD, //SD_COMMAND_CLASS CmdClass
SDTD_READ, //SD_TRANSFER_DIRECTION TransferDirection
SDTT_SINGLE_BLOCK, //SD_TRANSFER_TYPE TransferType
SDRT_1 }; //SD_RESPONSE_TYPE ResponseType
const SDCMD_DESCRIPTOR IoExtendedDesc2 = {
SDCMD_IO_RW_EXTENDED,//SD_COMMAND_CODE Cmd
SDCC_STANDARD, //SD_COMMAND_CLASS CmdClass
SDTD_WRITE, //SD_TRANSFER_DIRECTION TransferDirection
SDTT_SINGLE_BLOCK, //SD_TRANSFER_TYPE TransferType
SDRT_1 }; //SD_RESPONSE_TYPE ResponseType

//if(rw) //if write
// IoDirectDesc.TransferDirection=SDTD_WRITE;
//lblk/=2;
sdrp = ExAllocatePool(NonPagedPool,sizeof(SDBUS_REQUEST_PACKET));
if(!sdrp)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlZeroMemory(sdrp,sizeof(SDBUS_REQUEST_PACKET));
//while(nblk--) {

len_help = lblk*nblk;//sizeof(helper_image);
mdl = IoAllocateMdl(buf,len_help,FALSE,FALSE,NULL);
//UCHAR Data[64];
if(mdl == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}


//ULONG Length=24,Offset=12;
MmBuildMdlForNonPagedPool(mdl);

sdrp->RequestFunction = SDRF_DEVICE_COMMAND;
//NdisMoveMemory(&(sdrp->Parameters.DeviceCommand.CmdDesc),&IoDirectDesc,sizeof(SDCMD_DESCRIPTOR));
if(rw)
sdrp->Parameters.DeviceCommand.CmdDesc = IoExtendedDesc2;
else
sdrp->Parameters.DeviceCommand.CmdDesc = IoExtendedDesc1;
sdIoArgument.u.AsULONG = 0;
sdIoArgument.u.bits.Count = nblk;//1; //1 block read or write
sdIoArgument.u.bits.Address = addr; //
sdIoArgument.u.bits.OpCode = op;//0;
sdIoArgument.u.bits.BlockMode = blk;//1; //block one time
sdIoArgument.u.bits.Function =
fn;//Adapter->FunctionNumber;//FuncNum;//pDevExt->FunctionNumber;
sdIoArgument.u.bits.WriteToDevice = rw;
sdrp->Parameters.DeviceCommand.Argument = sdIoArgument.u.AsULONG;
sdrp->Parameters.DeviceCommand.Mdl = mdl;
sdrp->Parameters.DeviceCommand.Length = lblk;//len_help;//

Status = SdBusSubmitRequest(Adapter->SdBusIfStd.Context,sdrp);
//Status = SdBusSubmitRequestAsync(Adapter->SdBusIfStd.Context,sdrp,);
//Status = SdioSendIrp(Adapter, IOCTL_SD_SUBMIT_REQUEST, sdrp,
sizeof(SDBUS_REQUEST_PACKET), buf, lblk*nblk);
if(NT_SUCCESS(Status)) {
KdPrint(("SdioCommand53:SdBusSubmitRequest() 3 success
sdrp->ResponseLength = %x\n",sdrp->ResponseLength));
/*
if ((sdrp->ResponseData.AsUCHAR[2] & (SDIO_RESPONSE_ERROR_MASK>>8))
== 0)
{
KdPrint(("sdrp->ResponseData.AsUCHAR = %x %x %x %x \n",
sdrp->ResponseData.AsUCHAR[0],
sdrp->ResponseData.AsUCHAR[1],
sdrp->ResponseData.AsUCHAR[2],
sdrp->ResponseData.AsUCHAR[3]));
}*/
KdPrint(("SdBusSubmitRequest() 3 success addr = %x\n",addr));
//*Data = sdrp->ResponseData.AsUCHAR[0];
//return Status;
}
else
KdPrint(("SdBusSubmitRequest() 3 failed\n"));


IoFreeMdl(mdl);
//buf+=lblk;

//addr+=lblk;
//}//while
ExFreePool(sdrp);

}//1.3 end