]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/asm-avr32/page.h
CONFIG_HIGHPTE vs. sub-page page tables.
[mirror_ubuntu-artful-kernel.git] / include / asm-avr32 / page.h
CommitLineData
5f97f7f9
HS
1/*
2 * Copyright (C) 2004-2006 Atmel Corporation
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 */
8#ifndef __ASM_AVR32_PAGE_H
9#define __ASM_AVR32_PAGE_H
10
5f97f7f9
HS
11/* PAGE_SHIFT determines the page size */
12#define PAGE_SHIFT 12
13#ifdef __ASSEMBLY__
14#define PAGE_SIZE (1 << PAGE_SHIFT)
15#else
16#define PAGE_SIZE (1UL << PAGE_SHIFT)
17#endif
18#define PAGE_MASK (~(PAGE_SIZE-1))
19#define PTE_MASK PAGE_MASK
20
21#ifndef __ASSEMBLY__
22
23#include <asm/addrspace.h>
24
25extern void clear_page(void *to);
26extern void copy_page(void *to, void *from);
27
28#define clear_user_page(page, vaddr, pg) clear_page(page)
29#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
30
31/*
32 * These are used to make use of C type-checking..
33 */
34typedef struct { unsigned long pte; } pte_t;
35typedef struct { unsigned long pgd; } pgd_t;
36typedef struct { unsigned long pgprot; } pgprot_t;
2f569afd 37typedef struct page *pgtable_t;
5f97f7f9
HS
38
39#define pte_val(x) ((x).pte)
40#define pgd_val(x) ((x).pgd)
41#define pgprot_val(x) ((x).pgprot)
42
43#define __pte(x) ((pte_t) { (x) })
44#define __pgd(x) ((pgd_t) { (x) })
45#define __pgprot(x) ((pgprot_t) { (x) })
46
47/* FIXME: These should be removed soon */
48extern unsigned long memory_start, memory_end;
49
50/* Pure 2^n version of get_order */
51static inline int get_order(unsigned long size)
52{
53 unsigned lz;
54
55 size = (size - 1) >> PAGE_SHIFT;
56 asm("clz %0, %1" : "=r"(lz) : "r"(size));
57 return 32 - lz;
58}
59
60#endif /* !__ASSEMBLY__ */
61
62/* Align the pointer to the (next) page boundary */
63#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
64
65/*
66 * The hardware maps the virtual addresses 0x80000000 -> 0x9fffffff
67 * permanently to the physical addresses 0x00000000 -> 0x1fffffff when
68 * segmentation is enabled. We want to make use of this in order to
69 * minimize TLB pressure.
70 */
71#define PAGE_OFFSET (0x80000000UL)
72
73/*
74 * ALSA uses virt_to_page() on DMA pages, which I'm not entirely sure
75 * is a good idea. Anyway, we can't simply subtract PAGE_OFFSET here
76 * in that case, so we'll have to mask out the three most significant
77 * bits of the address instead...
78 *
79 * What's the difference between __pa() and virt_to_phys() anyway?
80 */
81#define __pa(x) PHYSADDR(x)
82#define __va(x) ((void *)(P1SEGADDR(x)))
83
84#define MAP_NR(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> PAGE_SHIFT)
85
86#define phys_to_page(phys) (pfn_to_page(phys >> PAGE_SHIFT))
87#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
88
89#ifndef CONFIG_NEED_MULTIPLE_NODES
90
91#define PHYS_PFN_OFFSET (CONFIG_PHYS_OFFSET >> PAGE_SHIFT)
92
93#define pfn_to_page(pfn) (mem_map + ((pfn) - PHYS_PFN_OFFSET))
94#define page_to_pfn(page) ((unsigned long)((page) - mem_map) + PHYS_PFN_OFFSET)
95#define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr))
96#endif /* CONFIG_NEED_MULTIPLE_NODES */
97
98#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
99#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
100
101#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
102 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
103
104/*
105 * Memory above this physical address will be considered highmem.
106 */
107#define HIGHMEM_START 0x20000000UL
108
5f97f7f9 109#endif /* __ASM_AVR32_PAGE_H */