diff --git a/headers/compatibility/freebsd/machine/atomic.h b/headers/compatibility/freebsd/machine/atomic.h
new file mode 100644
index 0000000000..d02f8ff148
--- /dev/null
+++ b/headers/compatibility/freebsd/machine/atomic.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2007, Hugo Santos. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _FBSD_COMPAT_MACHINE_ATOMIC_H_
+#define _FBSD_COMPAT_MACHINE_ATOMIC_H_
+
+
+#include <KernelExport.h>
+
+
+#define atomic_add_int(ptr, value) \
+	atomic_add((int32 *)(ptr), value)
+
+#define atomic_subtract_int(ptr, value) \
+	atomic_add((int32 *)(ptr), -value)
+
+#define atomic_set_acq_32(ptr, value) \
+	atomic_set_int(ptr, value)
+
+#define atomic_set_int(ptr, value) \
+	atomic_or((int32 *)(ptr), value)
+
+#define atomic_readandclear_int(ptr) \
+	atomic_set((int32 *)(ptr), 0)
+
+#endif	/* _FBSD_COMPAT_MACHINE_ATOMIC_H_ */
diff --git a/headers/compatibility/freebsd/machine/cpufunc.h b/headers/compatibility/freebsd/machine/cpufunc.h
new file mode 100644
index 0000000000..8e1575b1dd
--- /dev/null
+++ b/headers/compatibility/freebsd/machine/cpufunc.h
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 1993 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef _FBSD_COMPAT_MACHINE_CPUFUNC_H_
+#define _FBSD_COMPAT_MACHINE_CPUFUNC_H_
+
+
+static __inline void
+outsb(u_int port, const void *addr, size_t cnt)
+{
+	__asm __volatile("cld; rep; outsb"
+			 : "+S" (addr), "+c" (cnt)
+			 : "d" (port));
+}
+
+#endif /* _FBSD_COMPAT_MACHINE_CPUFUNC_H_ */
diff --git a/headers/compatibility/freebsd/machine/endian.h b/headers/compatibility/freebsd/machine/endian.h
new file mode 100644
index 0000000000..6d6e68c768
--- /dev/null
+++ b/headers/compatibility/freebsd/machine/endian.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2007 Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _FBSD_COMPAT_MACHINE_ENDIAN_H_
+#define _FBSD_COMPAT_MACHINE_ENDIAN_H_
+
+
+#include <freebsd/sys/cdefs.h>
+#include <freebsd/sys/_types.h>
+
+#endif
diff --git a/headers/compatibility/freebsd/sys/_mutex.h b/headers/compatibility/freebsd/sys/_mutex.h
new file mode 100644
index 0000000000..7d8e757c53
--- /dev/null
+++ b/headers/compatibility/freebsd/sys/_mutex.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2009, Colin Günther, coling@gmx.de.
+ * Copyright 2007, Hugo Santos. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _FBSD_COMPAT_SYS__MUTEX_H_
+#define _FBSD_COMPAT_SYS__MUTEX_H_
+
+
+#include <lock.h>
+
+
+struct mtx {
+	int						type;
+	union {
+		struct {
+			mutex			lock;
+			thread_id		owner;
+		}					mutex;
+		int32				spinlock;
+		recursive_lock		recursive;
+	} u;
+};
+
+
+#endif /* _FBSD_COMPAT_SYS__MUTEX_H_ */
diff --git a/headers/compatibility/freebsd/sys/_timeval.h b/headers/compatibility/freebsd/sys/_timeval.h
new file mode 100644
index 0000000000..f447fca94b
--- /dev/null
+++ b/headers/compatibility/freebsd/sys/_timeval.h
@@ -0,0 +1,11 @@
+/*
+ * Copyright 2009 Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _FBSD_COMPAT_SYS__TIMEVAL_H_
+#define _FBSD_COMPAT_SYS__TIMEVAL_H_
+
+
+#include <freebsd/sys/_types.h>
+
+#endif /* _FBSD_COMPAT_SYS__TIMEVAL_H_ */
diff --git a/headers/compatibility/freebsd/sys/_types.h b/headers/compatibility/freebsd/sys/_types.h
new file mode 100644
index 0000000000..790e013860
--- /dev/null
+++ b/headers/compatibility/freebsd/sys/_types.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2007 Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _FBSD_COMPAT_SYS__TYPES_H_
+#define _FBSD_COMPAT_SYS__TYPES_H_
+
+
+#ifdef __GNUCLIKE_BUILTIN_VARARGS
+typedef __builtin_va_list	__va_list;	/* internally known to gcc */
+#else
+typedef	char *			__va_list;
+#endif /* __GNUCLIKE_BUILTIN_VARARGS */
+#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
+    && !defined(__NO_GNUC_VA_LIST)
+#define __GNUC_VA_LIST
+typedef __va_list		__gnuc_va_list;	/* compatibility w/GNU headers*/
+#endif
+
+#endif /* _FBSD_COMPAT_SYS__TYPES_H_ */
diff --git a/headers/compatibility/freebsd/sys/cdefs.h b/headers/compatibility/freebsd/sys/cdefs.h
new file mode 100644
index 0000000000..f971269f4c
--- /dev/null
+++ b/headers/compatibility/freebsd/sys/cdefs.h
@@ -0,0 +1,310 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Berkeley Software Design, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)cdefs.h	8.8 (Berkeley) 1/9/95
+ * $FreeBSD$
+ */
+#ifndef _FBSD_COMPAT_SYS_CDEFS_H_
+#define _FBSD_COMPAT_SYS_CDEFS_H_
+
+
+#include <posix/sys/cdefs.h>
+
+
+#define __FBSDID(str)	static const char __fbsdid[] = str
+
+/*
+ * This code has been put in place to help reduce the addition of
+ * compiler specific defines in FreeBSD code.  It helps to aid in
+ * having a compiler-agnostic source tree.
+ */
+
+#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+
+#if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
+#define __GNUCLIKE_ASM 3
+#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
+#else
+#define __GNUCLIKE_ASM 2
+#endif
+#define __GNUCLIKE___TYPEOF 1
+#define __GNUCLIKE___OFFSETOF 1
+#define __GNUCLIKE___SECTION 1
+
+#define __GNUCLIKE_ATTRIBUTE_MODE_DI 1
+
+#ifndef __INTEL_COMPILER
+# define __GNUCLIKE_CTOR_SECTION_HANDLING 1
+#endif
+
+#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
+# if defined(__INTEL_COMPILER) && defined(__cplusplus) \
+    && __INTEL_COMPILER < 800
+#  undef __GNUCLIKE_BUILTIN_CONSTANT_P
+# endif
+
+#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
+# define __GNUCLIKE_BUILTIN_VARARGS 1
+# define __GNUCLIKE_BUILTIN_STDARG 1
+# define __GNUCLIKE_BUILTIN_VAALIST 1
+#endif
+
+#if defined(__GNUC__)
+# define __GNUC_VA_LIST_COMPATIBILITY 1
+#endif
+
+#ifndef __INTEL_COMPILER
+# define __GNUCLIKE_BUILTIN_NEXT_ARG 1
+# define __GNUCLIKE_MATH_BUILTIN_RELOPS
+#endif
+
+#define __GNUCLIKE_BUILTIN_MEMCPY 1
+
+/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
+#define __CC_SUPPORTS_INLINE 1
+#define __CC_SUPPORTS___INLINE 1
+#define __CC_SUPPORTS___INLINE__ 1
+
+#define __CC_SUPPORTS___FUNC__ 1
+#define __CC_SUPPORTS_WARNING 1
+
+#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
+
+#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
+
+#endif /* __GNUC__ || __INTEL_COMPILER */
+
+
+/*
+ * Macro to test if we're using a specific version of gcc or later.
+ */
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+#define	__GNUC_PREREQ__(ma, mi)	\
+	(__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
+#else
+#define	__GNUC_PREREQ__(ma, mi)	0
+#endif
+
+/*
+ * GNU C version 2.96 adds explicit branch prediction so that
+ * the CPU back-end can hint the processor and also so that
+ * code blocks can be reordered such that the predicted path
+ * sees a more linear flow, thus improving cache behavior, etc.
+ *
+ * The following two macros provide us with a way to utilize this
+ * compiler feature.  Use __predict_true() if you expect the expression
+ * to evaluate to true, and __predict_false() if you expect the
+ * expression to evaluate to false.
+ *
+ * A few notes about usage:
+ *
+ *	* Generally, __predict_false() error condition checks (unless
+ *	  you have some _strong_ reason to do otherwise, in which case
+ *	  document it), and/or __predict_true() `no-error' condition
+ *	  checks, assuming you want to optimize for the no-error case.
+ *
+ *	* Other than that, if you don't know the likelihood of a test
+ *	  succeeding from empirical or other `hard' evidence, don't
+ *	  make predictions.
+ *
+ *	* These are meant to be used in places that are run `a lot'.
+ *	  It is wasteful to make predictions in code that is run
+ *	  seldomly (e.g. at subsystem initialization time) as the
+ *	  basic block reordering that this affects can often generate
+ *	  larger code.
+ */
+#if __GNUC_PREREQ__(2, 96)
+#define __predict_true(exp)     __builtin_expect((exp), 1)
+#define __predict_false(exp)    __builtin_expect((exp), 0)
+#else
+#define __predict_true(exp)     (exp)
+#define __predict_false(exp)    (exp)
+#endif
+
+/*
+ * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
+ * require it.
+ */
+#if __GNUC_PREREQ__(4, 1)
+#define __offsetof(type, field)	 __builtin_offsetof(type, field)
+#else
+#ifndef __cplusplus
+#define	__offsetof(type, field)	((size_t)(&((type *)0)->field))
+#else
+#define __offsetof(type, field)					\
+  (__offsetof__ (reinterpret_cast <size_t>			\
+                 (&reinterpret_cast <const volatile char &>	\
+                  (static_cast<type *> (0)->field))))
+#endif
+#endif
+#define	__rangeof(type, start, end) \
+	(__offsetof(type, end) - __offsetof(type, start))
+
+/*
+ * Compiler-dependent macros to help declare dead (non-returning) and
+ * pure (no side effects) functions, and unused variables.  They are
+ * null except for versions of gcc that are known to support the features
+ * properly (old versions of gcc-2 supported the dead and pure features
+ * in a different (wrong) way).  If we do not provide an implementation
+ * for a given compiler, let the compile fail if it is told to use
+ * a feature that we cannot live without.
+ */
+#ifdef lint
+#define	__pure2
+#define	__unused
+#define	__packed
+#define	__aligned(x)
+#define	__section(x)
+#else
+#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
+#define	__pure2
+#define	__unused
+#endif
+#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
+#define	__pure2		__attribute__((__const__))
+#define	__unused
+/* XXX Find out what to do for __packed, __aligned and __section */
+#endif
+#if __GNUC_PREREQ__(2, 7)
+#define	__pure2		__attribute__((__const__))
+#define	__unused	__attribute__((__unused__))
+#define	__packed	__attribute__((__packed__))
+#define	__aligned(x)	__attribute__((__aligned__(x)))
+#define	__section(x)	__attribute__((__section__(x)))
+#endif
+
+#if __GNUC_PREREQ__(3, 1)
+#define	__used		__attribute__((__used__))
+#else
+#if __GNUC_PREREQ__(2, 7)
+#define	__used
+#endif
+#endif
+
+#if defined(__INTEL_COMPILER)
+#define __pure2		__attribute__((__const__))
+#define __unused	__attribute__((__unused__))
+#define __used		__attribute__((__used__))
+#define __packed	__attribute__((__packed__))
+#define __aligned(x)	__attribute__((__aligned__(x)))
+#define __section(x)	__attribute__((__section__(x)))
+#endif
+#endif
+
+/*
+ * Compiler-dependent macros to declare that functions take printf-like
+ * or scanf-like arguments.  They are null except for versions of gcc
+ * that are known to support the features properly (old versions of gcc-2
+ * didn't permit keeping the keywords out of the application namespace).
+ */
+#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
+#define	__printflike(fmtarg, firstvararg)
+#define	__scanflike(fmtarg, firstvararg)
+#define	__format_arg(fmtarg)
+#else
+#define	__printflike(fmtarg, firstvararg) \
+	    __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
+#define	__scanflike(fmtarg, firstvararg) \
+	    __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
+#define	__format_arg(fmtarg)	__attribute__((__format_arg__ (fmtarg)))
+#endif
+
+#if __GNUC_PREREQ__(3, 1)
+#define	__noinline	__attribute__ ((__noinline__))
+#else
+#define	__noinline
+#endif
+
+#if __GNUC_PREREQ__(3, 3)
+#define __nonnull(x)	__attribute__((__nonnull__(x)))
+#else
+#define __nonnull(x)
+#endif
+
+/*
+ * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
+ * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
+ * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
+ * mode -- there must be no spaces between its arguments, and for nested
+ * __CONCAT's, all the __CONCAT's must be at the left.  __CONCAT can also
+ * concatenate double-quoted strings produced by the __STRING macro, but
+ * this only works with ANSI C.
+ *
+ * __XSTRING is like __STRING, but it expands any macros in its argument
+ * first.  It is only available with ANSI C.
+ */
+#if defined(__STDC__) || defined(__cplusplus)
+#define	__XSTRING(x)	__STRING(x)	/* expand x, then stringify */
+
+#define	__const		const		/* define reserved names to standard */
+#define	__signed	signed
+#define	__volatile	volatile
+#if defined(__cplusplus)
+#define	__inline	inline		/* convert to C++ keyword */
+#else
+#if !(defined(__CC_SUPPORTS___INLINE))
+#define	__inline			/* delete GCC keyword */
+#endif /* ! __CC_SUPPORTS___INLINE */
+#endif /* !__cplusplus */
+
+#else	/* !(__STDC__ || __cplusplus) */
+
+#if !defined(__CC_SUPPORTS___INLINE)
+#define	__const				/* delete pseudo-ANSI C keywords */
+#define	__inline
+#define	__signed
+#define	__volatile
+/*
+ * In non-ANSI C environments, new programs will want ANSI-only C keywords
+ * deleted from the program and old programs will want them left alone.
+ * When using a compiler other than gcc, programs using the ANSI C keywords
+ * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
+ * When using "gcc -traditional", we assume that this is the intent; if
+ * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
+ */
+#ifndef	NO_ANSI_KEYWORDS
+#define	const				/* delete ANSI C keywords */
+#define	inline
+#define	signed
+#define	volatile
+#endif	/* !NO_ANSI_KEYWORDS */
+#endif	/* !__CC_SUPPORTS___INLINE */
+#endif	/* !(__STDC__ || __cplusplus) */
+
+#ifndef	__DECONST
+#define	__DECONST(type, var)	((type)(uintptr_t)(const void *)(var))
+#endif
+
+#ifndef	__UNCONST
+#define	__UNCONST(var)	((void*)(uintptr_t)(const void *)(var))
+#endif
+
+#endif
diff --git a/headers/compatibility/freebsd/sys/libkern.h b/headers/compatibility/freebsd/sys/libkern.h
new file mode 100644
index 0000000000..ad98f4d4eb
--- /dev/null
+++ b/headers/compatibility/freebsd/sys/libkern.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2009, Colin Günther, coling@gmx.de.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _FBSD_COMPAT_SYS_LIBKERN_H_
+#define _FBSD_COMPAT_SYS_LIBKERN_H_
+
+
+#include <freebsd/sys/cdefs.h>
+#include <freebsd/sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int random(void);
+uint32_t arc4random(void);
+
+static __inline int imax(int a, int b) { return (a > b ? a : b); }
+
+extern int abs(int a);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FBSD_COMPAT_SYS_LIBKERN_H_ */
diff --git a/headers/compatibility/freebsd/sys/queue.h b/headers/compatibility/freebsd/sys/queue.h
new file mode 100644
index 0000000000..a6c6ba197b
--- /dev/null
+++ b/headers/compatibility/freebsd/sys/queue.h
@@ -0,0 +1,552 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ * $FreeBSD: src/sys/sys/queue.h,v 1.60.2.1 2005/08/16 22:41:39 phk Exp $
+ */
+#ifndef _SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+#include <freebsd/sys/cdefs.h>
+
+/*
+ * This file defines four types of data structures: singly-linked lists,
+ * singly-linked tail queues, lists and tail queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The elements
+ * are singly linked for minimum space and pointer manipulation overhead at
+ * the expense of O(n) removal for arbitrary elements. New elements can be
+ * added to the list after an existing element or at the head of the list.
+ * Elements being removed from the head of the list should use the explicit
+ * macro for this purpose for optimum efficiency. A singly-linked list may
+ * only be traversed in the forward direction.  Singly-linked lists are ideal
+ * for applications with large datasets and few or no removals or for
+ * implementing a LIFO queue.
+ *
+ * A singly-linked tail queue is headed by a pair of pointers, one to the
+ * head of the list and the other to the tail of the list. The elements are
+ * singly linked for minimum space and pointer manipulation overhead at the
+ * expense of O(n) removal for arbitrary elements. New elements can be added
+ * to the list after an existing element, at the head of the list, or at the
+ * end of the list. Elements being removed from the head of the tail queue
+ * should use the explicit macro for this purpose for optimum efficiency.
+ * A singly-linked tail queue may only be traversed in the forward direction.
+ * Singly-linked tail queues are ideal for applications with large datasets
+ * and few or no removals or for implementing a FIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ *
+ *
+ *				SLIST	LIST	STAILQ	TAILQ
+ * _HEAD			+	+	+	+
+ * _HEAD_INITIALIZER		+	+	+	+
+ * _ENTRY			+	+	+	+
+ * _INIT			+	+	+	+
+ * _EMPTY			+	+	+	+
+ * _FIRST			+	+	+	+
+ * _NEXT			+	+	+	+
+ * _PREV			-	-	-	+
+ * _LAST			-	-	+	+
+ * _FOREACH			+	+	+	+
+ * _FOREACH_SAFE		+	+	+	+
+ * _FOREACH_REVERSE		-	-	-	+
+ * _FOREACH_REVERSE_SAFE	-	-	-	+
+ * _INSERT_HEAD			+	+	+	+
+ * _INSERT_BEFORE		-	+	-	+
+ * _INSERT_AFTER		+	+	+	+
+ * _INSERT_TAIL			-	-	+	+
+ * _CONCAT			-	-	+	+
+ * _REMOVE_HEAD			+	-	+	-
+ * _REMOVE			+	+	+	+
+ *
+ */
+#define	QUEUE_MACRO_DEBUG 0
+#if QUEUE_MACRO_DEBUG
+/* Store the last 2 places the queue element or head was altered */
+struct qm_trace {
+	char * lastfile;
+	int lastline;
+	char * prevfile;
+	int prevline;
+};
+
+#define	TRACEBUF	struct qm_trace trace;
+#define	TRASHIT(x)	do {(x) = (void *)-1;} while (0)
+
+#define	QMD_TRACE_HEAD(head) do {					\
+	(head)->trace.prevline = (head)->trace.lastline;		\
+	(head)->trace.prevfile = (head)->trace.lastfile;		\
+	(head)->trace.lastline = __LINE__;				\
+	(head)->trace.lastfile = __FILE__;				\
+} while (0)
+
+#define	QMD_TRACE_ELEM(elem) do {					\
+	(elem)->trace.prevline = (elem)->trace.lastline;		\
+	(elem)->trace.prevfile = (elem)->trace.lastfile;		\
+	(elem)->trace.lastline = __LINE__;				\
+	(elem)->trace.lastfile = __FILE__;				\
+} while (0)
+
+#else
+#define	QMD_TRACE_ELEM(elem)
+#define	QMD_TRACE_HEAD(head)
+#define	TRACEBUF
+#define	TRASHIT(x)
+#endif	/* QUEUE_MACRO_DEBUG */
+
+/*
+ * Singly-linked List declarations.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+
+#define	SLIST_FIRST(head)	((head)->slh_first)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for ((var) = SLIST_FIRST((head));				\
+	    (var);							\
+	    (var) = SLIST_NEXT((var), field))
+
+#define	SLIST_FOREACH_SAFE(var, head, field, tvar)			\
+	for ((var) = SLIST_FIRST((head));				\
+	    (var) && ((tvar) = SLIST_NEXT((var), field), 1);		\
+	    (var) = (tvar))
+
+#define	SLIST_FOREACH_PREVPTR(var, varp, head, field)			\
+	for ((varp) = &SLIST_FIRST((head));				\
+	    ((var) = *(varp)) != NULL;					\
+	    (varp) = &SLIST_NEXT((var), field))
+
+#define	SLIST_INIT(head) do {						\
+	SLIST_FIRST((head)) = NULL;					\
+} while (0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field);	\
+	SLIST_NEXT((slistelm), field) = (elm);				\
+} while (0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	SLIST_NEXT((elm), field) = SLIST_FIRST((head));			\
+	SLIST_FIRST((head)) = (elm);					\
+} while (0)
+
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if (SLIST_FIRST((head)) == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = SLIST_FIRST((head));		\
+		while (SLIST_NEXT(curelm, field) != (elm))		\
+			curelm = SLIST_NEXT(curelm, field);		\
+		SLIST_NEXT(curelm, field) =				\
+		    SLIST_NEXT(SLIST_NEXT(curelm, field), field);	\
+	}								\
+} while (0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);	\
+} while (0)
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)						\
+struct name {								\
+	struct type *stqh_first;/* first element */			\
+	struct type **stqh_last;/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (0)
+
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for((var) = STAILQ_FIRST((head));				\
+	   (var);							\
+	   (var) = STAILQ_NEXT((var), field))
+
+
+#define	STAILQ_FOREACH_SAFE(var, head, field, tvar)			\
+	for ((var) = STAILQ_FIRST((head));				\
+	    (var) && ((tvar) = STAILQ_NEXT((var), field), 1);		\
+	    (var) = (tvar))
+
+#define	STAILQ_INIT(head) do {						\
+	STAILQ_FIRST((head)) = NULL;					\
+	(head)->stqh_last = &STAILQ_FIRST((head));			\
+} while (0)
+
+#define	STAILQ_INSERT_AFTER(head, tqelm, elm, field) do {		\
+	if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
+		(head)->stqh_last = &STAILQ_NEXT((elm), field);		\
+	STAILQ_NEXT((tqelm), field) = (elm);				\
+} while (0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL)	\
+		(head)->stqh_last = &STAILQ_NEXT((elm), field);		\
+	STAILQ_FIRST((head)) = (elm);					\
+} while (0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	STAILQ_NEXT((elm), field) = NULL;				\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &STAILQ_NEXT((elm), field);			\
+} while (0)
+
+#define	STAILQ_LAST(head, type, field)					\
+	(STAILQ_EMPTY((head)) ?						\
+		NULL :							\
+	        ((struct type *)					\
+		((char *)((head)->stqh_last) - __offsetof(struct type, field))))
+
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if (STAILQ_FIRST((head)) == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = STAILQ_FIRST((head));		\
+		while (STAILQ_NEXT(curelm, field) != (elm))		\
+			curelm = STAILQ_NEXT(curelm, field);		\
+		if ((STAILQ_NEXT(curelm, field) =			\
+		     STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
+			(head)->stqh_last = &STAILQ_NEXT((curelm), field);\
+	}								\
+} while (0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if ((STAILQ_FIRST((head)) =					\
+	     STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL)		\
+		(head)->stqh_last = &STAILQ_FIRST((head));		\
+} while (0)
+
+#define	STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do {			\
+	if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL)	\
+		(head)->stqh_last = &STAILQ_FIRST((head));		\
+} while (0)
+
+/*
+ * List declarations.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+
+#define	LIST_EMPTY(head)	((head)->lh_first == NULL)
+
+#define	LIST_FIRST(head)	((head)->lh_first)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = LIST_FIRST((head));				\
+	    (var);							\
+	    (var) = LIST_NEXT((var), field))
+
+#define	LIST_FOREACH_SAFE(var, head, field, tvar)			\
+	for ((var) = LIST_FIRST((head));				\
+	    (var) && ((tvar) = LIST_NEXT((var), field), 1);		\
+	    (var) = (tvar))
+
+#define	LIST_INIT(head) do {						\
+	LIST_FIRST((head)) = NULL;					\
+} while (0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
+		LIST_NEXT((listelm), field)->field.le_prev =		\
+		    &LIST_NEXT((elm), field);				\
+	LIST_NEXT((listelm), field) = (elm);				\
+	(elm)->field.le_prev = &LIST_NEXT((listelm), field);		\
+} while (0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	LIST_NEXT((elm), field) = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &LIST_NEXT((elm), field);		\
+} while (0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL)	\
+		LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
+	LIST_FIRST((head)) = (elm);					\
+	(elm)->field.le_prev = &LIST_FIRST((head));			\
+} while (0)
+
+#define	LIST_NEXT(elm, field)	((elm)->field.le_next)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if (LIST_NEXT((elm), field) != NULL)				\
+		LIST_NEXT((elm), field)->field.le_prev = 		\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = LIST_NEXT((elm), field);		\
+} while (0)
+
+/*
+ * Tail queue declarations.
+ */
+#define	TAILQ_HEAD(name, type)						\
+struct name {								\
+	struct type *tqh_first;	/* first element */			\
+	struct type **tqh_last;	/* addr of last next element */		\
+	TRACEBUF							\
+}
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	TAILQ_ENTRY(type)						\
+struct {								\
+	struct type *tqe_next;	/* next element */			\
+	struct type **tqe_prev;	/* address of previous next element */	\
+	TRACEBUF							\
+}
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+		QMD_TRACE_HEAD(head1);					\
+		QMD_TRACE_HEAD(head2);					\
+	}								\
+} while (0)
+
+#define	TAILQ_EMPTY(head)	((head)->tqh_first == NULL)
+
+#define	TAILQ_FIRST(head)	((head)->tqh_first)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = TAILQ_FIRST((head));				\
+	    (var);							\
+	    (var) = TAILQ_NEXT((var), field))
+
+#define	TAILQ_FOREACH_SAFE(var, head, field, tvar)			\
+	for ((var) = TAILQ_FIRST((head));				\
+	    (var) && ((tvar) = TAILQ_NEXT((var), field), 1);		\
+	    (var) = (tvar))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = TAILQ_LAST((head), headname);			\
+	    (var);							\
+	    (var) = TAILQ_PREV((var), headname, field))
+
+#define	TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar)	\
+	for ((var) = TAILQ_LAST((head), headname);			\
+	    (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1);	\
+	    (var) = (tvar))
+
+#define	TAILQ_INIT(head) do {						\
+	TAILQ_FIRST((head)) = NULL;					\
+	(head)->tqh_last = &TAILQ_FIRST((head));			\
+	QMD_TRACE_HEAD(head);						\
+} while (0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
+		TAILQ_NEXT((elm), field)->field.tqe_prev = 		\
+		    &TAILQ_NEXT((elm), field);				\
+	else {								\
+		(head)->tqh_last = &TAILQ_NEXT((elm), field);		\
+		QMD_TRACE_HEAD(head);					\
+	}								\
+	TAILQ_NEXT((listelm), field) = (elm);				\
+	(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field);		\
+	QMD_TRACE_ELEM(&(elm)->field);					\
+	QMD_TRACE_ELEM(&listelm->field);				\
+} while (0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	TAILQ_NEXT((elm), field) = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field);		\
+	QMD_TRACE_ELEM(&(elm)->field);					\
+	QMD_TRACE_ELEM(&listelm->field);				\
+} while (0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL)	\
+		TAILQ_FIRST((head))->field.tqe_prev =			\
+		    &TAILQ_NEXT((elm), field);				\
+	else								\
+		(head)->tqh_last = &TAILQ_NEXT((elm), field);		\
+	TAILQ_FIRST((head)) = (elm);					\
+	(elm)->field.tqe_prev = &TAILQ_FIRST((head));			\
+	QMD_TRACE_HEAD(head);						\
+	QMD_TRACE_ELEM(&(elm)->field);					\
+} while (0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	TAILQ_NEXT((elm), field) = NULL;				\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &TAILQ_NEXT((elm), field);			\
+	QMD_TRACE_HEAD(head);						\
+	QMD_TRACE_ELEM(&(elm)->field);					\
+} while (0)
+
+#define	TAILQ_LAST(head, headname)					\
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+
+#define	TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+
+#define	TAILQ_PREV(elm, headname, field)				\
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if ((TAILQ_NEXT((elm), field)) != NULL)				\
+		TAILQ_NEXT((elm), field)->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else {								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+		QMD_TRACE_HEAD(head);					\
+	}								\
+	*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field);		\
+	TRASHIT((elm)->field.tqe_next);					\
+	TRASHIT((elm)->field.tqe_prev);					\
+	QMD_TRACE_ELEM(&(elm)->field);					\
+} while (0)
+
+
+#ifdef _KERNEL
+
+/*
+ * XXX insque() and remque() are an old way of handling certain queues.
+ * They bogusly assumes that all queue heads look alike.
+ */
+
+struct quehead {
+	struct quehead *qh_link;
+	struct quehead *qh_rlink;
+};
+
+#ifdef __CC_SUPPORTS___INLINE
+
+static __inline void
+insque(void *a, void *b)
+{
+	struct quehead *element = (struct quehead *)a,
+		 *head = (struct quehead *)b;
+
+	element->qh_link = head->qh_link;
+	element->qh_rlink = head;
+	head->qh_link = element;
+	element->qh_link->qh_rlink = element;
+}
+
+static __inline void
+remque(void *a)
+{
+	struct quehead *element = (struct quehead *)a;
+
+	element->qh_link->qh_rlink = element->qh_rlink;
+	element->qh_rlink->qh_link = element->qh_link;
+	element->qh_rlink = 0;
+}
+
+#else /* !__CC_SUPPORTS___INLINE */
+
+void	insque(void *a, void *b);
+void	remque(void *a);
+
+#endif /* __CC_SUPPORTS___INLINE */
+
+#endif /* _KERNEL */
+
+#endif /* !_SYS_QUEUE_H_ */
diff --git a/headers/compatibility/freebsd/sys/systm.h b/headers/compatibility/freebsd/sys/systm.h
new file mode 100644
index 0000000000..ebd70b1ccf
--- /dev/null
+++ b/headers/compatibility/freebsd/sys/systm.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2009, Colin Günther, coling@gmx.de.
+ * Copyright 2007, Hugo Santos. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _FBSD_COMPAT_SYS_SYSTM_H_
+#define _FBSD_COMPAT_SYS_SYSTM_H_
+
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+
+#include <freebsd/machine/atomic.h>
+#include <freebsd/machine/cpufunc.h>
+
+//#include <freebsd/sys/callout.h>
+#include <freebsd/sys/cdefs.h>
+#include <freebsd/sys/_mutex.h>
+#include <freebsd/sys/queue.h>
+
+#include <freebsd/sys/libkern.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define printf freebsd_printf
+int printf(const char *format, ...) __printflike(1, 2);
+
+
+#define ovbcopy(f, t, l) bcopy((f), (t), (l))
+
+#define bootverbose 1
+
+#ifdef INVARIANTS
+#define KASSERT(cond,msg) do {	\
+	if (!(cond))				\
+		panic msg;				\
+} while (0)
+#else
+#define KASSERT(exp,msg) do { \
+} while (0)
+#endif
+
+#define DELAY(n) \
+	do {				\
+		if (n < 1000)	\
+			spin(n);	\
+		else			\
+			snooze(n);	\
+	} while (0)
+
+void wakeup(void *);
+
+#ifndef CTASSERT /* Allow lint to override */
+#define CTASSERT(x)			_CTASSERT(x, __LINE__)
+#define _CTASSERT(x, y)		__CTASSERT(x, y)
+#define __CTASSERT(x, y)	typedef char __assert ## y[(x) ? 1 : -1]
+#endif
+
+
+static inline int
+copyin(const void * __restrict udaddr, void * __restrict kaddr,
+	size_t len)
+{
+	return user_memcpy(kaddr, udaddr, len);
+}
+
+
+static inline int
+copyout(const void * __restrict kaddr, void * __restrict udaddr,
+	size_t len)
+{
+	return user_memcpy(udaddr, kaddr, len);
+}
+
+
+static inline void log(int level, const char *fmt, ...) { }
+
+
+int snprintf(char *, size_t, const char *, ...) __printflike(3, 4);
+extern int sprintf(char *buf, const char *, ...);
+
+extern void driver_vprintf(const char *format, va_list vl);
+#define vprintf(fmt, vl) driver_vprintf(fmt, vl)
+
+extern int vsnprintf(char *, size_t, const char *, __va_list)
+	__printflike(3, 0);
+
+int msleep(void *, struct mtx *, int, const char *, int);
+int _pause(const char *, int);
+#define pause(waitMessage, timeout) _pause((waitMessage), (timeout))
+#define tsleep(channel, priority, waitMessage, timeout) \
+	msleep((channel), NULL, (priority), (waitMessage), (timeout))
+
+struct unrhdr;
+struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex);
+void delete_unrhdr(struct unrhdr *);
+int alloc_unr(struct unrhdr *);
+void free_unr(struct unrhdr *, u_int);
+
+extern char *getenv(const char *name);
+extern void    freeenv(char *env);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif	/* _FBSD_COMPAT_SYS_SYSTM_H_ */
diff --git a/headers/compatibility/freebsd/sys/time.h b/headers/compatibility/freebsd/sys/time.h
new file mode 100644
index 0000000000..0c8428587d
--- /dev/null
+++ b/headers/compatibility/freebsd/sys/time.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2009, Colin Günther, coling@gmx.de.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _FBSD_COMPAT_SYS_TIME_H_
+#define _FBSD_COMPAT_SYS_TIME_H_
+
+
+#include <posix/sys/time.h>
+
+#include <freebsd/sys/_timeval.h>
+#include <sys/types.h>
+
+
+#define time_uptime (system_time() / 1000000)
+
+
+int	ppsratecheck(struct timeval*, int*, int);
+
+#endif /* _FBSD_COMPAT_SYS_TIME_H_ */
diff --git a/headers/compatibility/freebsd/sys/types.h b/headers/compatibility/freebsd/sys/types.h
new file mode 100644
index 0000000000..2823689b4a
--- /dev/null
+++ b/headers/compatibility/freebsd/sys/types.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2007 Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _FBSD_COMPAT_SYS_TYPES_H_
+#define _FBSD_COMPAT_SYS_TYPES_H_
+
+
+#include <posix/stdint.h>
+#include <posix/sys/types.h>
+
+#include <freebsd/sys/cdefs.h>
+
+#include <freebsd/machine/endian.h>
+#include <freebsd/sys/_types.h>
+
+
+typedef int boolean_t;
+typedef __const char* c_caddr_t;
+typedef uint64_t u_quad_t;
+
+#ifdef B_HAIKU_64_BIT
+
+typedef uint64_t segsz_t;
+
+#else
+
+typedef uint32_t segsz_t;
+
+#endif
+
+#endif
diff --git a/headers/compatibility/freebsd/vm/_vm_radix.h b/headers/compatibility/freebsd/vm/_vm_radix.h
new file mode 100644
index 0000000000..e5a0bb2a24
--- /dev/null
+++ b/headers/compatibility/freebsd/vm/_vm_radix.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013 EMC Corp.
+ * Copyright (c) 2011 Jeffrey Roberson <jeff@freebsd.org>
+ * Copyright (c) 2008 Mayur Shardul <mayur.shardul@gmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _FBSD_COMPAT_VM_VM_RADIX_H_
+#define _FBSD_COMPAT_VM_VM_RADIX_H_
+
+#include <freebsd/sys/types.h>
+
+/*
+ * Radix tree root.
+ */
+struct vm_radix {
+	uintptr_t	rt_root;
+};
+
+#ifdef _KERNEL
+
+static __inline boolean_t
+vm_radix_is_empty(struct vm_radix *rtree)
+{
+
+	return (rtree->rt_root == 0);
+}
+
+#endif /* _KERNEL */
+#endif /* !_FBSD_COMPAT_VM_VM_RADIX_H_ */
diff --git a/headers/compatibility/freebsd/vm/vm.h b/headers/compatibility/freebsd/vm/vm.h
new file mode 100644
index 0000000000..8e41b01bb5
--- /dev/null
+++ b/headers/compatibility/freebsd/vm/vm.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2007, Hugo Santos. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _FBSD_COMPAT_VM_VM_H_
+#define _FBSD_COMPAT_VM_VM_H_
+
+
+#include <stdint.h>
+#include <KernelExport.h>
+#include <vm/vm_types.h>
+
+#ifdef B_HAIKU_64_BIT
+
+typedef uint64_t vm_size_t;
+
+#else
+
+typedef uint32_t vm_size_t;
+
+#endif
+
+typedef char vm_inherit_t;	/* inheritance codes */
+
+#define	VM_INHERIT_SHARE	((vm_inherit_t) 0)
+#define	VM_INHERIT_COPY		((vm_inherit_t) 1)
+#define	VM_INHERIT_NONE		((vm_inherit_t) 2)
+#define	VM_INHERIT_ZERO		((vm_inherit_t) 3)
+#define	VM_INHERIT_DEFAULT	VM_INHERIT_COPY
+
+typedef u_char vm_prot_t;	/* protection codes */
+
+#define	VM_PROT_NONE		((vm_prot_t) 0x00)
+#define	VM_PROT_READ		((vm_prot_t) 0x01)
+#define	VM_PROT_WRITE		((vm_prot_t) 0x02)
+#define	VM_PROT_EXECUTE		((vm_prot_t) 0x04)
+#define	VM_PROT_COPY		((vm_prot_t) 0x08)	/* copy-on-read */
+
+#define	VM_PROT_ALL		(VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)
+#define VM_PROT_RW		(VM_PROT_READ|VM_PROT_WRITE)
+#define	VM_PROT_DEFAULT		VM_PROT_ALL
+
+typedef page_num_t vm_pindex_t;
+typedef page_num_t pfn_t;
+typedef void *pmap_t;
+typedef addr_t vm_offset_t;
+typedef phys_addr_t vm_paddr_t;
+typedef char vm_memattr_t;
+typedef u_char objtype_t;
+typedef uint64_t vm_ooffset_t;
+
+struct vm_object;
+typedef struct vm_object *vm_object_t;
+
+struct vm_map_entry;
+typedef struct vm_map_entry *vm_map_entry_t;
+
+struct vm_map;
+typedef struct vm_map *vm_map_t;
+
+typedef struct vm_page *vm_page_t;
+
+#define vmspace_pmap(...)	NULL
+#define pmap_extract(...)	NULL
+
+
+vm_paddr_t pmap_kextract(vm_offset_t virtualAddress);
+
+#define vtophys(virtualAddress) pmap_kextract((vm_offset_t)(virtualAddress))
+
+#endif	/* _FBSD_COMPAT_VM_VM_H_ */
diff --git a/headers/compatibility/freebsd/vm/vm_map.h b/headers/compatibility/freebsd/vm/vm_map.h
new file mode 100644
index 0000000000..e95869249c
--- /dev/null
+++ b/headers/compatibility/freebsd/vm/vm_map.h
@@ -0,0 +1,390 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * The Mach Operating System project at Carnegie-Mellon University.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)vm_map.h	8.9 (Berkeley) 5/17/95
+ *
+ *
+ * Copyright (c) 1987, 1990 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Authors: Avadis Tevanian, Jr., Michael Wayne Young
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ *	Virtual memory map module definitions.
+ */
+#ifndef	_FBSD_COMPAT_VM_MAP_
+#define	_FBSD_COMPAT_VM_MAP_
+
+// #include <sys/lock.h>
+// #include <sys/sx.h>
+// #include <sys/_mutex.h>
+#include <freebsd/sys/types.h>
+#include <freebsd/sys/_mutex.h>
+#include <freebsd/vm/vm.h>
+
+#include <lock.h>
+
+/*
+ *	Types defined:
+ *
+ *	vm_map_t		the high-level address map data structure.
+ *	vm_map_entry_t		an entry in an address map.
+ */
+
+typedef u_char vm_flags_t;
+typedef u_int vm_eflags_t;
+
+/*
+ *	Objects which live in maps may be either VM objects, or
+ *	another map (called a "sharing map") which denotes read-write
+ *	sharing with other maps.
+ */
+union vm_map_object {
+	struct vm_object *vm_object;	/* object object */
+	struct vm_map *sub_map;		/* belongs to another map */
+};
+
+/*
+ *	Address map entries consist of start and end addresses,
+ *	a VM object (or sharing map) and offset into that object,
+ *	and user-exported inheritance and protection information.
+ *	Also included is control information for virtual copy operations.
+ */
+struct vm_map_entry {
+	struct vm_map_entry *prev;	/* previous entry */
+	struct vm_map_entry *next;	/* next entry */
+	struct vm_map_entry *left;	/* left child in binary search tree */
+	struct vm_map_entry *right;	/* right child in binary search tree */
+	vm_offset_t start;		/* start address */
+	vm_offset_t end;		/* end address */
+	vm_offset_t avail_ssize;	/* amt can grow if this is a stack */
+	vm_offset_t next_read;		/* vaddr of the next sequential read */
+	vm_size_t adj_free;		/* amount of adjacent free space */
+	vm_size_t max_free;		/* max free space in subtree */
+	union vm_map_object object;	/* object I point to */
+	vm_ooffset_t offset;		/* offset into object */
+	vm_eflags_t eflags;		/* map entry flags */
+	vm_prot_t protection;		/* protection code */
+	vm_prot_t max_protection;	/* maximum protection */
+	vm_inherit_t inheritance;	/* inheritance */
+	uint8_t read_ahead;		/* pages in the read-ahead window */
+	int wired_count;		/* can be paged if = 0 */
+	struct ucred *cred;		/* tmp storage for creator ref */
+	struct thread *wiring_thread;
+};
+
+#define MAP_ENTRY_NOSYNC		0x0001
+#define MAP_ENTRY_IS_SUB_MAP		0x0002
+#define MAP_ENTRY_COW			0x0004
+#define MAP_ENTRY_NEEDS_COPY		0x0008
+#define MAP_ENTRY_NOFAULT		0x0010
+#define MAP_ENTRY_USER_WIRED		0x0020
+
+#define MAP_ENTRY_BEHAV_NORMAL		0x0000	/* default behavior */
+#define MAP_ENTRY_BEHAV_SEQUENTIAL	0x0040	/* expect sequential access */
+#define MAP_ENTRY_BEHAV_RANDOM		0x0080	/* expect random access */
+#define MAP_ENTRY_BEHAV_RESERVED	0x00C0	/* future use */
+
+#define MAP_ENTRY_BEHAV_MASK		0x00C0
+
+#define MAP_ENTRY_IN_TRANSITION		0x0100	/* entry being changed */
+#define MAP_ENTRY_NEEDS_WAKEUP		0x0200	/* waiters in transition */
+#define MAP_ENTRY_NOCOREDUMP		0x0400	/* don't include in a core */
+
+#define	MAP_ENTRY_GROWS_DOWN		0x1000	/* Top-down stacks */
+#define	MAP_ENTRY_GROWS_UP		0x2000	/* Bottom-up stacks */
+
+#define	MAP_ENTRY_WIRE_SKIPPED		0x4000
+#define	MAP_ENTRY_VN_WRITECNT		0x8000	/* writeable vnode mapping */
+
+// #ifdef	_KERNEL
+static __inline u_char
+vm_map_entry_behavior(vm_map_entry_t entry)
+{
+	return (entry->eflags & MAP_ENTRY_BEHAV_MASK);
+}
+
+static __inline int
+vm_map_entry_user_wired_count(vm_map_entry_t entry)
+{
+	if (entry->eflags & MAP_ENTRY_USER_WIRED)
+		return (1);
+	return (0);
+}
+
+static __inline int
+vm_map_entry_system_wired_count(vm_map_entry_t entry)
+{
+	return (entry->wired_count - vm_map_entry_user_wired_count(entry));
+}
+// #endif	/* _KERNEL */
+
+/*
+ *	A map is a set of map entries.  These map entries are
+ *	organized both as a binary search tree and as a doubly-linked
+ *	list.  Both structures are ordered based upon the start and
+ *	end addresses contained within each map entry.  Sleator and
+ *	Tarjan's top-down splay algorithm is employed to control
+ *	height imbalance in the binary search tree.
+ *
+ * List of locks
+ *	(c)	const until freed
+ */
+struct vm_map {
+	struct vm_map_entry header;	/* List of entries */
+	mutex lock;			/* Lock for map data */
+	struct mtx system_mtx;
+	int nentries;			/* Number of entries */
+	vm_size_t size;			/* virtual size */
+	u_int timestamp;		/* Version number */
+	u_char needs_wakeup;
+	u_char system_map;		/* (c) Am I a system map? */
+	vm_flags_t flags;		/* flags for this vm_map */
+	vm_map_entry_t root;		/* Root of a binary search tree */
+	pmap_t pmap;			/* (c) Physical map */
+#define	min_offset	header.start	/* (c) */
+#define	max_offset	header.end	/* (c) */
+	int busy;
+};
+
+/*
+ * vm_flags_t values
+ */
+#define MAP_WIREFUTURE		0x01	/* wire all future pages */
+#define	MAP_BUSY_WAKEUP		0x02
+
+// #ifdef	_KERNEL
+static __inline vm_offset_t
+vm_map_max(const struct vm_map *map)
+{
+	return (map->max_offset);
+}
+
+static __inline vm_offset_t
+vm_map_min(const struct vm_map *map)
+{
+	return (map->min_offset);
+}
+
+static __inline pmap_t
+vm_map_pmap(vm_map_t map)
+{
+	return (map->pmap);
+}
+
+static __inline void
+vm_map_modflags(vm_map_t map, vm_flags_t set, vm_flags_t clear)
+{
+	map->flags = (map->flags | set) & ~clear;
+}
+// #endif	/* _KERNEL */
+
+/*
+ * Shareable process virtual address space.
+ *
+ * List of locks
+ *	(c)	const until freed
+ */
+struct vmspace {
+	struct vm_map vm_map;	/* VM address map */
+	struct shmmap_state *vm_shm;	/* SYS5 shared memory private data XXX */
+	segsz_t vm_swrss;	/* resident set size before last swap */
+	segsz_t vm_tsize;	/* text size (pages) XXX */
+	segsz_t vm_dsize;	/* data size (pages) XXX */
+	segsz_t vm_ssize;	/* stack size (pages) */
+	caddr_t vm_taddr;	/* (c) user virtual address of text */
+	caddr_t vm_daddr;	/* (c) user virtual address of data */
+	caddr_t vm_maxsaddr;	/* user VA at max stack growth */
+	volatile int vm_refcnt;	/* number of references */
+};
+
+// #endif	/* _KERNEL */
+
+// #ifdef	_KERNEL
+/*
+ *	Macros:		vm_map_lock, etc.
+ *	Function:
+ *		Perform locking on the data portion of a map.  Note that
+ *		these macros mimic procedure calls returning void.  The
+ *		semicolon is supplied by the user of these macros, not
+ *		by the macros themselves.  The macros can safely be used
+ *		as unbraced elements in a higher level statement.
+ */
+
+void _vm_map_lock(vm_map_t map, const char *file, int line);
+void _vm_map_unlock(vm_map_t map, const char *file, int line);
+int _vm_map_unlock_and_wait(vm_map_t map, int timo, const char *file, int line);
+void _vm_map_lock_read(vm_map_t map, const char *file, int line);
+void _vm_map_unlock_read(vm_map_t map, const char *file, int line);
+int _vm_map_trylock(vm_map_t map, const char *file, int line);
+int _vm_map_trylock_read(vm_map_t map, const char *file, int line);
+int _vm_map_lock_upgrade(vm_map_t map, const char *file, int line);
+void _vm_map_lock_downgrade(vm_map_t map, const char *file, int line);
+int vm_map_locked(vm_map_t map);
+void vm_map_wakeup(vm_map_t map);
+void vm_map_busy(vm_map_t map);
+void vm_map_unbusy(vm_map_t map);
+void vm_map_wait_busy(vm_map_t map);
+
+#define	vm_map_lock(map)	_vm_map_lock(map, LOCK_FILE, LOCK_LINE)
+#define	vm_map_unlock(map)	_vm_map_unlock(map, LOCK_FILE, LOCK_LINE)
+#define	vm_map_unlock_and_wait(map, timo)	\
+			_vm_map_unlock_and_wait(map, timo, LOCK_FILE, LOCK_LINE)
+#define	vm_map_lock_read(map)	_vm_map_lock_read(map, LOCK_FILE, LOCK_LINE)
+#define	vm_map_unlock_read(map)	_vm_map_unlock_read(map, LOCK_FILE, LOCK_LINE)
+#define	vm_map_trylock(map)	_vm_map_trylock(map, LOCK_FILE, LOCK_LINE)
+#define	vm_map_trylock_read(map)	\
+			_vm_map_trylock_read(map, LOCK_FILE, LOCK_LINE)
+#define	vm_map_lock_upgrade(map)	\
+			_vm_map_lock_upgrade(map, LOCK_FILE, LOCK_LINE)
+#define	vm_map_lock_downgrade(map)	\
+			_vm_map_lock_downgrade(map, LOCK_FILE, LOCK_LINE)
+
+long vmspace_resident_count(struct vmspace *vmspace);
+// #endif	/* _KERNEL */
+
+
+/* XXX: number of kernel maps to statically allocate */
+#define MAX_KMAP	10
+
+/*
+ * Copy-on-write flags for vm_map operations
+ */
+#define MAP_INHERIT_SHARE	0x0001
+#define MAP_COPY_ON_WRITE	0x0002
+#define MAP_NOFAULT		0x0004
+#define MAP_PREFAULT		0x0008
+#define MAP_PREFAULT_PARTIAL	0x0010
+#define MAP_DISABLE_SYNCER	0x0020
+#define	MAP_CHECK_EXCL		0x0040
+#define MAP_DISABLE_COREDUMP	0x0100
+#define MAP_PREFAULT_MADVISE	0x0200	/* from (user) madvise request */
+#define	MAP_VN_WRITECOUNT	0x0400
+#define	MAP_STACK_GROWS_DOWN	0x1000
+#define	MAP_STACK_GROWS_UP	0x2000
+#define	MAP_ACC_CHARGED		0x4000
+#define	MAP_ACC_NO_CHARGE	0x8000
+
+/*
+ * vm_fault option flags
+ */
+#define	VM_FAULT_NORMAL	0		/* Nothing special */
+#define	VM_FAULT_WIRE	1		/* Wire the mapped page */
+#define	VM_FAULT_DIRTY	2		/* Dirty the page; use w/VM_PROT_COPY */
+
+/*
+ * Initially, mappings are slightly sequential.  The maximum window size must
+ * account for the map entry's "read_ahead" field being defined as an uint8_t.
+ */
+#define	VM_FAULT_READ_AHEAD_MIN		7
+#define	VM_FAULT_READ_AHEAD_INIT	15
+#define	VM_FAULT_READ_AHEAD_MAX		min(atop(MAXPHYS) - 1, UINT8_MAX)
+
+/*
+ * The following "find_space" options are supported by vm_map_find().
+ *
+ * For VMFS_ALIGNED_SPACE, the desired alignment is specified to
+ * the macro argument as log base 2 of the desired alignment.
+ */
+#define	VMFS_NO_SPACE		0	/* don't find; use the given range */
+#define	VMFS_ANY_SPACE		1	/* find a range with any alignment */
+#define	VMFS_OPTIMAL_SPACE	2	/* find a range with optimal alignment*/
+#define	VMFS_SUPER_SPACE	3	/* find a superpage-aligned range */
+#define	VMFS_ALIGNED_SPACE(x)	((x) << 8) /* find a range with fixed alignment */
+
+/*
+ * vm_map_wire and vm_map_unwire option flags
+ */
+#define VM_MAP_WIRE_SYSTEM	0	/* wiring in a kernel map */
+#define VM_MAP_WIRE_USER	1	/* wiring in a user map */
+
+#define VM_MAP_WIRE_NOHOLES	0	/* region must not have holes */
+#define VM_MAP_WIRE_HOLESOK	2	/* region may have holes */
+
+#define VM_MAP_WIRE_WRITE	4	/* Validate writable. */
+
+// #ifdef _KERNEL
+boolean_t vm_map_check_protection (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t);
+vm_map_t vm_map_create(pmap_t, vm_offset_t, vm_offset_t);
+int vm_map_delete(vm_map_t, vm_offset_t, vm_offset_t);
+int vm_map_find(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, vm_size_t,
+    vm_offset_t, int, vm_prot_t, vm_prot_t, int);
+int vm_map_fixed(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_size_t,
+    vm_prot_t, vm_prot_t, int);
+int vm_map_findspace (vm_map_t, vm_offset_t, vm_size_t, vm_offset_t *);
+int vm_map_inherit (vm_map_t, vm_offset_t, vm_offset_t, vm_inherit_t);
+void vm_map_init(vm_map_t, pmap_t, vm_offset_t, vm_offset_t);
+int vm_map_insert (vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_offset_t, vm_prot_t, vm_prot_t, int);
+int vm_map_lookup (vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *,
+    vm_pindex_t *, vm_prot_t *, boolean_t *);
+int vm_map_lookup_locked(vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *,
+    vm_pindex_t *, vm_prot_t *, boolean_t *);
+void vm_map_lookup_done (vm_map_t, vm_map_entry_t);
+boolean_t vm_map_lookup_entry (vm_map_t, vm_offset_t, vm_map_entry_t *);
+int vm_map_protect (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t, boolean_t);
+int vm_map_remove (vm_map_t, vm_offset_t, vm_offset_t);
+void vm_map_simplify_entry(vm_map_t map, vm_map_entry_t entry);
+void vm_map_startup (void);
+int vm_map_submap (vm_map_t, vm_offset_t, vm_offset_t, vm_map_t);
+int vm_map_sync(vm_map_t, vm_offset_t, vm_offset_t, boolean_t, boolean_t);
+int vm_map_madvise (vm_map_t, vm_offset_t, vm_offset_t, int);
+int vm_map_stack (vm_map_t, vm_offset_t, vm_size_t, vm_prot_t, vm_prot_t, int);
+int vm_map_growstack (struct proc *p, vm_offset_t addr);
+int vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end,
+    int flags);
+int vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end,
+    int flags);
+long vmspace_swap_count(struct vmspace *vmspace);
+// #endif				/* _KERNEL */
+#endif				/* _FBSD_COMPAT_VM_MAP_ */
diff --git a/headers/compatibility/freebsd/vm/vm_object.h b/headers/compatibility/freebsd/vm/vm_object.h
new file mode 100644
index 0000000000..f63a894a03
--- /dev/null
+++ b/headers/compatibility/freebsd/vm/vm_object.h
@@ -0,0 +1,668 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * The Mach Operating System project at Carnegie-Mellon University.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	from: @(#)vm_object.h	8.3 (Berkeley) 1/12/94
+ *
+ *
+ * Copyright (c) 1987, 1990 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Authors: Avadis Tevanian, Jr., Michael Wayne Young
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ *	Virtual memory object module definitions.
+ */
+
+#ifndef	_FBSD_COMPAT_VM_VM_OBJECT_
+#define	_FBSD_COMPAT_VM_VM_OBJECT_
+
+// #include <sys/queue.h>
+// #include <sys/_lock.h>
+// #include <sys/_mutex.h>
+// #include <sys/_rwlock.h>
+
+// #include <vm/_vm_radix.h>
+
+#include <lock.h>
+#include <freebsd/sys/queue.h>
+#include <freebsd/sys/types.h>
+#include <freebsd/vm/vm.h>
+#include <freebsd/vm/_vm_radix.h>
+
+/*
+ *	Types defined:
+ *
+ *	vm_object_t		Virtual memory object.
+ *
+ * List of locks
+ *	(c)	const until freed
+ *	(o)	per-object lock 
+ *	(f)	free pages queue mutex
+ *
+ */
+
+struct vm_object {
+	rw_lock lock;
+	TAILQ_ENTRY(vm_object) object_list; /* list of all objects */
+	LIST_HEAD(, vm_object) shadow_head; /* objects that this is a shadow for */
+	LIST_ENTRY(vm_object) shadow_list; /* chain of shadow objects */
+	TAILQ_HEAD(respgs, vm_page) memq; /* list of resident pages */
+	struct vm_radix rtree;		/* root of the resident page radix trie*/
+	vm_pindex_t size;		/* Object size */
+	int generation;			/* generation ID */
+	int ref_count;			/* How many refs?? */
+	int shadow_count;		/* how many objects that this is a shadow for */
+	vm_memattr_t memattr;		/* default memory attribute for pages */
+	objtype_t type;			/* type of pager */
+	u_short flags;			/* see below */
+	u_short pg_color;		/* (c) color of first page in obj */
+	u_int paging_in_progress;	/* Paging (in or out) so don't collapse or destroy */
+	int resident_page_count;	/* number of resident pages */
+	struct vm_object *backing_object; /* object that I'm a shadow of */
+	vm_ooffset_t backing_object_offset;/* Offset in backing object */
+	TAILQ_ENTRY(vm_object) pager_object_list; /* list of all objects of this pager type */
+	LIST_HEAD(, vm_reserv) rvq;	/* list of reservations */
+	void *handle;
+	union {
+		/*
+		 * VNode pager
+		 *
+		 *	vnp_size - current size of file
+		 */
+		struct {
+			off_t vnp_size;
+			vm_ooffset_t writemappings;
+		} vnp;
+
+		/*
+		 * Device pager
+		 *
+		 *	devp_pglist - list of allocated pages
+		 */
+		struct {
+			TAILQ_HEAD(, vm_page) devp_pglist;
+			struct cdev_pager_ops *ops;
+			struct cdev *dev;
+		} devp;
+
+		/*
+		 * SG pager
+		 *
+		 *	sgp_pglist - list of allocated pages
+		 */
+		struct {
+			TAILQ_HEAD(, vm_page) sgp_pglist;
+		} sgp;
+
+		/*
+		 * Swap pager
+		 *
+		 *	swp_tmpfs - back-pointer to the tmpfs vnode,
+		 *		     if any, which uses the vm object
+		 *		     as backing store.  The handle
+		 *		     cannot be reused for linking,
+		 *		     because the vnode can be
+		 *		     reclaimed and recreated, making
+		 *		     the handle changed and hash-chain
+		 *		     invalid.
+		 *
+		 *	swp_bcount - number of swap 'swblock' metablocks, each
+		 *		     contains up to 16 swapblk assignments.
+		 *		     see vm/swap_pager.h
+		 */
+		struct {
+			void *swp_tmpfs;
+			int swp_bcount;
+		} swp;
+	} un_pager;
+	struct ucred *cred;
+	vm_ooffset_t charge;
+	void *umtx_data;
+};
+
+/*
+ * Flags
+ */
+#define	OBJ_FICTITIOUS	0x0001		/* (c) contains fictitious pages */
+#define	OBJ_UNMANAGED	0x0002		/* (c) contains unmanaged pages */
+#define	OBJ_POPULATE	0x0004		/* pager implements populate() */
+#define OBJ_DEAD	0x0008		/* dead objects (during rundown) */
+#define	OBJ_NOSPLIT	0x0010		/* dont split this object */
+#define	OBJ_UMTXDEAD	0x0020		/* umtx pshared was terminated */
+#define OBJ_PIPWNT	0x0040		/* paging in progress wanted */
+#define OBJ_MIGHTBEDIRTY 0x0100		/* object might be dirty, only for vnode */
+#define	OBJ_TMPFS_NODE	0x0200		/* object belongs to tmpfs VREG node */
+#define	OBJ_TMPFS_DIRTY	0x0400		/* dirty tmpfs obj */
+#define	OBJ_COLORED	0x1000		/* pg_color is defined */
+#define	OBJ_ONEMAPPING	0x2000		/* One USE (a single, non-forked) mapping flag */
+#define	OBJ_DISCONNECTWNT 0x4000	/* disconnect from vnode wanted */
+#define	OBJ_TMPFS	0x8000		/* has tmpfs vnode allocated */
+
+/*
+ * Helpers to perform conversion between vm_object page indexes and offsets.
+ * IDX_TO_OFF() converts an index into an offset.
+ * OFF_TO_IDX() converts an offset into an index.  Since offsets are signed
+ *   by default, the sign propagation in OFF_TO_IDX(), when applied to
+ *   negative offsets, is intentional and returns a vm_object page index
+ *   that cannot be created by a userspace mapping.
+ * UOFF_TO_IDX() treats the offset as an unsigned value and converts it
+ *   into an index accordingly.  Use it only when the full range of offset
+ *   values are allowed.  Currently, this only applies to device mappings.
+ * OBJ_MAX_SIZE specifies the maximum page index corresponding to the
+ *   maximum unsigned offset.
+ */
+#define	IDX_TO_OFF(idx) (((vm_ooffset_t)(idx)) << PAGE_SHIFT)
+#define	OFF_TO_IDX(off) ((vm_pindex_t)(((vm_ooffset_t)(off)) >> PAGE_SHIFT))
+#define	UOFF_TO_IDX(off) (((vm_pindex_t)(off)) >> PAGE_SHIFT)
+#define	OBJ_MAX_SIZE	(UOFF_TO_IDX(UINT64_MAX) + 1)
+
+#ifdef	_KERNEL
+
+#define OBJPC_SYNC	0x1			/* sync I/O */
+#define OBJPC_INVAL	0x2			/* invalidate */
+#define OBJPC_NOSYNC	0x4			/* skip if VPO_NOSYNC */
+
+/*
+ * The following options are supported by vm_object_page_remove().
+ */
+#define	OBJPR_CLEANONLY	0x1		/* Don't remove dirty pages. */
+#define	OBJPR_NOTMAPPED	0x2		/* Don't unmap pages. */
+
+TAILQ_HEAD(object_q, vm_object);
+
+extern struct object_q vm_object_list;	/* list of allocated objects */
+extern struct mtx vm_object_list_mtx;	/* lock for object list and count */
+
+extern struct vm_object kernel_object_store;
+extern struct vm_object kmem_object_store;
+
+#define	kernel_object	(&kernel_object_store)
+#define	kmem_object	(&kmem_object_store)
+
+#define	VM_OBJECT_ASSERT_LOCKED(object)					\
+	rw_assert(&(object)->lock, RA_LOCKED)
+#define	VM_OBJECT_ASSERT_RLOCKED(object)				\
+	rw_assert(&(object)->lock, RA_RLOCKED)
+#define	VM_OBJECT_ASSERT_WLOCKED(object)				\
+	rw_assert(&(object)->lock, RA_WLOCKED)
+#define	VM_OBJECT_ASSERT_UNLOCKED(object)				\
+	rw_assert(&(object)->lock, RA_UNLOCKED)
+#define	VM_OBJECT_LOCK_DOWNGRADE(object)				\
+	rw_downgrade(&(object)->lock)
+#define	VM_OBJECT_RLOCK(object)						\
+	rw_rlock(&(object)->lock)
+#define	VM_OBJECT_RUNLOCK(object)					\
+	rw_runlock(&(object)->lock)
+#define	VM_OBJECT_SLEEP(object, wchan, pri, wmesg, timo)		\
+	rw_sleep((wchan), &(object)->lock, (pri), (wmesg), (timo))
+#define	VM_OBJECT_TRYRLOCK(object)					\
+	rw_try_rlock(&(object)->lock)
+#define	VM_OBJECT_TRYWLOCK(object)					\
+	rw_try_wlock(&(object)->lock)
+#define	VM_OBJECT_TRYUPGRADE(object)					\
+	rw_try_upgrade(&(object)->lock)
+#define	VM_OBJECT_WLOCK(object)						\
+	rw_wlock(&(object)->lock)
+#define	VM_OBJECT_WOWNED(object)					\
+	rw_wowned(&(object)->lock)
+#define	VM_OBJECT_WUNLOCK(object)					\
+	rw_wunlock(&(object)->lock)
+
+/*
+ *	The object must be locked or thread private.
+ */
+static __inline void
+vm_object_set_flag(vm_object_t object, u_short bits)
+{
+
+	object->flags |= bits;
+}
+
+/*
+ *	Conditionally set the object's color, which (1) enables the allocation
+ *	of physical memory reservations for anonymous objects and larger-than-
+ *	superpage-sized named objects and (2) determines the first page offset
+ *	within the object at which a reservation may be allocated.  In other
+ *	words, the color determines the alignment of the object with respect
+ *	to the largest superpage boundary.  When mapping named objects, like
+ *	files or POSIX shared memory objects, the color should be set to zero
+ *	before a virtual address is selected for the mapping.  In contrast,
+ *	for anonymous objects, the color may be set after the virtual address
+ *	is selected.
+ *
+ *	The object must be locked.
+ */
+static __inline void
+vm_object_color(vm_object_t object, u_short color)
+{
+
+	if ((object->flags & OBJ_COLORED) == 0) {
+		object->pg_color = color;
+		object->flags |= OBJ_COLORED;
+	}
+}
+
+void vm_object_clear_flag(vm_object_t object, u_short bits);
+void vm_object_pip_add(vm_object_t object, short i);
+void vm_object_pip_subtract(vm_object_t object, short i);
+void vm_object_pip_wakeup(vm_object_t object);
+void vm_object_pip_wakeupn(vm_object_t object, short i);
+void vm_object_pip_wait(vm_object_t object, char *waitid);
+
+void umtx_shm_object_init(vm_object_t object);
+void umtx_shm_object_terminated(vm_object_t object);
+extern int umtx_shm_vnobj_persistent;
+
+vm_object_t vm_object_allocate (objtype_t, vm_pindex_t);
+boolean_t vm_object_coalesce(vm_object_t, vm_ooffset_t, vm_size_t, vm_size_t,
+   boolean_t);
+void vm_object_collapse (vm_object_t);
+void vm_object_deallocate (vm_object_t);
+void vm_object_destroy (vm_object_t);
+void vm_object_terminate (vm_object_t);
+void vm_object_set_writeable_dirty (vm_object_t);
+void vm_object_init (void);
+void vm_object_madvise(vm_object_t, vm_pindex_t, vm_pindex_t, int);
+boolean_t vm_object_page_clean(vm_object_t object, vm_ooffset_t start,
+    vm_ooffset_t end, int flags);
+void vm_object_page_noreuse(vm_object_t object, vm_pindex_t start,
+    vm_pindex_t end);
+void vm_object_page_remove(vm_object_t object, vm_pindex_t start,
+    vm_pindex_t end, int options);
+boolean_t vm_object_populate(vm_object_t, vm_pindex_t, vm_pindex_t);
+void vm_object_print(long addr, boolean_t have_addr, long count, char *modif);
+void vm_object_reference (vm_object_t);
+void vm_object_reference_locked(vm_object_t);
+int  vm_object_set_memattr(vm_object_t object, vm_memattr_t memattr);
+void vm_object_shadow (vm_object_t *, vm_ooffset_t *, vm_size_t);
+void vm_object_split(vm_map_entry_t);
+boolean_t vm_object_sync(vm_object_t, vm_ooffset_t, vm_size_t, boolean_t,
+    boolean_t);
+void vm_object_unwire(vm_object_t object, vm_ooffset_t offset,
+    vm_size_t length, uint8_t queue);
+struct vnode *vm_object_vnode(vm_object_t object);
+#endif				/* _KERNEL */
+
+#endif				/* _FBSD_COMPAT_VM_VM_OBJECT_ */
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * The Mach Operating System project at Carnegie-Mellon University.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	from: @(#)vm_object.h	8.3 (Berkeley) 1/12/94
+ *
+ *
+ * Copyright (c) 1987, 1990 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Authors: Avadis Tevanian, Jr., Michael Wayne Young
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ *	Virtual memory object module definitions.
+ */
+
+#ifndef	_FBSD_COMPAT_VM_VM_OBJECT_
+#define	_FBSD_COMPAT_VM_VM_OBJECT_
+
+// #include <sys/queue.h>
+// #include <sys/_lock.h>
+// #include <sys/_mutex.h>
+// #include <sys/_rwlock.h>
+
+// #include <vm/_vm_radix.h>
+
+/*
+ *	Types defined:
+ *
+ *	vm_object_t		Virtual memory object.
+ *
+ * List of locks
+ *	(c)	const until freed
+ *	(o)	per-object lock 
+ *	(f)	free pages queue mutex
+ *
+ */
+
+struct vm_object {
+	struct rwlock lock;
+	TAILQ_ENTRY(vm_object) object_list; /* list of all objects */
+	LIST_HEAD(, vm_object) shadow_head; /* objects that this is a shadow for */
+	LIST_ENTRY(vm_object) shadow_list; /* chain of shadow objects */
+	TAILQ_HEAD(respgs, vm_page) memq; /* list of resident pages */
+	struct vm_radix rtree;		/* root of the resident page radix trie*/
+	vm_pindex_t size;		/* Object size */
+	int generation;			/* generation ID */
+	int ref_count;			/* How many refs?? */
+	int shadow_count;		/* how many objects that this is a shadow for */
+	vm_memattr_t memattr;		/* default memory attribute for pages */
+	objtype_t type;			/* type of pager */
+	u_short flags;			/* see below */
+	u_short pg_color;		/* (c) color of first page in obj */
+	u_int paging_in_progress;	/* Paging (in or out) so don't collapse or destroy */
+	int resident_page_count;	/* number of resident pages */
+	struct vm_object *backing_object; /* object that I'm a shadow of */
+	vm_ooffset_t backing_object_offset;/* Offset in backing object */
+	TAILQ_ENTRY(vm_object) pager_object_list; /* list of all objects of this pager type */
+	LIST_HEAD(, vm_reserv) rvq;	/* list of reservations */
+	void *handle;
+	union {
+		/*
+		 * VNode pager
+		 *
+		 *	vnp_size - current size of file
+		 */
+		struct {
+			off_t vnp_size;
+			vm_ooffset_t writemappings;
+		} vnp;
+
+		/*
+		 * Device pager
+		 *
+		 *	devp_pglist - list of allocated pages
+		 */
+		struct {
+			TAILQ_HEAD(, vm_page) devp_pglist;
+			struct cdev_pager_ops *ops;
+			struct cdev *dev;
+		} devp;
+
+		/*
+		 * SG pager
+		 *
+		 *	sgp_pglist - list of allocated pages
+		 */
+		struct {
+			TAILQ_HEAD(, vm_page) sgp_pglist;
+		} sgp;
+
+		/*
+		 * Swap pager
+		 *
+		 *	swp_tmpfs - back-pointer to the tmpfs vnode,
+		 *		     if any, which uses the vm object
+		 *		     as backing store.  The handle
+		 *		     cannot be reused for linking,
+		 *		     because the vnode can be
+		 *		     reclaimed and recreated, making
+		 *		     the handle changed and hash-chain
+		 *		     invalid.
+		 *
+		 *	swp_bcount - number of swap 'swblock' metablocks, each
+		 *		     contains up to 16 swapblk assignments.
+		 *		     see vm/swap_pager.h
+		 */
+		struct {
+			void *swp_tmpfs;
+			int swp_bcount;
+		} swp;
+	} un_pager;
+	struct ucred *cred;
+	vm_ooffset_t charge;
+	void *umtx_data;
+};
+
+/*
+ * Flags
+ */
+#define	OBJ_FICTITIOUS	0x0001		/* (c) contains fictitious pages */
+#define	OBJ_UNMANAGED	0x0002		/* (c) contains unmanaged pages */
+#define	OBJ_POPULATE	0x0004		/* pager implements populate() */
+#define OBJ_DEAD	0x0008		/* dead objects (during rundown) */
+#define	OBJ_NOSPLIT	0x0010		/* dont split this object */
+#define	OBJ_UMTXDEAD	0x0020		/* umtx pshared was terminated */
+#define OBJ_PIPWNT	0x0040		/* paging in progress wanted */
+#define OBJ_MIGHTBEDIRTY 0x0100		/* object might be dirty, only for vnode */
+#define	OBJ_TMPFS_NODE	0x0200		/* object belongs to tmpfs VREG node */
+#define	OBJ_TMPFS_DIRTY	0x0400		/* dirty tmpfs obj */
+#define	OBJ_COLORED	0x1000		/* pg_color is defined */
+#define	OBJ_ONEMAPPING	0x2000		/* One USE (a single, non-forked) mapping flag */
+#define	OBJ_DISCONNECTWNT 0x4000	/* disconnect from vnode wanted */
+#define	OBJ_TMPFS	0x8000		/* has tmpfs vnode allocated */
+
+/*
+ * Helpers to perform conversion between vm_object page indexes and offsets.
+ * IDX_TO_OFF() converts an index into an offset.
+ * OFF_TO_IDX() converts an offset into an index.  Since offsets are signed
+ *   by default, the sign propagation in OFF_TO_IDX(), when applied to
+ *   negative offsets, is intentional and returns a vm_object page index
+ *   that cannot be created by a userspace mapping.
+ * UOFF_TO_IDX() treats the offset as an unsigned value and converts it
+ *   into an index accordingly.  Use it only when the full range of offset
+ *   values are allowed.  Currently, this only applies to device mappings.
+ * OBJ_MAX_SIZE specifies the maximum page index corresponding to the
+ *   maximum unsigned offset.
+ */
+#define	IDX_TO_OFF(idx) (((vm_ooffset_t)(idx)) << PAGE_SHIFT)
+#define	OFF_TO_IDX(off) ((vm_pindex_t)(((vm_ooffset_t)(off)) >> PAGE_SHIFT))
+#define	UOFF_TO_IDX(off) (((vm_pindex_t)(off)) >> PAGE_SHIFT)
+#define	OBJ_MAX_SIZE	(UOFF_TO_IDX(UINT64_MAX) + 1)
+
+#ifdef	_KERNEL
+
+#define OBJPC_SYNC	0x1			/* sync I/O */
+#define OBJPC_INVAL	0x2			/* invalidate */
+#define OBJPC_NOSYNC	0x4			/* skip if VPO_NOSYNC */
+
+/*
+ * The following options are supported by vm_object_page_remove().
+ */
+#define	OBJPR_CLEANONLY	0x1		/* Don't remove dirty pages. */
+#define	OBJPR_NOTMAPPED	0x2		/* Don't unmap pages. */
+
+TAILQ_HEAD(object_q, vm_object);
+
+extern struct object_q vm_object_list;	/* list of allocated objects */
+extern struct mtx vm_object_list_mtx;	/* lock for object list and count */
+
+extern struct vm_object kernel_object_store;
+extern struct vm_object kmem_object_store;
+
+#define	kernel_object	(&kernel_object_store)
+#define	kmem_object	(&kmem_object_store)
+
+#define	VM_OBJECT_ASSERT_LOCKED(object)					\
+	rw_assert(&(object)->lock, RA_LOCKED)
+#define	VM_OBJECT_ASSERT_RLOCKED(object)				\
+	rw_assert(&(object)->lock, RA_RLOCKED)
+#define	VM_OBJECT_ASSERT_WLOCKED(object)				\
+	rw_assert(&(object)->lock, RA_WLOCKED)
+#define	VM_OBJECT_ASSERT_UNLOCKED(object)				\
+	rw_assert(&(object)->lock, RA_UNLOCKED)
+#define	VM_OBJECT_LOCK_DOWNGRADE(object)				\
+	rw_downgrade(&(object)->lock)
+#define	VM_OBJECT_RLOCK(object)						\
+	rw_rlock(&(object)->lock)
+#define	VM_OBJECT_RUNLOCK(object)					\
+	rw_runlock(&(object)->lock)
+#define	VM_OBJECT_SLEEP(object, wchan, pri, wmesg, timo)		\
+	rw_sleep((wchan), &(object)->lock, (pri), (wmesg), (timo))
+#define	VM_OBJECT_TRYRLOCK(object)					\
+	rw_try_rlock(&(object)->lock)
+#define	VM_OBJECT_TRYWLOCK(object)					\
+	rw_try_wlock(&(object)->lock)
+#define	VM_OBJECT_TRYUPGRADE(object)					\
+	rw_try_upgrade(&(object)->lock)
+#define	VM_OBJECT_WLOCK(object)						\
+	rw_wlock(&(object)->lock)
+#define	VM_OBJECT_WOWNED(object)					\
+	rw_wowned(&(object)->lock)
+#define	VM_OBJECT_WUNLOCK(object)					\
+	rw_wunlock(&(object)->lock)
+
+/*
+ *	The object must be locked or thread private.
+ */
+static __inline void
+vm_object_set_flag(vm_object_t object, u_short bits)
+{
+
+	object->flags |= bits;
+}
+
+/*
+ *	Conditionally set the object's color, which (1) enables the allocation
+ *	of physical memory reservations for anonymous objects and larger-than-
+ *	superpage-sized named objects and (2) determines the first page offset
+ *	within the object at which a reservation may be allocated.  In other
+ *	words, the color determines the alignment of the object with respect
+ *	to the largest superpage boundary.  When mapping named objects, like
+ *	files or POSIX shared memory objects, the color should be set to zero
+ *	before a virtual address is selected for the mapping.  In contrast,
+ *	for anonymous objects, the color may be set after the virtual address
+ *	is selected.
+ *
+ *	The object must be locked.
+ */
+static __inline void
+vm_object_color(vm_object_t object, u_short color)
+{
+
+	if ((object->flags & OBJ_COLORED) == 0) {
+		object->pg_color = color;
+		object->flags |= OBJ_COLORED;
+	}
+}
+
+void vm_object_clear_flag(vm_object_t object, u_short bits);
+void vm_object_pip_add(vm_object_t object, short i);
+void vm_object_pip_subtract(vm_object_t object, short i);
+void vm_object_pip_wakeup(vm_object_t object);
+void vm_object_pip_wakeupn(vm_object_t object, short i);
+void vm_object_pip_wait(vm_object_t object, char *waitid);
+
+void umtx_shm_object_init(vm_object_t object);
+void umtx_shm_object_terminated(vm_object_t object);
+extern int umtx_shm_vnobj_persistent;
+
+vm_object_t vm_object_allocate (objtype_t, vm_pindex_t);
+boolean_t vm_object_coalesce(vm_object_t, vm_ooffset_t, vm_size_t, vm_size_t,
+   boolean_t);
+void vm_object_collapse (vm_object_t);
+void vm_object_deallocate (vm_object_t);
+void vm_object_destroy (vm_object_t);
+void vm_object_terminate (vm_object_t);
+void vm_object_set_writeable_dirty (vm_object_t);
+void vm_object_init (void);
+void vm_object_madvise(vm_object_t, vm_pindex_t, vm_pindex_t, int);
+boolean_t vm_object_page_clean(vm_object_t object, vm_ooffset_t start,
+    vm_ooffset_t end, int flags);
+void vm_object_page_noreuse(vm_object_t object, vm_pindex_t start,
+    vm_pindex_t end);
+void vm_object_page_remove(vm_object_t object, vm_pindex_t start,
+    vm_pindex_t end, int options);
+boolean_t vm_object_populate(vm_object_t, vm_pindex_t, vm_pindex_t);
+void vm_object_print(long addr, boolean_t have_addr, long count, char *modif);
+void vm_object_reference (vm_object_t);
+void vm_object_reference_locked(vm_object_t);
+int  vm_object_set_memattr(vm_object_t object, vm_memattr_t memattr);
+void vm_object_shadow (vm_object_t *, vm_ooffset_t *, vm_size_t);
+void vm_object_split(vm_map_entry_t);
+boolean_t vm_object_sync(vm_object_t, vm_ooffset_t, vm_size_t, boolean_t,
+    boolean_t);
+void vm_object_unwire(vm_object_t object, vm_ooffset_t offset,
+    vm_size_t length, uint8_t queue);
+struct vnode *vm_object_vnode(vm_object_t object);
+#endif				/* _KERNEL */
+
+#endif				/* _FBSD_COMPAT_VM_VM_OBJECT_ */
diff --git a/headers/compatibility/freebsd/vm/vm_page.h b/headers/compatibility/freebsd/vm/vm_page.h
new file mode 100644
index 0000000000..a76697cef5
--- /dev/null
+++ b/headers/compatibility/freebsd/vm/vm_page.h
@@ -0,0 +1,17 @@
+#include <freebsd/vm/vm.h>
+
+#define PQ_ACTIVE 0x00
+#define PQ_NONE 0x01
+
+#define VM_PAGE_TO_PHYS(p) ((p)->physical_page_number)
+
+extern void vm_page_dirty(vm_page_t m);
+extern void vm_page_reference(vm_page_t m);
+extern void vm_page_lock(vm_page_t m);
+extern void vm_page_unlock(vm_page_t m);
+extern void vm_page_hold(vm_page_t m);
+extern void vm_page_unhold(vm_page_t m);
+extern void vm_page_wire(vm_page_t m);
+extern boolean_t vm_page_unwire(vm_page_t m, uint8_t queue);
+
+extern vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t paddr);
diff --git a/headers/compatibility/linux/agp_backend.h b/headers/compatibility/linux/agp_backend.h
new file mode 100644
index 0000000000..afb0436cf0
--- /dev/null
+++ b/headers/compatibility/linux/agp_backend.h
@@ -0,0 +1,110 @@
+/*
+ * AGPGART backend specific includes. Not for userspace consumption.
+ *
+ * Copyright (C) 2004 Silicon Graphics, Inc.
+ * Copyright (C) 2002-2003 Dave Jones
+ * Copyright (C) 1999 Jeff Hartmann
+ * Copyright (C) 1999 Precision Insight, Inc.
+ * Copyright (C) 1999 Xi Graphics, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef _LINUX_AGP_BACKEND__H
+#define _LINUX_AGP_BACKEND_H_
+
+#include <linux/list.h>
+#include <linuxkpi/linux/types.h>
+
+enum chipset_type {
+	NOT_SUPPORTED,
+	SUPPORTED,
+};
+
+struct agp_version {
+	u16 major;
+	u16 minor;
+};
+
+struct agp_kern_info {
+	struct agp_version version;
+	struct pci_dev *device;
+	enum chipset_type chipset;
+	unsigned long mode;
+	unsigned long aper_base;
+	size_t aper_size;
+	int max_memory;		/* In pages */
+	int current_memory;
+	bool cant_use_aperture;
+	unsigned long page_mask;
+	const struct vm_operations_struct *vm_ops;
+};
+
+/*
+ * The agp_memory structure has information about the block of agp memory
+ * allocated.  A caller may manipulate the next and prev pointers to link
+ * each allocated item into a list.  These pointers are ignored by the backend.
+ * Everything else should never be written to, but the caller may read any of
+ * the items to determine the status of this block of agp memory.
+ */
+
+struct agp_bridge_data;
+
+struct agp_memory {
+	struct agp_memory *next;
+	struct agp_memory *prev;
+	struct agp_bridge_data *bridge;
+	struct page **pages;
+	size_t page_count;
+	int key;
+	int num_scratch_pages;
+	off_t pg_start;
+	u32 type;
+	u32 physical;
+	bool is_bound;
+	bool is_flushed;
+	/* list of agp_memory mapped to the aperture */
+	struct list_head mapped_list;
+	/* DMA-mapped addresses */
+	struct scatterlist *sg_list;
+	int num_sg;
+};
+
+#define AGP_NORMAL_MEMORY 0
+
+#define AGP_USER_TYPES (1 << 16)
+#define AGP_USER_MEMORY (AGP_USER_TYPES)
+#define AGP_USER_CACHED_MEMORY (AGP_USER_TYPES + 1)
+
+extern struct agp_bridge_data *agp_bridge;
+extern struct list_head agp_bridges;
+
+extern struct agp_bridge_data *(*agp_find_bridge)(struct pci_dev *);
+
+extern void agp_free_memory(struct agp_memory *);
+extern struct agp_memory *agp_allocate_memory(struct agp_bridge_data *, size_t, u32);
+extern int agp_copy_info(struct agp_bridge_data *, struct agp_kern_info *);
+extern int agp_bind_memory(struct agp_memory *, off_t);
+extern int agp_unbind_memory(struct agp_memory *);
+extern void agp_enable(struct agp_bridge_data *, u32);
+extern struct agp_bridge_data *agp_backend_acquire(struct pci_dev *);
+extern void agp_backend_release(struct agp_bridge_data *);
+
+#endif				/* _LINUX_AGP_BACKEND_H_ */
diff --git a/headers/compatibility/linux/list.h b/headers/compatibility/linux/list.h
new file mode 100644
index 0000000000..48a720c81b
--- /dev/null
+++ b/headers/compatibility/linux/list.h
@@ -0,0 +1,455 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef _LINUX_LIST_H_
+#define _LINUX_LIST_H_
+
+/*
+ * Since LIST_HEAD conflicts with the linux definition we must include any
+ * FreeBSD header which requires it here so it is resolved with the correct
+ * definition prior to the undef.
+ */
+
+#include <linuxkpi/linux/compiler.h>
+#include <stddef.h>
+
+#define	prefetch(x)
+
+#define LINUX_LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LINUX_LIST_HEAD(name) \
+	struct list_head name = LINUX_LIST_HEAD_INIT(name)
+
+#ifndef LIST_HEAD_DEF
+#define	LIST_HEAD_DEF
+struct list_head {
+	struct list_head *next;
+	struct list_head *prev;
+};
+#endif
+
+static inline void
+INIT_LIST_HEAD(struct list_head *list)
+{
+
+	list->next = list->prev = list;
+}
+ 
+static inline int
+list_empty(const struct list_head *head)
+{
+
+	return (head->next == head);
+}
+
+static inline int
+list_empty_careful(const struct list_head *head)
+{
+	struct list_head *next = head->next;
+
+	return ((next == head) && (next == head->prev));
+}
+
+static inline void
+__list_del(struct list_head *prev, struct list_head *next)
+{
+	next->prev = prev;
+	WRITE_ONCE(prev->next, next);
+}
+
+static inline void
+list_del(struct list_head *entry)
+{
+
+	__list_del(entry->prev, entry->next);
+}
+
+static inline void
+list_replace(struct list_head *old, struct list_head *new)
+{
+	new->next = old->next;
+	new->next->prev = new;
+	new->prev = old->prev;
+	new->prev->next = new;
+}
+
+static inline void
+list_replace_init(struct list_head *old, struct list_head *new)
+{
+	list_replace(old, new);
+	INIT_LIST_HEAD(old);
+}
+
+static inline void
+linux_list_add(struct list_head *new, struct list_head *prev,
+    struct list_head *next)
+{
+
+	next->prev = new;
+	new->next = next;
+	new->prev = prev;
+	prev->next = new;
+}
+
+static inline void
+list_del_init(struct list_head *entry)
+{	
+
+	list_del(entry);
+	INIT_LIST_HEAD(entry);
+}
+
+#define	list_entry(ptr, type, field)	container_of(ptr, type, field)
+
+#define list_first_entry(ptr, type, member) \
+        list_entry((ptr)->next, type, member)
+
+#define	list_last_entry(ptr, type, member)	\
+	list_entry((ptr)->prev, type, member)
+
+#define	list_first_entry_or_null(ptr, type, member) \
+	(!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL)
+
+#define	list_next_entry(ptr, member)					\
+	list_entry(((ptr)->member.next), typeof(*(ptr)), member)
+
+#define	list_prev_entry(ptr, member)					\
+	list_entry(((ptr)->member.prev), typeof(*(ptr)), member)
+
+#define	list_for_each(p, head)						\
+	for (p = (head)->next; p != (head); p = (p)->next)
+
+#define	list_for_each_safe(p, n, head)					\
+	for (p = (head)->next, n = (p)->next; p != (head); p = n, n = (p)->next)
+
+#define list_for_each_entry(p, h, field)				\
+	for (p = list_entry((h)->next, typeof(*p), field); &(p)->field != (h); \
+	    p = list_entry((p)->field.next, typeof(*p), field))
+
+#define list_for_each_entry_safe(p, n, h, field)			\
+	for (p = list_entry((h)->next, typeof(*p), field), 		\
+	    n = list_entry((p)->field.next, typeof(*p), field); &(p)->field != (h);\
+	    p = n, n = list_entry(n->field.next, typeof(*n), field))
+
+#define	list_for_each_entry_from(p, h, field) \
+	for ( ; &(p)->field != (h); \
+	    p = list_entry((p)->field.next, typeof(*p), field))
+
+#define	list_for_each_entry_continue(p, h, field)			\
+	for (p = list_next_entry((p), field); &(p)->field != (h);	\
+	    p = list_next_entry((p), field))
+
+#define	list_for_each_entry_safe_from(pos, n, head, member) 			\
+	for (n = list_entry((pos)->member.next, typeof(*pos), member);		\
+	     &(pos)->member != (head);						\
+	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+#define	list_for_each_entry_reverse(p, h, field)			\
+	for (p = list_entry((h)->prev, typeof(*p), field); &(p)->field != (h); \
+	    p = list_entry((p)->field.prev, typeof(*p), field))
+
+#define	list_for_each_entry_safe_reverse(p, n, h, field)		\
+	for (p = list_entry((h)->prev, typeof(*p), field), 		\
+	    n = list_entry((p)->field.prev, typeof(*p), field); &(p)->field != (h); \
+	    p = n, n = list_entry(n->field.prev, typeof(*n), field))
+
+#define	list_for_each_entry_continue_reverse(p, h, field) \
+	for (p = list_entry((p)->field.prev, typeof(*p), field); &(p)->field != (h); \
+	    p = list_entry((p)->field.prev, typeof(*p), field))
+
+#define	list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = (p)->prev)
+
+static inline void
+list_add(struct list_head *new, struct list_head *head)
+{
+
+	linux_list_add(new, head, head->next);
+}
+
+static inline void
+list_add_tail(struct list_head *new, struct list_head *head)
+{
+
+	linux_list_add(new, head->prev, head);
+}
+
+static inline void
+list_move(struct list_head *list, struct list_head *head)
+{
+
+	list_del(list);
+	list_add(list, head);
+}
+
+static inline void
+list_move_tail(struct list_head *entry, struct list_head *head)
+{
+
+	list_del(entry);
+	list_add_tail(entry, head);
+}
+
+static inline void
+linux_list_splice(const struct list_head *list, struct list_head *prev,  
+    struct list_head *next)
+{
+	struct list_head *first;
+	struct list_head *last;
+
+	if (list_empty(list))
+		return;
+	first = list->next;
+	last = list->prev;
+	first->prev = prev;
+	prev->next = first;
+	last->next = next;
+	next->prev = last;
+}
+
+static inline void
+list_splice(const struct list_head *list, struct list_head *head)
+{
+
+	linux_list_splice(list, head, head->next);
+} 
+
+static inline void
+list_splice_tail(struct list_head *list, struct list_head *head)
+{
+
+	linux_list_splice(list, head->prev, head);
+}
+ 
+static inline void
+list_splice_init(struct list_head *list, struct list_head *head)
+{
+
+	linux_list_splice(list, head, head->next);
+	INIT_LIST_HEAD(list);   
+}
+ 
+static inline void
+list_splice_tail_init(struct list_head *list, struct list_head *head)
+{
+
+	linux_list_splice(list, head->prev, head);
+	INIT_LIST_HEAD(list);
+}
+
+#undef LIST_HEAD
+#define LIST_HEAD(name)	struct list_head name = { &(name), &(name) }
+
+
+struct hlist_head {
+	struct hlist_node *first;
+};
+
+struct hlist_node {
+	struct hlist_node *next, **pprev;
+};
+
+#define	HLIST_HEAD_INIT { }
+#define	HLIST_HEAD(name) struct hlist_head name = HLIST_HEAD_INIT
+#define	INIT_HLIST_HEAD(head) (head)->first = NULL
+#define	INIT_HLIST_NODE(node)						\
+do {									\
+	(node)->next = NULL;						\
+	(node)->pprev = NULL;						\
+} while (0)
+
+static inline int
+hlist_unhashed(const struct hlist_node *h)
+{
+
+	return !h->pprev;
+}
+
+static inline int
+hlist_empty(const struct hlist_head *h)
+{
+
+	return !h->first;
+}
+
+static inline void
+hlist_del(struct hlist_node *n)
+{
+
+        if (n->next)
+                n->next->pprev = n->pprev;
+        *n->pprev = n->next;
+}
+
+static inline void
+hlist_del_init(struct hlist_node *n)
+{
+
+	if (hlist_unhashed(n))
+		return;
+	hlist_del(n);
+	INIT_HLIST_NODE(n);
+}
+
+static inline void
+hlist_add_head(struct hlist_node *n, struct hlist_head *h)
+{
+
+	n->next = h->first;
+	if (h->first)
+		h->first->pprev = &n->next;
+	h->first = n;
+	n->pprev = &h->first;
+}
+
+static inline void
+hlist_add_before(struct hlist_node *n, struct hlist_node *next)
+{
+
+	n->pprev = next->pprev;
+	n->next = next;
+	next->pprev = &n->next;
+	*(n->pprev) = n;
+}
+ 
+static inline void
+hlist_add_after(struct hlist_node *n, struct hlist_node *next)
+{
+
+	next->next = n->next;
+	n->next = next;
+	next->pprev = &n->next;
+	if (next->next)
+		next->next->pprev = &next->next;
+}
+ 
+static inline void
+hlist_move_list(struct hlist_head *old, struct hlist_head *new)
+{
+
+	new->first = old->first;
+	if (new->first)
+		new->first->pprev = &new->first;
+	old->first = NULL;
+}
+
+/**
+ * list_is_singular - tests whether a list has just one entry.
+ * @head: the list to test.
+ */
+static inline int list_is_singular(const struct list_head *head)
+{
+	return !list_empty(head) && (head->next == head->prev);
+}
+
+static inline void __list_cut_position(struct list_head *list,
+		struct list_head *head, struct list_head *entry)
+{
+	struct list_head *new_first = entry->next;
+	list->next = head->next;
+	list->next->prev = list;
+	list->prev = entry;
+	entry->next = list;
+	head->next = new_first;
+	new_first->prev = head;
+}
+
+/**
+ * list_cut_position - cut a list into two
+ * @list: a new list to add all removed entries
+ * @head: a list with entries
+ * @entry: an entry within head, could be the head itself
+ *	and if so we won't cut the list
+ *
+ * This helper moves the initial part of @head, up to and
+ * including @entry, from @head to @list. You should
+ * pass on @entry an element you know is on @head. @list
+ * should be an empty list or a list you do not care about
+ * losing its data.
+ *
+ */
+static inline void list_cut_position(struct list_head *list,
+		struct list_head *head, struct list_head *entry)
+{
+	if (list_empty(head))
+		return;
+	if (list_is_singular(head) &&
+		(head->next != entry && head != entry))
+		return;
+	if (entry == head)
+		INIT_LIST_HEAD(list);
+	else
+		__list_cut_position(list, head, entry);
+}
+
+/**
+ *  list_is_last - tests whether @list is the last entry in list @head
+ *   @list: the entry to test
+ *    @head: the head of the list
+ */
+static inline int list_is_last(const struct list_head *list,
+                                const struct list_head *head)
+{
+        return list->next == head;
+}
+ 
+#define	hlist_entry(ptr, type, field)	container_of(ptr, type, field)
+
+#define	hlist_for_each(p, head)						\
+	for (p = (head)->first; p; p = (p)->next)
+
+#define	hlist_for_each_safe(p, n, head)					\
+	for (p = (head)->first; p && ({ n = (p)->next; 1; }); p = n)
+
+#define	hlist_entry_safe(ptr, type, member) \
+	((ptr) ? hlist_entry(ptr, type, member) : NULL)
+
+#define	hlist_for_each_entry(pos, head, member)				\
+	for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
+	     pos;							\
+	     pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
+
+#define	hlist_for_each_entry_continue(pos, member)			\
+	for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member); \
+	     (pos);							\
+	     pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
+
+#define	hlist_for_each_entry_from(pos, member)				\
+	for (; (pos);								\
+	     pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
+
+#define	hlist_for_each_entry_safe(pos, n, head, member)			\
+	for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); \
+	     (pos) && ({ n = (pos)->member.next; 1; });			\
+	     pos = hlist_entry_safe(n, typeof(*(pos)), member))
+
+extern void list_sort(void *priv, struct list_head *head, int (*cmp)(void *priv,
+    struct list_head *a, struct list_head *b));
+
+#endif /* _LINUX_LIST_H_ */
diff --git a/headers/compatibility/linuxkpi/asm/atomic.h b/headers/compatibility/linuxkpi/asm/atomic.h
new file mode 100644
index 0000000000..ee8837bda1
--- /dev/null
+++ b/headers/compatibility/linuxkpi/asm/atomic.h
@@ -0,0 +1,250 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _ASM_ATOMIC_H_
+#define	_ASM_ATOMIC_H_
+
+#include <stdint.h>
+#include <SupportDefs.h>
+#include <linux/compiler.h>
+
+#define	ATOMIC_INIT(x)	{ .counter = (x) }
+#ifndef __DECONST
+#define __DECONST(type, var) ((type)(uintptr_t)(const void*)(var))
+#endif
+
+typedef struct {
+	volatile int counter;
+} atomic_t;
+
+/*------------------------------------------------------------------------*
+ *	32-bit atomic operations
+ *------------------------------------------------------------------------*/
+
+#define	linux_atomic_add(i, v)		atomic_add_return((i), (v))
+#define	linux_atomic_sub(i, v)		atomic_sub_return((i), (v))
+#define	linux_atomic_inc_return(v)		atomic_add_return(1, (v))
+#define	linux_atomic_add_negative(i, v)	(atomic_add_return((i), (v)) < 0)
+#define	linux_atomic_add_and_test(i, v)	(atomic_add_return((i), (v)) == 0)
+#define	linux_atomic_sub_and_test(i, v)	(atomic_sub_return((i), (v)) == 0)
+#define	linux_atomic_dec_and_test(v)		(atomic_sub_return(1, (v)) == 0)
+#define	linux_atomic_inc_and_test(v)		(atomic_add_return(1, (v)) == 0)
+#define	linux_atomic_dec_return(v)		atomic_sub_return(1, (v))
+#define	linux_atomic_inc_not_zero(v)		atomic_add_unless((v), 1, 0)
+
+#define atomic_cmpset_int(p, old, new)		\
+	atomic_test_and_set((int32*)(p), (new), (old))
+
+#define atomic_load_acq_int(p)		\
+	atomic_get((int32*)(p))
+
+#define atomic_clear_int(p, v)	\
+	atomic_and((int32*)(p), (~(v)))
+
+#define atomic_swap_int(p, v)		\
+	atomic_get_and_set((int32*)(p), (v))
+
+static __inline__ int
+atomic_add_return(int i, atomic_t *v)
+{
+	return atomic_add((int32*)(&v->counter), i);
+}
+
+static __inline__ int
+atomic_sub_return(int i, atomic_t *v)
+{
+	return atomic_add((int32*)(&v->counter), -i);
+}
+
+static __inline__ void
+linux_atomic_set(atomic_t *v, int i)
+{
+	atomic_set((int32*)(&v->counter), i);
+}
+
+static __inline__ void
+atomic_set_release(atomic_t *v, int i)
+{
+	atomic_set((int32*)(&v->counter), i);
+}
+
+static __inline__ void
+atomic_set_mask(unsigned int mask, atomic_t *v)
+{
+	atomic_or((int32*)(&v->counter), (mask));
+}
+
+static __inline__ int
+atomic_read(const atomic_t *v)
+{
+	return atomic_get((int32*)(&v->counter));
+}
+
+static __inline__ int
+atomic_inc(atomic_t *v)
+{
+	return atomic_add((int32*)(&v->counter), 1);
+}
+
+static __inline__ int
+atomic_dec(atomic_t *v)
+{
+	return atomic_add((int32*)(&v->counter), -1);
+}
+
+static __inline__ int
+atomic_add_unless(atomic_t *v, int a, int u)
+{
+	int c;
+
+	for (;;) {
+		c = atomic_read(v);
+		if (unlikely(c == u))
+			break;
+		if (likely(atomic_cmpset_int(&v->counter, c, c + a)))
+			break;
+	}
+	return (c != u);
+}
+
+static __inline__ void
+atomic_clear_mask(unsigned int mask, atomic_t *v)
+{
+	atomic_clear_int(&v->counter, mask);
+}
+
+static __inline__ int
+atomic_xchg(atomic_t *v, int i)
+{
+#if defined(__i386__) || defined(__amd64__) || \
+    defined(__arm__) || defined(__aarch64__)
+	return (atomic_swap_int(&v->counter, i));
+#else
+	int ret;
+	for (;;) {
+		ret = atomic_load_acq_int(&v->counter);
+		if (atomic_cmpset_int(&v->counter, ret, i))
+			break;
+	}
+	return (ret);
+#endif
+}
+
+static __inline__ int
+atomic_cmpxchg(atomic_t *v, int old, int new)
+{
+	int ret = old;
+
+	for (;;) {
+		if (atomic_cmpset_int(&v->counter, old, new))
+			break;
+		ret = atomic_load_acq_int(&v->counter);
+		if (ret != old)
+			break;
+	}
+	return (ret);
+}
+
+#define	cmpxchg(ptr, old, new) ({				\
+	__typeof(*(ptr)) __ret;					\
+								\
+	CTASSERT(sizeof(__ret) == 1 || sizeof(__ret) == 2 ||	\
+	    sizeof(__ret) == 4 || sizeof(__ret) == 8);		\
+								\
+	__ret = (old);						\
+	switch (sizeof(__ret)) {				\
+	case 1:							\
+		while (!atomic_fcmpset_8((volatile int8_t *)(ptr), \
+		    (int8_t *)&__ret, (new)) && __ret == (old))	\
+			;					\
+		break;						\
+	case 2:							\
+		while (!atomic_fcmpset_16((volatile int16_t *)(ptr), \
+		    (int16_t *)&__ret, (new)) && __ret == (old)) \
+			;					\
+		break;						\
+	case 4:							\
+		while (!atomic_fcmpset_32((volatile int32_t *)(ptr), \
+		    (int32_t *)&__ret, (new)) && __ret == (old)) \
+			;					\
+		break;						\
+	case 8:							\
+		while (!atomic_fcmpset_64((volatile int64_t *)(ptr), \
+		    (int64_t *)&__ret, (new)) && __ret == (old)) \
+			;					\
+		break;						\
+	}							\
+	__ret;							\
+})
+
+#define	cmpxchg_relaxed(...)	cmpxchg(__VA_ARGS__)
+
+#define	xchg(ptr, v) ({						\
+	__typeof(*(ptr)) __ret;					\
+								\
+	__ret = *(ptr);						\
+	*(ptr) = v;						\
+	__ret;							\
+})
+
+#define	LINUX_ATOMIC_OP(op, c_op)				\
+static __inline__ void linux_atomic_##op(int i, atomic_t *v)		\
+{								\
+	int c, old;						\
+								\
+	c = v->counter;						\
+	while ((old = atomic_cmpxchg(v, c, c c_op i)) != c)	\
+		c = old;					\
+}
+
+#define	LINUX_ATOMIC_FETCH_OP(op, c_op)				\
+static __inline__ int linux_atomic_fetch_##op(int i, atomic_t *v)		\
+{								\
+	int c, old;						\
+								\
+	c = v->counter;						\
+	while ((old = atomic_cmpxchg(v, c, c c_op i)) != c)	\
+		c = old;					\
+								\
+	return (c);						\
+}
+
+LINUX_ATOMIC_OP(or, |)
+LINUX_ATOMIC_OP(and, &)
+LINUX_ATOMIC_OP(andnot, &~)
+LINUX_ATOMIC_OP(xor, ^)
+
+LINUX_ATOMIC_FETCH_OP(or, |)
+LINUX_ATOMIC_FETCH_OP(and, &)
+LINUX_ATOMIC_FETCH_OP(andnot, &~)
+LINUX_ATOMIC_FETCH_OP(xor, ^)
+
+#endif					/* _ASM_ATOMIC_H_ */
diff --git a/headers/compatibility/linuxkpi/asm/pgtable.h b/headers/compatibility/linuxkpi/asm/pgtable.h
new file mode 100644
index 0000000000..1df1030603
--- /dev/null
+++ b/headers/compatibility/linuxkpi/asm/pgtable.h
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef _ASM_PGTABLE_H_
+#define	_ASM_PGTABLE_H_
+
+#include <linux/page.h>
+
+typedef unsigned long	pteval_t;
+typedef unsigned long	pmdval_t;
+typedef unsigned long	pudval_t;
+typedef unsigned long	pgdval_t;
+typedef unsigned long	pgprotval_t;
+typedef struct page *pgtable_t;
+
+#endif	/* _ASM_PGTABLE_H_ */
diff --git a/headers/compatibility/linuxkpi/asm/types.h b/headers/compatibility/linuxkpi/asm/types.h
new file mode 100644
index 0000000000..b32f5a9bc4
--- /dev/null
+++ b/headers/compatibility/linuxkpi/asm/types.h
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_ASM_TYPES_H_
+#define	_ASM_TYPES_H_
+
+#include <sys/types.h>
+#include <SupportDefs.h>
+
+typedef uint8_t u8;
+typedef uint8_t __u8;
+typedef uint16_t u16;
+typedef uint16_t __u16;
+typedef uint32_t u32;
+typedef uint32_t __u32;
+typedef uint64_t u64;
+typedef uint64_t __u64;
+
+typedef int8_t s8;
+typedef int8_t __s8;
+typedef int16_t s16;
+typedef int16_t __s16;
+typedef int32_t s32;
+typedef int32_t __s32;
+typedef int64_t s64;
+typedef int64_t __s64;
+
+typedef phys_addr_t vm_paddr_t;
+
+/* DMA addresses come in generic and 64-bit flavours.  */
+typedef vm_paddr_t dma_addr_t;
+typedef vm_paddr_t dma64_addr_t;
+
+// typedef unsigned short umode_t;
+
+#endif	/* _ASM_TYPES_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/cdev.h b/headers/compatibility/linuxkpi/linux/cdev.h
new file mode 100644
index 0000000000..917695a19d
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/cdev.h
@@ -0,0 +1,84 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_CDEV_H_
+#define	_LINUX_CDEV_H_
+
+#include <linux/kdev_t.h>
+
+struct file_operations;
+struct inode;
+struct module;
+
+extern struct cdevsw linuxcdevsw;
+extern const struct kobj_type linux_cdev_ktype;
+extern const struct kobj_type linux_cdev_static_ktype;
+
+struct linux_cdev {
+};
+
+static inline void
+cdev_init(struct linux_cdev *cdev, const struct file_operations *ops)
+{
+}
+
+static inline struct linux_cdev *
+cdev_alloc(void)
+{
+	return NULL;
+}
+
+static inline void
+cdev_put(struct linux_cdev *p)
+{
+}
+
+static inline int
+cdev_add(struct linux_cdev *cdev, dev_t dev, unsigned count)
+{
+	return (0);
+}
+
+static inline int
+cdev_add_ext(struct linux_cdev *cdev, dev_t dev, uid_t uid, gid_t gid, int mode)
+{
+	return (0);
+}
+
+static inline void
+cdev_del(struct linux_cdev *cdev)
+{
+}
+
+struct linux_cdev *linux_find_cdev(const char *name, unsigned major, unsigned minor);
+
+#define	cdev	linux_cdev
+
+#endif	/* _LINUX_CDEV_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/compiler.h b/headers/compatibility/linuxkpi/linux/compiler.h
new file mode 100644
index 0000000000..389fdd76b3
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/compiler.h
@@ -0,0 +1,101 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
+ * Copyright (c) 2015 François Tigeot
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_COMPILER_H_
+#define	_LINUX_COMPILER_H_
+
+#define __user
+#define __kernel
+#define __safe
+#define __force
+#define __nocast
+#define __iomem
+#define __chk_user_ptr(x)		0
+#define __chk_io_ptr(x)			0
+#define __builtin_warning(x, y...)	(1)
+#define __acquires(x)
+#define __releases(x)
+#define __acquire(x)			0
+#define __release(x)			0
+#define __cond_lock(x,c)		(c)
+#define	__bitwise
+#define __devinitdata
+#define	__deprecated
+#define __init
+#define	__devinit
+#define	__devexit
+#define __exit
+#define	__rcu
+#define	__malloc
+#define	___stringify(...)		#__VA_ARGS__
+#define	__stringify(...)		___stringify(__VA_ARGS__)
+#define	__attribute_const__		__attribute__((__const__))
+#undef __always_inline
+#define	__always_inline			inline
+#define	____cacheline_aligned		__aligned(CACHE_LINE_SIZE)
+
+#define	likely(x)			__builtin_expect(!!(x), 1)
+#define	unlikely(x)			__builtin_expect(!!(x), 0)
+#define typeof(x)			__typeof(x)
+
+#define	uninitialized_var(x)		x = x
+#define	__always_unused			__unused
+#define	__must_check			__result_use_check
+
+#define	__printf(a,b)			__printflike(a,b)
+
+#define	barrier()			__asm__ __volatile__("": : :"memory")
+
+#define	___PASTE(a,b) a##b
+#define	__PASTE(a,b) ___PASTE(a,b)
+
+#define	ACCESS_ONCE(x)			(*(volatile __typeof(x) *)&(x))
+  
+#define	WRITE_ONCE(x,v) do {		\
+	barrier();			\
+	ACCESS_ONCE(x) = (v);		\
+	barrier();			\
+} while (0)
+
+#define	READ_ONCE(x) ({			\
+	__typeof(x) __var = ({		\
+		barrier();		\
+		ACCESS_ONCE(x);		\
+	});				\
+	barrier();			\
+	__var;				\
+})
+
+#define	lockless_dereference(p) READ_ONCE(p)
+
+#define	_AT(T,X)	((T)(X))
+
+#endif	/* _LINUX_COMPILER_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/device.h b/headers/compatibility/linuxkpi/linux/device.h
new file mode 100644
index 0000000000..12432553f0
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/device.h
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_DEVICE_H_
+#define	_LINUX_DEVICE_H_
+
+struct device;
+
+#endif	/* _LINUX_DEVICE_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/dma-attrs.h b/headers/compatibility/linuxkpi/linux/dma-attrs.h
new file mode 100644
index 0000000000..fda22822dc
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/dma-attrs.h
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_DMA_ATTR_H_
+#define	_LINUX_DMA_ATTR_H_
+
+enum dma_attr { DMA_ATTR_WRITE_BARRIER, DMA_ATTR_WEAK_ORDERING, DMA_ATTR_MAX, };
+
+#define __DMA_ATTRS_LONGS BITS_TO_LONGS(DMA_ATTR_MAX)
+
+struct dma_attrs {
+	unsigned long flags;
+};
+ 
+#define DEFINE_DMA_ATTRS(x) struct dma_attrs x = { }
+
+static inline void
+init_dma_attrs(struct dma_attrs *attrs)
+{
+	attrs->flags = 0;
+}
+
+#endif	/* _LINUX_DMA_ATTR_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/gfp.h b/headers/compatibility/linuxkpi/linux/gfp.h
new file mode 100644
index 0000000000..96eac510b9
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/gfp.h
@@ -0,0 +1,64 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_GFP_H_
+#define	_LINUX_GFP_H_
+
+#define M_WAITOK	0x01u
+#define M_NOWAIT	0x02u
+#define M_USE_RESERVE	0x04u
+#define M_ZERO	__GFP_ZERO
+
+#define	__GFP_NOWARN	0
+#define	__GFP_HIGHMEM	0
+#define	__GFP_ZERO	0x08u
+#define	__GFP_NORETRY	0
+#define	__GFP_RECLAIM   0
+#define	__GFP_RECLAIMABLE   0
+
+#define	__GFP_IO	0
+#define	__GFP_NO_KSWAPD	0
+#define	__GFP_WAIT	M_WAITOK
+#define	__GFP_DMA32	0x10u
+
+#define	GFP_NOWAIT	M_NOWAIT
+#define	GFP_ATOMIC	(M_NOWAIT | M_USE_RESERVE)
+#define	GFP_KERNEL	M_WAITOK
+#define	GFP_USER	M_WAITOK
+#define	GFP_HIGHUSER	M_WAITOK
+#define	GFP_HIGHUSER_MOVABLE	M_WAITOK
+#define	GFP_IOFS	M_NOWAIT
+#define	GFP_NOIO	M_NOWAIT
+#define	GFP_DMA32	__GFP_DMA32
+#define	GFP_TEMPORARY	M_NOWAIT
+#define	GFP_NATIVE_MASK	(M_NOWAIT | M_WAITOK | M_USE_RESERVE | M_ZERO)
+
+
+#endif	/* _LINUX_GFP_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/kdev_t.h b/headers/compatibility/linuxkpi/linux/kdev_t.h
new file mode 100644
index 0000000000..6f1b9a10de
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/kdev_t.h
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_KDEV_T_H_
+#define	_LINUX_KDEV_T_H_
+
+#include <linux/types.h>
+
+#define MAJOR(dev)      major((dev))
+#define MINOR(dev)      minor((dev))
+#define MKDEV(ma, mi)   makedev((ma), (mi))
+
+static inline uint16_t
+old_encode_dev(dev_t dev)
+{
+	return ((MAJOR(dev) << 8) | MINOR(dev));
+}
+
+#endif	/* _LINUX_KDEV_T_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/kernel.h b/headers/compatibility/linuxkpi/linux/kernel.h
new file mode 100644
index 0000000000..59d1063171
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/kernel.h
@@ -0,0 +1,433 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
+ * Copyright (c) 2014-2015 François Tigeot
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_KERNEL_H_
+#define	_LINUX_KERNEL_H_
+
+#include <linux/types.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <freebsd/sys/time.h>
+
+#define KERN_CONT       ""
+#define	KERN_EMERG	"<0>"
+#define	KERN_ALERT	"<1>"
+#define	KERN_CRIT	"<2>"
+#define	KERN_ERR	"<3>"
+#define	KERN_WARNING	"<4>"
+#define	KERN_NOTICE	"<5>"
+#define	KERN_INFO	"<6>"
+#define	KERN_DEBUG	"<7>"
+
+#define	U8_MAX		((u8)~0U)
+#define	S8_MAX		((s8)(U8_MAX >> 1))
+#define	S8_MIN		((s8)(-S8_MAX - 1))
+#define	U16_MAX		((u16)~0U)
+#define	S16_MAX		((s16)(U16_MAX >> 1))
+#define	S16_MIN		((s16)(-S16_MAX - 1))
+#define	U32_MAX		((u32)~0U)
+#define	S32_MAX		((s32)(U32_MAX >> 1))
+#define	S32_MIN		((s32)(-S32_MAX - 1))
+#define	U64_MAX		((u64)~0ULL)
+#define	S64_MAX		((s64)(U64_MAX >> 1))
+#define	S64_MIN		((s64)(-S64_MAX - 1))
+
+#define	S8_C(x)  x
+#define	U8_C(x)  x ## U
+#define	S16_C(x) x
+#define	U16_C(x) x ## U
+#define	S32_C(x) x
+#define	U32_C(x) x ## U
+#define	S64_C(x) x ## LL
+#define	U64_C(x) x ## ULL
+
+#define	BUILD_BUG_ON(x)			CTASSERT(!(x))
+#define	BUILD_BUG_ON_MSG(x, msg)	BUILD_BUG_ON(x)
+#define	BUILD_BUG_ON_NOT_POWER_OF_2(x)	BUILD_BUG_ON(!powerof2(x))
+
+#define	BUG()			panic("BUG at %s:%d", __FILE__, __LINE__)
+#define	BUG_ON(cond)		do {				\
+	if (cond) {						\
+		panic("BUG ON %s failed at %s:%d",		\
+		    __stringify(cond), __FILE__, __LINE__);	\
+	}							\
+} while (0)
+
+#define	WARN_ON(cond) ({					\
+      bool __ret = (cond);					\
+      if (__ret) {						\
+		printf("WARNING %s failed at %s:%d\n",		\
+		    __stringify(cond), __FILE__, __LINE__);	\
+      }								\
+      unlikely(__ret);						\
+})
+
+#define	WARN_ON_SMP(cond)	WARN_ON(cond)
+
+#define	WARN_ON_ONCE(cond) ({					\
+      static bool __warn_on_once;				\
+      bool __ret = (cond);					\
+      if (__ret && !__warn_on_once) {				\
+		__warn_on_once = 1;				\
+		printf("WARNING %s failed at %s:%d\n",		\
+		    __stringify(cond), __FILE__, __LINE__);	\
+      }								\
+      unlikely(__ret);						\
+})
+
+#define	oops_in_progress	SCHEDULER_STOPPED()
+
+#undef	ALIGN
+#define	ALIGN(x, y)		roundup2((x), (y))
+#undef PTR_ALIGN
+#define	PTR_ALIGN(p, a)		((__typeof(p))ALIGN((uintptr_t)(p), (a)))
+#define	DIV_ROUND_UP(x, n)	howmany(x, n)
+#define	DIV_ROUND_UP_ULL(x, n)	DIV_ROUND_UP((unsigned long long)(x), (n))
+#define	FIELD_SIZEOF(t, f)	sizeof(((t *)0)->f)
+
+#define	printk(...)		printf(__VA_ARGS__)
+#define	vprintk(f, a)		vprintf(f, a)
+
+struct va_format {
+	const char *fmt;
+	va_list *va;
+};
+
+static inline int
+vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
+{
+	ssize_t ssize = size;
+	int i;
+
+	i = vsnprintf(buf, size, fmt, args);
+
+	return ((i >= ssize) ? (ssize - 1) : i);
+}
+
+static inline int
+scnprintf(char *buf, size_t size, const char *fmt, ...)
+{
+	va_list args;
+	int i;
+
+	va_start(args, fmt);
+	i = vscnprintf(buf, size, fmt, args);
+	va_end(args);
+
+	return (i);
+}
+
+/*
+ * The "pr_debug()" and "pr_devel()" macros should produce zero code
+ * unless DEBUG is defined:
+ */
+#ifdef DEBUG
+#define pr_debug(fmt, ...) \
+        log(LOG_DEBUG, fmt, ##__VA_ARGS__)
+#define pr_devel(fmt, ...) \
+	log(LOG_DEBUG, pr_fmt(fmt), ##__VA_ARGS__)
+#else
+#define pr_debug(fmt, ...) \
+        ({ if (0) log(LOG_DEBUG, fmt, ##__VA_ARGS__); 0; })
+#define pr_devel(fmt, ...) \
+	({ if (0) log(LOG_DEBUG, pr_fmt(fmt), ##__VA_ARGS__); 0; })
+#endif
+
+#ifndef pr_fmt
+#define pr_fmt(fmt) fmt
+#endif
+
+/*
+ * Print a one-time message (analogous to WARN_ONCE() et al):
+ */
+#define printk_once(...) do {			\
+	static bool __print_once;		\
+						\
+	if (!__print_once) {			\
+		__print_once = true;		\
+		printk(__VA_ARGS__);		\
+	}					\
+} while (0)
+
+/*
+ * Log a one-time message (analogous to WARN_ONCE() et al):
+ */
+#define log_once(level,...) do {		\
+	static bool __log_once;			\
+						\
+	if (unlikely(!__log_once)) {		\
+		__log_once = true;		\
+		log(level, __VA_ARGS__);	\
+	}					\
+} while (0)
+
+#define pr_emerg(fmt, ...) \
+	log(LOG_EMERG, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_alert(fmt, ...) \
+	log(LOG_ALERT, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_crit(fmt, ...) \
+	log(LOG_CRIT, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err(fmt, ...) \
+	log(LOG_ERR, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warning(fmt, ...) \
+	log(LOG_WARNING, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warn(...) \
+	pr_warning(__VA_ARGS__)
+#define pr_warn_once(fmt, ...) \
+	log_once(LOG_WARNING, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_notice(fmt, ...) \
+	log(LOG_NOTICE, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info(fmt, ...) \
+	log(LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info_once(fmt, ...) \
+	log_once(LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_cont(fmt, ...) \
+	printk(KERN_CONT fmt, ##__VA_ARGS__)
+#define	pr_warn_ratelimited(...) do {		\
+	static linux_ratelimit_t __ratelimited;	\
+	if (linux_ratelimited(&__ratelimited))	\
+		pr_warning(__VA_ARGS__);	\
+} while (0)
+
+#ifndef WARN
+#define	WARN(condition, ...) ({			\
+        bool __ret_warn_on = (condition);	\
+        if (unlikely(__ret_warn_on))		\
+                pr_warning(__VA_ARGS__);	\
+        unlikely(__ret_warn_on);		\
+})
+#endif
+
+#ifndef WARN_ONCE
+#define	WARN_ONCE(condition, ...) ({		\
+        bool __ret_warn_on = (condition);	\
+        if (unlikely(__ret_warn_on))		\
+                pr_warn_once(__VA_ARGS__);	\
+        unlikely(__ret_warn_on);		\
+})
+#endif
+
+#define container_of(ptr, type, member)				\
+({								\
+	const __typeof(((type *)0)->member) *__p = (ptr);	\
+	(type *)((uintptr_t)__p - offsetof(type, member));	\
+})
+  
+#define	ARRAY_SIZE(x)	(sizeof(x) / sizeof((x)[0]))
+
+#define strtoq strtoll
+#define strtouq strtoull
+
+static inline unsigned long long
+simple_strtoull(const char *cp, char **endp, unsigned int base)
+{
+	return (strtouq(cp, endp, base));
+}
+
+static inline long long
+simple_strtoll(const char *cp, char **endp, unsigned int base)
+{
+	return (strtoq(cp, endp, base));
+}
+
+static inline unsigned long
+simple_strtoul(const char *cp, char **endp, unsigned int base)
+{
+	return (strtoul(cp, endp, base));
+}
+
+static inline long
+simple_strtol(const char *cp, char **endp, unsigned int base)
+{
+	return (strtol(cp, endp, base));
+}
+
+static inline int
+kstrtoul(const char *cp, unsigned int base, unsigned long *res)
+{
+	char *end;
+
+	*res = strtoul(cp, &end, base);
+
+	if (*cp == 0 || *end != 0)
+		return (-EINVAL);
+	return (0);
+}
+
+static inline int
+kstrtol(const char *cp, unsigned int base, long *res)
+{
+	char *end;
+
+	*res = strtol(cp, &end, base);
+
+	if (*cp == 0 || *end != 0)
+		return (-EINVAL);
+	return (0);
+}
+
+static inline int
+kstrtoint(const char *cp, unsigned int base, int *res)
+{
+	char *end;
+	long temp;
+
+	*res = temp = strtol(cp, &end, base);
+
+	if (*cp == 0 || *end != 0)
+		return (-EINVAL);
+	if (temp != (int)temp)
+		return (-ERANGE);
+	return (0);
+}
+
+static inline int
+kstrtouint(const char *cp, unsigned int base, unsigned int *res)
+{
+	char *end;
+	unsigned long temp;
+
+	*res = temp = strtoul(cp, &end, base);
+
+	if (*cp == 0 || *end != 0)
+		return (-EINVAL);
+	if (temp != (unsigned int)temp)
+		return (-ERANGE);
+	return (0);
+}
+
+static inline int
+kstrtou32(const char *cp, unsigned int base, u32 *res)
+{
+	char *end;
+	unsigned long temp;
+
+	*res = temp = strtoul(cp, &end, base);
+
+	if (*cp == 0 || *end != 0)
+		return (-EINVAL);
+	if (temp != (u32)temp)
+		return (-ERANGE);
+	return (0);
+}
+
+#ifndef min
+#define min(x, y)	((x) < (y) ? (x) : (y))
+#endif
+
+#ifndef max
+#define max(x, y)	((x) > (y) ? (x) : (y))
+#endif
+
+#define min3(a, b, c)	min(a, min(b,c))
+#define max3(a, b, c)	max(a, max(b,c))
+
+#define	min_t(type, x, y) ({			\
+	type __min1 = (x);			\
+	type __min2 = (y);			\
+	__min1 < __min2 ? __min1 : __min2; })
+
+#define	max_t(type, x, y) ({			\
+	type __max1 = (x);			\
+	type __max2 = (y);			\
+	__max1 > __max2 ? __max1 : __max2; })
+
+#define clamp_t(type, _x, min, max)	min_t(type, max_t(type, _x, min), max)
+#define clamp(x, lo, hi)		min( max(x,lo), hi)
+#define	clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
+
+/*
+ * This looks more complex than it should be. But we need to
+ * get the type for the ~ right in round_down (it needs to be
+ * as wide as the result!), and we want to evaluate the macro
+ * arguments just once each.
+ */
+#define __round_mask(x, y) ((__typeof__(x))((y)-1))
+#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
+#define round_down(x, y) ((x) & ~__round_mask(x, y))
+
+#define	smp_processor_id()	PCPU_GET(cpuid)
+#define	num_possible_cpus()	mp_ncpus
+#define	num_online_cpus()	mp_ncpus
+
+#if defined(__i386__) || defined(__amd64__)
+extern bool linux_cpu_has_clflush;
+#define	cpu_has_clflush		linux_cpu_has_clflush
+#endif
+
+typedef struct pm_message {
+        int event;
+} pm_message_t;
+
+/* Swap values of a and b */
+#define swap(a, b) do {			\
+	typeof(a) _swap_tmp = a;	\
+	a = b;				\
+	b = _swap_tmp;			\
+} while (0)
+
+#define	DIV_ROUND_CLOSEST(x, divisor)	(((x) + ((divisor) / 2)) / (divisor))
+
+#define	DIV_ROUND_CLOSEST_ULL(x, divisor) ({		\
+	__typeof(divisor) __d = (divisor);		\
+	unsigned long long __ret = (x) + (__d) / 2;	\
+	__ret /= __d;					\
+	__ret;						\
+})
+
+static inline uintmax_t
+mult_frac(uintmax_t x, uintmax_t multiplier, uintmax_t divisor)
+{
+	uintmax_t q = (x / divisor);
+	uintmax_t r = (x % divisor);
+
+	return ((q * multiplier) + ((r * multiplier) / divisor));
+}
+
+static inline int64_t
+abs64(int64_t x)
+{
+	return (x < 0 ? -x : x);
+}
+
+typedef struct linux_ratelimit {
+	struct timeval lasttime;
+	int counter;
+} linux_ratelimit_t;
+
+static inline bool
+linux_ratelimited(linux_ratelimit_t *rl)
+{
+	return (ppsratecheck(&rl->lasttime, &rl->counter, 1));
+}
+
+#endif	/* _LINUX_KERNEL_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/kobject.h b/headers/compatibility/linuxkpi/linux/kobject.h
new file mode 100644
index 0000000000..90a884af98
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/kobject.h
@@ -0,0 +1,148 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_KOBJECT_H_
+#define	_LINUX_KOBJECT_H_
+
+#include <linux/kernel.h>
+#include <linux/kref.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+
+struct kobject;
+struct sysctl_oid;
+
+struct kobj_type {
+	void (*release)(struct kobject *kobj);
+	const struct sysfs_ops *sysfs_ops;
+	struct attribute **default_attrs;
+};
+
+extern const struct kobj_type linux_kfree_type;
+
+struct kobject {
+	struct kobject		*parent;
+	char			*name;
+	struct kref		kref;
+	const struct kobj_type	*ktype;
+	struct list_head	entry;
+	struct sysctl_oid	*oidp;
+};
+
+extern struct kobject *mm_kobj;
+
+struct attribute {
+	const char 	*name;
+	struct module	*owner;
+	mode_t		mode;
+};
+
+struct kobj_attribute {
+        struct attribute attr;
+        ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
+                        char *buf);
+        ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
+                         const char *buf, size_t count);
+};
+
+static inline void
+kobject_init(struct kobject *kobj, const struct kobj_type *ktype)
+{
+
+	kref_init(&kobj->kref);
+	INIT_LIST_HEAD(&kobj->entry);
+	kobj->ktype = ktype;
+	kobj->oidp = NULL;
+}
+
+void linux_kobject_release(struct kref *kref);
+
+static inline void
+kobject_put(struct kobject *kobj)
+{
+
+	if (kobj)
+		kref_put(&kobj->kref, linux_kobject_release);
+}
+
+static inline struct kobject *
+kobject_get(struct kobject *kobj)
+{
+
+	if (kobj)
+		kref_get(&kobj->kref);
+	return kobj;
+}
+
+int	kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list);
+int	kobject_add(struct kobject *kobj, struct kobject *parent,
+	    const char *fmt, ...);
+
+static inline struct kobject *
+kobject_create(void)
+{
+	struct kobject *kobj;
+
+	kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
+
+	if (kobj == (NULL))
+		return (NULL);
+	kobject_init(kobj, &linux_kfree_type);
+
+	return (kobj);
+}
+
+static inline struct kobject *
+kobject_create_and_add(const char *name, struct kobject *parent)
+{
+	struct kobject *kobj;
+
+	kobj = kobject_create();
+	if (kobj == NULL)
+		return (NULL);
+	if (kobject_add(kobj, parent, "%s", name) == 0)
+		return (kobj);
+	kobject_put(kobj);
+
+	return (NULL);
+}
+
+static inline char *
+kobject_name(const struct kobject *kobj)
+{
+
+	return kobj->name;
+}
+
+int	kobject_set_name(struct kobject *kobj, const char *fmt, ...);
+int	kobject_init_and_add(struct kobject *kobj, const struct kobj_type *ktype,
+	    struct kobject *parent, const char *fmt, ...);
+
+#endif /* _LINUX_KOBJECT_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/kref.h b/headers/compatibility/linuxkpi/linux/kref.h
new file mode 100644
index 0000000000..bbb43f4753
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/kref.h
@@ -0,0 +1,116 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013 François Tigeot
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef _LINUX_KREF_H_
+#define _LINUX_KREF_H_
+
+#include <linux/refcount.h>
+#include <linux/mutex.h>
+
+#include <asm/atomic.h>
+
+#ifndef WARN_ON
+#define	WARN_ON(cond) ({					\
+	bool __ret = (cond);					\
+	if (__ret) {						\
+		printf("WARNING %s failed at %s:%d\n",		\
+			__stringify(cond), __FILE__, __LINE__);	\
+	}								\
+	unlikely(__ret);						\
+})
+#endif /* WARN_ON */
+
+struct kref {
+	atomic_t refcount;
+};
+
+static __inline void
+kref_init(struct kref *kref)
+{
+
+	refcount_init(&kref->refcount.counter, 1);
+}
+
+static __inline void
+kref_get(struct kref *kref)
+{
+
+	refcount_acquire(&kref->refcount.counter);
+}
+
+static __inline int
+kref_put(struct kref *kref, void (*rel)(struct kref *kref))
+{
+
+	if (refcount_release(&kref->refcount.counter)) {
+		rel(kref);
+		return 1;
+	}
+	return 0;
+}
+
+static __inline int
+kref_sub(struct kref *kref, unsigned int count,
+	void (*rel)(struct kref *kref))
+{
+
+	while (count--) {
+		if (refcount_release(&kref->refcount.counter)) {
+			rel(kref);
+			return 1;
+		}
+	}
+	return 0;
+}
+
+static __inline int
+kref_get_unless_zero(struct kref *kref)
+{
+	return atomic_add_unless(&kref->refcount, 1, 0);
+}
+
+static __inline int kref_put_mutex(struct kref *kref,
+	void (*release)(struct kref *kref), struct mutex *lock)
+{
+	WARN_ON(release == NULL);
+	if (unlikely(!atomic_add_unless(&kref->refcount, -1, 1))) {
+		mutex_lock(lock);
+		if (unlikely(!linux_atomic_dec_and_test(&kref->refcount))) {
+			mutex_unlock(lock);
+			return 0;
+		}
+		release(kref);
+		return 1;
+	}
+	return 0;
+}
+
+#endif /* _LINUX_KREF_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/mm.h b/headers/compatibility/linuxkpi/linux/mm.h
new file mode 100644
index 0000000000..b4a50af0c9
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/mm.h
@@ -0,0 +1,279 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
+ * Copyright (c) 2015 François Tigeot
+ * Copyright (c) 2015 Matthew Dillon <dillon@backplane.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_MM_H_
+#define	_LINUX_MM_H_
+
+#include <linux/page.h>
+// #include <linux/spinlock.h>
+// #include <linux/gfp.h>
+// #include <linux/kernel.h>
+// #include <linux/mm_types.h>
+// #include <linux/pfn.h>
+// #include <linux/list.h>
+
+#include <asm/pgtable.h>
+#include <freebsd/vm/vm_map.h>
+#include <freebsd/vm/vm_page.h>
+#include <freebsd/vm/vm_object.h>
+
+#include <arch_vm.h>
+
+#define	VM_READ			VM_PROT_READ
+#define	VM_WRITE		VM_PROT_WRITE
+#define	VM_EXEC			VM_PROT_EXECUTE
+
+#define	VM_PFNINTERNAL		(1 << 8)	/* FreeBSD private flag to vm_insert_pfn() */
+#define	VM_MIXEDMAP		(1 << 9)
+#define	VM_NORESERVE		(1 << 10)
+#define	VM_PFNMAP		(1 << 11)
+#define	VM_IO			(1 << 12)
+#define	VM_MAYWRITE		(1 << 13)
+#define	VM_DONTCOPY		(1 << 14)
+#define	VM_DONTEXPAND		(1 << 15)
+#define	VM_DONTDUMP		(1 << 16)
+
+#define	VMA_MAX_PREFAULT_RECORD	1
+
+#define	FOLL_WRITE		(1 << 0)
+#define	FOLL_FORCE		(1 << 1)
+
+#define	VM_FAULT_OOM		(1 << 0)
+#define	VM_FAULT_SIGBUS		(1 << 1)
+#define	VM_FAULT_MAJOR		(1 << 2)
+#define	VM_FAULT_WRITE		(1 << 3)
+#define	VM_FAULT_HWPOISON	(1 << 4)
+#define	VM_FAULT_HWPOISON_LARGE	(1 << 5)
+#define	VM_FAULT_SIGSEGV	(1 << 6)
+#define	VM_FAULT_NOPAGE		(1 << 7)
+#define	VM_FAULT_LOCKED		(1 << 8)
+#define	VM_FAULT_RETRY		(1 << 9)
+#define	VM_FAULT_FALLBACK	(1 << 10)
+
+#define	FAULT_FLAG_WRITE	(1 << 0)
+#define	FAULT_FLAG_MKWRITE	(1 << 1)
+#define	FAULT_FLAG_ALLOW_RETRY	(1 << 2)
+#define	FAULT_FLAG_RETRY_NOWAIT	(1 << 3)
+#define	FAULT_FLAG_KILLABLE	(1 << 4)
+#define	FAULT_FLAG_TRIED	(1 << 5)
+#define	FAULT_FLAG_USER		(1 << 6)
+#define	FAULT_FLAG_REMOTE	(1 << 7)
+#define	FAULT_FLAG_INSTRUCTION	(1 << 8)
+
+typedef int (*pte_fn_t)(linux_pte_t *, pgtable_t, unsigned long addr, void *data);
+
+struct vm_area_struct {
+	vm_offset_t vm_start;
+	vm_offset_t vm_end;
+	vm_offset_t vm_pgoff;
+	pgprot_t vm_page_prot;
+	unsigned long vm_flags;
+	struct mm_struct *vm_mm;
+	void   *vm_private_data;
+	const struct vm_operations_struct *vm_ops;
+	struct linux_file *vm_file;
+
+	/* internal operation */
+	vm_paddr_t vm_pfn;		/* PFN for memory map */
+	vm_size_t vm_len;		/* length for memory map */
+	vm_pindex_t vm_pfn_first;
+	int	vm_pfn_count;
+	int    *vm_pfn_pcount;
+	vm_object_t vm_obj;
+	vm_map_t vm_cached_map;
+	TAILQ_ENTRY(vm_area_struct) vm_entry;
+};
+
+struct vm_fault {
+	unsigned int flags;
+	pgoff_t	pgoff;
+	void   *virtual_address;	/* user-space address */
+	struct page *page;
+};
+
+struct vm_operations_struct {
+	void    (*open) (struct vm_area_struct *);
+	void    (*close) (struct vm_area_struct *);
+	int     (*fault) (struct vm_area_struct *, struct vm_fault *);
+};
+
+/*
+ * Compute log2 of the power of two rounded up count of pages
+ * needed for size bytes.
+ */
+static inline int
+get_order(unsigned long size)
+{
+	int order;
+
+	size = (size - 1) >> PAGE_SHIFT;
+	order = 0;
+	while (size) {
+		order++;
+		size >>= 1;
+	}
+	return (order);
+}
+
+static inline void *
+lowmem_page_address(struct page *page)
+{
+	return (page_address(page));
+}
+
+/*
+ * This only works via memory map operations.
+ */
+static inline int
+io_remap_pfn_range(struct vm_area_struct *vma,
+    unsigned long addr, unsigned long pfn, unsigned long size,
+    vm_memattr_t prot)
+{
+	vma->vm_page_prot = prot;
+	vma->vm_pfn = pfn;
+	vma->vm_len = size;
+
+	return (0);
+}
+
+static inline int
+apply_to_page_range(struct mm_struct *mm, unsigned long address,
+    unsigned long size, pte_fn_t fn, void *data)
+{
+	return (-ENOTSUP);
+}
+
+static inline int
+zap_vma_ptes(struct vm_area_struct *vma, unsigned long address,
+    unsigned long size)
+{
+	return (-ENOTSUP);
+}
+
+static inline int
+remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,
+    unsigned long pfn, unsigned long size, pgprot_t prot)
+{
+	return (-ENOTSUP);
+}
+
+static inline unsigned long
+vma_pages(struct vm_area_struct *vma)
+{
+	return ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT);
+}
+
+#define	offset_in_page(off)	((off) & (PAGE_SIZE - 1))
+
+static inline void
+set_page_dirty(struct vm_page *page)
+{
+	vm_page_dirty(page);
+}
+
+static inline void
+set_page_dirty_lock(struct vm_page *page)
+{
+	vm_page_lock(page);
+	vm_page_dirty(page);
+	vm_page_unlock(page);
+}
+
+static inline void
+mark_page_accessed(struct vm_page *page)
+{
+	vm_page_reference(page);
+}
+
+static inline void
+get_page(struct vm_page *page)
+{
+	vm_page_lock(page);
+	vm_page_hold(page);
+	vm_page_wire(page);
+	vm_page_unlock(page);
+}
+
+extern long
+get_user_pages(unsigned long start, unsigned long nr_pages,
+    int gup_flags, struct page **,
+    struct vm_area_struct **);
+
+extern int
+__get_user_pages_fast(unsigned long start, int nr_pages, int write,
+    struct page **);
+
+extern long
+get_user_pages_remote(struct task_struct *, struct mm_struct *,
+    unsigned long start, unsigned long nr_pages,
+    int gup_flags, struct page **,
+    struct vm_area_struct **);
+
+static inline void
+put_page(struct vm_page *page)
+{
+	vm_page_lock(page);
+	vm_page_unwire(page, PQ_ACTIVE);
+	vm_page_unhold(page);
+	vm_page_unlock(page);
+}
+
+#define	copy_highpage(to, from) pmap_copy_page(from, to)
+
+static inline pgprot_t
+vm_get_page_prot(unsigned long vm_flags)
+{
+	return (vm_flags & VM_PROT_ALL);
+}
+
+extern int vm_insert_mixed(struct vm_area_struct *, unsigned long addr, pfn_t pfn);
+
+extern int
+vm_insert_pfn(struct vm_area_struct *, unsigned long addr,
+    unsigned long pfn);
+
+extern int
+vm_insert_pfn_prot(struct vm_area_struct *, unsigned long addr,
+    unsigned long pfn, pgprot_t pgprot);
+
+static inline vm_page_t
+vmalloc_to_page(const void *addr)
+{
+	vm_paddr_t paddr;
+
+	paddr = pmap_kextract((vm_offset_t)addr);
+	return (PHYS_TO_VM_PAGE(paddr));
+}
+
+extern int is_vmalloc_addr(const void *addr);
+
+#endif					/* _LINUX_MM_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/mutex.h b/headers/compatibility/linuxkpi/linux/mutex.h
new file mode 100644
index 0000000000..3a9f822e29
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/mutex.h
@@ -0,0 +1,21 @@
+#ifndef	_LINUX_MUTEX_H_
+#define	_LINUX_MUTEX_H_
+
+#include <lock.h>
+
+typedef mutex mutex_t;
+
+#define	mutex_lock_nested(_m, _s)	mutex_lock((_m))
+#define	mutex_lock_nest_lock(_m, _s)	mutex_lock((_m))
+
+#define	mutex_init(_m) \
+	mutex_init((_m), mutex_name(#_m))
+
+#define linux_mutex_init(m, name, flags)		\
+	mutex_init_etc((m), (name), (flags))
+
+
+#define linux_mutex_destroy(m)		\
+	mutex_destroy((m))
+
+#endif					/* _LINUX_MUTEX_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/page.h b/headers/compatibility/linuxkpi/linux/page.h
new file mode 100644
index 0000000000..0ac2824337
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/page.h
@@ -0,0 +1,212 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_PAGE_H_
+#define _LINUX_PAGE_H_
+
+#include <linux/types.h>
+#include <linux/gfp.h>
+
+#include <freebsd/vm/vm.h>
+
+#include <KernelExport.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef PAGE_SIZE
+#include <kernel.h>
+#define PAGE_SIZE B_PAGE_SIZE
+#endif
+
+#define vm_memattr_t		uint32
+#define VM_MEMATTR_DEFAULT	B_MTR_WB
+typedef unsigned long linux_pte_t;
+typedef unsigned long linux_pmd_t;
+typedef unsigned long linux_pgd_t;
+typedef unsigned long pgprot_t;
+
+#define page	vm_page
+
+#define	LINUXKPI_PROT_VALID (1 << 4)
+#define	LINUXKPI_CACHE_MODE_SHIFT 3
+
+static inline pgprot_t
+cachemode2protval(vm_memattr_t attr)
+{
+	return ((attr | LINUXKPI_PROT_VALID) << LINUXKPI_CACHE_MODE_SHIFT);
+}
+
+static inline vm_memattr_t
+pgprot2cachemode(pgprot_t prot)
+{
+	int val;
+
+	val = prot >> LINUXKPI_CACHE_MODE_SHIFT;
+
+	if (val & LINUXKPI_PROT_VALID)
+		return (val & ~LINUXKPI_PROT_VALID);
+	else
+		return (VM_MEMATTR_DEFAULT);
+}
+
+#define	virt_to_page(x)		PHYS_TO_VM_PAGE(vtophys((x)))
+#define	page_to_pfn(pp)		(VM_PAGE_TO_PHYS((pp)) >> PAGE_SHIFT)
+#define	pfn_to_page(pfn)	(PHYS_TO_VM_PAGE((pfn) << PAGE_SHIFT))
+#define	nth_page(page,n)	pfn_to_page(page_to_pfn((page)) + (n))
+
+#define	clear_page(page)		memset((page), 0, PAGE_SIZE)
+#define	pgprot_noncached(prot)		((pgprot_t)VM_MEMATTR_UNCACHEABLE)
+#define	pgprot_writecombine(prot)	((pgprot_t)VM_MEMATTR_WRITE_COMBINING)
+
+#undef	PAGE_MASK
+#define	PAGE_MASK	(~(PAGE_SIZE-1))
+/*
+ * Modifying PAGE_MASK in the above way breaks trunc_page, round_page,
+ * and btoc macros. Therefore, redefine them in a way that makes sense
+ * so the LinuxKPI consumers don't get totally broken behavior.
+ */
+#undef	btoc
+#define	btoc(x)	(((vm_offset_t)(x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
+#undef	round_page
+#define	round_page(x)	((((uintptr_t)(x)) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
+#undef	trunc_page
+#define	trunc_page(x)	((uintptr_t)(x) & ~(PAGE_SIZE - 1))
+
+/*
+ * Resolve a page into a virtual address:
+ *
+ * NOTE: This function only works for pages allocated by the kernel.
+ */
+extern void *linux_page_address(struct page *);
+
+#define	page_address(page) linux_page_address(page)
+
+/*
+ * Page management for unmapped pages:
+ */
+extern vm_page_t linux_alloc_pages(gfp_t flags, unsigned int order);
+extern void linux_free_pages(vm_page_t page, unsigned int order);
+
+static inline struct page *
+alloc_page(gfp_t flags)
+{
+
+	return (linux_alloc_pages(flags, 0));
+}
+
+static inline struct page *
+alloc_pages(gfp_t flags, unsigned int order)
+{
+
+	return (linux_alloc_pages(flags, order));
+}
+
+static inline struct page *
+alloc_pages_node(int node_id, gfp_t flags, unsigned int order)
+{
+
+	return (linux_alloc_pages(flags, order));
+}
+
+static inline void
+__free_pages(struct page *page, unsigned int order)
+{
+
+	linux_free_pages(page, order);
+}
+
+static inline void
+__free_page(struct page *page)
+{
+
+	linux_free_pages(page, 0);
+}
+
+/*
+ * Page management for mapped pages:
+ */
+extern vm_offset_t linux_alloc_kmem(gfp_t flags, unsigned int order);
+extern void linux_free_kmem(vm_offset_t, unsigned int order);
+
+static inline vm_offset_t
+get_zeroed_page(gfp_t flags)
+{
+
+	return (linux_alloc_kmem(flags | __GFP_ZERO, 0));
+}
+
+static inline vm_offset_t
+__get_free_page(gfp_t flags)
+{
+
+	return (linux_alloc_kmem(flags, 0));
+}
+
+static inline vm_offset_t
+__get_free_pages(gfp_t flags, unsigned int order)
+{
+
+	return (linux_alloc_kmem(flags, order));
+}
+
+static inline void
+free_pages(uintptr_t addr, unsigned int order)
+{
+	if (addr == 0)
+		return;
+
+	linux_free_kmem(addr, order);
+}
+
+static inline void
+free_page(uintptr_t addr)
+{
+	if (addr == 0)
+		return;
+
+	linux_free_kmem(addr, 0);
+}
+
+static inline bool
+gfpflags_allow_blocking(const gfp_t gfp_flags)
+{
+	return ((gfp_flags & (M_WAITOK | M_NOWAIT)) == M_WAITOK);
+}
+
+#define	SetPageReserved(page)	do { } while (0)	/* NOP */
+#define	ClearPageReserved(page)	do { } while (0)	/* NOP */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif	/* _LINUX_PAGE_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/refcount.h b/headers/compatibility/linuxkpi/linux/refcount.h
new file mode 100644
index 0000000000..f6cf619a19
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/refcount.h
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (c) 2005 John Baldwin <jhb@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __SYS_REFCOUNT_H__
+#define __SYS_REFCOUNT_H__
+
+// #include <sys/limits.h>
+// #include <freebsd/machine/atomic.h>
+#include <sys/types.h>
+#include <limits.h>
+
+#ifdef _KERNEL
+#include <freebsd/sys/systm.h>
+#else
+#define	KASSERT(exp, msg)	/* */
+#endif
+
+#define atomic_add_acq_int(value, addValue) __atomic_fetch_add((value), (addValue), __ATOMIC_ACQUIRE)
+#define atomic_fetchadd_int(value, addValue) __atomic_fetch_add((value), (addValue), __ATOMIC_ACQUIRE)
+
+static __inline void
+refcount_init(volatile int *count, int value)
+{
+
+	*count = value;
+}
+
+static __inline void
+refcount_acquire(volatile int *count)
+{
+
+	KASSERT(*count < UINT_MAX, ("refcount %p overflowed", count));
+	atomic_add_acq_int(count, 1);	
+}
+
+static __inline int
+refcount_release(volatile int *count)
+{
+	int old;
+
+	/* XXX: Should this have a rel membar? */
+	old = atomic_fetchadd_int(count, -1);
+	KASSERT(old > 0, ("negative refcount %p", count));
+	return (old == 1);
+}
+
+#endif	/* ! __SYS_REFCOUNT_H__ */
diff --git a/headers/compatibility/linuxkpi/linux/scatterlist.h b/headers/compatibility/linuxkpi/linux/scatterlist.h
new file mode 100644
index 0000000000..86529b9ee4
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/scatterlist.h
@@ -0,0 +1,436 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
+ * Copyright (c) 2015 Matthew Dillon <dillon@backplane.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_SCATTERLIST_H_
+#define	_LINUX_SCATTERLIST_H_
+
+#include <freebsd/sys/systm.h>
+#include <linux/page.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef min
+#define min(a, b) ((a) < (b)) ? (a) : (b)
+#endif
+
+struct scatterlist {
+	unsigned long page_link;
+#define	SG_PAGE_LINK_CHAIN	0x1UL
+#define	SG_PAGE_LINK_LAST	0x2UL
+#define	SG_PAGE_LINK_MASK	0x3UL
+	unsigned int offset;
+	unsigned int length;
+	dma_addr_t address;
+};
+
+CTASSERT((sizeof(struct scatterlist) & SG_PAGE_LINK_MASK) == 0);
+
+struct sg_table {
+	struct scatterlist *sgl;
+	unsigned int nents;
+	unsigned int orig_nents;
+};
+
+struct sg_page_iter {
+	struct scatterlist *sg;
+	unsigned int sg_pgoffset;
+	unsigned int maxents;
+	struct {
+		unsigned int nents;
+		int	pg_advance;
+	} internal;
+};
+
+#define	SG_MAX_SINGLE_ALLOC	(PAGE_SIZE / sizeof(struct scatterlist))
+
+#define	SG_MAGIC		0x87654321UL
+
+#define	sg_is_chain(sg)		((sg)->page_link & SG_PAGE_LINK_CHAIN)
+#define	sg_is_last(sg)		((sg)->page_link & SG_PAGE_LINK_LAST)
+#define	sg_chain_ptr(sg)	\
+	((struct scatterlist *) ((sg)->page_link & ~SG_PAGE_LINK_MASK))
+
+#define	sg_dma_address(sg)	(sg)->address
+#define	sg_dma_len(sg)		(sg)->length
+
+#define	for_each_sg_page(sgl, iter, nents, pgoffset)			\
+	for (_sg_iter_init(sgl, iter, nents, pgoffset);			\
+	     (iter)->sg; _sg_iter_next(iter))
+
+#define	for_each_sg(sglist, sg, sgmax, iter)				\
+	for (iter = 0, sg = (sglist); iter < (sgmax); iter++, sg = sg_next(sg))
+
+typedef struct scatterlist *(sg_alloc_fn) (unsigned int, gfp_t);
+typedef void (sg_free_fn) (struct scatterlist *, unsigned int);
+
+static inline void
+sg_assign_page(struct scatterlist *sg, struct page *page)
+{
+	unsigned long page_link = sg->page_link & SG_PAGE_LINK_MASK;
+
+	sg->page_link = page_link | (unsigned long)page;
+}
+
+static inline void
+sg_set_page(struct scatterlist *sg, struct page *page, unsigned int len,
+    unsigned int offset)
+{
+	sg_assign_page(sg, page);
+	sg->offset = offset;
+	sg->length = len;
+}
+
+static inline struct page *
+sg_page(struct scatterlist *sg)
+{
+	return ((struct page *)((sg)->page_link & ~SG_PAGE_LINK_MASK));
+}
+
+static inline void
+sg_set_buf(struct scatterlist *sg, const void *buf, unsigned int buflen)
+{
+	sg_set_page(sg, virt_to_page(buf), buflen,
+	    ((uintptr_t)buf) & (PAGE_SIZE - 1));
+}
+
+static inline struct scatterlist *
+sg_next(struct scatterlist *sg)
+{
+	if (sg_is_last(sg))
+		return (NULL);
+	sg++;
+	if (sg_is_chain(sg))
+		sg = sg_chain_ptr(sg);
+	return (sg);
+}
+
+static inline vm_paddr_t
+sg_phys(struct scatterlist *sg)
+{
+	return (VM_PAGE_TO_PHYS(sg_page(sg)) + sg->offset);
+}
+
+static inline void
+sg_chain(struct scatterlist *prv, unsigned int prv_nents,
+    struct scatterlist *sgl)
+{
+	struct scatterlist *sg = &prv[prv_nents - 1];
+
+	sg->offset = 0;
+	sg->length = 0;
+	sg->page_link = ((unsigned long)sgl |
+	    SG_PAGE_LINK_CHAIN) & ~SG_PAGE_LINK_LAST;
+}
+
+static inline void
+sg_mark_end(struct scatterlist *sg)
+{
+	sg->page_link |= SG_PAGE_LINK_LAST;
+	sg->page_link &= ~SG_PAGE_LINK_CHAIN;
+}
+
+static inline void
+sg_init_table(struct scatterlist *sg, unsigned int nents)
+{
+	bzero(sg, sizeof(*sg) * nents);
+	sg_mark_end(&sg[nents - 1]);
+}
+
+static struct scatterlist *
+sg_kmalloc(unsigned int nents, gfp_t gfp_mask)
+{
+	if (nents == SG_MAX_SINGLE_ALLOC) {
+		return ((scatterlist *)__get_free_page(gfp_mask));
+	} else
+		return (scatterlist *)(kmalloc(nents * sizeof(struct scatterlist), gfp_mask));
+}
+
+static inline void
+sg_kfree(struct scatterlist *sg, unsigned int nents)
+{
+	if (nents == SG_MAX_SINGLE_ALLOC) {
+		free_page((unsigned long)sg);
+	} else
+		kfree(sg);
+}
+
+static inline void
+__sg_free_table(struct sg_table *table, unsigned int max_ents,
+    bool skip_first_chunk, sg_free_fn * free_fn)
+{
+	struct scatterlist *sgl, *next;
+
+	if (unlikely(!table->sgl))
+		return;
+
+	sgl = table->sgl;
+	while (table->orig_nents) {
+		unsigned int alloc_size = table->orig_nents;
+		unsigned int sg_size;
+
+		if (alloc_size > max_ents) {
+			next = sg_chain_ptr(&sgl[max_ents - 1]);
+			alloc_size = max_ents;
+			sg_size = alloc_size - 1;
+		} else {
+			sg_size = alloc_size;
+			next = NULL;
+		}
+
+		table->orig_nents -= sg_size;
+		if (skip_first_chunk)
+			skip_first_chunk = 0;
+		else
+			free_fn(sgl, alloc_size);
+		sgl = next;
+	}
+
+	table->sgl = NULL;
+}
+
+static inline void
+sg_free_table(struct sg_table *table)
+{
+	__sg_free_table(table, SG_MAX_SINGLE_ALLOC, 0, sg_kfree);
+}
+
+static inline int
+__sg_alloc_table(struct sg_table *table, unsigned int nents,
+    unsigned int max_ents, struct scatterlist *first_chunk,
+    gfp_t gfp_mask, sg_alloc_fn *alloc_fn)
+{
+	struct scatterlist *sg, *prv;
+	unsigned int left;
+
+	memset(table, 0, sizeof(*table));
+
+	if (nents == 0)
+		return (-EINVAL);
+	left = nents;
+	prv = NULL;
+	do {
+		unsigned int sg_size;
+		unsigned int alloc_size = left;
+
+		if (alloc_size > max_ents) {
+			alloc_size = max_ents;
+			sg_size = alloc_size - 1;
+		} else
+			sg_size = alloc_size;
+
+		left -= sg_size;
+
+		if (first_chunk) {
+			sg = first_chunk;
+			first_chunk = NULL;
+		} else {
+			sg = alloc_fn(alloc_size, gfp_mask);
+		}
+		if (unlikely(!sg)) {
+			if (prv)
+				table->nents = ++table->orig_nents;
+			return (ENOMEM);
+		}
+		sg_init_table(sg, alloc_size);
+		table->nents = table->orig_nents += sg_size;
+
+		if (prv)
+			sg_chain(prv, max_ents, sg);
+		else
+			table->sgl = sg;
+
+		if (!left)
+			sg_mark_end(&sg[sg_size - 1]);
+
+		prv = sg;
+	} while (left);
+
+	return (0);
+}
+
+static inline int
+sg_alloc_table(struct sg_table *table, unsigned int nents, gfp_t gfp_mask)
+{
+	int ret;
+
+	ret = __sg_alloc_table(table, nents, SG_MAX_SINGLE_ALLOC,
+	    NULL, gfp_mask, sg_kmalloc);
+	if (unlikely(ret))
+		__sg_free_table(table, SG_MAX_SINGLE_ALLOC, 0, sg_kfree);
+
+	return (ret);
+}
+
+static inline int
+sg_alloc_table_from_pages(struct sg_table *sgt,
+    struct page **pages, unsigned int count,
+    unsigned long off, unsigned long size,
+    gfp_t gfp_mask)
+{
+	unsigned int i, segs, cur;
+	int rc;
+	struct scatterlist *s;
+
+	for (segs = i = 1; i < count; ++i) {
+		if (page_to_pfn(pages[i]) != page_to_pfn(pages[i - 1]) + 1)
+			++segs;
+	}
+	if (__predict_false((rc = sg_alloc_table(sgt, segs, gfp_mask))))
+		return (rc);
+
+	cur = 0;
+	for_each_sg(sgt->sgl, s, sgt->orig_nents, i) {
+		unsigned long seg_size;
+		unsigned int j;
+
+		for (j = cur + 1; j < count; ++j)
+			if (page_to_pfn(pages[j]) !=
+			    page_to_pfn(pages[j - 1]) + 1)
+				break;
+
+		seg_size = ((j - cur) << PAGE_SHIFT) - off;
+		sg_set_page(s, pages[cur], min(size, seg_size), off);
+		size -= seg_size;
+		off = 0;
+		cur = j;
+	}
+	return (0);
+}
+
+
+static inline int
+sg_nents(struct scatterlist *sg)
+{
+	int nents;
+
+	for (nents = 0; sg; sg = sg_next(sg))
+		nents++;
+	return (nents);
+}
+
+static inline void
+__sg_page_iter_start(struct sg_page_iter *piter,
+    struct scatterlist *sglist, unsigned int nents,
+    unsigned long pgoffset)
+{
+	piter->internal.pg_advance = 0;
+	piter->internal.nents = nents;
+
+	piter->sg = sglist;
+	piter->sg_pgoffset = pgoffset;
+}
+
+static inline void
+_sg_iter_next(struct sg_page_iter *iter)
+{
+	struct scatterlist *sg;
+	unsigned int pgcount;
+
+	sg = iter->sg;
+	pgcount = (sg->offset + sg->length + PAGE_SIZE - 1) >> PAGE_SHIFT;
+
+	++iter->sg_pgoffset;
+	while (iter->sg_pgoffset >= pgcount) {
+		iter->sg_pgoffset -= pgcount;
+		sg = sg_next(sg);
+		--iter->maxents;
+		if (sg == NULL || iter->maxents == 0)
+			break;
+		pgcount = (sg->offset + sg->length + PAGE_SIZE - 1) >> PAGE_SHIFT;
+	}
+	iter->sg = sg;
+}
+
+static inline int
+sg_page_count(struct scatterlist *sg)
+{
+	return (PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT);
+}
+
+static inline bool
+__sg_page_iter_next(struct sg_page_iter *piter)
+{
+	if (piter->internal.nents == 0)
+		return (0);
+	if (piter->sg == NULL)
+		return (0);
+
+	piter->sg_pgoffset += piter->internal.pg_advance;
+	piter->internal.pg_advance = 1;
+
+	while (piter->sg_pgoffset >= (unsigned int)sg_page_count(piter->sg)) {
+		piter->sg_pgoffset -= sg_page_count(piter->sg);
+		piter->sg = sg_next(piter->sg);
+		if (--piter->internal.nents == 0)
+			return (0);
+		if (piter->sg == NULL)
+			return (0);
+	}
+	return (1);
+}
+
+static inline void
+_sg_iter_init(struct scatterlist *sgl, struct sg_page_iter *iter,
+    unsigned int nents, unsigned long pgoffset)
+{
+	if (nents) {
+		iter->sg = sgl;
+		iter->sg_pgoffset = pgoffset - 1;
+		iter->maxents = nents;
+		_sg_iter_next(iter);
+	} else {
+		iter->sg = NULL;
+		iter->sg_pgoffset = 0;
+		iter->maxents = 0;
+	}
+}
+
+static inline dma_addr_t
+sg_page_iter_dma_address(struct sg_page_iter *spi)
+{
+	return (spi->sg->address + (spi->sg_pgoffset << PAGE_SHIFT));
+}
+
+static inline struct page *
+sg_page_iter_page(struct sg_page_iter *piter)
+{
+	return (nth_page(sg_page(piter->sg), piter->sg_pgoffset));
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif					/* _LINUX_SCATTERLIST_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/slab.h b/headers/compatibility/linuxkpi/linux/slab.h
new file mode 100644
index 0000000000..3bc11420dd
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/slab.h
@@ -0,0 +1,45 @@
+#ifndef	_LINUX_SLAB_H_
+#define	_LINUX_SLAB_H_
+
+#include <linux/gfp.h>
+#include <linux/types.h>
+
+#include <malloc.h>
+
+#define	kvmalloc(size)			kmalloc(size, GFP_KERNEL)
+#define	kzalloc(size, flags)		kmalloc(size, (flags) | __GFP_ZERO)
+#define	kzalloc_node(size, flags, node)	kmalloc(size, (flags) | __GFP_ZERO)
+#define	kfree_const(ptr)		kfree(ptr)
+#define	kcalloc(n, size, flags)		kmalloc((n) * (size), (flags) | __GFP_ZERO)
+#define	vzalloc(size)			__vmalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, 0)
+#define	vfree(arg)			kfree(arg)
+#define	kvfree(arg)			kfree(arg)
+#define	vmalloc_node(size, node)		__vmalloc(size, GFP_KERNEL, 0)
+#define	vmalloc_user(size)				__vmalloc(size, GFP_KERNEL | __GFP_ZERO, 0)
+#define	vmalloc(size)					__vmalloc(size, GFP_KERNEL, 0)
+#define	__kmalloc(...)			kmalloc(__VA_ARGS__)
+#define	kmalloc_node(chunk, flags, n)	kmalloc(chunk, flags)
+
+extern void *kmalloc(size_t size, int flags);
+extern void *krealloc(void *ptr, size_t size, int flags);
+extern void kfree(const void *ptr);
+
+static inline void *
+__vmalloc(size_t size, int flags, int other)
+{
+	return (malloc(size));
+}
+
+static inline void *
+vmalloc_32(size_t size)
+{
+	return (malloc(size));
+}
+
+static inline void *
+kmalloc_array(size_t n, size_t size, int flags)
+{
+	return (kmalloc(n * size, flags));
+}
+
+#endif	/* _LINUX_SLAB_H_ */
diff --git a/headers/compatibility/linuxkpi/linux/types.h b/headers/compatibility/linuxkpi/linux/types.h
new file mode 100644
index 0000000000..3cdd1c19bd
--- /dev/null
+++ b/headers/compatibility/linuxkpi/linux/types.h
@@ -0,0 +1,80 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_TYPES_H_
+#define	_LINUX_TYPES_H_
+
+#include <linux/compiler.h>
+#include <asm/types.h>
+#include <freebsd/sys/cdefs.h>
+
+#ifndef __bitwise__
+#ifdef __CHECKER__
+#define __bitwise__ __attribute__((bitwise))
+#else
+#define __bitwise__
+#endif
+#endif
+
+#define major(x)	0
+#define minor(x)	0
+#define	makedev(x,y)	0
+
+typedef uint16_t __le16;
+typedef uint16_t __be16;
+typedef uint32_t __le32;
+typedef uint32_t __be32;
+typedef uint64_t __le64;
+typedef uint64_t __be64;
+
+typedef unsigned int    uint;
+typedef unsigned gfp_t;
+typedef uint64_t loff_t;
+typedef vm_paddr_t resource_size_t;
+typedef uint16_t __bitwise__ __sum16;
+typedef unsigned long pgoff_t;
+
+typedef u64 phys_addr_t;
+
+#define	DECLARE_BITMAP(n, bits)						\
+	unsigned long n[howmany(bits, sizeof(long) * 8)]
+
+typedef unsigned long irq_hw_number_t;
+
+struct rcu_head {
+	void *raw[2];
+} __aligned(sizeof(void *));
+
+typedef void (*rcu_callback_t)(struct rcu_head *head);
+typedef void (*call_rcu_func_t)(struct rcu_head *head, rcu_callback_t func);
+typedef int linux_task_fn_t(void *data);
+
+#endif	/* _LINUX_TYPES_H_ */
+	
\ No newline at end of file
diff --git a/headers/private/graphics/3dfx/DriverInterface.h b/headers/private/graphics/non-drm/3dfx/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/3dfx/DriverInterface.h
rename to headers/private/graphics/non-drm/3dfx/DriverInterface.h
diff --git a/headers/private/graphics/AGP.h b/headers/private/graphics/non-drm/AGP.h
similarity index 100%
rename from headers/private/graphics/AGP.h
rename to headers/private/graphics/non-drm/AGP.h
diff --git a/headers/private/graphics/ati/DriverInterface.h b/headers/private/graphics/non-drm/ati/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/ati/DriverInterface.h
rename to headers/private/graphics/non-drm/ati/DriverInterface.h
diff --git a/headers/private/graphics/common/benaphore.h b/headers/private/graphics/non-drm/common/benaphore.h
similarity index 100%
rename from headers/private/graphics/common/benaphore.h
rename to headers/private/graphics/non-drm/common/benaphore.h
diff --git a/headers/private/graphics/common/bendian_bitfield.h b/headers/private/graphics/non-drm/common/bendian_bitfield.h
similarity index 100%
rename from headers/private/graphics/common/bendian_bitfield.h
rename to headers/private/graphics/non-drm/common/bendian_bitfield.h
diff --git a/headers/private/graphics/common/compute_display_timing.h b/headers/private/graphics/non-drm/common/compute_display_timing.h
similarity index 100%
rename from headers/private/graphics/common/compute_display_timing.h
rename to headers/private/graphics/non-drm/common/compute_display_timing.h
diff --git a/headers/private/graphics/common/create_display_modes.h b/headers/private/graphics/non-drm/common/create_display_modes.h
similarity index 100%
rename from headers/private/graphics/common/create_display_modes.h
rename to headers/private/graphics/non-drm/common/create_display_modes.h
diff --git a/headers/private/graphics/common/ddc.h b/headers/private/graphics/non-drm/common/ddc.h
similarity index 100%
rename from headers/private/graphics/common/ddc.h
rename to headers/private/graphics/non-drm/common/ddc.h
diff --git a/headers/private/graphics/common/debug_ext.h b/headers/private/graphics/non-drm/common/debug_ext.h
similarity index 100%
rename from headers/private/graphics/common/debug_ext.h
rename to headers/private/graphics/non-drm/common/debug_ext.h
diff --git a/headers/private/graphics/common/dp.h b/headers/private/graphics/non-drm/common/dp.h
similarity index 100%
rename from headers/private/graphics/common/dp.h
rename to headers/private/graphics/non-drm/common/dp.h
diff --git a/headers/private/graphics/common/dp_raw.h b/headers/private/graphics/non-drm/common/dp_raw.h
similarity index 100%
rename from headers/private/graphics/common/dp_raw.h
rename to headers/private/graphics/non-drm/common/dp_raw.h
diff --git a/headers/private/graphics/common/edid.h b/headers/private/graphics/non-drm/common/edid.h
similarity index 100%
rename from headers/private/graphics/common/edid.h
rename to headers/private/graphics/non-drm/common/edid.h
diff --git a/headers/private/graphics/common/edid_raw.h b/headers/private/graphics/non-drm/common/edid_raw.h
similarity index 100%
rename from headers/private/graphics/common/edid_raw.h
rename to headers/private/graphics/non-drm/common/edid_raw.h
diff --git a/headers/private/graphics/common/i2c.h b/headers/private/graphics/non-drm/common/i2c.h
similarity index 100%
rename from headers/private/graphics/common/i2c.h
rename to headers/private/graphics/non-drm/common/i2c.h
diff --git a/headers/private/graphics/common/lendian_bitfield.h b/headers/private/graphics/non-drm/common/lendian_bitfield.h
similarity index 100%
rename from headers/private/graphics/common/lendian_bitfield.h
rename to headers/private/graphics/non-drm/common/lendian_bitfield.h
diff --git a/headers/private/graphics/common/log_coll.h b/headers/private/graphics/non-drm/common/log_coll.h
similarity index 100%
rename from headers/private/graphics/common/log_coll.h
rename to headers/private/graphics/non-drm/common/log_coll.h
diff --git a/headers/private/graphics/common/memory_manager.h b/headers/private/graphics/non-drm/common/memory_manager.h
similarity index 100%
rename from headers/private/graphics/common/memory_manager.h
rename to headers/private/graphics/non-drm/common/memory_manager.h
diff --git a/headers/private/graphics/common/validate_display_mode.h b/headers/private/graphics/non-drm/common/validate_display_mode.h
similarity index 100%
rename from headers/private/graphics/common/validate_display_mode.h
rename to headers/private/graphics/non-drm/common/validate_display_mode.h
diff --git a/headers/private/graphics/common/video_configuration.h b/headers/private/graphics/non-drm/common/video_configuration.h
similarity index 100%
rename from headers/private/graphics/common/video_configuration.h
rename to headers/private/graphics/non-drm/common/video_configuration.h
diff --git a/headers/private/graphics/et6x00/DriverInterface.h b/headers/private/graphics/non-drm/et6x00/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/et6x00/DriverInterface.h
rename to headers/private/graphics/non-drm/et6x00/DriverInterface.h
diff --git a/headers/private/graphics/intel_810/DriverInterface.h b/headers/private/graphics/non-drm/intel_810/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/intel_810/DriverInterface.h
rename to headers/private/graphics/non-drm/intel_810/DriverInterface.h
diff --git a/headers/private/graphics/intel_extreme/AreaKeeper.h b/headers/private/graphics/non-drm/intel_extreme/AreaKeeper.h
similarity index 100%
rename from headers/private/graphics/intel_extreme/AreaKeeper.h
rename to headers/private/graphics/non-drm/intel_extreme/AreaKeeper.h
diff --git a/headers/private/graphics/intel_extreme/intel_extreme.h b/headers/private/graphics/non-drm/intel_extreme/intel_extreme.h
similarity index 100%
rename from headers/private/graphics/intel_extreme/intel_extreme.h
rename to headers/private/graphics/non-drm/intel_extreme/intel_extreme.h
diff --git a/headers/private/graphics/intel_extreme/lock.h b/headers/private/graphics/non-drm/intel_extreme/lock.h
similarity index 100%
rename from headers/private/graphics/intel_extreme/lock.h
rename to headers/private/graphics/non-drm/intel_extreme/lock.h
diff --git a/headers/private/graphics/intel_extreme/utility.h b/headers/private/graphics/non-drm/intel_extreme/utility.h
similarity index 100%
rename from headers/private/graphics/intel_extreme/utility.h
rename to headers/private/graphics/non-drm/intel_extreme/utility.h
diff --git a/headers/private/graphics/matrox/DriverInterface.h b/headers/private/graphics/non-drm/matrox/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/matrox/DriverInterface.h
rename to headers/private/graphics/non-drm/matrox/DriverInterface.h
diff --git a/headers/private/graphics/matrox/mga_macros.h b/headers/private/graphics/non-drm/matrox/mga_macros.h
similarity index 100%
rename from headers/private/graphics/matrox/mga_macros.h
rename to headers/private/graphics/non-drm/matrox/mga_macros.h
diff --git a/headers/private/graphics/neomagic/DriverInterface.h b/headers/private/graphics/non-drm/neomagic/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/neomagic/DriverInterface.h
rename to headers/private/graphics/non-drm/neomagic/DriverInterface.h
diff --git a/headers/private/graphics/neomagic/nm_macros.h b/headers/private/graphics/non-drm/neomagic/nm_macros.h
similarity index 100%
rename from headers/private/graphics/neomagic/nm_macros.h
rename to headers/private/graphics/non-drm/neomagic/nm_macros.h
diff --git a/headers/private/graphics/nvidia/DriverInterface.h b/headers/private/graphics/non-drm/nvidia/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/nvidia/DriverInterface.h
rename to headers/private/graphics/non-drm/nvidia/DriverInterface.h
diff --git a/headers/private/graphics/nvidia/nv_acc.h b/headers/private/graphics/non-drm/nvidia/nv_acc.h
similarity index 100%
rename from headers/private/graphics/nvidia/nv_acc.h
rename to headers/private/graphics/non-drm/nvidia/nv_acc.h
diff --git a/headers/private/graphics/nvidia/nv_macros.h b/headers/private/graphics/non-drm/nvidia/nv_macros.h
similarity index 100%
rename from headers/private/graphics/nvidia/nv_macros.h
rename to headers/private/graphics/non-drm/nvidia/nv_macros.h
diff --git a/headers/private/graphics/nvidia_gpgpu/DriverInterface.h b/headers/private/graphics/non-drm/nvidia_gpgpu/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/nvidia_gpgpu/DriverInterface.h
rename to headers/private/graphics/non-drm/nvidia_gpgpu/DriverInterface.h
diff --git a/headers/private/graphics/nvidia_gpgpu/nv_acc.h b/headers/private/graphics/non-drm/nvidia_gpgpu/nv_acc.h
similarity index 100%
rename from headers/private/graphics/nvidia_gpgpu/nv_acc.h
rename to headers/private/graphics/non-drm/nvidia_gpgpu/nv_acc.h
diff --git a/headers/private/graphics/nvidia_gpgpu/nv_macros.h b/headers/private/graphics/non-drm/nvidia_gpgpu/nv_macros.h
similarity index 100%
rename from headers/private/graphics/nvidia_gpgpu/nv_macros.h
rename to headers/private/graphics/non-drm/nvidia_gpgpu/nv_macros.h
diff --git a/headers/private/graphics/omap/omap3_regs.h b/headers/private/graphics/non-drm/omap/omap3_regs.h
similarity index 100%
rename from headers/private/graphics/omap/omap3_regs.h
rename to headers/private/graphics/non-drm/omap/omap3_regs.h
diff --git a/headers/private/graphics/radeon/2d_regs.h b/headers/private/graphics/non-drm/radeon/2d_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/2d_regs.h
rename to headers/private/graphics/non-drm/radeon/2d_regs.h
diff --git a/headers/private/graphics/radeon/3d_regs.h b/headers/private/graphics/non-drm/radeon/3d_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/3d_regs.h
rename to headers/private/graphics/non-drm/radeon/3d_regs.h
diff --git a/headers/private/graphics/radeon/accelerant_ext.h b/headers/private/graphics/non-drm/radeon/accelerant_ext.h
similarity index 100%
rename from headers/private/graphics/radeon/accelerant_ext.h
rename to headers/private/graphics/non-drm/radeon/accelerant_ext.h
diff --git a/headers/private/graphics/radeon/bios_regs.h b/headers/private/graphics/non-drm/radeon/bios_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/bios_regs.h
rename to headers/private/graphics/non-drm/radeon/bios_regs.h
diff --git a/headers/private/graphics/radeon/buscntrl_regs.h b/headers/private/graphics/non-drm/radeon/buscntrl_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/buscntrl_regs.h
rename to headers/private/graphics/non-drm/radeon/buscntrl_regs.h
diff --git a/headers/private/graphics/radeon/capture_regs.h b/headers/private/graphics/non-drm/radeon/capture_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/capture_regs.h
rename to headers/private/graphics/non-drm/radeon/capture_regs.h
diff --git a/headers/private/graphics/radeon/config_regs.h b/headers/private/graphics/non-drm/radeon/config_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/config_regs.h
rename to headers/private/graphics/non-drm/radeon/config_regs.h
diff --git a/headers/private/graphics/radeon/cp_regs.h b/headers/private/graphics/non-drm/radeon/cp_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/cp_regs.h
rename to headers/private/graphics/non-drm/radeon/cp_regs.h
diff --git a/headers/private/graphics/radeon/crtc_regs.h b/headers/private/graphics/non-drm/radeon/crtc_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/crtc_regs.h
rename to headers/private/graphics/non-drm/radeon/crtc_regs.h
diff --git a/headers/private/graphics/radeon/dac_regs.h b/headers/private/graphics/non-drm/radeon/dac_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/dac_regs.h
rename to headers/private/graphics/non-drm/radeon/dac_regs.h
diff --git a/headers/private/graphics/radeon/ddc_regs.h b/headers/private/graphics/non-drm/radeon/ddc_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/ddc_regs.h
rename to headers/private/graphics/non-drm/radeon/ddc_regs.h
diff --git a/headers/private/graphics/radeon/dma_regs.h b/headers/private/graphics/non-drm/radeon/dma_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/dma_regs.h
rename to headers/private/graphics/non-drm/radeon/dma_regs.h
diff --git a/headers/private/graphics/radeon/fp_regs.h b/headers/private/graphics/non-drm/radeon/fp_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/fp_regs.h
rename to headers/private/graphics/non-drm/radeon/fp_regs.h
diff --git a/headers/private/graphics/radeon/gpiopad_regs.h b/headers/private/graphics/non-drm/radeon/gpiopad_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/gpiopad_regs.h
rename to headers/private/graphics/non-drm/radeon/gpiopad_regs.h
diff --git a/headers/private/graphics/radeon/log_enum.h b/headers/private/graphics/non-drm/radeon/log_enum.h
similarity index 100%
rename from headers/private/graphics/radeon/log_enum.h
rename to headers/private/graphics/non-drm/radeon/log_enum.h
diff --git a/headers/private/graphics/radeon/log_names.h b/headers/private/graphics/non-drm/radeon/log_names.h
similarity index 100%
rename from headers/private/graphics/radeon/log_names.h
rename to headers/private/graphics/non-drm/radeon/log_names.h
diff --git a/headers/private/graphics/radeon/memcntrl_regs.h b/headers/private/graphics/non-drm/radeon/memcntrl_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/memcntrl_regs.h
rename to headers/private/graphics/non-drm/radeon/memcntrl_regs.h
diff --git a/headers/private/graphics/radeon/mmio.h b/headers/private/graphics/non-drm/radeon/mmio.h
similarity index 100%
rename from headers/private/graphics/radeon/mmio.h
rename to headers/private/graphics/non-drm/radeon/mmio.h
diff --git a/headers/private/graphics/radeon/multimon.h b/headers/private/graphics/non-drm/radeon/multimon.h
similarity index 100%
rename from headers/private/graphics/radeon/multimon.h
rename to headers/private/graphics/non-drm/radeon/multimon.h
diff --git a/headers/private/graphics/radeon/overlay_regs.h b/headers/private/graphics/non-drm/radeon/overlay_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/overlay_regs.h
rename to headers/private/graphics/non-drm/radeon/overlay_regs.h
diff --git a/headers/private/graphics/radeon/pll_access.h b/headers/private/graphics/non-drm/radeon/pll_access.h
similarity index 100%
rename from headers/private/graphics/radeon/pll_access.h
rename to headers/private/graphics/non-drm/radeon/pll_access.h
diff --git a/headers/private/graphics/radeon/pll_regs.h b/headers/private/graphics/non-drm/radeon/pll_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/pll_regs.h
rename to headers/private/graphics/non-drm/radeon/pll_regs.h
diff --git a/headers/private/graphics/radeon/radeon_bios.h b/headers/private/graphics/non-drm/radeon/radeon_bios.h
similarity index 100%
rename from headers/private/graphics/radeon/radeon_bios.h
rename to headers/private/graphics/non-drm/radeon/radeon_bios.h
diff --git a/headers/private/graphics/radeon/radeon_interface.h b/headers/private/graphics/non-drm/radeon/radeon_interface.h
similarity index 100%
rename from headers/private/graphics/radeon/radeon_interface.h
rename to headers/private/graphics/non-drm/radeon/radeon_interface.h
diff --git a/headers/private/graphics/radeon/radeon_regs.h b/headers/private/graphics/non-drm/radeon/radeon_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/radeon_regs.h
rename to headers/private/graphics/non-drm/radeon/radeon_regs.h
diff --git a/headers/private/graphics/radeon/rbbm_regs.h b/headers/private/graphics/non-drm/radeon/rbbm_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/rbbm_regs.h
rename to headers/private/graphics/non-drm/radeon/rbbm_regs.h
diff --git a/headers/private/graphics/radeon/theatre_regs.h b/headers/private/graphics/non-drm/radeon/theatre_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/theatre_regs.h
rename to headers/private/graphics/non-drm/radeon/theatre_regs.h
diff --git a/headers/private/graphics/radeon/tv_out_regs.h b/headers/private/graphics/non-drm/radeon/tv_out_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/tv_out_regs.h
rename to headers/private/graphics/non-drm/radeon/tv_out_regs.h
diff --git a/headers/private/graphics/radeon/utils.h b/headers/private/graphics/non-drm/radeon/utils.h
similarity index 100%
rename from headers/private/graphics/radeon/utils.h
rename to headers/private/graphics/non-drm/radeon/utils.h
diff --git a/headers/private/graphics/radeon/version.h b/headers/private/graphics/non-drm/radeon/version.h
similarity index 100%
rename from headers/private/graphics/radeon/version.h
rename to headers/private/graphics/non-drm/radeon/version.h
diff --git a/headers/private/graphics/radeon/vip_regs.h b/headers/private/graphics/non-drm/radeon/vip_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/vip_regs.h
rename to headers/private/graphics/non-drm/radeon/vip_regs.h
diff --git a/headers/private/graphics/radeon_hd/AreaKeeper.h b/headers/private/graphics/non-drm/radeon_hd/AreaKeeper.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/AreaKeeper.h
rename to headers/private/graphics/non-drm/radeon_hd/AreaKeeper.h
diff --git a/headers/private/graphics/radeon_hd/avivo_reg.h b/headers/private/graphics/non-drm/radeon_hd/avivo_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/avivo_reg.h
rename to headers/private/graphics/non-drm/radeon_hd/avivo_reg.h
diff --git a/headers/private/graphics/radeon_hd/car_reg.h b/headers/private/graphics/non-drm/radeon_hd/car_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/car_reg.h
rename to headers/private/graphics/non-drm/radeon_hd/car_reg.h
diff --git a/headers/private/graphics/radeon_hd/evergreen_reg.h b/headers/private/graphics/non-drm/radeon_hd/evergreen_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/evergreen_reg.h
rename to headers/private/graphics/non-drm/radeon_hd/evergreen_reg.h
diff --git a/headers/private/graphics/radeon_hd/lock.h b/headers/private/graphics/non-drm/radeon_hd/lock.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/lock.h
rename to headers/private/graphics/non-drm/radeon_hd/lock.h
diff --git a/headers/private/graphics/radeon_hd/ni_reg.h b/headers/private/graphics/non-drm/radeon_hd/ni_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/ni_reg.h
rename to headers/private/graphics/non-drm/radeon_hd/ni_reg.h
diff --git a/headers/private/graphics/radeon_hd/r500_reg.h b/headers/private/graphics/non-drm/radeon_hd/r500_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/r500_reg.h
rename to headers/private/graphics/non-drm/radeon_hd/r500_reg.h
diff --git a/headers/private/graphics/radeon_hd/r600_reg.h b/headers/private/graphics/non-drm/radeon_hd/r600_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/r600_reg.h
rename to headers/private/graphics/non-drm/radeon_hd/r600_reg.h
diff --git a/headers/private/graphics/radeon_hd/r700_reg.h b/headers/private/graphics/non-drm/radeon_hd/r700_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/r700_reg.h
rename to headers/private/graphics/non-drm/radeon_hd/r700_reg.h
diff --git a/headers/private/graphics/radeon_hd/radeon_hd.h b/headers/private/graphics/non-drm/radeon_hd/radeon_hd.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/radeon_hd.h
rename to headers/private/graphics/non-drm/radeon_hd/radeon_hd.h
diff --git a/headers/private/graphics/radeon_hd/radeon_reg.h b/headers/private/graphics/non-drm/radeon_hd/radeon_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/radeon_reg.h
rename to headers/private/graphics/non-drm/radeon_hd/radeon_reg.h
diff --git a/headers/private/graphics/radeon_hd/sea_reg.h b/headers/private/graphics/non-drm/radeon_hd/sea_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/sea_reg.h
rename to headers/private/graphics/non-drm/radeon_hd/sea_reg.h
diff --git a/headers/private/graphics/radeon_hd/si_reg.h b/headers/private/graphics/non-drm/radeon_hd/si_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/si_reg.h
rename to headers/private/graphics/non-drm/radeon_hd/si_reg.h
diff --git a/headers/private/graphics/radeon_hd/utility.h b/headers/private/graphics/non-drm/radeon_hd/utility.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/utility.h
rename to headers/private/graphics/non-drm/radeon_hd/utility.h
diff --git a/headers/private/graphics/radeon_hd/vol_reg.h b/headers/private/graphics/non-drm/radeon_hd/vol_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/vol_reg.h
rename to headers/private/graphics/non-drm/radeon_hd/vol_reg.h
diff --git a/headers/private/graphics/s3/DriverInterface.h b/headers/private/graphics/non-drm/s3/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/s3/DriverInterface.h
rename to headers/private/graphics/non-drm/s3/DriverInterface.h
diff --git a/headers/private/graphics/skeleton/DriverInterface.h b/headers/private/graphics/non-drm/skeleton/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/skeleton/DriverInterface.h
rename to headers/private/graphics/non-drm/skeleton/DriverInterface.h
diff --git a/headers/private/graphics/skeleton/macros.h b/headers/private/graphics/non-drm/skeleton/macros.h
similarity index 100%
rename from headers/private/graphics/skeleton/macros.h
rename to headers/private/graphics/non-drm/skeleton/macros.h
diff --git a/headers/private/graphics/vesa/utility.h b/headers/private/graphics/non-drm/vesa/utility.h
similarity index 100%
rename from headers/private/graphics/vesa/utility.h
rename to headers/private/graphics/non-drm/vesa/utility.h
diff --git a/headers/private/graphics/vesa/vesa.h b/headers/private/graphics/non-drm/vesa/vesa.h
similarity index 100%
rename from headers/private/graphics/vesa/vesa.h
rename to headers/private/graphics/non-drm/vesa/vesa.h
diff --git a/headers/private/graphics/vesa/vesa_info.h b/headers/private/graphics/non-drm/vesa/vesa_info.h
similarity index 100%
rename from headers/private/graphics/vesa/vesa_info.h
rename to headers/private/graphics/non-drm/vesa/vesa_info.h
diff --git a/headers/private/graphics/vesa/vga.h b/headers/private/graphics/non-drm/vesa/vga.h
similarity index 100%
rename from headers/private/graphics/vesa/vga.h
rename to headers/private/graphics/non-drm/vesa/vga.h
diff --git a/headers/private/graphics/via/DriverInterface.h b/headers/private/graphics/non-drm/via/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/via/DriverInterface.h
rename to headers/private/graphics/non-drm/via/DriverInterface.h
diff --git a/headers/private/graphics/via/macros.h b/headers/private/graphics/non-drm/via/macros.h
similarity index 100%
rename from headers/private/graphics/via/macros.h
rename to headers/private/graphics/non-drm/via/macros.h
diff --git a/headers/private/graphics/video_overlay.h b/headers/private/graphics/non-drm/video_overlay.h
similarity index 100%
rename from headers/private/graphics/video_overlay.h
rename to headers/private/graphics/non-drm/video_overlay.h
diff --git a/headers/private/graphics/vmware/DriverInterface.h b/headers/private/graphics/non-drm/vmware/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/vmware/DriverInterface.h
rename to headers/private/graphics/non-drm/vmware/DriverInterface.h
diff --git a/headers/private/graphics/vmware/svga_reg.h b/headers/private/graphics/non-drm/vmware/svga_reg.h
similarity index 100%
rename from headers/private/graphics/vmware/svga_reg.h
rename to headers/private/graphics/non-drm/vmware/svga_reg.h
diff --git a/headers/private/graphics/vmware/vm_device_version.h b/headers/private/graphics/non-drm/vmware/vm_device_version.h
similarity index 100%
rename from headers/private/graphics/vmware/vm_device_version.h
rename to headers/private/graphics/non-drm/vmware/vm_device_version.h
diff --git a/src/add-ons/kernel/drivers/graphics/Jamfile b/src/add-ons/kernel/drivers/graphics/Jamfile
index f8881e30a6..703890f279 100644
--- a/src/add-ons/kernel/drivers/graphics/Jamfile
+++ b/src/add-ons/kernel/drivers/graphics/Jamfile
@@ -1,19 +1,4 @@
 SubDir HAIKU_TOP src add-ons kernel drivers graphics ;
 
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics 3dfx ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics ati ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics common ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics et6x00 ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics framebuffer ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics intel_810 ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics intel_extreme ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics matrox ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics neomagic ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics nvidia ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics nvidia_gpgpu ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics radeon ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics radeon_hd ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics s3 ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics skeleton ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics vesa ;
-SubInclude HAIKU_TOP src add-ons kernel drivers graphics via ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics drm ;
diff --git a/src/add-ons/kernel/drivers/graphics/drm/Jamfile b/src/add-ons/kernel/drivers/graphics/drm/Jamfile
new file mode 100644
index 0000000000..dbaf197ddc
--- /dev/null
+++ b/src/add-ons/kernel/drivers/graphics/drm/Jamfile
@@ -0,0 +1,59 @@
+SubDir HAIKU_TOP src add-ons kernel drivers graphics drm ;
+
+UsePrivateHeaders [ FDirName graphics drm ] ;
+UsePrivateHeaders [ FDirName graphics drm uapi ] ;
+UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility ] : true ;
+UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility linuxkpi ] : true ;
+
+UsePrivateKernelHeaders ;
+UseHeaders $(HAIKU_PRIVATE_KERNEL_HEADERS) : true ;
+
+SubDirCcFlags [ FDefines _KERNEL=1 B_USE_POSITIVE_POSIX_ERRORS=1 __KERNEL__=1 ] ;
+
+KernelAddon drm :
+	test.c
+	 # drm_auth.c			# NOT Complete
+	 # drm_bufs.c			# NOT Complete
+	 # drm_cache.c			# NOT Complete
+	 # drm_context.c		# NOT Complete
+	 # drm_dma.c			# NOT Complete
+	 # drm_fops.c			# NOT Complete
+	 # drm_gem.c			# NOT Complete
+	 # drm_ioctl.c			# NOT Complete
+	 # drm_irq.c			# NOT Complete
+	 # drm_lock.c			# NOT Complete
+	 # drm_memory.c			# NOT Complete
+	 # drm_drv.c			# NOT Complete
+	 # drm_scatter.c		# NOT Complete
+	 # drm_pci.c			# NOT Complete
+	 # drm_platform.c		# NOT Complete
+	 # drm_sysfs.c			# NOT Complete
+	 # drm_hashtab.c		# NOT Complete
+	 # drm_mm.c				# NOT Complete
+	 # drm_crtc.c			# NOT Complete
+	 # drm_fourcc.c			# NOT Complete
+	 # drm_modes.c			# NOT Complete
+	 # drm_edid.c			# NOT Complete
+	 # drm_info.c			# NOT Complete
+	 # drm_encoder_slave.c	# NOT Complete
+	 # drm_trace_points.c	# NOT Complete
+	 # drm_global.c			# NOT Complete
+	 # drm_prime.c			# NOT Complete
+	 # drm_rect.c			# NOT Complete
+	 # drm_vma_manager.c	# NOT Complete
+	 # drm_flip_work.c		# NOT Complete
+	 # drm_modeset_lock.c	# NOT Complete
+	 # drm_atomic.c			# NOT Complete
+	 # drm_bridge.c			# NOT Complete
+	 # drm_framebuffer.c	# NOT Complete
+	 # drm_connector.c		# NOT Complete
+	 # drm_blend.c			# NOT Complete
+	 # drm_encoder.c		# NOT Complete
+	 # drm_mode_object.c	# NOT Complete
+	 # drm_property.c		# NOT Complete
+	 # drm_plane.c			# NOT Complete
+	 # drm_color_mgmt.c		# NOT Complete
+	 # drm_print.c			# NOT Complete
+	 # drm_dumb_buffers.c	# NOT Complete
+	 # drm_mode_config.c	# NOT Complete
+;
diff --git a/src/add-ons/kernel/drivers/graphics/3dfx/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/3dfx/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/3dfx/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/3dfx/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/3dfx/driver.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/3dfx/driver.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/3dfx/driver.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/3dfx/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/non-drm/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/Jamfile
new file mode 100644
index 0000000000..15c4a18239
--- /dev/null
+++ b/src/add-ons/kernel/drivers/graphics/non-drm/Jamfile
@@ -0,0 +1,19 @@
+SubDir HAIKU_TOP src add-ons kernel drivers graphics non-drm ;
+
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm 3dfx ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm ati ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm common ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm et6x00 ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm framebuffer ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm intel_810 ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm intel_extreme ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm matrox ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm neomagic ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm nvidia ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm nvidia_gpgpu ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm radeon ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm radeon_hd ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm s3 ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm skeleton ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm vesa ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics non-drm via ;
diff --git a/src/add-ons/kernel/drivers/graphics/ati/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/ati/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/ati/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/ati/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/ati/driver.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/ati/driver.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/ati/driver.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/ati/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/common/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/common/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/common/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/common/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/common/memory_manager.c b/src/add-ons/kernel/drivers/graphics/non-drm/common/memory_manager.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/common/memory_manager.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/common/memory_manager.c
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/et6x00/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/et6x00/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/acl.c b/src/add-ons/kernel/drivers/graphics/non-drm/et6x00/acl.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/acl.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/et6x00/acl.c
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/acl.h b/src/add-ons/kernel/drivers/graphics/non-drm/et6x00/acl.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/acl.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/et6x00/acl.h
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/bits.c b/src/add-ons/kernel/drivers/graphics/non-drm/et6x00/bits.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/bits.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/et6x00/bits.c
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/bits.h b/src/add-ons/kernel/drivers/graphics/non-drm/et6x00/bits.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/bits.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/et6x00/bits.h
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/driver.c b/src/add-ons/kernel/drivers/graphics/non-drm/et6x00/driver.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/driver.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/et6x00/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/license b/src/add-ons/kernel/drivers/graphics/non-drm/et6x00/license
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/license
rename to src/add-ons/kernel/drivers/graphics/non-drm/et6x00/license
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/readme b/src/add-ons/kernel/drivers/graphics/non-drm/et6x00/readme
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/readme
rename to src/add-ons/kernel/drivers/graphics/non-drm/et6x00/readme
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/setmode.c b/src/add-ons/kernel/drivers/graphics/non-drm/et6x00/setmode.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/setmode.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/et6x00/setmode.c
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/setmode.h b/src/add-ons/kernel/drivers/graphics/non-drm/et6x00/setmode.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/setmode.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/et6x00/setmode.h
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/framebuffer/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/device.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/device.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/framebuffer/device.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/device.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/device.h b/src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/device.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/framebuffer/device.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/device.h
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/driver.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/driver.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/framebuffer/driver.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/driver.h b/src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/driver.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/framebuffer/driver.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/driver.h
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/framebuffer.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/framebuffer.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer_private.h b/src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/framebuffer_private.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer_private.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/framebuffer/framebuffer_private.h
diff --git a/src/add-ons/kernel/drivers/graphics/intel_810/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/intel_810/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/intel_810/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/intel_810/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/intel_810/driver.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/intel_810/driver.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/intel_810/driver.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/intel_810/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/intel_extreme/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/bios.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/bios.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/intel_extreme/bios.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/bios.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/device.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/device.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/intel_extreme/device.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/device.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/device.h b/src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/device.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/intel_extreme/device.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/device.h
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/driver.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.h b/src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/driver.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/intel_extreme/driver.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/driver.h
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/intel_extreme.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/intel_extreme.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme_private.h b/src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/intel_extreme_private.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/intel_extreme/intel_extreme_private.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/intel_extreme_private.h
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/power.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/power.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/intel_extreme/power.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/power.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/power.h b/src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/power.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/intel_extreme/power.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/intel_extreme/power.h
diff --git a/src/add-ons/kernel/drivers/graphics/matrox/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/matrox/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/matrox/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/matrox/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/matrox/README.html b/src/add-ons/kernel/drivers/graphics/non-drm/matrox/README.html
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/matrox/README.html
rename to src/add-ons/kernel/drivers/graphics/non-drm/matrox/README.html
diff --git a/src/add-ons/kernel/drivers/graphics/matrox/UPDATE.html b/src/add-ons/kernel/drivers/graphics/non-drm/matrox/UPDATE.html
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/matrox/UPDATE.html
rename to src/add-ons/kernel/drivers/graphics/non-drm/matrox/UPDATE.html
diff --git a/src/add-ons/kernel/drivers/graphics/matrox/driver.c b/src/add-ons/kernel/drivers/graphics/non-drm/matrox/driver.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/matrox/driver.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/matrox/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/matrox/matrox.settings b/src/add-ons/kernel/drivers/graphics/non-drm/matrox/matrox.settings
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/matrox/matrox.settings
rename to src/add-ons/kernel/drivers/graphics/non-drm/matrox/matrox.settings
diff --git a/src/add-ons/kernel/drivers/graphics/neomagic/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/neomagic/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/neomagic/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/neomagic/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/neomagic/README.html b/src/add-ons/kernel/drivers/graphics/non-drm/neomagic/README.html
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/neomagic/README.html
rename to src/add-ons/kernel/drivers/graphics/non-drm/neomagic/README.html
diff --git a/src/add-ons/kernel/drivers/graphics/neomagic/UPDATE.html b/src/add-ons/kernel/drivers/graphics/non-drm/neomagic/UPDATE.html
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/neomagic/UPDATE.html
rename to src/add-ons/kernel/drivers/graphics/non-drm/neomagic/UPDATE.html
diff --git a/src/add-ons/kernel/drivers/graphics/neomagic/driver.c b/src/add-ons/kernel/drivers/graphics/non-drm/neomagic/driver.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/neomagic/driver.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/neomagic/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/neomagic/neomagic.settings b/src/add-ons/kernel/drivers/graphics/non-drm/neomagic/neomagic.settings
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/neomagic/neomagic.settings
rename to src/add-ons/kernel/drivers/graphics/non-drm/neomagic/neomagic.settings
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/nvidia/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/nvidia/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/nvidia/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/README.html b/src/add-ons/kernel/drivers/graphics/non-drm/nvidia/README.html
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/nvidia/README.html
rename to src/add-ons/kernel/drivers/graphics/non-drm/nvidia/README.html
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/UPDATE.html b/src/add-ons/kernel/drivers/graphics/non-drm/nvidia/UPDATE.html
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/nvidia/UPDATE.html
rename to src/add-ons/kernel/drivers/graphics/non-drm/nvidia/UPDATE.html
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/driver.c b/src/add-ons/kernel/drivers/graphics/non-drm/nvidia/driver.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/nvidia/driver.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/nvidia/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/nvidia.settings b/src/add-ons/kernel/drivers/graphics/non-drm/nvidia/nvidia.settings
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/nvidia/nvidia.settings
rename to src/add-ons/kernel/drivers/graphics/non-drm/nvidia/nvidia.settings
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/nvidia_gpgpu/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/nvidia_gpgpu/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/README.html b/src/add-ons/kernel/drivers/graphics/non-drm/nvidia_gpgpu/README.html
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/README.html
rename to src/add-ons/kernel/drivers/graphics/non-drm/nvidia_gpgpu/README.html
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/UPDATE.html b/src/add-ons/kernel/drivers/graphics/non-drm/nvidia_gpgpu/UPDATE.html
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/UPDATE.html
rename to src/add-ons/kernel/drivers/graphics/non-drm/nvidia_gpgpu/UPDATE.html
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/driver.c b/src/add-ons/kernel/drivers/graphics/non-drm/nvidia_gpgpu/driver.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/driver.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/nvidia_gpgpu/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/nvidia_gpgpu.settings b/src/add-ons/kernel/drivers/graphics/non-drm/nvidia_gpgpu/nvidia_gpgpu.settings
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/nvidia_gpgpu.settings
rename to src/add-ons/kernel/drivers/graphics/non-drm/nvidia_gpgpu/nvidia_gpgpu.settings
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/CPMicroCode.h b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/CPMicroCode.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/CPMicroCode.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/CPMicroCode.h
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/CP_setup.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/CP_setup.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/CP_setup.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/CP_setup.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/DMA.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/DMA.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/DMA.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/DMA.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/PCI_GART.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/PCI_GART.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/PCI_GART.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/PCI_GART.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/agp.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/agp.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/agp.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/agp.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/bios.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/bios.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/bios.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/bios.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/detect.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/detect.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/detect.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/detect.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/driver.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/driver.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/driver.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/global_data.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/global_data.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/global_data.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/global_data.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/init.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/init.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/init.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/init.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/irq.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/irq.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/irq.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/irq.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/mem_controller.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/mem_controller.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/mem_controller.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/mem_controller.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/pll_access.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/pll_access.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/pll_access.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/pll_access.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/radeon_driver.h b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/radeon_driver.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/radeon_driver.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/radeon_driver.h
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/utils.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/utils.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/utils.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/utils.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/vip.c b/src/add-ons/kernel/drivers/graphics/non-drm/radeon/vip.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/vip.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon/vip.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon_hd/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/device.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/device.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon_hd/device.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/device.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/device.h b/src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/device.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon_hd/device.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/device.h
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/driver.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/driver.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon_hd/driver.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/driver.h b/src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/driver.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon_hd/driver.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/driver.h
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/radeon_hd.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/radeon_hd.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd_private.h b/src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/radeon_hd_private.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd_private.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/radeon_hd_private.h
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/sensors.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/sensors.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon_hd/sensors.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/sensors.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/sensors.h b/src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/sensors.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon_hd/sensors.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/radeon_hd/sensors.h
diff --git a/src/add-ons/kernel/drivers/graphics/s3/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/s3/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/s3/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/s3/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/s3/driver.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/s3/driver.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/s3/driver.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/s3/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/skeleton/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/skeleton/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/skeleton/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/skeleton/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/skeleton/README.html b/src/add-ons/kernel/drivers/graphics/non-drm/skeleton/README.html
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/skeleton/README.html
rename to src/add-ons/kernel/drivers/graphics/non-drm/skeleton/README.html
diff --git a/src/add-ons/kernel/drivers/graphics/skeleton/UPDATE.html b/src/add-ons/kernel/drivers/graphics/non-drm/skeleton/UPDATE.html
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/skeleton/UPDATE.html
rename to src/add-ons/kernel/drivers/graphics/non-drm/skeleton/UPDATE.html
diff --git a/src/add-ons/kernel/drivers/graphics/skeleton/driver.c b/src/add-ons/kernel/drivers/graphics/non-drm/skeleton/driver.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/skeleton/driver.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/skeleton/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/skeleton/skel.settings b/src/add-ons/kernel/drivers/graphics/non-drm/skeleton/skel.settings
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/skeleton/skel.settings
rename to src/add-ons/kernel/drivers/graphics/non-drm/skeleton/skel.settings
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/vesa/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/vesa/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/vesa/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/device.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/vesa/device.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/vesa/device.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/vesa/device.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/device.h b/src/add-ons/kernel/drivers/graphics/non-drm/vesa/device.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/vesa/device.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/vesa/device.h
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/driver.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/vesa/driver.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/vesa/driver.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/vesa/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/driver.h b/src/add-ons/kernel/drivers/graphics/non-drm/vesa/driver.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/vesa/driver.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/vesa/driver.h
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/vesa/vesa.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/vesa/vesa.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/vesa_private.h b/src/add-ons/kernel/drivers/graphics/non-drm/vesa/vesa_private.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/vesa/vesa_private.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/vesa/vesa_private.h
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/vga.cpp b/src/add-ons/kernel/drivers/graphics/non-drm/vesa/vga.cpp
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/vesa/vga.cpp
rename to src/add-ons/kernel/drivers/graphics/non-drm/vesa/vga.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/vga.h b/src/add-ons/kernel/drivers/graphics/non-drm/vesa/vga.h
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/vesa/vga.h
rename to src/add-ons/kernel/drivers/graphics/non-drm/vesa/vga.h
diff --git a/src/add-ons/kernel/drivers/graphics/via/Jamfile b/src/add-ons/kernel/drivers/graphics/non-drm/via/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/via/Jamfile
rename to src/add-ons/kernel/drivers/graphics/non-drm/via/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/via/README.html b/src/add-ons/kernel/drivers/graphics/non-drm/via/README.html
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/via/README.html
rename to src/add-ons/kernel/drivers/graphics/non-drm/via/README.html
diff --git a/src/add-ons/kernel/drivers/graphics/via/UPDATE.html b/src/add-ons/kernel/drivers/graphics/non-drm/via/UPDATE.html
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/via/UPDATE.html
rename to src/add-ons/kernel/drivers/graphics/non-drm/via/UPDATE.html
diff --git a/src/add-ons/kernel/drivers/graphics/via/driver.c b/src/add-ons/kernel/drivers/graphics/non-drm/via/driver.c
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/via/driver.c
rename to src/add-ons/kernel/drivers/graphics/non-drm/via/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/via/via.settings b/src/add-ons/kernel/drivers/graphics/non-drm/via/via.settings
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/via/via.settings
rename to src/add-ons/kernel/drivers/graphics/non-drm/via/via.settings
