/*
 * Set reasonable mode for Toshiba Portégé 4000/4010
 *
 * Copyright (c) Samuel Tardieu 2002 <sam@inf.enst.fr>
 *
 */

#include <fcntl.h>
#include <stdio.h>

static void inline
hci_op (unsigned long ebx, unsigned long ecx, unsigned long edx)
{
  asm ("inb $0xb2,%%al"
       :: "a" (0xff00), "b" (ebx), "c" (ecx), "d" (edx));
}

static void
stop_apm_bios ()
{
  hci_op (0x25, 2, 1);
}

static void
screen_bright ()
{
  hci_op (0x2a, 0xe000, 0);
}

static void
cpu_full_speed ()
{
  hci_op (0x32, 0, 0);
}

static void
get_io_perms ()
{
  if (open ("/dev/io", O_RDONLY) < 0) {
    fprintf (stderr, "root privileges needed\n");
    exit (1);
  }
}

int
main ()
{
  get_io_perms ();
  stop_apm_bios ();
  screen_bright ();
  cpu_full_speed ();
  exit (0);
}
