1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) 4 * Copyright 2003 PathScale, Inc. 5 */ 6 7 #ifndef __UM_PAGE_H 8 #define __UM_PAGE_H 9 10 #include <linux/const.h> 11 12 #include <vdso/page.h> 13 14 #ifndef __ASSEMBLY__ 15 16 struct page; 17 18 #include <linux/pfn.h> 19 #include <linux/types.h> 20 #include <asm/vm-flags.h> 21 22 /* 23 * These are used to make use of C type-checking.. 24 */ 25 26 #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) 27 #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE) 28 29 #define clear_user_page(page, vaddr, pg) clear_page(page) 30 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) 31 32 typedef struct { unsigned long pte; } pte_t; 33 typedef struct { unsigned long pgd; } pgd_t; 34 35 #if CONFIG_PGTABLE_LEVELS > 2 36 37 typedef struct { unsigned long pmd; } pmd_t; 38 #define pmd_val(x) ((x).pmd) 39 #define __pmd(x) ((pmd_t) { (x) } ) 40 41 #if CONFIG_PGTABLE_LEVELS > 3 42 43 typedef struct { unsigned long pud; } pud_t; 44 #define pud_val(x) ((x).pud) 45 #define __pud(x) ((pud_t) { (x) } ) 46 47 #endif /* CONFIG_PGTABLE_LEVELS > 3 */ 48 #endif /* CONFIG_PGTABLE_LEVELS > 2 */ 49 50 #define pte_val(x) ((x).pte) 51 52 #define pte_get_bits(p, bits) ((p).pte & (bits)) 53 #define pte_set_bits(p, bits) ((p).pte |= (bits)) 54 #define pte_clear_bits(p, bits) ((p).pte &= ~(bits)) 55 #define pte_copy(to, from) ((to).pte = (from).pte) 56 #define pte_is_zero(p) (!((p).pte & ~_PAGE_NEEDSYNC)) 57 #define pte_set_val(p, phys, prot) (p).pte = (phys | pgprot_val(prot)) 58 59 typedef unsigned long phys_t; 60 61 typedef struct { unsigned long pgprot; } pgprot_t; 62 63 typedef struct page *pgtable_t; 64 65 #define pgd_val(x) ((x).pgd) 66 #define pgprot_val(x) ((x).pgprot) 67 68 #define __pte(x) ((pte_t) { (x) } ) 69 #define __pgd(x) ((pgd_t) { (x) } ) 70 #define __pgprot(x) ((pgprot_t) { (x) } ) 71 72 extern unsigned long uml_physmem; 73 74 #define PAGE_OFFSET (uml_physmem) 75 #define KERNELBASE PAGE_OFFSET 76 77 #define __va_space (8*1024*1024) 78 79 #include <mem.h> 80 81 /* Cast to unsigned long before casting to void * to avoid a warning from 82 * mmap_kmem about cutting a long long down to a void *. Not sure that 83 * casting is the right thing, but 32-bit UML can't have 64-bit virtual 84 * addresses 85 */ 86 #define __pa(virt) uml_to_phys((void *) (unsigned long) (virt)) 87 #define __va(phys) uml_to_virt((unsigned long) (phys)) 88 89 #define phys_to_pfn(p) ((p) >> PAGE_SHIFT) 90 #define pfn_to_phys(pfn) PFN_PHYS(pfn) 91 92 #define virt_addr_valid(v) pfn_valid(phys_to_pfn(__pa(v))) 93 94 #include <asm-generic/memory_model.h> 95 #include <asm-generic/getorder.h> 96 97 #endif /* __ASSEMBLY__ */ 98 99 #ifdef CONFIG_X86_32 100 #define __HAVE_ARCH_GATE_AREA 1 101 #endif 102 103 #endif /* __UM_PAGE_H */ 104