blob: ab84bf131fe135a2070c4a22bc5c177020787759 [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
14#ifndef __ASSEMBLY__
15
16#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
17#define free_user_page(page, addr) free_page(addr)
18
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053019#define clear_page(paddr) memset((paddr), 0, PAGE_SIZE)
20#define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
21
Vineet Gupta4102b532013-05-09 21:54:51 +053022struct vm_area_struct;
23struct page;
24
25#define __HAVE_ARCH_COPY_USER_HIGHPAGE
26
27void copy_user_highpage(struct page *to, struct page *from,
28 unsigned long u_vaddr, struct vm_area_struct *vma);
29void clear_user_page(void *to, unsigned long u_vaddr, struct page *page);
30
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053031#undef STRICT_MM_TYPECHECKS
32
33#ifdef STRICT_MM_TYPECHECKS
34/*
35 * These are used to make use of C type-checking..
36 */
37typedef struct {
38 unsigned long pte;
39} pte_t;
40typedef struct {
41 unsigned long pgd;
42} pgd_t;
43typedef struct {
44 unsigned long pgprot;
45} pgprot_t;
46typedef unsigned long pgtable_t;
47
48#define pte_val(x) ((x).pte)
49#define pgd_val(x) ((x).pgd)
50#define pgprot_val(x) ((x).pgprot)
51
52#define __pte(x) ((pte_t) { (x) })
53#define __pgd(x) ((pgd_t) { (x) })
54#define __pgprot(x) ((pgprot_t) { (x) })
55
Gilad Ben-Yossef43689022013-01-22 16:48:45 +053056#define pte_pgprot(x) __pgprot(pte_val(x))
57
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053058#else /* !STRICT_MM_TYPECHECKS */
59
60typedef unsigned long pte_t;
61typedef unsigned long pgd_t;
62typedef unsigned long pgprot_t;
63typedef unsigned long pgtable_t;
64
65#define pte_val(x) (x)
66#define pgd_val(x) (x)
67#define pgprot_val(x) (x)
68#define __pte(x) (x)
69#define __pgprot(x) (x)
Gilad Ben-Yossef43689022013-01-22 16:48:45 +053070#define pte_pgprot(x) (x)
Vineet Gupta5dda4dc2013-01-18 15:12:19 +053071
72#endif
73
74#define ARCH_PFN_OFFSET (CONFIG_LINUX_LINK_BASE >> PAGE_SHIFT)
75
76#define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
77
78/*
79 * __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
80 *
81 * These macros have historically been misnamed
82 * virt here means link-address/program-address as embedded in object code.
83 * So if kernel img is linked at 0x8000_0000 onwards, 0x8010_0000 will be
84 * 128th page, and virt_to_page( ) will return the struct page corresp to it.
85 * mem_map[ ] is an array of struct page for each page frame in the system
86 *
87 * Independent of where linux is linked at, link-addr = physical address
88 * So the old macro __pa = vaddr + PAGE_OFFSET - CONFIG_LINUX_LINK_BASE
89 * would have been wrong in case kernel is not at 0x8zs
90 */
91#define __pa(vaddr) ((unsigned long)vaddr)
92#define __va(paddr) ((void *)((unsigned long)(paddr)))
93
94#define virt_to_page(kaddr) \
95 (mem_map + ((__pa(kaddr) - CONFIG_LINUX_LINK_BASE) >> PAGE_SHIFT))
96
97#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
98
99/* Default Permissions for page, used in mmap.c */
100#ifdef CONFIG_ARC_STACK_NONEXEC
101#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE)
102#else
103#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
104 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
105#endif
106
107#define WANT_PAGE_VIRTUAL 1
108
109#include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */
110#include <asm-generic/getorder.h>
111
Vineet Gupta3be80aa2013-01-18 15:12:17 +0530112#endif /* !__ASSEMBLY__ */
113
Vineet Gupta3be80aa2013-01-18 15:12:17 +0530114#endif