Merge tag 'f2fs-for-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeu...
[linux.git] / arch / hexagon / include / asm / page.h
blob137ba7c5de4811638ced0fb1acdcc72badc75412
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Page management definitions for the Hexagon architecture
5 * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
6 */
8 #ifndef _ASM_PAGE_H
9 #define _ASM_PAGE_H
11 #include <linux/const.h>
13 /* This is probably not the most graceful way to handle this. */
15 #ifdef CONFIG_PAGE_SIZE_4KB
16 #define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_4KB
17 #endif
19 #ifdef CONFIG_PAGE_SIZE_16KB
20 #define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_16KB
21 #endif
23 #ifdef CONFIG_PAGE_SIZE_64KB
24 #define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_64KB
25 #endif
27 #ifdef CONFIG_PAGE_SIZE_256KB
28 #define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_256KB
29 #endif
31 #ifdef CONFIG_PAGE_SIZE_1MB
32 #define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_1MB
33 #endif
36 * These should be defined in hugetlb.h, but apparently not.
37 * "Huge" for us should be 4MB or 16MB, which are both represented
38 * in L1 PTE's. Right now, it's set up for 4MB.
40 #ifdef CONFIG_HUGETLB_PAGE
41 #define HPAGE_SHIFT 22
42 #define HPAGE_SIZE (1UL << HPAGE_SHIFT)
43 #define HPAGE_MASK (~(HPAGE_SIZE-1))
44 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
45 #define HVM_HUGEPAGE_SIZE 0x5
46 #endif
48 #include <vdso/page.h>
50 #ifdef __KERNEL__
51 #ifndef __ASSEMBLY__
54 * This is for PFN_DOWN, which mm.h needs. Seems the right place to pull it in.
56 #include <linux/pfn.h>
59 * We implement a two-level architecture-specific page table structure.
60 * Null intermediate page table level (pmd, pud) definitions will come from
61 * asm-generic/pagetable-nopmd.h and asm-generic/pagetable-nopud.h
63 typedef struct { unsigned long pte; } pte_t;
64 typedef struct { unsigned long pgd; } pgd_t;
65 typedef struct { unsigned long pgprot; } pgprot_t;
66 typedef struct page *pgtable_t;
68 #define pte_val(x) ((x).pte)
69 #define pgd_val(x) ((x).pgd)
70 #define pgprot_val(x) ((x).pgprot)
71 #define __pte(x) ((pte_t) { (x) })
72 #define __pgd(x) ((pgd_t) { (x) })
73 #define __pgprot(x) ((pgprot_t) { (x) })
75 /* Needed for PAGE_OFFSET used in the macro right below */
76 #include <asm/mem-layout.h>
79 * We need a __pa and a __va routine for kernel space.
80 * MIPS says they're only used during mem_init.
81 * also, check if we need a PHYS_OFFSET.
83 #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET)
84 #define __va(x) ((void *)((unsigned long)(x) - PHYS_OFFSET + PAGE_OFFSET))
86 /* The "page frame" descriptor is defined in linux/mm.h */
87 struct page;
89 /* Returns page frame descriptor for virtual address. */
90 #define virt_to_page(kaddr) pfn_to_page(PFN_DOWN(__pa(kaddr)))
92 /* Default vm area behavior is non-executable. */
93 #define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
95 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
97 /* Need to not use a define for linesize; may move this to another file. */
98 static inline void clear_page(void *page)
100 /* This can only be done on pages with L1 WB cache */
101 asm volatile(
102 " loop0(1f,%1);\n"
103 "1: { dczeroa(%0);\n"
104 " %0 = add(%0,#32); }:endloop0\n"
105 : "+r" (page)
106 : "r" (PAGE_SIZE/32)
107 : "lc0", "sa0", "memory"
111 #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
114 * Under assumption that kernel always "sees" user map...
116 #define clear_user_page(page, vaddr, pg) clear_page(page)
117 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
119 static inline unsigned long virt_to_pfn(const void *kaddr)
121 return __pa(kaddr) >> PAGE_SHIFT;
124 #define page_to_virt(page) __va(page_to_phys(page))
126 #include <asm/mem-layout.h>
127 #include <asm-generic/memory_model.h>
128 /* XXX Todo: implement assembly-optimized version of getorder. */
129 #include <asm-generic/getorder.h>
131 #endif /* ifdef __ASSEMBLY__ */
132 #endif /* ifdef __KERNEL__ */
134 #endif