aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-um/page.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-um/page.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/asm-um/page.h')
-rw-r--r--include/asm-um/page.h130
1 files changed, 130 insertions, 0 deletions
diff --git a/include/asm-um/page.h b/include/asm-um/page.h
new file mode 100644
index 000000000000..3620a08dc9f3
--- /dev/null
+++ b/include/asm-um/page.h
@@ -0,0 +1,130 @@
1/*
2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Copyright 2003 PathScale, Inc.
4 * Licensed under the GPL
5 */
6
7#ifndef __UM_PAGE_H
8#define __UM_PAGE_H
9
10struct page;
11
12#include <linux/config.h>
13#include <asm/vm-flags.h>
14
15/* PAGE_SHIFT determines the page size */
16#define PAGE_SHIFT 12
17#define PAGE_SIZE (1UL << PAGE_SHIFT)
18#define PAGE_MASK (~(PAGE_SIZE-1))
19
20/*
21 * These are used to make use of C type-checking..
22 */
23
24#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
25#define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
26
27#define clear_user_page(page, vaddr, pg) clear_page(page)
28#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
29
30#if defined(CONFIG_3_LEVEL_PGTABLES) && !defined(CONFIG_64_BIT)
31
32typedef struct { unsigned long pte_low, pte_high; } pte_t;
33typedef struct { unsigned long long pmd; } pmd_t;
34typedef struct { unsigned long pgd; } pgd_t;
35#define pte_val(x) ((x).pte_low | ((unsigned long long) (x).pte_high << 32))
36
37#define pte_get_bits(pte, bits) ((pte).pte_low & (bits))
38#define pte_set_bits(pte, bits) ((pte).pte_low |= (bits))
39#define pte_clear_bits(pte, bits) ((pte).pte_low &= ~(bits))
40#define pte_copy(to, from) ({ (to).pte_high = (from).pte_high; \
41 smp_wmb(); \
42 (to).pte_low = (from).pte_low; })
43#define pte_is_zero(pte) (!((pte).pte_low & ~_PAGE_NEWPAGE) && !(pte).pte_high)
44#define pte_set_val(pte, phys, prot) \
45 ({ (pte).pte_high = (phys) >> 32; \
46 (pte).pte_low = (phys) | pgprot_val(prot); })
47
48typedef unsigned long long pfn_t;
49typedef unsigned long long phys_t;
50
51#else
52
53typedef struct { unsigned long pte; } pte_t;
54typedef struct { unsigned long pgd; } pgd_t;
55
56#ifdef CONFIG_3_LEVEL_PGTABLES
57typedef struct { unsigned long pmd; } pmd_t;
58#define pmd_val(x) ((x).pmd)
59#define __pmd(x) ((pmd_t) { (x) } )
60#endif
61
62#define pte_val(x) ((x).pte)
63
64
65#define pte_get_bits(p, bits) ((p).pte & (bits))
66#define pte_set_bits(p, bits) ((p).pte |= (bits))
67#define pte_clear_bits(p, bits) ((p).pte &= ~(bits))
68#define pte_copy(to, from) ((to).pte = (from).pte)
69#define pte_is_zero(p) (!((p).pte & ~_PAGE_NEWPAGE))
70#define pte_set_val(p, phys, prot) (p).pte = (phys | pgprot_val(prot))
71
72typedef unsigned long pfn_t;
73typedef unsigned long phys_t;
74
75#endif
76
77typedef struct { unsigned long pgprot; } pgprot_t;
78
79#define pgd_val(x) ((x).pgd)
80#define pgprot_val(x) ((x).pgprot)
81
82#define __pte(x) ((pte_t) { (x) } )
83#define __pgd(x) ((pgd_t) { (x) } )
84#define __pgprot(x) ((pgprot_t) { (x) } )
85
86/* to align the pointer to the (next) page boundary */
87#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
88
89extern unsigned long uml_physmem;
90
91#define PAGE_OFFSET (uml_physmem)
92#define KERNELBASE PAGE_OFFSET
93
94#define __va_space (8*1024*1024)
95
96extern unsigned long to_phys(void *virt);
97extern void *to_virt(unsigned long phys);
98#define __pa(virt) to_phys((void *) virt)
99#define __va(phys) to_virt((unsigned long) phys)
100
101#define page_to_pfn(page) ((page) - mem_map)
102#define pfn_to_page(pfn) (mem_map + (pfn))
103
104#define phys_to_pfn(p) ((p) >> PAGE_SHIFT)
105#define pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT)
106
107#define pfn_valid(pfn) ((pfn) < max_mapnr)
108#define virt_addr_valid(v) pfn_valid(phys_to_pfn(__pa(v)))
109
110/* Pure 2^n version of get_order */
111static __inline__ int get_order(unsigned long size)
112{
113 int order;
114
115 size = (size-1) >> (PAGE_SHIFT-1);
116 order = -1;
117 do {
118 size >>= 1;
119 order++;
120 } while (size);
121 return order;
122}
123
124extern struct page *arch_validate(struct page *page, int mask, int order);
125#define HAVE_ARCH_VALIDATE
126
127extern void arch_free_page(struct page *page, int order);
128#define HAVE_ARCH_FREE_PAGE
129
130#endif