2 * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
3 * Copyright (C) 2004 Microtronix Datacom Ltd.
5 * MMU support based on asm/page.h from mips which is:
7 * Copyright (C) 1994 - 1999, 2000, 03 Ralf Baechle
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
15 #ifndef _ASM_NIOS2_PAGE_H
16 #define _ASM_NIOS2_PAGE_H
18 #include <linux/pfn.h>
19 #include <linux/const.h>
21 #include <vdso/page.h>
24 * PAGE_OFFSET -- the first address of the first page of memory.
27 (CONFIG_NIOS2_MEM_BASE + CONFIG_NIOS2_KERNEL_REGION_BASE)
32 * This gives the physical RAM offset.
34 #define PHYS_OFFSET CONFIG_NIOS2_MEM_BASE
37 * It's normally defined only for FLATMEM config but it's
38 * used in our early mem init code for all memory models.
39 * So always define it.
41 #define ARCH_PFN_OFFSET PFN_UP(PHYS_OFFSET)
43 #define clear_page(page) memset((page), 0, PAGE_SIZE)
44 #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
48 extern void clear_user_page(void *addr
, unsigned long vaddr
, struct page
*page
);
49 extern void copy_user_page(void *vto
, void *vfrom
, unsigned long vaddr
,
53 * These are used to make use of C type-checking.
55 typedef struct page
*pgtable_t
;
56 typedef struct { unsigned long pte
; } pte_t
;
57 typedef struct { unsigned long pgd
; } pgd_t
;
58 typedef struct { unsigned long pgprot
; } pgprot_t
;
60 #define pte_val(x) ((x).pte)
61 #define pgd_val(x) ((x).pgd)
62 #define pgprot_val(x) ((x).pgprot)
64 #define __pte(x) ((pte_t) { (x) })
65 #define __pgd(x) ((pgd_t) { (x) })
66 #define __pgprot(x) ((pgprot_t) { (x) })
68 extern unsigned long memory_start
;
69 extern unsigned long memory_end
;
70 extern unsigned long memory_size
;
72 extern struct page
*mem_map
;
75 ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET)
77 ((void *)((unsigned long)(x) + PAGE_OFFSET - PHYS_OFFSET))
79 #define page_to_virt(page) \
80 ((void *)(((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
82 # define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
84 # define virt_to_page(vaddr) pfn_to_page(PFN_DOWN(virt_to_phys(vaddr)))
85 # define virt_addr_valid(vaddr) pfn_valid(PFN_DOWN(virt_to_phys(vaddr)))
87 # define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
89 #include <asm-generic/memory_model.h>
91 #include <asm-generic/getorder.h>
93 #endif /* !__ASSEMBLY__ */
95 #endif /* _ASM_NIOS2_PAGE_H */