^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #ifndef __ASM_ARC_PAGE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define __ASM_ARC_PAGE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <uapi/asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifdef CONFIG_ARC_HAS_PAE40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define MAX_POSSIBLE_PHYSMEM_BITS 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define PAGE_MASK_PHYS (0xff00000000ull | PAGE_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #else /* CONFIG_ARC_HAS_PAE40 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define MAX_POSSIBLE_PHYSMEM_BITS 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define PAGE_MASK_PHYS PAGE_MASK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #endif /* CONFIG_ARC_HAS_PAE40 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define clear_page(paddr) memset((paddr), 0, PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct vm_area_struct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define __HAVE_ARCH_COPY_USER_HIGHPAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) void copy_user_highpage(struct page *to, struct page *from,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) unsigned long u_vaddr, struct vm_area_struct *vma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) void clear_user_page(void *to, unsigned long u_vaddr, struct page *page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #undef STRICT_MM_TYPECHECKS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #ifdef STRICT_MM_TYPECHECKS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * These are used to make use of C type-checking..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #ifdef CONFIG_ARC_HAS_PAE40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) unsigned long long pte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) unsigned long pte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) } pte_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) unsigned long pgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) } pgd_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) unsigned long pgprot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) } pgprot_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define pte_val(x) ((x).pte)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define pgd_val(x) ((x).pgd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define pgprot_val(x) ((x).pgprot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define __pte(x) ((pte_t) { (x) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define __pgd(x) ((pgd_t) { (x) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define __pgprot(x) ((pgprot_t) { (x) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define pte_pgprot(x) __pgprot(pte_val(x))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #else /* !STRICT_MM_TYPECHECKS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #ifdef CONFIG_ARC_HAS_PAE40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) typedef unsigned long long pte_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) typedef unsigned long pte_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) typedef unsigned long pgd_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) typedef unsigned long pgprot_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #define pte_val(x) (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define pgd_val(x) (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define pgprot_val(x) (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define __pte(x) (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #define __pgd(x) (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define __pgprot(x) (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define pte_pgprot(x) (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) typedef pte_t * pgtable_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * Use virt_to_pfn with caution:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * If used in pte or paddr related macros, it could cause truncation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * in PAE40 builds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * As a rule of thumb, only use it in helpers starting with virt_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * You have been warned !
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_RAM_BASE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #ifdef CONFIG_FLATMEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * These macros have historically been misnamed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * virt here means link-address/program-address as embedded in object code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * And for ARC, link-addr = physical address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define __pa(vaddr) ((unsigned long)(vaddr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #define __va(paddr) ((void *)((unsigned long)(paddr)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /* Default Permissions for stack/heaps pages (Non Executable) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define WANT_PAGE_VIRTUAL 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #include <asm-generic/getorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #endif /* !__ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #endif