18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _MCF_PGTABLE_H 38c2ecf20Sopenharmony_ci#define _MCF_PGTABLE_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <asm/mcfmmu.h> 68c2ecf20Sopenharmony_ci#include <asm/page.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci/* 98c2ecf20Sopenharmony_ci * MMUDR bits, in proper place. We write these directly into the MMUDR 108c2ecf20Sopenharmony_ci * after masking from the pte. 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci#define CF_PAGE_LOCKED MMUDR_LK /* 0x00000002 */ 138c2ecf20Sopenharmony_ci#define CF_PAGE_EXEC MMUDR_X /* 0x00000004 */ 148c2ecf20Sopenharmony_ci#define CF_PAGE_WRITABLE MMUDR_W /* 0x00000008 */ 158c2ecf20Sopenharmony_ci#define CF_PAGE_READABLE MMUDR_R /* 0x00000010 */ 168c2ecf20Sopenharmony_ci#define CF_PAGE_SYSTEM MMUDR_SP /* 0x00000020 */ 178c2ecf20Sopenharmony_ci#define CF_PAGE_COPYBACK MMUDR_CM_CCB /* 0x00000040 */ 188c2ecf20Sopenharmony_ci#define CF_PAGE_NOCACHE MMUDR_CM_NCP /* 0x00000080 */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define CF_CACHEMASK (~MMUDR_CM_CCB) 218c2ecf20Sopenharmony_ci#define CF_PAGE_MMUDR_MASK 0x000000fe 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define _PAGE_NOCACHE030 CF_PAGE_NOCACHE 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* 268c2ecf20Sopenharmony_ci * MMUTR bits, need shifting down. 278c2ecf20Sopenharmony_ci */ 288c2ecf20Sopenharmony_ci#define CF_PAGE_MMUTR_MASK 0x00000c00 298c2ecf20Sopenharmony_ci#define CF_PAGE_MMUTR_SHIFT 10 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define CF_PAGE_VALID (MMUTR_V << CF_PAGE_MMUTR_SHIFT) 328c2ecf20Sopenharmony_ci#define CF_PAGE_SHARED (MMUTR_SG << CF_PAGE_MMUTR_SHIFT) 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* 358c2ecf20Sopenharmony_ci * Fake bits, not implemented in CF, will get masked out before 368c2ecf20Sopenharmony_ci * hitting hardware. 378c2ecf20Sopenharmony_ci */ 388c2ecf20Sopenharmony_ci#define CF_PAGE_DIRTY 0x00000001 398c2ecf20Sopenharmony_ci#define CF_PAGE_ACCESSED 0x00001000 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define _PAGE_CACHE040 0x020 /* 68040 cache mode, cachable, copyback */ 428c2ecf20Sopenharmony_ci#define _PAGE_NOCACHE_S 0x040 /* 68040 no-cache mode, serialized */ 438c2ecf20Sopenharmony_ci#define _PAGE_NOCACHE 0x060 /* 68040 cache mode, non-serialized */ 448c2ecf20Sopenharmony_ci#define _PAGE_CACHE040W 0x000 /* 68040 cache mode, cachable, write-through */ 458c2ecf20Sopenharmony_ci#define _DESCTYPE_MASK 0x003 468c2ecf20Sopenharmony_ci#define _CACHEMASK040 (~0x060) 478c2ecf20Sopenharmony_ci#define _PAGE_GLOBAL040 0x400 /* 68040 global bit, used for kva descs */ 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/* 508c2ecf20Sopenharmony_ci * Externally used page protection values. 518c2ecf20Sopenharmony_ci */ 528c2ecf20Sopenharmony_ci#define _PAGE_PRESENT (CF_PAGE_VALID) 538c2ecf20Sopenharmony_ci#define _PAGE_ACCESSED (CF_PAGE_ACCESSED) 548c2ecf20Sopenharmony_ci#define _PAGE_DIRTY (CF_PAGE_DIRTY) 558c2ecf20Sopenharmony_ci#define _PAGE_READWRITE (CF_PAGE_READABLE \ 568c2ecf20Sopenharmony_ci | CF_PAGE_WRITABLE \ 578c2ecf20Sopenharmony_ci | CF_PAGE_SYSTEM \ 588c2ecf20Sopenharmony_ci | CF_PAGE_SHARED) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/* 618c2ecf20Sopenharmony_ci * Compound page protection values. 628c2ecf20Sopenharmony_ci */ 638c2ecf20Sopenharmony_ci#define PAGE_NONE __pgprot(CF_PAGE_VALID \ 648c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED) 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#define PAGE_SHARED __pgprot(CF_PAGE_VALID \ 678c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 688c2ecf20Sopenharmony_ci | CF_PAGE_SHARED) 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define PAGE_INIT __pgprot(CF_PAGE_VALID \ 718c2ecf20Sopenharmony_ci | CF_PAGE_READABLE \ 728c2ecf20Sopenharmony_ci | CF_PAGE_WRITABLE \ 738c2ecf20Sopenharmony_ci | CF_PAGE_EXEC \ 748c2ecf20Sopenharmony_ci | CF_PAGE_SYSTEM) 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci#define PAGE_KERNEL __pgprot(CF_PAGE_VALID \ 778c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 788c2ecf20Sopenharmony_ci | CF_PAGE_READABLE \ 798c2ecf20Sopenharmony_ci | CF_PAGE_WRITABLE \ 808c2ecf20Sopenharmony_ci | CF_PAGE_EXEC \ 818c2ecf20Sopenharmony_ci | CF_PAGE_SYSTEM \ 828c2ecf20Sopenharmony_ci | CF_PAGE_SHARED) 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define PAGE_COPY __pgprot(CF_PAGE_VALID \ 858c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 868c2ecf20Sopenharmony_ci | CF_PAGE_READABLE \ 878c2ecf20Sopenharmony_ci | CF_PAGE_DIRTY) 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/* 908c2ecf20Sopenharmony_ci * Page protections for initialising protection_map. See mm/mmap.c 918c2ecf20Sopenharmony_ci * for use. In general, the bit positions are xwr, and P-items are 928c2ecf20Sopenharmony_ci * private, the S-items are shared. 938c2ecf20Sopenharmony_ci */ 948c2ecf20Sopenharmony_ci#define __P000 PAGE_NONE 958c2ecf20Sopenharmony_ci#define __P001 __pgprot(CF_PAGE_VALID \ 968c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 978c2ecf20Sopenharmony_ci | CF_PAGE_READABLE) 988c2ecf20Sopenharmony_ci#define __P010 __pgprot(CF_PAGE_VALID \ 998c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 1008c2ecf20Sopenharmony_ci | CF_PAGE_WRITABLE) 1018c2ecf20Sopenharmony_ci#define __P011 __pgprot(CF_PAGE_VALID \ 1028c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 1038c2ecf20Sopenharmony_ci | CF_PAGE_READABLE \ 1048c2ecf20Sopenharmony_ci | CF_PAGE_WRITABLE) 1058c2ecf20Sopenharmony_ci#define __P100 __pgprot(CF_PAGE_VALID \ 1068c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 1078c2ecf20Sopenharmony_ci | CF_PAGE_EXEC) 1088c2ecf20Sopenharmony_ci#define __P101 __pgprot(CF_PAGE_VALID \ 1098c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 1108c2ecf20Sopenharmony_ci | CF_PAGE_READABLE \ 1118c2ecf20Sopenharmony_ci | CF_PAGE_EXEC) 1128c2ecf20Sopenharmony_ci#define __P110 __pgprot(CF_PAGE_VALID \ 1138c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 1148c2ecf20Sopenharmony_ci | CF_PAGE_WRITABLE \ 1158c2ecf20Sopenharmony_ci | CF_PAGE_EXEC) 1168c2ecf20Sopenharmony_ci#define __P111 __pgprot(CF_PAGE_VALID \ 1178c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 1188c2ecf20Sopenharmony_ci | CF_PAGE_READABLE \ 1198c2ecf20Sopenharmony_ci | CF_PAGE_WRITABLE \ 1208c2ecf20Sopenharmony_ci | CF_PAGE_EXEC) 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci#define __S000 PAGE_NONE 1238c2ecf20Sopenharmony_ci#define __S001 __pgprot(CF_PAGE_VALID \ 1248c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 1258c2ecf20Sopenharmony_ci | CF_PAGE_READABLE) 1268c2ecf20Sopenharmony_ci#define __S010 PAGE_SHARED 1278c2ecf20Sopenharmony_ci#define __S011 __pgprot(CF_PAGE_VALID \ 1288c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 1298c2ecf20Sopenharmony_ci | CF_PAGE_SHARED \ 1308c2ecf20Sopenharmony_ci | CF_PAGE_READABLE) 1318c2ecf20Sopenharmony_ci#define __S100 __pgprot(CF_PAGE_VALID \ 1328c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 1338c2ecf20Sopenharmony_ci | CF_PAGE_EXEC) 1348c2ecf20Sopenharmony_ci#define __S101 __pgprot(CF_PAGE_VALID \ 1358c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 1368c2ecf20Sopenharmony_ci | CF_PAGE_READABLE \ 1378c2ecf20Sopenharmony_ci | CF_PAGE_EXEC) 1388c2ecf20Sopenharmony_ci#define __S110 __pgprot(CF_PAGE_VALID \ 1398c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 1408c2ecf20Sopenharmony_ci | CF_PAGE_SHARED \ 1418c2ecf20Sopenharmony_ci | CF_PAGE_EXEC) 1428c2ecf20Sopenharmony_ci#define __S111 __pgprot(CF_PAGE_VALID \ 1438c2ecf20Sopenharmony_ci | CF_PAGE_ACCESSED \ 1448c2ecf20Sopenharmony_ci | CF_PAGE_SHARED \ 1458c2ecf20Sopenharmony_ci | CF_PAGE_READABLE \ 1468c2ecf20Sopenharmony_ci | CF_PAGE_EXEC) 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci#define PTE_MASK PAGE_MASK 1498c2ecf20Sopenharmony_ci#define CF_PAGE_CHG_MASK (PTE_MASK | CF_PAGE_ACCESSED | CF_PAGE_DIRTY) 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci/* 1548c2ecf20Sopenharmony_ci * Conversion functions: convert a page and protection to a page entry, 1558c2ecf20Sopenharmony_ci * and a page entry and page directory to the page they refer to. 1568c2ecf20Sopenharmony_ci */ 1578c2ecf20Sopenharmony_ci#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_cistatic inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 1608c2ecf20Sopenharmony_ci{ 1618c2ecf20Sopenharmony_ci pte_val(pte) = (pte_val(pte) & CF_PAGE_CHG_MASK) | pgprot_val(newprot); 1628c2ecf20Sopenharmony_ci return pte; 1638c2ecf20Sopenharmony_ci} 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci#define pmd_set(pmdp, ptep) do {} while (0) 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_cistatic inline void pgd_set(pgd_t *pgdp, pmd_t *pmdp) 1688c2ecf20Sopenharmony_ci{ 1698c2ecf20Sopenharmony_ci pgd_val(*pgdp) = virt_to_phys(pmdp); 1708c2ecf20Sopenharmony_ci} 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci#define __pte_page(pte) ((unsigned long) (pte_val(pte) & PAGE_MASK)) 1738c2ecf20Sopenharmony_ci#define pmd_page_vaddr(pmd) ((unsigned long) (pmd_val(pmd))) 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_cistatic inline int pte_none(pte_t pte) 1768c2ecf20Sopenharmony_ci{ 1778c2ecf20Sopenharmony_ci return !pte_val(pte); 1788c2ecf20Sopenharmony_ci} 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_cistatic inline int pte_present(pte_t pte) 1818c2ecf20Sopenharmony_ci{ 1828c2ecf20Sopenharmony_ci return pte_val(pte) & CF_PAGE_VALID; 1838c2ecf20Sopenharmony_ci} 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_cistatic inline void pte_clear(struct mm_struct *mm, unsigned long addr, 1868c2ecf20Sopenharmony_ci pte_t *ptep) 1878c2ecf20Sopenharmony_ci{ 1888c2ecf20Sopenharmony_ci pte_val(*ptep) = 0; 1898c2ecf20Sopenharmony_ci} 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci#define pte_pagenr(pte) ((__pte_page(pte) - PAGE_OFFSET) >> PAGE_SHIFT) 1928c2ecf20Sopenharmony_ci#define pte_page(pte) virt_to_page(__pte_page(pte)) 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_cistatic inline int pmd_none2(pmd_t *pmd) { return !pmd_val(*pmd); } 1958c2ecf20Sopenharmony_ci#define pmd_none(pmd) pmd_none2(&(pmd)) 1968c2ecf20Sopenharmony_cistatic inline int pmd_bad2(pmd_t *pmd) { return 0; } 1978c2ecf20Sopenharmony_ci#define pmd_bad(pmd) pmd_bad2(&(pmd)) 1988c2ecf20Sopenharmony_ci#define pmd_present(pmd) (!pmd_none2(&(pmd))) 1998c2ecf20Sopenharmony_cistatic inline void pmd_clear(pmd_t *pmdp) { pmd_val(*pmdp) = 0; } 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci#define pte_ERROR(e) \ 2028c2ecf20Sopenharmony_ci printk(KERN_ERR "%s:%d: bad pte %08lx.\n", \ 2038c2ecf20Sopenharmony_ci __FILE__, __LINE__, pte_val(e)) 2048c2ecf20Sopenharmony_ci#define pgd_ERROR(e) \ 2058c2ecf20Sopenharmony_ci printk(KERN_ERR "%s:%d: bad pgd %08lx.\n", \ 2068c2ecf20Sopenharmony_ci __FILE__, __LINE__, pgd_val(e)) 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci/* 2098c2ecf20Sopenharmony_ci * The following only work if pte_present() is true. 2108c2ecf20Sopenharmony_ci * Undefined behaviour if not... 2118c2ecf20Sopenharmony_ci * [we have the full set here even if they don't change from m68k] 2128c2ecf20Sopenharmony_ci */ 2138c2ecf20Sopenharmony_cistatic inline int pte_read(pte_t pte) 2148c2ecf20Sopenharmony_ci{ 2158c2ecf20Sopenharmony_ci return pte_val(pte) & CF_PAGE_READABLE; 2168c2ecf20Sopenharmony_ci} 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_cistatic inline int pte_write(pte_t pte) 2198c2ecf20Sopenharmony_ci{ 2208c2ecf20Sopenharmony_ci return pte_val(pte) & CF_PAGE_WRITABLE; 2218c2ecf20Sopenharmony_ci} 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_cistatic inline int pte_exec(pte_t pte) 2248c2ecf20Sopenharmony_ci{ 2258c2ecf20Sopenharmony_ci return pte_val(pte) & CF_PAGE_EXEC; 2268c2ecf20Sopenharmony_ci} 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_cistatic inline int pte_dirty(pte_t pte) 2298c2ecf20Sopenharmony_ci{ 2308c2ecf20Sopenharmony_ci return pte_val(pte) & CF_PAGE_DIRTY; 2318c2ecf20Sopenharmony_ci} 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_cistatic inline int pte_young(pte_t pte) 2348c2ecf20Sopenharmony_ci{ 2358c2ecf20Sopenharmony_ci return pte_val(pte) & CF_PAGE_ACCESSED; 2368c2ecf20Sopenharmony_ci} 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_cistatic inline pte_t pte_wrprotect(pte_t pte) 2398c2ecf20Sopenharmony_ci{ 2408c2ecf20Sopenharmony_ci pte_val(pte) &= ~CF_PAGE_WRITABLE; 2418c2ecf20Sopenharmony_ci return pte; 2428c2ecf20Sopenharmony_ci} 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_cistatic inline pte_t pte_rdprotect(pte_t pte) 2458c2ecf20Sopenharmony_ci{ 2468c2ecf20Sopenharmony_ci pte_val(pte) &= ~CF_PAGE_READABLE; 2478c2ecf20Sopenharmony_ci return pte; 2488c2ecf20Sopenharmony_ci} 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_cistatic inline pte_t pte_exprotect(pte_t pte) 2518c2ecf20Sopenharmony_ci{ 2528c2ecf20Sopenharmony_ci pte_val(pte) &= ~CF_PAGE_EXEC; 2538c2ecf20Sopenharmony_ci return pte; 2548c2ecf20Sopenharmony_ci} 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_cistatic inline pte_t pte_mkclean(pte_t pte) 2578c2ecf20Sopenharmony_ci{ 2588c2ecf20Sopenharmony_ci pte_val(pte) &= ~CF_PAGE_DIRTY; 2598c2ecf20Sopenharmony_ci return pte; 2608c2ecf20Sopenharmony_ci} 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_cistatic inline pte_t pte_mkold(pte_t pte) 2638c2ecf20Sopenharmony_ci{ 2648c2ecf20Sopenharmony_ci pte_val(pte) &= ~CF_PAGE_ACCESSED; 2658c2ecf20Sopenharmony_ci return pte; 2668c2ecf20Sopenharmony_ci} 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_cistatic inline pte_t pte_mkwrite(pte_t pte) 2698c2ecf20Sopenharmony_ci{ 2708c2ecf20Sopenharmony_ci pte_val(pte) |= CF_PAGE_WRITABLE; 2718c2ecf20Sopenharmony_ci return pte; 2728c2ecf20Sopenharmony_ci} 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_cistatic inline pte_t pte_mkread(pte_t pte) 2758c2ecf20Sopenharmony_ci{ 2768c2ecf20Sopenharmony_ci pte_val(pte) |= CF_PAGE_READABLE; 2778c2ecf20Sopenharmony_ci return pte; 2788c2ecf20Sopenharmony_ci} 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_cistatic inline pte_t pte_mkexec(pte_t pte) 2818c2ecf20Sopenharmony_ci{ 2828c2ecf20Sopenharmony_ci pte_val(pte) |= CF_PAGE_EXEC; 2838c2ecf20Sopenharmony_ci return pte; 2848c2ecf20Sopenharmony_ci} 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_cistatic inline pte_t pte_mkdirty(pte_t pte) 2878c2ecf20Sopenharmony_ci{ 2888c2ecf20Sopenharmony_ci pte_val(pte) |= CF_PAGE_DIRTY; 2898c2ecf20Sopenharmony_ci return pte; 2908c2ecf20Sopenharmony_ci} 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_cistatic inline pte_t pte_mkyoung(pte_t pte) 2938c2ecf20Sopenharmony_ci{ 2948c2ecf20Sopenharmony_ci pte_val(pte) |= CF_PAGE_ACCESSED; 2958c2ecf20Sopenharmony_ci return pte; 2968c2ecf20Sopenharmony_ci} 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_cistatic inline pte_t pte_mknocache(pte_t pte) 2998c2ecf20Sopenharmony_ci{ 3008c2ecf20Sopenharmony_ci pte_val(pte) |= 0x80 | (pte_val(pte) & ~0x40); 3018c2ecf20Sopenharmony_ci return pte; 3028c2ecf20Sopenharmony_ci} 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_cistatic inline pte_t pte_mkcache(pte_t pte) 3058c2ecf20Sopenharmony_ci{ 3068c2ecf20Sopenharmony_ci pte_val(pte) &= ~CF_PAGE_NOCACHE; 3078c2ecf20Sopenharmony_ci return pte; 3088c2ecf20Sopenharmony_ci} 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci#define swapper_pg_dir kernel_pg_dir 3118c2ecf20Sopenharmony_ciextern pgd_t kernel_pg_dir[PTRS_PER_PGD]; 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci/* 3148c2ecf20Sopenharmony_ci * Encode and de-code a swap entry (must be !pte_none(e) && !pte_present(e)) 3158c2ecf20Sopenharmony_ci */ 3168c2ecf20Sopenharmony_ci#define __swp_type(x) ((x).val & 0xFF) 3178c2ecf20Sopenharmony_ci#define __swp_offset(x) ((x).val >> 11) 3188c2ecf20Sopenharmony_ci#define __swp_entry(typ, off) ((swp_entry_t) { (typ) | \ 3198c2ecf20Sopenharmony_ci (off << 11) }) 3208c2ecf20Sopenharmony_ci#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) 3218c2ecf20Sopenharmony_ci#define __swp_entry_to_pte(x) (__pte((x).val)) 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 3268c2ecf20Sopenharmony_ci#define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 3298c2ecf20Sopenharmony_ci#endif /* _MCF_PGTABLE_H */ 330