summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/ectool/Makefile8
-rw-r--r--util/ectool/ec.c16
-rw-r--r--util/ectool/ectool.c15
3 files changed, 37 insertions, 2 deletions
diff --git a/util/ectool/Makefile b/util/ectool/Makefile
index a869577da6..8aa1415a56 100644
--- a/util/ectool/Makefile
+++ b/util/ectool/Makefile
@@ -19,12 +19,16 @@ CFLAGS = -O2 -Wall -W
PROGRAM = ectool
INSTALL = /usr/bin/install
PREFIX = /usr/local
+OS_ARCH = $(shell uname)
-OS_ARCH = $(shell uname -o)
-ifeq ($(OS_ARCH), Cygwin)
+ifeq ($(shell uname -o 2>/dev/null), Cygwin)
LDFLAGS = -lioperm
endif
+ifeq ($(OS_ARCH), NetBSD)
+LDFLAGS = -l$(shell uname -p)
+endif
+
all: $(PROGRAM)
$(PROGRAM): ec.o ectool.o
diff --git a/util/ectool/ec.c b/util/ectool/ec.c
index 406cc41ae7..098e8126d9 100644
--- a/util/ectool/ec.c
+++ b/util/ectool/ec.c
@@ -17,9 +17,25 @@
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
+#ifndef __NetBSD__
#include <sys/io.h>
+#endif
#include "ec.h"
+#ifdef __NetBSD__
+#include <machine/sysarch.h>
+static uint8_t inb(unsigned port)
+{
+ uint8_t data;
+ __asm volatile("inb %w1,%0" : "=a" (data) : "d" (port));
+ return data;
+}
+static __inline void outb(uint8_t data, unsigned port)
+{
+ __asm volatile("outb %0,%w1" : : "a" (data), "d" (port));
+}
+#endif
+
extern int verbose;
#define debug(x...) if (verbose) printf(x)
diff --git a/util/ectool/ectool.c b/util/ectool/ectool.c
index c93eb256e7..50ac30b5e5 100644
--- a/util/ectool/ectool.c
+++ b/util/ectool/ectool.c
@@ -18,10 +18,17 @@
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
+#ifndef __NetBSD__
#include <sys/io.h>
+#endif
#include <ec.h>
#include <stdlib.h>
+#ifdef __NetBSD__
+#include <machine/sysarch.h>
+#endif
+
+
#define ECTOOL_VERSION "0.1"
void print_version(void)
@@ -106,7 +113,15 @@ int main(int argc, char *argv[])
}
}
+#ifdef __NetBSD__
+# ifdef __i386__
+ if (i386_iopl(3)) {
+# else
+ if (x86_64_iopl(3)) {
+# endif
+#else
if (iopl(3)) {
+#endif
printf("You need to be root.\n");
exit(1);
}