aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include/linux/page.h
diff options
context:
space:
mode:
authorVladimir Kondratyev <wulf@FreeBSD.org>2021-09-29 20:15:37 +0000
committerVladimir Kondratyev <wulf@FreeBSD.org>2021-09-29 20:15:37 +0000
commitc072f6e856bc0348bf6fdd468761041948823f73 (patch)
treef307ff5b896b0c92a41b4aa16fb2995dfb604fa6 /sys/compat/linuxkpi/common/include/linux/page.h
parent88531adbfbe25c6ae56cc7bbe76c825a3f5dc504 (diff)
Diffstat (limited to 'sys/compat/linuxkpi/common/include/linux/page.h')
-rw-r--r--sys/compat/linuxkpi/common/include/linux/page.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/page.h b/sys/compat/linuxkpi/common/include/linux/page.h
index c2dbab769c2a..ca7365419e22 100644
--- a/sys/compat/linuxkpi/common/include/linux/page.h
+++ b/sys/compat/linuxkpi/common/include/linux/page.h
@@ -41,6 +41,10 @@
#include <vm/vm_page.h>
#include <vm/pmap.h>
+#if defined(__i386__) || defined(__amd64__)
+#include <machine/md_var.h>
+#endif
+
typedef unsigned long linux_pte_t;
typedef unsigned long linux_pmd_t;
typedef unsigned long linux_pgd_t;
@@ -53,6 +57,8 @@ typedef unsigned long pgprot_t;
CTASSERT((VM_PROT_ALL & -LINUXKPI_PROT_VALID) == 0);
+#define PAGE_KERNEL_IO 0x0000
+
static inline pgprot_t
cachemode2protval(vm_memattr_t attr)
{
@@ -72,6 +78,7 @@ pgprot2cachemode(pgprot_t prot)
#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 page_to_phys(page) VM_PAGE_TO_PHYS(page)
#define clear_page(page) memset(page, 0, PAGE_SIZE)
#define pgprot_noncached(prot) \
@@ -93,4 +100,19 @@ pgprot2cachemode(pgprot_t prot)
#undef trunc_page
#define trunc_page(x) ((uintptr_t)(x) & ~(PAGE_SIZE - 1))
+#if defined(__i386__) || defined(__amd64__)
+#undef clflushopt
+static inline void
+lkpi_clflushopt(unsigned long addr)
+{
+ if (cpu_stdext_feature & CPUID_STDEXT_CLFLUSHOPT)
+ clflushopt(addr);
+ else if (cpu_feature & CPUID_CLFSH)
+ clflush(addr);
+ else
+ pmap_invalidate_cache();
+}
+#define clflushopt(x) lkpi_clflushopt((unsigned long)(x))
+#endif
+
#endif /* _LINUX_PAGE_H_ */