/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
GRUB_MOD_LICENSE ("GPLv3+");
"(1=low, ..., 254=high, 255=off)."),
0, ARG_TYPE_INT},
0, ARG_TYPE_NONE},
"(0=off, 128=quiet, ..., 254=fast)."),
0, ARG_TYPE_INT},
"(0=off, 1=5s, 2=10s, ..., 240=20m, 241=30m, ...)."),
0, ARG_TYPE_INT},
0, ARG_TYPE_NONE},
0, ARG_TYPE_NONE},
{0, 0, 0, 0, 0, 0}
};
{
};
static int quiet = 0;
static grub_err_t
{
return grub_errno;
return GRUB_ERR_NONE;
}
static int
{
return -1;
}
static int
{
return -1;
if (features == GRUB_ATA_FEAT_SMART_STATUS)
{
return 0; /* Good SMART status. */
return 1; /* Bad SMART status. */
else
return -1;
}
return 0;
}
static grub_err_t
{
return err;
}
static grub_err_t
{
{
if (val >= 0)
else
}
NULL, 0);
return err;
}
static const char *
{
unsigned i;
for (i = 0; i < bytes / 2; i++)
dest[i] = 0;
return (char *) dest;
}
static void
{
/* Print identity strings. */
/* Print AAM, APM and SMART settings. */
grub_printf ("Automatic Acoustic Management: ");
if (features2 & 0x0200)
{
if (enabled2 & 0x0200)
{
grub_printf ("%u (128=quiet, ..., 254=fast, recommended=%u)\n",
}
else
grub_printf ("disabled\n");
}
else
grub_printf ("not supported\n");
grub_printf ("Advanced Power Management: ");
if (features2 & 0x0008)
{
if (enabled2 & 0x0008)
grub_printf ("%u (1=low, ..., 254=high)\n",
else
grub_printf ("disabled\n");
}
else
grub_printf ("not supported\n");
grub_printf ("SMART Feature Set: ");
if (features1 & 0x0001)
else
grub_printf ("not supported\n");
/* Print security settings. */
grub_printf ("ATA Security: ");
if (security & 0x0001)
grub_printf ("%s, %s, %s, %s\n",
else
grub_printf ("not supported\n");
}
static void
{
if (timeout == 0)
grub_printf ("off");
{
int h = 0, m = 0 , s = 0;
if (timeout == 255)
{
m = 21;
s = 15;
}
else if (timeout == 252)
m = 21;
else if (timeout <= 240)
{
s = timeout * 5;
m = s / 60;
s %= 60;
}
else
{
h = m / 60;
m %= 60;
}
grub_printf ("%02d:%02d:%02d", h, m, s);
}
else
grub_printf ("invalid or vendor-specific");
}
{
}
static grub_err_t
{
/* Check command line. */
if (argc != 1)
int i = 0;
/* Open disk. */
if (! disk)
return grub_errno;
{
}
{
case GRUB_DISK_DEVICE_ATA_ID:
break;
case GRUB_DISK_DEVICE_SCSI_ID:
{
break;
}
default:
}
/* Change settings. */
if (aam >= 0)
if (apm >= 0)
grub_hdparm_set_val_cmd ("Advanced Power Management",
if (standby_tout >= 0)
{
if (! quiet)
{
grub_printf (")");
}
/* The IDLE cmd sets disk to idle mode and configures standby timer. */
}
if (enable_smart >= 0)
{
if (! quiet)
if (! quiet)
}
if (sec_freeze)
if (ident || dumpid)
{
grub_printf ("Cannot read ATA IDENTIFY data\n");
else
{
if (ident)
if (dumpid)
}
}
/* Check power mode. */
if (power)
{
grub_printf ("Disk power mode is: ");
if (mode < 0)
grub_printf ("unknown\n");
else
grub_printf ("%s (0x%02x)\n",
}
/* Check health. */
int status = 0;
if (health)
{
if (! quiet)
grub_printf ("SMART status is: ");
if (! quiet)
}
/* Change power mode. */
if (standby_now)
if (sleep_now)
return status;
}
{
N_("[OPTIONS] DISK"),
}
{
}