locked
DeviceIoControl on ATA_PASS_THROUGH_DIRECT retrun error code 87 (invalid parameter) only when transfer size larger than 512*256 bytes RRS feed

  • Question

  • You cannot vote on your own post

    Hi,

    DeviceIoControl on ATA_PASS_THROUGH_DIRECT retrun error code 87 (invalid parameter) only when transfer size larger than 512*256 bytes. Would you please help me to sort it out. The source code and the value before call DeviceIoControl are listed in following.

    Thank you.

    C Xie

    #############################################

    The following code is to send a SATA download microcode into a hard disk.

    ###########################################

        ATA_PASS_THROUGH_DIRECT* PTE = new ATA_PASS_THROUGH_DIRECT ;
        memset(PTE, 0, sizeof(ATA_PASS_THROUGH_DIRECT) );
        PTE->Length = sizeof(ATA_PASS_THROUGH_DIRECT);
        PTE->AtaFlags = 0;
        PTE->AtaFlags |= ATA_FLAGS_DRDY_REQUIRED ;
        PTE->AtaFlags |= cmd->isread() ? ATA_FLAGS_DATA_IN : ATA_FLAGS_DATA_OUT ;
        PTE->AtaFlags |= cmd->is48bit() ? ATA_FLAGS_48BIT_COMMAND : 0;
        PTE->AtaFlags |= cmd->isDMA() ? ATA_FLAGS_USE_DMA : 0;
        PTE->DataTransferLength = cmd->getbuffersize(); //only return error on this value is larger than 512*256
        PTE->TimeOutValue = 10;
        PTE->DataBuffer = cmd->getbuffer();
        PTE->CurrentTaskFile[0] = cmd->getfeaturesbyte(false);
        PTE->CurrentTaskFile[1] = cmd->getnumsectorsbyte(false);
        PTE->CurrentTaskFile[2] = cmd->getLBAbyte(0,false);
        PTE->CurrentTaskFile[3] = cmd->getLBAbyte(1,false);
        PTE->CurrentTaskFile[4] = cmd->getLBAbyte(2,false);
        PTE->CurrentTaskFile[5] = cmd->getLBAbyte(3,false);
        PTE->CurrentTaskFile[5] |= cmd->getdevice();
        PTE->CurrentTaskFile[6] = cmd->getcommand();
        PTE->PreviousTaskFile[0] = cmd->getfeaturesbyte(true);
        PTE->PreviousTaskFile[1] = cmd->getnumsectorsbyte(true);
        PTE->PreviousTaskFile[2] = cmd->getLBAbyte(0,true);
        PTE->PreviousTaskFile[3] = cmd->getLBAbyte(1,true);
        PTE->PreviousTaskFile[4] = cmd->getLBAbyte(2,true);
        PTE->PreviousTaskFile[5] = 0;
        PTE->PreviousTaskFile[6] = cmd->getcontrol(); // control ?
        PTE->PreviousTaskFile[7] = 0;

        DWORD BR;
        int ret = DeviceIoControl(
            _handle,
            IOCTL_ATA_PASS_THROUGH_DIRECT,
            PTE,
            sizeof(ATA_PASS_THROUGH_DIRECT),
            PTE,
            sizeof(ATA_PASS_THROUGH_DIRECT),
            &BR,
            0);
      
            if (!ret)       DWORD   dwLastError = GetLastError();

    ##########################################

    The PTE value before call DeviceIoControl

    #########################################

    -        PTE    0x05CD1AA8 { Length=40 AtaFlags=5 PathId=0 '' ...}    _ATA_PASS_THROUGH_DIRECT*
            AtaFlags    5    unsigned short
    -        CurrentTaskFile    {Length=8}    unsigned char[]
            [0]    7 ''    unsigned char
            [1]    13 '
    '    unsigned char
            [2]    1 ''    unsigned char
            [3]    0 ''    unsigned char
            [4]    0 ''    unsigned char
            [5]    0 ''    unsigned char
            [6]    146 '’'    unsigned char
            [7]    0 ''    unsigned char
            DataBuffer    0x05CB0068    void*
            DataTransferLength    137728    unsigned int   //only return error on this value is larger than 512*256
            Length    40    unsigned short
            Lun    0 ''    unsigned char
            PathId    0 ''    unsigned char
    -        PreviousTaskFile    {Length=8}    unsigned char[]
            [0]    0 ''    unsigned char
            [1]    0 ''    unsigned char
            [2]    0 ''    unsigned char
            [3]    0 ''    unsigned char
            [4]    0 ''    unsigned char
            [5]    0 ''    unsigned char
            [6]    0 ''    unsigned char
            [7]    0 ''    unsigned char
            ReservedAsUchar    0 ''    unsigned char
            ReservedAsUlong    0    unsigned int
            TargetId    0 ''    unsigned char
            TimeOutValue    10    unsigned int
    Wednesday, August 8, 2012 2:53 PM

Answers

All replies

  • Hi CWXie,

    Based on your description, I’m afraid that it is not the correct forum, since this forum is to discuss the VS debugger tool.

    Would you mind letting us know more information about your issue? Which tool are you using? Are you debugging an app in VS? Maybe you could provide more information, so we could provide the correct forum for this issue.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Friday, August 10, 2012 2:26 AM
  • Hi Jack Zhai,

    I am using MS Visual Studio 2010 Professional to write the code and debug. My application program is to download the microcode into a SATA device by using SATA download microcode comand and the subcommand 0x07.

    Best regards,

    Changwen Xie

    Monday, August 13, 2012 1:03 PM
  • Hi CWXie,

    Since this forum is to discuss Visual Studio debugger tool. Based on your description, it seems that this issue is related to your specific app. I’m still not very sure which kind of app you are developing and which language you are using, but I suggest you post this issue in the correct development forum.

    It seems that you have posted this issue in the SDK forum here. I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum. Thanks for your understanding.

    Sincerely,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, August 14, 2012 2:51 AM
  • Hi Jack Zhai,

    My program is in C++. My question is why the DeviceIoControl return an invalid parameter error message only at the conditions of the buffer size is larger than 512*256, no matter what kind of the application it is. From the following message you will see where the DeviceIoControl comes from. Please let me know which forum is the right forum.

    Thank you.

    CW Xie

    Tuesday, August 14, 2012 7:55 AM
  • Try asking in the VC++ forum on MSDN.

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Experience Program Manager (Blog, Twitter, Wiki)

    Monday, August 20, 2012 6:48 AM