summaryrefslogtreecommitdiffstats
path: root/sys/compat/linuxkpi
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2016-05-13 12:41:21 +0000
committerhselasky <hselasky@FreeBSD.org>2016-05-13 12:41:21 +0000
commit7bf21672e6306c2a580adbc86bb158572bbd3b8a (patch)
tree41749990acb49bfcd0a32140be3a8596eb4f54d1 /sys/compat/linuxkpi
parent13b35dc5e387e73f6d5f3446f91afb7dcc52c5a0 (diff)
downloadFreeBSD-src-7bf21672e6306c2a580adbc86bb158572bbd3b8a.zip
FreeBSD-src-7bf21672e6306c2a580adbc86bb158572bbd3b8a.tar.gz
Add more PAGE related defines to the LinuxKPI. Move the definition of
"pgprot_t" to "linux/page.h" similar to what Linux does. Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies
Diffstat (limited to 'sys/compat/linuxkpi')
-rw-r--r--sys/compat/linuxkpi/common/include/asm/pgtable.h2
-rw-r--r--sys/compat/linuxkpi/common/include/linux/page.h25
2 files changed, 22 insertions, 5 deletions
diff --git a/sys/compat/linuxkpi/common/include/asm/pgtable.h b/sys/compat/linuxkpi/common/include/asm/pgtable.h
index 7bdab1c..c54eb04 100644
--- a/sys/compat/linuxkpi/common/include/asm/pgtable.h
+++ b/sys/compat/linuxkpi/common/include/asm/pgtable.h
@@ -31,6 +31,6 @@
#ifndef _ASM_PGTABLE_H_
#define _ASM_PGTABLE_H_
-typedef int pgprot_t;
+#include <linux/page.h>
#endif /* _ASM_PGTABLE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/page.h b/sys/compat/linuxkpi/common/include/linux/page.h
index acc9f03..2ad9eb6 100644
--- a/sys/compat/linuxkpi/common/include/linux/page.h
+++ b/sys/compat/linuxkpi/common/include/linux/page.h
@@ -2,7 +2,7 @@
* 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) 2013-2016 Mellanox Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,16 +38,33 @@
#include <machine/atomic.h>
#include <vm/vm.h>
#include <vm/vm_page.h>
+#include <vm/pmap.h>
+
+typedef unsigned long pgprot_t;
#define page vm_page
-#define virt_to_page(x) PHYS_TO_VM_PAGE(vtophys((x)))
+#define virt_to_page(x) PHYS_TO_VM_PAGE(vtophys((x)))
+#define page_to_pfn(pp) (VM_PAGE_TO_PHYS((pp)) >> PAGE_SHIFT)
+#define pfn_to_page(pfn) (PHYS_TO_VM_PAGE((pfn) << PAGE_SHIFT))
+#define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
#define clear_page(page) memset((page), 0, PAGE_SIZE)
-#define pgprot_noncached(prot) VM_MEMATTR_UNCACHEABLE
-#define pgprot_writecombine(prot) VM_MEMATTR_WRITE_COMBINING
+#define pgprot_noncached(prot) ((pgprot_t)VM_MEMATTR_UNCACHEABLE)
+#define pgprot_writecombine(prot) ((pgprot_t)VM_MEMATTR_WRITE_COMBINING)
#undef PAGE_MASK
#define PAGE_MASK (~(PAGE_SIZE-1))
+/*
+ * Modifying PAGE_MASK in the above way breaks trunc_page, round_page,
+ * and btoc macros. Therefore, redefine them in a way that makes sense
+ * so the LinuxKPI consumers don't get totally broken behavior.
+ */
+#undef btoc
+#define btoc(x) (((vm_offset_t)(x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
+#undef round_page
+#define round_page(x) ((((uintptr_t)(x)) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
+#undef trunc_page
+#define trunc_page(x) ((uintptr_t)(x) & ~(PAGE_SIZE - 1))
#endif /* _LINUX_PAGE_H_ */
OpenPOWER on IntegriCloud