diff options
author | uwe <uwe@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2009-05-14 20:41:57 +0000 |
---|---|---|
committer | uwe <uwe@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2009-05-14 20:41:57 +0000 |
commit | db6e99604a49158868dd4975e470901e492848b4 (patch) | |
tree | d002290fdd64e4adca0ad8a00e16821e987347cb /nic3com.c | |
parent | b784f43e5b6ca66f86b3a2e4d1841a6b765236ae (diff) | |
download | flashrom-db6e99604a49158868dd4975e470901e492848b4.tar.gz |
Factor out portable iopl()-style code into a global function
which all programmers can use, add missing close() call (trivial).
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@511 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'nic3com.c')
-rw-r--r-- | nic3com.c | 19 |
1 files changed, 4 insertions, 15 deletions
@@ -39,10 +39,6 @@ uint32_t io_base_addr; struct pci_access *pacc; struct pci_filter filter; -#if defined(__FreeBSD__) || defined(__DragonFly__) -int io_fd; -#endif - #define OK 0 #define NT 1 /* Not tested */ @@ -102,17 +98,7 @@ int nic3com_init(void) struct pci_dev *dev; char *msg = NULL; -#if defined (__sun) && (defined(__i386) || defined(__amd64)) - if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0) { -#elif defined(__FreeBSD__) || defined (__DragonFly__) - if ((io_fd = open("/dev/io", O_RDWR)) < 0) { -#else - if (iopl(3) != 0) { -#endif - fprintf(stderr, "ERROR: Could not get IO privileges (%s).\n" - "You need to be root.\n", strerror(errno)); - exit(1); - } + get_io_perms(); pacc = pci_alloc(); /* Get the pci_access structure */ pci_init(pacc); /* Initialize the PCI library */ @@ -155,6 +141,9 @@ int nic3com_shutdown(void) { free(nic_pcidev); pci_cleanup(pacc); +#if defined(__FreeBSD__) || defined(__DragonFly__) + close(io_fd); +#endif return 0; } |