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