Re: IBM HDAPS things are looking up (was: Re: [Hdaps-devel] Re: [ltp] IBM HDAPS Someone interested? (Accelerometer))

Jens Axboe
2005-07-04T06:39:27Z

On Mon, Jul 04 2005, Alejandro Bonilla wrote:
> Jens Axboe wrote:
>
> >On Mon, Jul 04 2005, Lenz Grimmer wrote:
> >
> >
> >>>I'll be working on adding sysfs stuff to it tomorrow so it's generally
> >>>useful (at least for monitoring things - not yet for parking disk
> >>>heads).
> >>>
> >>>
> >>Maybe there is some kind of all-purpose ATA command that instructs the
> >>disk drive to park the heads? Jens, could you give us a hint on how a
> >>userspace application would do that?
> >>
> >>
> >
> >Dunno if there's something that explicitly only parks the head, the best
> >option is probably to issue a STANDBY_NOW command. You can test this
> >with hdparm -y.
> >
> >
> This is exactly what I said. Use hdparm to make the HD park
> inmediatelly. I did send the email to the HDPARM developer, but he never
> replied. I asked him what would be the best way to make the HD park with
> no exception and then let it come back 5 or 10 seconds later.

IIRC, you don't have to do anything to wake up the drive after a
STANDBYNOW command, if you want to be on the safe side you just issue an
IDLEIMMEDIATE. So your code will look something like:

int drive_standby(int fd)
{
char foo[4] = { 0xe0, 0, 0, 0 };

return ioctl(fd, HDIO_DRIVE_CMD, &foo);
}

int drive_wakeup(int fd)
{
char foo[4] = { 0xe1, 0, 0, 0 };

return ioctl(fd, HDIO_DRIVE_CMD, &foo);
}

--
Jens Axboe