summaryrefslogtreecommitdiff
path: root/util/nvramtool
diff options
context:
space:
mode:
authorjakllsch <jakllsch@kollasch.net>2011-02-08 16:07:49 +0000
committerJonathan A. Kollasch <jakllsch@kollasch.net>2011-02-08 16:07:49 +0000
commitb0c94a1866debb262ff1343674de871f6b770f3f (patch)
tree1a12418d6ea08b4e679901ab2ce163a4da23a16d /util/nvramtool
parent167b79232744eea31d966bce4007d0a7c6d982ee (diff)
downloadcoreboot-b0c94a1866debb262ff1343674de871f6b770f3f.tar.xz
Add NetBSD support to nvramtool.
Signed-off-by: <jakllsch@kollasch.net> Acked-by: Patrick Georgi <patrick.georgi@secunet.com> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@6338 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/nvramtool')
-rw-r--r--util/nvramtool/Makefile3
-rw-r--r--util/nvramtool/accessors/cmos-hw-unix.c47
2 files changed, 50 insertions, 0 deletions
diff --git a/util/nvramtool/Makefile b/util/nvramtool/Makefile
index 520655dbb5..e0054cde34 100644
--- a/util/nvramtool/Makefile
+++ b/util/nvramtool/Makefile
@@ -39,6 +39,9 @@ OS_ARCH = $(shell uname)
ifeq ($(OS_ARCH), Darwin)
LDFLAGS = -framework DirectIO
endif
+ifeq ($(OS_ARCH), NetBSD)
+LDFLAGS = -l$(shell uname -p)
+endif
all: dep $(PROGRAM)
diff --git a/util/nvramtool/accessors/cmos-hw-unix.c b/util/nvramtool/accessors/cmos-hw-unix.c
index 06855d72df..24cc42d2dd 100644
--- a/util/nvramtool/accessors/cmos-hw-unix.c
+++ b/util/nvramtool/accessors/cmos-hw-unix.c
@@ -17,6 +17,53 @@
#if (defined(__MACH__) && defined(__APPLE__))
#include <DirectIO/darwinio.h>
#endif
+#if defined(__NetBSD__)
+#if defined(__i386__) || defined(__x86_64__)
+#include <machine/sysarch.h>
+
+static inline void outb(uint8_t value, uint16_t port)
+{
+ asm volatile ("outb %b0,%w1": :"a" (value), "Nd" (port));
+}
+
+static inline uint8_t inb(uint16_t port)
+{
+ uint8_t value;
+ asm volatile ("inb %w1,%0":"=a" (value):"Nd" (port));
+ return value;
+}
+
+static inline void outw(uint16_t value, uint16_t port)
+{
+ asm volatile ("outw %w0,%w1": :"a" (value), "Nd" (port));
+}
+
+static inline uint16_t inw(uint16_t port)
+{
+ uint16_t value;
+ asm volatile ("inw %w1,%0":"=a" (value):"Nd" (port));
+ return value;
+}
+
+static inline void outl(uint32_t value, uint16_t port)
+{
+ asm volatile ("outl %0,%w1": :"a" (value), "Nd" (port));
+}
+
+static inline uint32_t inl(uint16_t port)
+{
+ uint32_t value;
+ asm volatile ("inl %1,%0":"=a" (value):"Nd" (port));
+ return value;
+}
+#endif
+#ifdef __x86_64__
+#define iopl x86_64_iopl
+#endif
+#ifdef __i386__
+#define iopl i386_iopl
+#endif
+#endif
#define OUTB outb
#define OUTW outw
#define OUTL outl