diff --git a/headers/compatibility/linux/asm/bitops/const_hweight.h b/headers/compatibility/linux/asm/bitops/const_hweight.h
new file mode 100644
index 0000000000..ac2c795f7c
--- /dev/null
+++ b/headers/compatibility/linux/asm/bitops/const_hweight.h
@@ -0,0 +1,40 @@
+/*-
+ * 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.
+ */
+
+#ifndef _ASM_BITOPS_CONST_HWEIGHT_H_
+#define _ASM_BITOPS_CONST_HWEIGHT_H_
+
+static __inline uint16_t
+hweight16(uint32_t x)
+{
+	x = (x & 0x5555) + ((x & 0xaaaa) >> 1);
+	x = (x & 0x3333) + ((x & 0xcccc) >> 2);
+	x = (x + (x >> 4)) & 0x0f0f;
+	x = (x + (x >> 8)) & 0x00ff;
+	return (x);
+}
+
+#endif	/* _ASM_BITOPS_CONST_HWEIGHT_H_ */
diff --git a/headers/compatibility/linux/asm/bitops/non-atomic.h b/headers/compatibility/linux/asm/bitops/non-atomic.h
new file mode 100644
index 0000000000..3282812d75
--- /dev/null
+++ b/headers/compatibility/linux/asm/bitops/non-atomic.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 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.
+ */
+
+#ifndef _ASM_BITOPS_NON_ATOMIC_H_
+#define _ASM_BITOPS_NON_ATOMIC_H_
+
+static inline void __set_bit(int nr, volatile unsigned long *addr)
+{
+	*(addr + (nr / BITS_PER_LONG)) |= (1 << (nr % BITS_PER_LONG));
+}
+
+static inline void __clear_bit(int nr, volatile unsigned long *addr)
+{
+	*(addr + (nr / BITS_PER_LONG)) &= ~(1 << (nr % BITS_PER_LONG));
+}
+
+#endif	/* _ASM_BITOPS_NON_ATOMIC_H_ */
diff --git a/headers/compatibility/linux/asm/io.h b/headers/compatibility/linux/asm/io.h
new file mode 100644
index 0000000000..412f922709
--- /dev/null
+++ b/headers/compatibility/linux/asm/io.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2015 Hamish Morrison
+ * Copyright (c) 2014 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.
+ */
+
+#ifndef _ASM_IO_H_
+#define _ASM_IO_H_
+
+
+#define ioread8(addr)		*(volatile uint8_t *)((char *)addr)
+#define ioread16(addr)		*(volatile uint16_t *)((char *)addr)
+#define ioread32(addr)		*(volatile uint32_t *)((char *)addr)
+
+#define iowrite8(data, addr)	*(volatile uint8_t *)((char *)addr) = data;
+#define iowrite16(data, addr)	*(volatile uint16_t *)((char *)addr) = data;
+#define iowrite32(data, addr)	*(volatile uint32_t *)((char *)addr) = data;
+
+static inline void __iomem *map_common(resource_size_t addr, unsigned long size,
+	uint32 flags)
+{
+	void* address;
+	area_id area = map_physical_memory("lio", addr, size, flags,
+		B_READ_AREA | B_WRITE_AREA, &address);
+	if (area < 0)
+		return NULL;
+
+	return address;
+}
+
+/* ioremap: map bus memory into CPU space */
+static inline void __iomem *ioremap(resource_size_t phys_addr, unsigned long size)
+{
+	return map_common(phys_addr, size, B_ANY_KERNEL_ADDRESS | B_MTR_UC);
+}
+
+static inline void __iomem *ioremap_wc(resource_size_t phys_addr, unsigned long size)
+{
+	return map_common(phys_addr, size, B_ANY_KERNEL_ADDRESS | B_MTR_WC);
+}
+
+#endif	/* _ASM_IO_H_ */
diff --git a/headers/compatibility/linux/asm/ioctl.h b/headers/compatibility/linux/asm/ioctl.h
new file mode 100644
index 0000000000..2849931f78
--- /dev/null
+++ b/headers/compatibility/linux/asm/ioctl.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _H
+#define _H
+
+
+#endif
diff --git a/headers/compatibility/linux/asm/mman.h b/headers/compatibility/linux/asm/mman.h
new file mode 100644
index 0000000000..2849931f78
--- /dev/null
+++ b/headers/compatibility/linux/asm/mman.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _H
+#define _H
+
+
+#endif
diff --git a/headers/compatibility/linux/asm/pgalloc.h b/headers/compatibility/linux/asm/pgalloc.h
new file mode 100644
index 0000000000..2849931f78
--- /dev/null
+++ b/headers/compatibility/linux/asm/pgalloc.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _H
+#define _H
+
+
+#endif
diff --git a/headers/compatibility/linux/asm/types.h b/headers/compatibility/linux/asm/types.h
new file mode 100644
index 0000000000..6006e1a23b
--- /dev/null
+++ b/headers/compatibility/linux/asm/types.h
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * 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.
+ */
+#ifndef	_ASM_TYPES_H_
+#define	_ASM_TYPES_H_
+
+
+typedef signed char __s8;
+typedef unsigned char __u8;
+
+typedef signed short __s16;
+typedef unsigned short __u16;
+
+typedef signed int __s32;
+typedef unsigned int __u32;
+
+#if defined(__GNUC__) // && !defined(__STRICT_ANSI__)
+typedef signed long long __s64;
+typedef uint64_t __u64;
+#endif
+
+typedef signed char s8;
+typedef unsigned char u8;
+
+typedef signed short s16;
+typedef unsigned short u16;
+
+typedef signed int s32;
+typedef unsigned int u32;
+
+typedef signed long long s64;
+typedef unsigned long long u64;
+
+/* DMA addresses come in generic and 64-bit flavours.  */
+typedef phys_addr_t dma_addr_t;
+typedef phys_addr_t dma64_addr_t;
+
+
+#endif	/* _ASM_TYPES_H_ */
diff --git a/headers/compatibility/linux/linux/agp_backend.h b/headers/compatibility/linux/linux/agp_backend.h
new file mode 100644
index 0000000000..532940e412
--- /dev/null
+++ b/headers/compatibility/linux/linux/agp_backend.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _LINUX_AGP_BACKEND_H
+#define _LINUX_AGP_BACKEND_H
+
+#include <SupportDefs.h>
+
+enum chipset_type {
+	NOT_SUPPORTED,
+	SUPPORTED
+};
+
+struct agp_version {
+	uint16 major;
+	uint16 minor;
+};
+
+struct agp_kern_info {
+	struct agp_version version;
+	struct pci_dev* dev;
+	enum chipset_type chipset;
+	unsigned long mode;
+	unsigned long aper_base;
+	size_t aper_size;
+	int max_memory;
+	int current_memory;
+	bool cant_use_aperture;
+	unsigned long page_mask;
+	// const struct vm_operations_struct* vm_ops;
+};
+
+struct agp_bridge_data;
+
+struct agp_memory {
+};
+
+#endif
diff --git a/headers/compatibility/linux/linux/atomic.h b/headers/compatibility/linux/linux/atomic.h
new file mode 100644
index 0000000000..236ac56199
--- /dev/null
+++ b/headers/compatibility/linux/linux/atomic.h
@@ -0,0 +1,144 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2015 François Tigeot
+ * Copyright (c) 2015 Hamish Morrison
+ * 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.
+ */
+
+#ifndef	_ASM_ATOMIC_H_
+#define	_ASM_ATOMIC_H_
+
+#include <SupportDefs.h>
+#include <arch/atomic.h>
+#include <sys/types.h>
+#include <linux/compiler.h>
+
+typedef struct {
+	uint32 counter;
+} atomic_t;
+
+typedef struct {
+	uint64 counter;
+} atomic64_t;
+
+#define	atomic_inc_return(v)		atomic_add_return(1, (v))
+#define	atomic_add_negative(i, v)	(atomic_add_return((i), (v)) < 0)
+#define	atomic_sub_and_test(i, v)	(atomic_sub_return((i), (v)) == 0)
+#define	atomic_dec_and_test(v)		(atomic_sub_return(1, (v)) == 0)
+#define	atomic_inc_and_test(v)		(atomic_add_return(1, (v)) == 0)
+#define atomic_dec_return(v)             atomic_sub_return(1, (v))
+
+#define atomic_xchg(p, v)		atomic_get_and_set(&((p)->counter), v)
+#define atomic64_xchg(p, v)		atomic_get_and_set64(&((p)->counter), v)
+
+static inline int
+atomic_add_return(int i, atomic_t *v)
+{
+	return i + atomic_add(&v->counter, i);
+}
+
+static inline int
+atomic_sub_return(int i, atomic_t *v)
+{
+	return atomic_add(&v->counter, -i) - i;
+}
+
+static inline void
+linux_atomic_set(atomic_t *v, int i)
+{
+	atomic_set(&v->counter, i);
+}
+
+static inline void
+atomic64_set(atomic64_t *v, long i)
+{
+	atomic_set64(&v->counter, i);
+}
+
+static inline int
+atomic_read(atomic_t *v)
+{
+	return atomic_get(&v->counter);
+}
+
+static inline int64_t
+atomic64_read(atomic64_t *v)
+{
+	return atomic_get64(&v->counter);
+}
+
+static inline int
+atomic_inc(atomic_t *v)
+{
+	return atomic_add(&v->counter, 1) + 1;
+}
+
+static inline int
+atomic_dec(atomic_t *v)
+{
+	return atomic_add(&v->counter, -1) - 1;
+}
+
+static inline int atomic_add_unless(atomic_t *v, int a, int u)
+{
+        int c, old;
+        c = atomic_read(v);
+        for (;;) {
+                if (unlikely(c == (u)))
+                        break;
+                // old = atomic_cmpxchg((v), c, c + (a)); /*Linux*/
+                old = atomic_test_and_set(&v->counter, c + (a), c);
+                if (likely(old == c))
+                        break;
+                c = old;
+        }
+        return c != (u);
+}
+
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
+static inline void
+atomic_clear_mask(int mask, atomic_t *v)
+{
+	atomic_and(&v->counter, ~mask);
+}
+
+static inline void
+atomic_set_mask(int mask, atomic_t *v)
+{
+	atomic_or(&v->counter, mask);
+}
+
+#define	atomic_sub(i, v)		atomic_sub_return((i), (v))
+
+/*
+#undef atomic_add
+#undef atomic_set
+#define	atomic_add(i, v)		atomic_add_return((i), (v))
+#define atomic_set(v, i)		linux_atomic_set((v), (i))
+*/
+
+#endif	/* _ASM_ATOMIC_H_ */
diff --git a/headers/compatibility/linux/linux/bitops.h b/headers/compatibility/linux/linux/bitops.h
new file mode 100644
index 0000000000..e80f9a0e2a
--- /dev/null
+++ b/headers/compatibility/linux/linux/bitops.h
@@ -0,0 +1,541 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * 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.
+ */
+#ifndef	_LINUX_BITOPS_H_
+#define	_LINUX_BITOPS_H_
+
+#include <string.h>
+
+#include <SupportDefs.h>
+
+
+#ifndef howmany
+#define howmany(x, y) (((x)+((y)-1))/(y))
+#endif
+
+#ifdef __LP64__
+#define	BITS_PER_LONG		64
+#else
+#define	BITS_PER_LONG		32
+#endif
+#define	BIT_MASK(n)		(~0UL >> (BITS_PER_LONG - (n)))
+#define	BITS_TO_LONGS(n)	howmany((n), BITS_PER_LONG)
+#define BIT_WORD(nr)		((nr) / BITS_PER_LONG)
+
+static inline int
+__ffs(int mask)
+{
+#if __GNUC__ >= 4
+	return __builtin_ffs(mask) - 1;
+#else
+	int i;
+	unsigned int umask = (unsigned int)mask;
+	for (i = 0; umask != 0; i++) {
+		if ((umask & 0x1) != 0)
+			return i;
+		umask >>= 1;
+	}
+	return -1;
+#endif
+}
+
+static inline int
+__fls(int mask)
+{
+#if __GNUC__ >= 4
+	return sizeof(int) * 8 - __builtin_clz(mask) + 1;
+#else
+	int i;
+	unsigned int umask = (unsigned int)mask;
+	for (i = 0; umask != 0; i++) {
+		umask >>= 1;
+	}
+	return i - 1;
+#endif
+}
+
+static inline int
+__ffsl(long mask)
+{
+#if __GNUC__ >= 4
+	return __builtin_ffsl(mask) - 1;
+#else
+	int i;
+	unsigned long umask = (unsigned long)mask;
+	for (i = 0; umask != 0; i++) {
+		if ((umask & 0x1) != 0)
+			return i;
+		umask >>= 1;
+	}
+	return -1;
+#endif
+}
+
+static inline int
+__flsl(long mask)
+{
+#if __GNUC__ >= 4
+	return sizeof(int) * 8 - __builtin_clzl(mask) + 1;
+#else
+	int i;
+	unsigned long umask = (unsigned long)mask;
+	for (i = 0; umask != 0; i++) {
+		umask >>= 1;
+	}
+	return i - 1;
+#endif
+}
+
+
+#define	ffz(mask)	__ffs(~(mask))
+
+static inline int get_count_order(unsigned int count)
+{
+        int order;
+
+        order = __fls(count);
+        if (count & (count - 1))
+                order++;
+        return order;
+}
+
+static inline unsigned long
+find_first_bit(unsigned long *addr, unsigned long size)
+{
+	long mask;
+	int bit;
+
+	for (bit = 0; size >= BITS_PER_LONG;
+	    size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
+		if (*addr == 0)
+			continue;
+		return (bit + __ffsl(*addr));
+	}
+	if (size) {
+		mask = (*addr) & BIT_MASK(size);
+		if (mask)
+			bit += __ffsl(mask);
+		else
+			bit += size;
+	}
+	return (bit);
+}
+
+static inline unsigned long
+find_first_zero_bit(unsigned long *addr, unsigned long size)
+{
+	long mask;
+	int bit;
+
+	for (bit = 0; size >= BITS_PER_LONG;
+	    size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
+		if (~(*addr) == 0)
+			continue;
+		return (bit + __ffsl(~(*addr)));
+	}
+	if (size) {
+		mask = ~(*addr) & BIT_MASK(size);
+		if (mask)
+			bit += __ffsl(mask);
+		else
+			bit += size;
+	}
+	return (bit);
+}
+
+static inline unsigned long
+find_last_bit(unsigned long *addr, unsigned long size)
+{
+	long mask;
+	int offs;
+	int bit;
+	int pos;
+
+	pos = size / BITS_PER_LONG;
+	offs = size % BITS_PER_LONG;
+	bit = BITS_PER_LONG * pos;
+	addr += pos;
+	if (offs) {
+		mask = (*addr) & BIT_MASK(offs);
+		if (mask)
+			return (bit + __flsl(mask));
+	}
+	while (--pos) {
+		addr--;
+		bit -= BITS_PER_LONG;
+		if (*addr)
+			return (bit + __flsl(mask));
+	}
+	return (size);
+}
+
+static inline unsigned long
+find_next_bit(unsigned long *addr, unsigned long size, unsigned long offset)
+{
+	long mask;
+	int offs;
+	int bit;
+	int pos;
+
+	if (offset >= size)
+		return (size);
+	pos = offset / BITS_PER_LONG;
+	offs = offset % BITS_PER_LONG;
+	bit = BITS_PER_LONG * pos;
+	addr += pos;
+	if (offs) {
+		mask = (*addr) & ~BIT_MASK(offs);
+		if (mask)
+			return (bit + __ffsl(mask));
+		bit += BITS_PER_LONG;
+		addr++;
+	}
+	for (size -= bit; size >= BITS_PER_LONG;
+	    size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
+		if (*addr == 0)
+			continue;
+		return (bit + __ffsl(*addr));
+	}
+	if (size) {
+		mask = (*addr) & BIT_MASK(size);
+		if (mask)
+			bit += __ffsl(mask);
+		else
+			bit += size;
+	}
+	return (bit);
+}
+
+static inline unsigned long
+find_next_zero_bit(unsigned long *addr, unsigned long size,
+    unsigned long offset)
+{
+	long mask;
+	int offs;
+	int bit;
+	int pos;
+
+	if (offset >= size)
+		return (size);
+	pos = offset / BITS_PER_LONG;
+	offs = offset % BITS_PER_LONG;
+	bit = BITS_PER_LONG * pos;
+	addr += pos;
+	if (offs) {
+		mask = ~(*addr) & ~BIT_MASK(offs);
+		if (mask)
+			return (bit + __ffsl(mask));
+		bit += BITS_PER_LONG;
+		addr++;
+	}
+	for (size -= bit; size >= BITS_PER_LONG;
+	    size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
+		if (~(*addr) == 0)
+			continue;
+		return (bit + __ffsl(~(*addr)));
+	}
+	if (size) {
+		mask = ~(*addr) & BIT_MASK(size);
+		if (mask)
+			bit += __ffsl(mask);
+		else
+			bit += size;
+	}
+	return (bit);
+}
+
+static inline void
+bitmap_zero(unsigned long *addr, int size)
+{
+	int len;
+
+	len = BITS_TO_LONGS(size) * sizeof(long);
+	memset(addr, 0, len);
+}
+
+static inline void
+bitmap_fill(unsigned long *addr, int size)
+{
+	int tail;
+	int len;
+
+	len = (size / BITS_PER_LONG) * sizeof(long);
+	memset(addr, 0xff, len);
+	tail = size & (BITS_PER_LONG - 1);
+	if (tail) 
+		addr[size / BITS_PER_LONG] = BIT_MASK(tail);
+}
+
+static inline int
+bitmap_full(unsigned long *addr, int size)
+{
+	long mask;
+	int tail;
+	int len;
+	int i;
+
+	len = size / BITS_PER_LONG;
+	for (i = 0; i < len; i++)
+		if (addr[i] != ~0UL)
+			return (0);
+	tail = size & (BITS_PER_LONG - 1);
+	if (tail) {
+		mask = BIT_MASK(tail);
+		if ((addr[i] & mask) != mask)
+			return (0);
+	}
+	return (1);
+}
+
+static inline int
+bitmap_empty(unsigned long *addr, int size)
+{
+	long mask;
+	int tail;
+	int len;
+	int i;
+
+	len = size / BITS_PER_LONG;
+	for (i = 0; i < len; i++)
+		if (addr[i] != 0)
+			return (0);
+	tail = size & (BITS_PER_LONG - 1);
+	if (tail) {
+		mask = BIT_MASK(tail);
+		if ((addr[i] & mask) != 0)
+			return (0);
+	}
+	return (1);
+}
+
+#define	NBLONG BITS_PER_LONG
+
+#define	set_bit(i, a)							\
+    atomic_or64(&((volatile long *)(a))[(i)/NBLONG], 1 << (i) % NBLONG)
+
+#define	clear_bit(i, a)							\
+    atomic_and64(&((volatile long *)(a))[(i)/NBLONG], ~(1 << (i) % NBLONG))
+
+#define	test_bit(i, a)							\
+    !!(atomic_get64(&((volatile long *)(a))[(i)/NBLONG]) & 1 << ((i) % NBLONG))
+
+static inline long
+test_and_clear_bit(long bit, long *var)
+{
+	long val;
+
+	var += bit / BITS_PER_LONG;
+	bit %= BITS_PER_LONG;
+	bit = 1 << bit;
+	do {
+		val = *(volatile long *)var;
+#if BITS_PER_LONG == 32
+	} while (atomic_test_and_set((long*)var, val & ~bit, val) == 0);
+#else
+	} while (atomic_test_and_set64((long*)var, val & ~bit, val) == 0);
+#endif
+
+	return !!(val & bit);
+}
+
+static inline long
+test_and_set_bit(long bit, volatile unsigned long *var)
+{
+	long val;
+
+	var += bit / BITS_PER_LONG;
+	bit %= BITS_PER_LONG;
+	bit = 1 << bit;
+	do {
+		val = *(volatile long *)var;
+#if BITS_PER_LONG == 32
+	} while (atomic_test_and_set((long*)var, val | bit, val) == 0);
+#else
+	} while (atomic_test_and_set64((long*)var, val | bit, val) == 0);
+#endif
+
+	return !!(val & bit);
+}
+
+
+#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))
+#define BITMAP_LAST_WORD_MASK(nbits)                                    \
+(                                                                       \
+        ((nbits) % BITS_PER_LONG) ?                                     \
+                (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL               \
+)
+
+
+static inline void
+bitmap_set(unsigned long *map, int start, int nr)
+{
+	unsigned long *p = map + BIT_WORD(start);
+	const int size = start + nr;
+	int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
+	unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
+
+	while (nr - bits_to_set >= 0) {
+		*p |= mask_to_set;
+		nr -= bits_to_set;
+		bits_to_set = BITS_PER_LONG;
+		mask_to_set = ~0UL;
+		p++;
+	}
+	if (nr) {
+		mask_to_set &= BITMAP_LAST_WORD_MASK(size);
+		*p |= mask_to_set;
+	}
+}
+
+static inline void
+bitmap_clear(unsigned long *map, int start, int nr)
+{
+	unsigned long *p = map + BIT_WORD(start);
+	const int size = start + nr;
+	int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
+	unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
+
+	while (nr - bits_to_clear >= 0) {
+		*p &= ~mask_to_clear;
+		nr -= bits_to_clear;
+		bits_to_clear = BITS_PER_LONG;
+		mask_to_clear = ~0UL;
+		p++;
+	}
+	if (nr) {
+		mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
+		*p &= ~mask_to_clear;
+	}
+}
+
+enum {
+        REG_OP_ISFREE,          /* true if region is all zero bits */
+        REG_OP_ALLOC,           /* set all bits in region */
+        REG_OP_RELEASE,         /* clear all bits in region */
+};
+
+static int __reg_op(unsigned long *bitmap, int pos, int order, int reg_op)
+{
+        int nbits_reg;          /* number of bits in region */
+        int index;              /* index first long of region in bitmap */
+        int offset;             /* bit offset region in bitmap[index] */
+        int nlongs_reg;         /* num longs spanned by region in bitmap */
+        int nbitsinlong;        /* num bits of region in each spanned long */
+        unsigned long mask;     /* bitmask for one long of region */
+        int i;                  /* scans bitmap by longs */
+        int ret = 0;            /* return value */
+
+        /*
+         * Either nlongs_reg == 1 (for small orders that fit in one long)
+         * or (offset == 0 && mask == ~0UL) (for larger multiword orders.)
+         */
+        nbits_reg = 1 << order;
+        index = pos / BITS_PER_LONG;
+        offset = pos - (index * BITS_PER_LONG);
+        nlongs_reg = BITS_TO_LONGS(nbits_reg);
+        nbitsinlong = min_c(nbits_reg,  BITS_PER_LONG);
+
+        /*
+         * Can't do "mask = (1UL << nbitsinlong) - 1", as that
+         * overflows if nbitsinlong == BITS_PER_LONG.
+         */
+        mask = (1UL << (nbitsinlong - 1));
+        mask += mask - 1;
+        mask <<= offset;
+
+        switch (reg_op) {
+        case REG_OP_ISFREE:
+                for (i = 0; i < nlongs_reg; i++) {
+                        if (bitmap[index + i] & mask)
+                                goto done;
+                }
+                ret = 1;        /* all bits in region free (zero) */
+                break;
+
+        case REG_OP_ALLOC:
+                for (i = 0; i < nlongs_reg; i++)
+                        bitmap[index + i] |= mask;
+                break;
+
+        case REG_OP_RELEASE:
+                for (i = 0; i < nlongs_reg; i++)
+                        bitmap[index + i] &= ~mask;
+                break;
+        }
+done:
+        return ret;
+}
+
+/**
+ * bitmap_find_free_region - find a contiguous aligned mem region
+ *      @bitmap: array of unsigned longs corresponding to the bitmap
+ *      @bits: number of bits in the bitmap
+ *      @order: region size (log base 2 of number of bits) to find
+ *
+ * Find a region of free (zero) bits in a @bitmap of @bits bits and
+ * allocate them (set them to one).  Only consider regions of length
+ * a power (@order) of two, aligned to that power of two, which
+ * makes the search algorithm much faster.
+ *
+ * Return the bit offset in bitmap of the allocated region,
+ * or -errno on failure.
+ */
+static inline int 
+bitmap_find_free_region(unsigned long *bitmap, int bits, int order)
+{
+        int pos, end;           /* scans bitmap by regions of size order */
+
+        for (pos = 0 ; (end = pos + (1 << order)) <= bits; pos = end) {
+                if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
+                        continue;
+                __reg_op(bitmap, pos, order, REG_OP_ALLOC);
+                return pos;
+        }
+        return -ENOMEM;
+}
+
+/**
+ * bitmap_release_region - release allocated bitmap region
+ *      @bitmap: array of unsigned longs corresponding to the bitmap
+ *      @pos: beginning of bit region to release
+ *      @order: region size (log base 2 of number of bits) to release
+ *
+ * This is the complement to __bitmap_find_free_region() and releases
+ * the found region (by clearing it in the bitmap).
+ *
+ * No return value.
+ */
+static inline void 
+bitmap_release_region(unsigned long *bitmap, int pos, int order)
+{
+        __reg_op(bitmap, pos, order, REG_OP_RELEASE);
+}
+
+#include <asm/bitops/non-atomic.h>
+#include <asm/bitops/const_hweight.h>
+
+#endif	/* _LINUX_BITOPS_H_ */
diff --git a/headers/compatibility/linux/linux/cdev.h b/headers/compatibility/linux/linux/cdev.h
new file mode 100644
index 0000000000..df3a700dca
--- /dev/null
+++ b/headers/compatibility/linux/linux/cdev.h
@@ -0,0 +1,110 @@
+/*-
+ * 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.
+ */
+
+#ifndef	_LINUX_CDEV_H_
+#define	_LINUX_CDEV_H_
+
+#include <linux/kobject.h>
+#include <linux/kdev_t.h>
+#include <linux/list.h>
+
+struct file_operations;
+struct inode;
+struct module;
+
+struct cdev {
+	struct kobject kobj;
+	struct module* owner;
+	const struct file_operations* ops;
+
+	dev_t dev;
+	unsigned count;
+	struct list_head entry;
+};
+
+
+extern int cdev_add(struct cdev* cdev, dev_t dev, unsigned count);
+
+
+static inline void
+cdev_release(struct kobject *kobj)
+{
+	struct cdev* cdev;
+
+	cdev = container_of(kobj, struct cdev, kobj);
+	kfree(cdev);
+}
+
+static inline void
+cdev_static_release(struct kobject *kobj)
+{
+}
+
+static struct kobj_type cdev_ktype = {
+	.release = cdev_release,
+};
+
+static struct kobj_type cdev_static_ktype = {
+	.release = cdev_static_release,
+};
+
+static inline void
+cdev_init(struct cdev* cdev, const struct file_operations *ops)
+{
+	kobject_init(&cdev->kobj, &cdev_static_ktype);
+	cdev->ops = ops;
+}
+
+static inline struct cdev*
+cdev_alloc(void)
+{
+	struct cdev* cdev;
+
+	cdev = kzalloc(sizeof(struct cdev), GFP_KERNEL);
+	if (cdev != NULL)
+		kobject_init(&cdev->kobj, &cdev_ktype);
+	return cdev;
+}
+
+static inline void
+cdev_put(struct cdev *p)
+{
+	kobject_put(&p->kobj);
+}
+
+
+
+static inline void
+cdev_del(struct cdev* cdev)
+{
+	kobject_put(&cdev->kobj);
+}
+
+
+#endif	/* _LINUX_CDEV_H_ */
diff --git a/headers/compatibility/linux/linux/compiler.h b/headers/compatibility/linux/linux/compiler.h
new file mode 100644
index 0000000000..75de7265a4
--- /dev/null
+++ b/headers/compatibility/linux/linux/compiler.h
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * 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.
+ */
+
+#ifndef	_LINUX_COMPILER_H_
+#define	_LINUX_COMPILER_H_
+
+#include <sys/cdefs.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 __init
+#define	__devinit
+#define	__devexit
+#define __exit
+#define	__stringify(x)			#x
+#define	__attribute_const__		__attribute__((__const__))
+#undef __always_inline
+#define	__always_inline			inline
+
+#if __GNUC__ >= 4
+#define	likely(x)			__builtin_expect(!!(x), 1)
+#define	unlikely(x)			__builtin_expect(!!(x), 0)
+#else
+#define likely(x)			x
+#define unlikely(x)			x
+#endif
+
+#define typeof(x)			__typeof(x)
+
+#define __read_mostly
+#define __always_unused
+#define __must_check			__heedresult
+
+#endif	/* _LINUX_COMPILER_H_ */
diff --git a/headers/compatibility/linux/linux/device.h b/headers/compatibility/linux/linux/device.h
new file mode 100644
index 0000000000..3728183e51
--- /dev/null
+++ b/headers/compatibility/linux/linux/device.h
@@ -0,0 +1,370 @@
+/*-
+ * 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.
+ */
+#ifndef	_LINUX_DEVICE_H_
+#define	_LINUX_DEVICE_H_
+
+#include <linux/types.h>
+#include <linux/kobject.h>
+#include <linux/list.h>
+#include <linux/compiler.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/workqueue.h>
+#include <linux/sysfs.h>
+#include <linux/kdev_t.h>
+
+#include <stdio.h>
+
+
+enum irqreturn	{ IRQ_NONE = 0, IRQ_HANDLED, IRQ_WAKE_THREAD, };
+typedef enum irqreturn	irqreturn_t;
+
+struct device;
+
+
+struct class {
+	const char* name;
+	struct module* owner;
+	struct kobject kobj;
+
+	void (*class_release)(struct class* class);
+	void (*dev_release)(struct device* dev);
+	char* (*devnode)(struct device* dev, umode_t* mode);
+};
+
+struct device {
+	struct device* parent;
+	struct list_head irqents;
+
+	dev_t devt;
+	struct class* class;
+	struct kobject kobj;
+
+	void (*release)(struct device *dev);
+	uint64_t* dma_mask;
+	void* driver_data;
+
+	unsigned int irq;
+	unsigned int msix;
+	unsigned int msix_max;
+
+	// Private
+	struct device_node* node;
+};
+
+
+struct device_driver {
+};
+
+// TODO
+//extern struct device linux_rootdev;
+extern struct kobject class_root;
+
+
+struct class_attribute {
+    struct attribute attr;
+    ssize_t (*show)(struct class *, struct class_attribute *, char *);
+    ssize_t (*store)(struct class *, struct class_attribute *, const char *, size_t);
+    const void *(*namespace)(struct class *, const struct class_attribute *);
+};
+
+#define	CLASS_ATTR(_name, _mode, _show, _store)				\
+	struct class_attribute class_attr_##_name =			\
+	    { { #_name, NULL, _mode }, _show, _store }
+
+struct device_attribute {
+	struct attribute	attr;
+	ssize_t			(*show)(struct device *,
+					struct device_attribute *, char *);
+	ssize_t			(*store)(struct device *,
+					struct device_attribute *, const char *,
+					size_t);
+};
+
+#define	DEVICE_ATTR(_name, _mode, _show, _store)			\
+	struct device_attribute dev_attr_##_name =			\
+	    { { #_name, NULL, _mode }, _show, _store }
+
+/* Simple class attribute that is just a static string */
+struct class_attribute_string {
+	struct class_attribute attr;
+	char *str;
+};
+
+static inline ssize_t
+show_class_attr_string(struct class *class,
+				struct class_attribute *attr, char *buf)
+{
+	struct class_attribute_string *cs;
+	cs = container_of(attr, struct class_attribute_string, attr);
+	return snprintf(buf, PAGE_SIZE, "%s\n", cs->str);
+}
+
+/* Currently read-only only */
+#define _CLASS_ATTR_STRING(_name, _mode, _str) \
+	{ __ATTR(_name, _mode, show_class_attr_string, NULL), _str }
+#define CLASS_ATTR_STRING(_name, _mode, _str) \
+	struct class_attribute_string class_attr_##_name = \
+		_CLASS_ATTR_STRING(_name, _mode, _str)
+
+#define	dev_err(dev, fmt, ...)			kprintf(fmt, ##__VA_ARGS__)
+#define	dev_warn(dev, fmt, ...)			kprintf(fmt, ##__VA_ARGS__)
+#define	dev_info(dev, fmt, ...)			kprintf(fmt, ##__VA_ARGS__)
+#define	dev_printk(lvl, dev, fmt, ...)	kprintf(fmt, ##__VA_ARGS__)
+
+static inline void *
+dev_get_drvdata(struct device *dev)
+{
+	return dev->driver_data;
+}
+
+static inline void
+dev_set_drvdata(struct device *dev, void *data)
+{
+	dev->driver_data = data;
+}
+
+static inline struct device *
+get_device(struct device *dev)
+{
+	if (dev)
+		kobject_get(&dev->kobj);
+
+	return (dev);
+}
+
+static inline char *
+dev_name(const struct device *dev)
+{
+ 	return kobject_name(&dev->kobj);
+}
+
+#define	dev_set_name(_dev, _fmt, ...)					\
+	kobject_set_name(&(_dev)->kobj, (_fmt), ##__VA_ARGS__)
+
+static inline void
+put_device(struct device *dev)
+{
+	if (dev)
+		kobject_put(&dev->kobj);
+}
+
+static inline ssize_t
+class_show(struct kobject *kobj, struct attribute *attr, char *buf)
+{
+	struct class_attribute *dattr;
+	ssize_t error;
+
+	dattr = container_of(attr, struct class_attribute, attr);
+	error = -EIO;
+	if (dattr->show)
+		error = dattr->show(container_of(kobj, struct class, kobj),
+		    dattr, buf);
+	return (error);
+}
+
+static inline ssize_t
+class_store(struct kobject *kobj, struct attribute *attr, const char *buf,
+    size_t count)
+{
+	struct class_attribute *dattr;
+	ssize_t error;
+
+	dattr = container_of(attr, struct class_attribute, attr);
+	error = -EIO;
+	if (dattr->store)
+		error = dattr->store(container_of(kobj, struct class, kobj),
+		    dattr, buf, count);
+	return (error);
+}
+
+static inline void
+class_release(struct kobject *kobj)
+{
+	struct class *class;
+
+	class = container_of(kobj, struct class, kobj);
+	if (class->class_release)
+		class->class_release(class);
+}
+
+static struct sysfs_ops class_sysfs = {
+	.show  = class_show,
+	.store = class_store,
+};
+
+static struct kobj_type class_ktype = {
+	.release = class_release,
+	.sysfs_ops = &class_sysfs
+};
+
+static inline int
+class_register(struct class *class)
+{
+	kobject_init(&class->kobj, &class_ktype);
+	kobject_set_name(&class->kobj, class->name);
+	kobject_add(&class->kobj, &class_root, class->name);
+
+	return (0);
+}
+
+static inline void
+class_unregister(struct class *class)
+{
+	kobject_put(&class->kobj);
+}
+
+static inline void
+device_release(struct kobject *kobj)
+{
+	struct device *dev;
+
+	dev = container_of(kobj, struct device, kobj);
+	/* This is the precedence defined by linux. */
+	if (dev->release)
+		dev->release(dev);
+	else if (dev->class && dev->class->dev_release)
+		dev->class->dev_release(dev);
+}
+
+static inline ssize_t
+dev_show(struct kobject *kobj, struct attribute *attr, char *buf)
+{
+	struct device_attribute *dattr;
+	ssize_t error;
+
+	dattr = container_of(attr, struct device_attribute, attr);
+	error = -EIO;
+	if (dattr->show)
+		error = dattr->show(container_of(kobj, struct device, kobj),
+		    dattr, buf);
+	return (error);
+}
+
+static inline ssize_t
+dev_store(struct kobject *kobj, struct attribute *attr, const char *buf,
+    size_t count)
+{
+	struct device_attribute *dattr;
+	ssize_t error;
+
+	dattr = container_of(attr, struct device_attribute, attr);
+	error = -EIO;
+	if (dattr->store)
+		error = dattr->store(container_of(kobj, struct device, kobj),
+		    dattr, buf, count);
+	return (error);
+}
+
+static struct sysfs_ops dev_sysfs = { .show  = dev_show, .store = dev_store, };
+static struct kobj_type dev_ktype = {
+	.release = device_release,
+	.sysfs_ops = &dev_sysfs
+};
+
+
+extern void device_initialize(struct device* dev);
+extern int device_register(struct device* dev);
+extern void device_unregister(struct device* dev);
+
+extern struct device* device_create(struct class* class, struct device* parent,
+	dev_t devt, void* drvdata, const char* fmt, ...);
+extern void device_destroy(struct class *class, dev_t devt);
+
+
+static inline void
+class_kfree(struct class* class)
+{
+	kfree(class);
+}
+
+static inline struct class*
+class_create(struct module* owner, const char* name)
+{
+	struct class* class;
+	int error;
+
+	class = kzalloc(sizeof(*class), GFP_KERNEL);
+	class->owner = owner;
+	class->name= name;
+	class->class_release = class_kfree;
+	error = class_register(class);
+	if (error) {
+		kfree(class);
+		return (NULL);
+	}
+
+	return (class);
+}
+
+static inline void
+class_destroy(struct class *class)
+{
+	if (class == NULL)
+		return;
+	class_unregister(class);
+}
+
+static inline int
+device_create_file(struct device *dev, const struct device_attribute *attr)
+{
+	if (dev)
+		return sysfs_create_file(&dev->kobj, &attr->attr);
+	return -EINVAL;
+}
+
+static inline void
+device_remove_file(struct device *dev, const struct device_attribute *attr)
+{
+	if (dev)
+		sysfs_remove_file(&dev->kobj, &attr->attr);
+}
+
+static inline int
+class_create_file(struct class *class, const struct class_attribute *attr)
+{
+	if (class)
+		return sysfs_create_file(&class->kobj, &attr->attr);
+	return -EINVAL;
+}
+
+static inline void
+class_remove_file(struct class *class, const struct class_attribute *attr)
+{
+	if (class)
+		sysfs_remove_file(&class->kobj, &attr->attr);
+}
+
+static inline int dev_to_node(struct device *dev)
+{
+    return -1;
+}
+
+
+#endif	/* _LINUX_DEVICE_H_ */
diff --git a/headers/compatibility/linux/linux/dma-fence.h b/headers/compatibility/linux/linux/dma-fence.h
new file mode 100644
index 0000000000..e119abdf5e
--- /dev/null
+++ b/headers/compatibility/linux/linux/dma-fence.h
@@ -0,0 +1,4 @@
+#ifndef _LINUX_DMA_FENCE_H_
+#define _LINUX_DMA_FENCE_H_
+
+#endif /* _LINUX_DMA_FENCE_H_ */
diff --git a/headers/compatibility/linux/linux/dma-mapping.h b/headers/compatibility/linux/linux/dma-mapping.h
new file mode 100644
index 0000000000..2849931f78
--- /dev/null
+++ b/headers/compatibility/linux/linux/dma-mapping.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _H
+#define _H
+
+
+#endif
diff --git a/headers/compatibility/linux/linux/errno.h b/headers/compatibility/linux/linux/errno.h
new file mode 100644
index 0000000000..4592c1889b
--- /dev/null
+++ b/headers/compatibility/linux/linux/errno.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014 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.
+ */
+
+#ifndef _LINUX_ERRNO_H_
+#define _LINUX_ERRNO_H_
+
+#define ERESTARTSYS	EINTR
+
+#endif	/* _LINUX_ERRNO_H_ */
diff --git a/headers/compatibility/linux/linux/file.h b/headers/compatibility/linux/linux/file.h
new file mode 100644
index 0000000000..2849931f78
--- /dev/null
+++ b/headers/compatibility/linux/linux/file.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _H
+#define _H
+
+
+#endif
diff --git a/headers/compatibility/linux/linux/fs.h b/headers/compatibility/linux/linux/fs.h
new file mode 100644
index 0000000000..11dcc5ad1f
--- /dev/null
+++ b/headers/compatibility/linux/linux/fs.h
@@ -0,0 +1,134 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 Mellanox Technologies, Ltd.
+ * Copyright (c) 2015 Hamish Morrison
+ * 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.
+ */
+#ifndef	_LINUX_FS_H_
+#define	_LINUX_FS_H_
+
+#include <linux/types.h>
+
+struct inode;
+struct module;
+struct vm_area_struct;
+struct poll_table_struct;
+
+
+#define	S_IRUGO	(S_IRUSR | S_IRGRP | S_IROTH)
+#define	S_IWUGO	(S_IWUSR | S_IWGRP | S_IWOTH)
+
+
+struct file_operations;
+
+struct file {
+	const struct file_operations* f_op;
+	void* private_data;
+	int f_flags;
+	int f_mode;
+
+	// Private
+	struct inode* inode;
+};
+
+struct inode {
+	umode_t i_mode;
+	unsigned int i_flags;
+	dev_t i_rdev;
+	union {
+		struct cdev* i_cdev;
+	};
+	void* i_private;
+};
+
+
+struct file_operations {
+	struct module* owner;
+
+	int (*open)(struct inode *, struct file *);
+	int (*release)(struct inode *, struct file *);
+	ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
+	ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
+
+	long (*unlocked_ioctl)(struct file *, unsigned int, unsigned long);
+	loff_t (*llseek)(struct file *, loff_t, int);
+	unsigned int (*poll) (struct file *, struct poll_table_struct *);
+	int (*mmap)(struct file *, struct vm_area_struct *);
+};
+
+#define	fops_get(fops) (fops)
+#define replace_fops(file, fops) ((file)->f_op = (fops))
+
+
+#define	FMODE_READ	FREAD
+#define	FMODE_WRITE	FWRITE
+#define	FMODE_EXEC	FEXEC
+
+
+extern int register_chrdev(unsigned int major, const char* name,
+	const struct file_operations* ops);
+extern void unregister_chrdev(unsigned int major, const char* name);
+
+static inline int
+register_chrdev_region(dev_t dev, unsigned range, const char*name)
+{
+	return 0;
+}
+
+static inline void
+unregister_chrdev_region(dev_t dev, unsigned range)
+{
+	return;
+}
+
+static inline int
+alloc_chrdev_region(dev_t* dev, unsigned baseminor, unsigned count,
+	const char* name)
+{
+	// TODO
+	return 0;
+}
+
+static inline dev_t iminor(struct inode* inode)
+{
+	return MINOR(inode->i_rdev);
+}
+
+static inline dev_t imajor(struct inode* inode)
+{
+	return MAJOR(inode->i_rdev);
+}
+
+static inline struct inode* igrab(struct inode* inode)
+{
+	return inode;
+}
+
+static inline void iput(struct inode* inode)
+{
+}
+
+#endif /* _LINUX_FS_H_ */
diff --git a/headers/compatibility/linux/linux/gfp.h b/headers/compatibility/linux/linux/gfp.h
new file mode 100644
index 0000000000..86d3815f3c
--- /dev/null
+++ b/headers/compatibility/linux/linux/gfp.h
@@ -0,0 +1,135 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 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.
+ */
+
+#ifndef	_LINUX_GFP_H_
+#define	_LINUX_GFP_H_
+
+#include <malloc.h>
+
+
+struct page {
+	void* address;
+};
+
+
+#define	__GFP_NOWARN	0
+#define	__GFP_HIGHMEM	0
+#define	__GFP_ZERO		0x08
+
+#define GFP_KERNEL		0
+#define GFP_USER		0
+#define	GFP_HIGHUSER	0
+#define	GFP_HIGHUSER_MOVABLE	0
+#define	GFP_NOWAIT		HEAP_DONT_WAIT_FOR_MEMORY
+#define	GFP_ATOMIC		HEAP_DONT_WAIT_FOR_MEMORY
+#define	GFP_IOFS		HEAP_DONT_WAIT_FOR_MEMORY
+
+static inline void*
+page_address(struct page *page)
+{
+	return page->address;
+}
+
+#if 0
+
+static inline unsigned long
+_get_page(gfp_t mask)
+{
+	return (unsigned long)memalign_etc(PAGE_SIZE, PAGE_SIZE, mask);
+}
+
+static inline unsigned long
+get_zeroed_page(gfp_t mask)
+{
+	unsigned long page = _get_page(mask);
+	memset((void*)page, 0, PAGE_SIZE);
+	return page;
+}
+
+#define	get_zeroed_page(mask)	_get_page((mask) | M_ZERO)
+#define	alloc_page(mask)	virt_to_page(_get_page((mask)))
+#define	__get_free_page(mask)	_get_page((mask))
+
+static inline void
+free_page(unsigned long page)
+{
+
+	if (page == 0)
+		return;
+	kmem_free(kmem_arena, page, PAGE_SIZE);
+}
+
+static inline void
+__free_page(struct page *m)
+{
+
+	if (m->object != kmem_object)
+		panic("__free_page:  Freed page %p not allocated via wrappers.",
+		    m);
+	kmem_free(kmem_arena, (vm_offset_t)page_address(m), PAGE_SIZE);
+}
+
+static inline void
+__free_pages(struct page *m, unsigned int order)
+{
+	size_t size;
+
+	if (m == NULL)
+		return;
+	size = PAGE_SIZE << order;
+	kmem_free(kmem_arena, (vm_offset_t)page_address(m), size);
+}
+
+/*
+ * Alloc pages allocates directly from the buddy allocator on linux so
+ * order specifies a power of two bucket of pages and the results
+ * are expected to be aligned on the size as well.
+ */
+static inline struct page*
+alloc_pages(gfp_t gfp_mask, unsigned int order)
+{
+	void* address;
+	size_t size;
+
+	size = PAGE_SIZE << order;
+	area_id area = create_area("linux pages", &address, B_ANY_KERNEL_ADDRESS,
+		size, B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA);
+	if (area < 0)
+		return NULL;
+
+	return page_struct(address);
+}
+
+#define alloc_pages_node(node, mask, order)     alloc_pages(mask, order)
+
+#define kmalloc_node(chunk, mask, node)         kmalloc(chunk, mask)
+
+#endif
+
+#endif	/* _LINUX_GFP_H_ */
diff --git a/headers/compatibility/linux/linux/highmem.h b/headers/compatibility/linux/linux/highmem.h
new file mode 100644
index 0000000000..2849931f78
--- /dev/null
+++ b/headers/compatibility/linux/linux/highmem.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _H
+#define _H
+
+
+#endif
diff --git a/headers/compatibility/linux/linux/idr.h b/headers/compatibility/linux/linux/idr.h
new file mode 100644
index 0000000000..553c40b3f8
--- /dev/null
+++ b/headers/compatibility/linux/linux/idr.h
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 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.
+ */
+
+#ifndef	_LINUX_IDR_H_
+#define	_LINUX_IDR_H_
+
+#include <lock.h>
+#include <linux/types.h>
+
+#define NBBY		8
+
+#define	IDR_BITS	5
+#define	IDR_SIZE	(1 << IDR_BITS)
+#define	IDR_MASK	(IDR_SIZE - 1)
+
+#define	MAX_ID_SHIFT	((sizeof(int) * NBBY) - 1)
+#define	MAX_ID_BIT	(1U << MAX_ID_SHIFT)
+#define	MAX_ID_MASK	(MAX_ID_BIT - 1)
+#define	MAX_LEVEL	(MAX_ID_SHIFT + IDR_BITS - 1) / IDR_BITS
+
+#define MAX_IDR_SHIFT (sizeof(int)*8 - 1)
+#define MAX_IDR_BIT (1U << MAX_IDR_SHIFT)
+#define MAX_IDR_MASK (MAX_IDR_BIT - 1)
+
+struct idr_layer {
+	unsigned long bitmap;
+	struct idr_layer* ary[IDR_SIZE];
+};
+
+struct idr {
+	mutex lock;
+	struct idr_layer* top;
+	struct idr_layer* avail;
+	int layers;
+};
+
+#define DEFINE_IDR(name)						\
+	struct idr name = {							\
+		.lock = MUTEX_INITIALIZER("linux idr")	\
+	};
+
+void	*idr_find(struct idr *idp, int id);
+int	idr_pre_get(struct idr *idp, gfp_t gfp_mask);
+int	idr_get_new(struct idr *idp, void *ptr, int *id);
+int	idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
+void	*idr_replace(struct idr *idp, void *ptr, int id);
+void	idr_remove(struct idr *idp, int id);
+void	idr_remove_all(struct idr *idp);
+void	idr_destroy(struct idr *idp);
+void	idr_init(struct idr *idp);
+int		idr_alloc(struct idr* idr, void* ptr, int start, int end, gfp_t mask);
+
+#endif	/* _LINUX_IDR_H_ */
diff --git a/headers/compatibility/linux/linux/init.h b/headers/compatibility/linux/linux/init.h
new file mode 100644
index 0000000000..317c5bf828
--- /dev/null
+++ b/headers/compatibility/linux/linux/init.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2015 Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _LINUX_INIT_H
+#define _LINUX_INIT_H
+
+
+typedef int (*initcall_t)(void);
+
+
+#define __init
+
+#define module_init(func) \
+	static initcall_t __attribute__ ((section(".module_init"))) \
+		__init_##func = func;
+
+
+#endif
diff --git a/headers/compatibility/linux/linux/io.h b/headers/compatibility/linux/linux/io.h
new file mode 100644
index 0000000000..a59d652916
--- /dev/null
+++ b/headers/compatibility/linux/linux/io.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014 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.
+ */
+
+#ifndef _LINUX_IO_H_
+#define _LINUX_IO_H_
+
+#include <asm/io.h>
+
+static inline void
+writel(uint32_t value, void* addr)
+{
+	*(volatile uint32_t*)addr = value;
+}
+
+static inline uint32_t
+readl(void* addr)
+{
+	return *(volatile uint32_t*)addr;
+}
+
+#endif	/* _LINUX_IO_H_ */
diff --git a/headers/compatibility/linux/linux/jiffies.h b/headers/compatibility/linux/linux/jiffies.h
new file mode 100644
index 0000000000..a09339cbef
--- /dev/null
+++ b/headers/compatibility/linux/linux/jiffies.h
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#ifndef _LINUX_JIFFIES_H_
+#define _LINUX_JIFFIES_H_
+
+#include <linux/math64.h>
+#include <linux/time.h>
+
+#define HZ 1000000
+
+#define jiffies_to_msecs(x)	(((int64_t)(x)) * 1000 / HZ)
+#define msecs_to_jiffies(x)	(((int64_t)(x)) * HZ / 1000)
+#define jiffies			ticks
+#define time_after(a,b)		((long)(b) - (long)(a) < 0)
+#define time_after_eq(a,b)	((long)(b) - (long)(a) <= 0)
+
+static inline unsigned long
+timespec_to_jiffies(const struct timespec *ts)
+{
+	unsigned long result;
+
+	result = ((unsigned long)HZ * ts->tv_sec) + (ts->tv_nsec / NSEC_PER_SEC);
+	if (result > LONG_MAX)
+		result = LONG_MAX;
+
+	return result;
+}
+
+static inline
+unsigned long usecs_to_jiffies(const unsigned int u)
+{
+	unsigned long result;
+
+	result = (u * HZ) / 1000000;
+	if (result < 1)
+		return 1;
+	else
+		return result;
+}
+
+#endif	/* _LINUX_JIFFIES_H_ */
diff --git a/headers/compatibility/linux/linux/kdev_t.h b/headers/compatibility/linux/linux/kdev_t.h
new file mode 100644
index 0000000000..11fce8f26d
--- /dev/null
+++ b/headers/compatibility/linux/linux/kdev_t.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2015 Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _LINUX_KDEV_T_H
+#define _LINUX_KDEV_T_H
+
+#define MAJOR(devt) ((devt) >> 20)
+#define MINOR(devt) ((devt) & 0xfffff)
+#define MKDEV(major, minor) (((major) << 20) | (minor))
+
+#endif
diff --git a/headers/compatibility/linux/linux/kernel.h b/headers/compatibility/linux/linux/kernel.h
new file mode 100644
index 0000000000..f4009aa5a4
--- /dev/null
+++ b/headers/compatibility/linux/linux/kernel.h
@@ -0,0 +1,197 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2014 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.
+ */
+#ifndef	_LINUX_KERNEL_H_
+#define	_LINUX_KERNEL_H_
+
+#include <linux/bitops.h>
+#include <linux/compiler.h>
+#include <linux/log2.h>
+#include <linux/types.h>
+
+#include <stdarg.h>
+
+#define PAGE_SHIFT 12
+
+#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 BUG()	do				\
+{						\
+	panic("BUG in %s at %s:%u",		\
+		__func__, __FILE__, __LINE__);	\
+} while (0)
+
+#define BUG_ON(condition)	do { if (condition) BUG(); } while(0)
+
+#define _WARN_STR(x) #x
+
+#define WARN_ON(condition) ({						\
+	int __ret = !!(condition);					\
+	if (__ret)							\
+		kprintf("WARNING %s failed at %s:%d\n",			\
+		    _WARN_STR(condition), __FILE__, __LINE__);			\
+	unlikely(__ret);						\
+})
+
+#define WARN_ON_ONCE(condition) ({					\
+	static int __warned;						\
+	int __ret = !!(condition);					\
+	if (__ret && !__warned) {					\
+		kprintf("WARNING %s failed at %s:%d\n",			\
+		    _WARN_STR(condition), __FILE__, __LINE__);		\
+		__warned = 1;						\
+	}								\
+	unlikely(__ret);						\
+})
+
+#undef	ALIGN
+#define	ALIGN(x, y)		(((x) + ((y) - 1)) & ~((y) - 1))
+#define	DIV_ROUND_UP	(((x) + ((y) - 1)) / (y))
+
+#define	printk(X...)		kprintf(X)
+#define	pr_debug(fmt, ...)	printk(KERN_DEBUG # fmt, ##__VA_ARGS__)
+
+#ifndef pr_fmt
+#define pr_fmt(fmt) fmt
+#endif
+
+/*
+ * Print a one-time message (analogous to WARN_ONCE() et al):
+ */
+#define printk_once(x...) ({                    \
+        static bool __print_once;               \
+                                                \
+        if (!__print_once) {                    \
+                __print_once = true;            \
+                printk(x);                      \
+        }                                       \
+})
+
+
+
+#define pr_emerg(fmt, ...) \
+        printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_alert(fmt, ...) \
+        printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_crit(fmt, ...) \
+        printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err(fmt, ...) \
+        kprintf(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warning(fmt, ...) \
+        printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warn pr_warning
+#define pr_notice(fmt, ...) \
+        printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info(fmt, ...) \
+        printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_cont(fmt, ...) \
+        printk(KERN_CONT fmt, ##__VA_ARGS__)
+
+/* pr_devel() should produce zero code unless DEBUG is defined */
+#ifdef DEBUG
+#define pr_devel(fmt, ...) \
+        printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#else
+#define pr_devel(fmt, ...) \
+        ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
+#endif
+
+#ifndef WARN
+#define WARN(condition, format...) ({                                   \
+        int __ret_warn_on = !!(condition);                              \
+        if (unlikely(__ret_warn_on))                                    \
+                pr_warning(format);                                     \
+        unlikely(__ret_warn_on);                                        \
+})
+#endif
+
+#define WARN_ONCE(condition, format...)	({	\
+	static bool __warned_once;		\
+						\
+	if ((condition) && !__warned_once) {	\
+		WARN(condition, format);	\
+		__warned_once = true;		\
+	}					\
+})
+
+#define container_of(ptr, type, member)				\
+({								\
+	__typeof(((type *)0)->member) *_p = (ptr);		\
+	(type *)((char *)_p - offsetof(type, member));		\
+})
+
+#define	ARRAY_SIZE(x)	(sizeof(x) / sizeof((x)[0]))
+
+#define	simple_strtoul	strtoul
+#define	simple_strtol	strtol
+
+//#define min(x, y)	(x < y ? x : y)
+//#define max(x, y)	(x > y ? x : y)
+#define min_t(type, _x, _y)	(type)(_x) < (type)(_y) ? (type)(_x) : (_y)
+#define max_t(type, _x, _y)	(type)(_x) > (type)(_y) ? (type)(_x) : (_y)
+
+/*
+ * 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	num_possible_cpus()	mp_ncpus
+
+typedef struct pm_message {
+        int event;
+} pm_message_t;
+
+/* Swap values of a and b */
+#define swap(a, b)			\
+({					\
+	typeof(a) _swap_tmp = a;	\
+	a = b;				\
+	b = _swap_tmp;			\
+})
+
+#define DIV_ROUND_CLOSEST(x, divisor)	(((x) + ((divisor) /2)) / (divisor))
+
+
+extern char* kvasprintf(gfp_t gfp, const char* fmt, va_list ap);
+extern char* kasprintf(gfp_t gfp, const char* fmt, ...);
+
+
+#endif	/* _LINUX_KERNEL_H_ */
diff --git a/headers/compatibility/linux/linux/kobject.h b/headers/compatibility/linux/linux/kobject.h
new file mode 100644
index 0000000000..6195a1966b
--- /dev/null
+++ b/headers/compatibility/linux/linux/kobject.h
@@ -0,0 +1,168 @@
+/*-
+ * 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.
+ */
+#ifndef	_LINUX_KOBJECT_H_
+#define	_LINUX_KOBJECT_H_
+
+#include <linux/kernel.h>
+#include <linux/kref.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+
+#include <stdio.h>
+
+
+struct kobject;
+
+
+struct kobj_type {
+	void (*release)(struct kobject *kobj);
+	const struct sysfs_ops *sysfs_ops;
+	struct attribute **default_attrs;
+};
+
+extern struct kobj_type kfree_type;
+
+struct kobject {
+	struct kobject *parent;
+	char *name;
+	struct kref kref;
+	struct kobj_type *ktype;
+	struct list_head entry;
+};
+
+extern struct kobject *mm_kobj;
+
+static inline void
+kobject_init(struct kobject *kobj, struct kobj_type *ktype)
+{
+
+	kref_init(&kobj->kref);
+	INIT_LIST_HEAD(&kobj->entry);
+	kobj->ktype = ktype;
+}
+
+static inline void kobject_put(struct kobject *kobj);
+void kobject_release(struct kref *kref);
+
+static inline void
+kobject_put(struct kobject *kobj)
+{
+	if (kobj)
+		kref_put(&kobj->kref, kobject_release);
+}
+
+static inline struct kobject *
+kobject_get(struct kobject *kobj)
+{
+
+	if (kobj)
+		kref_get(&kobj->kref);
+	return kobj;
+}
+
+static inline int
+kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list args)
+{
+	char *old;
+	char *name;
+
+	old = kobj->name;
+
+	if (old && !fmt)
+		return 0;
+
+	name = kzalloc(MAXPATHLEN, GFP_KERNEL);
+	if (!name)
+		return -ENOMEM;
+	vsnprintf(name, MAXPATHLEN, fmt, args);
+	kobj->name = name;
+	kfree(old);
+	for (; *name != '\0'; name++)
+		if (*name == '/')
+			*name = '!';
+	return (0);
+}
+
+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, &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, struct kobj_type *ktype,
+	    struct kobject *parent, const char *fmt, ...);
+
+/* sysfs.h calles for 'kobject' which is defined here, 
+ * so we need to add the include only after the 'kobject' def.
+ */
+#include <linux/sysfs.h>
+
+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);
+};
+
+#endif /* _LINUX_KOBJECT_H_ */
diff --git a/headers/compatibility/linux/linux/kref.h b/headers/compatibility/linux/linux/kref.h
new file mode 100644
index 0000000000..45f4c9eae0
--- /dev/null
+++ b/headers/compatibility/linux/linux/kref.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 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.
+ */
+#ifndef _LINUX_KREF_H_
+#define _LINUX_KREF_H_
+
+#include <linux/atomic.h>
+
+struct kref {
+	atomic_t count;
+};
+
+static inline void
+kref_init(struct kref *kref)
+{
+	kref->count.counter = 1;
+}
+
+static inline void
+kref_get(struct kref *kref)
+{
+	atomic_add_return(1, &kref->count);
+}
+
+static inline int
+kref_put(struct kref *kref, void (*rel)(struct kref *kref))
+{
+	if (atomic_sub(1, &kref->count) <= 0) {
+		rel(kref);
+		return 1;
+	}
+	return 0;
+}
+
+static inline int
+kref_sub(struct kref *kref, unsigned int count,
+	     void (*rel)(struct kref *kref))
+{
+	if (atomic_sub(1, &kref->count) <= 0) {
+		rel(kref);
+		return 1;
+	}
+	return 0;
+}
+
+/*
+ * kref_get_unless_zero: Increment refcount for object unless it is zero.
+ */
+static inline int
+kref_get_unless_zero(struct kref *kref)
+{
+	return atomic_add_unless(&kref->count, 1, 0);
+}
+
+#endif /* _LINUX_KREF_H_ */
diff --git a/headers/compatibility/linux/linux/list.h b/headers/compatibility/linux/linux/list.h
new file mode 100644
index 0000000000..cbd56753f6
--- /dev/null
+++ b/headers/compatibility/linux/linux/list.h
@@ -0,0 +1,334 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * 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.
+ */
+#ifndef _LINUX_LIST_H_
+#define _LINUX_LIST_H_
+
+#include <stddef.h>
+
+
+struct list_head {
+	struct list_head *next;
+	struct list_head *prev;
+};
+
+static inline void
+INIT_LIST_HEAD(struct list_head *list)
+{
+	list->next = list->prev = list;
+}
+
+#define LIST_HEAD_INIT(list) { &(list), &(list) }
+ 
+static inline int
+list_empty(const struct list_head *head)
+{
+
+	return (head->next == head);
+}
+
+static inline void
+list_del(struct list_head *entry)
+{
+
+	entry->next->prev = entry->prev;
+	entry->prev->next = entry->next;
+}
+
+static inline void list_replace(struct list_head *old,
+    struct list_head *entry)
+{
+	entry->next = old->next;
+	entry->next->prev = entry;
+	entry->prev = old->prev;
+	entry->prev->next = entry;
+}
+
+static inline void
+_list_add(struct list_head *entry, struct list_head *prev,
+    struct list_head *next)
+{
+
+	next->prev = entry;
+	entry->next = next;
+	entry->prev = prev;
+	prev->next = entry;
+}
+
+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_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_continue_reverse(pos, head, member)         \
+        for (pos = list_entry(pos->member.prev, typeof(*pos), member);  \
+             &pos->member != (head);    				\
+             pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+#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_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_prev(p, h) for (p = (h)->prev; p != (h); p = p->prev)
+
+static inline void
+list_add(struct list_head *entry, struct list_head *head)
+{
+
+	_list_add(entry, head, head->next);
+}
+
+static inline void
+list_add_tail(struct list_head *entry, struct list_head *head)
+{
+
+	_list_add(entry, 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
+_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)
+{
+
+	_list_splice(list, head, head->next);
+} 
+
+static inline void
+list_splice_tail(struct list_head *list, struct list_head *head)
+{
+
+	_list_splice(list, head->prev, head);
+}
+ 
+static inline void
+list_splice_init(struct list_head *list, struct list_head *head)
+{
+
+	_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)
+{
+
+	_list_splice(list, head->prev, head);
+	INIT_LIST_HEAD(list);
+}
+
+#define LINUX_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 *from, struct hlist_head *to)
+{
+
+	to->first = from->first;
+	if (to->first)
+		to->first->pprev = &to->first;
+	from->first = NULL;
+}
+ 
+#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_for_each_entry(tp, p, head, field)			\
+	for (p = (head)->first;						\
+	    p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next)
+ 
+#define hlist_for_each_entry_continue(tp, p, field)			\
+	for (p = (p)->next;						\
+	    p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next)
+
+#define	hlist_for_each_entry_from(tp, p, field)				\
+	for (; p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next)
+
+#define	hlist_for_each_entry_safe(tp, p, n, head, field)		\
+	for (p = (head)->first;	p ?					\
+	    (n = p->next) | (tp = hlist_entry(p, typeof(*tp), field)) :	\
+	    NULL; p = n)
+
+void drm_list_sort(void *priv, struct list_head *head, int (*cmp)(void *priv,
+    struct list_head *a, struct list_head *b));
+
+#define	hlist_for_each_entry_rcu(tp, p, head, field)	\
+		hlist_for_each_entry(tp, p, head, field)
+
+#define hlist_add_after_rcu(prev, n)	hlist_add_after(prev, n)
+
+#define hlist_add_head_rcu(n, h)	hlist_add_head(n, h)
+
+#define	hlist_del_init_rcu(n)		hlist_del_init(n)
+
+#endif /* _LINUX_LIST_H_ */
diff --git a/headers/compatibility/linux/linux/log2.h b/headers/compatibility/linux/linux/log2.h
new file mode 100644
index 0000000000..108b0e79bc
--- /dev/null
+++ b/headers/compatibility/linux/linux/log2.h
@@ -0,0 +1,175 @@
+/*-
+ * 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.
+ */
+
+#ifndef	_LINUX_LOG2_H_
+#define	_LINUX_LOG2_H_
+
+#include <linux/bitops.h>
+#include <linux/types.h>
+
+static inline unsigned long
+roundup_pow_of_two(unsigned long x)
+{
+	if (x == 0)
+		return 1;
+	if (x == 1)
+		return 1;
+	return 1UL << (__flsl(x - 1) + 1);
+}
+
+static inline int
+is_power_of_2(unsigned long n)
+{
+	return n == roundup_pow_of_two(n);
+}
+
+static inline unsigned long
+rounddown_pow_of_two(unsigned long x)
+{
+	if (x == 1)
+		return 1;
+	return 1UL << __flsl(x);
+}
+
+
+/*
+ * deal with unrepresentable constant logarithms
+ */
+extern __attribute__((const, noreturn))
+int ____ilog2_NaN(void);
+
+/*
+ * non-constant log of base 2 calculators
+ * - the arch may override these in asm/bitops.h if they can be implemented
+ *   more efficiently than using fls() and fls64()
+ * - the arch is not required to handle n==0 if implementing the fallback
+ */
+#ifndef CONFIG_ARCH_HAS_ILOG2_U32
+static inline __attribute__((const))
+int __ilog2_u32(u32 n)
+{
+	return __flsl(n);
+}
+#endif
+
+#ifndef CONFIG_ARCH_HAS_ILOG2_U64
+static inline __attribute__((const))
+int __ilog2_u64(u64 n)
+{
+	return __flsl(n);
+}
+#endif
+
+
+/**
+ * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value
+ * @n - parameter
+ *
+ * constant-capable log of base 2 calculation
+ * - this can be used to initialise global variables from constant data, hence
+ *   the massive ternary operator construction
+ *
+ * selects the appropriately-sized optimised version depending on sizeof(n)
+ */
+#define ilog2(n)				\
+(						\
+	__builtin_constant_p(n) ? (		\
+		(n) < 1 ? ____ilog2_NaN() :	\
+		(n) & (1ULL << 63) ? 63 :	\
+		(n) & (1ULL << 62) ? 62 :	\
+		(n) & (1ULL << 61) ? 61 :	\
+		(n) & (1ULL << 60) ? 60 :	\
+		(n) & (1ULL << 59) ? 59 :	\
+		(n) & (1ULL << 58) ? 58 :	\
+		(n) & (1ULL << 57) ? 57 :	\
+		(n) & (1ULL << 56) ? 56 :	\
+		(n) & (1ULL << 55) ? 55 :	\
+		(n) & (1ULL << 54) ? 54 :	\
+		(n) & (1ULL << 53) ? 53 :	\
+		(n) & (1ULL << 52) ? 52 :	\
+		(n) & (1ULL << 51) ? 51 :	\
+		(n) & (1ULL << 50) ? 50 :	\
+		(n) & (1ULL << 49) ? 49 :	\
+		(n) & (1ULL << 48) ? 48 :	\
+		(n) & (1ULL << 47) ? 47 :	\
+		(n) & (1ULL << 46) ? 46 :	\
+		(n) & (1ULL << 45) ? 45 :	\
+		(n) & (1ULL << 44) ? 44 :	\
+		(n) & (1ULL << 43) ? 43 :	\
+		(n) & (1ULL << 42) ? 42 :	\
+		(n) & (1ULL << 41) ? 41 :	\
+		(n) & (1ULL << 40) ? 40 :	\
+		(n) & (1ULL << 39) ? 39 :	\
+		(n) & (1ULL << 38) ? 38 :	\
+		(n) & (1ULL << 37) ? 37 :	\
+		(n) & (1ULL << 36) ? 36 :	\
+		(n) & (1ULL << 35) ? 35 :	\
+		(n) & (1ULL << 34) ? 34 :	\
+		(n) & (1ULL << 33) ? 33 :	\
+		(n) & (1ULL << 32) ? 32 :	\
+		(n) & (1ULL << 31) ? 31 :	\
+		(n) & (1ULL << 30) ? 30 :	\
+		(n) & (1ULL << 29) ? 29 :	\
+		(n) & (1ULL << 28) ? 28 :	\
+		(n) & (1ULL << 27) ? 27 :	\
+		(n) & (1ULL << 26) ? 26 :	\
+		(n) & (1ULL << 25) ? 25 :	\
+		(n) & (1ULL << 24) ? 24 :	\
+		(n) & (1ULL << 23) ? 23 :	\
+		(n) & (1ULL << 22) ? 22 :	\
+		(n) & (1ULL << 21) ? 21 :	\
+		(n) & (1ULL << 20) ? 20 :	\
+		(n) & (1ULL << 19) ? 19 :	\
+		(n) & (1ULL << 18) ? 18 :	\
+		(n) & (1ULL << 17) ? 17 :	\
+		(n) & (1ULL << 16) ? 16 :	\
+		(n) & (1ULL << 15) ? 15 :	\
+		(n) & (1ULL << 14) ? 14 :	\
+		(n) & (1ULL << 13) ? 13 :	\
+		(n) & (1ULL << 12) ? 12 :	\
+		(n) & (1ULL << 11) ? 11 :	\
+		(n) & (1ULL << 10) ? 10 :	\
+		(n) & (1ULL <<  9) ?  9 :	\
+		(n) & (1ULL <<  8) ?  8 :	\
+		(n) & (1ULL <<  7) ?  7 :	\
+		(n) & (1ULL <<  6) ?  6 :	\
+		(n) & (1ULL <<  5) ?  5 :	\
+		(n) & (1ULL <<  4) ?  4 :	\
+		(n) & (1ULL <<  3) ?  3 :	\
+		(n) & (1ULL <<  2) ?  2 :	\
+		(n) & (1ULL <<  1) ?  1 :	\
+		(n) & (1ULL <<  0) ?  0 :	\
+		____ilog2_NaN()			\
+				   ) :		\
+	(sizeof(n) <= 4) ?			\
+	__ilog2_u32(n) :			\
+	__ilog2_u64(n)				\
+ )
+
+#endif	/* _LINUX_LOG2_H_ */
diff --git a/headers/compatibility/linux/linux/math64.h b/headers/compatibility/linux/linux/math64.h
new file mode 100644
index 0000000000..94650ca4a9
--- /dev/null
+++ b/headers/compatibility/linux/linux/math64.h
@@ -0,0 +1,132 @@
+/*-
+ * Copyright (c) 2007 Cisco Systems, Inc.  All rights reserved.
+ * Copyright (c) 2014 Mellanox Technologies, Ltd. All rights reserved.
+ * 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.
+ */
+
+#ifndef _LINUX_MATH64_H
+#define _LINUX_MATH64_H
+
+#include <linux/types.h>
+#include <linux/bitops.h>
+
+#if BITS_PER_LONG == 64
+
+# define do_div(n, base) ({                                    \
+	uint32_t __base = (base);                               \
+	uint32_t __rem;                                         \
+	__rem = ((uint64_t)(n)) % __base;                       \
+	(n) = ((uint64_t)(n)) / __base;                         \
+	__rem;                                                  \
+})
+
+/**
+* div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder
+*
+* This is commonly provided by 32bit archs to provide an optimized 64bit
+* divide.
+*/
+static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
+{
+        *remainder = dividend % divisor;
+        return dividend / divisor;
+}
+
+
+#elif BITS_PER_LONG == 32
+
+static uint32_t __div64_32(uint64_t *n, uint32_t base)
+{
+	uint64_t rem = *n;
+	uint64_t b = base;
+	uint64_t res, d = 1;
+	uint32_t high = rem >> 32;
+
+	/* Reduce the thing a bit first */
+	res = 0;
+	if (high >= base) {
+		high /= base;
+		res = (uint64_t) high << 32;
+		rem -= (uint64_t) (high*base) << 32;
+	}
+
+	while ((int64_t)b > 0 && b < rem) {
+		b = b+b;
+		d = d+d;
+	}
+
+	do {
+		if (rem >= b) {
+			rem -= b;
+			res += d;
+		}
+		b >>= 1;
+		d >>= 1;
+	} while (d);
+
+	*n = res;
+	return rem;
+}
+
+# define do_div(n, base) ({                            \
+	uint32_t __base = (base);                       \
+	uint32_t __rem;                                 \
+	(void)(((typeof((n)) *)0) == ((uint64_t *)0));  \
+	if (likely(((n) >> 32) == 0)) {                 \
+		__rem = (uint32_t)(n) % __base;         \
+		(n) = (uint32_t)(n) / __base;           \
+	} else                                          \
+		__rem = __div64_32(&(n), __base);       \
+	__rem;                                          \
+})
+
+#ifndef div_u64_rem
+static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
+{
+        *remainder = do_div(dividend, divisor);
+        return dividend;
+}
+#endif
+
+#endif /* BITS_PER_LONG */
+
+
+
+/**
+ ** div_u64 - unsigned 64bit divide with 32bit divisor
+ **
+ ** This is the most common 64bit divide and should be used if possible,
+ ** as many 32bit archs can optimize this variant better than a full 64bit
+ ** divide.
+ *  */
+#ifndef div_u64
+
+static inline u64 div_u64(u64 dividend, u32 divisor)
+{
+        u32 remainder;
+        return div_u64_rem(dividend, divisor, &remainder);
+}
+#endif
+
+#endif	/* _LINUX_MATH64_H */
diff --git a/headers/compatibility/linux/linux/miscdevice.h b/headers/compatibility/linux/linux/miscdevice.h
new file mode 100644
index 0000000000..2849931f78
--- /dev/null
+++ b/headers/compatibility/linux/linux/miscdevice.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _H
+#define _H
+
+
+#endif
diff --git a/headers/compatibility/linux/linux/mm.h b/headers/compatibility/linux/linux/mm.h
new file mode 100644
index 0000000000..907a7c6d33
--- /dev/null
+++ b/headers/compatibility/linux/linux/mm.h
@@ -0,0 +1,79 @@
+/*-
+ * 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.
+ */
+#ifndef	_LINUX_MM_H_
+#define	_LINUX_MM_H_
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+
+#define PAGE_ALIGN(addr) round_page(addr)
+
+struct vm_area_struct {
+	uintptr_t vm_start;
+	uintptr_t vm_end;
+	uintptr_t vm_pgoff;
+	phys_addr_t vm_pfn;		/* PFN For mmap. */
+	uintptr_t vm_page_prot;
+};
+
+/*
+ * 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);
+}
+
+/*
+ * This only works via mmap ops.
+ */
+#if 0
+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;
+
+	return (0);
+}
+#endif
+
+#endif	/* _LINUX_MM_H_ */
diff --git a/headers/compatibility/linux/linux/module.h b/headers/compatibility/linux/linux/module.h
new file mode 100644
index 0000000000..536257cda0
--- /dev/null
+++ b/headers/compatibility/linux/linux/module.h
@@ -0,0 +1,49 @@
+/*-
+ * 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.
+ */
+#ifndef	_LINUX_MODULE_H_
+#define	_LINUX_MODULE_H_
+
+#include <linux/list.h>
+#include <linux/compiler.h>
+#include <linux/moduleparam.h>
+
+#define MODULE_AUTHOR(name)
+#define MODULE_DESCRIPTION(name)
+#define MODULE_LICENSE(name)
+
+#ifndef MODULE_VERSION
+#define MODULE_VERSION(name)
+#endif
+
+#define	THIS_MODULE	((struct module *)0)
+
+#define	EXPORT_SYMBOL(name)
+#define	EXPORT_SYMBOL_GPL(name)
+
+#endif	/* _LINUX_MODULE_H_ */
diff --git a/headers/compatibility/linux/linux/moduleparam.h b/headers/compatibility/linux/linux/moduleparam.h
new file mode 100644
index 0000000000..e87c79ee13
--- /dev/null
+++ b/headers/compatibility/linux/linux/moduleparam.h
@@ -0,0 +1,233 @@
+/*-
+ * 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.
+ */
+
+#ifndef	_LINUX_MODULEPARAM_H_
+#define	_LINUX_MODULEPARAM_H_
+
+#include <linux/types.h>
+
+/*
+ * These are presently not hooked up to anything.  In linux the parameters
+ * can be set when modules are loaded.  On FreeBSD these could be mapped
+ * to kenv in the future.
+ */
+struct kernel_param;
+
+typedef int (*param_set_fn)(const char *val, struct kernel_param *kp);
+typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp);
+
+struct kernel_param {
+	const char	*name;
+	u16		perm;
+	u16		flags;
+	param_set_fn	set;
+	param_get_fn	get;
+	union {
+		void	*arg;
+		struct kparam_string	*str;
+		struct kparam_array	*arr;
+	} un;
+};
+
+#define	KPARAM_ISBOOL	2
+
+struct kparam_string {
+	unsigned int maxlen;
+	char *string;
+};
+
+struct kparam_array
+{
+	unsigned int	max;
+	unsigned int	*num;
+	param_set_fn	set;
+	param_get_fn	get;
+	unsigned int	elemsize;
+	void 		*elem;
+};
+
+static inline void
+param_sysinit(struct kernel_param *param)
+{
+}
+
+#define	module_param_call(name, set, get, arg, perm)			\
+	static struct kernel_param __param_##name =			\
+	    { #name, perm, 0, set, get, { arg } };			\
+	SYSINIT(name##_param_sysinit, SI_SUB_DRIVERS, SI_ORDER_FIRST,	\
+	    param_sysinit, &__param_##name);
+
+#define module_param_string(name, string, len, perm)
+
+#define	module_param_named(name, var, type, mode)			\
+	module_param_call(name, param_set_##type, param_get_##type, &var, mode)
+
+#define	module_param(var, type, mode)					\
+	module_param_named(var, var, type, mode)
+
+#define module_param_array(var, type, addr_argc, mode)                  \
+        module_param_named(var, var, type, mode)
+
+#define	MODULE_PARM_DESC(name, desc)
+
+static inline int
+param_set_byte(const char *val, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+static inline int
+param_get_byte(char *buffer, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+
+static inline int
+param_set_short(const char *val, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+static inline int
+param_get_short(char *buffer, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+
+static inline int
+param_set_ushort(const char *val, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+static inline int
+param_get_ushort(char *buffer, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+
+static inline int
+param_set_int(const char *val, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+static inline int
+param_get_int(char *buffer, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+
+static inline int
+param_set_uint(const char *val, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+static inline int
+param_get_uint(char *buffer, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+
+static inline int
+param_set_long(const char *val, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+static inline int
+param_get_long(char *buffer, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+
+static inline int
+param_set_ulong(const char *val, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+static inline int
+param_get_ulong(char *buffer, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+
+static inline int
+param_set_charp(const char *val, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+static inline int
+param_get_charp(char *buffer, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+
+static inline int
+param_set_bool(const char *val, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+static inline int
+param_get_bool(char *buffer, struct kernel_param *kp)
+{
+
+	return 0;
+}
+
+#endif	/* _LINUX_MODULEPARAM_H_ */
diff --git a/headers/compatibility/linux/linux/mutex.h b/headers/compatibility/linux/linux/mutex.h
new file mode 100644
index 0000000000..f74668d56d
--- /dev/null
+++ b/headers/compatibility/linux/linux/mutex.h
@@ -0,0 +1,58 @@
+/*-
+ * 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.
+ */
+#ifndef	_LINUX_MUTEX_H_
+#define	_LINUX_MUTEX_H_
+
+#include <lock.h>
+
+typedef struct linux_mutex {
+	mutex lock;
+} mutex_t;
+
+#define	mutex_lock(_m) mutex_lock(&(_m)->lock)
+#define	mutex_lock_nested(_m, _s) mutex_lock(_m)
+#define	mutex_lock_interruptible(_m) ({ mutex_lock((_m)); 0; })
+#define	mutex_unlock(_m) mutex_unlock(&(_m)->sx)
+#define	mutex_trylock(_m) (mutex_trylock(&(_m)->sx) == B_OK)
+
+#define DEFINE_MUTEX(lock)						\
+	mutex_t lock;								\
+	mutex_init(&(lock)->lock, "linux mutex");
+
+
+static inline void
+linux_mutex_init(mutex_t *m)
+{
+	mutex_init(&m->lock, "linux mutex");
+}
+
+#define	mutex_init	linux_mutex_init
+#define mutex 		linux_mutex
+
+#endif	/* _LINUX_MUTEX_H_ */
diff --git a/headers/compatibility/linux/linux/pci.h b/headers/compatibility/linux/linux/pci.h
new file mode 100644
index 0000000000..49c2d2d0ef
--- /dev/null
+++ b/headers/compatibility/linux/linux/pci.h
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2014 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.
+ */
+
+#ifndef LINUX_PCI_H
+#define LINUX_PCI_H
+
+
+#include <bus/PCI.h>
+
+#include <linux/device.h>
+#include <linux/io.h>
+
+#include <linux/pci_ids.h>
+
+
+#define PCI_ANY_ID	(~0u)
+
+struct pci_driver;
+
+struct pci_dev {
+	uint16 vendor;
+	uint16 device;
+	uint16 subvendor;
+	uint16 subdevice;
+	uint32 class;
+
+	// Private
+	struct pci_device* dev;
+	struct pci_device_module_info* module;
+	struct pci_device_id* matching_id;
+	struct pci_driver* driver;
+	struct device_node* node;
+};
+
+
+struct pci_device_id {
+	uint16 vendor;
+	uint16 device;
+	uint16 subvendor;
+	uint16 subdevice;
+	uint32 class;
+	uint32 class_mask;
+};
+
+#define PCI_DEVICE(vend, dev)	\
+	.vendor = (vend),			\
+	.device = (dev),			\
+	.subvendor = PCI_ANY_ID,	\
+	.subdevice = PCI_ANY_ID
+
+#define PCI_DEVICE_SUB(vend, dev, subv, subd)	\
+	.vendor = (vend),							\
+	.device = (dev),							\
+	.subvendor = (subv),						\
+	.subdevice = (subd)
+
+#define PCI_DEVICE_CLASS(cls, mask)	\
+	.vendor = PCI_ANY_ID,			\
+	.device = PCI_ANY_ID,			\
+	.subvendor = PCI_ANY_ID,		\
+	.device = PCI_ANY_ID,			\
+	.class = (cls),					\
+	.class_mask = (mask)
+
+
+#define DEFINE_PCI_DEVICE_TABLE(table) \
+	const struct pci_device_id table[]
+
+
+struct pci_driver {
+	struct list_head list;
+
+	const char* name;
+	const struct pci_device_id* id_table;
+	int (*probe)(struct pci_dev* dev, const struct pci_device_id* id);
+	int (*remove)(struct pci_dev* dev, const struct pci_device_id* id);
+
+	/* Unused by DRM:
+	 * int (*suspend)(struct pci_dev* dev, pm_message_t state);
+	 * int (*suspend_late)(struct pci_dev* dev, pm_message_t state);
+	 * int (*resume_early)(struct pci_dev* dev);
+	 * int (*resume)(struct pci_dev* dev);
+	 * void (*shutdown)(struct pci_dev* dev);
+	 */
+
+	struct device_driver driver;
+};
+
+
+extern int pci_register_driver(struct pci_driver* driver);
+
+
+#define to_pci_driver(driver) container_of(driver, struct pci_driver, driver)
+
+
+static inline int
+pci_read_config_byte(struct pci_dev *pdev, int where, u8 *val)
+{
+	*val = (u16)pdev->module->read_pci_config(pdev->dev, where, 1);
+	return 0;
+}
+
+static inline int
+pci_read_config_word(struct pci_dev *pdev, int where, u16 *val)
+{
+	*val = (u16)pdev->module->read_pci_config(pdev->dev, where, 2);
+	return 0;
+}
+
+static inline int
+pci_read_config_dword(struct pci_dev *pdev, int where, u32 *val)
+{
+	*val = (u32)pdev->module->read_pci_config(pdev->dev, where, 4);
+	return 0;
+}
+
+static inline int
+pci_write_config_byte(struct pci_dev *pdev, int where, u8 val)
+{
+	pdev->module->write_pci_config(pdev->dev, where, val, 1);
+	return 0;
+}
+
+static inline int
+pci_write_config_word(struct pci_dev *pdev, int where, u16 val)
+{
+	pdev->module->write_pci_config(pdev->dev, where, val, 2);
+	return 0;
+}
+
+static inline int
+pci_write_config_dword(struct pci_dev *pdev, int where, u32 val)
+{
+	pdev->module->write_pci_config(pdev->dev, where, val, 4);
+	return 0;
+}
+
+
+static inline struct pci_dev *
+pci_dev_get(struct pci_dev *dev)
+{
+	/* Linux increments a reference count here */
+	return dev;
+}
+
+static inline struct pci_dev *
+pci_dev_put(struct pci_dev *dev)
+{
+	/* Linux decrements a reference count here */
+	return dev;
+}
+
+
+static inline int
+pci_set_dma_mask(struct pci_dev *dev, u64 mask)
+{
+	return -EIO;
+}
+
+static inline int
+pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
+{
+	return -EIO;
+}
+
+#endif /* LINUX_PCI_H */
diff --git a/headers/compatibility/linux/linux/pci_ids.h b/headers/compatibility/linux/linux/pci_ids.h
new file mode 100644
index 0000000000..b8487a4298
--- /dev/null
+++ b/headers/compatibility/linux/linux/pci_ids.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014 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.
+ */
+
+#ifndef LINUX_PCI_IDS_H
+#define LINUX_PCI_IDS_H
+
+#define PCI_BASE_CLASS_DISPLAY		0x03
+
+#define PCI_VENDOR_ID_ATI		0x1002
+
+#define PCI_VENDOR_ID_IBM		0x1014
+
+#define PCI_VENDOR_ID_DELL		0x1028
+
+#define PCI_VENDOR_ID_HP		0x103c
+
+#define PCI_VENDOR_ID_ASUSTEK		0x1043
+
+#define PCI_VENDOR_ID_SONY		0x104d
+
+#define PCI_VENDOR_ID_APPLE		0x106b
+
+#define PCI_VENDOR_ID_NVIDIA		0x10de
+
+#define PCI_VENDOR_ID_VIA		0x1106
+
+#define PCI_VENDOR_ID_SERVERWORKS	0x1166
+
+#define PCI_VENDOR_ID_NVIDIA_SGS	0x12d2
+
+#define PCI_VENDOR_ID_INTEL		0x8086
+
+#endif /* LINUX_PCI_IDS_H */
diff --git a/headers/compatibility/linux/linux/platform_device.h b/headers/compatibility/linux/linux/platform_device.h
new file mode 100644
index 0000000000..2849931f78
--- /dev/null
+++ b/headers/compatibility/linux/linux/platform_device.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _H
+#define _H
+
+
+#endif
diff --git a/headers/compatibility/linux/linux/poll.h b/headers/compatibility/linux/linux/poll.h
new file mode 100644
index 0000000000..2849931f78
--- /dev/null
+++ b/headers/compatibility/linux/linux/poll.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _H
+#define _H
+
+
+#endif
diff --git a/headers/compatibility/linux/linux/ratelimit.h b/headers/compatibility/linux/linux/ratelimit.h
new file mode 100644
index 0000000000..2849931f78
--- /dev/null
+++ b/headers/compatibility/linux/linux/ratelimit.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _H
+#define _H
+
+
+#endif
diff --git a/headers/compatibility/linux/linux/rbtree.h b/headers/compatibility/linux/linux/rbtree.h
new file mode 100644
index 0000000000..1592f7f9fa
--- /dev/null
+++ b/headers/compatibility/linux/linux/rbtree.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _LINUX_RBTREE_H
+#define _LINUX_RBTREE_H
+
+
+#define RB_NONE		0
+#define RB_RED		1
+#define RB_BLACK 	2
+
+
+struct rb_node {
+	int colour;
+	struct rb_node* parent;
+	struct rb_node* rb_left;
+	struct rb_node* rb_right;
+};
+
+#define rb_parent(r) 	((struct rb_node*)((r)->parent))
+#define rb_color(r) 	((struct rb_node*)((r)->colour))
+
+#define rb_is_red(r)	(rb_color(r) == RB_RED)
+#define rb_is_black(r)	(rb_color(r) == RB_BLACK)
+
+#define rb_set_parent(r, p)	(rb_parent(r) = (p))
+#define rb_set_color(r, c)	(rb_color(r) = (c))
+
+#define rb_entry(ptr, type, member)	container_of(ptr, type, member)
+
+
+#endif
diff --git a/headers/compatibility/linux/linux/sched.h b/headers/compatibility/linux/linux/sched.h
new file mode 100644
index 0000000000..56c1d3d9b9
--- /dev/null
+++ b/headers/compatibility/linux/linux/sched.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015 Hamish Morrison
+ * 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.
+ */
+
+#ifndef	_LINUX_SCHED_H_
+#define	_LINUX_SCHED_H_
+
+
+#define	TASK_RUNNING			~0UL
+#define	TASK_UNINTERRUPTIBLE	0
+#define	TASK_INTERRUPTIBLE		B_CAN_INTERRUPT
+#define TASK_KILLABLE			B_KILL_CAN_INTERRUPT
+
+#define MAX_SCHEDULE_TIMEOUT	B_INFINITE_TIMEOUT
+
+/*
+ * schedule_timeout - sleep until timeout
+ * @timeout: timeout value in jiffies
+ */
+extern long schedule_timeout(long timeout);
+
+extern void schedule();
+
+
+#endif	/* _LINUX_SCHED_H_ */
diff --git a/headers/compatibility/linux/linux/slab.h b/headers/compatibility/linux/linux/slab.h
new file mode 100644
index 0000000000..d87ea79f0f
--- /dev/null
+++ b/headers/compatibility/linux/linux/slab.h
@@ -0,0 +1,118 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2015 Hamish Morrison
+ * 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.
+ */
+#ifndef	_LINUX_SLAB_H_
+#define	_LINUX_SLAB_H_
+
+#include <heap.h>
+#include <slab/Slab.h>
+
+#include <linux/types.h>
+#include <linux/gfp.h>
+
+
+
+static inline void* kmalloc(size_t size, uint32 flags)
+{
+	void* addr = malloc_etc(size, flags);
+	if (addr != NULL && (flags & __GFP_ZERO) != 0)
+		memset(addr, 0, size);
+
+	return addr;
+}
+
+
+#define PAGE_KERNEL 0x0001
+
+
+#define	kvmalloc(size)					kmalloc((size), 0)
+#define	kzalloc(size, flags)			kmalloc((size), (flags) | __GFP_ZERO)
+#define	kzalloc_node(size, flags, node)	kzalloc(size, flags)
+#define	kfree(ptr)						free((ptr))
+#define	krealloc(ptr, size, flags)		realloc((ptr), (size))
+#define	kcalloc(n, size, flags)	    	kmalloc((n) * (size), (flags) | __GFP_ZERO)
+#define	vzalloc(size)					kzalloc((size), GFP_KERNEL)
+#define	vfree(arg)						kfree((arg))
+#define	kvfree(arg)						kfree((arg))
+#define	vmalloc(size)					kmalloc((size), GFP_KERNEL)
+#define	vmalloc_node(size, node)		kmalloc((size), GFP_KERNEL)
+
+// XXX
+#define __vmalloc(size, flags, prot)	kmalloc((size), (flags))
+#define is_vmalloc_addr(ptr) 			(true)
+
+
+struct kmem_cache {
+	object_cache* cache;
+};
+
+
+#define	SLAB_HWCACHE_ALIGN	0x0001
+
+
+static inline status_t
+kmem_ctor(void* cookie, void* object)
+{
+	void (*ctor)(void *) = cookie;
+	ctor(object);
+	return 0;
+}
+
+
+static inline struct kmem_cache *
+kmem_cache_create(char *name, size_t size, size_t align, u_long flags,
+    void (*ctor)(void *))
+{
+	struct kmem_cache *c = (struct kmem_cache*)malloc(sizeof(struct kmem_cache));
+
+	c->cache = create_object_cache(name, size, align,
+		ctor != NULL ? (void*)kmem_ctor : NULL, kmem_ctor, NULL);
+	return c;
+}
+
+static inline void *
+kmem_cache_alloc(struct kmem_cache *c, int flags)
+{
+	return object_cache_alloc(c->cache, flags);
+}
+
+static inline void
+kmem_cache_free(struct kmem_cache *c, void *m)
+{
+	object_cache_free(c->cache, m, 0);
+}
+
+static inline void
+kmem_cache_destroy(struct kmem_cache *c)
+{
+	delete_object_cache(c->cache);
+	free(c);
+}
+
+#endif	/* _LINUX_SLAB_H_ */
diff --git a/headers/compatibility/linux/linux/sysfs.h b/headers/compatibility/linux/linux/sysfs.h
new file mode 100644
index 0000000000..5d80ece562
--- /dev/null
+++ b/headers/compatibility/linux/linux/sysfs.h
@@ -0,0 +1,102 @@
+/*-
+ * 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.
+ */
+
+#ifndef	_LINUX_SYSFS_H_
+#define	_LINUX_SYSFS_H_
+
+
+struct attribute {
+	const char* name;
+	struct module* owner;
+	mode_t mode;
+};
+
+struct sysfs_ops {
+	ssize_t (*show)(struct kobject*, struct attribute*, char*);
+	ssize_t (*store)(struct kobject*, struct attribute*, const char*,
+		size_t);
+};
+
+struct attribute_group {
+	const char* name;
+	mode_t (*is_visible)(struct kobject*, struct attribute*, int);
+	struct attribute** attrs;
+};
+
+
+#define	__ATTR(_name, _mode, _show, _store) {				\
+	.attr = { .name = __stringify(_name), .mode = _mode },	\
+	.show = _show, .store  = _store,						\
+}
+
+#define	__ATTR_RO(_name) {									\
+	.attr = { .name = __stringify(_name), .mode = 0444 },	\
+	.show   = _name##_show,									\
+}
+
+#define	__ATTR_NULL	{ .attr = { .name = NULL } }
+
+
+static inline int
+sysfs_create_file(struct kobject* kobj, const struct attribute* attr)
+{
+	return 0;
+}
+
+static inline void
+sysfs_remove_file(struct kobject* kobj, const struct attribute* attr)
+{
+}
+
+static inline void
+sysfs_remove_group(struct kobject* kobj, const struct attribute_group* grp)
+{
+}
+
+static inline int
+sysfs_create_group(struct kobject* kobj, const struct attribute_group* grp)
+{
+	return 0;
+}
+
+static inline int
+sysfs_create_dir(struct kobject* kobj)
+{
+	return 0;
+}
+
+static inline void
+sysfs_remove_dir(struct kobject* kobj)
+{
+}
+
+#define sysfs_attr_init(attr) do {} while(0)
+
+
+#endif	/* _LINUX_SYSFS_H_ */
diff --git a/headers/compatibility/linux/linux/time.h b/headers/compatibility/linux/linux/time.h
new file mode 100644
index 0000000000..5b3affd5c3
--- /dev/null
+++ b/headers/compatibility/linux/linux/time.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2014 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.
+ */
+
+#ifndef _LINUX_TIME_H_
+#define _LINUX_TIME_H_
+
+#define NSEC_PER_USEC	1000L
+#define NSEC_PER_SEC	1000000000L
+
+#include <sys/time.h>
+
+
+static inline struct timeval
+ns_to_timeval(const int64_t nsec)
+{
+	struct timeval tv;
+	long rem;
+
+	if (nsec == 0) {
+		tv.tv_sec = 0;
+		tv.tv_usec = 0;
+		return (tv);
+	}
+
+	tv.tv_sec = nsec / NSEC_PER_SEC;
+	rem = nsec % NSEC_PER_SEC;
+	if (rem < 0) {
+		tv.tv_sec--;
+		rem += NSEC_PER_SEC;
+	}
+	tv.tv_usec = rem / 1000;
+	return (tv);
+}
+
+static inline int64_t
+timeval_to_ns(const struct timeval *tv)
+{
+	return ((int64_t)tv->tv_sec * NSEC_PER_SEC) +
+		tv->tv_usec * NSEC_PER_USEC;
+}
+
+static inline void
+set_normalized_timespec(struct timespec *ts, time_t sec, int64_t nsec)
+{
+	if (nsec >= NSEC_PER_SEC) {
+		sec += nsec / NSEC_PER_SEC;
+		nsec %= NSEC_PER_SEC;
+	}
+
+	if (nsec < 0) {
+		sec += nsec / NSEC_PER_SEC;
+		nsec = (nsec % NSEC_PER_SEC) + NSEC_PER_SEC;
+	}
+
+	ts->tv_sec = sec;
+	ts->tv_nsec = nsec;
+}
+
+static inline struct timespec
+timespec_sub(struct timespec lhs, struct timespec rhs)
+{
+	struct timespec ts;
+	set_normalized_timespec(&ts, lhs.tv_sec - rhs.tv_sec,
+		lhs.tv_nsec - rhs.tv_nsec);
+	return ts;
+}
+
+static inline int64_t
+timespec_to_ns(const struct timespec *ts)
+{
+	return ((ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec);
+}
+
+static inline struct timespec
+ns_to_timespec(const int64_t nsec)
+{
+	struct timespec ts;
+	int32_t rem;
+
+	if (nsec == 0) {
+		ts.tv_sec = 0;
+		ts.tv_nsec = 0;
+		return (ts);
+	}
+
+	ts.tv_sec = nsec / NSEC_PER_SEC;
+	rem = nsec % NSEC_PER_SEC;
+	if (rem < 0) {
+		ts.tv_sec--;
+		rem += NSEC_PER_SEC;
+	}
+	ts.tv_nsec = rem;
+	return (ts);
+}
+
+static inline int
+timespec_valid(const struct timespec *ts)
+{
+	if (ts->tv_sec < 0 || ts->tv_sec > 100000000 ||
+	    ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000)
+		return (0);
+	return (1);
+}
+
+static inline void
+getrawmonotonic(struct timespec *ts)
+{
+	uint32_t rem;
+	bigtime_t nsec = system_time_nsecs();
+
+	ts->tv_sec = nsec / NSEC_PER_SEC;
+	rem = nsec % NSEC_PER_SEC;
+	if (rem < 0) {
+		ts->tv_sec--;
+		rem += NSEC_PER_SEC;
+	}
+	ts->tv_nsec = rem;
+}
+
+#endif	/* _LINUX_TIME_H_ */
diff --git a/headers/compatibility/linux/linux/types.h b/headers/compatibility/linux/linux/types.h
new file mode 100644
index 0000000000..a4270080f2
--- /dev/null
+++ b/headers/compatibility/linux/linux/types.h
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * 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.
+ */
+#ifndef	_LINUX_TYPES_H_
+#define	_LINUX_TYPES_H_
+
+#include <SupportDefs.h>
+#include <linux/compiler.h>
+#include <asm/types.h>
+
+
+typedef uint16 __le16;
+typedef uint16 __be16;
+typedef uint32 __le32;
+typedef uint32 __be32;
+typedef uint64 __le64;
+typedef uint64 __be64;
+#if !defined(__bool_true_false_are_defined) && !defined(__cplusplus)
+typedef _Bool bool;
+#define	true	TRUE
+#define	false	FALSE
+#endif
+
+typedef unsigned long kernel_ulong_t;
+typedef unsigned gfp_t;
+typedef uint64_t loff_t;
+typedef phys_addr_t resource_size_t;
+
+#define	DECLARE_BITMAP(n, bits)						\
+	unsigned long n[howmany(bits, sizeof(long) * 8)]
+
+#endif	/* _LINUX_TYPES_H_ */
diff --git a/headers/compatibility/linux/linux/uaccess.h b/headers/compatibility/linux/linux/uaccess.h
new file mode 100644
index 0000000000..ab6e844349
--- /dev/null
+++ b/headers/compatibility/linux/linux/uaccess.h
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+#ifndef _LINUX_UACCESS_H_
+#define _LINUX_UACCESS_H_
+
+static inline void pagefault_disable(void)
+{
+	atomic_set_int(&curthread->td_flags, TDF_NOFAULT);
+}
+
+static inline void pagefault_enable(void)
+{
+	atomic_clear_int(&curthread->td_flags, TDF_NOFAULT);
+}
+
+#endif	/* _LINUX_UACCESS_H_ */
diff --git a/headers/compatibility/linux/linux/vmalloc.h b/headers/compatibility/linux/linux/vmalloc.h
new file mode 100644
index 0000000000..2849931f78
--- /dev/null
+++ b/headers/compatibility/linux/linux/vmalloc.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef _H
+#define _H
+
+
+#endif
diff --git a/headers/compatibility/linux/linux/workqueue.h b/headers/compatibility/linux/linux/workqueue.h
new file mode 100644
index 0000000000..415c882803
--- /dev/null
+++ b/headers/compatibility/linux/linux/workqueue.h
@@ -0,0 +1,117 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2015 Hamish Morrison
+ * 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.
+ */
+#ifndef	_LINUX_WORKQUEUE_H_
+#define	_LINUX_WORKQUEUE_H_
+
+#include <linux/list.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+#include <KernelExport.h>
+
+
+extern int32 smp_get_num_cpus(void);
+
+
+struct workqueue_struct;
+struct work_struct;
+
+typedef void (*work_func_t)(struct work_struct* work);
+
+struct work_struct {
+	struct workqueue_struct* queue;
+	struct list_head list;
+	bool linked;
+	work_func_t fn;
+	long data;
+};
+
+struct delayed_work {
+	struct work_struct work;
+	struct timer event;
+};
+
+
+
+#define	INIT_WORK(work, func) 	 			\
+do {										\
+	(work)->fn = (func);					\
+	(work)->queue = NULL;					\
+	INIT_LIST_HEAD(&(work)->list);			\
+} while (0)
+
+#define	INIT_DELAYED_WORK 		INIT_WORK
+#define	INIT_DEFERRABLE_WORK	INIT_DELAYED_WORK
+
+
+/* TODO!!
+#define	schedule_work(work)						\
+do {									\
+	(work)->taskqueue = taskqueue_thread[mycpuid];				\
+	taskqueue_enqueue(taskqueue_thread[mycpuid], &(work)->work_task);	\
+} while (0)
+
+#define	flush_scheduled_work()	flush_taskqueue(taskqueue_thread[mycpuid])
+
+static inline bool schedule_delayed_work(struct delayed_work *dwork,
+                                         unsigned long delay)
+{
+        struct workqueue_struct wq;
+        wq.taskqueue = taskqueue_thread[mycpuid];
+        return queue_delayed_work(&wq, dwork, delay);
+}
+*/
+
+
+extern bool queue_work(struct workqueue_struct *wq, struct work_struct *work);
+
+extern bool queue_delayed_work(struct workqueue_struct *wq,
+	struct delayed_work *work, unsigned long delay);
+
+extern struct workqueue_struct * _workqueue_create(const char* name,
+	int threads);
+
+static inline struct workqueue_struct *
+create_singlethread_workqueue(const char *name) {
+	return _workqueue_create(name, 1);
+}
+
+static inline struct workqueue_struct *
+create_workqueue(const char *name) {
+	return _workqueue_create(name, smp_get_num_cpus());
+}
+
+extern void destroy_workqueue(struct workqueue_struct *wq);
+extern void flush_workqueue(struct workqueue_struct *wq);
+
+extern bool cancel_work_sync(struct work_struct *work);
+extern bool cancel_delayed_work(struct delayed_work *work);
+extern bool cancel_delayed_work_sync(struct delayed_work *work);
+
+#endif	/* _LINUX_WORKQUEUE_H_ */
diff --git a/headers/private/graphics/drm/drm/drmP.h b/headers/private/graphics/drm/drm/drmP.h
new file mode 100644
index 0000000000..6105c050d7
--- /dev/null
+++ b/headers/private/graphics/drm/drm/drmP.h
@@ -0,0 +1,837 @@
+/*
+ * Internal Header for the Direct Rendering Manager
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * Copyright (c) 2009-2010, Code Aurora Forum.
+ * All rights reserved.
+ *
+ * Author: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Author: Gareth Hughes <gareth@valinux.com>
+ *
+ * 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 (including the next
+ * paragraph) 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
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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 _DRM_P_H_
+#define _DRM_P_H_
+
+#include <linux/agp_backend.h>
+#include <linux/cdev.h>
+#include <linux/dma-mapping.h>
+#include <linux/file.h>
+#include <linux/fs.h>
+#include <linux/highmem.h>
+#include <linux/idr.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/jiffies.h>
+#include <linux/kernel.h>
+#include <linux/kref.h>
+#include <linux/miscdevice.h>
+#include <linux/mm.h>
+#include <linux/mutex.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+#include <linux/poll.h>
+#include <linux/ratelimit.h>
+#include <linux/rbtree.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/vmalloc.h>
+#include <linux/workqueue.h>
+#include <linux/dma-fence.h>
+
+#include <asm/mman.h>
+#include <asm/pgalloc.h>
+#include <linux/uaccess.h>
+
+#include <uapi/drm/drm.h>
+#include <uapi/drm/drm_mode.h>
+
+#include <drm/drm_agpsupport.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_fourcc.h>
+#include <drm/drm_global.h>
+#include <drm/drm_hashtab.h>
+#include <drm/drm_mem_util.h>
+#include <drm/drm_mm.h>
+#include <drm/drm_os_linux.h>
+#include <drm/drm_sarea.h>
+#include <drm/drm_vma_manager.h>
+#include <drm/drm_drv.h>
+
+struct module;
+
+struct drm_file;
+struct drm_device;
+struct drm_agp_head;
+struct drm_local_map;
+struct drm_device_dma;
+struct drm_dma_handle;
+struct drm_gem_object;
+struct drm_master;
+struct drm_vblank_crtc;
+
+struct device_node;
+struct videomode;
+struct reservation_object;
+struct dma_buf_attachment;
+
+/*
+ * The following categories are defined:
+ *
+ * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
+ *	 This is the category used by the DRM_DEBUG() macro.
+ *
+ * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
+ *	   This is the category used by the DRM_DEBUG_DRIVER() macro.
+ *
+ * KMS: used in the modesetting code.
+ *	This is the category used by the DRM_DEBUG_KMS() macro.
+ *
+ * PRIME: used in the prime code.
+ *	  This is the category used by the DRM_DEBUG_PRIME() macro.
+ *
+ * ATOMIC: used in the atomic code.
+ *	  This is the category used by the DRM_DEBUG_ATOMIC() macro.
+ *
+ * VBL: used for verbose debug message in the vblank code
+ *	  This is the category used by the DRM_DEBUG_VBL() macro.
+ *
+ * Enabling verbose debug messages is done through the drm.debug parameter,
+ * each category being enabled by a bit.
+ *
+ * drm.debug=0x1 will enable CORE messages
+ * drm.debug=0x2 will enable DRIVER messages
+ * drm.debug=0x3 will enable CORE and DRIVER messages
+ * ...
+ * drm.debug=0x3f will enable all messages
+ *
+ * An interesting feature is that it's possible to enable verbose logging at
+ * run-time by echoing the debug value in its sysfs node:
+ *   # echo 0xf > /sys/module/drm/parameters/debug
+ */
+#define DRM_UT_NONE		0x00
+#define DRM_UT_CORE 		0x01
+#define DRM_UT_DRIVER		0x02
+#define DRM_UT_KMS		0x04
+#define DRM_UT_PRIME		0x08
+#define DRM_UT_ATOMIC		0x10
+#define DRM_UT_VBL		0x20
+#define DRM_UT_STATE		0x40
+
+/***********************************************************************/
+/** \name DRM template customization defaults */
+/*@{*/
+
+/***********************************************************************/
+/** \name Macros to make printk easier */
+/*@{*/
+
+#define _DRM_PRINTK(once, level, fmt, ...)				\
+	do {								\
+		printk##once(KERN_##level "[" DRM_NAME "] " fmt,	\
+			     ##__VA_ARGS__);				\
+	} while (0)
+
+#define DRM_INFO(fmt, ...)						\
+	_DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
+#define DRM_NOTE(fmt, ...)						\
+	_DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
+#define DRM_WARN(fmt, ...)						\
+	_DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
+
+#define DRM_INFO_ONCE(fmt, ...)						\
+	_DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
+#define DRM_NOTE_ONCE(fmt, ...)						\
+	_DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
+#define DRM_WARN_ONCE(fmt, ...)						\
+	_DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
+
+/**
+ * Error output.
+ *
+ * \param fmt printf() like format string.
+ * \param arg arguments
+ */
+#define DRM_DEV_ERROR(dev, fmt, ...)					\
+	drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\
+		       fmt, ##__VA_ARGS__)
+#define DRM_ERROR(fmt, ...)						\
+	drm_printk(KERN_ERR, DRM_UT_NONE, fmt,	##__VA_ARGS__)
+
+/**
+ * Rate limited error output.  Like DRM_ERROR() but won't flood the log.
+ *
+ * \param fmt printf() like format string.
+ * \param arg arguments
+ */
+#define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...)			\
+({									\
+	static DEFINE_RATELIMIT_STATE(_rs,				\
+				      DEFAULT_RATELIMIT_INTERVAL,	\
+				      DEFAULT_RATELIMIT_BURST);		\
+									\
+	if (__ratelimit(&_rs))						\
+		DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__);			\
+})
+#define DRM_ERROR_RATELIMITED(fmt, ...)					\
+	DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
+
+#define DRM_DEV_INFO(dev, fmt, ...)					\
+	drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt,	\
+		       ##__VA_ARGS__)
+
+#define DRM_DEV_INFO_ONCE(dev, fmt, ...)				\
+({									\
+	static bool __print_once __read_mostly;				\
+	if (!__print_once) {						\
+		__print_once = true;					\
+		DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__);			\
+	}								\
+})
+
+/**
+ * Debug output.
+ *
+ * \param fmt printf() like format string.
+ * \param arg arguments
+ */
+#define DRM_DEV_DEBUG(dev, fmt, args...)				\
+	drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt,	\
+		       ##args)
+#define DRM_DEBUG(fmt, ...)						\
+	drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__)
+
+#define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...)				\
+	drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "",	\
+		       fmt, ##args)
+#define DRM_DEBUG_DRIVER(fmt, ...)					\
+	drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
+
+#define DRM_DEV_DEBUG_KMS(dev, fmt, args...)				\
+	drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt,	\
+		       ##args)
+#define DRM_DEBUG_KMS(fmt, ...)					\
+	drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__)
+
+#define DRM_DEV_DEBUG_PRIME(dev, fmt, args...)				\
+	drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "",	\
+		       fmt, ##args)
+#define DRM_DEBUG_PRIME(fmt, ...)					\
+	drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
+
+#define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...)				\
+	drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "",	\
+		       fmt, ##args)
+#define DRM_DEBUG_ATOMIC(fmt, ...)					\
+	drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
+
+#define DRM_DEV_DEBUG_VBL(dev, fmt, args...)				\
+	drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt,	\
+		       ##args)
+#define DRM_DEBUG_VBL(fmt, ...)					\
+	drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__)
+
+#define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...)	\
+({									\
+	static DEFINE_RATELIMIT_STATE(_rs,				\
+				      DEFAULT_RATELIMIT_INTERVAL,	\
+				      DEFAULT_RATELIMIT_BURST);		\
+	if (__ratelimit(&_rs))						\
+		drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level,	\
+			       __func__, "", fmt, ##args);		\
+})
+
+/**
+ * Rate limited debug output. Like DRM_DEBUG() but won't flood the log.
+ *
+ * \param fmt printf() like format string.
+ * \param arg arguments
+ */
+#define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...)			\
+	DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args)
+#define DRM_DEBUG_RATELIMITED(fmt, args...)				\
+	DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args)
+#define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...)		\
+	_DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args)
+#define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...)			\
+	DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args)
+#define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...)		\
+	_DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args)
+#define DRM_DEBUG_KMS_RATELIMITED(fmt, args...)				\
+	DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args)
+#define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...)		\
+	_DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args)
+#define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...)			\
+	DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args)
+
+/* Format strings and argument splitters to simplify printing
+ * various "complex" objects
+ */
+#define DRM_MODE_FMT    "%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x"
+#define DRM_MODE_ARG(m) \
+	(m)->base.id, (m)->name, (m)->vrefresh, (m)->clock, \
+	(m)->hdisplay, (m)->hsync_start, (m)->hsync_end, (m)->htotal, \
+	(m)->vdisplay, (m)->vsync_start, (m)->vsync_end, (m)->vtotal, \
+	(m)->type, (m)->flags
+
+#define DRM_RECT_FMT    "%dx%d%+d%+d"
+#define DRM_RECT_ARG(r) drm_rect_width(r), drm_rect_height(r), (r)->x1, (r)->y1
+
+/* for rect's in fixed-point format: */
+#define DRM_RECT_FP_FMT "%d.%06ux%d.%06u%+d.%06u%+d.%06u"
+#define DRM_RECT_FP_ARG(r) \
+		drm_rect_width(r) >> 16, ((drm_rect_width(r) & 0xffff) * 15625) >> 10, \
+		drm_rect_height(r) >> 16, ((drm_rect_height(r) & 0xffff) * 15625) >> 10, \
+		(r)->x1 >> 16, (((r)->x1 & 0xffff) * 15625) >> 10, \
+		(r)->y1 >> 16, (((r)->y1 & 0xffff) * 15625) >> 10
+
+/*@}*/
+
+/***********************************************************************/
+/** \name Internal types and structures */
+/*@{*/
+
+#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
+
+/**
+ * Ioctl function type.
+ *
+ * \param inode device inode.
+ * \param file_priv DRM file private pointer.
+ * \param cmd command.
+ * \param arg argument.
+ */
+typedef int drm_ioctl_t(struct drm_device *dev, void *data,
+			struct drm_file *file_priv);
+
+typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
+			       unsigned long arg);
+
+#define DRM_IOCTL_NR(n)                _IOC_NR(n)
+#define DRM_MAJOR       226
+
+#define DRM_AUTH	0x1
+#define	DRM_MASTER	0x2
+#define DRM_ROOT_ONLY	0x4
+#define DRM_CONTROL_ALLOW 0x8
+#define DRM_UNLOCKED	0x10
+#define DRM_RENDER_ALLOW 0x20
+
+struct drm_ioctl_desc {
+	unsigned int cmd;
+	int flags;
+	drm_ioctl_t *func;
+	const char *name;
+};
+
+/**
+ * Creates a driver or general drm_ioctl_desc array entry for the given
+ * ioctl, for use by drm_ioctl().
+ */
+
+#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)				\
+	[DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = {	\
+		.cmd = DRM_IOCTL_##ioctl,				\
+		.func = _func,						\
+		.flags = _flags,					\
+		.name = #ioctl						\
+	 }
+
+/* Event queued up for userspace to read */
+struct drm_pending_event {
+	struct completion *completion;
+	void (*completion_release)(struct completion *completion);
+	struct drm_event *event;
+	struct dma_fence *fence;
+	struct list_head link;
+	struct list_head pending_link;
+	struct drm_file *file_priv;
+	pid_t pid; /* pid of requester, no guarantee it's valid by the time
+		      we deliver the event, for tracing only */
+};
+
+struct drm_prime_file_private {
+	struct mutex lock;
+	struct rb_root dmabufs;
+	struct rb_root handles;
+};
+
+/** File private data */
+struct drm_file {
+	unsigned authenticated :1;
+	/* true when the client has asked us to expose stereo 3D mode flags */
+	unsigned stereo_allowed :1;
+	/*
+	 * true if client understands CRTC primary planes and cursor planes
+	 * in the plane list
+	 */
+	unsigned universal_planes:1;
+	/* true if client understands atomic properties */
+	unsigned atomic:1;
+	/*
+	 * This client is the creator of @master.
+	 * Protected by struct drm_device::master_mutex.
+	 */
+	unsigned is_master:1;
+
+	struct pid *pid;
+	drm_magic_t magic;
+	struct list_head lhead;
+	struct drm_minor *minor;
+	unsigned long lock_count;
+
+	/** Mapping of mm object handles to object pointers. */
+	struct idr object_idr;
+	/** Lock for synchronization of access to object_idr. */
+	spinlock_t table_lock;
+
+	struct file *filp;
+	void *driver_priv;
+
+	struct drm_master *master; /* master this node is currently associated with
+				      N.B. not always dev->master */
+	/**
+	 * fbs - List of framebuffers associated with this file.
+	 *
+	 * Protected by fbs_lock. Note that the fbs list holds a reference on
+	 * the fb object to prevent it from untimely disappearing.
+	 */
+	struct list_head fbs;
+	struct mutex fbs_lock;
+
+	/** User-created blob properties; this retains a reference on the
+	 *  property. */
+	struct list_head blobs;
+
+	wait_queue_head_t event_wait;
+	struct list_head pending_event_list;
+	struct list_head event_list;
+	int event_space;
+
+	struct mutex event_read_lock;
+
+	struct drm_prime_file_private prime;
+};
+
+/**
+ * Lock data.
+ */
+struct drm_lock_data {
+	struct drm_hw_lock *hw_lock;	/**< Hardware lock */
+	/** Private of lock holder's file (NULL=kernel) */
+	struct drm_file *file_priv;
+	wait_queue_head_t lock_queue;	/**< Queue of blocked processes */
+	unsigned long lock_time;	/**< Time of last lock in jiffies */
+	spinlock_t spinlock;
+	uint32_t kernel_waiters;
+	uint32_t user_waiters;
+	int idle_has_lock;
+};
+
+/* Flags and return codes for get_vblank_timestamp() driver function. */
+#define DRM_CALLED_FROM_VBLIRQ 1
+#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
+#define DRM_VBLANKTIME_IN_VBLANK         (1 << 1)
+
+/* get_scanout_position() return flags */
+#define DRM_SCANOUTPOS_VALID        (1 << 0)
+#define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)
+#define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
+
+enum drm_minor_type {
+	DRM_MINOR_PRIMARY,
+	DRM_MINOR_CONTROL,
+	DRM_MINOR_RENDER,
+	DRM_MINOR_CNT,
+};
+
+/**
+ * Info file list entry. This structure represents a debugfs or proc file to
+ * be created by the drm core
+ */
+struct drm_info_list {
+	const char *name; /** file name */
+	int (*show)(struct seq_file*, void*); /** show callback */
+	u32 driver_features; /**< Required driver features for this entry */
+	void *data;
+};
+
+/**
+ * debugfs node structure. This structure represents a debugfs file.
+ */
+struct drm_info_node {
+	struct list_head list;
+	struct drm_minor *minor;
+	const struct drm_info_list *info_ent;
+	struct dentry *dent;
+};
+
+/**
+ * DRM minor structure. This structure represents a drm minor number.
+ */
+struct drm_minor {
+	int index;			/**< Minor device number */
+	int type;                       /**< Control or render */
+	struct device *kdev;		/**< Linux device */
+	struct drm_device *dev;
+
+	struct dentry *debugfs_root;
+
+	struct list_head debugfs_list;
+	struct mutex debugfs_lock; /* Protects debugfs_list. */
+};
+
+/**
+ * DRM device structure. This structure represent a complete card that
+ * may contain multiple heads.
+ */
+struct drm_device {
+	struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
+	int if_version;			/**< Highest interface version set */
+
+	/** \name Lifetime Management */
+	/*@{ */
+	struct kref ref;		/**< Object ref-count */
+	struct device *dev;		/**< Device structure of bus-device */
+	struct drm_driver *driver;	/**< DRM driver managing the device */
+	void *dev_private;		/**< DRM driver private data */
+	struct drm_minor *control;		/**< Control node */
+	struct drm_minor *primary;		/**< Primary node */
+	struct drm_minor *render;		/**< Render node */
+	bool registered;
+
+	/* currently active master for this device. Protected by master_mutex */
+	struct drm_master *master;
+
+	atomic_t unplugged;			/**< Flag whether dev is dead */
+	struct inode *anon_inode;		/**< inode for private address-space */
+	char *unique;				/**< unique name of the device */
+	/*@} */
+
+	/** \name Locks */
+	/*@{ */
+	struct mutex struct_mutex;	/**< For others */
+	struct mutex master_mutex;      /**< For drm_minor::master and drm_file::is_master */
+	/*@} */
+
+	/** \name Usage Counters */
+	/*@{ */
+	int open_count;			/**< Outstanding files open, protected by drm_global_mutex. */
+	spinlock_t buf_lock;		/**< For drm_device::buf_use and a few other things. */
+	int buf_use;			/**< Buffers in use -- cannot alloc */
+	atomic_t buf_alloc;		/**< Buffer allocation in progress */
+	/*@} */
+
+	struct mutex filelist_mutex;
+	struct list_head filelist;
+
+	/** \name Memory management */
+	/*@{ */
+	struct list_head maplist;	/**< Linked list of regions */
+	struct drm_open_hash map_hash;	/**< User token hash table for maps */
+
+	/** \name Context handle management */
+	/*@{ */
+	struct list_head ctxlist;	/**< Linked list of context handles */
+	struct mutex ctxlist_mutex;	/**< For ctxlist */
+
+	struct idr ctx_idr;
+
+	struct list_head vmalist;	/**< List of vmas (for debugging) */
+
+	/*@} */
+
+	/** \name DMA support */
+	/*@{ */
+	struct drm_device_dma *dma;		/**< Optional pointer for DMA support */
+	/*@} */
+
+	/** \name Context support */
+	/*@{ */
+
+	__volatile__ long context_flag;	/**< Context swapping flag */
+	int last_context;		/**< Last current context */
+	/*@} */
+
+	/** \name VBLANK IRQ support */
+	/*@{ */
+	bool irq_enabled;
+	int irq;
+
+	/*
+	 * If true, vblank interrupt will be disabled immediately when the
+	 * refcount drops to zero, as opposed to via the vblank disable
+	 * timer.
+	 * This can be set to true it the hardware has a working vblank
+	 * counter and the driver uses drm_vblank_on() and drm_vblank_off()
+	 * appropriately.
+	 */
+	bool vblank_disable_immediate;
+
+	/* array of size num_crtcs */
+	struct drm_vblank_crtc *vblank;
+
+	spinlock_t vblank_time_lock;    /**< Protects vblank count and time updates during vblank enable/disable */
+	spinlock_t vbl_lock;
+
+	u32 max_vblank_count;           /**< size of vblank counter register */
+
+	/**
+	 * List of events
+	 */
+	struct list_head vblank_event_list;
+	spinlock_t event_lock;
+
+	/*@} */
+
+	struct drm_agp_head *agp;	/**< AGP data */
+
+	struct pci_dev *pdev;		/**< PCI device structure */
+#ifdef __alpha__
+	struct pci_controller *hose;
+#endif
+
+	struct platform_device *platformdev; /**< Platform device struture */
+	struct virtio_device *virtdev;
+
+	struct drm_sg_mem *sg;	/**< Scatter gather memory */
+	unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
+
+	struct {
+		int context;
+		struct drm_hw_lock *lock;
+	} sigdata;
+
+	struct drm_local_map *agp_buffer_map;
+	unsigned int agp_buffer_token;
+
+	struct drm_mode_config mode_config;	/**< Current mode config */
+
+	/** \name GEM information */
+	/*@{ */
+	struct mutex object_name_lock;
+	struct idr object_name_idr;
+	struct drm_vma_offset_manager *vma_offset_manager;
+	/*@} */
+	int switch_power_state;
+};
+
+/**
+ * drm_drv_uses_atomic_modeset - check if the driver implements
+ * atomic_commit()
+ * @dev: DRM device
+ *
+ * This check is useful if drivers do not have DRIVER_ATOMIC set but
+ * have atomic modesetting internally implemented.
+ */
+static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
+{
+	return dev->mode_config.funcs->atomic_commit != NULL;
+}
+
+#include <drm/drm_irq.h>
+
+#define DRM_SWITCH_POWER_ON 0
+#define DRM_SWITCH_POWER_OFF 1
+#define DRM_SWITCH_POWER_CHANGING 2
+#define DRM_SWITCH_POWER_DYNAMIC_OFF 3
+
+static __inline__ int drm_core_check_feature(struct drm_device *dev,
+					     int feature)
+{
+	return ((dev->driver->driver_features & feature) ? 1 : 0);
+}
+
+static inline void drm_device_set_unplugged(struct drm_device *dev)
+{
+	smp_wmb();
+	atomic_set(&dev->unplugged, 1);
+}
+
+static inline int drm_device_is_unplugged(struct drm_device *dev)
+{
+	int ret = atomic_read(&dev->unplugged);
+	smp_rmb();
+	return ret;
+}
+
+static inline bool drm_is_render_client(const struct drm_file *file_priv)
+{
+	return file_priv->minor->type == DRM_MINOR_RENDER;
+}
+
+static inline bool drm_is_control_client(const struct drm_file *file_priv)
+{
+	return file_priv->minor->type == DRM_MINOR_CONTROL;
+}
+
+static inline bool drm_is_primary_client(const struct drm_file *file_priv)
+{
+	return file_priv->minor->type == DRM_MINOR_PRIMARY;
+}
+
+/******************************************************************/
+/** \name Internal function definitions */
+/*@{*/
+
+				/* Driver support (drm_drv.h) */
+extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
+extern long drm_ioctl(struct file *filp,
+		      unsigned int cmd, unsigned long arg);
+#ifdef CONFIG_COMPAT
+extern long drm_compat_ioctl(struct file *filp,
+			     unsigned int cmd, unsigned long arg);
+#else
+/* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */
+#define drm_compat_ioctl NULL
+#endif
+extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
+
+/* File Operations (drm_fops.c) */
+int drm_open(struct inode *inode, struct file *filp);
+ssize_t drm_read(struct file *filp, char __user *buffer,
+		 size_t count, loff_t *offset);
+int drm_release(struct inode *inode, struct file *filp);
+unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
+int drm_event_reserve_init_locked(struct drm_device *dev,
+				  struct drm_file *file_priv,
+				  struct drm_pending_event *p,
+				  struct drm_event *e);
+int drm_event_reserve_init(struct drm_device *dev,
+			   struct drm_file *file_priv,
+			   struct drm_pending_event *p,
+			   struct drm_event *e);
+void drm_event_cancel_free(struct drm_device *dev,
+			   struct drm_pending_event *p);
+void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e);
+void drm_send_event(struct drm_device *dev, struct drm_pending_event *e);
+
+/* Misc. IOCTL support (drm_ioctl.c) */
+int drm_noop(struct drm_device *dev, void *data,
+	     struct drm_file *file_priv);
+int drm_invalid_op(struct drm_device *dev, void *data,
+		   struct drm_file *file_priv);
+
+/*
+ * These are exported to drivers so that they can implement fencing using
+ * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
+ */
+
+				/* Debugfs support */
+#if defined(CONFIG_DEBUG_FS)
+extern int drm_debugfs_create_files(const struct drm_info_list *files,
+				    int count, struct dentry *root,
+				    struct drm_minor *minor);
+extern int drm_debugfs_remove_files(const struct drm_info_list *files,
+				    int count, struct drm_minor *minor);
+#else
+static inline int drm_debugfs_create_files(const struct drm_info_list *files,
+					   int count, struct dentry *root,
+					   struct drm_minor *minor)
+{
+	return 0;
+}
+
+static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
+					   int count, struct drm_minor *minor)
+{
+	return 0;
+}
+#endif
+
+struct dma_buf_export_info;
+
+extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
+					    struct drm_gem_object *obj,
+					    int flags);
+extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
+		struct drm_file *file_priv, uint32_t handle, uint32_t flags,
+		int *prime_fd);
+extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
+		struct dma_buf *dma_buf);
+extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
+		struct drm_file *file_priv, int prime_fd, uint32_t *handle);
+struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev,
+				      struct dma_buf_export_info *exp_info);
+extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf);
+
+extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
+					    dma_addr_t *addrs, int max_pages);
+extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages);
+extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
+
+
+extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
+					    size_t align);
+extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
+
+			       /* sysfs support (drm_sysfs.c) */
+extern void drm_sysfs_hotplug_event(struct drm_device *dev);
+
+
+/*@}*/
+
+extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
+extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
+#ifdef CONFIG_PCI
+extern int drm_get_pci_dev(struct pci_dev *pdev,
+			   const struct pci_device_id *ent,
+			   struct drm_driver *driver);
+extern int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
+#else
+static inline int drm_get_pci_dev(struct pci_dev *pdev,
+				  const struct pci_device_id *ent,
+				  struct drm_driver *driver)
+{
+	return -ENOSYS;
+}
+
+static inline int drm_pci_set_busid(struct drm_device *dev,
+				    struct drm_master *master)
+{
+	return -ENOSYS;
+}
+#endif
+
+#define DRM_PCIE_SPEED_25 1
+#define DRM_PCIE_SPEED_50 2
+#define DRM_PCIE_SPEED_80 4
+
+extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
+extern int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw);
+
+/* platform section */
+extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
+
+/* returns true if currently okay to sleep */
+static __inline__ bool drm_can_sleep(void)
+{
+	if (in_atomic() || in_dbg_master() || irqs_disabled())
+		return false;
+	return true;
+}
+
+/* helper for handling conditionals in various for_each macros */
+#define for_each_if(condition) if (!(condition)) {} else
+
+#endif
diff --git a/headers/private/graphics/drm/drm/drm_agpsupport.h b/headers/private/graphics/drm/drm/drm_agpsupport.h
new file mode 100644
index 0000000000..b2d912670a
--- /dev/null
+++ b/headers/private/graphics/drm/drm/drm_agpsupport.h
@@ -0,0 +1,148 @@
+#ifndef _DRM_AGPSUPPORT_H_
+#define _DRM_AGPSUPPORT_H_
+
+#include <linux/agp_backend.h>
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/mm.h>
+#include <linux/mutex.h>
+#include <linux/types.h>
+#include <uapi/drm/drm.h>
+
+struct drm_device;
+struct drm_file;
+
+struct drm_agp_head {
+	struct agp_kern_info agp_info;
+	struct list_head memory;
+	unsigned long mode;
+	struct agp_bridge_data *bridge;
+	int enabled;
+	int acquired;
+	unsigned long base;
+	int agp_mtrr;
+	int cant_use_aperture;
+	unsigned long page_mask;
+};
+
+#if IS_ENABLED(CONFIG_AGP)
+
+void drm_free_agp(struct agp_memory * handle, int pages);
+int drm_bind_agp(struct agp_memory * handle, unsigned int start);
+int drm_unbind_agp(struct agp_memory * handle);
+struct agp_memory *drm_agp_bind_pages(struct drm_device *dev,
+				struct page **pages,
+				unsigned long num_pages,
+				uint32_t gtt_offset,
+				uint32_t type);
+
+struct drm_agp_head *drm_agp_init(struct drm_device *dev);
+void drm_legacy_agp_clear(struct drm_device *dev);
+int drm_agp_acquire(struct drm_device *dev);
+int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
+			  struct drm_file *file_priv);
+int drm_agp_release(struct drm_device *dev);
+int drm_agp_release_ioctl(struct drm_device *dev, void *data,
+			  struct drm_file *file_priv);
+int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
+int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
+			 struct drm_file *file_priv);
+int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info);
+int drm_agp_info_ioctl(struct drm_device *dev, void *data,
+		       struct drm_file *file_priv);
+int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
+int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
+			struct drm_file *file_priv);
+int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
+int drm_agp_free_ioctl(struct drm_device *dev, void *data,
+		       struct drm_file *file_priv);
+int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
+int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
+			 struct drm_file *file_priv);
+int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
+int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
+		       struct drm_file *file_priv);
+
+#else /* CONFIG_AGP */
+
+static inline void drm_free_agp(struct agp_memory * handle, int pages)
+{
+}
+
+static inline int drm_bind_agp(struct agp_memory * handle, unsigned int start)
+{
+	return -ENODEV;
+}
+
+static inline int drm_unbind_agp(struct agp_memory * handle)
+{
+	return -ENODEV;
+}
+
+static inline struct agp_memory *drm_agp_bind_pages(struct drm_device *dev,
+					      struct page **pages,
+					      unsigned long num_pages,
+					      uint32_t gtt_offset,
+					      uint32_t type)
+{
+	return NULL;
+}
+
+static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)
+{
+	return NULL;
+}
+
+static inline void drm_legacy_agp_clear(struct drm_device *dev)
+{
+}
+
+static inline int drm_agp_acquire(struct drm_device *dev)
+{
+	return -ENODEV;
+}
+
+static inline int drm_agp_release(struct drm_device *dev)
+{
+	return -ENODEV;
+}
+
+static inline int drm_agp_enable(struct drm_device *dev,
+				 struct drm_agp_mode mode)
+{
+	return -ENODEV;
+}
+
+static inline int drm_agp_info(struct drm_device *dev,
+			       struct drm_agp_info *info)
+{
+	return -ENODEV;
+}
+
+static inline int drm_agp_alloc(struct drm_device *dev,
+				struct drm_agp_buffer *request)
+{
+	return -ENODEV;
+}
+
+static inline int drm_agp_free(struct drm_device *dev,
+			       struct drm_agp_buffer *request)
+{
+	return -ENODEV;
+}
+
+static inline int drm_agp_unbind(struct drm_device *dev,
+				 struct drm_agp_binding *request)
+{
+	return -ENODEV;
+}
+
+static inline int drm_agp_bind(struct drm_device *dev,
+			       struct drm_agp_binding *request)
+{
+	return -ENODEV;
+}
+
+#endif /* CONFIG_AGP */
+
+#endif /* _DRM_AGPSUPPORT_H_ */
diff --git a/headers/private/graphics/drm/drm/drm_crtc.h b/headers/private/graphics/drm/drm/drm_crtc.h
new file mode 100644
index 0000000000..8f0b195e4a
--- /dev/null
+++ b/headers/private/graphics/drm/drm/drm_crtc.h
@@ -0,0 +1,860 @@
+/*
+ * Copyright © 2006 Keith Packard
+ * Copyright © 2007-2008 Dave Airlie
+ * Copyright © 2007-2008 Intel Corporation
+ *   Jesse Barnes <jesse.barnes@intel.com>
+ *
+ * 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
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 __DRM_CRTC_H__
+#define __DRM_CRTC_H__
+
+#include <linux/i2c.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
+#include <linux/fb.h>
+#include <linux/hdmi.h>
+#include <linux/media-bus-format.h>
+#include <uapi/drm/drm_mode.h>
+#include <uapi/drm/drm_fourcc.h>
+#include <drm/drm_modeset_lock.h>
+#include <drm/drm_rect.h>
+#include <drm/drm_mode_object.h>
+#include <drm/drm_framebuffer.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_connector.h>
+#include <drm/drm_property.h>
+#include <drm/drm_bridge.h>
+#include <drm/drm_edid.h>
+#include <drm/drm_plane.h>
+#include <drm/drm_blend.h>
+#include <drm/drm_color_mgmt.h>
+#include <drm/drm_debugfs_crc.h>
+#include <drm/drm_mode_config.h>
+
+struct drm_device;
+struct drm_mode_set;
+struct drm_file;
+struct drm_clip_rect;
+struct drm_printer;
+struct device_node;
+struct dma_fence;
+struct edid;
+
+static inline int64_t U642I64(uint64_t val)
+{
+	return (int64_t)*((int64_t *)&val);
+}
+static inline uint64_t I642U64(int64_t val)
+{
+	return (uint64_t)*((uint64_t *)&val);
+}
+
+struct drm_crtc;
+struct drm_pending_vblank_event;
+struct drm_plane;
+struct drm_bridge;
+struct drm_atomic_state;
+
+struct drm_crtc_helper_funcs;
+struct drm_plane_helper_funcs;
+
+/**
+ * struct drm_crtc_state - mutable CRTC state
+ * @crtc: backpointer to the CRTC
+ * @enable: whether the CRTC should be enabled, gates all other state
+ * @active: whether the CRTC is actively displaying (used for DPMS)
+ * @planes_changed: planes on this crtc are updated
+ * @mode_changed: @mode or @enable has been changed
+ * @active_changed: @active has been toggled.
+ * @connectors_changed: connectors to this crtc have been updated
+ * @zpos_changed: zpos values of planes on this crtc have been updated
+ * @color_mgmt_changed: color management properties have changed (degamma or
+ *	gamma LUT or CSC matrix)
+ * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
+ * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors
+ * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders
+ * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings
+ * @mode: current mode timings
+ * @mode_blob: &drm_property_blob for @mode
+ * @degamma_lut: Lookup table for converting framebuffer pixel data
+ *	before apply the conversion matrix
+ * @ctm: Transformation matrix
+ * @gamma_lut: Lookup table for converting pixel data after the
+ *	conversion matrix
+ * @state: backpointer to global drm_atomic_state
+ *
+ * Note that the distinction between @enable and @active is rather subtile:
+ * Flipping @active while @enable is set without changing anything else may
+ * never return in a failure from the &drm_mode_config_funcs.atomic_check
+ * callback. Userspace assumes that a DPMS On will always succeed. In other
+ * words: @enable controls resource assignment, @active controls the actual
+ * hardware state.
+ *
+ * The three booleans active_changed, connectors_changed and mode_changed are
+ * intended to indicate whether a full modeset is needed, rather than strictly
+ * describing what has changed in a commit.
+ * See also: drm_atomic_crtc_needs_modeset()
+ */
+struct drm_crtc_state {
+	struct drm_crtc *crtc;
+
+	bool enable;
+	bool active;
+
+	/* computed state bits used by helpers and drivers */
+	bool planes_changed : 1;
+	bool mode_changed : 1;
+	bool active_changed : 1;
+	bool connectors_changed : 1;
+	bool zpos_changed : 1;
+	bool color_mgmt_changed : 1;
+
+	/* attached planes bitmask:
+	 * WARNING: transitional helpers do not maintain plane_mask so
+	 * drivers not converted over to atomic helpers should not rely
+	 * on plane_mask being accurate!
+	 */
+	u32 plane_mask;
+
+	u32 connector_mask;
+	u32 encoder_mask;
+
+	/* adjusted_mode: for use by helpers and drivers */
+	struct drm_display_mode adjusted_mode;
+
+	struct drm_display_mode mode;
+
+	/* blob property to expose current mode to atomic userspace */
+	struct drm_property_blob *mode_blob;
+
+	/* blob property to expose color management to userspace */
+	struct drm_property_blob *degamma_lut;
+	struct drm_property_blob *ctm;
+	struct drm_property_blob *gamma_lut;
+
+	/**
+	 * @target_vblank:
+	 *
+	 * Target vertical blank period when a page flip
+	 * should take effect.
+	 */
+
+	u32 target_vblank;
+
+	/**
+	 * @event:
+	 *
+	 * Optional pointer to a DRM event to signal upon completion of the
+	 * state update. The driver must send out the event when the atomic
+	 * commit operation completes. There are two cases:
+	 *
+	 *  - The event is for a CRTC which is being disabled through this
+	 *    atomic commit. In that case the event can be send out any time
+	 *    after the hardware has stopped scanning out the current
+	 *    framebuffers. It should contain the timestamp and counter for the
+	 *    last vblank before the display pipeline was shut off.
+	 *
+	 *  - For a CRTC which is enabled at the end of the commit (even when it
+	 *    undergoes an full modeset) the vblank timestamp and counter must
+	 *    be for the vblank right before the first frame that scans out the
+	 *    new set of buffers. Again the event can only be sent out after the
+	 *    hardware has stopped scanning out the old buffers.
+	 *
+	 *  - Events for disabled CRTCs are not allowed, and drivers can ignore
+	 *    that case.
+	 *
+	 * This can be handled by the drm_crtc_send_vblank_event() function,
+	 * which the driver should call on the provided event upon completion of
+	 * the atomic commit. Note that if the driver supports vblank signalling
+	 * and timestamping the vblank counters and timestamps must agree with
+	 * the ones returned from page flip events. With the current vblank
+	 * helper infrastructure this can be achieved by holding a vblank
+	 * reference while the page flip is pending, acquired through
+	 * drm_crtc_vblank_get() and released with drm_crtc_vblank_put().
+	 * Drivers are free to implement their own vblank counter and timestamp
+	 * tracking though, e.g. if they have accurate timestamp registers in
+	 * hardware.
+	 *
+	 * For hardware which supports some means to synchronize vblank
+	 * interrupt delivery with committing display state there's also
+	 * drm_crtc_arm_vblank_event(). See the documentation of that function
+	 * for a detailed discussion of the constraints it needs to be used
+	 * safely.
+	 */
+	struct drm_pending_vblank_event *event;
+
+	struct drm_atomic_state *state;
+};
+
+/**
+ * struct drm_crtc_funcs - control CRTCs for a given device
+ *
+ * The drm_crtc_funcs structure is the central CRTC management structure
+ * in the DRM.  Each CRTC controls one or more connectors (note that the name
+ * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
+ * connectors, not just CRTs).
+ *
+ * Each driver is responsible for filling out this structure at startup time,
+ * in addition to providing other modesetting features, like i2c and DDC
+ * bus accessors.
+ */
+struct drm_crtc_funcs {
+	/**
+	 * @reset:
+	 *
+	 * Reset CRTC hardware and software state to off. This function isn't
+	 * called by the core directly, only through drm_mode_config_reset().
+	 * It's not a helper hook only for historical reasons.
+	 *
+	 * Atomic drivers can use drm_atomic_helper_crtc_reset() to reset
+	 * atomic state using this hook.
+	 */
+	void (*reset)(struct drm_crtc *crtc);
+
+	/**
+	 * @cursor_set:
+	 *
+	 * Update the cursor image. The cursor position is relative to the CRTC
+	 * and can be partially or fully outside of the visible area.
+	 *
+	 * Note that contrary to all other KMS functions the legacy cursor entry
+	 * points don't take a framebuffer object, but instead take directly a
+	 * raw buffer object id from the driver's buffer manager (which is
+	 * either GEM or TTM for current drivers).
+	 *
+	 * This entry point is deprecated, drivers should instead implement
+	 * universal plane support and register a proper cursor plane using
+	 * drm_crtc_init_with_planes().
+	 *
+	 * This callback is optional
+	 *
+	 * RETURNS:
+	 *
+	 * 0 on success or a negative error code on failure.
+	 */
+	int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
+			  uint32_t handle, uint32_t width, uint32_t height);
+
+	/**
+	 * @cursor_set2:
+	 *
+	 * Update the cursor image, including hotspot information. The hotspot
+	 * must not affect the cursor position in CRTC coordinates, but is only
+	 * meant as a hint for virtualized display hardware to coordinate the
+	 * guests and hosts cursor position. The cursor hotspot is relative to
+	 * the cursor image. Otherwise this works exactly like @cursor_set.
+	 *
+	 * This entry point is deprecated, drivers should instead implement
+	 * universal plane support and register a proper cursor plane using
+	 * drm_crtc_init_with_planes().
+	 *
+	 * This callback is optional.
+	 *
+	 * RETURNS:
+	 *
+	 * 0 on success or a negative error code on failure.
+	 */
+	int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv,
+			   uint32_t handle, uint32_t width, uint32_t height,
+			   int32_t hot_x, int32_t hot_y);
+
+	/**
+	 * @cursor_move:
+	 *
+	 * Update the cursor position. The cursor does not need to be visible
+	 * when this hook is called.
+	 *
+	 * This entry point is deprecated, drivers should instead implement
+	 * universal plane support and register a proper cursor plane using
+	 * drm_crtc_init_with_planes().
+	 *
+	 * This callback is optional.
+	 *
+	 * RETURNS:
+	 *
+	 * 0 on success or a negative error code on failure.
+	 */
+	int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
+
+	/**
+	 * @gamma_set:
+	 *
+	 * Set gamma on the CRTC.
+	 *
+	 * This callback is optional.
+	 *
+	 * NOTE:
+	 *
+	 * Drivers that support gamma tables and also fbdev emulation through
+	 * the provided helper library need to take care to fill out the gamma
+	 * hooks for both. Currently there's a bit an unfortunate duplication
+	 * going on, which should eventually be unified to just one set of
+	 * hooks.
+	 */
+	int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
+			 uint32_t size);
+
+	/**
+	 * @destroy:
+	 *
+	 * Clean up plane resources. This is only called at driver unload time
+	 * through drm_mode_config_cleanup() since a CRTC cannot be hotplugged
+	 * in DRM.
+	 */
+	void (*destroy)(struct drm_crtc *crtc);
+
+	/**
+	 * @set_config:
+	 *
+	 * This is the main legacy entry point to change the modeset state on a
+	 * CRTC. All the details of the desired configuration are passed in a
+	 * &struct drm_mode_set - see there for details.
+	 *
+	 * Drivers implementing atomic modeset should use
+	 * drm_atomic_helper_set_config() to implement this hook.
+	 *
+	 * RETURNS:
+	 *
+	 * 0 on success or a negative error code on failure.
+	 */
+	int (*set_config)(struct drm_mode_set *set);
+
+	/**
+	 * @page_flip:
+	 *
+	 * Legacy entry point to schedule a flip to the given framebuffer.
+	 *
+	 * Page flipping is a synchronization mechanism that replaces the frame
+	 * buffer being scanned out by the CRTC with a new frame buffer during
+	 * vertical blanking, avoiding tearing (except when requested otherwise
+	 * through the DRM_MODE_PAGE_FLIP_ASYNC flag). When an application
+	 * requests a page flip the DRM core verifies that the new frame buffer
+	 * is large enough to be scanned out by the CRTC in the currently
+	 * configured mode and then calls this hook with a pointer to the new
+	 * frame buffer.
+	 *
+	 * The driver must wait for any pending rendering to the new framebuffer
+	 * to complete before executing the flip. It should also wait for any
+	 * pending rendering from other drivers if the underlying buffer is a
+	 * shared dma-buf.
+	 *
+	 * An application can request to be notified when the page flip has
+	 * completed. The drm core will supply a &struct drm_event in the event
+	 * parameter in this case. This can be handled by the
+	 * drm_crtc_send_vblank_event() function, which the driver should call on
+	 * the provided event upon completion of the flip. Note that if
+	 * the driver supports vblank signalling and timestamping the vblank
+	 * counters and timestamps must agree with the ones returned from page
+	 * flip events. With the current vblank helper infrastructure this can
+	 * be achieved by holding a vblank reference while the page flip is
+	 * pending, acquired through drm_crtc_vblank_get() and released with
+	 * drm_crtc_vblank_put(). Drivers are free to implement their own vblank
+	 * counter and timestamp tracking though, e.g. if they have accurate
+	 * timestamp registers in hardware.
+	 *
+	 * This callback is optional.
+	 *
+	 * NOTE:
+	 *
+	 * Very early versions of the KMS ABI mandated that the driver must
+	 * block (but not reject) any rendering to the old framebuffer until the
+	 * flip operation has completed and the old framebuffer is no longer
+	 * visible. This requirement has been lifted, and userspace is instead
+	 * expected to request delivery of an event and wait with recycling old
+	 * buffers until such has been received.
+	 *
+	 * RETURNS:
+	 *
+	 * 0 on success or a negative error code on failure. Note that if a
+	 * page flip operation is already pending the callback should return
+	 * -EBUSY. Pageflips on a disabled CRTC (either by setting a NULL mode
+	 * or just runtime disabled through DPMS respectively the new atomic
+	 * "ACTIVE" state) should result in an -EINVAL error code. Note that
+	 * drm_atomic_helper_page_flip() checks this already for atomic drivers.
+	 */
+	int (*page_flip)(struct drm_crtc *crtc,
+			 struct drm_framebuffer *fb,
+			 struct drm_pending_vblank_event *event,
+			 uint32_t flags);
+
+	/**
+	 * @page_flip_target:
+	 *
+	 * Same as @page_flip but with an additional parameter specifying the
+	 * absolute target vertical blank period (as reported by
+	 * drm_crtc_vblank_count()) when the flip should take effect.
+	 *
+	 * Note that the core code calls drm_crtc_vblank_get before this entry
+	 * point, and will call drm_crtc_vblank_put if this entry point returns
+	 * any non-0 error code. It's the driver's responsibility to call
+	 * drm_crtc_vblank_put after this entry point returns 0, typically when
+	 * the flip completes.
+	 */
+	int (*page_flip_target)(struct drm_crtc *crtc,
+				struct drm_framebuffer *fb,
+				struct drm_pending_vblank_event *event,
+				uint32_t flags, uint32_t target);
+
+	/**
+	 * @set_property:
+	 *
+	 * This is the legacy entry point to update a property attached to the
+	 * CRTC.
+	 *
+	 * Drivers implementing atomic modeset should use
+	 * drm_atomic_helper_crtc_set_property() to implement this hook.
+	 *
+	 * This callback is optional if the driver does not support any legacy
+	 * driver-private properties.
+	 *
+	 * RETURNS:
+	 *
+	 * 0 on success or a negative error code on failure.
+	 */
+	int (*set_property)(struct drm_crtc *crtc,
+			    struct drm_property *property, uint64_t val);
+
+	/**
+	 * @atomic_duplicate_state:
+	 *
+	 * Duplicate the current atomic state for this CRTC and return it.
+	 * The core and helpers guarantee that any atomic state duplicated with
+	 * this hook and still owned by the caller (i.e. not transferred to the
+	 * driver by calling &drm_mode_config_funcs.atomic_commit) will be
+	 * cleaned up by calling the @atomic_destroy_state hook in this
+	 * structure.
+	 *
+	 * Atomic drivers which don't subclass &struct drm_crtc_state should use
+	 * drm_atomic_helper_crtc_duplicate_state(). Drivers that subclass the
+	 * state structure to extend it with driver-private state should use
+	 * __drm_atomic_helper_crtc_duplicate_state() to make sure shared state is
+	 * duplicated in a consistent fashion across drivers.
+	 *
+	 * It is an error to call this hook before &drm_crtc.state has been
+	 * initialized correctly.
+	 *
+	 * NOTE:
+	 *
+	 * If the duplicate state references refcounted resources this hook must
+	 * acquire a reference for each of them. The driver must release these
+	 * references again in @atomic_destroy_state.
+	 *
+	 * RETURNS:
+	 *
+	 * Duplicated atomic state or NULL when the allocation failed.
+	 */
+	struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc);
+
+	/**
+	 * @atomic_destroy_state:
+	 *
+	 * Destroy a state duplicated with @atomic_duplicate_state and release
+	 * or unreference all resources it references
+	 */
+	void (*atomic_destroy_state)(struct drm_crtc *crtc,
+				     struct drm_crtc_state *state);
+
+	/**
+	 * @atomic_set_property:
+	 *
+	 * Decode a driver-private property value and store the decoded value
+	 * into the passed-in state structure. Since the atomic core decodes all
+	 * standardized properties (even for extensions beyond the core set of
+	 * properties which might not be implemented by all drivers) this
+	 * requires drivers to subclass the state structure.
+	 *
+	 * Such driver-private properties should really only be implemented for
+	 * truly hardware/vendor specific state. Instead it is preferred to
+	 * standardize atomic extension and decode the properties used to expose
+	 * such an extension in the core.
+	 *
+	 * Do not call this function directly, use
+	 * drm_atomic_crtc_set_property() instead.
+	 *
+	 * This callback is optional if the driver does not support any
+	 * driver-private atomic properties.
+	 *
+	 * NOTE:
+	 *
+	 * This function is called in the state assembly phase of atomic
+	 * modesets, which can be aborted for any reason (including on
+	 * userspace's request to just check whether a configuration would be
+	 * possible). Drivers MUST NOT touch any persistent state (hardware or
+	 * software) or data structures except the passed in @state parameter.
+	 *
+	 * Also since userspace controls in which order properties are set this
+	 * function must not do any input validation (since the state update is
+	 * incomplete and hence likely inconsistent). Instead any such input
+	 * validation must be done in the various atomic_check callbacks.
+	 *
+	 * RETURNS:
+	 *
+	 * 0 if the property has been found, -EINVAL if the property isn't
+	 * implemented by the driver (which should never happen, the core only
+	 * asks for properties attached to this CRTC). No other validation is
+	 * allowed by the driver. The core already checks that the property
+	 * value is within the range (integer, valid enum value, ...) the driver
+	 * set when registering the property.
+	 */
+	int (*atomic_set_property)(struct drm_crtc *crtc,
+				   struct drm_crtc_state *state,
+				   struct drm_property *property,
+				   uint64_t val);
+	/**
+	 * @atomic_get_property:
+	 *
+	 * Reads out the decoded driver-private property. This is used to
+	 * implement the GETCRTC IOCTL.
+	 *
+	 * Do not call this function directly, use
+	 * drm_atomic_crtc_get_property() instead.
+	 *
+	 * This callback is optional if the driver does not support any
+	 * driver-private atomic properties.
+	 *
+	 * RETURNS:
+	 *
+	 * 0 on success, -EINVAL if the property isn't implemented by the
+	 * driver (which should never happen, the core only asks for
+	 * properties attached to this CRTC).
+	 */
+	int (*atomic_get_property)(struct drm_crtc *crtc,
+				   const struct drm_crtc_state *state,
+				   struct drm_property *property,
+				   uint64_t *val);
+
+	/**
+	 * @late_register:
+	 *
+	 * This optional hook can be used to register additional userspace
+	 * interfaces attached to the crtc like debugfs interfaces.
+	 * It is called late in the driver load sequence from drm_dev_register().
+	 * Everything added from this callback should be unregistered in
+	 * the early_unregister callback.
+	 *
+	 * Returns:
+	 *
+	 * 0 on success, or a negative error code on failure.
+	 */
+	int (*late_register)(struct drm_crtc *crtc);
+
+	/**
+	 * @early_unregister:
+	 *
+	 * This optional hook should be used to unregister the additional
+	 * userspace interfaces attached to the crtc from
+	 * @late_register. It is called from drm_dev_unregister(),
+	 * early in the driver unload sequence to disable userspace access
+	 * before data structures are torndown.
+	 */
+	void (*early_unregister)(struct drm_crtc *crtc);
+
+	/**
+	 * @set_crc_source:
+	 *
+	 * Changes the source of CRC checksums of frames at the request of
+	 * userspace, typically for testing purposes. The sources available are
+	 * specific of each driver and a %NULL value indicates that CRC
+	 * generation is to be switched off.
+	 *
+	 * When CRC generation is enabled, the driver should call
+	 * drm_crtc_add_crc_entry() at each frame, providing any information
+	 * that characterizes the frame contents in the crcN arguments, as
+	 * provided from the configured source. Drivers must accept a "auto"
+	 * source name that will select a default source for this CRTC.
+	 *
+	 * This callback is optional if the driver does not support any CRC
+	 * generation functionality.
+	 *
+	 * RETURNS:
+	 *
+	 * 0 on success or a negative error code on failure.
+	 */
+	int (*set_crc_source)(struct drm_crtc *crtc, const char *source,
+			      size_t *values_cnt);
+
+	/**
+	 * @atomic_print_state:
+	 *
+	 * If driver subclasses &struct drm_crtc_state, it should implement
+	 * this optional hook for printing additional driver specific state.
+	 *
+	 * Do not call this directly, use drm_atomic_crtc_print_state()
+	 * instead.
+	 */
+	void (*atomic_print_state)(struct drm_printer *p,
+				   const struct drm_crtc_state *state);
+};
+
+/**
+ * struct drm_crtc - central CRTC control structure
+ * @dev: parent DRM device
+ * @port: OF node used by drm_of_find_possible_crtcs()
+ * @head: list management
+ * @name: human readable name, can be overwritten by the driver
+ * @mutex: per-CRTC locking
+ * @base: base KMS object for ID tracking etc.
+ * @primary: primary plane for this CRTC
+ * @cursor: cursor plane for this CRTC
+ * @cursor_x: current x position of the cursor, used for universal cursor planes
+ * @cursor_y: current y position of the cursor, used for universal cursor planes
+ * @enabled: is this CRTC enabled?
+ * @mode: current mode timings
+ * @hwmode: mode timings as programmed to hw regs
+ * @x: x position on screen
+ * @y: y position on screen
+ * @funcs: CRTC control functions
+ * @gamma_size: size of gamma ramp
+ * @gamma_store: gamma ramp values
+ * @helper_private: mid-layer private data
+ * @properties: property tracking for this CRTC
+ *
+ * Each CRTC may have one or more connectors associated with it.  This structure
+ * allows the CRTC to be controlled.
+ */
+struct drm_crtc {
+	struct drm_device *dev;
+	struct device_node *port;
+	struct list_head head;
+
+	char *name;
+
+	/**
+	 * @mutex:
+	 *
+	 * This provides a read lock for the overall crtc state (mode, dpms
+	 * state, ...) and a write lock for everything which can be update
+	 * without a full modeset (fb, cursor data, crtc properties ...). A full
+	 * modeset also need to grab &drm_mode_config.connection_mutex.
+	 */
+	struct drm_modeset_lock mutex;
+
+	struct drm_mode_object base;
+
+	/* primary and cursor planes for CRTC */
+	struct drm_plane *primary;
+	struct drm_plane *cursor;
+
+	/**
+	 * @index: Position inside the mode_config.list, can be used as an array
+	 * index. It is invariant over the lifetime of the CRTC.
+	 */
+	unsigned index;
+
+	/* position of cursor plane on crtc */
+	int cursor_x;
+	int cursor_y;
+
+	bool enabled;
+
+	/* Requested mode from modesetting. */
+	struct drm_display_mode mode;
+
+	/* Programmed mode in hw, after adjustments for encoders,
+	 * crtc, panel scaling etc. Needed for timestamping etc.
+	 */
+	struct drm_display_mode hwmode;
+
+	int x, y;
+	const struct drm_crtc_funcs *funcs;
+
+	/* Legacy FB CRTC gamma size for reporting to userspace */
+	uint32_t gamma_size;
+	uint16_t *gamma_store;
+
+	/* if you are using the helper */
+	const struct drm_crtc_helper_funcs *helper_private;
+
+	struct drm_object_properties properties;
+
+	/**
+	 * @state:
+	 *
+	 * Current atomic state for this CRTC.
+	 */
+	struct drm_crtc_state *state;
+
+	/**
+	 * @commit_list:
+	 *
+	 * List of &drm_crtc_commit structures tracking pending commits.
+	 * Protected by @commit_lock. This list doesn't hold its own full
+	 * reference, but burrows it from the ongoing commit. Commit entries
+	 * must be removed from this list once the commit is fully completed,
+	 * but before it's correspoding &drm_atomic_state gets destroyed.
+	 */
+	struct list_head commit_list;
+
+	/**
+	 * @commit_lock:
+	 *
+	 * Spinlock to protect @commit_list.
+	 */
+	spinlock_t commit_lock;
+
+	/**
+	 * @acquire_ctx:
+	 *
+	 * Per-CRTC implicit acquire context used by atomic drivers for legacy
+	 * IOCTLs, so that atomic drivers can get at the locking acquire
+	 * context.
+	 */
+	struct drm_modeset_acquire_ctx *acquire_ctx;
+
+#ifdef CONFIG_DEBUG_FS
+	/**
+	 * @debugfs_entry:
+	 *
+	 * Debugfs directory for this CRTC.
+	 */
+	struct dentry *debugfs_entry;
+
+	/**
+	 * @crc:
+	 *
+	 * Configuration settings of CRC capture.
+	 */
+	struct drm_crtc_crc crc;
+#endif
+
+	/**
+	 * @fence_context:
+	 *
+	 * timeline context used for fence operations.
+	 */
+	unsigned int fence_context;
+
+	/**
+	 * @fence_lock:
+	 *
+	 * spinlock to protect the fences in the fence_context.
+	 */
+
+	spinlock_t fence_lock;
+	/**
+	 * @fence_seqno:
+	 *
+	 * Seqno variable used as monotonic counter for the fences
+	 * created on the CRTC's timeline.
+	 */
+	unsigned long fence_seqno;
+
+	/**
+	 * @timeline_name:
+	 *
+	 * The name of the CRTC's fence timeline.
+	 */
+	char timeline_name[32];
+};
+
+/**
+ * struct drm_mode_set - new values for a CRTC config change
+ * @fb: framebuffer to use for new config
+ * @crtc: CRTC whose configuration we're about to change
+ * @mode: mode timings to use
+ * @x: position of this CRTC relative to @fb
+ * @y: position of this CRTC relative to @fb
+ * @connectors: array of connectors to drive with this CRTC if possible
+ * @num_connectors: size of @connectors array
+ *
+ * This represents a modeset configuration for the legacy SETCRTC ioctl and is
+ * also used internally. Atomic drivers instead use &drm_atomic_state.
+ */
+struct drm_mode_set {
+	struct drm_framebuffer *fb;
+	struct drm_crtc *crtc;
+	struct drm_display_mode *mode;
+
+	uint32_t x;
+	uint32_t y;
+
+	struct drm_connector **connectors;
+	size_t num_connectors;
+};
+
+#define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
+
+__printf(6, 7)
+int drm_crtc_init_with_planes(struct drm_device *dev,
+			      struct drm_crtc *crtc,
+			      struct drm_plane *primary,
+			      struct drm_plane *cursor,
+			      const struct drm_crtc_funcs *funcs,
+			      const char *name, ...);
+void drm_crtc_cleanup(struct drm_crtc *crtc);
+
+/**
+ * drm_crtc_index - find the index of a registered CRTC
+ * @crtc: CRTC to find index for
+ *
+ * Given a registered CRTC, return the index of that CRTC within a DRM
+ * device's list of CRTCs.
+ */
+static inline unsigned int drm_crtc_index(const struct drm_crtc *crtc)
+{
+	return crtc->index;
+}
+
+/**
+ * drm_crtc_mask - find the mask of a registered CRTC
+ * @crtc: CRTC to find mask for
+ *
+ * Given a registered CRTC, return the mask bit of that CRTC for an
+ * encoder's possible_crtcs field.
+ */
+static inline uint32_t drm_crtc_mask(const struct drm_crtc *crtc)
+{
+	return 1 << drm_crtc_index(crtc);
+}
+
+int drm_crtc_force_disable(struct drm_crtc *crtc);
+int drm_crtc_force_disable_all(struct drm_device *dev);
+
+int drm_mode_set_config_internal(struct drm_mode_set *set);
+struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx);
+
+/**
+ * drm_crtc_find - look up a CRTC object from its ID
+ * @dev: DRM device
+ * @id: &drm_mode_object ID
+ *
+ * This can be used to look up a CRTC from its userspace ID. Only used by
+ * drivers for legacy IOCTLs and interface, nowadays extensions to the KMS
+ * userspace interface should be done using &drm_property.
+ */
+static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
+	uint32_t id)
+{
+	struct drm_mode_object *mo;
+	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC);
+	return mo ? obj_to_crtc(mo) : NULL;
+}
+
+/**
+ * drm_for_each_crtc - iterate over all CRTCs
+ * @crtc: a &struct drm_crtc as the loop cursor
+ * @dev: the &struct drm_device
+ *
+ * Iterate over all CRTCs of @dev.
+ */
+#define drm_for_each_crtc(crtc, dev) \
+	list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head)
+
+#endif /* __DRM_CRTC_H__ */
diff --git a/headers/private/graphics/drm/uapi/drm/drm.h b/headers/private/graphics/drm/uapi/drm/drm.h
new file mode 100644
index 0000000000..b0b8556136
--- /dev/null
+++ b/headers/private/graphics/drm/uapi/drm/drm.h
@@ -0,0 +1,866 @@
+/**
+ * \file drm.h
+ * Header for the Direct Rendering Manager
+ *
+ * \author Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ * \par Acknowledgments:
+ * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic \c cmpxchg.
+ */
+
+/*
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * 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 (including the next
+ * paragraph) 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
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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 _DRM_H_
+#define _DRM_H_
+
+#if defined(__KERNEL__) || defined(__linux__)
+
+#include <linux/types.h>
+#include <asm/ioctl.h>
+typedef unsigned int drm_handle_t;
+
+#else /* One of the BSDs */
+
+#include <sys/ioccom.h>
+#include <sys/types.h>
+typedef int8_t   __s8;
+typedef uint8_t  __u8;
+typedef int16_t  __s16;
+typedef uint16_t __u16;
+typedef int32_t  __s32;
+typedef uint32_t __u32;
+typedef int64_t  __s64;
+typedef uint64_t __u64;
+typedef unsigned long drm_handle_t;
+
+#endif
+
+#define DRM_NAME	"drm"	  /**< Name in kernel, /dev, and /proc */
+#define DRM_MIN_ORDER	5	  /**< At least 2^5 bytes = 32 bytes */
+#define DRM_MAX_ORDER	22	  /**< Up to 2^22 bytes = 4MB */
+#define DRM_RAM_PERCENT 10	  /**< How much system ram can we lock? */
+
+#define _DRM_LOCK_HELD	0x80000000U /**< Hardware lock is held */
+#define _DRM_LOCK_CONT	0x40000000U /**< Hardware lock is contended */
+#define _DRM_LOCK_IS_HELD(lock)	   ((lock) & _DRM_LOCK_HELD)
+#define _DRM_LOCK_IS_CONT(lock)	   ((lock) & _DRM_LOCK_CONT)
+#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
+
+typedef unsigned int drm_context_t;
+typedef unsigned int drm_drawable_t;
+typedef unsigned int drm_magic_t;
+
+/**
+ * Cliprect.
+ *
+ * \warning: If you change this structure, make sure you change
+ * XF86DRIClipRectRec in the server as well
+ *
+ * \note KW: Actually it's illegal to change either for
+ * backwards-compatibility reasons.
+ */
+struct drm_clip_rect {
+	unsigned short x1;
+	unsigned short y1;
+	unsigned short x2;
+	unsigned short y2;
+};
+
+/**
+ * Drawable information.
+ */
+struct drm_drawable_info {
+	unsigned int num_rects;
+	struct drm_clip_rect *rects;
+};
+
+/**
+ * Texture region,
+ */
+struct drm_tex_region {
+	unsigned char next;
+	unsigned char prev;
+	unsigned char in_use;
+	unsigned char padding;
+	unsigned int age;
+};
+
+/**
+ * Hardware lock.
+ *
+ * The lock structure is a simple cache-line aligned integer.  To avoid
+ * processor bus contention on a multiprocessor system, there should not be any
+ * other data stored in the same cache line.
+ */
+struct drm_hw_lock {
+	__volatile__ unsigned int lock;		/**< lock variable */
+	char padding[60];			/**< Pad to cache line */
+};
+
+/**
+ * DRM_IOCTL_VERSION ioctl argument type.
+ *
+ * \sa drmGetVersion().
+ */
+struct drm_version {
+	int version_major;	  /**< Major version */
+	int version_minor;	  /**< Minor version */
+	int version_patchlevel;	  /**< Patch level */
+	size_t name_len;	  /**< Length of name buffer */
+	char __user *name;	  /**< Name of driver */
+	size_t date_len;	  /**< Length of date buffer */
+	char __user *date;	  /**< User-space buffer to hold date */
+	size_t desc_len;	  /**< Length of desc buffer */
+	char __user *desc;	  /**< User-space buffer to hold desc */
+};
+
+/**
+ * DRM_IOCTL_GET_UNIQUE ioctl argument type.
+ *
+ * \sa drmGetBusid() and drmSetBusId().
+ */
+struct drm_unique {
+	size_t unique_len;	  /**< Length of unique */
+	char __user *unique;	  /**< Unique name for driver instantiation */
+};
+
+struct drm_list {
+	int count;		  /**< Length of user-space structures */
+	struct drm_version __user *version;
+};
+
+struct drm_block {
+	int unused;
+};
+
+/**
+ * DRM_IOCTL_CONTROL ioctl argument type.
+ *
+ * \sa drmCtlInstHandler() and drmCtlUninstHandler().
+ */
+struct drm_control {
+	enum {
+		DRM_ADD_COMMAND,
+		DRM_RM_COMMAND,
+		DRM_INST_HANDLER,
+		DRM_UNINST_HANDLER
+	} func;
+	int irq;
+};
+
+/**
+ * Type of memory to map.
+ */
+enum drm_map_type {
+	_DRM_FRAME_BUFFER = 0,	  /**< WC (no caching), no core dump */
+	_DRM_REGISTERS = 1,	  /**< no caching, no core dump */
+	_DRM_SHM = 2,		  /**< shared, cached */
+	_DRM_AGP = 3,		  /**< AGP/GART */
+	_DRM_SCATTER_GATHER = 4,  /**< Scatter/gather memory for PCI DMA */
+	_DRM_CONSISTENT = 5,	  /**< Consistent memory for PCI DMA */
+};
+
+/**
+ * Memory mapping flags.
+ */
+enum drm_map_flags {
+	_DRM_RESTRICTED = 0x01,	     /**< Cannot be mapped to user-virtual */
+	_DRM_READ_ONLY = 0x02,
+	_DRM_LOCKED = 0x04,	     /**< shared, cached, locked */
+	_DRM_KERNEL = 0x08,	     /**< kernel requires access */
+	_DRM_WRITE_COMBINING = 0x10, /**< use write-combining if available */
+	_DRM_CONTAINS_LOCK = 0x20,   /**< SHM page that contains lock */
+	_DRM_REMOVABLE = 0x40,	     /**< Removable mapping */
+	_DRM_DRIVER = 0x80	     /**< Managed by driver */
+};
+
+struct drm_ctx_priv_map {
+	unsigned int ctx_id;	 /**< Context requesting private mapping */
+	void *handle;		 /**< Handle of map */
+};
+
+/**
+ * DRM_IOCTL_GET_MAP, DRM_IOCTL_ADD_MAP and DRM_IOCTL_RM_MAP ioctls
+ * argument type.
+ *
+ * \sa drmAddMap().
+ */
+struct drm_map {
+	unsigned long offset;	 /**< Requested physical address (0 for SAREA)*/
+	unsigned long size;	 /**< Requested physical size (bytes) */
+	enum drm_map_type type;	 /**< Type of memory to map */
+	enum drm_map_flags flags;	 /**< Flags */
+	void *handle;		 /**< User-space: "Handle" to pass to mmap() */
+				 /**< Kernel-space: kernel-virtual address */
+	int mtrr;		 /**< MTRR slot used */
+	/*   Private data */
+};
+
+/**
+ * DRM_IOCTL_GET_CLIENT ioctl argument type.
+ */
+struct drm_client {
+	int idx;		/**< Which client desired? */
+	int auth;		/**< Is client authenticated? */
+	unsigned long pid;	/**< Process ID */
+	unsigned long uid;	/**< User ID */
+	unsigned long magic;	/**< Magic */
+	unsigned long iocs;	/**< Ioctl count */
+};
+
+enum drm_stat_type {
+	_DRM_STAT_LOCK,
+	_DRM_STAT_OPENS,
+	_DRM_STAT_CLOSES,
+	_DRM_STAT_IOCTLS,
+	_DRM_STAT_LOCKS,
+	_DRM_STAT_UNLOCKS,
+	_DRM_STAT_VALUE,	/**< Generic value */
+	_DRM_STAT_BYTE,		/**< Generic byte counter (1024bytes/K) */
+	_DRM_STAT_COUNT,	/**< Generic non-byte counter (1000/k) */
+
+	_DRM_STAT_IRQ,		/**< IRQ */
+	_DRM_STAT_PRIMARY,	/**< Primary DMA bytes */
+	_DRM_STAT_SECONDARY,	/**< Secondary DMA bytes */
+	_DRM_STAT_DMA,		/**< DMA */
+	_DRM_STAT_SPECIAL,	/**< Special DMA (e.g., priority or polled) */
+	_DRM_STAT_MISSED	/**< Missed DMA opportunity */
+	    /* Add to the *END* of the list */
+};
+
+/**
+ * DRM_IOCTL_GET_STATS ioctl argument type.
+ */
+struct drm_stats {
+	unsigned long count;
+	struct {
+		unsigned long value;
+		enum drm_stat_type type;
+	} data[15];
+};
+
+/**
+ * Hardware locking flags.
+ */
+enum drm_lock_flags {
+	_DRM_LOCK_READY = 0x01,	     /**< Wait until hardware is ready for DMA */
+	_DRM_LOCK_QUIESCENT = 0x02,  /**< Wait until hardware quiescent */
+	_DRM_LOCK_FLUSH = 0x04,	     /**< Flush this context's DMA queue first */
+	_DRM_LOCK_FLUSH_ALL = 0x08,  /**< Flush all DMA queues first */
+	/* These *HALT* flags aren't supported yet
+	   -- they will be used to support the
+	   full-screen DGA-like mode. */
+	_DRM_HALT_ALL_QUEUES = 0x10, /**< Halt all current and future queues */
+	_DRM_HALT_CUR_QUEUES = 0x20  /**< Halt all current queues */
+};
+
+/**
+ * DRM_IOCTL_LOCK, DRM_IOCTL_UNLOCK and DRM_IOCTL_FINISH ioctl argument type.
+ *
+ * \sa drmGetLock() and drmUnlock().
+ */
+struct drm_lock {
+	int context;
+	enum drm_lock_flags flags;
+};
+
+/**
+ * DMA flags
+ *
+ * \warning
+ * These values \e must match xf86drm.h.
+ *
+ * \sa drm_dma.
+ */
+enum drm_dma_flags {
+	/* Flags for DMA buffer dispatch */
+	_DRM_DMA_BLOCK = 0x01,	      /**<
+				       * Block until buffer dispatched.
+				       *
+				       * \note The buffer may not yet have
+				       * been processed by the hardware --
+				       * getting a hardware lock with the
+				       * hardware quiescent will ensure
+				       * that the buffer has been
+				       * processed.
+				       */
+	_DRM_DMA_WHILE_LOCKED = 0x02, /**< Dispatch while lock held */
+	_DRM_DMA_PRIORITY = 0x04,     /**< High priority dispatch */
+
+	/* Flags for DMA buffer request */
+	_DRM_DMA_WAIT = 0x10,	      /**< Wait for free buffers */
+	_DRM_DMA_SMALLER_OK = 0x20,   /**< Smaller-than-requested buffers OK */
+	_DRM_DMA_LARGER_OK = 0x40     /**< Larger-than-requested buffers OK */
+};
+
+/**
+ * DRM_IOCTL_ADD_BUFS and DRM_IOCTL_MARK_BUFS ioctl argument type.
+ *
+ * \sa drmAddBufs().
+ */
+struct drm_buf_desc {
+	int count;		 /**< Number of buffers of this size */
+	int size;		 /**< Size in bytes */
+	int low_mark;		 /**< Low water mark */
+	int high_mark;		 /**< High water mark */
+	enum {
+		_DRM_PAGE_ALIGN = 0x01,	/**< Align on page boundaries for DMA */
+		_DRM_AGP_BUFFER = 0x02,	/**< Buffer is in AGP space */
+		_DRM_SG_BUFFER = 0x04,	/**< Scatter/gather memory buffer */
+		_DRM_FB_BUFFER = 0x08,	/**< Buffer is in frame buffer */
+		_DRM_PCI_BUFFER_RO = 0x10 /**< Map PCI DMA buffer read-only */
+	} flags;
+	unsigned long agp_start; /**<
+				  * Start address of where the AGP buffers are
+				  * in the AGP aperture
+				  */
+};
+
+/**
+ * DRM_IOCTL_INFO_BUFS ioctl argument type.
+ */
+struct drm_buf_info {
+	int count;		/**< Entries in list */
+	struct drm_buf_desc __user *list;
+};
+
+/**
+ * DRM_IOCTL_FREE_BUFS ioctl argument type.
+ */
+struct drm_buf_free {
+	int count;
+	int __user *list;
+};
+
+/**
+ * Buffer information
+ *
+ * \sa drm_buf_map.
+ */
+struct drm_buf_pub {
+	int idx;		       /**< Index into the master buffer list */
+	int total;		       /**< Buffer size */
+	int used;		       /**< Amount of buffer in use (for DMA) */
+	void __user *address;	       /**< Address of buffer */
+};
+
+/**
+ * DRM_IOCTL_MAP_BUFS ioctl argument type.
+ */
+struct drm_buf_map {
+	int count;		/**< Length of the buffer list */
+	void __user *virtual;		/**< Mmap'd area in user-virtual */
+	struct drm_buf_pub __user *list;	/**< Buffer information */
+};
+
+/**
+ * DRM_IOCTL_DMA ioctl argument type.
+ *
+ * Indices here refer to the offset into the buffer list in drm_buf_get.
+ *
+ * \sa drmDMA().
+ */
+struct drm_dma {
+	int context;			  /**< Context handle */
+	int send_count;			  /**< Number of buffers to send */
+	int __user *send_indices;	  /**< List of handles to buffers */
+	int __user *send_sizes;		  /**< Lengths of data to send */
+	enum drm_dma_flags flags;	  /**< Flags */
+	int request_count;		  /**< Number of buffers requested */
+	int request_size;		  /**< Desired size for buffers */
+	int __user *request_indices;	  /**< Buffer information */
+	int __user *request_sizes;
+	int granted_count;		  /**< Number of buffers granted */
+};
+
+enum drm_ctx_flags {
+	_DRM_CONTEXT_PRESERVED = 0x01,
+	_DRM_CONTEXT_2DONLY = 0x02
+};
+
+/**
+ * DRM_IOCTL_ADD_CTX ioctl argument type.
+ *
+ * \sa drmCreateContext() and drmDestroyContext().
+ */
+struct drm_ctx {
+	drm_context_t handle;
+	enum drm_ctx_flags flags;
+};
+
+/**
+ * DRM_IOCTL_RES_CTX ioctl argument type.
+ */
+struct drm_ctx_res {
+	int count;
+	struct drm_ctx __user *contexts;
+};
+
+/**
+ * DRM_IOCTL_ADD_DRAW and DRM_IOCTL_RM_DRAW ioctl argument type.
+ */
+struct drm_draw {
+	drm_drawable_t handle;
+};
+
+/**
+ * DRM_IOCTL_UPDATE_DRAW ioctl argument type.
+ */
+typedef enum {
+	DRM_DRAWABLE_CLIPRECTS,
+} drm_drawable_info_type_t;
+
+struct drm_update_draw {
+	drm_drawable_t handle;
+	unsigned int type;
+	unsigned int num;
+	unsigned long long data;
+};
+
+/**
+ * DRM_IOCTL_GET_MAGIC and DRM_IOCTL_AUTH_MAGIC ioctl argument type.
+ */
+struct drm_auth {
+	drm_magic_t magic;
+};
+
+/**
+ * DRM_IOCTL_IRQ_BUSID ioctl argument type.
+ *
+ * \sa drmGetInterruptFromBusID().
+ */
+struct drm_irq_busid {
+	int irq;	/**< IRQ number */
+	int busnum;	/**< bus number */
+	int devnum;	/**< device number */
+	int funcnum;	/**< function number */
+};
+
+enum drm_vblank_seq_type {
+	_DRM_VBLANK_ABSOLUTE = 0x0,	/**< Wait for specific vblank sequence number */
+	_DRM_VBLANK_RELATIVE = 0x1,	/**< Wait for given number of vblanks */
+	/* bits 1-6 are reserved for high crtcs */
+	_DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e,
+	_DRM_VBLANK_EVENT = 0x4000000,   /**< Send event instead of blocking */
+	_DRM_VBLANK_FLIP = 0x8000000,   /**< Scheduled buffer swap should flip */
+	_DRM_VBLANK_NEXTONMISS = 0x10000000,	/**< If missed, wait for next vblank */
+	_DRM_VBLANK_SECONDARY = 0x20000000,	/**< Secondary display controller */
+	_DRM_VBLANK_SIGNAL = 0x40000000	/**< Send signal instead of blocking, unsupported */
+};
+#define _DRM_VBLANK_HIGH_CRTC_SHIFT 1
+
+#define _DRM_VBLANK_TYPES_MASK (_DRM_VBLANK_ABSOLUTE | _DRM_VBLANK_RELATIVE)
+#define _DRM_VBLANK_FLAGS_MASK (_DRM_VBLANK_EVENT | _DRM_VBLANK_SIGNAL | \
+				_DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS)
+
+struct drm_wait_vblank_request {
+	enum drm_vblank_seq_type type;
+	unsigned int sequence;
+	unsigned long signal;
+};
+
+struct drm_wait_vblank_reply {
+	enum drm_vblank_seq_type type;
+	unsigned int sequence;
+	long tval_sec;
+	long tval_usec;
+};
+
+/**
+ * DRM_IOCTL_WAIT_VBLANK ioctl argument type.
+ *
+ * \sa drmWaitVBlank().
+ */
+union drm_wait_vblank {
+	struct drm_wait_vblank_request request;
+	struct drm_wait_vblank_reply reply;
+};
+
+#define _DRM_PRE_MODESET 1
+#define _DRM_POST_MODESET 2
+
+/**
+ * DRM_IOCTL_MODESET_CTL ioctl argument type
+ *
+ * \sa drmModesetCtl().
+ */
+struct drm_modeset_ctl {
+	__u32 crtc;
+	__u32 cmd;
+};
+
+/**
+ * DRM_IOCTL_AGP_ENABLE ioctl argument type.
+ *
+ * \sa drmAgpEnable().
+ */
+struct drm_agp_mode {
+	unsigned long mode;	/**< AGP mode */
+};
+
+/**
+ * DRM_IOCTL_AGP_ALLOC and DRM_IOCTL_AGP_FREE ioctls argument type.
+ *
+ * \sa drmAgpAlloc() and drmAgpFree().
+ */
+struct drm_agp_buffer {
+	unsigned long size;	/**< In bytes -- will round to page boundary */
+	unsigned long handle;	/**< Used for binding / unbinding */
+	unsigned long type;	/**< Type of memory to allocate */
+	unsigned long physical;	/**< Physical used by i810 */
+};
+
+/**
+ * DRM_IOCTL_AGP_BIND and DRM_IOCTL_AGP_UNBIND ioctls argument type.
+ *
+ * \sa drmAgpBind() and drmAgpUnbind().
+ */
+struct drm_agp_binding {
+	unsigned long handle;	/**< From drm_agp_buffer */
+	unsigned long offset;	/**< In bytes -- will round to page boundary */
+};
+
+/**
+ * DRM_IOCTL_AGP_INFO ioctl argument type.
+ *
+ * \sa drmAgpVersionMajor(), drmAgpVersionMinor(), drmAgpGetMode(),
+ * drmAgpBase(), drmAgpSize(), drmAgpMemoryUsed(), drmAgpMemoryAvail(),
+ * drmAgpVendorId() and drmAgpDeviceId().
+ */
+struct drm_agp_info {
+	int agp_version_major;
+	int agp_version_minor;
+	unsigned long mode;
+	unsigned long aperture_base;	/* physical address */
+	unsigned long aperture_size;	/* bytes */
+	unsigned long memory_allowed;	/* bytes */
+	unsigned long memory_used;
+
+	/* PCI information */
+	unsigned short id_vendor;
+	unsigned short id_device;
+};
+
+/**
+ * DRM_IOCTL_SG_ALLOC ioctl argument type.
+ */
+struct drm_scatter_gather {
+	unsigned long size;	/**< In bytes -- will round to page boundary */
+	unsigned long handle;	/**< Used for mapping / unmapping */
+};
+
+/**
+ * DRM_IOCTL_SET_VERSION ioctl argument type.
+ */
+struct drm_set_version {
+	int drm_di_major;
+	int drm_di_minor;
+	int drm_dd_major;
+	int drm_dd_minor;
+};
+
+/** DRM_IOCTL_GEM_CLOSE ioctl argument type */
+struct drm_gem_close {
+	/** Handle of the object to be closed. */
+	__u32 handle;
+	__u32 pad;
+};
+
+/** DRM_IOCTL_GEM_FLINK ioctl argument type */
+struct drm_gem_flink {
+	/** Handle for the object being named */
+	__u32 handle;
+
+	/** Returned global name */
+	__u32 name;
+};
+
+/** DRM_IOCTL_GEM_OPEN ioctl argument type */
+struct drm_gem_open {
+	/** Name of object being opened */
+	__u32 name;
+
+	/** Returned handle for the object */
+	__u32 handle;
+
+	/** Returned size of the object */
+	__u64 size;
+};
+
+#define DRM_CAP_DUMB_BUFFER		0x1
+#define DRM_CAP_VBLANK_HIGH_CRTC	0x2
+#define DRM_CAP_DUMB_PREFERRED_DEPTH	0x3
+#define DRM_CAP_DUMB_PREFER_SHADOW	0x4
+#define DRM_CAP_PRIME			0x5
+#define  DRM_PRIME_CAP_IMPORT		0x1
+#define  DRM_PRIME_CAP_EXPORT		0x2
+#define DRM_CAP_TIMESTAMP_MONOTONIC	0x6
+#define DRM_CAP_ASYNC_PAGE_FLIP		0x7
+/*
+ * The CURSOR_WIDTH and CURSOR_HEIGHT capabilities return a valid widthxheight
+ * combination for the hardware cursor. The intention is that a hardware
+ * agnostic userspace can query a cursor plane size to use.
+ *
+ * Note that the cross-driver contract is to merely return a valid size;
+ * drivers are free to attach another meaning on top, eg. i915 returns the
+ * maximum plane size.
+ */
+#define DRM_CAP_CURSOR_WIDTH		0x8
+#define DRM_CAP_CURSOR_HEIGHT		0x9
+
+/** DRM_IOCTL_GET_CAP ioctl argument type */
+struct drm_get_cap {
+	__u64 capability;
+	__u64 value;
+};
+
+/**
+ * DRM_CLIENT_CAP_STEREO_3D
+ *
+ * if set to 1, the DRM core will expose the stereo 3D capabilities of the
+ * monitor by advertising the supported 3D layouts in the flags of struct
+ * drm_mode_modeinfo.
+ */
+#define DRM_CLIENT_CAP_STEREO_3D	1
+
+/**
+ * DRM_CLIENT_CAP_UNIVERSAL_PLANES
+ *
+ * If set to 1, the DRM core will expose all planes (overlay, primary, and
+ * cursor) to userspace.
+ */
+#define DRM_CLIENT_CAP_UNIVERSAL_PLANES  2
+
+/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
+struct drm_set_client_cap {
+	__u64 capability;
+	__u64 value;
+};
+
+#define DRM_CLOEXEC O_CLOEXEC
+struct drm_prime_handle {
+	__u32 handle;
+
+	/** Flags.. only applicable for handle->fd */
+	__u32 flags;
+
+	/** Returned dmabuf file descriptor */
+	__s32 fd;
+};
+
+#include <drm/drm_mode.h>
+
+#define DRM_IOCTL_BASE			'd'
+#define DRM_IO(nr)			_IO(DRM_IOCTL_BASE,nr)
+#define DRM_IOR(nr,type)		_IOR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOW(nr,type)		_IOW(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOWR(nr,type)		_IOWR(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_VERSION		DRM_IOWR(0x00, struct drm_version)
+#define DRM_IOCTL_GET_UNIQUE		DRM_IOWR(0x01, struct drm_unique)
+#define DRM_IOCTL_GET_MAGIC		DRM_IOR( 0x02, struct drm_auth)
+#define DRM_IOCTL_IRQ_BUSID		DRM_IOWR(0x03, struct drm_irq_busid)
+#define DRM_IOCTL_GET_MAP               DRM_IOWR(0x04, struct drm_map)
+#define DRM_IOCTL_GET_CLIENT            DRM_IOWR(0x05, struct drm_client)
+#define DRM_IOCTL_GET_STATS             DRM_IOR( 0x06, struct drm_stats)
+#define DRM_IOCTL_SET_VERSION		DRM_IOWR(0x07, struct drm_set_version)
+#define DRM_IOCTL_MODESET_CTL           DRM_IOW(0x08, struct drm_modeset_ctl)
+#define DRM_IOCTL_GEM_CLOSE		DRM_IOW (0x09, struct drm_gem_close)
+#define DRM_IOCTL_GEM_FLINK		DRM_IOWR(0x0a, struct drm_gem_flink)
+#define DRM_IOCTL_GEM_OPEN		DRM_IOWR(0x0b, struct drm_gem_open)
+#define DRM_IOCTL_GET_CAP		DRM_IOWR(0x0c, struct drm_get_cap)
+#define DRM_IOCTL_SET_CLIENT_CAP	DRM_IOW( 0x0d, struct drm_set_client_cap)
+
+#define DRM_IOCTL_SET_UNIQUE		DRM_IOW( 0x10, struct drm_unique)
+#define DRM_IOCTL_AUTH_MAGIC		DRM_IOW( 0x11, struct drm_auth)
+#define DRM_IOCTL_BLOCK			DRM_IOWR(0x12, struct drm_block)
+#define DRM_IOCTL_UNBLOCK		DRM_IOWR(0x13, struct drm_block)
+#define DRM_IOCTL_CONTROL		DRM_IOW( 0x14, struct drm_control)
+#define DRM_IOCTL_ADD_MAP		DRM_IOWR(0x15, struct drm_map)
+#define DRM_IOCTL_ADD_BUFS		DRM_IOWR(0x16, struct drm_buf_desc)
+#define DRM_IOCTL_MARK_BUFS		DRM_IOW( 0x17, struct drm_buf_desc)
+#define DRM_IOCTL_INFO_BUFS		DRM_IOWR(0x18, struct drm_buf_info)
+#define DRM_IOCTL_MAP_BUFS		DRM_IOWR(0x19, struct drm_buf_map)
+#define DRM_IOCTL_FREE_BUFS		DRM_IOW( 0x1a, struct drm_buf_free)
+
+#define DRM_IOCTL_RM_MAP		DRM_IOW( 0x1b, struct drm_map)
+
+#define DRM_IOCTL_SET_SAREA_CTX		DRM_IOW( 0x1c, struct drm_ctx_priv_map)
+#define DRM_IOCTL_GET_SAREA_CTX 	DRM_IOWR(0x1d, struct drm_ctx_priv_map)
+
+#define DRM_IOCTL_SET_MASTER            DRM_IO(0x1e)
+#define DRM_IOCTL_DROP_MASTER           DRM_IO(0x1f)
+
+#define DRM_IOCTL_ADD_CTX		DRM_IOWR(0x20, struct drm_ctx)
+#define DRM_IOCTL_RM_CTX		DRM_IOWR(0x21, struct drm_ctx)
+#define DRM_IOCTL_MOD_CTX		DRM_IOW( 0x22, struct drm_ctx)
+#define DRM_IOCTL_GET_CTX		DRM_IOWR(0x23, struct drm_ctx)
+#define DRM_IOCTL_SWITCH_CTX		DRM_IOW( 0x24, struct drm_ctx)
+#define DRM_IOCTL_NEW_CTX		DRM_IOW( 0x25, struct drm_ctx)
+#define DRM_IOCTL_RES_CTX		DRM_IOWR(0x26, struct drm_ctx_res)
+#define DRM_IOCTL_ADD_DRAW		DRM_IOWR(0x27, struct drm_draw)
+#define DRM_IOCTL_RM_DRAW		DRM_IOWR(0x28, struct drm_draw)
+#define DRM_IOCTL_DMA			DRM_IOWR(0x29, struct drm_dma)
+#define DRM_IOCTL_LOCK			DRM_IOW( 0x2a, struct drm_lock)
+#define DRM_IOCTL_UNLOCK		DRM_IOW( 0x2b, struct drm_lock)
+#define DRM_IOCTL_FINISH		DRM_IOW( 0x2c, struct drm_lock)
+
+#define DRM_IOCTL_PRIME_HANDLE_TO_FD    DRM_IOWR(0x2d, struct drm_prime_handle)
+#define DRM_IOCTL_PRIME_FD_TO_HANDLE    DRM_IOWR(0x2e, struct drm_prime_handle)
+
+#define DRM_IOCTL_AGP_ACQUIRE		DRM_IO(  0x30)
+#define DRM_IOCTL_AGP_RELEASE		DRM_IO(  0x31)
+#define DRM_IOCTL_AGP_ENABLE		DRM_IOW( 0x32, struct drm_agp_mode)
+#define DRM_IOCTL_AGP_INFO		DRM_IOR( 0x33, struct drm_agp_info)
+#define DRM_IOCTL_AGP_ALLOC		DRM_IOWR(0x34, struct drm_agp_buffer)
+#define DRM_IOCTL_AGP_FREE		DRM_IOW( 0x35, struct drm_agp_buffer)
+#define DRM_IOCTL_AGP_BIND		DRM_IOW( 0x36, struct drm_agp_binding)
+#define DRM_IOCTL_AGP_UNBIND		DRM_IOW( 0x37, struct drm_agp_binding)
+
+#define DRM_IOCTL_SG_ALLOC		DRM_IOWR(0x38, struct drm_scatter_gather)
+#define DRM_IOCTL_SG_FREE		DRM_IOW( 0x39, struct drm_scatter_gather)
+
+#define DRM_IOCTL_WAIT_VBLANK		DRM_IOWR(0x3a, union drm_wait_vblank)
+
+#define DRM_IOCTL_UPDATE_DRAW		DRM_IOW(0x3f, struct drm_update_draw)
+
+#define DRM_IOCTL_MODE_GETRESOURCES	DRM_IOWR(0xA0, struct drm_mode_card_res)
+#define DRM_IOCTL_MODE_GETCRTC		DRM_IOWR(0xA1, struct drm_mode_crtc)
+#define DRM_IOCTL_MODE_SETCRTC		DRM_IOWR(0xA2, struct drm_mode_crtc)
+#define DRM_IOCTL_MODE_CURSOR		DRM_IOWR(0xA3, struct drm_mode_cursor)
+#define DRM_IOCTL_MODE_GETGAMMA		DRM_IOWR(0xA4, struct drm_mode_crtc_lut)
+#define DRM_IOCTL_MODE_SETGAMMA		DRM_IOWR(0xA5, struct drm_mode_crtc_lut)
+#define DRM_IOCTL_MODE_GETENCODER	DRM_IOWR(0xA6, struct drm_mode_get_encoder)
+#define DRM_IOCTL_MODE_GETCONNECTOR	DRM_IOWR(0xA7, struct drm_mode_get_connector)
+#define DRM_IOCTL_MODE_ATTACHMODE	DRM_IOWR(0xA8, struct drm_mode_mode_cmd) /* deprecated (never worked) */
+#define DRM_IOCTL_MODE_DETACHMODE	DRM_IOWR(0xA9, struct drm_mode_mode_cmd) /* deprecated (never worked) */
+
+#define DRM_IOCTL_MODE_GETPROPERTY	DRM_IOWR(0xAA, struct drm_mode_get_property)
+#define DRM_IOCTL_MODE_SETPROPERTY	DRM_IOWR(0xAB, struct drm_mode_connector_set_property)
+#define DRM_IOCTL_MODE_GETPROPBLOB	DRM_IOWR(0xAC, struct drm_mode_get_blob)
+#define DRM_IOCTL_MODE_GETFB		DRM_IOWR(0xAD, struct drm_mode_fb_cmd)
+#define DRM_IOCTL_MODE_ADDFB		DRM_IOWR(0xAE, struct drm_mode_fb_cmd)
+#define DRM_IOCTL_MODE_RMFB		DRM_IOWR(0xAF, unsigned int)
+#define DRM_IOCTL_MODE_PAGE_FLIP	DRM_IOWR(0xB0, struct drm_mode_crtc_page_flip)
+#define DRM_IOCTL_MODE_DIRTYFB		DRM_IOWR(0xB1, struct drm_mode_fb_dirty_cmd)
+
+#define DRM_IOCTL_MODE_CREATE_DUMB DRM_IOWR(0xB2, struct drm_mode_create_dumb)
+#define DRM_IOCTL_MODE_MAP_DUMB    DRM_IOWR(0xB3, struct drm_mode_map_dumb)
+#define DRM_IOCTL_MODE_DESTROY_DUMB    DRM_IOWR(0xB4, struct drm_mode_destroy_dumb)
+#define DRM_IOCTL_MODE_GETPLANERESOURCES DRM_IOWR(0xB5, struct drm_mode_get_plane_res)
+#define DRM_IOCTL_MODE_GETPLANE	DRM_IOWR(0xB6, struct drm_mode_get_plane)
+#define DRM_IOCTL_MODE_SETPLANE	DRM_IOWR(0xB7, struct drm_mode_set_plane)
+#define DRM_IOCTL_MODE_ADDFB2		DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)
+#define DRM_IOCTL_MODE_OBJ_GETPROPERTIES	DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)
+#define DRM_IOCTL_MODE_OBJ_SETPROPERTY	DRM_IOWR(0xBA, struct drm_mode_obj_set_property)
+#define DRM_IOCTL_MODE_CURSOR2		DRM_IOWR(0xBB, struct drm_mode_cursor2)
+
+/**
+ * Device specific ioctls should only be in their respective headers
+ * The device specific ioctl range is from 0x40 to 0x9f.
+ * Generic IOCTLS restart at 0xA0.
+ *
+ * \sa drmCommandNone(), drmCommandRead(), drmCommandWrite(), and
+ * drmCommandReadWrite().
+ */
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END			0xA0
+
+/**
+ * Header for events written back to userspace on the drm fd.  The
+ * type defines the type of event, the length specifies the total
+ * length of the event (including the header), and user_data is
+ * typically a 64 bit value passed with the ioctl that triggered the
+ * event.  A read on the drm fd will always only return complete
+ * events, that is, if for example the read buffer is 100 bytes, and
+ * there are two 64 byte events pending, only one will be returned.
+ *
+ * Event types 0 - 0x7fffffff are generic drm events, 0x80000000 and
+ * up are chipset specific.
+ */
+struct drm_event {
+	__u32 type;
+	__u32 length;
+};
+
+#define DRM_EVENT_VBLANK 0x01
+#define DRM_EVENT_FLIP_COMPLETE 0x02
+
+struct drm_event_vblank {
+	struct drm_event base;
+	__u64 user_data;
+	__u32 tv_sec;
+	__u32 tv_usec;
+	__u32 sequence;
+	__u32 reserved;
+};
+
+/* typedef area */
+#ifndef __KERNEL__
+typedef struct drm_clip_rect drm_clip_rect_t;
+typedef struct drm_drawable_info drm_drawable_info_t;
+typedef struct drm_tex_region drm_tex_region_t;
+typedef struct drm_hw_lock drm_hw_lock_t;
+typedef struct drm_version drm_version_t;
+typedef struct drm_unique drm_unique_t;
+typedef struct drm_list drm_list_t;
+typedef struct drm_block drm_block_t;
+typedef struct drm_control drm_control_t;
+typedef enum drm_map_type drm_map_type_t;
+typedef enum drm_map_flags drm_map_flags_t;
+typedef struct drm_ctx_priv_map drm_ctx_priv_map_t;
+typedef struct drm_map drm_map_t;
+typedef struct drm_client drm_client_t;
+typedef enum drm_stat_type drm_stat_type_t;
+typedef struct drm_stats drm_stats_t;
+typedef enum drm_lock_flags drm_lock_flags_t;
+typedef struct drm_lock drm_lock_t;
+typedef enum drm_dma_flags drm_dma_flags_t;
+typedef struct drm_buf_desc drm_buf_desc_t;
+typedef struct drm_buf_info drm_buf_info_t;
+typedef struct drm_buf_free drm_buf_free_t;
+typedef struct drm_buf_pub drm_buf_pub_t;
+typedef struct drm_buf_map drm_buf_map_t;
+typedef struct drm_dma drm_dma_t;
+typedef union drm_wait_vblank drm_wait_vblank_t;
+typedef struct drm_agp_mode drm_agp_mode_t;
+typedef enum drm_ctx_flags drm_ctx_flags_t;
+typedef struct drm_ctx drm_ctx_t;
+typedef struct drm_ctx_res drm_ctx_res_t;
+typedef struct drm_draw drm_draw_t;
+typedef struct drm_update_draw drm_update_draw_t;
+typedef struct drm_auth drm_auth_t;
+typedef struct drm_irq_busid drm_irq_busid_t;
+typedef enum drm_vblank_seq_type drm_vblank_seq_type_t;
+
+typedef struct drm_agp_buffer drm_agp_buffer_t;
+typedef struct drm_agp_binding drm_agp_binding_t;
+typedef struct drm_agp_info drm_agp_info_t;
+typedef struct drm_scatter_gather drm_scatter_gather_t;
+typedef struct drm_set_version drm_set_version_t;
+#endif
+
+#endif
diff --git a/headers/private/graphics/drm/uapi/drm/drm_mode.h b/headers/private/graphics/drm/uapi/drm/drm_mode.h
new file mode 100644
index 0000000000..a0db2d4aa5
--- /dev/null
+++ b/headers/private/graphics/drm/uapi/drm/drm_mode.h
@@ -0,0 +1,520 @@
+/*
+ * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
+ * Copyright (c) 2007 Jakob Bornecrantz <wallbraker@gmail.com>
+ * Copyright (c) 2008 Red Hat Inc.
+ * Copyright (c) 2007-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
+ * Copyright (c) 2007-2008 Intel Corporation
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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 _DRM_MODE_H
+#define _DRM_MODE_H
+
+#include <linux/types.h>
+
+#define DRM_DISPLAY_INFO_LEN	32
+#define DRM_CONNECTOR_NAME_LEN	32
+#define DRM_DISPLAY_MODE_LEN	32
+#define DRM_PROP_NAME_LEN	32
+
+#define DRM_MODE_TYPE_BUILTIN	(1<<0)
+#define DRM_MODE_TYPE_CLOCK_C	((1<<1) | DRM_MODE_TYPE_BUILTIN)
+#define DRM_MODE_TYPE_CRTC_C	((1<<2) | DRM_MODE_TYPE_BUILTIN)
+#define DRM_MODE_TYPE_PREFERRED	(1<<3)
+#define DRM_MODE_TYPE_DEFAULT	(1<<4)
+#define DRM_MODE_TYPE_USERDEF	(1<<5)
+#define DRM_MODE_TYPE_DRIVER	(1<<6)
+
+/* Video mode flags */
+/* bit compatible with the xorg definitions. */
+#define DRM_MODE_FLAG_PHSYNC			(1<<0)
+#define DRM_MODE_FLAG_NHSYNC			(1<<1)
+#define DRM_MODE_FLAG_PVSYNC			(1<<2)
+#define DRM_MODE_FLAG_NVSYNC			(1<<3)
+#define DRM_MODE_FLAG_INTERLACE			(1<<4)
+#define DRM_MODE_FLAG_DBLSCAN			(1<<5)
+#define DRM_MODE_FLAG_CSYNC			(1<<6)
+#define DRM_MODE_FLAG_PCSYNC			(1<<7)
+#define DRM_MODE_FLAG_NCSYNC			(1<<8)
+#define DRM_MODE_FLAG_HSKEW			(1<<9) /* hskew provided */
+#define DRM_MODE_FLAG_BCAST			(1<<10)
+#define DRM_MODE_FLAG_PIXMUX			(1<<11)
+#define DRM_MODE_FLAG_DBLCLK			(1<<12)
+#define DRM_MODE_FLAG_CLKDIV2			(1<<13)
+ /*
+  * When adding a new stereo mode don't forget to adjust DRM_MODE_FLAGS_3D_MAX
+  * (define not exposed to user space).
+  */
+#define DRM_MODE_FLAG_3D_MASK			(0x1f<<14)
+#define  DRM_MODE_FLAG_3D_NONE			(0<<14)
+#define  DRM_MODE_FLAG_3D_FRAME_PACKING		(1<<14)
+#define  DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE	(2<<14)
+#define  DRM_MODE_FLAG_3D_LINE_ALTERNATIVE	(3<<14)
+#define  DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL	(4<<14)
+#define  DRM_MODE_FLAG_3D_L_DEPTH		(5<<14)
+#define  DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH	(6<<14)
+#define  DRM_MODE_FLAG_3D_TOP_AND_BOTTOM	(7<<14)
+#define  DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF	(8<<14)
+
+
+/* DPMS flags */
+/* bit compatible with the xorg definitions. */
+#define DRM_MODE_DPMS_ON	0
+#define DRM_MODE_DPMS_STANDBY	1
+#define DRM_MODE_DPMS_SUSPEND	2
+#define DRM_MODE_DPMS_OFF	3
+
+/* Scaling mode options */
+#define DRM_MODE_SCALE_NONE		0 /* Unmodified timing (display or
+					     software can still scale) */
+#define DRM_MODE_SCALE_FULLSCREEN	1 /* Full screen, ignore aspect */
+#define DRM_MODE_SCALE_CENTER		2 /* Centered, no scaling */
+#define DRM_MODE_SCALE_ASPECT		3 /* Full screen, preserve aspect */
+
+/* Picture aspect ratio options */
+#define DRM_MODE_PICTURE_ASPECT_NONE	0
+#define DRM_MODE_PICTURE_ASPECT_4_3	1
+#define DRM_MODE_PICTURE_ASPECT_16_9	2
+
+/* Dithering mode options */
+#define DRM_MODE_DITHERING_OFF	0
+#define DRM_MODE_DITHERING_ON	1
+#define DRM_MODE_DITHERING_AUTO 2
+
+/* Dirty info options */
+#define DRM_MODE_DIRTY_OFF      0
+#define DRM_MODE_DIRTY_ON       1
+#define DRM_MODE_DIRTY_ANNOTATE 2
+
+struct drm_mode_modeinfo {
+	__u32 clock;
+	__u16 hdisplay, hsync_start, hsync_end, htotal, hskew;
+	__u16 vdisplay, vsync_start, vsync_end, vtotal, vscan;
+
+	__u32 vrefresh;
+
+	__u32 flags;
+	__u32 type;
+	char name[DRM_DISPLAY_MODE_LEN];
+};
+
+struct drm_mode_card_res {
+	__u64 fb_id_ptr;
+	__u64 crtc_id_ptr;
+	__u64 connector_id_ptr;
+	__u64 encoder_id_ptr;
+	__u32 count_fbs;
+	__u32 count_crtcs;
+	__u32 count_connectors;
+	__u32 count_encoders;
+	__u32 min_width, max_width;
+	__u32 min_height, max_height;
+};
+
+struct drm_mode_crtc {
+	__u64 set_connectors_ptr;
+	__u32 count_connectors;
+
+	__u32 crtc_id; /**< Id */
+	__u32 fb_id; /**< Id of framebuffer */
+
+	__u32 x, y; /**< Position on the frameuffer */
+
+	__u32 gamma_size;
+	__u32 mode_valid;
+	struct drm_mode_modeinfo mode;
+};
+
+#define DRM_MODE_PRESENT_TOP_FIELD	(1<<0)
+#define DRM_MODE_PRESENT_BOTTOM_FIELD	(1<<1)
+
+/* Planes blend with or override other bits on the CRTC */
+struct drm_mode_set_plane {
+	__u32 plane_id;
+	__u32 crtc_id;
+	__u32 fb_id; /* fb object contains surface format type */
+	__u32 flags; /* see above flags */
+
+	/* Signed dest location allows it to be partially off screen */
+	__s32 crtc_x, crtc_y;
+	__u32 crtc_w, crtc_h;
+
+	/* Source values are 16.16 fixed point */
+	__u32 src_x, src_y;
+	__u32 src_h, src_w;
+};
+
+struct drm_mode_get_plane {
+	__u32 plane_id;
+
+	__u32 crtc_id;
+	__u32 fb_id;
+
+	__u32 possible_crtcs;
+	__u32 gamma_size;
+
+	__u32 count_format_types;
+	__u64 format_type_ptr;
+};
+
+struct drm_mode_get_plane_res {
+	__u64 plane_id_ptr;
+	__u32 count_planes;
+};
+
+#define DRM_MODE_ENCODER_NONE	0
+#define DRM_MODE_ENCODER_DAC	1
+#define DRM_MODE_ENCODER_TMDS	2
+#define DRM_MODE_ENCODER_LVDS	3
+#define DRM_MODE_ENCODER_TVDAC	4
+#define DRM_MODE_ENCODER_VIRTUAL 5
+#define DRM_MODE_ENCODER_DSI	6
+#define DRM_MODE_ENCODER_DPMST	7
+
+struct drm_mode_get_encoder {
+	__u32 encoder_id;
+	__u32 encoder_type;
+
+	__u32 crtc_id; /**< Id of crtc */
+
+	__u32 possible_crtcs;
+	__u32 possible_clones;
+};
+
+/* This is for connectors with multiple signal types. */
+/* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
+#define DRM_MODE_SUBCONNECTOR_Automatic	0
+#define DRM_MODE_SUBCONNECTOR_Unknown	0
+#define DRM_MODE_SUBCONNECTOR_DVID	3
+#define DRM_MODE_SUBCONNECTOR_DVIA	4
+#define DRM_MODE_SUBCONNECTOR_Composite	5
+#define DRM_MODE_SUBCONNECTOR_SVIDEO	6
+#define DRM_MODE_SUBCONNECTOR_Component	8
+#define DRM_MODE_SUBCONNECTOR_SCART	9
+
+#define DRM_MODE_CONNECTOR_Unknown	0
+#define DRM_MODE_CONNECTOR_VGA		1
+#define DRM_MODE_CONNECTOR_DVII		2
+#define DRM_MODE_CONNECTOR_DVID		3
+#define DRM_MODE_CONNECTOR_DVIA		4
+#define DRM_MODE_CONNECTOR_Composite	5
+#define DRM_MODE_CONNECTOR_SVIDEO	6
+#define DRM_MODE_CONNECTOR_LVDS		7
+#define DRM_MODE_CONNECTOR_Component	8
+#define DRM_MODE_CONNECTOR_9PinDIN	9
+#define DRM_MODE_CONNECTOR_DisplayPort	10
+#define DRM_MODE_CONNECTOR_HDMIA	11
+#define DRM_MODE_CONNECTOR_HDMIB	12
+#define DRM_MODE_CONNECTOR_TV		13
+#define DRM_MODE_CONNECTOR_eDP		14
+#define DRM_MODE_CONNECTOR_VIRTUAL      15
+#define DRM_MODE_CONNECTOR_DSI		16
+
+struct drm_mode_get_connector {
+
+	__u64 encoders_ptr;
+	__u64 modes_ptr;
+	__u64 props_ptr;
+	__u64 prop_values_ptr;
+
+	__u32 count_modes;
+	__u32 count_props;
+	__u32 count_encoders;
+
+	__u32 encoder_id; /**< Current Encoder */
+	__u32 connector_id; /**< Id */
+	__u32 connector_type;
+	__u32 connector_type_id;
+
+	__u32 connection;
+	__u32 mm_width, mm_height; /**< HxW in millimeters */
+	__u32 subpixel;
+
+	__u32 pad;
+};
+
+#define DRM_MODE_PROP_PENDING	(1<<0)
+#define DRM_MODE_PROP_RANGE	(1<<1)
+#define DRM_MODE_PROP_IMMUTABLE	(1<<2)
+#define DRM_MODE_PROP_ENUM	(1<<3) /* enumerated type with text strings */
+#define DRM_MODE_PROP_BLOB	(1<<4)
+#define DRM_MODE_PROP_BITMASK	(1<<5) /* bitmask of enumerated types */
+
+/* non-extended types: legacy bitmask, one bit per type: */
+#define DRM_MODE_PROP_LEGACY_TYPE  ( \
+		DRM_MODE_PROP_RANGE | \
+		DRM_MODE_PROP_ENUM | \
+		DRM_MODE_PROP_BLOB | \
+		DRM_MODE_PROP_BITMASK)
+
+/* extended-types: rather than continue to consume a bit per type,
+ * grab a chunk of the bits to use as integer type id.
+ */
+#define DRM_MODE_PROP_EXTENDED_TYPE	0x0000ffc0
+#define DRM_MODE_PROP_TYPE(n)		((n) << 6)
+#define DRM_MODE_PROP_OBJECT		DRM_MODE_PROP_TYPE(1)
+#define DRM_MODE_PROP_SIGNED_RANGE	DRM_MODE_PROP_TYPE(2)
+
+struct drm_mode_property_enum {
+	__u64 value;
+	char name[DRM_PROP_NAME_LEN];
+};
+
+struct drm_mode_get_property {
+	__u64 values_ptr; /* values and blob lengths */
+	__u64 enum_blob_ptr; /* enum and blob id ptrs */
+
+	__u32 prop_id;
+	__u32 flags;
+	char name[DRM_PROP_NAME_LEN];
+
+	__u32 count_values;
+	__u32 count_enum_blobs;
+};
+
+struct drm_mode_connector_set_property {
+	__u64 value;
+	__u32 prop_id;
+	__u32 connector_id;
+};
+
+struct drm_mode_obj_get_properties {
+	__u64 props_ptr;
+	__u64 prop_values_ptr;
+	__u32 count_props;
+	__u32 obj_id;
+	__u32 obj_type;
+};
+
+struct drm_mode_obj_set_property {
+	__u64 value;
+	__u32 prop_id;
+	__u32 obj_id;
+	__u32 obj_type;
+};
+
+struct drm_mode_get_blob {
+	__u32 blob_id;
+	__u32 length;
+	__u64 data;
+};
+
+struct drm_mode_fb_cmd {
+	__u32 fb_id;
+	__u32 width, height;
+	__u32 pitch;
+	__u32 bpp;
+	__u32 depth;
+	/* driver specific handle */
+	__u32 handle;
+};
+
+#define DRM_MODE_FB_INTERLACED	(1<<0) /* for interlaced framebuffers */
+
+struct drm_mode_fb_cmd2 {
+	__u32 fb_id;
+	__u32 width, height;
+	__u32 pixel_format; /* fourcc code from drm_fourcc.h */
+	__u32 flags; /* see above flags */
+
+	/*
+	 * In case of planar formats, this ioctl allows up to 4
+	 * buffer objects with offets and pitches per plane.
+	 * The pitch and offset order is dictated by the fourcc,
+	 * e.g. NV12 (http://fourcc.org/yuv.php#NV12) is described as:
+	 *
+	 *   YUV 4:2:0 image with a plane of 8 bit Y samples
+	 *   followed by an interleaved U/V plane containing
+	 *   8 bit 2x2 subsampled colour difference samples.
+	 *
+	 * So it would consist of Y as offset[0] and UV as
+	 * offeset[1].  Note that offset[0] will generally
+	 * be 0.
+	 */
+	__u32 handles[4];
+	__u32 pitches[4]; /* pitch for each plane */
+	__u32 offsets[4]; /* offset of each plane */
+};
+
+#define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
+#define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
+#define DRM_MODE_FB_DIRTY_FLAGS         0x03
+
+#define DRM_MODE_FB_DIRTY_MAX_CLIPS     256
+
+/*
+ * Mark a region of a framebuffer as dirty.
+ *
+ * Some hardware does not automatically update display contents
+ * as a hardware or software draw to a framebuffer. This ioctl
+ * allows userspace to tell the kernel and the hardware what
+ * regions of the framebuffer have changed.
+ *
+ * The kernel or hardware is free to update more then just the
+ * region specified by the clip rects. The kernel or hardware
+ * may also delay and/or coalesce several calls to dirty into a
+ * single update.
+ *
+ * Userspace may annotate the updates, the annotates are a
+ * promise made by the caller that the change is either a copy
+ * of pixels or a fill of a single color in the region specified.
+ *
+ * If the DRM_MODE_FB_DIRTY_ANNOTATE_COPY flag is given then
+ * the number of updated regions are half of num_clips given,
+ * where the clip rects are paired in src and dst. The width and
+ * height of each one of the pairs must match.
+ *
+ * If the DRM_MODE_FB_DIRTY_ANNOTATE_FILL flag is given the caller
+ * promises that the region specified of the clip rects is filled
+ * completely with a single color as given in the color argument.
+ */
+
+struct drm_mode_fb_dirty_cmd {
+	__u32 fb_id;
+	__u32 flags;
+	__u32 color;
+	__u32 num_clips;
+	__u64 clips_ptr;
+};
+
+struct drm_mode_mode_cmd {
+	__u32 connector_id;
+	struct drm_mode_modeinfo mode;
+};
+
+#define DRM_MODE_CURSOR_BO	0x01
+#define DRM_MODE_CURSOR_MOVE	0x02
+#define DRM_MODE_CURSOR_FLAGS	0x03
+
+/*
+ * depending on the value in flags different members are used.
+ *
+ * CURSOR_BO uses
+ *    crtc_id
+ *    width
+ *    height
+ *    handle - if 0 turns the cursor off
+ *
+ * CURSOR_MOVE uses
+ *    crtc_id
+ *    x
+ *    y
+ */
+struct drm_mode_cursor {
+	__u32 flags;
+	__u32 crtc_id;
+	__s32 x;
+	__s32 y;
+	__u32 width;
+	__u32 height;
+	/* driver specific handle */
+	__u32 handle;
+};
+
+struct drm_mode_cursor2 {
+	__u32 flags;
+	__u32 crtc_id;
+	__s32 x;
+	__s32 y;
+	__u32 width;
+	__u32 height;
+	/* driver specific handle */
+	__u32 handle;
+	__s32 hot_x;
+	__s32 hot_y;
+};
+
+struct drm_mode_crtc_lut {
+	__u32 crtc_id;
+	__u32 gamma_size;
+
+	/* pointers to arrays */
+	__u64 red;
+	__u64 green;
+	__u64 blue;
+};
+
+#define DRM_MODE_PAGE_FLIP_EVENT 0x01
+#define DRM_MODE_PAGE_FLIP_ASYNC 0x02
+#define DRM_MODE_PAGE_FLIP_FLAGS (DRM_MODE_PAGE_FLIP_EVENT|DRM_MODE_PAGE_FLIP_ASYNC)
+
+/*
+ * Request a page flip on the specified crtc.
+ *
+ * This ioctl will ask KMS to schedule a page flip for the specified
+ * crtc.  Once any pending rendering targeting the specified fb (as of
+ * ioctl time) has completed, the crtc will be reprogrammed to display
+ * that fb after the next vertical refresh.  The ioctl returns
+ * immediately, but subsequent rendering to the current fb will block
+ * in the execbuffer ioctl until the page flip happens.  If a page
+ * flip is already pending as the ioctl is called, EBUSY will be
+ * returned.
+ *
+ * Flag DRM_MODE_PAGE_FLIP_EVENT requests that drm sends back a vblank
+ * event (see drm.h: struct drm_event_vblank) when the page flip is
+ * done.  The user_data field passed in with this ioctl will be
+ * returned as the user_data field in the vblank event struct.
+ *
+ * Flag DRM_MODE_PAGE_FLIP_ASYNC requests that the flip happen
+ * 'as soon as possible', meaning that it not delay waiting for vblank.
+ * This may cause tearing on the screen.
+ *
+ * The reserved field must be zero until we figure out something
+ * clever to use it for.
+ */
+
+struct drm_mode_crtc_page_flip {
+	__u32 crtc_id;
+	__u32 fb_id;
+	__u32 flags;
+	__u32 reserved;
+	__u64 user_data;
+};
+
+/* create a dumb scanout buffer */
+struct drm_mode_create_dumb {
+	uint32_t height;
+	uint32_t width;
+	uint32_t bpp;
+	uint32_t flags;
+	/* handle, pitch, size will be returned */
+	uint32_t handle;
+	uint32_t pitch;
+	uint64_t size;
+};
+
+/* set up for mmap of a dumb scanout buffer */
+struct drm_mode_map_dumb {
+	/** Handle for the object being mapped. */
+	__u32 handle;
+	__u32 pad;
+	/**
+	 * Fake offset to use for subsequent mmap call
+	 *
+	 * This is a fixed-size type for 32/64 compatibility.
+	 */
+	__u64 offset;
+};
+
+struct drm_mode_destroy_dumb {
+	uint32_t handle;
+};
+
+#endif
diff --git a/headers/private/graphics/3dfx/DriverInterface.h b/headers/private/graphics/legacy/3dfx/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/3dfx/DriverInterface.h
rename to headers/private/graphics/legacy/3dfx/DriverInterface.h
diff --git a/headers/private/graphics/AGP.h b/headers/private/graphics/legacy/AGP.h
similarity index 100%
rename from headers/private/graphics/AGP.h
rename to headers/private/graphics/legacy/AGP.h
diff --git a/headers/private/graphics/ati/DriverInterface.h b/headers/private/graphics/legacy/ati/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/ati/DriverInterface.h
rename to headers/private/graphics/legacy/ati/DriverInterface.h
diff --git a/headers/private/graphics/common/benaphore.h b/headers/private/graphics/legacy/common/benaphore.h
similarity index 100%
rename from headers/private/graphics/common/benaphore.h
rename to headers/private/graphics/legacy/common/benaphore.h
diff --git a/headers/private/graphics/common/bendian_bitfield.h b/headers/private/graphics/legacy/common/bendian_bitfield.h
similarity index 100%
rename from headers/private/graphics/common/bendian_bitfield.h
rename to headers/private/graphics/legacy/common/bendian_bitfield.h
diff --git a/headers/private/graphics/common/compute_display_timing.h b/headers/private/graphics/legacy/common/compute_display_timing.h
similarity index 100%
rename from headers/private/graphics/common/compute_display_timing.h
rename to headers/private/graphics/legacy/common/compute_display_timing.h
diff --git a/headers/private/graphics/common/create_display_modes.h b/headers/private/graphics/legacy/common/create_display_modes.h
similarity index 100%
rename from headers/private/graphics/common/create_display_modes.h
rename to headers/private/graphics/legacy/common/create_display_modes.h
diff --git a/headers/private/graphics/common/ddc.h b/headers/private/graphics/legacy/common/ddc.h
similarity index 100%
rename from headers/private/graphics/common/ddc.h
rename to headers/private/graphics/legacy/common/ddc.h
diff --git a/headers/private/graphics/common/debug_ext.h b/headers/private/graphics/legacy/common/debug_ext.h
similarity index 100%
rename from headers/private/graphics/common/debug_ext.h
rename to headers/private/graphics/legacy/common/debug_ext.h
diff --git a/headers/private/graphics/common/dp.h b/headers/private/graphics/legacy/common/dp.h
similarity index 100%
rename from headers/private/graphics/common/dp.h
rename to headers/private/graphics/legacy/common/dp.h
diff --git a/headers/private/graphics/common/dp_raw.h b/headers/private/graphics/legacy/common/dp_raw.h
similarity index 100%
rename from headers/private/graphics/common/dp_raw.h
rename to headers/private/graphics/legacy/common/dp_raw.h
diff --git a/headers/private/graphics/common/edid.h b/headers/private/graphics/legacy/common/edid.h
similarity index 100%
rename from headers/private/graphics/common/edid.h
rename to headers/private/graphics/legacy/common/edid.h
diff --git a/headers/private/graphics/common/edid_raw.h b/headers/private/graphics/legacy/common/edid_raw.h
similarity index 100%
rename from headers/private/graphics/common/edid_raw.h
rename to headers/private/graphics/legacy/common/edid_raw.h
diff --git a/headers/private/graphics/common/i2c.h b/headers/private/graphics/legacy/common/i2c.h
similarity index 100%
rename from headers/private/graphics/common/i2c.h
rename to headers/private/graphics/legacy/common/i2c.h
diff --git a/headers/private/graphics/common/lendian_bitfield.h b/headers/private/graphics/legacy/common/lendian_bitfield.h
similarity index 100%
rename from headers/private/graphics/common/lendian_bitfield.h
rename to headers/private/graphics/legacy/common/lendian_bitfield.h
diff --git a/headers/private/graphics/common/log_coll.h b/headers/private/graphics/legacy/common/log_coll.h
similarity index 100%
rename from headers/private/graphics/common/log_coll.h
rename to headers/private/graphics/legacy/common/log_coll.h
diff --git a/headers/private/graphics/common/memory_manager.h b/headers/private/graphics/legacy/common/memory_manager.h
similarity index 100%
rename from headers/private/graphics/common/memory_manager.h
rename to headers/private/graphics/legacy/common/memory_manager.h
diff --git a/headers/private/graphics/common/validate_display_mode.h b/headers/private/graphics/legacy/common/validate_display_mode.h
similarity index 100%
rename from headers/private/graphics/common/validate_display_mode.h
rename to headers/private/graphics/legacy/common/validate_display_mode.h
diff --git a/headers/private/graphics/common/video_configuration.h b/headers/private/graphics/legacy/common/video_configuration.h
similarity index 100%
rename from headers/private/graphics/common/video_configuration.h
rename to headers/private/graphics/legacy/common/video_configuration.h
diff --git a/headers/private/graphics/et6x00/DriverInterface.h b/headers/private/graphics/legacy/et6x00/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/et6x00/DriverInterface.h
rename to headers/private/graphics/legacy/et6x00/DriverInterface.h
diff --git a/headers/private/graphics/intel_810/DriverInterface.h b/headers/private/graphics/legacy/intel_810/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/intel_810/DriverInterface.h
rename to headers/private/graphics/legacy/intel_810/DriverInterface.h
diff --git a/headers/private/graphics/intel_extreme/AreaKeeper.h b/headers/private/graphics/legacy/intel_extreme/AreaKeeper.h
similarity index 100%
rename from headers/private/graphics/intel_extreme/AreaKeeper.h
rename to headers/private/graphics/legacy/intel_extreme/AreaKeeper.h
diff --git a/headers/private/graphics/intel_extreme/intel_extreme.h b/headers/private/graphics/legacy/intel_extreme/intel_extreme.h
similarity index 100%
rename from headers/private/graphics/intel_extreme/intel_extreme.h
rename to headers/private/graphics/legacy/intel_extreme/intel_extreme.h
diff --git a/headers/private/graphics/intel_extreme/lock.h b/headers/private/graphics/legacy/intel_extreme/lock.h
similarity index 100%
rename from headers/private/graphics/intel_extreme/lock.h
rename to headers/private/graphics/legacy/intel_extreme/lock.h
diff --git a/headers/private/graphics/intel_extreme/utility.h b/headers/private/graphics/legacy/intel_extreme/utility.h
similarity index 100%
rename from headers/private/graphics/intel_extreme/utility.h
rename to headers/private/graphics/legacy/intel_extreme/utility.h
diff --git a/headers/private/graphics/matrox/DriverInterface.h b/headers/private/graphics/legacy/matrox/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/matrox/DriverInterface.h
rename to headers/private/graphics/legacy/matrox/DriverInterface.h
diff --git a/headers/private/graphics/matrox/mga_macros.h b/headers/private/graphics/legacy/matrox/mga_macros.h
similarity index 100%
rename from headers/private/graphics/matrox/mga_macros.h
rename to headers/private/graphics/legacy/matrox/mga_macros.h
diff --git a/headers/private/graphics/neomagic/DriverInterface.h b/headers/private/graphics/legacy/neomagic/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/neomagic/DriverInterface.h
rename to headers/private/graphics/legacy/neomagic/DriverInterface.h
diff --git a/headers/private/graphics/neomagic/nm_macros.h b/headers/private/graphics/legacy/neomagic/nm_macros.h
similarity index 100%
rename from headers/private/graphics/neomagic/nm_macros.h
rename to headers/private/graphics/legacy/neomagic/nm_macros.h
diff --git a/headers/private/graphics/nvidia/DriverInterface.h b/headers/private/graphics/legacy/nvidia/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/nvidia/DriverInterface.h
rename to headers/private/graphics/legacy/nvidia/DriverInterface.h
diff --git a/headers/private/graphics/nvidia/nv_acc.h b/headers/private/graphics/legacy/nvidia/nv_acc.h
similarity index 100%
rename from headers/private/graphics/nvidia/nv_acc.h
rename to headers/private/graphics/legacy/nvidia/nv_acc.h
diff --git a/headers/private/graphics/nvidia/nv_macros.h b/headers/private/graphics/legacy/nvidia/nv_macros.h
similarity index 100%
rename from headers/private/graphics/nvidia/nv_macros.h
rename to headers/private/graphics/legacy/nvidia/nv_macros.h
diff --git a/headers/private/graphics/nvidia_gpgpu/DriverInterface.h b/headers/private/graphics/legacy/nvidia_gpgpu/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/nvidia_gpgpu/DriverInterface.h
rename to headers/private/graphics/legacy/nvidia_gpgpu/DriverInterface.h
diff --git a/headers/private/graphics/nvidia_gpgpu/nv_acc.h b/headers/private/graphics/legacy/nvidia_gpgpu/nv_acc.h
similarity index 100%
rename from headers/private/graphics/nvidia_gpgpu/nv_acc.h
rename to headers/private/graphics/legacy/nvidia_gpgpu/nv_acc.h
diff --git a/headers/private/graphics/nvidia_gpgpu/nv_macros.h b/headers/private/graphics/legacy/nvidia_gpgpu/nv_macros.h
similarity index 100%
rename from headers/private/graphics/nvidia_gpgpu/nv_macros.h
rename to headers/private/graphics/legacy/nvidia_gpgpu/nv_macros.h
diff --git a/headers/private/graphics/omap/omap3_regs.h b/headers/private/graphics/legacy/omap/omap3_regs.h
similarity index 100%
rename from headers/private/graphics/omap/omap3_regs.h
rename to headers/private/graphics/legacy/omap/omap3_regs.h
diff --git a/headers/private/graphics/radeon/2d_regs.h b/headers/private/graphics/legacy/radeon/2d_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/2d_regs.h
rename to headers/private/graphics/legacy/radeon/2d_regs.h
diff --git a/headers/private/graphics/radeon/3d_regs.h b/headers/private/graphics/legacy/radeon/3d_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/3d_regs.h
rename to headers/private/graphics/legacy/radeon/3d_regs.h
diff --git a/headers/private/graphics/radeon/accelerant_ext.h b/headers/private/graphics/legacy/radeon/accelerant_ext.h
similarity index 100%
rename from headers/private/graphics/radeon/accelerant_ext.h
rename to headers/private/graphics/legacy/radeon/accelerant_ext.h
diff --git a/headers/private/graphics/radeon/bios_regs.h b/headers/private/graphics/legacy/radeon/bios_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/bios_regs.h
rename to headers/private/graphics/legacy/radeon/bios_regs.h
diff --git a/headers/private/graphics/radeon/buscntrl_regs.h b/headers/private/graphics/legacy/radeon/buscntrl_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/buscntrl_regs.h
rename to headers/private/graphics/legacy/radeon/buscntrl_regs.h
diff --git a/headers/private/graphics/radeon/capture_regs.h b/headers/private/graphics/legacy/radeon/capture_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/capture_regs.h
rename to headers/private/graphics/legacy/radeon/capture_regs.h
diff --git a/headers/private/graphics/radeon/config_regs.h b/headers/private/graphics/legacy/radeon/config_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/config_regs.h
rename to headers/private/graphics/legacy/radeon/config_regs.h
diff --git a/headers/private/graphics/radeon/cp_regs.h b/headers/private/graphics/legacy/radeon/cp_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/cp_regs.h
rename to headers/private/graphics/legacy/radeon/cp_regs.h
diff --git a/headers/private/graphics/radeon/crtc_regs.h b/headers/private/graphics/legacy/radeon/crtc_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/crtc_regs.h
rename to headers/private/graphics/legacy/radeon/crtc_regs.h
diff --git a/headers/private/graphics/radeon/dac_regs.h b/headers/private/graphics/legacy/radeon/dac_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/dac_regs.h
rename to headers/private/graphics/legacy/radeon/dac_regs.h
diff --git a/headers/private/graphics/radeon/ddc_regs.h b/headers/private/graphics/legacy/radeon/ddc_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/ddc_regs.h
rename to headers/private/graphics/legacy/radeon/ddc_regs.h
diff --git a/headers/private/graphics/radeon/dma_regs.h b/headers/private/graphics/legacy/radeon/dma_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/dma_regs.h
rename to headers/private/graphics/legacy/radeon/dma_regs.h
diff --git a/headers/private/graphics/radeon/fp_regs.h b/headers/private/graphics/legacy/radeon/fp_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/fp_regs.h
rename to headers/private/graphics/legacy/radeon/fp_regs.h
diff --git a/headers/private/graphics/radeon/gpiopad_regs.h b/headers/private/graphics/legacy/radeon/gpiopad_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/gpiopad_regs.h
rename to headers/private/graphics/legacy/radeon/gpiopad_regs.h
diff --git a/headers/private/graphics/radeon/log_enum.h b/headers/private/graphics/legacy/radeon/log_enum.h
similarity index 100%
rename from headers/private/graphics/radeon/log_enum.h
rename to headers/private/graphics/legacy/radeon/log_enum.h
diff --git a/headers/private/graphics/radeon/log_names.h b/headers/private/graphics/legacy/radeon/log_names.h
similarity index 100%
rename from headers/private/graphics/radeon/log_names.h
rename to headers/private/graphics/legacy/radeon/log_names.h
diff --git a/headers/private/graphics/radeon/memcntrl_regs.h b/headers/private/graphics/legacy/radeon/memcntrl_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/memcntrl_regs.h
rename to headers/private/graphics/legacy/radeon/memcntrl_regs.h
diff --git a/headers/private/graphics/radeon/mmio.h b/headers/private/graphics/legacy/radeon/mmio.h
similarity index 100%
rename from headers/private/graphics/radeon/mmio.h
rename to headers/private/graphics/legacy/radeon/mmio.h
diff --git a/headers/private/graphics/radeon/multimon.h b/headers/private/graphics/legacy/radeon/multimon.h
similarity index 100%
rename from headers/private/graphics/radeon/multimon.h
rename to headers/private/graphics/legacy/radeon/multimon.h
diff --git a/headers/private/graphics/radeon/overlay_regs.h b/headers/private/graphics/legacy/radeon/overlay_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/overlay_regs.h
rename to headers/private/graphics/legacy/radeon/overlay_regs.h
diff --git a/headers/private/graphics/radeon/pll_access.h b/headers/private/graphics/legacy/radeon/pll_access.h
similarity index 100%
rename from headers/private/graphics/radeon/pll_access.h
rename to headers/private/graphics/legacy/radeon/pll_access.h
diff --git a/headers/private/graphics/radeon/pll_regs.h b/headers/private/graphics/legacy/radeon/pll_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/pll_regs.h
rename to headers/private/graphics/legacy/radeon/pll_regs.h
diff --git a/headers/private/graphics/radeon/radeon_bios.h b/headers/private/graphics/legacy/radeon/radeon_bios.h
similarity index 100%
rename from headers/private/graphics/radeon/radeon_bios.h
rename to headers/private/graphics/legacy/radeon/radeon_bios.h
diff --git a/headers/private/graphics/radeon/radeon_interface.h b/headers/private/graphics/legacy/radeon/radeon_interface.h
similarity index 100%
rename from headers/private/graphics/radeon/radeon_interface.h
rename to headers/private/graphics/legacy/radeon/radeon_interface.h
diff --git a/headers/private/graphics/radeon/radeon_regs.h b/headers/private/graphics/legacy/radeon/radeon_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/radeon_regs.h
rename to headers/private/graphics/legacy/radeon/radeon_regs.h
diff --git a/headers/private/graphics/radeon/rbbm_regs.h b/headers/private/graphics/legacy/radeon/rbbm_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/rbbm_regs.h
rename to headers/private/graphics/legacy/radeon/rbbm_regs.h
diff --git a/headers/private/graphics/radeon/theatre_regs.h b/headers/private/graphics/legacy/radeon/theatre_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/theatre_regs.h
rename to headers/private/graphics/legacy/radeon/theatre_regs.h
diff --git a/headers/private/graphics/radeon/tv_out_regs.h b/headers/private/graphics/legacy/radeon/tv_out_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/tv_out_regs.h
rename to headers/private/graphics/legacy/radeon/tv_out_regs.h
diff --git a/headers/private/graphics/radeon/utils.h b/headers/private/graphics/legacy/radeon/utils.h
similarity index 100%
rename from headers/private/graphics/radeon/utils.h
rename to headers/private/graphics/legacy/radeon/utils.h
diff --git a/headers/private/graphics/radeon/version.h b/headers/private/graphics/legacy/radeon/version.h
similarity index 100%
rename from headers/private/graphics/radeon/version.h
rename to headers/private/graphics/legacy/radeon/version.h
diff --git a/headers/private/graphics/radeon/vip_regs.h b/headers/private/graphics/legacy/radeon/vip_regs.h
similarity index 100%
rename from headers/private/graphics/radeon/vip_regs.h
rename to headers/private/graphics/legacy/radeon/vip_regs.h
diff --git a/headers/private/graphics/radeon_hd/AreaKeeper.h b/headers/private/graphics/legacy/radeon_hd/AreaKeeper.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/AreaKeeper.h
rename to headers/private/graphics/legacy/radeon_hd/AreaKeeper.h
diff --git a/headers/private/graphics/radeon_hd/avivo_reg.h b/headers/private/graphics/legacy/radeon_hd/avivo_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/avivo_reg.h
rename to headers/private/graphics/legacy/radeon_hd/avivo_reg.h
diff --git a/headers/private/graphics/radeon_hd/car_reg.h b/headers/private/graphics/legacy/radeon_hd/car_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/car_reg.h
rename to headers/private/graphics/legacy/radeon_hd/car_reg.h
diff --git a/headers/private/graphics/radeon_hd/evergreen_reg.h b/headers/private/graphics/legacy/radeon_hd/evergreen_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/evergreen_reg.h
rename to headers/private/graphics/legacy/radeon_hd/evergreen_reg.h
diff --git a/headers/private/graphics/radeon_hd/lock.h b/headers/private/graphics/legacy/radeon_hd/lock.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/lock.h
rename to headers/private/graphics/legacy/radeon_hd/lock.h
diff --git a/headers/private/graphics/radeon_hd/ni_reg.h b/headers/private/graphics/legacy/radeon_hd/ni_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/ni_reg.h
rename to headers/private/graphics/legacy/radeon_hd/ni_reg.h
diff --git a/headers/private/graphics/radeon_hd/r500_reg.h b/headers/private/graphics/legacy/radeon_hd/r500_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/r500_reg.h
rename to headers/private/graphics/legacy/radeon_hd/r500_reg.h
diff --git a/headers/private/graphics/radeon_hd/r600_reg.h b/headers/private/graphics/legacy/radeon_hd/r600_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/r600_reg.h
rename to headers/private/graphics/legacy/radeon_hd/r600_reg.h
diff --git a/headers/private/graphics/radeon_hd/r700_reg.h b/headers/private/graphics/legacy/radeon_hd/r700_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/r700_reg.h
rename to headers/private/graphics/legacy/radeon_hd/r700_reg.h
diff --git a/headers/private/graphics/radeon_hd/radeon_hd.h b/headers/private/graphics/legacy/radeon_hd/radeon_hd.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/radeon_hd.h
rename to headers/private/graphics/legacy/radeon_hd/radeon_hd.h
diff --git a/headers/private/graphics/radeon_hd/radeon_reg.h b/headers/private/graphics/legacy/radeon_hd/radeon_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/radeon_reg.h
rename to headers/private/graphics/legacy/radeon_hd/radeon_reg.h
diff --git a/headers/private/graphics/radeon_hd/sea_reg.h b/headers/private/graphics/legacy/radeon_hd/sea_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/sea_reg.h
rename to headers/private/graphics/legacy/radeon_hd/sea_reg.h
diff --git a/headers/private/graphics/radeon_hd/si_reg.h b/headers/private/graphics/legacy/radeon_hd/si_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/si_reg.h
rename to headers/private/graphics/legacy/radeon_hd/si_reg.h
diff --git a/headers/private/graphics/radeon_hd/utility.h b/headers/private/graphics/legacy/radeon_hd/utility.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/utility.h
rename to headers/private/graphics/legacy/radeon_hd/utility.h
diff --git a/headers/private/graphics/radeon_hd/vol_reg.h b/headers/private/graphics/legacy/radeon_hd/vol_reg.h
similarity index 100%
rename from headers/private/graphics/radeon_hd/vol_reg.h
rename to headers/private/graphics/legacy/radeon_hd/vol_reg.h
diff --git a/headers/private/graphics/s3/DriverInterface.h b/headers/private/graphics/legacy/s3/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/s3/DriverInterface.h
rename to headers/private/graphics/legacy/s3/DriverInterface.h
diff --git a/headers/private/graphics/skeleton/DriverInterface.h b/headers/private/graphics/legacy/skeleton/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/skeleton/DriverInterface.h
rename to headers/private/graphics/legacy/skeleton/DriverInterface.h
diff --git a/headers/private/graphics/skeleton/macros.h b/headers/private/graphics/legacy/skeleton/macros.h
similarity index 100%
rename from headers/private/graphics/skeleton/macros.h
rename to headers/private/graphics/legacy/skeleton/macros.h
diff --git a/headers/private/graphics/vesa/utility.h b/headers/private/graphics/legacy/vesa/utility.h
similarity index 100%
rename from headers/private/graphics/vesa/utility.h
rename to headers/private/graphics/legacy/vesa/utility.h
diff --git a/headers/private/graphics/vesa/vesa.h b/headers/private/graphics/legacy/vesa/vesa.h
similarity index 100%
rename from headers/private/graphics/vesa/vesa.h
rename to headers/private/graphics/legacy/vesa/vesa.h
diff --git a/headers/private/graphics/vesa/vesa_info.h b/headers/private/graphics/legacy/vesa/vesa_info.h
similarity index 100%
rename from headers/private/graphics/vesa/vesa_info.h
rename to headers/private/graphics/legacy/vesa/vesa_info.h
diff --git a/headers/private/graphics/vesa/vga.h b/headers/private/graphics/legacy/vesa/vga.h
similarity index 100%
rename from headers/private/graphics/vesa/vga.h
rename to headers/private/graphics/legacy/vesa/vga.h
diff --git a/headers/private/graphics/via/DriverInterface.h b/headers/private/graphics/legacy/via/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/via/DriverInterface.h
rename to headers/private/graphics/legacy/via/DriverInterface.h
diff --git a/headers/private/graphics/via/macros.h b/headers/private/graphics/legacy/via/macros.h
similarity index 100%
rename from headers/private/graphics/via/macros.h
rename to headers/private/graphics/legacy/via/macros.h
diff --git a/headers/private/graphics/video_overlay.h b/headers/private/graphics/legacy/video_overlay.h
similarity index 100%
rename from headers/private/graphics/video_overlay.h
rename to headers/private/graphics/legacy/video_overlay.h
diff --git a/headers/private/graphics/vmware/DriverInterface.h b/headers/private/graphics/legacy/vmware/DriverInterface.h
similarity index 100%
rename from headers/private/graphics/vmware/DriverInterface.h
rename to headers/private/graphics/legacy/vmware/DriverInterface.h
diff --git a/headers/private/graphics/vmware/svga_reg.h b/headers/private/graphics/legacy/vmware/svga_reg.h
similarity index 100%
rename from headers/private/graphics/vmware/svga_reg.h
rename to headers/private/graphics/legacy/vmware/svga_reg.h
diff --git a/headers/private/graphics/vmware/vm_device_version.h b/headers/private/graphics/legacy/vmware/vm_device_version.h
similarity index 100%
rename from headers/private/graphics/vmware/vm_device_version.h
rename to headers/private/graphics/legacy/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..3cb271cdc5 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 legacy ;
+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..11ab5f915a
--- /dev/null
+++ b/src/add-ons/kernel/drivers/graphics/drm/Jamfile
@@ -0,0 +1,57 @@
+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 linux ] : true ;
+
+UsePrivateKernelHeaders ;
+UseHeaders $(HAIKU_PRIVATE_KERNEL_HEADERS) : true ;
+
+SubDirCcFlags [ FDefines _KERNEL=1 B_USE_POSITIVE_POSIX_ERRORS=1 __KERNEL__=1 ] ;
+
+KernelAddon drm :
+	 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/drm/drm_auth.c b/src/add-ons/kernel/drivers/graphics/drm/drm_auth.c
new file mode 100644
index 0000000000..7ff697389d
--- /dev/null
+++ b/src/add-ons/kernel/drivers/graphics/drm/drm_auth.c
@@ -0,0 +1,334 @@
+/*
+ * Created: Tue Feb  2 08:37:54 1999 by faith@valinux.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Author Rickard E. (Rik) Faith <faith@valinux.com>
+ * Author Gareth Hughes <gareth@valinux.com>
+ *
+ * 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 (including the next
+ * paragraph) 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
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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.
+ */
+
+#include <drm/drmP.h>
+#include "drm_internal.h"
+#include "drm_legacy.h"
+
+/**
+ * DOC: master and authentication
+ *
+ * &struct drm_master is used to track groups of clients with open
+ * primary/legacy device nodes. For every &struct drm_file which has had at
+ * least once successfully became the device master (either through the
+ * SET_MASTER IOCTL, or implicitly through opening the primary device node when
+ * no one else is the current master that time) there exists one &drm_master.
+ * This is noted in &drm_file.is_master. All other clients have just a pointer
+ * to the &drm_master they are associated with.
+ *
+ * In addition only one &drm_master can be the current master for a &drm_device.
+ * It can be switched through the DROP_MASTER and SET_MASTER IOCTL, or
+ * implicitly through closing/openeing the primary device node. See also
+ * drm_is_current_master().
+ *
+ * Clients can authenticate against the current master (if it matches their own)
+ * using the GETMAGIC and AUTHMAGIC IOCTLs. Together with exchanging masters,
+ * this allows controlled access to the device for an entire group of mutually
+ * trusted clients.
+ */
+
+int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
+{
+	struct drm_auth *auth = data;
+	int ret = 0;
+
+	mutex_lock(&dev->master_mutex);
+	if (!file_priv->magic) {
+		ret = idr_alloc(&file_priv->master->magic_map, file_priv,
+				1, 0, GFP_KERNEL);
+		if (ret >= 0)
+			file_priv->magic = ret;
+	}
+	auth->magic = file_priv->magic;
+	mutex_unlock(&dev->master_mutex);
+
+	DRM_DEBUG("%u\n", auth->magic);
+
+	return ret < 0 ? ret : 0;
+}
+
+int drm_authmagic(struct drm_device *dev, void *data,
+		  struct drm_file *file_priv)
+{
+	struct drm_auth *auth = data;
+	struct drm_file *file;
+
+	DRM_DEBUG("%u\n", auth->magic);
+
+	mutex_lock(&dev->master_mutex);
+	file = idr_find(&file_priv->master->magic_map, auth->magic);
+	if (file) {
+		file->authenticated = 1;
+		idr_replace(&file_priv->master->magic_map, NULL, auth->magic);
+	}
+	mutex_unlock(&dev->master_mutex);
+
+	return file ? 0 : -EINVAL;
+}
+
+static struct drm_master *drm_master_create(struct drm_device *dev)
+{
+	struct drm_master *master;
+
+	master = kzalloc(sizeof(*master), GFP_KERNEL);
+	if (!master)
+		return NULL;
+
+	kref_init(&master->refcount);
+	spin_lock_init(&master->lock.spinlock);
+	init_waitqueue_head(&master->lock.lock_queue);
+	idr_init(&master->magic_map);
+	master->dev = dev;
+
+	return master;
+}
+
+static int drm_set_master(struct drm_device *dev, struct drm_file *fpriv,
+			  bool new_master)
+{
+	int ret = 0;
+
+	dev->master = drm_master_get(fpriv->master);
+	if (dev->driver->master_set) {
+		ret = dev->driver->master_set(dev, fpriv, new_master);
+		if (unlikely(ret != 0)) {
+			drm_master_put(&dev->master);
+		}
+	}
+
+	return ret;
+}
+
+static int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv)
+{
+	struct drm_master *old_master;
+	int ret;
+
+	lockdep_assert_held_once(&dev->master_mutex);
+
+	old_master = fpriv->master;
+	fpriv->master = drm_master_create(dev);
+	if (!fpriv->master) {
+		fpriv->master = old_master;
+		return -ENOMEM;
+	}
+
+	if (dev->driver->master_create) {
+		ret = dev->driver->master_create(dev, fpriv->master);
+		if (ret)
+			goto out_err;
+	}
+	fpriv->is_master = 1;
+	fpriv->authenticated = 1;
+
+	ret = drm_set_master(dev, fpriv, true);
+	if (ret)
+		goto out_err;
+
+	if (old_master)
+		drm_master_put(&old_master);
+
+	return 0;
+
+out_err:
+	/* drop references and restore old master on failure */
+	drm_master_put(&fpriv->master);
+	fpriv->master = old_master;
+
+	return ret;
+}
+
+int drm_setmaster_ioctl(struct drm_device *dev, void *data,
+			struct drm_file *file_priv)
+{
+	int ret = 0;
+
+	mutex_lock(&dev->master_mutex);
+	if (drm_is_current_master(file_priv))
+		goto out_unlock;
+
+	if (dev->master) {
+		ret = -EINVAL;
+		goto out_unlock;
+	}
+
+	if (!file_priv->master) {
+		ret = -EINVAL;
+		goto out_unlock;
+	}
+
+	if (!file_priv->is_master) {
+		ret = drm_new_set_master(dev, file_priv);
+		goto out_unlock;
+	}
+
+	ret = drm_set_master(dev, file_priv, false);
+out_unlock:
+	mutex_unlock(&dev->master_mutex);
+	return ret;
+}
+
+static void drm_drop_master(struct drm_device *dev,
+			    struct drm_file *fpriv)
+{
+	if (dev->driver->master_drop)
+		dev->driver->master_drop(dev, fpriv);
+	drm_master_put(&dev->master);
+}
+
+int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
+			 struct drm_file *file_priv)
+{
+	int ret = -EINVAL;
+
+	mutex_lock(&dev->master_mutex);
+	if (!drm_is_current_master(file_priv))
+		goto out_unlock;
+
+	if (!dev->master)
+		goto out_unlock;
+
+	ret = 0;
+	drm_drop_master(dev, file_priv);
+out_unlock:
+	mutex_unlock(&dev->master_mutex);
+	return ret;
+}
+
+int drm_master_open(struct drm_file *file_priv)
+{
+	struct drm_device *dev = file_priv->minor->dev;
+	int ret = 0;
+
+	/* if there is no current master make this fd it, but do not create
+	 * any master object for render clients */
+	mutex_lock(&dev->master_mutex);
+	if (!dev->master)
+		ret = drm_new_set_master(dev, file_priv);
+	else
+		file_priv->master = drm_master_get(dev->master);
+	mutex_unlock(&dev->master_mutex);
+
+	return ret;
+}
+
+void drm_master_release(struct drm_file *file_priv)
+{
+	struct drm_device *dev = file_priv->minor->dev;
+	struct drm_master *master = file_priv->master;
+
+	mutex_lock(&dev->master_mutex);
+	if (file_priv->magic)
+		idr_remove(&file_priv->master->magic_map, file_priv->magic);
+
+	if (!drm_is_current_master(file_priv))
+		goto out;
+
+	if (drm_core_check_feature(dev, DRIVER_LEGACY)) {
+		/*
+		 * Since the master is disappearing, so is the
+		 * possibility to lock.
+		 */
+		mutex_lock(&dev->struct_mutex);
+		if (master->lock.hw_lock) {
+			if (dev->sigdata.lock == master->lock.hw_lock)
+				dev->sigdata.lock = NULL;
+			master->lock.hw_lock = NULL;
+			master->lock.file_priv = NULL;
+			wake_up_interruptible_all(&master->lock.lock_queue);
+		}
+		mutex_unlock(&dev->struct_mutex);
+	}
+
+	if (dev->master == file_priv->master)
+		drm_drop_master(dev, file_priv);
+out:
+	/* drop the master reference held by the file priv */
+	if (file_priv->master)
+		drm_master_put(&file_priv->master);
+	mutex_unlock(&dev->master_mutex);
+}
+
+/**
+ * drm_is_current_master - checks whether @priv is the current master
+ * @fpriv: DRM file private
+ *
+ * Checks whether @fpriv is current master on its device. This decides whether a
+ * client is allowed to run DRM_MASTER IOCTLs.
+ *
+ * Most of the modern IOCTL which require DRM_MASTER are for kernel modesetting
+ * - the current master is assumed to own the non-shareable display hardware.
+ */
+bool drm_is_current_master(struct drm_file *fpriv)
+{
+	return fpriv->is_master && fpriv->master == fpriv->minor->dev->master;
+}
+EXPORT_SYMBOL(drm_is_current_master);
+
+/**
+ * drm_master_get - reference a master pointer
+ * @master: &struct drm_master
+ *
+ * Increments the reference count of @master and returns a pointer to @master.
+ */
+struct drm_master *drm_master_get(struct drm_master *master)
+{
+	kref_get(&master->refcount);
+	return master;
+}
+EXPORT_SYMBOL(drm_master_get);
+
+static void drm_master_destroy(struct kref *kref)
+{
+	struct drm_master *master = container_of(kref, struct drm_master, refcount);
+	struct drm_device *dev = master->dev;
+
+	if (dev->driver->master_destroy)
+		dev->driver->master_destroy(dev, master);
+
+	drm_legacy_master_rmmaps(dev, master);
+
+	idr_destroy(&master->magic_map);
+	kfree(master->unique);
+	kfree(master);
+}
+
+/**
+ * drm_master_put - unreference and clear a master pointer
+ * @master: pointer to a pointer of &struct drm_master
+ *
+ * This decrements the &drm_master behind @master and sets it to NULL.
+ */
+void drm_master_put(struct drm_master **master)
+{
+	kref_put(&(*master)->refcount, drm_master_destroy);
+	*master = NULL;
+}
+EXPORT_SYMBOL(drm_master_put);
diff --git a/src/add-ons/kernel/drivers/graphics/3dfx/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/3dfx/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/3dfx/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/3dfx/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/3dfx/driver.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/3dfx/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/legacy/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/Jamfile
new file mode 100644
index 0000000000..057cf7cea2
--- /dev/null
+++ b/src/add-ons/kernel/drivers/graphics/legacy/Jamfile
@@ -0,0 +1,19 @@
+SubDir HAIKU_TOP src add-ons kernel drivers graphics legacy ;
+
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy 3dfx ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy ati ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy common ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy et6x00 ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy framebuffer ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy intel_810 ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy intel_extreme ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy matrox ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy neomagic ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy nvidia ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy nvidia_gpgpu ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy radeon ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy radeon_hd ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy s3 ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy skeleton ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy vesa ;
+SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy via ;
diff --git a/src/add-ons/kernel/drivers/graphics/ati/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/ati/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/ati/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/ati/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/ati/driver.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/ati/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/common/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/common/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/common/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/common/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/common/memory_manager.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/common/memory_manager.c
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/et6x00/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/et6x00/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/acl.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/et6x00/acl.c
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/acl.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/et6x00/acl.h
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/bits.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/et6x00/bits.c
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/bits.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/et6x00/bits.h
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/driver.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/et6x00/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/license b/src/add-ons/kernel/drivers/graphics/legacy/et6x00/license
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/license
rename to src/add-ons/kernel/drivers/graphics/legacy/et6x00/license
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/readme b/src/add-ons/kernel/drivers/graphics/legacy/et6x00/readme
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/et6x00/readme
rename to src/add-ons/kernel/drivers/graphics/legacy/et6x00/readme
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/setmode.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/et6x00/setmode.c
diff --git a/src/add-ons/kernel/drivers/graphics/et6x00/setmode.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/et6x00/setmode.h
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/framebuffer/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/framebuffer/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/framebuffer/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/device.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/framebuffer/device.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/device.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/framebuffer/device.h
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/driver.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/framebuffer/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/driver.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/framebuffer/driver.h
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/framebuffer/framebuffer.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer_private.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/framebuffer/framebuffer_private.h
diff --git a/src/add-ons/kernel/drivers/graphics/intel_810/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/intel_810/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/intel_810/driver.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/intel_810/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/intel_extreme/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/bios.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/intel_extreme/bios.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/device.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/intel_extreme/device.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/device.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/intel_extreme/device.h
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/intel_extreme/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/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/legacy/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/legacy/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/legacy/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/legacy/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/legacy/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/legacy/intel_extreme/power.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/power.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/intel_extreme/power.h
diff --git a/src/add-ons/kernel/drivers/graphics/matrox/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/matrox/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/matrox/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/matrox/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/matrox/README.html b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/matrox/README.html
diff --git a/src/add-ons/kernel/drivers/graphics/matrox/UPDATE.html b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/matrox/UPDATE.html
diff --git a/src/add-ons/kernel/drivers/graphics/matrox/driver.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/matrox/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/matrox/matrox.settings b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/matrox/matrox.settings
diff --git a/src/add-ons/kernel/drivers/graphics/neomagic/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/neomagic/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/neomagic/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/neomagic/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/neomagic/README.html b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/neomagic/README.html
diff --git a/src/add-ons/kernel/drivers/graphics/neomagic/UPDATE.html b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/neomagic/UPDATE.html
diff --git a/src/add-ons/kernel/drivers/graphics/neomagic/driver.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/neomagic/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/neomagic/neomagic.settings b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/neomagic/neomagic.settings
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/nvidia/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/nvidia/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/nvidia/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/README.html b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/nvidia/README.html
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/UPDATE.html b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/nvidia/UPDATE.html
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/driver.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/nvidia/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/nvidia.settings b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/nvidia/nvidia.settings
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/nvidia_gpgpu/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/README.html b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/nvidia_gpgpu/README.html
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/UPDATE.html b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/nvidia_gpgpu/UPDATE.html
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/driver.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/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/legacy/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/legacy/nvidia_gpgpu/nvidia_gpgpu.settings
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/CPMicroCode.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/CPMicroCode.h
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/CP_setup.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/CP_setup.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/DMA.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/DMA.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/radeon/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/radeon/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/radeon/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/PCI_GART.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/PCI_GART.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/agp.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/agp.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/bios.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/bios.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/detect.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/detect.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/driver.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/global_data.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/global_data.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/init.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/init.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/irq.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/irq.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/mem_controller.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/mem_controller.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/pll_access.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/pll_access.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/radeon_driver.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/radeon_driver.h
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/utils.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/utils.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon/vip.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon/vip.c
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon_hd/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/device.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon_hd/device.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/device.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon_hd/device.h
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/driver.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon_hd/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/driver.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/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/legacy/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/legacy/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/legacy/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/legacy/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/legacy/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/legacy/radeon_hd/sensors.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/sensors.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/radeon_hd/sensors.h
diff --git a/src/add-ons/kernel/drivers/graphics/s3/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/s3/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/s3/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/s3/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/s3/driver.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/s3/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/skeleton/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/skeleton/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/skeleton/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/skeleton/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/skeleton/README.html b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/skeleton/README.html
diff --git a/src/add-ons/kernel/drivers/graphics/skeleton/UPDATE.html b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/skeleton/UPDATE.html
diff --git a/src/add-ons/kernel/drivers/graphics/skeleton/driver.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/skeleton/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/skeleton/skel.settings b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/skeleton/skel.settings
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/vesa/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/vesa/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/vesa/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/device.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/vesa/device.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/device.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/vesa/device.h
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/driver.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/vesa/driver.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/driver.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/vesa/driver.h
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/vesa.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/vesa/vesa.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/vesa_private.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/vesa/vesa_private.h
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/vga.cpp b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/vesa/vga.cpp
diff --git a/src/add-ons/kernel/drivers/graphics/vesa/vga.h b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/vesa/vga.h
diff --git a/src/add-ons/kernel/drivers/graphics/via/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/via/Jamfile
similarity index 100%
rename from src/add-ons/kernel/drivers/graphics/via/Jamfile
rename to src/add-ons/kernel/drivers/graphics/legacy/via/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/via/README.html b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/via/README.html
diff --git a/src/add-ons/kernel/drivers/graphics/via/UPDATE.html b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/via/UPDATE.html
diff --git a/src/add-ons/kernel/drivers/graphics/via/driver.c b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/via/driver.c
diff --git a/src/add-ons/kernel/drivers/graphics/via/via.settings b/src/add-ons/kernel/drivers/graphics/legacy/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/legacy/via/via.settings
