/*
 * A simple program to set the AIE bit of the RTC when nothing else works.
 * This has been tested on exactly one motherboard: ECS 755-A2. Use at your
 * own risk.
 *
 * To compile: gcc -o rtc_set_wakeup rtc_set_wakeup.c
 * This program only works if running as root.
 *
 * carl@cameltail.com
 */

#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <linux/rtc.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/io.h>

int main () {
  int fd;
  int retval;

  retval = ioperm(0x70, 6, 1);
  if (retval == -1) {
    perror("ioperm");
    return(errno);
  }

  outb(11, 0x70);
  outb(0x22, 0x71);

  retval = ioperm(0x70, 4, 0);
  printf("done: %d\n", retval);

  return 0;
}

