summaryrefslogtreecommitdiff
path: root/util/viatool/viatool.h
diff options
context:
space:
mode:
authorAndrey Korolyov <andrey@xdel.ru>2016-01-05 20:09:02 +0300
committerPatrick Georgi <pgeorgi@google.com>2016-01-07 15:31:35 +0100
commit0ff8f9048b104b4a01823755406fa79a590ad02f (patch)
tree4bfa79436a7e3247766e1352ee4bfa7c48a0ccc3 /util/viatool/viatool.h
parent4ba946c1e1aa550b2f00db9898356cca3202323c (diff)
downloadcoreboot-0ff8f9048b104b4a01823755406fa79a590ad02f.tar.xz
viatool: add NetBSD support
Change-Id: I033044e4b781475d6d60a49a61313a720103ce38 Signed-off-by: Andrey Korolyov <andrey@xdel.ru> Reviewed-on: https://review.coreboot.org/12836 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Diffstat (limited to 'util/viatool/viatool.h')
-rw-r--r--util/viatool/viatool.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/util/viatool/viatool.h b/util/viatool/viatool.h
index a0a5d79c94..3a6f04873d 100644
--- a/util/viatool/viatool.h
+++ b/util/viatool/viatool.h
@@ -28,13 +28,38 @@
#define __DARWIN__
#include <DirectHW/DirectHW.h>
#endif
+#ifdef __NetBSD__
+#include <pciutils/pci.h>
+#else
#include <pci/pci.h>
+#endif
/* This #include is needed for freebsd_{rd,wr}msr. */
#if defined(__FreeBSD__)
#include <machine/cpufunc.h>
#endif
+#ifdef __NetBSD__
+static inline uint8_t inb(unsigned port)
+{
+ uint8_t data;
+ __asm volatile("inb %w1,%0" : "=a" (data) : "d" (port));
+ return data;
+}
+static inline uint16_t inw(unsigned port)
+{
+ uint16_t data;
+ __asm volatile("inw %w1,%0": "=a" (data) : "d" (port));
+ return data;
+}
+static inline uint32_t inl(unsigned port)
+{
+ uint32_t data;
+ __asm volatile("inl %w1,%0": "=a" (data) : "d" (port));
+ return data;
+}
+#endif
+
#include <stdlib.h>
#define VIATOOL_VERSION "1.0"