blob: 36da89e2c853ef0551bfcee0f145454e23a81dd6 [file] [log] [blame]
Vineet Gupta3be80aa2013-01-18 15:12:17 +05301/*
2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
Vineet Gupta3be80aa2013-01-18 15:12:17 +05308#ifndef __ASM_ARC_PAGE_H
9#define __ASM_ARC_PAGE_H
10
Vineet Gupta8c2f4a82013-02-11 19:55:33 +053011#include <uapi/asm/page.h>
Vineet Gupta3be80aa2013-01-18 15:12:17 +053012
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053013#ifndef __ASSEMBLY__
14
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053015#define clear_page(paddr) memset((paddr), 0, PAGE_SIZE)
16#define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
17
Vineet Gupta4102b532013-05-09 21:54:51 +053018struct vm_area_struct;
19struct page;
20
21#define __HAVE_ARCH_COPY_USER_HIGHPAGE
22
23void copy_user_highpage(struct page *to, struct page *from,
24 unsigned long u_vaddr, struct vm_area_struct *vma);
25void clear_user_page(void *to, unsigned long u_vaddr, struct page *page);
26
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053027#undef STRICT_MM_TYPECHECKS
28
29#ifdef STRICT_MM_TYPECHECKS
30/*
31 * These are used to make use of C type-checking..
32 */
33typedef struct {
34 unsigned long pte;
35} pte_t;
36typedef struct {
37 unsigned long pgd;
38} pgd_t;
39typedef struct {
40 unsigned long pgprot;
41} pgprot_t;
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053042
43#define pte_val(x) ((x).pte)
44#define pgd_val(x) ((x).pgd)
45#define pgprot_val(x) ((x).pgprot)
46
47#define __pte(x) ((pte_t) { (x) })
48#define __pgd(x) ((pgd_t) { (x) })
49#define __pgprot(x) ((pgprot_t) { (x) })
50
Gilad Ben-Yossef43689022013-01-22 16:48:45 +053051#define pte_pgprot(x) __pgprot(pte_val(x))
52
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053053#else /* !STRICT_MM_TYPECHECKS */
54
Vineet Gupta5a364c22015-02-06 18:44:57 +030055#ifdef CONFIG_ARC_HAS_PAE40
56typedef unsigned long long pte_t;
57#else
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053058typedef unsigned long pte_t;
Vineet Gupta5a364c22015-02-06 18:44:57 +030059#endif
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053060typedef unsigned long pgd_t;
61typedef unsigned long pgprot_t;
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053062
63#define pte_val(x) (x)
64#define pgd_val(x) (x)
65#define pgprot_val(x) (x)
66#define __pte(x) (x)
Vineet Guptafe6c1b82014-07-08 18:43:47 +053067#define __pgd(x) (x)
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053068#define __pgprot(x) (x)
Gilad Ben-Yossef43689022013-01-22 16:48:45 +053069#define pte_pgprot(x) (x)
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053070
71#endif
72
Vineet Guptae8a75962015-08-28 08:39:57 +053073typedef pte_t * pgtable_t;
74
Vineet Guptac2ff5cf22015-12-18 13:57:41 +053075#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053076
Vineet Guptac2ff5cf22015-12-18 13:57:41 +053077#define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_LINK_BASE)
78
79#define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053080
81/*
82 * __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
83 *
84 * These macros have historically been misnamed
85 * virt here means link-address/program-address as embedded in object code.
Vineet Guptac2ff5cf22015-12-18 13:57:41 +053086 * And for ARC, link-addr = physical address
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053087 */
88#define __pa(vaddr) ((unsigned long)vaddr)
89#define __va(paddr) ((void *)((unsigned long)(paddr)))
90
91#define virt_to_page(kaddr) \
Vineet Guptac2ff5cf22015-12-18 13:57:41 +053092 (mem_map + virt_to_pfn((kaddr) - CONFIG_LINUX_LINK_BASE))
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053093
Vineet Guptac2ff5cf22015-12-18 13:57:41 +053094#define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr))
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053095
Vineet Gupta3abc9442013-06-05 17:49:14 +053096/* Default Permissions for stack/heaps pages (Non Executable) */
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053097#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE)
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053098
99#define WANT_PAGE_VIRTUAL 1
100
101#include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */
102#include <asm-generic/getorder.h>
103
Vineet Gupta3be80aa2013-01-18 15:12:17 +0530104#endif /* !__ASSEMBLY__ */
105
Vineet Gupta3be80aa2013-01-18 15:12:17 +0530106#endif