diff options
author | Andriy Gapon <avg@icyb.net.ua> | 2008-10-28 22:13:38 +0000 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2008-10-28 22:13:38 +0000 |
commit | b64aa60f1fd5e6c84ec8ff6ad0baa7afee0d810a (patch) | |
tree | af1c87228d5b0ed4e7726cf406c742c9e72c2313 /util/superiotool/superiotool.c | |
parent | c372aa4f77a81e24c1ced47b1da010814b3da3bf (diff) |
Allow superiotool to compile and work on FreeBSD. Tested on FreeBSD 7.
Signed-off-by: Andriy Gapon <avg@icyb.net.ua>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3698 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/superiotool/superiotool.c')
-rw-r--r-- | util/superiotool/superiotool.c | 30 |
1 files changed, 23 insertions, 7 deletions
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 <fcntl.h> +#include <unistd.h> +#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; } |