From b64aa60f1fd5e6c84ec8ff6ad0baa7afee0d810a Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Tue, 28 Oct 2008 22:13:38 +0000 Subject: Allow superiotool to compile and work on FreeBSD. Tested on FreeBSD 7. Signed-off-by: Andriy Gapon Acked-by: Carl-Daniel Hailfinger Acked-by: Uwe Hermann git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3698 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- util/superiotool/superiotool.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'util/superiotool/superiotool.c') diff --git a/util/superiotool/superiotool.c b/util/superiotool/superiotool.c index 10f225f6dc..1bbe5feec7 100644 --- a/util/superiotool/superiotool.c +++ b/util/superiotool/superiotool.c @@ -23,6 +23,11 @@ #include "superiotool.h" +#if defined(__FreeBSD__) +#include +#include +#endif + /* Command line options. */ int dump = 0, verbose = 0, extra_dump = 0; @@ -31,25 +36,25 @@ int chip_found = 0; uint8_t regval(uint16_t port, uint8_t reg) { - outb(reg, port); - return inb(port + ((port == 0x3bd) ? 2 : 1)); /* 0x3bd is special. */ + OUTB(reg, port); + return INB(port + ((port == 0x3bd) ? 2 : 1)); /* 0x3bd is special. */ } void regwrite(uint16_t port, uint8_t reg, uint8_t val) { - outb(reg, port); - outb(val, port + 1); + OUTB(reg, port); + OUTB(val, port + 1); } void enter_conf_mode_winbond_fintek_ite_8787(uint16_t port) { - outb(0x87, port); - outb(0x87, port); + OUTB(0x87, port); + OUTB(0x87, port); } void exit_conf_mode_winbond_fintek_ite_8787(uint16_t port) { - outb(0xaa, port); /* Fintek, Winbond */ + OUTB(0xaa, port); /* Fintek, Winbond */ regwrite(port, 0x02, 0x02); /* ITE */ } @@ -204,6 +209,9 @@ static void print_version(void) int main(int argc, char *argv[]) { int i, j, opt, option_index; +#if defined(__FreeBSD__) + int io_fd; +#endif static const struct option long_options[] = { {"dump", no_argument, NULL, 'd'}, @@ -247,8 +255,13 @@ int main(int argc, char *argv[]) } } +#if defined(__FreeBSD__) + if ((io_fd = open("/dev/io", O_RDWR)) < 0) { + perror("/dev/io"); +#else if (iopl(3) < 0) { perror("iopl"); +#endif printf("Superiotool must be run as root.\n"); exit(1); } @@ -264,5 +277,8 @@ int main(int argc, char *argv[]) if (!chip_found) printf("No Super I/O found\n"); +#if defined(__FreeBSD__) + close(io_fd); +#endif return 0; } -- cgit v1.2.3