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
This commit is contained in:
Andriy Gapon
2008-10-28 22:13:38 +00:00
committed by Uwe Hermann
parent c372aa4f77
commit b64aa60f1f
7 changed files with 66 additions and 30 deletions

View File

@@ -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;
}