This patch is a rework of Adam Kaufman's Solaris patch

* flash.h:
  - add a license header
  - add system definitions
* flash_enable.c:
  - put io priviledge access in one single place
  - add includes required for Solaris.
* lbtable.c, flash_rom.c, 82802ab.c:
  - use MEM_DEV so it works on Solaris
* sst49lfxxxc.c, sharplhf00l04.c, sst_fwhub.c, 82802ab.c
  - drop unneeded include to sys/io.h
* Makefile
  - adapt to Solaris specifics.

Corresponding to flashrom svn r88 and coreboot v2 svn r2550.

Signed-off-by: Adam Kaufman <adam.kaufman@pinnacle.com>
Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Adam Kaufman <adam.kaufman@pinnacle.com>
diff --git a/flash_enable.c b/flash_enable.c
index 743fe25..82dab1a 100644
--- a/flash_enable.c
+++ b/flash_enable.c
@@ -11,12 +11,18 @@
  *
  */
 
-#include <sys/io.h>
 #include <stdio.h>
 #include <pci/pci.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
+#if defined (__sun) && (defined(__i386) || defined(__amd64))
+#include <strings.h>
+#include <sys/sysi86.h>
+#include <sys/psw.h>
+#include <asm/sunddi.h>
+#endif
+#include "flash.h"
 #include "lbtable.h"
 #include "debug.h"
 
@@ -27,12 +33,6 @@
 {
 	char b;
 
-	/* get io privilege access PCI configuration space */
-	if (iopl(3) != 0) {
-		perror("Can not set io priviliage");
-		exit(1);
-	}
-
 	/* Enable 0xFFF8000~0xFFFF0000 decoding on SiS 540/630 */
 	outl(0x80000840, 0x0cf8);
 	b = inb(0x0cfc) | 0x0b;
@@ -164,12 +164,6 @@
 	unsigned int base;
 	int ok;
 
-	/* get io privilege access PCI configuration space */
-	if (iopl(3) != 0) {
-		perror("Can not set io priviliage");
-		exit(1);
-	}
-
 	old = pci_read_byte(dev, 0x40);
 
 	new = old | 0x10;
@@ -347,12 +341,6 @@
 	struct pci_filter f;
 	struct pci_dev *smbusdev;
 
-	/* get io privilege access */
-	if (iopl(3) != 0) {
-		perror("Can not set io priviliage");
-		exit(1);
-	}
-
 	/* then look for the smbus device */
 	pci_filter_init((struct pci_access *) 0, &f);
 	f.vendor = 0x1002;
@@ -491,12 +479,6 @@
  *  connected to the WinBond w83627hf GPIO 24.
  */
 
-	/* get io privilege access winbond config space */
-	if (iopl(3) != 0) {
-		perror("Can not set io priviliage");
-		exit(1);
-	}
-	
 	printf("Disabling mainboard flash write protection.\n");
 
 	outb(0x87, EFIR); // sequence to unlock extended functions
@@ -552,6 +534,18 @@
 	struct pci_dev *dev = 0;
 	FLASH_ENABLE *enable = 0;
 
+	/* get io privilege access PCI configuration space */
+#if defined (__sun) && (defined(__i386) || defined(__amd64))
+	if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0){
+#else
+	if (iopl(3) != 0) {
+#endif
+		perror("Can not set io privilege");
+		exit(1);
+	}
+
+
+	/* Initialize PCI access */
 	pacc = pci_alloc();	/* Get the pci_access structure */
 	/* Set all options you want -- here we stick with the defaults */
 	pci_init(pacc);		/* Initialize the PCI library */