page.h 2.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#ifndef __ASM_ARC_PAGE_H
#define __ASM_ARC_PAGE_H

11
#include <uapi/asm/page.h>
12

V
Vineet Gupta 已提交
13 14 15 16 17
#ifndef __ASSEMBLY__

#define clear_page(paddr)		memset((paddr), 0, PAGE_SIZE)
#define copy_page(to, from)		memcpy((to), (from), PAGE_SIZE)

18 19 20 21 22 23 24 25 26
struct vm_area_struct;
struct page;

#define __HAVE_ARCH_COPY_USER_HIGHPAGE

void copy_user_highpage(struct page *to, struct page *from,
			unsigned long u_vaddr, struct vm_area_struct *vma);
void clear_user_page(void *to, unsigned long u_vaddr, struct page *page);

V
Vineet Gupta 已提交
27 28 29 30 31 32 33
#undef STRICT_MM_TYPECHECKS

#ifdef STRICT_MM_TYPECHECKS
/*
 * These are used to make use of C type-checking..
 */
typedef struct {
34 35 36
#ifdef CONFIG_ARC_HAS_PAE40
	unsigned long long pte;
#else
V
Vineet Gupta 已提交
37
	unsigned long pte;
38
#endif
V
Vineet Gupta 已提交
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
} pte_t;
typedef struct {
	unsigned long pgd;
} pgd_t;
typedef struct {
	unsigned long pgprot;
} pgprot_t;

#define pte_val(x)      ((x).pte)
#define pgd_val(x)      ((x).pgd)
#define pgprot_val(x)   ((x).pgprot)

#define __pte(x)        ((pte_t) { (x) })
#define __pgd(x)        ((pgd_t) { (x) })
#define __pgprot(x)     ((pgprot_t) { (x) })

55 56
#define pte_pgprot(x) __pgprot(pte_val(x))

V
Vineet Gupta 已提交
57 58
#else /* !STRICT_MM_TYPECHECKS */

V
Vineet Gupta 已提交
59 60 61
#ifdef CONFIG_ARC_HAS_PAE40
typedef unsigned long long pte_t;
#else
V
Vineet Gupta 已提交
62
typedef unsigned long pte_t;
V
Vineet Gupta 已提交
63
#endif
V
Vineet Gupta 已提交
64 65 66 67 68 69 70
typedef unsigned long pgd_t;
typedef unsigned long pgprot_t;

#define pte_val(x)	(x)
#define pgd_val(x)	(x)
#define pgprot_val(x)	(x)
#define __pte(x)	(x)
V
Vineet Gupta 已提交
71
#define __pgd(x)	(x)
V
Vineet Gupta 已提交
72
#define __pgprot(x)	(x)
73
#define pte_pgprot(x)	(x)
V
Vineet Gupta 已提交
74 75 76

#endif

77 78
typedef pte_t * pgtable_t;

79 80 81 82 83 84 85
/*
 * Use virt_to_pfn with caution:
 * If used in pte or paddr related macros, it could cause truncation
 * in PAE40 builds
 * As a rule of thumb, only use it in helpers starting with virt_
 * You have been warned !
 */
86 87
#define virt_to_pfn(kaddr)	(__pa(kaddr) >> PAGE_SHIFT)

88
#define ARCH_PFN_OFFSET		virt_to_pfn(CONFIG_LINUX_RAM_BASE)
V
Vineet Gupta 已提交
89

90
#ifdef CONFIG_FLATMEM
91
#define pfn_valid(pfn)		(((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
92
#endif
V
Vineet Gupta 已提交
93 94 95 96 97 98

/*
 * __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
 *
 * These macros have historically been misnamed
 * virt here means link-address/program-address as embedded in object code.
99
 * And for ARC, link-addr = physical address
V
Vineet Gupta 已提交
100
 */
101
#define __pa(vaddr)  ((unsigned long)(vaddr))
V
Vineet Gupta 已提交
102 103
#define __va(paddr)  ((void *)((unsigned long)(paddr)))

104
#define virt_to_page(kaddr)	pfn_to_page(virt_to_pfn(kaddr))
105
#define virt_addr_valid(kaddr)  pfn_valid(virt_to_pfn(kaddr))
V
Vineet Gupta 已提交
106

107
/* Default Permissions for stack/heaps pages (Non Executable) */
108
#define VM_DATA_DEFAULT_FLAGS   (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
V
Vineet Gupta 已提交
109 110 111 112 113 114

#define WANT_PAGE_VIRTUAL   1

#include <asm-generic/memory_model.h>   /* page_to_pfn, pfn_to_page */
#include <asm-generic/getorder.h>

115 116 117
#endif /* !__ASSEMBLY__ */

#endif