Andrey Korolyov (andrey@xdel.ru) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12831
-gerrit
commit f1079253ee8e9f4295d87bbba4c97b7c1bd14106 Author: Andrey Korolyov andrey@xdel.ru Date: Tue Jan 5 14:27:59 2016 +0300
ectool: fix NetBSD compilation
Most of ifification was taken directly from pkgsrc/vbetool/patches/patch-ab
Change-Id: Ibd264384f49b33412f0ef8554bd9c9fb8f60a892 Signed-off-by: Andrey Korolyov andrey@xdel.ru --- util/ectool/Makefile | 6 +++++- util/ectool/ec.c | 22 ++++++++++++++++++++++ util/ectool/ectool.c | 23 +++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/util/ectool/Makefile b/util/ectool/Makefile index a869577..214032f 100644 --- a/util/ectool/Makefile +++ b/util/ectool/Makefile @@ -20,11 +20,15 @@ PROGRAM = ectool INSTALL = /usr/bin/install PREFIX = /usr/local
-OS_ARCH = $(shell uname -o) +OS_ARCH = $(shell uname) ifeq ($(OS_ARCH), 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 406cc41..592491c 100644 --- a/util/ectool/ec.c +++ b/util/ectool/ec.c @@ -17,9 +17,31 @@ #include <stdint.h> #include <stdlib.h> #include <unistd.h> +#ifdef __NetBSD__ +#include <sys/uio.h> +#else #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 4639c4e..3520a60 100644 --- a/util/ectool/ectool.c +++ b/util/ectool/ectool.c @@ -18,10 +18,19 @@ #include <stdlib.h> #include <unistd.h> #include <getopt.h> +#ifdef __NetBSD__ +#include <sys/uio.h> +#else #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) @@ -108,10 +117,24 @@ int main(int argc, char *argv[]) } }
+#ifdef __NetBSD__ +# ifdef __i386__ + if (i386_iopl(3)) { + printf("You need to be root.\n"); + exit(1); + } +# else + if (x86_64_iopl(3)) { + printf("You need to be root.\n"); + exit(1); + } +# endif +#else if (iopl(3)) { printf("You need to be root.\n"); exit(1); } +#endif if (write_addr >= 0 && write_data >= 0) { write_addr &= 0xff; write_data &= 0xff;