Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
3 * Copyright (C) 2004 Microtronix Datacom Ltd.
4 *
5 * MMU support based on asm/page.h from mips which is:
6 *
7 * Copyright (C) 1994 - 1999, 2000, 03 Ralf Baechle
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
9 *
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
12 * for more details.
13 */
14
15#ifndef _ASM_NIOS2_PAGE_H
16#define _ASM_NIOS2_PAGE_H
17
18#include <linux/pfn.h>
19#include <linux/const.h>
20
21#include <vdso/page.h>
22
23/*
24 * PAGE_OFFSET -- the first address of the first page of memory.
25 */
26#define PAGE_OFFSET \
27 (CONFIG_NIOS2_MEM_BASE + CONFIG_NIOS2_KERNEL_REGION_BASE)
28
29#ifndef __ASSEMBLER__
30
31/*
32 * This gives the physical RAM offset.
33 */
34#define PHYS_OFFSET CONFIG_NIOS2_MEM_BASE
35
36/*
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.
40 */
41#define ARCH_PFN_OFFSET PFN_UP(PHYS_OFFSET)
42
43#define clear_page(page) memset((page), 0, PAGE_SIZE)
44#define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
45
46struct page;
47
48extern void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
49extern void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
50 struct page *to);
51
52/*
53 * These are used to make use of C type-checking.
54 */
55typedef struct page *pgtable_t;
56typedef struct { unsigned long pte; } pte_t;
57typedef struct { unsigned long pgd; } pgd_t;
58typedef struct { unsigned long pgprot; } pgprot_t;
59
60#define pte_val(x) ((x).pte)
61#define pgd_val(x) ((x).pgd)
62#define pgprot_val(x) ((x).pgprot)
63
64#define __pte(x) ((pte_t) { (x) })
65#define __pgd(x) ((pgd_t) { (x) })
66#define __pgprot(x) ((pgprot_t) { (x) })
67
68extern unsigned long memory_start;
69extern unsigned long memory_end;
70extern unsigned long memory_size;
71
72extern struct page *mem_map;
73
74# define __pa(x) \
75 ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET)
76# define __va(x) \
77 ((void *)((unsigned long)(x) + PAGE_OFFSET - PHYS_OFFSET))
78
79#define page_to_virt(page) \
80 ((void *)(((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
81
82# define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
83
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)))
86
87# define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
88
89#include <asm-generic/memory_model.h>
90
91#include <asm-generic/getorder.h>
92
93#endif /* !__ASSEMBLER__ */
94
95#endif /* _ASM_NIOS2_PAGE_H */