Sign in with
Sign up | Sign in
Your question

how to send an ata command with buffer to deivice ?

Last response: in Windows XP
Share
Anonymous
a b \ Driver
August 25, 2004 7:04:17 PM

Archived from groups: microsoft.public.windowsxp.device_driver.dev (More info?)

dear all:

I know MS provide IOCTL_IDE_PASS_THROUGH controlcode to send ata
command from user interface.

but I test that it only can return data in registers,like return status
at bCommandReg (see below).

When I want a command with buffer that conntaining returned data or
send data. it will failed.

How to do then ?

Thanks.

THis is the structs I used.

typedef struct
{
UCHAR bFeaturesReg;
UCHAR bSectorCountReg;
UCHAR bSectorNumberReg;
UCHAR bCylLowReg;
UCHAR bCylHighReg;
UCHAR bDriveHeadReg;
UCHAR bCommandReg;
UCHAR bReserved;
} IDEREGS, *PIDEREGS;

typedef struct
{
IDEREGS IdeReg;
ULONG DataBufferSize;
UCHAR DataBuffer[1];
} ATA_PASS_THROUGH;
Anonymous
a b \ Driver
September 10, 2004 1:15:14 AM

Archived from groups: microsoft.public.windowsxp.device_driver.dev (More info?)

Hi icsi,

I'm a total programming diletant, so I don't know if it will help you. I was
trying to write an application that sends one simple ATA command and I was
asking people for help and samples of code. One of them answered me and gave
me this sample code. Maybe it will help you.
The code is:

typedef struct {
IDE_REGISTER strIDEReg;
unsigned long ulBufSize;
unsigned char ucBuffer[512];
}IDE_PASSTHROUGH;

IDE_PASSTRHOUGH strIDE;
strIDE.bFeatures = 0x00; /* NA for ATA inquiry */
strIDE.bSectorCount = 0x00; /* NA for ATA inquiry */
strIDE.bSecrorNumber =0x01; /* NA for ATA inquiry, but set to 1 */
strIDE.bCylinderLow = 0x00; /* NA for ATA inquiry */
strIDE.bCylinderHigh = 0x00; /* NA for ATA inquiry */
strIDE.bDeviceHead = 0xA0; /* 1010 0000 let say CHS mode and master */
strIDE.bCommand = 0xEC;
strIDE.features = 0x00; /* NA for ATA inquiry */

/* send the command*/
status = DeviceIOControl( DeviceHandle, IOCTL_IDE_PASS_THROUGH,
&strIDE, sizeof(strIDE), /* input buffer and size */
&strIDE, sizeof(strIDE), /* output buffer and size */
&bytescopied, /* bytes copied to output buffer*/
False); /* no overlapping */
if(!status)
error handling
.............

I don't know if this will help you, but I think the code sample has some
buffers, so maybe it's what you're looking for.

Regards
Jan Lenoch

"icsi" <icsi_iwub@sohu.com> pí¹e v diskusním pøíspìvku
news:%23AaA8GniEHA.644@tk2msftngp13.phx.gbl...
> dear all:
>
> I know MS provide IOCTL_IDE_PASS_THROUGH controlcode to send ata
> command from user interface.
>
> but I test that it only can return data in registers,like return
status
> at bCommandReg (see below).
>
> When I want a command with buffer that conntaining returned data or
> send data. it will failed.
>
> How to do then ?
>
> Thanks.
>
> THis is the structs I used.
>
> typedef struct
> {
> UCHAR bFeaturesReg;
> UCHAR bSectorCountReg;
> UCHAR bSectorNumberReg;
> UCHAR bCylLowReg;
> UCHAR bCylHighReg;
> UCHAR bDriveHeadReg;
> UCHAR bCommandReg;
> UCHAR bReserved;
> } IDEREGS, *PIDEREGS;
>
> typedef struct
> {
> IDEREGS IdeReg;
> ULONG DataBufferSize;
> UCHAR DataBuffer[1];
> } ATA_PASS_THROUGH;
>
>
Anonymous
a b \ Driver
September 10, 2004 4:50:05 PM

Archived from groups: microsoft.public.windowsxp.device_driver.dev (More info?)

ATA pass-through is broken in 2000 and XP up through SP1. For this to work
properly you must upgrade to XP SP2 or use Server 2003 and use
IOCTL_ATA_PASS_THROUGH or IOCTL_ATA_PASS_THROUGH_DIRECT. You will also need
to compile your application with a path to the latest DDK for Server 2003 to
provide the proper definitions for the ATA_PASS_THROUGH/DIRECT structures.
Caveats to be aware of: DMA does not work with pass through so you are
limited to PIO.

Microsoft does have a hot fix avaialable for XP SP1 which replaces
atapi.sys. That might still be supported. As to a fix for 2000, that is
supposed to be in the next SP(5).

--
The personal opinion of
Gary G. Little

"Jan Lenoch" <jan.lenoch@seznam.cz> wrote in message
news:2qbo4sFtj02fU1@uni-berlin.de...
> Hi icsi,
>
> I'm a total programming diletant, so I don't know if it will help you. I
was
> trying to write an application that sends one simple ATA command and I was
> asking people for help and samples of code. One of them answered me and
gave
> me this sample code. Maybe it will help you.
> The code is:
>
> typedef struct {
> IDE_REGISTER strIDEReg;
> unsigned long ulBufSize;
> unsigned char ucBuffer[512];
> }IDE_PASSTHROUGH;
>
> IDE_PASSTRHOUGH strIDE;
> strIDE.bFeatures = 0x00; /* NA for ATA inquiry */
> strIDE.bSectorCount = 0x00; /* NA for ATA inquiry */
> strIDE.bSecrorNumber =0x01; /* NA for ATA inquiry, but set to 1 */
> strIDE.bCylinderLow = 0x00; /* NA for ATA inquiry */
> strIDE.bCylinderHigh = 0x00; /* NA for ATA inquiry */
> strIDE.bDeviceHead = 0xA0; /* 1010 0000 let say CHS mode and master */
> strIDE.bCommand = 0xEC;
> strIDE.features = 0x00; /* NA for ATA inquiry */
>
> /* send the command*/
> status = DeviceIOControl( DeviceHandle, IOCTL_IDE_PASS_THROUGH,
> &strIDE, sizeof(strIDE), /* input buffer and size */
> &strIDE, sizeof(strIDE), /* output buffer and size */
> &bytescopied, /* bytes copied to output buffer*/
> False); /* no overlapping */
> if(!status)
> error handling
> ............
>
> I don't know if this will help you, but I think the code sample has some
> buffers, so maybe it's what you're looking for.
>
> Regards
> Jan Lenoch
>
> "icsi" <icsi_iwub@sohu.com> pí¹e v diskusním pøíspìvku
> news:%23AaA8GniEHA.644@tk2msftngp13.phx.gbl...
> > dear all:
> >
> > I know MS provide IOCTL_IDE_PASS_THROUGH controlcode to send ata
> > command from user interface.
> >
> > but I test that it only can return data in registers,like return
> status
> > at bCommandReg (see below).
> >
> > When I want a command with buffer that conntaining returned data or
> > send data. it will failed.
> >
> > How to do then ?
> >
> > Thanks.
> >
> > THis is the structs I used.
> >
> > typedef struct
> > {
> > UCHAR bFeaturesReg;
> > UCHAR bSectorCountReg;
> > UCHAR bSectorNumberReg;
> > UCHAR bCylLowReg;
> > UCHAR bCylHighReg;
> > UCHAR bDriveHeadReg;
> > UCHAR bCommandReg;
> > UCHAR bReserved;
> > } IDEREGS, *PIDEREGS;
> >
> > typedef struct
> > {
> > IDEREGS IdeReg;
> > ULONG DataBufferSize;
> > UCHAR DataBuffer[1];
> > } ATA_PASS_THROUGH;
> >
> >
>
>
!