Help !!! Problem IOCTL_ATA_PASS_THROUGH 48 bits COMMAND

Hi,

I’m trying to issue a vendor specific ATA command to a custom device via ATA_FLAGS_48BIT_COMMAND. However, i couldn’t find any proper dpcumentation on the usage of PreviousTaskFile and CurrentTaskFIle in the ATA_PASSTHROUGH_EX structure. Does anyone have any clues on this? Or any working examples that issue such 48-bit commands?

This is because i kept encountered incorrect parameters error (Status code : 0x57). I suspect it’s the way i craft the ATA_PASSTHROUGH_EX structure especially the PreviousTaskFIle.

The PreviousTaskFile should be initialized to the values that should be written first, and the CurrentTaskFile be initialized to the values written behind the first.

If it’s not working when initialized that way, then you may have something else going wrong, or you may have bumped into a bug in the implementation. If your vendor-specific command is PIO, you should probably add the ATA_FLAGS_NO_MULTIPLE. It’s a bit mis-documented, because when it was introduced, it meant “One sector per DRQ”. I assume it still means that, but I haven’t used the APTI in a while.

Phil

Not speaking for LogRhythm
Phil Barila | Senior Software Engineer
720.881.5364 (w)
LogRhythm, Inc.
A LEADER in the 2013 SIEM Magic Quadrant
Perfect 5-Star Rating in SC Magazine for 5 Consecutive Years

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, October 21, 2013 4:11 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Help !!! Problem IOCTL_ATA_PASS_THROUGH 48 bits COMMAND

Hi,

I’m trying to issue a vendor specific ATA command to a custom device via ATA_FLAGS_48BIT_COMMAND. However, i couldn’t find any proper dpcumentation on the usage of PreviousTaskFile and CurrentTaskFIle in the ATA_PASSTHROUGH_EX structure. Does anyone have any clues on this? Or any working examples that issue such 48-bit commands?

This is because i kept encountered incorrect parameters error (Status code : 0x57). I suspect it’s the way i craft the ATA_PASSTHROUGH_EX structure especially the PreviousTaskFIle.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

This is my code snippet:

pATAData->Length = sizeof(ATA_PASS_THROUGH_EX);
pATAData->DataBufferOffset = sizeof(ATA_PASS_THROUGH_EX);
pATAData->DataTransferLength = blockcount * 512;
pATAData->AtaFlags = ATA_FLAGS_DATA_OUT | ATA_FLAGS_DRDY_REQUIRED |
ATA_FLAGS_48BIT_COMMAND;

pATAData->TimeOutValue = 60; //Seconds
/* Byte Input Register

0

Features register

1

Sector count register

2

Sector number register

3

Cylinder low register

4

Cylinder high register

5

Device/head register

6

Command register

7

Reserved

*/

pATAData->PreviousTaskFile[0] = 7; // feature id?

pATAData->PreviousTaskFile[1] = blockcount >> 8;

pATAData->PreviousTaskFile[2] = llLba >> 24;

pATAData->PreviousTaskFile[3] = llLba >> 32;

pATAData->PreviousTaskFile[4] = llLba >> 40;

pATAData->PreviousTaskFile[5] = 0xa0 | 64;

pATAData->PreviousTaskFile[6] = 0x55; //ata command again?

pATAData->PreviousTaskFile[7] = 0;

pATAData->CurrentTaskFile[0] = 7; //feature id

pATAData->CurrentTaskFile[1] = blockcount;

pATAData->CurrentTaskFile[2] = llLba;

pATAData->CurrentTaskFile[3] = llLba >> 8;

pATAData->CurrentTaskFile[4] = llLba >> 16;

pATAData->CurrentTaskFile[5] = 0xa0 | 64;

pATAData->CurrentTaskFile[7] = 0;

pATAData->CurrentTaskFile[6] = 0x55; //Custom ATA_COMMAND ID
/* send the command*/

status = DeviceIoControl( hDevice,

IOCTL_ATA_PASS_THROUGH,

pATAData,

dataSize, /* input buffer and size */

pATAData,

dataSize, /* output buffer and size */

&bytescopied, /* bytes copied to output buffer*/

NULL

); /* no overlapping */
For this case, i’m trying to talk directly to a storage device via ata
command by ATA_PASS_THROUGH.
The llba is a 48bit LBA value and blockcount is the no of sector I wan to
pass the data to.

The storage device is a customize one. However as I mentioned, kept
encountering incorrect parameters error (Status code : 0x57).

Any clues on this?

Rgds.
Stan.

On Wed, Oct 23, 2013 at 10:39 PM, Phil Barila wrote:

> The PreviousTaskFile should be initialized to the values that should be
> written first, and the CurrentTaskFile be initialized to the values written
> behind the first.
>
> If it’s not working when initialized that way, then you may have something
> else going wrong, or you may have bumped into a bug in the implementation.
> If your vendor-specific command is PIO, you should probably add the
> ATA_FLAGS_NO_MULTIPLE. It’s a bit mis-documented, because when it was
> introduced, it meant “One sector per DRQ”. I assume it still means that,
> but I haven’t used the APTI in a while.
>
> Phil
>
> Not speaking for LogRhythm
> Phil Barila | Senior Software Engineer
> 720.881.5364 (w)
> LogRhythm, Inc.
> A LEADER in the 2013 SIEM Magic Quadrant
> Perfect 5-Star Rating in SC Magazine for 5 Consecutive Years
>
> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:
> xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
> Sent: Monday, October 21, 2013 4:11 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Help !!! Problem IOCTL_ATA_PASS_THROUGH 48 bits COMMAND
>
> Hi,
>
> I’m trying to issue a vendor specific ATA command to a custom device via
> ATA_FLAGS_48BIT_COMMAND. However, i couldn’t find any proper dpcumentation
> on the usage of PreviousTaskFile and CurrentTaskFIle in the
> ATA_PASSTHROUGH_EX structure. Does anyone have any clues on this? Or any
> working examples that issue such 48-bit commands?
>
> This is because i kept encountered incorrect parameters error (Status code
> : 0x57). I suspect it’s the way i craft the ATA_PASSTHROUGH_EX structure
> especially the PreviousTaskFIle.
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

There are a number of things wrong with this.

Since you are using ATA_PASS_THROUGH_EX instead of ATA_PASS_THROUGH_DIRECT, you need to make the Length field the size of the struct plus the DataTransferLength.

You are allocating a buffer that is the size of the struct plus the DataTransferLength, I hope? If not, you’ll be asking the HBA to read off the end of your buffer.

Since you don’t pass the DMA flag, you probably should pass the flag I mentioned previously.

I’ve always found the DIRECT form more intuitive to use, but YMMV.

Phil

Not speaking for LogRhythm
Phil Barila | Senior Software Engineer
720.881.5364 (w)
LogRhythm, Inc.
A LEADER in the 2013 SIEM Magic Quadrant
Perfect 5-Star Rating in SC Magazine for 5 Consecutive Years

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Stan Yong
Sent: Wednesday, October 23, 2013 6:36 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Help !!! Problem IOCTL_ATA_PASS_THROUGH 48 bits COMMAND

This is my code snippet:

pATAData->Length = sizeof(ATA_PASS_THROUGH_EX);
pATAData->DataBufferOffset = sizeof(ATA_PASS_THROUGH_EX);
pATAData->DataTransferLength = blockcount * 512;
pATAData->AtaFlags = ATA_FLAGS_DATA_OUT | ATA_FLAGS_DRDY_REQUIRED | ATA_FLAGS_48BIT_COMMAND;

pATAData->TimeOutValue = 60; //Seconds
/* Byte Input Register

0

Features register

1

Sector count register

2

Sector number register

3

Cylinder low register

4

Cylinder high register

5

Device/head register

6

Command register

7

Reserved

*/

pATAData->PreviousTaskFile[0] = 7; // feature id?

pATAData->PreviousTaskFile[1] = blockcount >> 8;

pATAData->PreviousTaskFile[2] = llLba >> 24;

pATAData->PreviousTaskFile[3] = llLba >> 32;

pATAData->PreviousTaskFile[4] = llLba >> 40;

pATAData->PreviousTaskFile[5] = 0xa0 | 64;

pATAData->PreviousTaskFile[6] = 0x55; //ata command again?

pATAData->PreviousTaskFile[7] = 0;

pATAData->CurrentTaskFile[0] = 7; //feature id

pATAData->CurrentTaskFile[1] = blockcount;

pATAData->CurrentTaskFile[2] = llLba;

pATAData->CurrentTaskFile[3] = llLba >> 8;

pATAData->CurrentTaskFile[4] = llLba >> 16;

pATAData->CurrentTaskFile[5] = 0xa0 | 64;

pATAData->CurrentTaskFile[7] = 0;

pATAData->CurrentTaskFile[6] = 0x55; //Custom ATA_COMMAND ID
/* send the command*/

status = DeviceIoControl( hDevice,

IOCTL_ATA_PASS_THROUGH,

pATAData,

dataSize, /* input buffer and size */

pATAData,

dataSize, /* output buffer and size */

&bytescopied, /* bytes copied to output buffer*/

NULL

); /* no overlapping */
For this case, i’m trying to talk directly to a storage device via ata command by ATA_PASS_THROUGH.
The llba is a 48bit LBA value and blockcount is the no of sector I wan to pass the data to.

The storage device is a customize one. However as I mentioned, kept encountering incorrect parameters error (Status code : 0x57).

Any clues on this?

Rgds.
Stan.

On Wed, Oct 23, 2013 at 10:39 PM, Phil Barila > wrote:
The PreviousTaskFile should be initialized to the values that should be written first, and the CurrentTaskFile be initialized to the values written behind the first.

If it’s not working when initialized that way, then you may have something else going wrong, or you may have bumped into a bug in the implementation. If your vendor-specific command is PIO, you should probably add the ATA_FLAGS_NO_MULTIPLE. It’s a bit mis-documented, because when it was introduced, it meant “One sector per DRQ”. I assume it still means that, but I haven’t used the APTI in a while.

Phil

Not speaking for LogRhythm
Phil Barila | Senior Software Engineer
720.881.5364tel:720.881.5364 (w)
LogRhythm, Inc.
A LEADER in the 2013 SIEM Magic Quadrant
Perfect 5-Star Rating in SC Magazine for 5 Consecutive Years

-----Original Message-----
From: xxxxx@lists.osr.commailto:xxxxx [mailto:xxxxx@lists.osr.commailto:xxxxx] On Behalf Of xxxxx@gmail.commailto:xxxxx
Sent: Monday, October 21, 2013 4:11 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Help !!! Problem IOCTL_ATA_PASS_THROUGH 48 bits COMMAND

Hi,

I’m trying to issue a vendor specific ATA command to a custom device via ATA_FLAGS_48BIT_COMMAND. However, i couldn’t find any proper dpcumentation on the usage of PreviousTaskFile and CurrentTaskFIle in the ATA_PASSTHROUGH_EX structure. Does anyone have any clues on this? Or any working examples that issue such 48-bit commands?

This is because i kept encountered incorrect parameters error (Status code : 0x57). I suspect it’s the way i craft the ATA_PASSTHROUGH_EX structure especially the PreviousTaskFIle.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

— NTDEV is sponsored by OSR Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See http://www.osr.com/careers For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx></mailto:xxxxx></tel:720.881.5364>